ce4b544a172b0f3d5b1a875b8e279583339cb0a5.svn-base 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package cn.com.goldenwater.dcproj.controller.plansd;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dto.*;
  5. import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
  6. import cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd;
  7. import cn.com.goldenwater.dcproj.param.BisInspGroupArrangementParam;
  8. import cn.com.goldenwater.dcproj.param.BisInspPlanDtlAddvcdParam;
  9. import cn.com.goldenwater.dcproj.service.*;
  10. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  11. import cn.com.goldenwater.dcproj.utils.Constant;
  12. import cn.com.goldenwater.dcproj.utils.DateUtils;
  13. import cn.com.goldenwater.dcproj.utils.StringUtils;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import io.swagger.annotations.ApiParam;
  17. import org.apache.commons.collections.CollectionUtils;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.util.Assert;
  22. import org.springframework.web.bind.annotation.*;
  23. import java.util.ArrayList;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Optional;
  27. import java.util.stream.Collectors;
  28. /**
  29. * @author hjp
  30. * @date 2022-8-9
  31. */
  32. @Api(value = "山东详细分组安排管理", tags = "山东详细分组安排管理")
  33. @RestController
  34. @RequestMapping("/bis/insp/plan/ga")
  35. public class BisInspGroupArrangementController extends BaseController {
  36. private Logger logger = LoggerFactory.getLogger(getClass());
  37. @Autowired
  38. private BisInspGroupArrangementService bisInspGroupArrangementService;
  39. @Autowired
  40. private BisInspAllRlationPersService bisInspAllRlationPersService;
  41. @Autowired
  42. private BisInspPlanDpService bisInspPlanDpService;
  43. @Autowired
  44. private OlBisInspOrgService olBisInspOrgService;
  45. @Autowired
  46. private BisInspPlanDtlAddvcdService bisInspPlanDtlAddvcdService;
  47. @Autowired
  48. private AttAdBaseService attAdBaseService;
  49. @ApiOperation(value = "获取详细分组安排列表")
  50. @RequestMapping(value = "/list", method = RequestMethod.POST)
  51. public BaseResponse<List<PlanAllInfoDto>> list(@RequestBody BisInspGroupArrangementParam param) {
  52. param.setOrgId(getCurrentOrgId());
  53. BisInspAllRlationPers byId = bisInspAllRlationPersService.getById(getCurrentPersId());
  54. String planDpId = byId.getPlanDpId();
  55. if (StringUtils.isBlank(planDpId)){
  56. return buildSuccessResponse(new ArrayList<>());
  57. }
  58. Optional.ofNullable(bisInspPlanDpService.get(planDpId)).ifPresent(dp ->{
  59. if (!StringUtils.equals(Constant.STRING_TWO,dp.getDpType())){
  60. param.setPlanDpId(dp.getId());
  61. param.setDdAdCode(AdLevelUtil.getAddvcd(olBisInspOrgService.getRlProvince(getCurrentOrgId())));
  62. }
  63. });
  64. return buildSuccessResponse(this.bisInspGroupArrangementService.getAllInfoByPnmAndTypeAndOrgId(param));
  65. }
  66. @ApiOperation(value = "添加分组")
  67. @RequestMapping(value = "/add", method = RequestMethod.POST)
  68. public BaseResponse<?> add(@RequestBody PlanAllAddDto dto) {
  69. Assert.notNull(dto.getDtlId(), "检查年度计划分解ID为必填参数");
  70. Assert.notNull(dto.getTypeList(),"类别IDS为必填参数");
  71. dto.setOrgId(getCurrentOrgId());
  72. dto.setPersId(getCurrentPersId());
  73. Optional.ofNullable(bisInspAllRlationPersService.get(getCurrentPersId())).ifPresent(b -> dto.setPlanDpId(b.getPlanDpId()));
  74. //判断是否重复创建
  75. if (null != dto.getDetermine() && !dto.getDetermine()) {
  76. Assert.notNull(dto.getStTm(), "开始时间为必填参数");
  77. Assert.notNull(dto.getEnTm(), "结束时间为必填参数");
  78. // true 表示 有重复计划 false 表示没有
  79. BisInspPlanDtlDto bisInspPlanDtlDto = new BisInspPlanDtlDto();
  80. bisInspPlanDtlDto.setEnTm(DateUtils.Str2Date(dto.getEnTm()));
  81. bisInspPlanDtlDto.setStTm(DateUtils.Str2Date(dto.getStTm()));
  82. Optional.ofNullable(bisInspPlanDtlAddvcdService.findList(new BisInspPlanDtlAddvcdParam(dto.getDtlId()))).ifPresent(l -> bisInspPlanDtlDto.setdAdCodes(l.stream().map(BisInspPlanDtlAddvcd::getAdCode).collect(Collectors.toList())));
  83. // 2024/1/29 modify by lxf
  84. // 督察计划 有个地区检查规则, 原来的是同一个区县不允许有两个以上检查组同时检查,这个规则修改下:一周内,到同一个市的督察检查组不能超过一个
  85. List<Map<String, String>> byAdCodeAndTm = bisInspPlanDtlAddvcdService.getByAdCodeAndTm(bisInspPlanDtlDto);
  86. BaseResponse response = buildFailResponse(String.valueOf(CollectionUtils.isNotEmpty(byAdCodeAndTm)));
  87. if(CollectionUtils.isNotEmpty(byAdCodeAndTm)){
  88. String hasAdCodes = byAdCodeAndTm.stream().map(m->m.get("AD_CODE").substring(0,4)).collect(Collectors.joining("','","'","'"));
  89. List<BisInspPlanDtlDto> byAdCodeAndTmList = bisInspPlanDtlAddvcdService.getByAdCodeAndTmList(hasAdCodes, bisInspPlanDtlDto);
  90. response.setData(byAdCodeAndTmList);
  91. }
  92. return response;
  93. }
  94. this.bisInspGroupArrangementService.add(dto);
  95. return buildSuccessResponse();
  96. }
  97. @ApiOperation(value = "编辑所有分组基本信息")
  98. @RequestMapping(value = "/upInfo", method = RequestMethod.POST)
  99. public BaseResponse<?> upInfo(@RequestBody PlanAllUpDto dto) {
  100. Assert.notNull(dto.getIds(), "组ids为必填参数");
  101. dto.setOrgId(getCurrentOrgId());
  102. this.bisInspGroupArrangementService.updateInfo(dto);
  103. return buildSuccessResponse();
  104. }
  105. @ApiOperation(value = "编辑分组类别人员 对象")
  106. @RequestMapping(value = "/up", method = RequestMethod.POST)
  107. public BaseResponse<?> up(@RequestBody PlanAllUpDto dto) {
  108. Assert.notNull(dto.getDtlId(), "检查年度计划分解ID为必填参数");
  109. Assert.notNull(dto.getId(), "组 ID 为必填参数");
  110. Assert.notNull(dto.getpType(), "督查类别为必填参数");
  111. dto.setOrgId(getCurrentOrgId());
  112. this.bisInspGroupArrangementService.update(dto);
  113. return buildSuccessResponse();
  114. }
  115. @ApiOperation(value = "删除分组信息")
  116. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  117. public BaseResponse<?> del(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  118. this.bisInspGroupArrangementService.cleanGroupInfo(id, getCurrentOrgId(),getCurrentPersId());
  119. return buildSuccessResponse();
  120. }
  121. @ApiOperation(value = "删除所有类别分组信息")
  122. @RequestMapping(value = "/delAll/{ids}", method = RequestMethod.GET)
  123. public BaseResponse<?> delAll(@ApiParam(name = "ids", value = "ids", required = true) @PathVariable String ids) {
  124. this.bisInspGroupArrangementService.delAll(ids, getCurrentOrgId(),getCurrentPersId());
  125. return buildSuccessResponse();
  126. }
  127. @ApiOperation(value = "删除单个组人员")
  128. @RequestMapping(value = "/delSinglePersonnel", method = RequestMethod.POST)
  129. public BaseResponse<?> delSinglePersonnel(@RequestBody PlanAllDelDto dto) {
  130. Assert.notNull(dto.getGroupId(), "组Id为必填参数");
  131. Assert.notNull(dto.getDelId(), "人员Id为必填参数");
  132. this.bisInspGroupArrangementService.delSinglePersonnel(dto);
  133. return buildSuccessResponse();
  134. }
  135. @ApiOperation(value = "删除单个组对象")
  136. @RequestMapping(value = "/delSingleObject", method = RequestMethod.POST)
  137. public BaseResponse<?> delSingleObject(@RequestBody PlanAllDelDto dto) {
  138. Assert.notNull(dto.getGroupId(), "组Id为必填参数");
  139. Assert.notNull(dto.getDelId(), "对象Id为必填参数");
  140. this.bisInspGroupArrangementService.delSingleObject(dto);
  141. return buildSuccessResponse();
  142. }
  143. }