Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

tags/24080901
WendyYang 1 vuosi sitten
vanhempi
commit
4aa5bd97c7
35 muutettua tiedostoa jossa 1195 lisäystä ja 102 poistoa
  1. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java
  3. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java
  4. +19
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java
  5. +74
    -39
      pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java
  6. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java
  7. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java
  8. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java
  9. +25
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectCollectionUtil.java
  10. +15
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java
  11. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java
  12. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java
  13. +52
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java
  14. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java
  15. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java
  16. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java
  17. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java
  18. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java
  19. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java
  20. +8
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  21. +15
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java
  22. +46
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java
  23. +251
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java
  24. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java
  25. +53
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/enumeration/NoticePermissionsEnum.java
  26. +92
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java
  27. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java
  28. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java
  29. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java
  30. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java
  31. +24
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java
  32. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java
  33. +1
    -1
      pmapi/src/main/resources/application-prod.yml
  34. +224
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/irs/EmployeeTest.java
  35. +200
    -27
      pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java Näytä tiedosto

@@ -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";



+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/CommonConst.java Näytä tiedosto

@@ -64,6 +64,6 @@ public interface CommonConst {
Integer VERIFY_TYPE = 2;
String REPEAT = " 已在其他当前评价计划其他分组中,请勿重复添加!";

String NORMAL_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

}

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/gov/controller/GovProjectCollectionController.java Näytä tiedosto

@@ -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);
}
}

+ 19
- 7
pmapi/src/main/java/com/ningdatech/pmapi/gov/convert/ProjectConvert.java Näytä tiedosto

@@ -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;
}



+ 74
- 39
pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java Näytä tiedosto

@@ -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<GovProjectDictionaryVO> dictionary(String type) {

List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class)
@@ -143,7 +150,8 @@ public class GovProjectCollectionManage {
Map<String,GovBizProjectApply> applyMap = Maps.newHashMap();
if(CollUtil.isNotEmpty(projIds)){
List<GovBizProjectApply> 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<GovBizProjectBaseinfo> wrapper) {
UserInfoDetails user = LoginUserUtil.loginUserDetail();
List<Role> 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


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectApplyDTO.java Näytä tiedosto

@@ -69,7 +69,7 @@ public class GovBizProjectApplyDTO implements Serializable {
private LocalDateTime baseProjEndTime;

@ApiModelProperty("项目期限")
private LocalDateTime baseProjDuration;
private String baseProjDuration;

@ApiModelProperty("项目年度")
private String baseProjSetYear;


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/gov/model/entity/GovBizProjectApply.java Näytä tiedosto

@@ -76,7 +76,7 @@ public class GovBizProjectApply implements Serializable {
private LocalDateTime baseProjEndTime;

@ApiModelProperty("项目期限")
private LocalDateTime baseProjDuration;
private String baseProjDuration;

@ApiModelProperty("项目年度")
private String baseProjSetYear;


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/gov/model/vo/GovBizProjectApplyVO.java Näytä tiedosto

@@ -71,7 +71,7 @@ public class GovBizProjectApplyVO implements Serializable {
private LocalDateTime baseProjEndTime;

@ApiModelProperty("项目期限")
private LocalDateTime baseProjDuration;
private String baseProjDuration;

@ApiModelProperty("项目年度")
private String baseProjSetYear;


+ 25
- 0
pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectCollectionUtil.java Näytä tiedosto

@@ -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));
}

}

+ 15
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java Näytä tiedosto

@@ -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();
}
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java Näytä tiedosto

@@ -80,7 +80,7 @@ public class ProjectIrsManage {

ResponseEntity<JSONObject> 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;


+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/mapper/ProjectCoreBizMapper.java Näytä tiedosto

@@ -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;

/**
* <p>
* Mapper 接口
* </p>
*
* @author zpf
* @since 2023-09-13
*/
public interface ProjectCoreBizMapper extends BaseMapper<ProjectCoreBiz> {

}

+ 52
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/entity/ProjectCoreBiz.java Näytä tiedosto

@@ -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;
}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/service/IProjectCoreBizService.java Näytä tiedosto

