| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- package cn.com.goldenwater.dcproj.controller.tac;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.constValue.SplitValue;
- import cn.com.goldenwater.dcproj.dto.TacObjPblmstbClass;
- import cn.com.goldenwater.dcproj.dto.TacObjPblmstbClass2;
- import cn.com.goldenwater.dcproj.dto.TacObjPblmstbDto;
- import cn.com.goldenwater.dcproj.dto.TacPblmsSn;
- import cn.com.goldenwater.dcproj.model.TacObjPblmstb;
- import cn.com.goldenwater.dcproj.model.TacObjSubject;
- import cn.com.goldenwater.dcproj.param.TacObjPblmstbParam;
- import cn.com.goldenwater.dcproj.param.TacPblmClassParam;
- import cn.com.goldenwater.dcproj.service.TacObjPblmstbService;
- import cn.com.goldenwater.dcproj.service.TacObjSubjectService;
- import cn.com.goldenwater.dcproj.utils.InspUtils;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.Assert;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.time.LocalDateTime;
- import java.util.Date;
- import java.util.List;
- /**
- * @author lune
- * @date 2019-6-19
- */
- @Api(value = "TAC 稽察问题标准库管理", tags = "TAC 稽察问题标准库管理")
- @RestController
- @RequestMapping("/tac/obj/pblmstb")
- public class TacObjPblmstbController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacObjPblmstbService tacObjPblmstbService;
- @Autowired
- private TacObjSubjectService tacObjSubjectService;
- @ApiOperation(value = "添加/修改稽察问题标准库")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacObjPblmstb> insert(@ApiParam(name = "tacObjPblmstb", value = "TacObjPblmstb", required = true) @RequestBody TacObjPblmstb tacObjPblmstb) {
- if (StringUtils.isBlank(tacObjPblmstb.getPersId())) {
- String persId = this.getCurrentPersId();
- tacObjPblmstb.setPersId(persId);
- }
- if (StringUtils.isBlank(tacObjPblmstb.getYear())) {
- tacObjPblmstb.setYear(LocalDateTime.now().getYear() + "");
- }
- if (StringUtils.isNotBlank(tacObjPblmstb.getPblmChType())) {
- tacObjPblmstb.setSpfsnlType(InspUtils.getSpfsnlType(tacObjPblmstb.getPblmChType()));
- tacObjPblmstb.setPblmType(InspUtils.getPblmType(tacObjPblmstb.getPblmChType()));
- }
- // tacObjPblmstb.setPersId(getCurrentPersId());
- if (StringUtils.isNotBlank(tacObjPblmstb.getId())) {
- tacObjPblmstb.setUptm(new Date());
- // sn 的值包含非数字 sort_no字段 排序就会报错
- // if (StringUtils.isNotBlank(tacObjPblmstb.getSn())) {
- // tacObjPblmstb.setSortNo(InspUtils.getBySn(tacObjPblmstb.getSn()));
- // }
- tacObjPblmstbService.update(tacObjPblmstb);
- } else {
- // 修改 默认 已审核
- tacObjPblmstb.setDataStat("1");
- String uuid = UuidUtil.uuid();
- tacObjPblmstb.setId(uuid);
- if (StringUtils.isBlank(tacObjPblmstb.getSortNo())) {
- tacObjPblmstb.setSortNo("0");
- }
- tacObjPblmstb.setIntm(new Date());
- tacObjPblmstbService.insert(tacObjPblmstb);
- }
- return buildSuccessResponse(tacObjPblmstb);
- }
- @ApiOperation(value = "根据ID删除稽察问题标准库")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = tacObjPblmstbService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "更新稽察问题标准库信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse<TacObjPblmstb> update(@ApiParam(name = "tacObjPblmstb", value = "TacObjPblmstb", required = true) @RequestBody TacObjPblmstb tacObjPblmstb) {
- Assert.notNull(tacObjPblmstb.getId(), "主键id为必填参数");
- if (StringUtils.isBlank(tacObjPblmstb.getPersId())) {
- String persId = this.getCurrentPersId();
- tacObjPblmstb.setPersId(persId);
- }
- int ret = tacObjPblmstbService.update(tacObjPblmstb);
- return buildSuccessResponse(tacObjPblmstb);
- }
- @ApiOperation(value = "根据ID获取稽察问题标准库(单表)包含所带主责主体单位类型")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacObjPblmstb> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacObjPblmstb tacObjPblmstb = tacObjPblmstbService.getOne(id);
- return buildSuccessResponse(tacObjPblmstb);
- }
- @ApiOperation(value = "分页查询稽察问题清单")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacObjPblmstb>> page(@RequestBody TacObjPblmstbParam pblmInfoParam) {
- if (StringUtils.isBlank(pblmInfoParam.getPersId())) {
- pblmInfoParam.setPersId(getCurrentPersId());
- }
- // if (StringUtils.isBlank(pblmInfoParam.getYear())) {
- // pblmInfoParam.setYear(LocalDateTime.now().getYear() + "");
- // }
- if (StringUtils.isBlank(pblmInfoParam.getDataStat())) {
- pblmInfoParam.setDataStat("1");
- }
- pblmInfoParam.setYear(LocalDateTime.now().getYear() + "");
- PageInfo<TacObjPblmstb> tacPawpRgstrList = tacObjPblmstbService.findPblmsPageinfo(pblmInfoParam);
- for (TacObjPblmstb tac : tacPawpRgstrList.getList()) {
- if (StringUtils.isBlank(tac.getSubjectIds())) {
- continue;
- }
- if (tac.getSubjectIds().contains(SplitValue.DOUHAO_SPLIT)) {
- String[] arrays = tac.getSubjectIds().split(SplitValue.DOUHAO_SPLIT);
- StringBuilder buffer = new StringBuilder();
- if (arrays.length > 0) {
- for (String str : arrays) {
- if (StringUtils.isNotBlank(str)) {
- TacObjSubject tacObjSubject = tacObjSubjectService.getOne(str);
- if (tacObjSubject != null) {
- buffer.append(tacObjSubject.getSubName()).append(SplitValue.DOUHAO_SPLIT);
- }
- }
- }
- tac.setSubName(buffer.toString());
- }
- }
- }
- return buildSuccessResponse(tacPawpRgstrList);
- }
- @ApiOperation(value = "根据ID批量删除问题清单")
- @RequestMapping(value = "/delList", method = RequestMethod.POST)
- public BaseResponse delList(@ApiParam(name = "ids", value = "ids", required = true) @RequestBody List<String> ids) {
- int ret = tacObjPblmstbService.delList(ids);
- return buildSuccessResponse(ret);
- }
- @ApiOperation(value = "根据ID批量更新问题标准的库别(问题大类小类)")
- @RequestMapping(value = "/updateList", method = RequestMethod.POST)
- public BaseResponse updateList(@ApiParam(name = "TacPblmClassParam", value = "TacPblmClassParam", required = true)
- @RequestBody TacPblmClassParam tacPblmClassParam) {
- int ret = tacObjPblmstbService.updateList(tacPblmClassParam);
- return buildSuccessResponse(ret);
- }
- @ApiOperation(value = "稽察问题标准树形结构")
- @RequestMapping(value = "/tree", method = RequestMethod.POST)
- public BaseResponse<List<TacObjPblmstbDto>> tree() {
- List<TacObjPblmstbDto> objPblmstbDtoList = tacObjPblmstbService.findSpfsnlType(getCurrentPersId(), LocalDateTime.now().getYear() + "");
- for (TacObjPblmstbDto pblmstbDto : objPblmstbDtoList) {
- List<TacObjPblmstbClass> pblmstbClasses = tacObjPblmstbService.findClass1ByType(pblmstbDto.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
- if (pblmstbClasses != null) {
- pblmstbDto.setChildren(pblmstbClasses);
- for (TacObjPblmstbClass tacObjPblmstbClass : pblmstbClasses) {
- List<TacObjPblmstbClass2> children2 = tacObjPblmstbService.findClass2ByClass1(pblmstbDto.getClass1(), tacObjPblmstbClass.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
- if (children2 != null) {
- tacObjPblmstbClass.setChildren(children2);
- for (TacObjPblmstbClass2 class2 : children2) {
- List<TacPblmsSn> children3 = tacObjPblmstbService.findClass3ByTypeClass1Class2(pblmstbDto.getClass1(),
- tacObjPblmstbClass.getClass1(), class2.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
- if (children3 != null) {
- class2.setChildren(children3);
- }
- }
- }
- }
- }
- }
- return buildSuccessResponse(objPblmstbDtoList);
- }
- @ApiOperation(value = "上传接口")
- @RequestMapping(value = "/upload", method = {RequestMethod.GET, RequestMethod.POST})
- public BaseResponse upload(MultipartFile file) {
- tacObjPblmstbService.upload(file);
- return buildSuccessResponse();
- }
- }
|