| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- package cn.com.goldenwater.dcproj.controller.ducha;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.dto.*;
- import cn.com.goldenwater.dcproj.model.OlBisInspOrg;
- import cn.com.goldenwater.dcproj.param.InGroupResParam;
- import cn.com.goldenwater.dcproj.param.InspObjParam;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.SupervisionPlanService;
- import cn.com.goldenwater.dcproj.util.CheckUtil;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import cn.com.goldenwater.dcproj.utils.TimeRangeUtil;
- import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
- import com.alibaba.fastjson.JSON;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.scheduling.annotation.Async;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.File;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * Created by 61618 on 2019/4/17.
- */
- @Api(value = "督查计划相关接口", tags = "督查计划相关接口")
- @RestController
- @RequestMapping("/supervision/plan")
- public class SupervisionPlanController extends BaseController {
- @Autowired
- private SupervisionPlanService supervisionPlanService;
- @Value("${export.templatePath}")
- private String templatePath;
- @Value("${impExcel.basePath}")
- private String impExcelPath;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- @ApiOperation(value = "根据用户信息与督查计划类型获取该用户可示可管理的单一机构的所有批次")
- @RequestMapping(value = "getNodeByPersid", method = RequestMethod.GET)
- public BaseResponse<List<AllNodeDto>> getNodeByPersid(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
- @ApiParam(name = "ptype", value = "ptype", required = true) @RequestParam String ptype) {
- List<AllNodeDto> allNodeDtoList = this.supervisionPlanService.getNodeByPersid(persid, ptype, getCurrentOrgId());
- return buildSuccessResponse(allNodeDtoList);
- }
- @ApiOperation(value = "获取督查组相关的对象、人员、区域信息(新)")
- @RequestMapping(value = "getAllInfoByPersidAndOrgId", method = RequestMethod.GET)
- public BaseResponse<List<PersAllInfoDto>> getAllInfoByPersidAndOrgId(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
- @ApiParam(name = "inspYear", value = "inspYear", required = false) @RequestParam(required = false) String inspYear,
- @ApiParam(name = "inspMnth", value = "inspMnth", required = false) @RequestParam(required = false) String inspMnth,
- @ApiParam(name = "orgId", value = "机构id", required = true) @RequestParam String orgId,
- @ApiParam(name = "yearPlanId", value = "年度id", required = true) @RequestParam String yearPlanId) {
- List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersidAndOrgId(persid, inspYear, inspMnth, orgId, yearPlanId);
- return buildSuccessResponse(allNodeDtoList);
- }
- @ApiOperation(value = "根据组id查询督查区域")
- @RequestMapping(value = "/getPersAllAreaDtoList", method = RequestMethod.POST)
- public BaseResponse<List<PersAllAreaDto>> getPersAllAreaDtoList(@PathVariable String id) {
- List<PersAllAreaDto> dtos = this.supervisionPlanService.getPersAllAreaDtoList(id, getCurrentOrgId());
- return buildSuccessResponse(dtos);
- }
- @ApiOperation(value = "获取督查组相关的对象、人员、区域信息")
- @RequestMapping(value = "getAllInfoByPersid", method = RequestMethod.GET)
- public BaseResponse<List<PersAllInfoDto>> getAllInfoByPersid(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
- @ApiParam(name = "ptype", value = "ptype", required = true) @RequestParam String ptype,
- @ApiParam(name = "id", value = "id", required = true) @RequestParam String id) {
- List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersid(persid, ptype, id, getCurrentOrgId());
- return buildSuccessResponse(allNodeDtoList);
- }
- @ApiOperation(value = "查询不在该督查组下的水库", notes = "查询不在该督查组下的水库")
- @RequestMapping(value = "/getSupResByGroup", method = RequestMethod.POST)
- public BaseResponse<PageInfo<AttSupResBase>> getSupResByGroup(@RequestBody InGroupResParam inGroupResParam) {
- inGroupResParam.setProvince(olBisInspOrgService.getProvinceFlag(getCurrentOrgId()));
- inGroupResParam.setOrgId(getCurrentOrgId());
- PageInfo<AttSupResBase> list = supervisionPlanService.getSupResByGroup(inGroupResParam);
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "查询不在督查组督查范围内的督查对象")
- @RequestMapping(value = "/getSupObjListNotInspGroupId", method = RequestMethod.GET)
- public BaseResponse<Object> getSupObjListNotInspGroupId(@ApiParam(name = "InspObjParam", value = "InspObjParam") InspObjParam inspObjParam) {
- OlBisInspOrg org = olBisInspOrgService.get(getCurrentOrgId());
- CheckUtil.notNull(org, "机构ID错误", getCurrentOrgId());
- inspObjParam.setProvince(AdLevelUtil.getAddvcd(org.getAdCode()));
- inspObjParam.setOrgId(getCurrentOrgId());
- if (StringUtils.isNotBlank(inspObjParam.getOrderBy()) && inspObjParam.getOrderBy().contains("undefined")) {
- inspObjParam.setOrderBy("");
- }
- PageInfo pageInfo = supervisionPlanService.getSupObjListNotInspGroupId(inspObjParam);
- return buildSuccessResponse(pageInfo);
- }
- @ApiOperation(value = "添加督查人员、督查对象、督查区域")
- @RequestMapping(value = "/insertSupervisionObj", method = RequestMethod.POST)
- public BaseResponse<Object> insertSupervisionObj(@ApiParam(name = "PersAllInfoDto", value = "PersAllInfoDto") @RequestBody PersAllInfoDto persAllInfoDto) {
- if ((StringUtils.isNotBlank(persAllInfoDto.getSttm()) || StringUtils.isNotBlank(persAllInfoDto.getEntm())) && StringUtils.isBlank(persAllInfoDto.getIsInsert())) {
- Map<String, Object> map = isValiTm(persAllInfoDto);
- if (map.get("msg") != null) {
- return buildSuccessResponse(map);
- }
- }
- persAllInfoDto.setOrgId(getCurrentOrgId());
- persAllInfoDto.setPersid(getCurrentPersId());
- persAllInfoDto.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
- SupInsertResult supInsertResult = supervisionPlanService.insertSupervisionObj(persAllInfoDto);
- return buildSuccessResponse(supInsertResult);
- }
- @ApiOperation(value = "添加督查人员、督查对象、督查区域")
- @RequestMapping(value = "/insertAllSupervisionObj", method = RequestMethod.POST)
- public BaseResponse<Object> insertAllSupervisionObj(@ApiParam(name = "InspObjParam", value = "InspObjParam") InspObjParam inspObjParam) {
- batchInsert(inspObjParam);
- return buildSuccessResponse("添加成功!");
- }
- @Async
- protected void batchInsert(InspObjParam inspObjParam) {
- OlBisInspOrg org = olBisInspOrgService.get(getCurrentOrgId());
- CheckUtil.notNull(org, "机构ID错误", getCurrentOrgId());
- inspObjParam.setProvince(AdLevelUtil.getAddvcd(org.getAdCode()));
- inspObjParam.setOrgId(getCurrentOrgId());
- if (StringUtils.isNotBlank(inspObjParam.getOrderBy()) && inspObjParam.getOrderBy().contains("undefined")) {
- inspObjParam.setOrderBy("");
- }
- List<SupervisionPlanDto> pageInfo = supervisionPlanService.getObjListNotGroupId(inspObjParam);
- PersAllInfoDto persAllInfoDto = new PersAllInfoDto();
- persAllInfoDto.setId(inspObjParam.getInspGroupId());
- List<PersAllObjDto> objList = new ArrayList<>();
- for (int i = 0; i < pageInfo.size(); i++) {
- PersAllObjDto persAllObjDto = new PersAllObjDto();
- persAllObjDto.setPtype(inspObjParam.getObjType());
- persAllObjDto.setCode(pageInfo.get(i).getCode());
- persAllObjDto.setName(pageInfo.get(i).getNm());
- objList.add(persAllObjDto);
- }
- persAllInfoDto.setPersAllObjDtoList(objList);
- persAllInfoDto.setPersAllAreaDtoList(new ArrayList<>());
- persAllInfoDto.setPersAllDtoList(new ArrayList<>());
- persAllInfoDto.setOrgId(getCurrentOrgId());
- persAllInfoDto.setPersid(getCurrentPersId());
- persAllInfoDto.setProvince(olBisInspOrgService.getProvince(getCurrentOrgId()));
- supervisionPlanService.insertSupervisionObj(persAllInfoDto);
- }
- public Map<String, Object> isValiTm(PersAllInfoDto persAllInfoDto) {
- String msg = "";
- Map<String, Object> map = new HashMap<>();
- Map<String, String> mapGroup = supervisionPlanService.getYearMonth(persAllInfoDto.getId());
- if (StringUtils.isNotBlank(persAllInfoDto.getSttm())) {
- mapGroup.put("STTM", persAllInfoDto.getSttm());
- }
- if (StringUtils.isNotBlank(persAllInfoDto.getEntm())) {
- mapGroup.put("ENTM", persAllInfoDto.getEntm());
- }
- List<String> adCodeList = new ArrayList<String>();
- List<String> errorList = new ArrayList<String>();
- List<PersAllInfoDto> allNodeDtoList = this.supervisionPlanService.getAllInfoByPersidAndOrgId(getCurrentPersId(), mapGroup.get("INSP_YEAR"), mapGroup.get("INSP_MNTH"), getCurrentOrgId(), null);
- if (allNodeDtoList != null && allNodeDtoList.size() > 0 && (StringUtils.isNotBlank(mapGroup.get("STTM")) || StringUtils.isNotBlank(mapGroup.get("ENTM")))) {
- allNodeDtoList.forEach(item -> {
- if (persAllInfoDto.getId().equals(item.getId()) && item.getPersAllAreaDtoList() != null && item.getPersAllAreaDtoList().size() > 0) {
- item.getPersAllAreaDtoList().forEach(item1 -> {
- adCodeList.add(item1.getAdCode());
- });
- }
- });
- if (adCodeList.size() > 0) {
- allNodeDtoList.forEach(item -> {
- long count = 0;
- if (!persAllInfoDto.getId().equals(item.getId()) && item.getPersAllAreaDtoList() != null && item.getPersAllAreaDtoList().size() > 0) {
- count = item.getPersAllAreaDtoList().stream().filter(item1 -> adCodeList.indexOf(item1.getAdCode()) > -1).count();
- }
- try {
- if (count > 0 && TimeRangeUtil.isTimeRange(item, mapGroup)) {
- errorList.add("(检查计划事项:" + item.getChkName() + "-组名:" + item.getNm() + ")");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- }
- }
- if (errorList.size() > 0) {
- msg = "(检查计划事项:" + mapGroup.get("CHK_NAME") + "-当前组:" + mapGroup.get("PNM") + ")与其他组" + String.join(",", errorList) + "重叠";
- map.put("msg", msg);
- }
- return map;
- }
- @ApiOperation(value = "督查组人员分配角色")
- @RequestMapping(value = "/assignmentRole", method = RequestMethod.POST)
- public BaseResponse assignmentRole(@ApiParam(name = "objIdDto", value = "ObjIdDto") ObjIdDto objIdDto) {
- int i = supervisionPlanService.assignmentRole(objIdDto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "获取人员类型")
- @GetMapping(value = "/getPersType")
- public BaseResponse<List<PersTypeDto>> getPersType(@RequestParam String persid, @RequestParam(value = "yearId", required = false) String yearId) {
- List<PersTypeDto> persTypeDtoList = supervisionPlanService.getPersType(persid, getCurrentOrgId(), yearId);
- return buildSuccessResponse(persTypeDtoList);
- }
- @ApiOperation(value = "获取人员类型(根据接收单位)")
- @GetMapping(value = "/getPersTypeByPersid")
- public BaseResponse<List<PersTypeDto>> getPersTypeByPersid(@RequestParam String persid) {
- List<PersTypeDto> persTypeDtoList = supervisionPlanService.getPersTypeByPersid(persid, getCurrentOrgId());
- return buildSuccessResponse(persTypeDtoList);
- }
- @ApiOperation(value = "清空督查对象")
- @RequestMapping(value = "/cleanObjData", method = RequestMethod.GET)
- public BaseResponse cleanObjData(@ApiParam(name = "objType", value = "督查对象类型", required = true) @RequestParam(required = true) String objType,
- @ApiParam(name = "id", value = "登记表id", required = true) @RequestParam(required = true) String id) {
- supervisionPlanService.cleanObjData(objType, id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "清空督查对象(根据obj_id)")
- @RequestMapping(value = "/cleanObjDataByObjId", method = RequestMethod.GET)
- public BaseResponse cleanObjDataByObjId(@ApiParam(name = "objType", value = "督查对象类型", required = true) @RequestParam(required = true) String objType,
- @ApiParam(name = "objId", value = "objId", required = true) @RequestParam(required = true) String objId) {
- supervisionPlanService.cleanObjDataByObjId(objType, objId);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "批量清空督查对象(根据obj_id)")
- @PostMapping(value = "/cleanObjDataByObjIds/{objType}")
- public BaseResponse cleanObjDataByObjIds(@PathVariable String objType,
- @RequestBody String objIds) {
- Map<String, Object> objIdMaps = (Map<String, Object>) JSON.parse(objIds);
- List<String> objIdList = (List<String>) objIdMaps.get("objIds");
- if (null == objIdList || objIdList.size() == 0) {
- buildFailResponse("获取参数失败");
- }
- supervisionPlanService.cleanObjDataByObjIds(objType, objIdList);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "添加督查小组,不存在批次时同时添加批次")
- @RequestMapping(value = "/insertGroupInfo", method = RequestMethod.POST)
- public BaseResponse<String> insertGroupInfo(@ApiParam(name = "GroupInfoDto", value = "groupInfoDto") @RequestBody GroupInfoDto groupInfoDto) {
- groupInfoDto.setOrgId(getCurrentOrgId());
- String groupId = supervisionPlanService.insertGroupInfo(groupInfoDto);
- return buildSuccessResponse(groupId);
- }
- @ApiOperation(value = "根据id修改节点")
- @RequestMapping(value = "/updateNode", method = RequestMethod.POST)
- public BaseResponse updateNode(@ApiParam(name = "BisInspAllDto", value = "bisInspAllDto") @RequestBody BisInspAllDto bisInspAllDto) {
- bisInspAllDto.setOrgId(getCurrentOrgId());
- supervisionPlanService.updateNode(bisInspAllDto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "清空督查组信息")
- @RequestMapping(value = "/cleanGroupInfo", method = RequestMethod.GET)
- public BaseResponse cleanGroupInfo(@ApiParam(name = "groupId", value = "组id") @RequestParam String groupId) {
- supervisionPlanService.cleanGroupInfo(groupId, getCurrentOrgId());
- return buildSuccessResponse();
- }
- @ApiOperation(value = "复用督查组信息")
- @RequestMapping(value = "/copyGroupInfo", method = RequestMethod.POST)
- public BaseResponse copyGroupInfo(@RequestBody AllGroupInfoDto allGroupInfoDto) {
- allGroupInfoDto.setOrgId(getCurrentOrgId());
- supervisionPlanService.copyGroupInfo(allGroupInfoDto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "导入督查组列表")
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
- public BaseResponse importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request, GroupInfoDto dto) {
- String persId = request.getHeader("persId");
- Map<String, Object> map = supervisionPlanService.importExcel(file, persId, dto.getOrgId());
- return buildSuccessResponse(map);
- }
- @ApiOperation(value = "下载模板")
- @RequestMapping(value = "/dowmTemplate/{fileName}", method = RequestMethod.GET)
- public BaseResponse dowmTemplate(HttpServletResponse response, @PathVariable String fileName) {
- try {
- ExpAndImpUtil.downloadFile(response, templatePath + File.separator + fileName + ".xls", "督查计划列表");
- } catch (Exception e) {
- return buildFailResponse(e);
- }
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据年度计划添加批次和组信息")
- @RequestMapping(value = "/insertByYearMonth", method = RequestMethod.POST)
- public BaseResponse insertByYearMonth(@RequestBody BisInspYearAllDto bisInspYearAllDto) {
- bisInspYearAllDto.setOrgId(getCurrentOrgId());
- supervisionPlanService.insertByYearMonth(bisInspYearAllDto);
- return buildSuccessResponse();
- }
- }
|