@@ -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;

/**
* <p>
* 服务类
* </p>
*
* @author Zpf
* @since 2023-09-13
*/
public interface IProjectCoreBizService extends IService<ProjectCoreBiz> {


}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/service/impl/ProjectCoreBizServiceImpl.java Näytä tiedosto

@@ -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;

/**
* <p>
* 服务实现类
* </p>
*
* @author zpf
* @since 2023-09-13
*/
@Service
public class ProjectCoreBizServiceImpl extends ServiceImpl<ProjectCoreBizMapper, ProjectCoreBiz>
implements IProjectCoreBizService {

}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java Näytä tiedosto

@@ -55,4 +55,5 @@ public class DingOrganization implements Serializable {

private String status;

private String unifiedSocialCreditCode;
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/OrganizationTreeVO.java Näytä tiedosto

@@ -36,6 +36,6 @@ public class OrganizationTreeVO {
// @ApiModelProperty(value = "是否为叶子节点")
// private Boolean isLeaf;
//
// @ApiModelProperty(value = "联合唯一字段方便页面使用(name##organizationCode)")
// private String unionCode;
@ApiModelProperty(value = "社会同一信用代码")
private String unifiedSocialCreditCode;;
}

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/vo/ResOrganizationListVO.java Näytä tiedosto

@@ -35,4 +35,6 @@ public class ResOrganizationListVO {
@ApiModelProperty("是否为上级条线主管单位")
private Boolean isSuperiorLineCompetentUnit;

@ApiModelProperty("社会统一信用代码")
private String unifiedSocialCreditCode;
}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/ProjectCodeContant.java Näytä tiedosto

@@ -13,4 +13,5 @@ public interface ProjectCodeContant {
String PROJECT_TYPE_PREFIX = "0";

String SHUZI_5 = "%05d";
String SHUZI_4 = "%04d";
}

+ 8
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java Näytä tiedosto

@@ -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<ProjectCoreBiz> 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;
}


+ 15
- 8
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java Näytä tiedosto

@@ -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);
}
}

+ 46
- 6
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCollectionTask.java Näytä tiedosto

@@ -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<GovBizProjectBaseinfo> projects = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class)
.eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE)
.eq(StringUtils.isNotBlank(projId),GovBizProjectBaseinfo::getBaseProjId,projId));
List<GovBizProjectApprove> 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<GovBizProjectApprove> 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());


+ 251
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java Näytä tiedosto

@@ -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<DingOrganization> 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<DingOrganization> 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<DingOrganization> orgs) {
for(DingOrganization organization : orgs){
GenericResult<DingOrgInfoDTO> 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<String,DingOrganization> 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<DingOrgInfoDTO> 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;
}

}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/SysProcDefController.java Näytä tiedosto

@@ -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);
}
}

+ 53
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/enumeration/NoticePermissionsEnum.java Näytä tiedosto

@@ -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;
}
}

+ 92
- 3
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java Näytä tiedosto

@@ -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<Long> 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<NoticeListItemVO> 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<NoticeListItemVO> 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<Notice> 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<String,List<NoticeListItemVO>> listToMapByManager(NoticeListReq req) {
public PageVo<NoticeListItemVO> listByManagerByPermission(NoticeListReq req) {
LambdaQueryWrapper<Notice> 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<Notice> page = noticeService.page(req.page(), wrapper);
if (page.getTotal() == 0) {
return PageVo.empty();
}
List<NoticeListItemVO> 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<String,List<NoticeListItemVO>> listToMapByManager(NoticeListReq req,UserFullInfoDTO user) {
LambdaQueryWrapper<Notice> 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<Notice> 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<Role> 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<Notice> 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<Notice> 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());
}
}
}

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Notice.java Näytä tiedosto

@@ -65,4 +65,9 @@ public class Notice implements Serializable {
@ApiModelProperty("置顶时间")
private LocalDateTime toppedTime;

@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看")
private Integer permissions;

@ApiModelProperty("权限值")
private String permissionsValue;
}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/NoticeDetailVO.java Näytä tiedosto

