| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- package cn.com.goldenwater.dcproj.controller.plansd;
- 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.BisInspAllRlationPers;
- import cn.com.goldenwater.dcproj.model.BisInspPlanDtlAddvcd;
- import cn.com.goldenwater.dcproj.param.BisInspGroupArrangementParam;
- import cn.com.goldenwater.dcproj.param.BisInspPlanDtlAddvcdParam;
- import cn.com.goldenwater.dcproj.service.*;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import cn.com.goldenwater.dcproj.utils.Constant;
- import cn.com.goldenwater.dcproj.utils.DateUtils;
- import cn.com.goldenwater.dcproj.utils.StringUtils;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.collections.CollectionUtils;
- 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 java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import java.util.Optional;
- import java.util.stream.Collectors;
- /**
- * @author hjp
- * @date 2022-8-9
- */
- @Api(value = "山东详细分组安排管理", tags = "山东详细分组安排管理")
- @RestController
- @RequestMapping("/bis/insp/plan/ga")
- public class BisInspGroupArrangementController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspGroupArrangementService bisInspGroupArrangementService;
- @Autowired
- private BisInspAllRlationPersService bisInspAllRlationPersService;
- @Autowired
- private BisInspPlanDpService bisInspPlanDpService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @Autowired
- private BisInspPlanDtlAddvcdService bisInspPlanDtlAddvcdService;
- @Autowired
- private AttAdBaseService attAdBaseService;
- @ApiOperation(value = "获取详细分组安排列表")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<PlanAllInfoDto>> list(@RequestBody BisInspGroupArrangementParam param) {
- param.setOrgId(getCurrentOrgId());
- BisInspAllRlationPers byId = bisInspAllRlationPersService.getById(getCurrentPersId());
- String planDpId = byId.getPlanDpId();
- if (StringUtils.isBlank(planDpId)){
- return buildSuccessResponse(new ArrayList<>());
- }
- Optional.ofNullable(bisInspPlanDpService.get(planDpId)).ifPresent(dp ->{
- if (!StringUtils.equals(Constant.STRING_TWO,dp.getDpType())){
- param.setPlanDpId(dp.getId());
- param.setDdAdCode(AdLevelUtil.getAddvcd(olBisInspOrgService.getRlProvince(getCurrentOrgId())));
- }
- });
- return buildSuccessResponse(this.bisInspGroupArrangementService.getAllInfoByPnmAndTypeAndOrgId(param));
- }
- @ApiOperation(value = "添加分组")
- @RequestMapping(value = "/add", method = RequestMethod.POST)
- public BaseResponse<?> add(@RequestBody PlanAllAddDto dto) {
- Assert.notNull(dto.getDtlId(), "检查年度计划分解ID为必填参数");
- Assert.notNull(dto.getTypeList(),"类别IDS为必填参数");
- dto.setOrgId(getCurrentOrgId());
- dto.setPersId(getCurrentPersId());
- Optional.ofNullable(bisInspAllRlationPersService.get(getCurrentPersId())).ifPresent(b -> dto.setPlanDpId(b.getPlanDpId()));
- //判断是否重复创建
- if (null != dto.getDetermine() && !dto.getDetermine()) {
- Assert.notNull(dto.getStTm(), "开始时间为必填参数");
- Assert.notNull(dto.getEnTm(), "结束时间为必填参数");
- // true 表示 有重复计划 false 表示没有
- BisInspPlanDtlDto bisInspPlanDtlDto = new BisInspPlanDtlDto();
- bisInspPlanDtlDto.setEnTm(DateUtils.Str2Date(dto.getEnTm()));
- bisInspPlanDtlDto.setStTm(DateUtils.Str2Date(dto.getStTm()));
- Optional.ofNullable(bisInspPlanDtlAddvcdService.findList(new BisInspPlanDtlAddvcdParam(dto.getDtlId()))).ifPresent(l -> bisInspPlanDtlDto.setdAdCodes(l.stream().map(BisInspPlanDtlAddvcd::getAdCode).collect(Collectors.toList())));
- // 2024/1/29 modify by lxf
- // 督察计划 有个地区检查规则, 原来的是同一个区县不允许有两个以上检查组同时检查,这个规则修改下:一周内,到同一个市的督察检查组不能超过一个
- List<Map<String, String>> byAdCodeAndTm = bisInspPlanDtlAddvcdService.getByAdCodeAndTm(bisInspPlanDtlDto);
- BaseResponse response = buildFailResponse(String.valueOf(CollectionUtils.isNotEmpty(byAdCodeAndTm)));
- if(CollectionUtils.isNotEmpty(byAdCodeAndTm)){
- String hasAdCodes = byAdCodeAndTm.stream().map(m->m.get("AD_CODE").substring(0,4)).collect(Collectors.joining("','","'","'"));
- List<BisInspPlanDtlDto> byAdCodeAndTmList = bisInspPlanDtlAddvcdService.getByAdCodeAndTmList(hasAdCodes, bisInspPlanDtlDto);
- response.setData(byAdCodeAndTmList);
- }
- return response;
- }
- this.bisInspGroupArrangementService.add(dto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "编辑所有分组基本信息")
- @RequestMapping(value = "/upInfo", method = RequestMethod.POST)
- public BaseResponse<?> upInfo(@RequestBody PlanAllUpDto dto) {
- Assert.notNull(dto.getIds(), "组ids为必填参数");
- dto.setOrgId(getCurrentOrgId());
- this.bisInspGroupArrangementService.updateInfo(dto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "编辑分组类别人员 对象")
- @RequestMapping(value = "/up", method = RequestMethod.POST)
- public BaseResponse<?> up(@RequestBody PlanAllUpDto dto) {
- Assert.notNull(dto.getDtlId(), "检查年度计划分解ID为必填参数");
- Assert.notNull(dto.getId(), "组 ID 为必填参数");
- Assert.notNull(dto.getpType(), "督查类别为必填参数");
- dto.setOrgId(getCurrentOrgId());
- this.bisInspGroupArrangementService.update(dto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "删除分组信息")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse<?> del(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- this.bisInspGroupArrangementService.cleanGroupInfo(id, getCurrentOrgId(),getCurrentPersId());
- return buildSuccessResponse();
- }
- @ApiOperation(value = "删除所有类别分组信息")
- @RequestMapping(value = "/delAll/{ids}", method = RequestMethod.GET)
- public BaseResponse<?> delAll(@ApiParam(name = "ids", value = "ids", required = true) @PathVariable String ids) {
- this.bisInspGroupArrangementService.delAll(ids, getCurrentOrgId(),getCurrentPersId());
- return buildSuccessResponse();
- }
- @ApiOperation(value = "删除单个组人员")
- @RequestMapping(value = "/delSinglePersonnel", method = RequestMethod.POST)
- public BaseResponse<?> delSinglePersonnel(@RequestBody PlanAllDelDto dto) {
- Assert.notNull(dto.getGroupId(), "组Id为必填参数");
- Assert.notNull(dto.getDelId(), "人员Id为必填参数");
- this.bisInspGroupArrangementService.delSinglePersonnel(dto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "删除单个组对象")
- @RequestMapping(value = "/delSingleObject", method = RequestMethod.POST)
- public BaseResponse<?> delSingleObject(@RequestBody PlanAllDelDto dto) {
- Assert.notNull(dto.getGroupId(), "组Id为必填参数");
- Assert.notNull(dto.getDelId(), "对象Id为必填参数");
- this.bisInspGroupArrangementService.delSingleObject(dto);
- return buildSuccessResponse();
- }
- }
|