20e1fc3d163a1e6c96873c12a4c5f607e8bdcd41.svn-base 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. package cn.com.goldenwater.dcproj.controller.ducha;
  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.OlBisInspOrg;
  6. import cn.com.goldenwater.dcproj.param.InGroupResParam;
  7. import cn.com.goldenwater.dcproj.param.InspObjParam;
  8. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  9. import cn.com.goldenwater.dcproj.service.SupervisionPlanService;
  10. import cn.com.goldenwater.dcproj.util.CheckUtil;
  11. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  12. import cn.com.goldenwater.dcproj.utils.TimeRangeUtil;
  13. import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
  14. import com.alibaba.fastjson.JSON;
  15. import com.github.pagehelper.PageInfo;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import io.swagger.annotations.ApiParam;
  19. import org.apache.commons.lang.StringUtils;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.beans.factory.annotation.Value;
  22. import org.springframework.web.bind.annotation.*;
  23. import org.springframework.web.multipart.MultipartFile;
  24. import javax.servlet.http.HttpServletRequest;
  25. import javax.servlet.http.HttpServletResponse;
  26. import java.io.File;
  27. import java.text.ParseException;
  28. import java.text.SimpleDateFormat;
  29. import java.util.ArrayList;
  30. import java.util.HashMap;
  31. import java.util.List;
  32. import java.util.Map;
  33. /**
  34. * Created by 61618 on 2019/4/17.
  35. */
  36. @Api(value = "督查计划相关接口", tags = "督查计划相关接口")
  37. @RestController
  38. @RequestMapping("/supervision/plan")
  39. public class SupervisionPlanController extends BaseController {
  40. @Autowired
  41. private SupervisionPlanService supervisionPlanService;
  42. @Value("${export.templatePath}")
  43. private String templatePath;
  44. @Value("${impExcel.basePath}")
  45. private String impExcelPath;
  46. @Autowired
  47. private OlBisInspOrgService olBisInspOrgService;
  48. private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  49. @ApiOperation(value = "根据用户信息与督查计划类型获取该用户可示可管理的单一机构的所有批次")
  50. @RequestMapping(value = "getNodeByPersid", method = RequestMethod.GET)
  51. public BaseResponse<List<AllNodeDto>> getNodeByPersid(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
  52. @ApiParam(name = "ptype", value = "ptype", required = true) @RequestParam String ptype) {
  53. List<AllNodeDto> allNodeDtoList = this.supervisionPlanService.getNodeByPersid(persid, ptype, getCurrentOrgId());
  54. return buildSuccessResponse(allNodeDtoList);
  55. }
  56. @ApiOperation(value = "获取督查组相关的对象、人员、区域信息(新)")
  57. @RequestMapping(value = "getAllInfoByPersidAndOrgId", method = RequestMethod.GET)
  58. public BaseResponse<List<PersAllInfoDto>> getAllInfoByPersidAndOrgId(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
  59. @ApiParam(name = "inspYear", value = "inspYear", required = false) @RequestParam(required = false) String inspYear,
  60. @ApiParam(name = "inspMnth", value = "inspMnth", required = false) @RequestParam(required = false) String inspMnth,
  61. @ApiParam(name = "orgId", value = "机构id", required = true) @RequestParam String orgId,
  62. @ApiParam(name = "yearPlanId", value = "年度id", required = true) @RequestParam String yearPlanId) {
  63. List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersidAndOrgId(persid, inspYear, inspMnth, orgId, yearPlanId);
  64. return buildSuccessResponse(allNodeDtoList);
  65. }
  66. @ApiOperation(value = "根据组id查询督查区域")
  67. @RequestMapping(value = "/getPersAllAreaDtoList", method = RequestMethod.POST)
  68. public BaseResponse<List<PersAllAreaDto>> getPersAllAreaDtoList(@PathVariable String id) {
  69. List<PersAllAreaDto> dtos = this.supervisionPlanService.getPersAllAreaDtoList(id, getCurrentOrgId());
  70. return buildSuccessResponse(dtos);
  71. }
  72. @ApiOperation(value = "获取督查组相关的对象、人员、区域信息")
  73. @RequestMapping(value = "getAllInfoByPersid", method = RequestMethod.GET)
  74. public BaseResponse<List<PersAllInfoDto>> getAllInfoByPersid(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
  75. @ApiParam(name = "ptype", value = "ptype", required = true) @RequestParam String ptype,
  76. @ApiParam(name = "id", value = "id", required = true) @RequestParam String id) {
  77. List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersid(persid, ptype, id, getCurrentOrgId());
  78. return buildSuccessResponse(allNodeDtoList);
  79. }
  80. @ApiOperation(value = "查询不在该督查组下的水库", notes = "查询不在该督查组下的水库")
  81. @RequestMapping(value = "/getSupResByGroup", method = RequestMethod.POST)
  82. public BaseResponse<PageInfo<AttSupResBase>> getSupResByGroup(@RequestBody InGroupResParam inGroupResParam) {
  83. inGroupResParam.setProvince(olBisInspOrgService.getProvinceFlag(getCurrentOrgId()));
  84. inGroupResParam.setOrgId(getCurrentOrgId());
  85. PageInfo<AttSupResBase> list = supervisionPlanService.getSupResByGroup(inGroupResParam);
  86. return buildSuccessResponse(list);
  87. }
  88. @ApiOperation(value = "查询不在督查组督查范围内的督查对象")
  89. @RequestMapping(value = "/getSupObjListNotInspGroupId", method = RequestMethod.GET)
  90. public BaseResponse<Object> getSupObjListNotInspGroupId(@ApiParam(name = "InspObjParam", value = "InspObjParam") InspObjParam inspObjParam) {
  91. OlBisInspOrg org = olBisInspOrgService.get(getCurrentOrgId());
  92. CheckUtil.notNull(org, "机构ID错误", getCurrentOrgId());
  93. inspObjParam.setProvince(AdLevelUtil.getAddvcd(org.getAdCode()));
  94. inspObjParam.setOrgId(getCurrentOrgId());
  95. if (StringUtils.isNotBlank(inspObjParam.getOrderBy()) && inspObjParam.getOrderBy().contains("undefined")) {
  96. inspObjParam.setOrderBy("");
  97. }
  98. PageInfo pageInfo = supervisionPlanService.getSupObjListNotInspGroupId(inspObjParam);
  99. return buildSuccessResponse(pageInfo);
  100. }
  101. @ApiOperation(value = "添加督查人员、督查对象、督查区域")
  102. @RequestMapping(value = "/insertSupervisionObj", method = RequestMethod.POST)
  103. public BaseResponse<Object> insertSupervisionObj(@ApiParam(name = "PersAllInfoDto", value = "PersAllInfoDto") @RequestBody PersAllInfoDto persAllInfoDto) {
  104. if((StringUtils.isNotBlank(persAllInfoDto.getSttm()) || StringUtils.isNotBlank(persAllInfoDto.getEntm())) && StringUtils.isBlank(persAllInfoDto.getIsInsert())){
  105. Map<String,Object> map = isValiTm(persAllInfoDto);
  106. if(map.get("msg")!=null){
  107. return buildSuccessResponse(map);
  108. }
  109. }
  110. persAllInfoDto.setOrgId(getCurrentOrgId());
  111. persAllInfoDto.setPersid(getCurrentPersId());
  112. persAllInfoDto.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
  113. SupInsertResult supInsertResult = supervisionPlanService.insertSupervisionObj(persAllInfoDto);
  114. return buildSuccessResponse(supInsertResult);
  115. }
  116. public Map<String,Object> isValiTm(PersAllInfoDto persAllInfoDto){
  117. String msg = "";
  118. Map<String,Object> map = new HashMap<>();
  119. Map<String, String> mapGroup = supervisionPlanService.getYearMonth(persAllInfoDto.getId());
  120. if(StringUtils.isNotBlank(persAllInfoDto.getSttm())){
  121. mapGroup.put("STTM",persAllInfoDto.getSttm());
  122. }
  123. if(StringUtils.isNotBlank(persAllInfoDto.getEntm())){
  124. mapGroup.put("ENTM",persAllInfoDto.getEntm());
  125. }
  126. List<String> adCodeList = new ArrayList<String>();
  127. List<String> errorList = new ArrayList<String>();
  128. List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersidAndOrgId(getCurrentPersId(), mapGroup.get("INSP_YEAR"), mapGroup.get("INSP_MNTH"), getCurrentOrgId(), null);
  129. if (allNodeDtoList != null && allNodeDtoList.size() > 0 && (StringUtils.isNotBlank(mapGroup.get("STTM")) || StringUtils.isNotBlank(mapGroup.get("ENTM")))) {
  130. allNodeDtoList.forEach(item -> {
  131. if (persAllInfoDto.getId().equals(item.getId()) && item.getPersAllAreaDtoList() != null && item.getPersAllAreaDtoList().size() > 0) {
  132. item.getPersAllAreaDtoList().forEach(item1 -> {
  133. adCodeList.add(item1.getAdCode());
  134. });
  135. }
  136. });
  137. if (adCodeList.size() > 0) {
  138. allNodeDtoList.forEach(item -> {
  139. long count = 0;
  140. if (!persAllInfoDto.getId().equals(item.getId()) && item.getPersAllAreaDtoList() != null && item.getPersAllAreaDtoList().size() > 0) {
  141. count = item.getPersAllAreaDtoList().stream().filter(item1 -> adCodeList.indexOf(item1.getAdCode()) > -1).count();
  142. }
  143. try {
  144. if (count > 0 && TimeRangeUtil.isTimeRange(item,mapGroup)) {
  145. errorList.add("(检查计划事项:"+item.getChkName()+"-组名:"+item.getNm()+")");
  146. }
  147. } catch (Exception e) {
  148. e.printStackTrace();
  149. }
  150. });
  151. }
  152. }
  153. if(errorList.size()>0){
  154. msg = "(检查计划事项:"+mapGroup.get("CHK_NAME")+"-当前组:"+mapGroup.get("PNM")+")与其他组"+String.join(",",errorList)+"重叠";
  155. map.put("msg",msg);
  156. }
  157. return map;
  158. }
  159. @ApiOperation(value = "督查组人员分配角色")
  160. @RequestMapping(value = "/assignmentRole", method = RequestMethod.POST)
  161. public BaseResponse assignmentRole(@ApiParam(name = "objIdDto", value = "ObjIdDto") ObjIdDto objIdDto) {
  162. int i = supervisionPlanService.assignmentRole(objIdDto);
  163. return buildSuccessResponse();
  164. }
  165. @ApiOperation(value = "获取人员类型")
  166. @GetMapping(value = "/getPersType")
  167. public BaseResponse<List<PersTypeDto>> getPersType(@RequestParam String persid,@RequestParam(value="yearId",required=false) String yearId) {
  168. List<PersTypeDto> persTypeDtoList = supervisionPlanService.getPersType(persid, getCurrentOrgId(),yearId);
  169. return buildSuccessResponse(persTypeDtoList);
  170. }
  171. @ApiOperation(value = "获取人员类型(根据接收单位)")
  172. @GetMapping(value = "/getPersTypeByPersid")
  173. public BaseResponse<List<PersTypeDto>> getPersTypeByPersid(@RequestParam String persid) {
  174. List<PersTypeDto> persTypeDtoList = supervisionPlanService.getPersTypeByPersid(persid, getCurrentOrgId());
  175. return buildSuccessResponse(persTypeDtoList);
  176. }
  177. @ApiOperation(value = "清空督查对象")
  178. @RequestMapping(value = "/cleanObjData", method = RequestMethod.GET)
  179. public BaseResponse cleanObjData(@ApiParam(name = "objType", value = "督查对象类型", required = true) @RequestParam(required = true) String objType,
  180. @ApiParam(name = "id", value = "登记表id", required = true) @RequestParam(required = true) String id) {
  181. supervisionPlanService.cleanObjData(objType, id);
  182. return buildSuccessResponse();
  183. }
  184. @ApiOperation(value = "清空督查对象(根据obj_id)")
  185. @RequestMapping(value = "/cleanObjDataByObjId", method = RequestMethod.GET)
  186. public BaseResponse cleanObjDataByObjId(@ApiParam(name = "objType", value = "督查对象类型", required = true) @RequestParam(required = true) String objType,
  187. @ApiParam(name = "objId", value = "objId", required = true) @RequestParam(required = true) String objId) {
  188. supervisionPlanService.cleanObjDataByObjId(objType, objId);
  189. return buildSuccessResponse();
  190. }
  191. @ApiOperation(value = "批量清空督查对象(根据obj_id)")
  192. @PostMapping(value = "/cleanObjDataByObjIds/{objType}")
  193. public BaseResponse cleanObjDataByObjIds(@PathVariable String objType,
  194. @RequestBody String objIds) {
  195. Map<String, Object> objIdMaps = (Map<String, Object>) JSON.parse(objIds);
  196. List<String> objIdList = (List<String>) objIdMaps.get("objIds");
  197. if (null == objIdList || objIdList.size() == 0) {
  198. buildFailResponse("获取参数失败");
  199. }
  200. supervisionPlanService.cleanObjDataByObjIds(objType, objIdList);
  201. return buildSuccessResponse();
  202. }
  203. @ApiOperation(value = "添加督查小组,不存在批次时同时添加批次")
  204. @RequestMapping(value = "/insertGroupInfo", method = RequestMethod.POST)
  205. public BaseResponse<String> insertGroupInfo(@ApiParam(name = "GroupInfoDto", value = "groupInfoDto") @RequestBody GroupInfoDto groupInfoDto) {
  206. groupInfoDto.setOrgId(getCurrentOrgId());
  207. String groupId = supervisionPlanService.insertGroupInfo(groupInfoDto);
  208. return buildSuccessResponse(groupId);
  209. }
  210. @ApiOperation(value = "根据id修改节点")
  211. @RequestMapping(value = "/updateNode", method = RequestMethod.POST)
  212. public BaseResponse updateNode(@ApiParam(name = "BisInspAllDto", value = "bisInspAllDto") @RequestBody BisInspAllDto bisInspAllDto) {
  213. bisInspAllDto.setOrgId(getCurrentOrgId());
  214. supervisionPlanService.updateNode(bisInspAllDto);
  215. return buildSuccessResponse();
  216. }
  217. @ApiOperation(value = "清空督查组信息")
  218. @RequestMapping(value = "/cleanGroupInfo", method = RequestMethod.GET)
  219. public BaseResponse cleanGroupInfo(@ApiParam(name = "groupId", value = "组id") @RequestParam String groupId) {
  220. supervisionPlanService.cleanGroupInfo(groupId, getCurrentOrgId());
  221. return buildSuccessResponse();
  222. }
  223. @ApiOperation(value = "复用督查组信息")
  224. @RequestMapping(value = "/copyGroupInfo", method = RequestMethod.POST)
  225. public BaseResponse copyGroupInfo(@RequestBody AllGroupInfoDto allGroupInfoDto) {
  226. allGroupInfoDto.setOrgId(getCurrentOrgId());
  227. supervisionPlanService.copyGroupInfo(allGroupInfoDto);
  228. return buildSuccessResponse();
  229. }
  230. @ApiOperation(value = "导入督查组列表")
  231. @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
  232. public BaseResponse importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request, GroupInfoDto dto) {
  233. String persId = request.getHeader("persId");
  234. Map<String, Object> map = supervisionPlanService.importExcel(file, persId, dto.getOrgId());
  235. return buildSuccessResponse(map);
  236. }
  237. @ApiOperation(value = "下载模板")
  238. @RequestMapping(value = "/dowmTemplate/{fileName}", method = RequestMethod.GET)
  239. public BaseResponse dowmTemplate(HttpServletResponse response, @PathVariable String fileName) {
  240. try {
  241. ExpAndImpUtil.downloadFile(response, templatePath + File.separator + fileName + ".xls", "督查计划列表");
  242. } catch (Exception e) {
  243. return buildFailResponse(e);
  244. }
  245. return buildSuccessResponse();
  246. }
  247. @ApiOperation(value = "根据年度计划添加批次和组信息")
  248. @RequestMapping(value = "/insertByYearMonth", method = RequestMethod.POST)
  249. public BaseResponse insertByYearMonth(@RequestBody BisInspYearAllDto bisInspYearAllDto) {
  250. bisInspYearAllDto.setOrgId(getCurrentOrgId());
  251. supervisionPlanService.insertByYearMonth(bisInspYearAllDto);
  252. return buildSuccessResponse();
  253. }
  254. }