@@ -37,4 +37,7 @@ public class NoticeDetailVO {
@ApiModelProperty("附件信息")
private List<AttachFileVo> attachments;

@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看")
private Integer permissions;

}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java Näytä tiedosto

@@ -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";
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialAuthProvider.java Näytä tiedosto

@@ -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;
}


+ 24
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java Näytä tiedosto

@@ -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;
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java Näytä tiedosto

@@ -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();



+ 1
- 1
pmapi/src/main/resources/application-prod.yml Näytä tiedosto

@@ -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

+ 224
- 0
pmapi/src/test/java/com/ningdatech/pmapi/irs/EmployeeTest.java Näytä tiedosto

@@ -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<OrganizationEmployeePosition> 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<Page<OrganizationEmployeePosition>> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query);
Page<OrganizationEmployeePosition> 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<DingEmployeeInfo> dingEmployeeInfoSaveRecordList = new ArrayList<>();
assemblerAccountId(allOrganizationEmployeePositionList, dingEmployeeInfoSaveRecordList);
System.out.println("dingEmployeeInfoSaveRecordList :{}" + JSON.toJSONString(dingEmployeeInfoSaveRecordList));
// 批量保存用户信息
saveBatch(dingEmployeeInfoSaveRecordList);
}

private void saveBatch(List<DingEmployeeInfo> 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<String> uniqueKeySet = new HashSet<String>();

List<DingEmployeeInfo> saveList = new ArrayList<>();

for (DingEmployeeInfo dingEmployeeInfo : dingEmployeeInfoSaveRecordList) {
if (uniqueKeySet.add(dingEmployeeInfo.getEmployeeCode() + dingEmployeeInfo.getEmpPosUnitCode())) {
saveList.add(dingEmployeeInfo);
}
}

List<DingOrganization> organizations = iDingOrganizationService.list();
Map<String, DingOrganization> 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<OrganizationEmployeePosition> segment, List<DingEmployeeInfo> dingEmployeeInfoSaveRecordList) {
List<String> employeeCodes = segment.stream().map(OrganizationEmployeePosition::getEmployeeCode).distinct().collect(Collectors.toList());
GenericResult<List<EmployeeAccountIdDTO>> listGenericResult = zwddClient.listEmployeeAccountIds(employeeCodes);
List<EmployeeAccountIdDTO> employeeAccountIdDTOList = listGenericResult.getData();
if (CollUtil.isNotEmpty(employeeAccountIdDTOList)) {
Map<String, Long> employeeCodeAccountIdMap = employeeAccountIdDTOList.stream().filter(Objects::nonNull)
.collect(Collectors.toMap(EmployeeAccountIdDTO::getEmployeeCode, EmployeeAccountIdDTO::getAccountId));

List<DingEmployeeInfo> dingEmployeeInfos = buildDingEmployeeInfoRecordList(segment);

dingEmployeeInfos = dingEmployeeInfos.stream().map(r -> {
r.setAccountId(employeeCodeAccountIdMap.get(r.getEmployeeCode()));
return r;
}).collect(Collectors.toList());
dingEmployeeInfoSaveRecordList.addAll(dingEmployeeInfos);
}
}
private List<DingEmployeeInfo> buildDingEmployeeInfoRecordList(List<OrganizationEmployeePosition> allOrganizationEmployeePositionList) {
List<DingEmployeeInfo> saveRecordList = new ArrayList<>();
for (OrganizationEmployeePosition organizationEmployeePosition : allOrganizationEmployeePositionList) {
List<OrganizationEmployeePosition.GovEmployeePosition> govEmployeePositions = organizationEmployeePosition.getGovEmployeePositions();
if (CollUtil.isNotEmpty(govEmployeePositions)) {
List<DingEmployeeInfo> 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<String, DingOrganization> 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);
}
}
}

+ 200
- 27
pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java Näytä tiedosto

@@ -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<String> 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<GovBizProjectProcure> 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<GovBizProjectApprove> 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<OptLog> 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<GovBizProjectApply> 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<GovBizProjectProcure> 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);
}
}

Loading…
Peruuta
Tallenna