diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java index 26c0f69..74864bb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java @@ -47,4 +47,6 @@ public interface UserInfoHelper { * @return */ String getUserEmpPosUnitCode(Long userId); + + String getMainOrgCode(String empPosUnitCode); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index f8fcd4f..5fc715a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; @@ -232,4 +233,15 @@ public class UserInfoHelperImpl implements UserInfoHelper { UserFullInfoDTO userFullInfo = getUserFullInfo(userId); return userFullInfo.getEmpPosUnitCode(); } + + @Override + public String getMainOrgCode(String empPosUnitCode) { + DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getOrganizationCode, empPosUnitCode) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(org)){ + return null; + } + return org.getParentCode(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java index 0203ee7..4ad2a72 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java @@ -172,4 +172,11 @@ public class GovProjectCollectionController { public void stagingConvertPdf3(@RequestParam(required = false) String projId) { collectionTask.stagingConvertPdf3(projId); } + + @PostMapping("/rebuild-project-code") + @ApiOperation("重新生成项目编号") + @WebLog("重新生成项目编号") + public String stagingConvertPdf3(@RequestBody List projIds) { + return collectionManage.rebuildProjectCode(projIds); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 108f059..412d1ad 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.StrPool; @@ -1689,4 +1690,73 @@ public class GovProjectCollectionManage { e.printStackTrace(); } } + + public String rebuildProjectCode(List baseProjIds){ + if(CollUtil.isEmpty(baseProjIds)){ + throw new BizException("项目编号不能为空"); + } + for(String baseProjId : baseProjIds){ + GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId) + .orderByDesc(GovBizProjectBaseinfo::getTongTime) + .last(BizConst.LIMIT_1)); + GovBizProjectApply apply = projectApplyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjId, baseProjId) + .orderByDesc(GovBizProjectApply::getTongTime) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(baseinfo)){ + System.out.println("项目不存在 直接下一个"); + continue; + } + GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); + saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); + saveDTO.setBaseinfo(BeanUtil.copyProperties(baseinfo, GovBizProjectBaseinfoDTO.class)); + String newProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); + + baseinfo.setBaseProjId(newProjId); + baseinfoService.updateById(baseinfo); + apply.setBaseProjId(newProjId); + projectApplyService.updateById(apply); + + GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaUpdate(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId, baseProjId) + .orderByDesc(GovBizProjectApprove::getTongTime) + .last(BizConst.LIMIT_1)); + if(Objects.nonNull(approve)){ + approve.setBaseProjId(newProjId); + approveService.updateById(approve); + } + + + GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class) + .eq(GovBizProjectCimplement::getBaseProjId, baseProjId) + .orderByDesc(GovBizProjectCimplement::getTongTime) + .last(BizConst.LIMIT_1)); + if(Objects.nonNull(cimplement)){ + cimplement.setBaseProjId(newProjId); + cimplement.setBaseBidCode(newProjId); + cimplementService.updateById(cimplement); + } + + GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class) + .eq(GovBizProjectMimplement::getBaseProjId, baseProjId) + .orderByDesc(GovBizProjectMimplement::getTongTime) + .last(BizConst.LIMIT_1)); + if(Objects.nonNull(mimplement)){ + mimplement.setBaseProjId(newProjId); + mimplement.setBaseBidCode(newProjId); + mimplementService.updateById(mimplement); + } + + List procures = procureService.list(Wrappers.lambdaUpdate(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getBaseProjId, baseProjId)); + + for(GovBizProjectProcure procure : procures){ + procure.setBaseProjId(newProjId); + procure.setBaseBidCode(newProjId + "-" + procure.getBaseBidCode().split("-")[1]); + procureService.updateById(procure); + } + } + return "运行成功 重新生成" + baseProjIds.size() + "个项目编号"; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java index 004a7f6..5ee9b33 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java @@ -83,6 +83,7 @@ public class ProjectIrsManage { ResponseEntity forEntity = restTemplate.getForEntity(url, JSONObject.class); JSONObject body = forEntity.getBody(); log.info("core biz :{}",body); + JSONObject datas = body.getJSONObject("datas"); if(Objects.nonNull(datas)){ return datas; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java index 06f8b13..cc2d898 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java @@ -476,10 +476,24 @@ public class DeclaredProjectManage { }else if(BizConst.PRE.equals(active) || BizConst.PROD.equals(active)){ jsonObject = projectIrsManage.searchCoreBiz(businessName,user.getEmpPosUnitCode(),limit,page); -// List list = coreBizService.list(Wrappers.lambdaQuery(ProjectCoreBiz.class) -// .eq(ProjectCoreBiz::getOrgCode, user.getEmpPosUnitCode()) -// .like(StringUtils.isNotBlank(businessName), ProjectCoreBiz::getMatterName, businessName)); -// jsonObject.put("data",list); + //主管单位的 + String mainOrgCode = userInfoHelper.getMainOrgCode(user.getEmpPosUnitCode()); + if(StringUtils.isNotBlank(mainOrgCode)){ + JSONObject mainOrgCoreBiz = projectIrsManage.searchCoreBiz(businessName, + mainOrgCode,limit,page); + if(Objects.nonNull(mainOrgCoreBiz) && + CollUtil.isNotEmpty(mainOrgCoreBiz.getJSONArray(BizConst.RESPONSE_KEY_DATA))){ + JSONArray mainOrgCoreArray = mainOrgCoreBiz.getJSONArray(BizConst.RESPONSE_KEY_DATA); + if(Objects.nonNull(jsonObject)){ + if(Objects.isNull(jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA))){ + jsonObject.put(BizConst.RESPONSE_KEY_DATA,mainOrgCoreArray); + }else{ + jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA).addAll(mainOrgCoreArray); + jsonObject.put(BizConst.RESPONSE_KEY_DATA,mainOrgCoreArray); + } + } + } + } } return jsonObject; }