@@ -15,6 +15,7 @@ import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.basic.util.StrPool; | import com.ningdatech.basic.util.StrPool; | ||||
import com.ningdatech.pmapi.common.constant.BizConst; | import com.ningdatech.pmapi.common.constant.BizConst; | ||||
import com.ningdatech.pmapi.common.constant.RegionConst; | 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.contants.BizProjectContant; | ||||
import com.ningdatech.pmapi.gov.convert.ProjectConvert; | import com.ningdatech.pmapi.gov.convert.ProjectConvert; | ||||
import com.ningdatech.pmapi.gov.model.dto.*; | import com.ningdatech.pmapi.gov.model.dto.*; | ||||
@@ -99,6 +100,8 @@ public class GovProjectCollectionManage { | |||||
@Value("${spring.profiles.active}") | @Value("${spring.profiles.active}") | ||||
private String active; | private String active; | ||||
private final RegionCacheHelper regionCacheHelper; | |||||
public List<GovProjectDictionaryVO> dictionary(String type) { | public List<GovProjectDictionaryVO> dictionary(String type) { | ||||
List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) | List<GovProjectDictionary> dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) | ||||
@@ -143,7 +146,8 @@ public class GovProjectCollectionManage { | |||||
Map<String,GovBizProjectApply> applyMap = Maps.newHashMap(); | Map<String,GovBizProjectApply> applyMap = Maps.newHashMap(); | ||||
if(CollUtil.isNotEmpty(projIds)){ | if(CollUtil.isNotEmpty(projIds)){ | ||||
List<GovBizProjectApply> applys = projectApplyService.list(Wrappers.lambdaQuery(GovBizProjectApply.class) | 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)); | 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()) || | if(RoleEnum.SUPER_ADMIN.name().equals(role.getCode()) || | ||||
RoleEnum.REGION_MANAGER.name().equals(role.getCode())){ | RoleEnum.REGION_MANAGER.name().equals(role.getCode())){ | ||||
log.info("超管和区管 可以看所有"); | log.info("超管和区管 可以看所有"); | ||||
}else{ | |||||
//其他情况 都只能看 自己单位的 | |||||
wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); | |||||
return; | |||||
} | } | ||||
} | } | ||||
wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing,user.getEmpPosUnitCode()); | |||||
} | } | ||||
public Long count(ProjectListReq req) { | public Long count(ProjectListReq req) { | ||||
@@ -237,6 +240,7 @@ public class GovProjectCollectionManage { | |||||
.eq(StringUtils.isNotBlank(req.getRegionCode()),GovBizProjectBaseinfo::getAreaCode,req.getRegionCode()) | .eq(StringUtils.isNotBlank(req.getRegionCode()),GovBizProjectBaseinfo::getAreaCode,req.getRegionCode()) | ||||
.gt(Objects.nonNull(req.getCreateOnMin()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMin()) | .gt(Objects.nonNull(req.getCreateOnMin()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMin()) | ||||
.le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMax()) | .le(Objects.nonNull(req.getCreateOnMax()),GovBizProjectBaseinfo::getTongTime,req.getCreateOnMax()) | ||||
.eq(GovBizProjectBaseinfo::getDeleted,Boolean.FALSE) | |||||
.orderByDesc(GovBizProjectBaseinfo::getBizTime); | .orderByDesc(GovBizProjectBaseinfo::getBizTime); | ||||
return baseinfoService.count(wrapper); | return baseinfoService.count(wrapper); | ||||
} | } | ||||
@@ -409,6 +413,7 @@ public class GovProjectCollectionManage { | |||||
}else{ | }else{ | ||||
saveBase.setTongTime(LocalDateTime.now()); | saveBase.setTongTime(LocalDateTime.now()); | ||||
saveBase.setBaseAreaCode(baseAreaCode); | saveBase.setBaseAreaCode(baseAreaCode); | ||||
saveBase.setBaseAreaName(regionCacheHelper.getRegionName(user.getRegionCode(),RegionConst.RL_COUNTY)); | |||||
} | } | ||||
saveBase.setAreaCode(RegionConst.RC_LS); | saveBase.setAreaCode(RegionConst.RC_LS); | ||||
saveBase.setBizTime(LocalDateTime.now()); | saveBase.setBizTime(LocalDateTime.now()); | ||||
@@ -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; | package com.ningdatech.pmapi.sys.manage; | ||||
import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 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.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | ||||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | 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.enumeration.NoticeTypeEnum; | ||||
import com.ningdatech.pmapi.sys.model.entity.Notice; | import com.ningdatech.pmapi.sys.model.entity.Notice; | ||||
import com.ningdatech.pmapi.sys.model.entity.Notify; | 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.NoticeListReq; | ||||
import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; | import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; | ||||
import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; | 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.bean.entity.WorkNoticeInfo; | ||||
import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | ||||
import com.ningdatech.pmapi.user.entity.UserInfo; | 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.UserFullInfoDTO; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | |||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -85,6 +91,7 @@ public class NoticeManage { | |||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public IdVo<Long> saveOrModify(NoticeSaveReq req) { | public IdVo<Long> saveOrModify(NoticeSaveReq req) { | ||||
Notice notice = BeanUtil.copyProperties(req, Notice.class); | Notice notice = BeanUtil.copyProperties(req, Notice.class); | ||||
permissionsSave(notice,LoginUserUtil.loginUserDetail()); | |||||
noticeService.saveOrUpdate(notice); | noticeService.saveOrUpdate(notice); | ||||
return IdVo.of(notice.getId()); | return IdVo.of(notice.getId()); | ||||
} | } | ||||
@@ -129,6 +136,7 @@ public class NoticeManage { | |||||
.like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) | .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) | ||||
.eq(req.getType() != null, Notice::getType, req.getType()) | .eq(req.getType() != null, Notice::getType, req.getType()) | ||||
.orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); | .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); | ||||
permissionsWrapper(wrapper,LoginUserUtil.loginUserDetail()); | |||||
Page<Notice> page = noticeService.page(req.page(), wrapper); | Page<Notice> page = noticeService.page(req.page(), wrapper); | ||||
if (page.getTotal() == 0) { | if (page.getTotal() == 0) { | ||||
return PageVo.empty(); | 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("置顶时间") | @ApiModelProperty("置顶时间") | ||||
private LocalDateTime toppedTime; | private LocalDateTime toppedTime; | ||||
@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") | |||||
private Integer permissions; | |||||
@ApiModelProperty("权限值") | |||||
private String permissionsValue; | |||||
} | } |
@@ -37,4 +37,7 @@ public class NoticeDetailVO { | |||||
@ApiModelProperty("附件信息") | @ApiModelProperty("附件信息") | ||||
private List<AttachFileVo> attachments; | private List<AttachFileVo> attachments; | ||||
@ApiModelProperty("权限控制 0所有人可看 1区域可看 2单位可看") | |||||
private Integer permissions; | |||||
} | } |
@@ -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); | |||||
} | |||||
} | |||||
} |
@@ -47,13 +47,14 @@ public class ProjectCollectionTest extends AppTests { | |||||
@Test | @Test | ||||
public void test(){ | public void test(){ | ||||
List<String> baseProjIds = Lists.newArrayList("33112720210100190","33112620230100053", | |||||
"33112620210100189","33112720210100188"); | |||||
List<String> baseProjIds = Lists.newArrayList("33112700020210100191"); | |||||
for(String baseProjId : baseProjIds){ | for(String baseProjId : baseProjIds){ | ||||
GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) | ||||
.eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId)); | |||||
.eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId) | |||||
.eq(GovBizProjectBaseinfo::getId,457)); | |||||
GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) | GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class) | ||||
.eq(GovBizProjectApply::getBaseProjId, baseProjId)); | |||||
.eq(GovBizProjectApply::getBaseProjId, baseProjId) | |||||
.eq(GovBizProjectApply::getId,451)); | |||||
GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); | GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); | ||||
saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); | saveDTO.setApply(BeanUtil.copyProperties(apply, GovBizProjectApplyDTO.class)); | ||||