f75a30bc4cbfad7feed8c2e532ad00417e0d63fd.svn-base 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package cn.com.goldenwater.dcproj.controller.tac;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  5. import cn.com.goldenwater.dcproj.dto.TacObjPblmstbClass;
  6. import cn.com.goldenwater.dcproj.dto.TacObjPblmstbClass2;
  7. import cn.com.goldenwater.dcproj.dto.TacObjPblmstbDto;
  8. import cn.com.goldenwater.dcproj.dto.TacPblmsSn;
  9. import cn.com.goldenwater.dcproj.model.TacObjPblmstb;
  10. import cn.com.goldenwater.dcproj.model.TacObjSubject;
  11. import cn.com.goldenwater.dcproj.param.TacObjPblmstbParam;
  12. import cn.com.goldenwater.dcproj.param.TacPblmClassParam;
  13. import cn.com.goldenwater.dcproj.service.TacObjPblmstbService;
  14. import cn.com.goldenwater.dcproj.service.TacObjSubjectService;
  15. import cn.com.goldenwater.dcproj.utils.InspUtils;
  16. import cn.com.goldenwater.id.util.UuidUtil;
  17. import com.github.pagehelper.PageInfo;
  18. import io.swagger.annotations.Api;
  19. import io.swagger.annotations.ApiOperation;
  20. import io.swagger.annotations.ApiParam;
  21. import org.apache.commons.lang3.StringUtils;
  22. import org.slf4j.Logger;
  23. import org.slf4j.LoggerFactory;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.util.Assert;
  26. import org.springframework.web.bind.annotation.*;
  27. import org.springframework.web.multipart.MultipartFile;
  28. import java.time.LocalDateTime;
  29. import java.util.Date;
  30. import java.util.List;
  31. /**
  32. * @author lune
  33. * @date 2019-6-19
  34. */
  35. @Api(value = "TAC 稽察问题标准库管理", tags = "TAC 稽察问题标准库管理")
  36. @RestController
  37. @RequestMapping("/tac/obj/pblmstb")
  38. public class TacObjPblmstbController extends BaseController {
  39. private Logger logger = LoggerFactory.getLogger(getClass());
  40. @Autowired
  41. private TacObjPblmstbService tacObjPblmstbService;
  42. @Autowired
  43. private TacObjSubjectService tacObjSubjectService;
  44. @ApiOperation(value = "添加/修改稽察问题标准库")
  45. @RequestMapping(value = "", method = RequestMethod.POST)
  46. public BaseResponse<TacObjPblmstb> insert(@ApiParam(name = "tacObjPblmstb", value = "TacObjPblmstb", required = true) @RequestBody TacObjPblmstb tacObjPblmstb) {
  47. if (StringUtils.isBlank(tacObjPblmstb.getPersId())) {
  48. String persId = this.getCurrentPersId();
  49. tacObjPblmstb.setPersId(persId);
  50. }
  51. if (StringUtils.isBlank(tacObjPblmstb.getYear())) {
  52. tacObjPblmstb.setYear(LocalDateTime.now().getYear() + "");
  53. }
  54. if (StringUtils.isNotBlank(tacObjPblmstb.getPblmChType())) {
  55. tacObjPblmstb.setSpfsnlType(InspUtils.getSpfsnlType(tacObjPblmstb.getPblmChType()));
  56. tacObjPblmstb.setPblmType(InspUtils.getPblmType(tacObjPblmstb.getPblmChType()));
  57. }
  58. // tacObjPblmstb.setPersId(getCurrentPersId());
  59. if (StringUtils.isNotBlank(tacObjPblmstb.getId())) {
  60. tacObjPblmstb.setUptm(new Date());
  61. // sn 的值包含非数字 sort_no字段 排序就会报错
  62. // if (StringUtils.isNotBlank(tacObjPblmstb.getSn())) {
  63. // tacObjPblmstb.setSortNo(InspUtils.getBySn(tacObjPblmstb.getSn()));
  64. // }
  65. tacObjPblmstbService.update(tacObjPblmstb);
  66. } else {
  67. // 修改 默认 已审核
  68. tacObjPblmstb.setDataStat("1");
  69. String uuid = UuidUtil.uuid();
  70. tacObjPblmstb.setId(uuid);
  71. if (StringUtils.isBlank(tacObjPblmstb.getSortNo())) {
  72. tacObjPblmstb.setSortNo("0");
  73. }
  74. tacObjPblmstb.setIntm(new Date());
  75. tacObjPblmstbService.insert(tacObjPblmstb);
  76. }
  77. return buildSuccessResponse(tacObjPblmstb);
  78. }
  79. @ApiOperation(value = "根据ID删除稽察问题标准库")
  80. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  81. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  82. int ret = tacObjPblmstbService.delete(id);
  83. return buildSuccessResponse();
  84. }
  85. @ApiOperation(value = "更新稽察问题标准库信息")
  86. @RequestMapping(value = "/update", method = RequestMethod.POST)
  87. public BaseResponse<TacObjPblmstb> update(@ApiParam(name = "tacObjPblmstb", value = "TacObjPblmstb", required = true) @RequestBody TacObjPblmstb tacObjPblmstb) {
  88. Assert.notNull(tacObjPblmstb.getId(), "主键id为必填参数");
  89. if (StringUtils.isBlank(tacObjPblmstb.getPersId())) {
  90. String persId = this.getCurrentPersId();
  91. tacObjPblmstb.setPersId(persId);
  92. }
  93. int ret = tacObjPblmstbService.update(tacObjPblmstb);
  94. return buildSuccessResponse(tacObjPblmstb);
  95. }
  96. @ApiOperation(value = "根据ID获取稽察问题标准库(单表)包含所带主责主体单位类型")
  97. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  98. public BaseResponse<TacObjPblmstb> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  99. TacObjPblmstb tacObjPblmstb = tacObjPblmstbService.getOne(id);
  100. return buildSuccessResponse(tacObjPblmstb);
  101. }
  102. @ApiOperation(value = "分页查询稽察问题清单")
  103. @RequestMapping(value = "/page", method = RequestMethod.POST)
  104. public BaseResponse<PageInfo<TacObjPblmstb>> page(@RequestBody TacObjPblmstbParam pblmInfoParam) {
  105. if (StringUtils.isBlank(pblmInfoParam.getPersId())) {
  106. pblmInfoParam.setPersId(getCurrentPersId());
  107. }
  108. // if (StringUtils.isBlank(pblmInfoParam.getYear())) {
  109. // pblmInfoParam.setYear(LocalDateTime.now().getYear() + "");
  110. // }
  111. if (StringUtils.isBlank(pblmInfoParam.getDataStat())) {
  112. pblmInfoParam.setDataStat("1");
  113. }
  114. pblmInfoParam.setYear(LocalDateTime.now().getYear() + "");
  115. PageInfo<TacObjPblmstb> tacPawpRgstrList = tacObjPblmstbService.findPblmsPageinfo(pblmInfoParam);
  116. for (TacObjPblmstb tac : tacPawpRgstrList.getList()) {
  117. if (StringUtils.isBlank(tac.getSubjectIds())) {
  118. continue;
  119. }
  120. if (tac.getSubjectIds().contains(SplitValue.DOUHAO_SPLIT)) {
  121. String[] arrays = tac.getSubjectIds().split(SplitValue.DOUHAO_SPLIT);
  122. StringBuilder buffer = new StringBuilder();
  123. if (arrays.length > 0) {
  124. for (String str : arrays) {
  125. if (StringUtils.isNotBlank(str)) {
  126. TacObjSubject tacObjSubject = tacObjSubjectService.getOne(str);
  127. if (tacObjSubject != null) {
  128. buffer.append(tacObjSubject.getSubName()).append(SplitValue.DOUHAO_SPLIT);
  129. }
  130. }
  131. }
  132. tac.setSubName(buffer.toString());
  133. }
  134. }
  135. }
  136. return buildSuccessResponse(tacPawpRgstrList);
  137. }
  138. @ApiOperation(value = "根据ID批量删除问题清单")
  139. @RequestMapping(value = "/delList", method = RequestMethod.POST)
  140. public BaseResponse delList(@ApiParam(name = "ids", value = "ids", required = true) @RequestBody List<String> ids) {
  141. int ret = tacObjPblmstbService.delList(ids);
  142. return buildSuccessResponse(ret);
  143. }
  144. @ApiOperation(value = "根据ID批量更新问题标准的库别(问题大类小类)")
  145. @RequestMapping(value = "/updateList", method = RequestMethod.POST)
  146. public BaseResponse updateList(@ApiParam(name = "TacPblmClassParam", value = "TacPblmClassParam", required = true)
  147. @RequestBody TacPblmClassParam tacPblmClassParam) {
  148. int ret = tacObjPblmstbService.updateList(tacPblmClassParam);
  149. return buildSuccessResponse(ret);
  150. }
  151. @ApiOperation(value = "稽察问题标准树形结构")
  152. @RequestMapping(value = "/tree", method = RequestMethod.POST)
  153. public BaseResponse<List<TacObjPblmstbDto>> tree() {
  154. List<TacObjPblmstbDto> objPblmstbDtoList = tacObjPblmstbService.findSpfsnlType(getCurrentPersId(), LocalDateTime.now().getYear() + "");
  155. for (TacObjPblmstbDto pblmstbDto : objPblmstbDtoList) {
  156. List<TacObjPblmstbClass> pblmstbClasses = tacObjPblmstbService.findClass1ByType(pblmstbDto.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
  157. if (pblmstbClasses != null) {
  158. pblmstbDto.setChildren(pblmstbClasses);
  159. for (TacObjPblmstbClass tacObjPblmstbClass : pblmstbClasses) {
  160. List<TacObjPblmstbClass2> children2 = tacObjPblmstbService.findClass2ByClass1(pblmstbDto.getClass1(), tacObjPblmstbClass.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
  161. if (children2 != null) {
  162. tacObjPblmstbClass.setChildren(children2);
  163. for (TacObjPblmstbClass2 class2 : children2) {
  164. List<TacPblmsSn> children3 = tacObjPblmstbService.findClass3ByTypeClass1Class2(pblmstbDto.getClass1(),
  165. tacObjPblmstbClass.getClass1(), class2.getClass1(), getCurrentPersId(), LocalDateTime.now().getYear() + "");
  166. if (children3 != null) {
  167. class2.setChildren(children3);
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. return buildSuccessResponse(objPblmstbDtoList);
  175. }
  176. @ApiOperation(value = "上传接口")
  177. @RequestMapping(value = "/upload", method = {RequestMethod.GET, RequestMethod.POST})
  178. public BaseResponse upload(MultipartFile file) {
  179. tacObjPblmstbService.upload(file);
  180. return buildSuccessResponse();
  181. }
  182. }