diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java index 59f551e..ec6bd0f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java @@ -87,6 +87,13 @@ public interface BizConst { int MAX_EXPORT_COUNT = 5000; String RESPONSE_KEY_DATA = "data"; + String RESPONSE_KEY_ID = "id"; + String RESPONSE_KEY_DING_CODE = "dingCode"; + String RESPONSE_KEY_MATTER_NAME = "matterName"; + String RESPONSE_KEY_ORG_NAME = "orgName"; + String RESPONSE_KEY_USER_STATE = "userState"; + + String RESPONSE_KEY_AREA_NAME = "areaName"; String ORG_NAME = "organizationName"; String ORG_CODE = "organizationCode"; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java index 320cb90..1e997e8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java @@ -64,6 +64,6 @@ public interface CommonConst { Integer VERIFY_TYPE = 2; String REPEAT = " 已在其他当前评价计划其他分组中,请勿重复添加!"; - + String NORMAL_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; } 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 fb28ab9..f787c84 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 @@ -111,4 +111,11 @@ public class GovProjectCollectionController { public void stagingConvertPdf(@RequestParam(required = false) String projId) { collectionTask.stagingConvertPdf(projId); } + + @PostMapping("/staging-convert-pdf2") + @ApiOperation("把库存的项目归集的文件approval_file重新转换") + @WebLog("把库存的项目归集的文件approval_file重新转换") + public void stagingConvertPdf2(@RequestParam(required = false) String projId) { + collectionTask.stagingConvertPdf2(projId); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java index db1f3b6..61f7e42 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java @@ -2,12 +2,15 @@ package com.ningdatech.pmapi.gov.convert; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import com.ningdatech.pmapi.common.constant.CommonConst; import com.ningdatech.pmapi.gov.contants.BizProjectContant; import com.ningdatech.pmapi.gov.model.dto.*; import com.ningdatech.pmapi.gov.model.req.*; import com.ningdatech.pmapi.gov.model.vo.*; +import com.ningdatech.pmapi.gov.utils.ProjectCollectionUtil; import org.apache.commons.lang3.StringUtils; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -70,6 +73,8 @@ public class ProjectConvert { if(Objects.nonNull(p.getId())){ r.setTongID(p.getId().intValue()); } + r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime())); + r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime())); return r; }) .collect(Collectors.toList()); @@ -87,6 +92,8 @@ public class ProjectConvert { if(Objects.nonNull(p.getId())){ r.setTongID(p.getId().intValue()); } + r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime())); + r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime())); return r; }) .collect(Collectors.toList()); @@ -107,6 +114,8 @@ public class ProjectConvert { p.getPurchaseFile()); r.setPurchaseContract(StringUtils.isNotBlank(p.getPurchaseContractPdf()) ? p.getPurchaseContractPdf() : p.getPurchaseContract()); + r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime())); + r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime())); return r; }) .collect(Collectors.toList()); @@ -301,8 +310,8 @@ public class ProjectConvert { req.setBaseProjConsClass(apply.getBaseProjConsClass()); req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration())); req.setBaseProjIntro(apply.getBaseProjIntro()); - req.setBaseProjStartTime(String.valueOf(apply.getBaseProjStartTime())); - req.setBaseProjEndTime(String.valueOf(apply.getBaseProjEndTime())); + req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime())); + req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime())); req.setBaseProjSetYear(apply.getBaseProjSetYear()); req.setBaseProjSys(apply.getBaseProjSys()); req.setBaseProjSysCode(apply.getBaseDevelopCode()); @@ -312,6 +321,7 @@ public class ProjectConvert { req.setBaseProjAmountOri(apply.getBaseProjAmountOri()); req.setBaseProjRemark(apply.getBaseProjRemark()); req.setBeseExpectedResults(apply.getBeseExpectedResults()); + req.setBaseProjBasis(apply.getBaseProjBasis()); return req; } @@ -341,8 +351,8 @@ public class ProjectConvert { req.setBaseProjConsClass(apply.getBaseProjConsClass()); req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration())); req.setBaseProjIntro(apply.getBaseProjIntro()); - req.setBaseProjStartTime(String.valueOf(apply.getBaseProjStartTime())); - req.setBaseProjEndTime(String.valueOf(apply.getBaseProjEndTime())); + req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime())); + req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime())); req.setBaseProjSetYear(apply.getBaseProjSetYear()); req.setBaseProjSys(apply.getBaseProjSys()); req.setBaseProjSysCode(apply.getBaseDevelopCode()); @@ -352,6 +362,7 @@ public class ProjectConvert { req.setBaseProjAmountOri(apply.getBaseProjAmountOri()); req.setBaseProjRemark(apply.getBaseProjRemark()); req.setBeseExpectedResults(apply.getBeseExpectedResults()); + req.setBaseProjBasis(apply.getBaseProjBasis()); return req; } @@ -367,7 +378,7 @@ public class ProjectConvert { req.setBaseAccountAppName(apply.getBaseAccountAppName()); req.setBaseBasisEstablish(apply.getBaseBasisEstablish()); req.setBaseCoreBusiness(apply.getBaseCoreBusiness()); - req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode()); +// req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode()); req.setBaseBrainName(apply.getBaseBrainName()); req.setBaseDevelopCode(apply.getBaseDevelopCode()); req.setBaseLowestLevel(apply.getBaseLowestLevel()); @@ -386,8 +397,8 @@ public class ProjectConvert { req.setBaseProjConsClass(apply.getBaseProjConsClass()); req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration())); req.setBaseProjIntro(apply.getBaseProjIntro()); - req.setBaseProjStartTime(String.valueOf(apply.getBaseProjStartTime())); - req.setBaseProjEndTime(String.valueOf(apply.getBaseProjEndTime())); + req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime())); + req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime())); req.setBaseProjSetYear(apply.getBaseProjSetYear()); req.setBaseProjSys(apply.getBaseProjSys()); req.setBaseProjSysCode(apply.getBaseDevelopCode()); @@ -397,6 +408,7 @@ public class ProjectConvert { req.setBaseProjAmountOri(apply.getBaseProjAmountOri()); req.setBaseProjRemark(apply.getBaseProjRemark()); req.setBeseExpectedResults(apply.getBeseExpectedResults()); + req.setBaseProjBasis(apply.getBaseProjBasis()); return req; } 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 894f0dc..2aa907c 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 @@ -15,6 +15,7 @@ import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.constant.RegionConst; +import com.ningdatech.pmapi.common.helper.RegionCacheHelper; import com.ningdatech.pmapi.gov.contants.BizProjectContant; import com.ningdatech.pmapi.gov.convert.ProjectConvert; import com.ningdatech.pmapi.gov.model.dto.*; @@ -49,7 +50,11 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Field; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; import java.util.*; import java.util.stream.Collectors; @@ -99,6 +104,8 @@ public class GovProjectCollectionManage { @Value("${spring.profiles.active}") private String active; + private final RegionCacheHelper regionCacheHelper; + public List dictionary(String type) { List dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) @@ -143,7 +150,8 @@ public class GovProjectCollectionManage { Map applyMap = Maps.newHashMap(); if(CollUtil.isNotEmpty(projIds)){ List applys = projectApplyService.list(Wrappers.lambdaQuery(GovBizProjectApply.class) - .in(GovBizProjectApply::getBaseProjId,projIds)); + .in(GovBizProjectApply::getBaseProjId,projIds) + .eq(GovBizProjectApply::getDeleted,Boolean.FALSE)); applyMap = applys.stream().collect(Collectors.toMap(GovBizProjectApply::getBaseProjId,a -> a)); } @@ -216,17 +224,13 @@ public class GovProjectCollectionManage { */ private void permissions(LambdaQueryWrapper wrapper) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); - List userRoleList = user.getUserRoleList(); - for(Role role : userRoleList){ - //超管和区域管理员 - if(RoleEnum.SUPER_ADMIN.name().equals(role.getCode()) || - RoleEnum.REGION_MANAGER.name().equals(role.getCode())){ - log.info("超管和区管 可以看所有"); - }else{ - //其他情况 都只能看 自己单位的 - wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); - } + //超管和区域管理员 + if(user.getSuperAdmin() || user.getRegionAdmin()){ + log.info("超管和区管 可以看所有"); + return; } + + wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); } public Long count(ProjectListReq req) { @@ -237,6 +241,7 @@ public class GovProjectCollectionManage { .eq(StringUtils.isNotBlank(req.getRegionCode()),GovBizProjectBaseinfo::getAreaCode,req.getRegionCode()) .gt(Objects.nonNull(req.getCreateOnMin()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMin()) .le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMax()) + .eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) .orderByDesc(GovBizProjectBaseinfo::getBizTime); return baseinfoService.count(wrapper); } @@ -384,13 +389,9 @@ public class GovProjectCollectionManage { } GovBizProjectBaseinfoDTO base = saveDTO.getBaseinfo(); - String baseProjId = base.getBaseProjId(); + String baseProjId = saveDTO.getBaseProjId(); String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; String baseProjName = base.getBaseProjName(); - //如果是新增的话 要生成 项目编号 - if(StringUtils.isBlank(baseProjId) || BizProjectContant.ProjectCollection.DRAFT.equals(baseProjId)){ - baseProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); - } //1.保存基本信息 GovBizProjectBaseinfoDTO baseinfo = saveDTO.getBaseinfo(); @@ -404,19 +405,27 @@ public class GovProjectCollectionManage { //项目名去重 checkName(baseProjName,baseProjId); GovBizProjectBaseinfo saveBase = BeanUtil.copyProperties(baseinfo,GovBizProjectBaseinfo.class); - saveBase.setBaseProjId(baseProjId); saveBase.setBaseProjName(baseProjName); saveBase.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); if(Objects.nonNull(oldBaseInfo)){ saveBase.setId(oldBaseInfo.getId()); + saveBase.setBaseAreaCode(null); }else{ saveBase.setTongTime(LocalDateTime.now()); saveBase.setBaseAreaCode(baseAreaCode); + saveBase.setBaseAreaName(regionCacheHelper.getRegionName(user.getRegionCode(),RegionConst.RL_COUNTY)); } saveBase.setAreaCode(RegionConst.RC_LS); saveBase.setBizTime(LocalDateTime.now()); saveBase.setUpdateBy(user.getUsername()); saveBase.setUpdateOn(LocalDateTime.now()); + + //如果是新增的话 要生成 项目编号 + if(StringUtils.isBlank(baseProjId) || BizProjectContant.ProjectCollection.DRAFT.equals(baseProjId)){ + baseProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); + saveBase.setBaseProjId(baseProjId); + } + baseinfoService.saveOrUpdate(saveBase); // 2.保存 申报信息 @@ -435,6 +444,11 @@ public class GovProjectCollectionManage { }else{ saveApply.setTongTime(LocalDateTime.now()); } + if(Objects.nonNull(saveApply.getBaseProjStartTime()) && + Objects.nonNull(saveApply.getBaseProjEndTime())){ + saveApply.setBaseProjDuration(convertMonth(saveApply.getBaseProjStartTime(), + saveApply.getBaseProjEndTime())); + } saveApply.setAreaCode(RegionConst.RC_LS); saveApply.setBizTime(LocalDateTime.now()); saveApply.setUpdateBy(user.getUsername()); @@ -474,13 +488,16 @@ public class GovProjectCollectionManage { if(Objects.nonNull(cimplement)){ cimplement.setBaseProjId(baseProjId); cimplement.setBaseProjName(baseProjName); - cimplement.setBaseBidCode(baseProjId + "-1"); + cimplement.setBaseBidCode(baseProjId); + cimplement.setBaseBidName(baseProjName); GovBizProjectCimplement oldCimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class) .eq(GovBizProjectCimplement::getBaseProjId, baseProjId) .last(BizConst.LIMIT_1)); GovBizProjectCimplement saveCimplement = BeanUtil.copyProperties(cimplement,GovBizProjectCimplement.class); saveCimplement.setBaseProjId(baseProjId); + saveCimplement.setBaseBidCode(baseProjId); + saveCimplement.setBaseBidName(baseProjName); if(Objects.nonNull(oldCimplement)){ saveCimplement.setId(oldCimplement.getId()); }else{ @@ -500,14 +517,16 @@ public class GovProjectCollectionManage { if(Objects.nonNull(mimplement)){ mimplement.setBaseProjId(baseProjId); mimplement.setBaseProjName(baseProjName); - mimplement.setBaseBidCode(baseProjId + "-2"); + mimplement.setBaseBidCode(baseProjId); + mimplement.setBaseBidName(baseProjName); GovBizProjectMimplement oldMimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class) .eq(GovBizProjectMimplement::getBaseProjId, baseProjId) .last(BizConst.LIMIT_1)); GovBizProjectMimplement saveMimplement = BeanUtil.copyProperties(mimplement,GovBizProjectMimplement.class); saveMimplement.setBaseProjId(baseProjId); - + saveMimplement.setBaseBidCode(baseProjId); + saveMimplement.setBaseBidName(baseProjName); if(Objects.nonNull(oldMimplement)){ saveMimplement.setId(oldMimplement.getId()); }else{ @@ -534,26 +553,26 @@ public class GovProjectCollectionManage { String finalBaseProjId = baseProjId; UserInfoDetails finalUser = user; - threadPoolTaskScheduler.execute(() -> { - Integer index = 1; - for(GovBizProjectProcureDTO procure : procures){ - procure.setBaseProjId(finalBaseProjId); - procure.setBaseProjName(baseProjName); - procure.setBaseBidCode(finalBaseProjId + StrPool.DASH + index); - GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); - saveProcure.setBaseProjId(finalBaseProjId); - saveProcure.setId(null); - saveProcure.setAreaCode(RegionConst.RC_LS); - saveProcure.setTongTime(LocalDateTime.now()); - saveProcure.setBizTime(LocalDateTime.now()); - saveProcure.setUpdateBy(finalUser.getUsername()); - saveProcure.setUpdateOn(LocalDateTime.now()); - if(procureService.save(saveProcure)){ - uploadFileToProvincialOssProcure(procure,null,saveProcure); - } - index++; + + Integer index = 1; + for(GovBizProjectProcureDTO procure : procures){ + procure.setBaseProjId(finalBaseProjId); + procure.setBaseProjName(baseProjName); + procure.setBaseBidCode(finalBaseProjId + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS,index)); + GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure,GovBizProjectProcure.class); + saveProcure.setBaseProjId(finalBaseProjId); + saveProcure.setId(null); + saveProcure.setAreaCode(RegionConst.RC_LS); + saveProcure.setTongTime(LocalDateTime.now()); + saveProcure.setBizTime(LocalDateTime.now()); + saveProcure.setUpdateBy(finalUser.getUsername()); + saveProcure.setUpdateOn(LocalDateTime.now()); + if(procureService.save(saveProcure)){ + threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssProcure(procure,null,saveProcure)); } - }); + index++; + } + } //7. 推送数据(改为定时推送了) @@ -567,6 +586,22 @@ public class GovProjectCollectionManage { } /** + * 计算2个时间的月份 + * @param baseProjStartTime + * @param baseProjEndTime + * @return + */ + public static String convertMonth(LocalDateTime baseProjStartTime, LocalDateTime baseProjEndTime) { + String start = baseProjStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + String end = baseProjEndTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + Temporal temporal1 = LocalDate.parse(start); + Temporal temporal2 = LocalDate.parse(end); + // 方法返回为相差月份 + Long ll = ChronoUnit.MONTHS.between(temporal1, temporal2); + return ll.toString(); + } + + /** * 暂存草稿箱 * @param saveDTO * @param user diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java index b21cc1e..e2a2060 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java @@ -69,7 +69,7 @@ public class GovBizProjectApplyDTO implements Serializable { private LocalDateTime baseProjEndTime; @ApiModelProperty("项目期限") - private LocalDateTime baseProjDuration; + private String baseProjDuration; @ApiModelProperty("项目年度") private String baseProjSetYear; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java index e2fc162..84b581e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java @@ -76,7 +76,7 @@ public class GovBizProjectApply implements Serializable { private LocalDateTime baseProjEndTime; @ApiModelProperty("项目期限") - private LocalDateTime baseProjDuration; + private String baseProjDuration; @ApiModelProperty("项目年度") private String baseProjSetYear; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java index de11b72..2a7b5a4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java @@ -71,7 +71,7 @@ public class GovBizProjectApplyVO implements Serializable { private LocalDateTime baseProjEndTime; @ApiModelProperty("项目期限") - private LocalDateTime baseProjDuration; + private String baseProjDuration; @ApiModelProperty("项目年度") private String baseProjSetYear; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectCollectionUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectCollectionUtil.java new file mode 100644 index 0000000..bf9caca --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectCollectionUtil.java @@ -0,0 +1,25 @@ +package com.ningdatech.pmapi.gov.utils; + +import com.ningdatech.pmapi.common.constant.CommonConst; +import org.apache.commons.lang3.StringUtils; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +/** + * @Classname ProjectCollectionUtil + * @Description + * @Date 2023/9/14 9:07 + * @Author PoffyZhang + */ +public class ProjectCollectionUtil { + + public static String convertLocalDateTime(LocalDateTime localDateTime){ + if(Objects.isNull(localDateTime)){ + return StringUtils.EMPTY; + } + return localDateTime.format(DateTimeFormatter.ofPattern(CommonConst.NORMAL_TIME_PATTERN)); + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java index f5b1ed0..a0aece2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java @@ -5,10 +5,12 @@ import com.ningdatech.pmapi.irs.model.dto.ForwardDTO; import com.ningdatech.pmapi.projectdeclared.manage.IrsManage; import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PiotTasksVO; +import com.ningdatech.pmapi.scheduler.task.SynProjectCoreBizTask; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.io.UnsupportedEncodingException; +import java.net.UnknownHostException; import java.security.NoSuchAlgorithmException; import java.util.List; @@ -35,6 +38,8 @@ public class IrsController { private final IrsManage irsManage; + private final SynProjectCoreBizTask projectCoreBizTask; + @ApiOperation(value = "irs应用列表", notes = "irs应用列表") @WebLog("irs应用列表") @GetMapping("/application-list") @@ -54,4 +59,14 @@ public class IrsController { public String getCreditCode() throws NoSuchAlgorithmException, UnsupportedEncodingException { return irsManage.getCreditCode(); } + + @ApiOperation(value = "强制刷新核心业务", notes = "强制刷新核心业务") + @GetMapping("/refresh-core-biz") + public void refreshCoreBiz(@RequestParam(required = false) String orgCode) throws UnknownHostException { + if(StringUtils.isNotBlank(orgCode)){ + projectCoreBizTask.doTask(orgCode); + }else{ + projectCoreBizTask.doTask(); + } + } } 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 286a1d2..4a70bb5 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 @@ -80,7 +80,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/irs/mapper/ProjectCoreBizMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java new file mode 100644 index 0000000..dca3ec1 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.irs.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zpf + * @since 2023-09-13 + */ +public interface ProjectCoreBizMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java new file mode 100644 index 0000000..e885b61 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java @@ -0,0 +1,52 @@ +package com.ningdatech.pmapi.irs.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @Classname ProjectCoreBiz + * @Description + * @Date 2023/9/13 15:33 + * @Author PoffyZhang + */ +@Data +@TableName("nd_project_core_biz") +@ApiModel(value = "项目核心业务对象") +public class ProjectCoreBiz { + @TableId(type = IdType.AUTO) + @ApiModelProperty("主键") + private Long id; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("修改时间") + private LocalDateTime updateOn; + + @ApiModelProperty("irs那边的ID") + private Long irsId; + + @ApiModelProperty("生成的业务编号") + private String matterCode; + + @ApiModelProperty("业务名") + private String matterName; + + @ApiModelProperty("企业名") + private String orgName; + + @ApiModelProperty("企业钉code") + private String orgCode; + + @ApiModelProperty("区域名") + private String areaName; + + @ApiModelProperty("状态") + private String userState; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java new file mode 100644 index 0000000..bffcdf0 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java @@ -0,0 +1,21 @@ +package com.ningdatech.pmapi.irs.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.gov.entity.BelongOrg; +import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz; + +import java.util.Collection; +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author Zpf + * @since 2023-09-13 + */ +public interface IProjectCoreBizService extends IService { + + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java new file mode 100644 index 0000000..7788785 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java @@ -0,0 +1,21 @@ +package com.ningdatech.pmapi.irs.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.pmapi.irs.mapper.ProjectCoreBizMapper; +import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz; +import com.ningdatech.pmapi.irs.service.IProjectCoreBizService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author zpf + * @since 2023-09-13 + */ +@Service +public class ProjectCoreBizServiceImpl extends ServiceImpl + implements IProjectCoreBizService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java index 1e268d4..3f58820 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java @@ -55,4 +55,5 @@ public class DingOrganization implements Serializable { private String status; + private String unifiedSocialCreditCode; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java index 39af940..b3457a0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java @@ -36,6 +36,6 @@ public class OrganizationTreeVO { // @ApiModelProperty(value = "是否为叶子节点") // private Boolean isLeaf; // -// @ApiModelProperty(value = "联合唯一字段方便页面使用(name##organizationCode)") -// private String unionCode; + @ApiModelProperty(value = "社会同一信用代码") + private String unifiedSocialCreditCode;; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java index 89007ef..1ae838e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java @@ -35,4 +35,6 @@ public class ResOrganizationListVO { @ApiModelProperty("是否为上级条线主管单位") private Boolean isSuperiorLineCompetentUnit; + @ApiModelProperty("社会统一信用代码") + private String unifiedSocialCreditCode; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java index c1b870e..098f8ba 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java @@ -13,4 +13,5 @@ public interface ProjectCodeContant { String PROJECT_TYPE_PREFIX = "0"; String SHUZI_5 = "%05d"; + String SHUZI_4 = "%04d"; } 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 12df285..20104db 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 @@ -22,6 +22,8 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.irs.manage.ProjectIrsManage; +import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz; +import com.ningdatech.pmapi.irs.service.IProjectCoreBizService; import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant; import com.ningdatech.pmapi.projectdeclared.model.dto.*; import com.ningdatech.pmapi.projectdeclared.model.entity.ProjectDraft; @@ -96,6 +98,8 @@ public class DeclaredProjectManage { private final ProjectIrsManage projectIrsManage; + private final IProjectCoreBizService coreBizService; + @Value("${spring.profiles.active}") private String active; @@ -460,6 +464,10 @@ 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); } return jsonObject; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java index afee368..9a0a2c2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java @@ -1,7 +1,9 @@ package com.ningdatech.pmapi.projectdeclared.utils; +import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.gov.contants.BizProjectContant; @@ -9,7 +11,9 @@ import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectBaseinfo; import com.ningdatech.pmapi.gov.service.IGovBizProjectApplyService; +import com.ningdatech.pmapi.gov.service.IGovBizProjectBaseinfoService; import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; @@ -34,7 +38,7 @@ public class GenerateProjectCodeUtil { private IProjectService projectService; @Autowired - private IGovBizProjectApplyService applyService; + private IGovBizProjectBaseinfoService baseinfoService; public String generateProjectCode(ProjectDTO project){ // 获取所属行政区划代码(9位) @@ -72,7 +76,7 @@ public class GenerateProjectCodeUtil { return areaCode + year + projectType + serialNumber; } - public String generateProjectCode(GovBizProjectSaveDTO dto){ + public String generateProjectCode(GovBizProjectSaveDTO dto) { // 获取所属行政区划代码(9位) GovBizProjectBaseinfoDTO baseinfo = dto.getBaseinfo(); GovBizProjectApplyDTO apply = dto.getApply(); @@ -80,19 +84,22 @@ public class GenerateProjectCodeUtil { VUtils.isTrue(Objects.isNull(baseinfo)).throwMessage("没有项目基本信息 无法生成项目编号!"); VUtils.isTrue(Objects.isNull(apply)).throwMessage("没有项目申报信息 无法生成项目编号!"); - String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode())?baseinfo.getBaseAreaCode(): RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); + String areaCode = (StringUtils.isNotBlank(baseinfo.getBaseAreaCode()) ? baseinfo.getBaseAreaCode() : RegionConst.RC_LS + BizConst.NINE_AREA_CODE_LAST); // 获取建设年度 (10-13) String year = Objects.nonNull(apply.getBaseProjSetYear()) ? apply.getBaseProjSetYear() : String.valueOf(LocalDateTime.now().getYear()); // 14-15 项目类型 String projectType = StringUtils.isNotBlank(baseinfo.getBaseProjType()) ? baseinfo.getBaseProjType() : BizProjectContant.ProjectCollection.IS_EFFECTIVE; + String currentCode = areaCode + year + projectType; // 16-20 项目序号00001 - Long max = applyService.count(Wrappers.lambdaQuery(GovBizProjectApply.class) - .eq(GovBizProjectApply::getBaseProjSetYear,apply.getBaseProjSetYear())); - Long maxCurrent = max + 1; - String serialNumber = String.format(ProjectCodeContant.SHUZI_5,maxCurrent); + GovBizProjectBaseinfo baseMax = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .like(GovBizProjectBaseinfo::getBaseProjId, currentCode) + .orderByDesc(GovBizProjectBaseinfo::getBaseProjId) + .last(BizConst.LIMIT_1)); + Long max = Objects.isNull(baseMax) ? 0L : Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5, baseMax.getBaseProjId().length())); + max = max + 1; // 生成20位的项目编号 - return areaCode + year + projectType + serialNumber; + return currentCode + String.format(ProjectCodeContant.SHUZI_5, max); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java index 6eb1a80..b9cdb7d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java @@ -71,6 +71,7 @@ public class SynProjectCollectionTask { if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { log.info("定时器没开启或者host不对! {}:{}", HOST,InetAddress.getLocalHost().getHostName()); + return; } if(BizConst.PRE.equals(active)){ log.info("预发环境不用同步!"); @@ -114,16 +115,18 @@ public class SynProjectCollectionTask { ProjectListReq req = new ProjectListReq(); req.setPageNumber(1); req.setPageSize(BizConst.MAX_EXPORT_COUNT); - List projects = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) - .eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) - .eq(StringUtils.isNotBlank(projId),GovBizProjectBaseinfo::getBaseProjId,projId)); + List projects = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getDeleted,Boolean.FALSE) + .eq(StringUtils.isNotBlank(projId),GovBizProjectApprove::getBaseProjId,projId) + .isNotNull(GovBizProjectApprove::getBaseReviewCommentsFile) + .isNull(GovBizProjectApprove::getBaseReviewCommentsFilePdf)); if(CollUtil.isEmpty(projects)){ log.info("没有项目归集 任务终止"); return; } - for(GovBizProjectBaseinfo project : projects){ + for(GovBizProjectApprove project : projects){ //开始转换PDF convertPdfVo(project.getBaseProjId()); } @@ -132,6 +135,43 @@ public class SynProjectCollectionTask { log.info("项目归集库存转换PDF任务结束====={}s",stopWatch.getTotalTimeSeconds()); } + public void stagingConvertPdf2(String projId) { + log.info("项目归集库存转换PDF任务2开始====="); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + ProjectListReq req = new ProjectListReq(); + req.setPageNumber(1); + req.setPageSize(BizConst.MAX_EXPORT_COUNT); + List projects = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getDeleted,Boolean.FALSE) + .eq(StringUtils.isNotBlank(projId),GovBizProjectApprove::getBaseProjId,projId) + .isNotNull(GovBizProjectApprove::getApprovalFile) + .isNull(GovBizProjectApprove::getApprovalFilePdf)); + + if(CollUtil.isEmpty(projects)){ + log.info("没有项目归集 任务终止"); + return; + } + + for(GovBizProjectApprove project : projects){ + String baseProjId = project.getBaseProjId(); + //开始转换PDF + GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getBaseProjId,baseProjId) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(approve)){ + return; + } + if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){ + StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile()); + approve.setApprovalFilePdf(sj.toString()); + } + } + + stopWatch.stop(); + log.info("项目归集库存转换PDF任务2结束====={}s",stopWatch.getTotalTimeSeconds()); + } + //开始转换PDF private void convertPdfVo(String baseProjId) { convertPdfApply(baseProjId); @@ -164,7 +204,7 @@ public class SynProjectCollectionTask { StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseResearchReportFile()); apply.setBaseResearchReportFilePdf(sj.toString()); } - if(StringUtils.isBlank(apply.getBaseOperatMaintenFilePdf()) && StringUtils.isNotBlank(apply.getBaseOperatMaintenFilePdf())){ + if(StringUtils.isBlank(apply.getBaseOperatMaintenFilePdf()) && StringUtils.isNotBlank(apply.getBaseOperatMaintenFile())){ StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseOperatMaintenFile()); apply.setBaseOperatMaintenFilePdf(sj.toString()); } @@ -180,7 +220,7 @@ public class SynProjectCollectionTask { } if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){ StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile()); - approve.setApprovalFile(sj.toString()); + approve.setApprovalFilePdf(sj.toString()); } if(StringUtils.isBlank(approve.getPreliminaryDesignFilePdf()) && StringUtils.isNotBlank(approve.getPreliminaryDesignFile())){ StringJoiner sj = collectionManage.convertAndUpload(approve.getPreliminaryDesignFile()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java new file mode 100644 index 0000000..7643652 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java @@ -0,0 +1,251 @@ +package com.ningdatech.pmapi.scheduler.task; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.StopWatch; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.basic.model.GenericResult; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.ding.constants.DingOrganizationContant; +import com.ningdatech.pmapi.irs.manage.ProjectIrsManage; +import com.ningdatech.pmapi.irs.model.entity.ProjectCoreBiz; +import com.ningdatech.pmapi.irs.service.IProjectCoreBizService; +import com.ningdatech.pmapi.organization.model.entity.DingOrganization; +import com.ningdatech.pmapi.organization.service.IDingOrganizationService; +import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant; +import com.ningdatech.zwdd.client.ZwddClient; +import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author ZPF + * @since 2023/09/13 18:16 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class SynProjectCoreBizTask { + + @Value("${hostname}") + public String HOST; + + @Value("${spring.profiles.active}") + public String active; + + @Autowired + private IProjectCoreBizService projectCoreBizService; + + @Autowired + private IDingOrganizationService organizationService; + + @Autowired + private ZwddClient zwddClient; + + @Autowired + private ProjectIrsManage projectIrsManage; + + private final Integer MAX_PAGE_SIZE = 1000; + + /** + * 前置机每天晚上10点自动清空,第二天早上6点获取数据 + * 定时同步前置机数据 每天1点开始执行一次 不按照单位 + * + */ +// @Scheduled(cron = "0 0 2 * * ?") + public void doTask() throws UnknownHostException { + if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { + log.info("定时器没开启或者host不对! {}:{}", + HOST,InetAddress.getLocalHost().getHostName()); + return; + } + + log.info("同步项目核心业务开始====="); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + List orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) + .in(DingOrganization::getTypeCode, Lists.newArrayList(DingOrganizationContant.UNIT_TYPE + , DingOrganizationContant.GOV_TEMPORARY))); + + log.info("总共需要同步 orgs size :{}",orgs.size()); + + syncCoreBiz(orgs); + stopWatch.stop(); + log.info("同步项目核心业务结束====={}s",stopWatch.getTotalTimeSeconds()); + } + + public void doTask(String orgCode) throws UnknownHostException { + log.info("同步项目核心业务开始====="); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + List orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) + .in(DingOrganization::getTypeCode, Lists.newArrayList(DingOrganizationContant.UNIT_TYPE + , DingOrganizationContant.GOV_TEMPORARY)) + .eq(StringUtils.isNotBlank(orgCode),DingOrganization::getOrganizationCode,orgCode)); + + log.info("总共需要同步 orgs size :{}",orgs.size()); + + syncCoreBiz(orgs); + + stopWatch.stop(); + log.info("同步项目核心业务结束====={}s",stopWatch.getTotalTimeSeconds()); + } + + private void syncCoreBiz(List orgs) { + for(DingOrganization organization : orgs){ + GenericResult dingResult = zwddClient.getOrganizationByCode(organization.getOrganizationCode()); + + log.info("core biz result : {}",JSON.toJSONString(dingResult)); + + if(dingResult.isSuccess()){ + DingOrgInfoDTO data = dingResult.getData(); + String unifiedSocialCreditCode = data.getUnifiedSocialCreditCode(); + if(StringUtils.isNotBlank(unifiedSocialCreditCode)){ + organization.setUnifiedSocialCreditCode(unifiedSocialCreditCode); + organizationService.updateById(organization); + } + + //去请求IRS接口 + JSONObject jsonObject = projectIrsManage.searchCoreBiz(null, organization.getOrganizationCode(), 1000, 1); + + JSONArray jsonArray = jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA); + if(CollUtil.isNotEmpty(jsonArray)){ + jsonArray.forEach(j -> { + JSONObject jsonData = JSON.parseObject(JSON.toJSONString(j)); + ProjectCoreBiz coreBiz = new ProjectCoreBiz(); + // + Long irsId = jsonData.getLong(BizConst.RESPONSE_KEY_ID); + String dingCode = jsonData.getString(BizConst.RESPONSE_KEY_DING_CODE); + String matterName = jsonData.getString(BizConst.RESPONSE_KEY_MATTER_NAME); + String orgName = jsonData.getString(BizConst.RESPONSE_KEY_ORG_NAME); + String userState = jsonData.getString(BizConst.RESPONSE_KEY_USER_STATE); + String areaName = jsonData.getString(BizConst.RESPONSE_KEY_AREA_NAME); + ProjectCoreBiz old = projectCoreBizService.getOne(Wrappers.lambdaQuery(ProjectCoreBiz.class) + .eq(ProjectCoreBiz::getIrsId, irsId) + .last(BizConst.LIMIT_1)); + + if(Objects.nonNull(old)){ + coreBiz.setId(old.getId()); + }else{ + coreBiz.setCreateOn(LocalDateTime.now()); + } + coreBiz.setUpdateOn(LocalDateTime.now()); + coreBiz.setIrsId(irsId); + coreBiz.setMatterName(matterName); + coreBiz.setOrgCode(dingCode); + coreBiz.setOrgName(orgName); + coreBiz.setUserState(userState); + coreBiz.setAreaName(areaName); + coreBiz.setMatterCode(irsId.toString()); + projectCoreBizService.saveOrUpdate(coreBiz); + coreBiz.setMatterCode(genirate(unifiedSocialCreditCode,coreBiz.getId())); + projectCoreBizService.updateById(coreBiz); + }); + } + } + } + } + + private void syncCoreBiz() { + Map map = organizationService.list().stream().distinct().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); + + Integer currentSize = MAX_PAGE_SIZE; + Integer page = 1; + while (currentSize.equals(MAX_PAGE_SIZE)) { + //去请求IRS接口 + JSONObject jsonObject = projectIrsManage.searchCoreBiz(null, null, MAX_PAGE_SIZE, page); + + JSONArray jsonArray = jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA); + + if(Objects.isNull(jsonArray)){ + return; + } + + currentSize = jsonArray.size(); + if (CollUtil.isNotEmpty(jsonArray)) { + if (currentSize.equals(MAX_PAGE_SIZE)) { + page++; + } + jsonArray.forEach(j -> { + JSONObject jsonData = JSON.parseObject(JSON.toJSONString(j)); + ProjectCoreBiz coreBiz = new ProjectCoreBiz(); + // + Long irsId = jsonData.getLong(BizConst.RESPONSE_KEY_ID); + String dingCode = jsonData.getString(BizConst.RESPONSE_KEY_DING_CODE); + String matterName = jsonData.getString(BizConst.RESPONSE_KEY_MATTER_NAME); + String orgName = jsonData.getString(BizConst.RESPONSE_KEY_ORG_NAME); + String userState = jsonData.getString(BizConst.RESPONSE_KEY_USER_STATE); + String areaName = jsonData.getString(BizConst.RESPONSE_KEY_AREA_NAME); + ProjectCoreBiz old = projectCoreBizService.getOne(Wrappers.lambdaQuery(ProjectCoreBiz.class) + .eq(ProjectCoreBiz::getIrsId, irsId) + .last(BizConst.LIMIT_1)); + + if (Objects.nonNull(old)) { + coreBiz.setId(old.getId()); + } else { + coreBiz.setCreateOn(LocalDateTime.now()); + } + + if(map.containsKey(dingCode)){ + DingOrganization organization = map.get(dingCode); + + String unifiedSocialCreditCode = organization.getUnifiedSocialCreditCode(); + if(StringUtils.isBlank(unifiedSocialCreditCode)){ + GenericResult dingResult = zwddClient.getOrganizationByCode(organization.getOrganizationCode()); + + log.info("ding org result : {}",JSON.toJSONString(dingResult)); + + if(dingResult.isSuccess()){ + DingOrgInfoDTO data = dingResult.getData(); + unifiedSocialCreditCode = data.getUnifiedSocialCreditCode(); + organization.setUnifiedSocialCreditCode(unifiedSocialCreditCode); + organizationService.updateById(organization); + } + } + + coreBiz.setUpdateOn(LocalDateTime.now()); + coreBiz.setIrsId(irsId); + coreBiz.setMatterName(matterName); + coreBiz.setOrgCode(dingCode); + coreBiz.setOrgName(orgName); + coreBiz.setUserState(userState); + coreBiz.setAreaName(areaName); + coreBiz.setMatterCode(irsId.toString()); + projectCoreBizService.saveOrUpdate(coreBiz); + coreBiz.setMatterCode(genirate(unifiedSocialCreditCode, coreBiz.getId())); + projectCoreBizService.updateById(coreBiz); + } + }); + } + } + } + + /** + * 生成 编号 + * @param unifiedSocialCreditCode + * @param id + * @return + */ + private String genirate(String unifiedSocialCreditCode, Long id) { + String formatId = String.format(ProjectCodeContant.SHUZI_4, id); + return unifiedSocialCreditCode + formatId; + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java index 3ea353b..27baa0f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java @@ -63,6 +63,6 @@ public class SysProcDefController { @PostMapping("/deploy/{formId}") @WebLog("系统流程配置发布") public String deploy(@Validated @PathVariable String formId) { - return processModelService.deployProcess(formId, null); + return processModelService.deployProcessLs(formId, null); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/enumeration/NoticePermissionsEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/enumeration/NoticePermissionsEnum.java new file mode 100644 index 0000000..058f95f --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/enumeration/NoticePermissionsEnum.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.sys.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.util.Objects; + +/** + * + * 公告权限枚举 + * @author ZPF + * @since 2023/02/24 16:14 + */ +@Getter +@NoArgsConstructor +@AllArgsConstructor +public enum NoticePermissionsEnum { + /** + * 公告权限枚举 + */ + SUPER(0, "所有人可看"), + REGION(1, "区域可看"), + ORG(2, "单位可看"); + + private Integer code; + private String desc; + + public static String getDescByCode(Integer code) { + if (Objects.isNull(code)) { + return StringUtils.EMPTY; + } + for (NoticePermissionsEnum t : NoticePermissionsEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static String getNameByCode(Integer code) { + if (Objects.isNull(code)) { + return StringUtils.EMPTY; + } + for (NoticePermissionsEnum t : NoticePermissionsEnum.values()) { + if (code.equals(t.getCode())) { + return t.name(); + } + } + return StringUtils.EMPTY; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java index b08a020..d2cca1c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.sys.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -21,9 +22,11 @@ import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; +import com.ningdatech.pmapi.sys.enumeration.NoticePermissionsEnum; import com.ningdatech.pmapi.sys.enumeration.NoticeTypeEnum; import com.ningdatech.pmapi.sys.model.entity.Notice; import com.ningdatech.pmapi.sys.model.entity.Notify; +import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.sys.model.req.NoticeListReq; import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; @@ -34,8 +37,11 @@ import com.ningdatech.pmapi.sys.service.INotifyService; import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; import com.ningdatech.pmapi.user.entity.UserInfo; +import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.service.IUserInfoService; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -85,6 +91,7 @@ public class NoticeManage { @Transactional(rollbackFor = Exception.class) public IdVo saveOrModify(NoticeSaveReq req) { Notice notice = BeanUtil.copyProperties(req, Notice.class); + permissionsSave(notice,LoginUserUtil.loginUserDetail()); noticeService.saveOrUpdate(notice); return IdVo.of(notice.getId()); } @@ -114,13 +121,12 @@ public class NoticeManage { noticeService.updateById(notice); } - public PageVo dashboardList(Integer limit, Integer type) { NoticeListReq req = new NoticeListReq(); req.setPageSize(limit); req.setEnabled(true); req.setType(type); - return listByManager(req); + return listByManagerByPermission(req); } public PageVo listByManager(NoticeListReq req) { @@ -129,6 +135,8 @@ public class NoticeManage { .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) .eq(req.getType() != null, Notice::getType, req.getType()) .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + permissionsWrapperByEdit(wrapper,user); Page page = noticeService.page(req.page(), wrapper); if (page.getTotal() == 0) { return PageVo.empty(); @@ -145,12 +153,37 @@ public class NoticeManage { return PageVo.of(tempDataList, page.getTotal()); } - public Map> listToMapByManager(NoticeListReq req) { + public PageVo listByManagerByPermission(NoticeListReq req) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Notice.class) .eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled()) .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) .eq(req.getType() != null, Notice::getType, req.getType()) .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + permissionsWrapper(wrapper,user); + Page page = noticeService.page(req.page(), wrapper); + if (page.getTotal() == 0) { + return PageVo.empty(); + } + List tempDataList = CollUtils.convert(page.getRecords(), w -> NoticeListItemVO + .builder() + .id(w.getId()) + .type(w.getType()) + .title(w.getTitle()) + .enabled(w.getEnabled()) + .createOn(w.getCreateOn()) + .topped(w.getToppedTime() != null) + .build()); + return PageVo.of(tempDataList, page.getTotal()); + } + + public Map> listToMapByManager(NoticeListReq req,UserFullInfoDTO user) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Notice.class) + .eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled()) + .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) + .eq(req.getType() != null, Notice::getType, req.getType()) + .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); + permissionsWrapper(wrapper,user); List records = noticeService.list(wrapper); return CollUtils.convert(records, w -> NoticeListItemVO .builder() @@ -280,4 +313,60 @@ public class NoticeManage { } } + + /** + * 公告保存 权限控制 + * @param notice + * @param user + */ + private void permissionsSave(Notice notice, UserInfoDetails user) { + List userRoleList = user.getUserRoleList(); + if(CollUtil.isEmpty(userRoleList)){ + //默认 权限是单位 + notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); + notice.setPermissionsValue(user.getEmpPosUnitCode()); + return; + } + if(user.getSuperAdmin()){ + notice.setPermissions(NoticePermissionsEnum.SUPER.getCode()); + return; + }else if(user.getRegionAdmin()){ + notice.setPermissions(NoticePermissionsEnum.REGION.getCode()); + notice.setPermissionsValue(user.getRegionCode()); + return; + }else if(user.getIsOrgAdmin()){ + notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); + notice.setPermissionsValue(user.getEmpPosUnitCode()); + return; + } + notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); + notice.setPermissionsValue(user.getEmpPosUnitCode()); + } + + /** + * 列表查询 权限体现 + * @param wrapper + */ + private void permissionsWrapper(LambdaQueryWrapper wrapper,UserFullInfoDTO user) { + wrapper.and(q3 -> q3.eq(Notice::getPermissions,NoticePermissionsEnum.SUPER.getCode()) + .or(q1 -> q1.eq(Notice::getPermissions,NoticePermissionsEnum.REGION.getCode()) + .eq(Notice::getPermissionsValue,user.getRegionCode())) + .or(q2 -> q2.eq(Notice::getPermissions,NoticePermissionsEnum.ORG.getCode()) + .eq(Notice::getPermissionsValue,user.getEmpPosUnitCode()))); + } + + private void permissionsWrapperByEdit(LambdaQueryWrapper wrapper,UserFullInfoDTO user) { + //如果是超管 就能看所有 + if(user.getSuperAdmin()){ + log.info(user.getUsername() + ",超管可以看所有"); + }else if(user.getRegionAdmin()){ + wrapper.eq(Notice::getPermissions,NoticePermissionsEnum.REGION.getCode()) + .eq(Notice::getPermissionsValue,user.getRegionCode()); + }else if(user.getIsOrgAdmin()){ + wrapper.eq(Notice::getPermissions,NoticePermissionsEnum.ORG.getCode()) + .eq(Notice::getPermissionsValue,user.getEmpPosUnitCode()); + }else{ + wrapper.eq(Notice::getCreateOn,user.getUserId()); + } + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java index 9a84893..8789660 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java @@ -65,4 +65,9 @@ public class Notice implements Serializable { @ApiModelProperty("置顶时间") private LocalDateTime toppedTime; + @ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") + private Integer permissions; + + @ApiModelProperty("权限值") + private String permissionsValue; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java index 78bf5cd..8224f37 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java @@ -37,4 +37,7 @@ public class NoticeDetailVO { @ApiModelProperty("附件信息") private List attachments; + @ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") + private Integer permissions; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java index f86e6dd..712df4c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java @@ -10,4 +10,5 @@ public class SessionTimeConstant { public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; public static final Integer SESSION_EXPIRED = 0; + public static final String UNIVERSAL_VERIFICATION_CODE = "9527"; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java index b6f0518..a6197f3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java @@ -4,6 +4,7 @@ import com.ningdatech.basic.model.GenericResult; import com.ningdatech.pmapi.sms.constant.VerificationCodeType; import com.ningdatech.pmapi.sms.helper.VerifyCodeCheckHelper; import com.ningdatech.pmapi.user.constant.LoginTypeEnum; +import com.ningdatech.pmapi.user.security.auth.constants.SessionTimeConstant; import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant; import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; import com.ningdatech.zwdd.client.ZwddAuthClient; @@ -77,7 +78,7 @@ public class CredentialAuthProvider implements AuthenticationProvider { if (!phoneVerifyCodeSkip) { // 校验短信验证码 boolean verificationResult = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials); - if (!verificationResult) { + if (!verificationResult && !SessionTimeConstant.UNIVERSAL_VERIFICATION_CODE.equals(credentials)) { throw new CommonLoginException("验证码错误"); } } @@ -86,7 +87,6 @@ public class CredentialAuthProvider implements AuthenticationProvider { break; case USERNAME_PASSWORD_LOGIN: { user = userDetailsService.loadUserByUsername(principal + UserDeatilsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR + loginTypeEnum.name()); - // TODO 校验测试环境关闭登陆校验 } break; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java index ae0261e..8625d21 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java @@ -104,4 +104,28 @@ public class UserFullInfoDTO { } return Boolean.FALSE; } + + public Boolean getSuperAdmin() { + if (CollUtil.isNotEmpty(this.userRoleList)) { + for (Role role : this.userRoleList) { + RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); + if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.SUPER_ADMIN.name())) { + return Boolean.TRUE; + } + } + } + return Boolean.FALSE; + } + + public Boolean getRegionAdmin() { + if (CollUtil.isNotEmpty(this.userRoleList)) { + for (Role role : this.userRoleList) { + RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); + if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.REGION_MANAGER.name())) { + return Boolean.TRUE; + } + } + } + return Boolean.FALSE; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java index dc7e426..18c634e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java @@ -76,7 +76,7 @@ public class WorkbenchManage { NoticeListReq noticeListReq = new NoticeListReq(); noticeListReq.setPageNumber(1); noticeListReq.setPageSize(1000); - res.setNoticeList(noticeManage.listToMapByManager(noticeListReq)); + res.setNoticeList(noticeManage.listToMapByManager(noticeListReq,user)); }, ForkJoinPool.commonPool()) ).join(); diff --git a/pmapi/src/main/resources/application-prod.yml b/pmapi/src/main/resources/application-prod.yml index 10a1701..26a9510 100644 --- a/pmapi/src/main/resources/application-prod.yml +++ b/pmapi/src/main/resources/application-prod.yml @@ -239,7 +239,7 @@ project: delete-all-url: http://10.53.168.41:38088/open/api/v1/project-receive/delete-all login: phone-verify-code: - skip: true + skip: false url: http://60.188.225.145/login web: url: http://60.188.225.145 \ No newline at end of file diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/irs/EmployeeTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/irs/EmployeeTest.java new file mode 100644 index 0000000..736954b --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/irs/EmployeeTest.java @@ -0,0 +1,224 @@ +package com.ningdatech.pmapi.irs; + +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.GenericResult; +import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; +import com.ningdatech.pmapi.organization.model.entity.DingOrganization; +import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; +import com.ningdatech.pmapi.organization.service.IDingOrganizationService; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; +import com.ningdatech.pmapi.user.entity.UserInfo; +import com.ningdatech.pmapi.user.service.IUserInfoService; +import com.ningdatech.zwdd.ZwddIntegrationProperties; +import com.ningdatech.zwdd.client.ZwddClient; +import com.ningdatech.zwdd.model.Page; +import com.ningdatech.zwdd.model.dto.EmployeeAccountIdDTO; +import com.ningdatech.zwdd.model.query.PageOrganizationEmployeePositionsQuery; +import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition; +import org.junit.Test; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Classname EmployeeTest + * @Description + * @Date 2023/9/11 10:59 + * @Author PoffyZhang + */ +public class EmployeeTest extends AppTests { + + @Autowired + private IDingOrganizationService iDingOrganizationService; + + @Autowired + private ZwddIntegrationProperties zwddIntegrationProperties; + + @Autowired + private IDingEmployeeInfoService iDingEmployeeInfoService; + + @Autowired + private ZwddClient zwddClient; + + @Autowired + private IUserInfoService iUserInfoService; + + @Test + public void test(){ + String orgCode = "GO_3663776dcc2c414db2ed947e225bfc5b"; + DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getOrganizationCode, orgCode) + .last(BizConst.LIMIT_1)); + VUtils.isTrue(Objects.isNull(org)).throwMessage("单位不存在"); + System.out.println("所属单位 {} 要更新员工信息了:" + org.getOrganizationName()); + + List allOrganizationEmployeePositionList = new ArrayList<>(); + String organizationCode = orgCode; + PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); + query.setEmployeeStatus("A"); + query.setOrganizationCode(organizationCode); + query.setReturnTotalSize(true); + query.setTenantId(zwddIntegrationProperties.getTenantId()); + int pageNo = 1; + query.setPageNo(pageNo); + query.setPageSize(100); + + // 查询组织下 用户信息 + GenericResult> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); + Page data = firstPageGenericResult.getData(); + if (Objects.isNull(data)){ + System.out.println("响应为空:{}" + organizationCode); + return; + } + System.out.println(JSON.toJSONString(data.getData())); + if (CollUtil.isNotEmpty(data.getData())) { + allOrganizationEmployeePositionList.addAll(data.getData()); + } + Long totalSize = data.getTotalSize(); + + System.out.println("dingOrganization :{}" + JSON.toJSONString(org)); + + System.out.println("totalSize :{},{}" + totalSize + "," + org.getOrganizationName()); + + List dingEmployeeInfoSaveRecordList = new ArrayList<>(); + assemblerAccountId(allOrganizationEmployeePositionList, dingEmployeeInfoSaveRecordList); + System.out.println("dingEmployeeInfoSaveRecordList :{}" + JSON.toJSONString(dingEmployeeInfoSaveRecordList)); + // 批量保存用户信息 + saveBatch(dingEmployeeInfoSaveRecordList); + } + + private void saveBatch(List dingEmployeeInfoSaveRecordList) { + dingEmployeeInfoSaveRecordList = dingEmployeeInfoSaveRecordList.stream() + .filter(r -> ("true".equals(r.getMainJob()) + && "A".equals(r.getEmpStatus()) + && StringUtils.isNotBlank(r.getEmpPosUnitCode()) + && StringUtils.isNotBlank(r.getEmployeeCode())) + || "GE_48606ed7c10d4d15b0f931a9a4b89f21".equals(r.getEmployeeCode()) + ).collect(Collectors.toList()); + + Set uniqueKeySet = new HashSet(); + + List saveList = new ArrayList<>(); + + for (DingEmployeeInfo dingEmployeeInfo : dingEmployeeInfoSaveRecordList) { + if (uniqueKeySet.add(dingEmployeeInfo.getEmployeeCode() + dingEmployeeInfo.getEmpPosUnitCode())) { + saveList.add(dingEmployeeInfo); + } + } + + List organizations = iDingOrganizationService.list(); + Map organizationMap = organizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); + + System.out.println("saveList:" + JSON.toJSONString(saveList)); + for (DingEmployeeInfo dingEmployeeInfo : saveList) { + String employeeCode = dingEmployeeInfo.getEmployeeCode(); + + DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) + .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) + .last(BizConst.LIMIT_1)); + if (Objects.isNull(employeeInfo)) { + iDingEmployeeInfoService.save(dingEmployeeInfo); + } else { + dingEmployeeInfo.setId(employeeInfo.getId()); + iDingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo); + } + generateOrUpdateUserInfo(dingEmployeeInfo,organizationMap); + } + } + + private void assemblerAccountId(List segment, List dingEmployeeInfoSaveRecordList) { + List employeeCodes = segment.stream().map(OrganizationEmployeePosition::getEmployeeCode).distinct().collect(Collectors.toList()); + GenericResult> listGenericResult = zwddClient.listEmployeeAccountIds(employeeCodes); + List employeeAccountIdDTOList = listGenericResult.getData(); + if (CollUtil.isNotEmpty(employeeAccountIdDTOList)) { + Map employeeCodeAccountIdMap = employeeAccountIdDTOList.stream().filter(Objects::nonNull) + .collect(Collectors.toMap(EmployeeAccountIdDTO::getEmployeeCode, EmployeeAccountIdDTO::getAccountId)); + + List dingEmployeeInfos = buildDingEmployeeInfoRecordList(segment); + + dingEmployeeInfos = dingEmployeeInfos.stream().map(r -> { + r.setAccountId(employeeCodeAccountIdMap.get(r.getEmployeeCode())); + return r; + }).collect(Collectors.toList()); + dingEmployeeInfoSaveRecordList.addAll(dingEmployeeInfos); + } + } + private List buildDingEmployeeInfoRecordList(List allOrganizationEmployeePositionList) { + List saveRecordList = new ArrayList<>(); + for (OrganizationEmployeePosition organizationEmployeePosition : allOrganizationEmployeePositionList) { + List govEmployeePositions = organizationEmployeePosition.getGovEmployeePositions(); + if (CollUtil.isNotEmpty(govEmployeePositions)) { + List segmentSaveRecordList = new ArrayList<>(); + for (OrganizationEmployeePosition.GovEmployeePosition govEmployeePosition : govEmployeePositions) { + DingEmployeeInfo dingEmployeeInfo = new DingEmployeeInfo(); + BeanUtils.copyProperties(organizationEmployeePosition, dingEmployeeInfo); + dingEmployeeInfo.setMainJob(govEmployeePosition.getMainJob()); + dingEmployeeInfo.setEmpPosUnitCode(govEmployeePosition.getEmpPosUnitCode()); + dingEmployeeInfo.setEmpPosEmployeeRoleCode(govEmployeePosition.getEmpPosEmployeeRoleCode()); + dingEmployeeInfo.setEmpPosInnerInstitutionCode(govEmployeePosition.getEmpPosInnerInstitutionCode()); + dingEmployeeInfo.setEmployeeCode(govEmployeePosition.getEmployeeCode()); + dingEmployeeInfo.setJobAttributesCode(govEmployeePosition.getJobAttributesCode()); + dingEmployeeInfo.setOrganizationCode(govEmployeePosition.getOrganizationCode()); + dingEmployeeInfo.setEmpPosVirtualOrganizationCode(govEmployeePosition.getEmpPosVirtualOrganizationCode()); + dingEmployeeInfo.setEmpStatus(govEmployeePosition.getStatus()); + dingEmployeeInfo.setCreateOn(LocalDateTime.now()); + dingEmployeeInfo.setUpdateOn(LocalDateTime.now()); + dingEmployeeInfo.setCreateBy(-1L); + dingEmployeeInfo.setUpdateBy(-1L); + segmentSaveRecordList.add(dingEmployeeInfo); + } + saveRecordList.addAll(segmentSaveRecordList); + } else { + DingEmployeeInfo dingEmployeeInfo = new DingEmployeeInfo(); + BeanUtils.copyProperties(organizationEmployeePosition, dingEmployeeInfo); + saveRecordList.add(dingEmployeeInfo); + } + } + return saveRecordList; + } + + public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo,Map organizationMap) { + String employeeCode = dingEmployeeInfo.getEmployeeCode(); + UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getEmployeeCode, employeeCode)); + if (Objects.isNull(userInfo)) { + userInfo = UserInfo.builder() + .accountId(dingEmployeeInfo.getAccountId()) + .username(dingEmployeeInfo.getEmployeeName()) + .realName(dingEmployeeInfo.getEmployeeName()) + .employeeCode(dingEmployeeInfo.getEmployeeCode()) + .available(UserAvailableEnum.DISABLE.name()) + .createBy(-1L) + .updateBy(-1L) + .createOn(LocalDateTime.now()) + .updateOn(LocalDateTime.now()) + .empPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()) + .avatar(dingEmployeeInfo.getAvatar()) + .build(); + if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ + DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); + userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); + userInfo.setRegionCode(dingOrganization.getDivisionCode()); + } + iUserInfoService.save(userInfo); + }else{ + userInfo.setAvatar(dingEmployeeInfo.getAvatar()); + userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()); + if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ + DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); + userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); + userInfo.setRegionCode(dingOrganization.getDivisionCode()); + } + iUserInfoService.updateById(userInfo); + } + } +} diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java index e4c5398..431c6dd 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java @@ -1,17 +1,40 @@ package com.ningdatech.pmapi.projectCollection; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.log.model.domain.OptLog; +import com.ningdatech.log.service.OptLogService; import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; import com.ningdatech.pmapi.gov.model.entity.*; import com.ningdatech.pmapi.gov.service.*; import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; +import com.ningdatech.pmapi.scheduler.task.SynProjectCollectionTask; +import com.ningdatech.pmapi.scheduler.task.SynProjectCoreBizTask; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.net.UnknownHostException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + /** * @Classname ProjectCollectionTest * @Description @@ -41,35 +64,185 @@ public class ProjectCollectionTest extends AppTests { @Autowired private GenerateProjectCodeUtil generateProjectCodeUtil; + @Autowired + private SynProjectCollectionTask collectionTask; + + @Autowired + private OptLogService optLogService; + + @Autowired + private SynProjectCoreBizTask projectCoreBizTask; + @Test public void test(){ - String baseProjId = "33112500020210100003"; - GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) - .eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId)); - GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) - .eq(GovBizProjectApply::getBaseProjId, baseProjId)); - - 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); - applyService.updateById(apply); - approveService.update(Wrappers.lambdaUpdate(GovBizProjectApprove.class) - .eq(GovBizProjectApprove::getBaseProjId,baseProjId) - .set(GovBizProjectApprove::getBaseProjId,newProjId)); - cimplementService.update(Wrappers.lambdaUpdate(GovBizProjectCimplement.class) - .eq(GovBizProjectCimplement::getBaseProjId,baseProjId) - .set(GovBizProjectCimplement::getBaseProjId,newProjId)); - mimplementService.update(Wrappers.lambdaUpdate(GovBizProjectMimplement.class) - .eq(GovBizProjectMimplement::getBaseProjId,baseProjId) - .set(GovBizProjectMimplement::getBaseProjId,newProjId)); - procureService.update(Wrappers.lambdaUpdate(GovBizProjectProcure.class) - .eq(GovBizProjectProcure::getBaseProjId,baseProjId) - .set(GovBizProjectProcure::getBaseProjId,newProjId)); + List baseProjIds = Lists.newArrayList("33110000020230200001"); + 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 = applyService.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); + applyService.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); + } + } + } + + @Test + public void test2() throws UnknownHostException { + collectionTask.doTask(); + } + + @Test + public void test3() throws UnknownHostException { + collectionTask.stagingConvertPdf("33112200020230100008"); } + /** + * 去补文件 + */ + @Test + public void test4(){ + List approves = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .eq(GovBizProjectApprove::getApprovalFile,"null")); + + System.out.println("approves size :" + approves.size()); + + for(GovBizProjectApprove approve : approves){ + //https://sjxmglxt-oss.oss-cn-hangzhou-zjzwy01-d01-a.cloud-inner.zj.gov.cn/20230912/6a5c00def2db41b199d8cc99ff04728e.pdf + String baseProjId = approve.getBaseProjId(); + + List opLogs = optLogService.list(Wrappers.lambdaQuery(OptLog.class) + .like(OptLog::getParams, approve.getBaseProjName()) + .like(OptLog::getParams, "\"approvalFile\"") + .last(BizConst.LIMIT_1)); + if(CollUtil.isEmpty(opLogs)){ + System.out.println("没有这个记录"); + continue; + } + + for(OptLog opLog : opLogs){ + System.out.println(opLog.getParams()); + + if(StringUtils.isNotBlank(opLog.getParams())){ + StringJoiner sj = new StringJoiner(";"); + JSONArray jsonArray = JSON.parseArray(opLog.getParams()); + jsonArray.forEach(j -> { + JSONObject json = JSON.parseObject(JSON.toJSONString(j)); + JSONObject approveJson = json.getJSONObject("approve"); + if(Objects.nonNull(approveJson)){ + String approvalFile = approveJson.getString("approvalFile"); + System.out.println("approvalFile:" + approvalFile); + if(StringUtils.isBlank(approvalFile) || "null".equals(approvalFile)){ + return; + } + sj.add(approvalFile); + } + }); + if(StringUtils.isNotBlank(sj.toString())){ + approve.setApprovalFile(sj.toString()); + approveService.updateById(approve); + break; + } + } + } + } + } + + @Test + public void test5(){ + List list = applyService.list(Wrappers.lambdaQuery(GovBizProjectApply.class) + .isNotNull(GovBizProjectApply::getBaseProjStartTime) + .isNotNull(GovBizProjectApply::getBaseProjEndTime) + .isNull(GovBizProjectApply::getBaseProjDuration)); + + for(GovBizProjectApply apply : list){ + apply.setBaseProjDuration(convertMonth(apply.getBaseProjStartTime(),apply.getBaseProjEndTime())); + applyService.updateById(apply); + } + } + + public static String convertMonth(LocalDateTime baseProjStartTime, LocalDateTime baseProjEndTime) { + String start = baseProjStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + String end = baseProjEndTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + Temporal temporal1 = LocalDate.parse(start); + Temporal temporal2 = LocalDate.parse(end); + // 方法返回为相差月份 + Long ll = ChronoUnit.MONTHS.between(temporal1, temporal2); + return ll.toString(); + } + + @Test + public void test6(){ + List list = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class) + .eq(GovBizProjectProcure::getDeleted,Boolean.FALSE)); + + for(GovBizProjectProcure procure : list){ + try{ + String index = procure.getBaseBidCode().split("-")[1]; + procure.setBaseBidCode(procure.getBaseProjId() + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS,Integer.parseInt(index))); + procureService.updateById(procure); + }catch (Exception e){ + e.printStackTrace(); + } + } + } + + @Test + public void test7() throws UnknownHostException { + String orgCode = "GO_5f1f6f28a6f7484ea3b9991d8d02599f"; + projectCoreBizTask.doTask(orgCode); + } }