@@ -53,6 +53,13 @@ public class ExpertController { | |||
expertManage.expertBasicInfoSubmit(request); | |||
} | |||
@PostMapping("/basic-info-submit-notvalid") | |||
@ApiOperation("专家管理员新增专家 参数不校检") | |||
@WebLog("专家管理员新增专家 参数不校检") | |||
public void expertBasicInfoSubmitNotValid(@RequestBody ExpertUserBasicInfoSubmitRequest request) { | |||
expertManage.expertBasicInfoSubmit(request); | |||
} | |||
@GetMapping("/detail") | |||
@ApiOperation("专家获取专家详细信息") | |||
public ExpertFullInfoVO getExpertFullInfoDetail() { | |||
@@ -108,7 +108,7 @@ public class GovProjectCollectionController { | |||
@PostMapping("/staging-convert-pdf") | |||
@ApiOperation("把库存的项目归集的文件 都转换成PDF文件存入字段") | |||
@WebLog("主动转换库存的文件都为PDF文件") | |||
public void stagingConvertPdf() { | |||
collectionTask.stagingConvertPdf(); | |||
public void stagingConvertPdf(@RequestParam(required = false) String projId) { | |||
collectionTask.stagingConvertPdf(projId); | |||
} | |||
} |
@@ -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.*; | |||
@@ -99,6 +100,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 +146,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)); | |||
} | |||
@@ -222,11 +226,10 @@ public class GovProjectCollectionManage { | |||
if(RoleEnum.SUPER_ADMIN.name().equals(role.getCode()) || | |||
RoleEnum.REGION_MANAGER.name().equals(role.getCode())){ | |||
log.info("超管和区管 可以看所有"); | |||
}else{ | |||
//其他情况 都只能看 自己单位的 | |||
wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); | |||
return; | |||
} | |||
} | |||
wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); | |||
} | |||
public Long count(ProjectListReq req) { | |||
@@ -237,6 +240,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); | |||
} | |||
@@ -387,10 +391,6 @@ public class GovProjectCollectionManage { | |||
String baseProjId = base.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(); | |||
@@ -409,14 +409,22 @@ public class GovProjectCollectionManage { | |||
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); | |||
} | |||
baseinfoService.saveOrUpdate(saveBase); | |||
// 2.保存 申报信息 | |||
@@ -534,26 +542,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 + 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. 推送数据(改为定时推送了) | |||
@@ -992,19 +1000,24 @@ public class GovProjectCollectionManage { | |||
String[] baseProjBasisFileArr = baseProjBasisFile.split(";"); | |||
StringJoiner sj = new StringJoiner(";"); | |||
for(String bpb : baseProjBasisFileArr){ | |||
JSONArray fileArray = JSON.parseArray(bpb); | |||
fileArray.forEach(j -> { | |||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); | |||
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); | |||
String suffix = jsonObject.getString("suffix"); | |||
String originalFileName = jsonObject.getString("originalFileName"); | |||
if(!BizConst.DEV.equals(active)){ | |||
originalFileName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); | |||
} | |||
try{ | |||
JSONArray fileArray = JSON.parseArray(bpb); | |||
fileArray.forEach(j -> { | |||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(j)); | |||
byte[] btyes = wpsConvertManage.downloadToPdfStream(jsonObject.getLong("id")); | |||
String suffix = jsonObject.getString("suffix"); | |||
String originalFileName = jsonObject.getString("originalFileName"); | |||
if(!BizConst.DEV.equals(active)){ | |||
originalFileName = originalFileName.replace(StrPool.DOT + suffix, ".pdf"); | |||
} | |||
// upload(btyes,"/temp",originalFileName); | |||
String oss = ProvincialManage.uploadToOss(btyes, originalFileName); | |||
sj.add(oss); | |||
}); | |||
String oss = ProvincialManage.uploadToOss(btyes, originalFileName); | |||
sj.add(oss); | |||
}); | |||
}catch (Exception e){ | |||
log.error("解析文件出错!" + e); | |||
} | |||
} | |||
return sj; | |||
} | |||
@@ -44,6 +44,8 @@ public class SynProjectCollectionTask { | |||
private GovProjectCollectionManage collectionManage; | |||
@Autowired | |||
private IGovBizProjectBaseinfoService baseinfoService; | |||
@Autowired | |||
private IGovBizProjectApplyService applyService; | |||
@Autowired | |||
private IGovBizProjectApproveService approveService; | |||
@@ -105,22 +107,23 @@ public class SynProjectCollectionTask { | |||
/** | |||
* 把库存的项目归集里 没有转换PDF文件的 都转换一遍 存入数据库 | |||
*/ | |||
public void stagingConvertPdf() { | |||
public void stagingConvertPdf(String projId) { | |||
log.info("项目归集库存转换PDF任务开始====="); | |||
StopWatch stopWatch = new StopWatch(); | |||
stopWatch.start(); | |||
ProjectListReq req = new ProjectListReq(); | |||
req.setPageNumber(1); | |||
req.setPageSize(BizConst.MAX_EXPORT_COUNT); | |||
PageVo<GovBizProjectListVO> pageRes = collectionManage.list(req); | |||
List<GovBizProjectBaseinfo> projects = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | |||
.eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) | |||
.eq(StringUtils.isNotBlank(projId),GovBizProjectBaseinfo::getBaseProjId,projId)); | |||
if(CollUtil.isEmpty(pageRes.getRecords())){ | |||
if(CollUtil.isEmpty(projects)){ | |||
log.info("没有项目归集 任务终止"); | |||
return; | |||
} | |||
Collection<GovBizProjectListVO> records = pageRes.getRecords(); | |||
for(GovBizProjectListVO project : records){ | |||
for(GovBizProjectBaseinfo project : projects){ | |||
//开始转换PDF | |||
convertPdfVo(project.getBaseProjId()); | |||
} | |||
@@ -253,6 +256,10 @@ public class SynProjectCollectionTask { | |||
StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseIrsTestRunFile()); | |||
cimplement.setBaseIrsTestRunFilePdf(sj.toString()); | |||
} | |||
if(StringUtils.isBlank(cimplement.getBaseInforLevelFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseInforLevelFile())){ | |||
StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseInforLevelFile()); | |||
cimplement.setBaseInforLevelFilePdf(sj.toString()); | |||
} | |||
cimplementService.updateById(cimplement); | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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()); | |||
} | |||
@@ -129,6 +136,7 @@ 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); | |||
permissionsWrapper(wrapper,LoginUserUtil.loginUserDetail()); | |||
Page<Notice> page = noticeService.page(req.page(), wrapper); | |||
if (page.getTotal() == 0) { | |||
return PageVo.empty(); | |||
@@ -280,4 +288,48 @@ 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; | |||
} | |||
for(Role role : userRoleList){ | |||
if(RoleEnum.SUPER_ADMIN.eq(role.getCode())){ | |||
notice.setPermissions(NoticePermissionsEnum.SUPER.getCode()); | |||
return; | |||
}else if(RoleEnum.REGION_MANAGER.eq(role.getCode())){ | |||
notice.setPermissions(NoticePermissionsEnum.REGION.getCode()); | |||
notice.setPermissionsValue(user.getRegionCode()); | |||
return; | |||
}else if(RoleEnum.COMPANY_MANAGER.eq(role.getCode())){ | |||
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,UserInfoDetails user) { | |||
wrapper.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())); | |||
} | |||
} |
@@ -65,4 +65,9 @@ public class Notice implements Serializable { | |||
@ApiModelProperty("置顶时间") | |||
private LocalDateTime toppedTime; | |||
@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") | |||
private Integer permissions; | |||
@ApiModelProperty("权限值") | |||
private String permissionsValue; | |||
} |
@@ -37,4 +37,7 @@ public class NoticeDetailVO { | |||
@ApiModelProperty("附件信息") | |||
private List<AttachFileVo> attachments; | |||
@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") | |||
private Integer permissions; | |||
} |
@@ -75,7 +75,7 @@ public class UserAuthController { | |||
response.setContentType(StrPool.CONTENT_TYPE); | |||
Cookie cookie = new Cookie(BizConst.COOKIE_KEY, null); | |||
cookie.setPath(request.getContextPath() + "/"); | |||
cookie.setMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS); | |||
cookie.setMaxAge(SessionTimeConstant.SESSION_EXPIRED); | |||
response.addCookie(cookie); | |||
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | |||
response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); | |||
@@ -8,5 +8,6 @@ package com.ningdatech.pmapi.user.security.auth.constants; | |||
public class SessionTimeConstant { | |||
public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; | |||
public static final Integer SESSION_EXPIRED = 0; | |||
} |
@@ -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); | |||
} | |||
} | |||
} |
@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.projectCollection; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.pmapi.AppTests; | |||
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; | |||
import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; | |||
@@ -12,6 +13,9 @@ import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; | |||
import org.junit.Test; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* @Classname ProjectCollectionTest | |||
* @Description | |||
@@ -43,33 +47,37 @@ public class ProjectCollectionTest extends AppTests { | |||
@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)); | |||
List<String> baseProjIds = Lists.newArrayList("33112700020210100191"); | |||
for(String baseProjId : baseProjIds){ | |||
GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | |||
.eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId) | |||
.eq(GovBizProjectBaseinfo::getId,457)); | |||
GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) | |||
.eq(GovBizProjectApply::getBaseProjId, baseProjId) | |||
.eq(GovBizProjectApply::getId,451)); | |||
GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); | |||
saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); | |||
saveDTO.setBaseinfo(BeanUtil.copyProperties(baseinfo, GovBizProjectBaseinfoDTO.class)); | |||
String newProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); | |||
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)); | |||
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)); | |||
} | |||
} | |||
} |