dev_1.0.1
luotaiqian 2026-07-15 13:35:37 +08:00
parent ac61e5b93c
commit 612882849a
2 changed files with 58 additions and 136 deletions

View File

@ -0,0 +1,48 @@
package org.qinan.safetyeval.app.convertor;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.qinan.safetyeval.client.co.OrgPersonnelCO;
import org.qinan.safetyeval.client.dto.OrgPersonnelAddCmd;
import org.qinan.safetyeval.client.dto.OrgPersonnelModifyCmd;
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
/**
* Entity/Cmd/CO
*/
@Mapper(componentModel = "spring")
public interface OrgPersonnelConvertor {
/**
* Entity CO
*/
@Mapping(target = "basicDisciplineMajorId", ignore = true)
@Mapping(target = "technicalDirectorFlag", ignore = true)
@Mapping(target = "processControlLeaderFlag", ignore = true)
@Mapping(target = "deptName", ignore = true)
@Mapping(target = "postName", ignore = true)
@Mapping(target = "certNames", ignore = true)
@Mapping(target = "changeCount", ignore = true)
@Mapping(target = "resignApplyId", ignore = true)
@Mapping(target = "resignAuditStatus", ignore = true)
OrgPersonnelCO toCO(OrgPersonnelEntity entity);
/**
* AddCmd Entity
*/
@Mapping(target = "id", ignore = true)
@Mapping(target = "orgId", ignore = true)
@Mapping(target = "tenantId", ignore = true)
@Mapping(target = "deleteEnum", ignore = true)
@Mapping(target = "basicDisciplineMajorId", ignore = true)
OrgPersonnelEntity toEntity(OrgPersonnelAddCmd cmd);
/**
* ModifyCmd Entity
*/
@Mapping(target = "orgId", ignore = true)
@Mapping(target = "deleteEnum", ignore = true)
@Mapping(target = "technicalDirectorFlag", ignore = true)
@Mapping(target = "processControlLeaderFlag", ignore = true)
OrgPersonnelEntity toEntity(OrgPersonnelModifyCmd cmd);
}

View File

@ -4,6 +4,7 @@ import com.jjb.saas.system.client.user.request.UserAddCmd;
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd; import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
import com.zcloud.gbscommon.utils.MD5; import com.zcloud.gbscommon.utils.MD5;
import com.zcloud.gbscommon.utils.Sm2Util; import com.zcloud.gbscommon.utils.Sm2Util;
import org.qinan.safetyeval.app.convertor.OrgPersonnelConvertor;
import org.qinan.safetyeval.app.support.OrgPersonnelChangeRecorder; import org.qinan.safetyeval.app.support.OrgPersonnelChangeRecorder;
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher; import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
import org.qinan.safetyeval.client.api.OrgPersonnelApi; import org.qinan.safetyeval.client.api.OrgPersonnelApi;
@ -47,6 +48,9 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
@Autowired(required = false) @Autowired(required = false)
private OrgPersonnelChangeRecorder orgPersonnelChangeRecorder; private OrgPersonnelChangeRecorder orgPersonnelChangeRecorder;
@Autowired
private OrgPersonnelConvertor orgPersonnelConvertor;
@Autowired(required = false) @Autowired(required = false)
private OrgResignApplyGateway orgResignApplyGateway; private OrgResignApplyGateway orgResignApplyGateway;
@ -65,9 +69,9 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public SingleResponse<OrgPersonnelCO> add(OrgPersonnelAddCmd cmd) { public SingleResponse<OrgPersonnelCO> add(OrgPersonnelAddCmd cmd) {
OrgPersonnelEntity entity = toEntity(cmd); OrgPersonnelEntity entity = orgPersonnelConvertor.toEntity(cmd);
OrgPersonnelEntity result = orgPersonnelDomainService.add(entity); OrgPersonnelEntity result = orgPersonnelDomainService.add(entity);
OrgPersonnelCO co = toCO(result); OrgPersonnelCO co = orgPersonnelConvertor.toCO(result);
enrich(co); enrich(co);
UserAddCmd userAddCmd = new UserAddCmd(); UserAddCmd userAddCmd = new UserAddCmd();
userAddCmd.setId(result.getId()); userAddCmd.setId(result.getId());
@ -91,7 +95,7 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
@Override @Override
public SingleResponse<OrgPersonnelCO> get(Long id) { public SingleResponse<OrgPersonnelCO> get(Long id) {
OrgPersonnelEntity entity = orgPersonnelDomainService.get(id); OrgPersonnelEntity entity = orgPersonnelDomainService.get(id);
OrgPersonnelCO co = toCO(entity); OrgPersonnelCO co = orgPersonnelConvertor.toCO(entity);
enrich(co); enrich(co);
return SingleResponse.success(co); return SingleResponse.success(co);
} }
@ -100,11 +104,11 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public SingleResponse<OrgPersonnelCO> modify(OrgPersonnelModifyCmd cmd) { public SingleResponse<OrgPersonnelCO> modify(OrgPersonnelModifyCmd cmd) {
OrgPersonnelEntity existing = orgPersonnelDomainService.get(cmd.getId()); OrgPersonnelEntity existing = orgPersonnelDomainService.get(cmd.getId());
OrgPersonnelEntity entity = toEntity(cmd); OrgPersonnelEntity entity = orgPersonnelConvertor.toEntity(cmd);
entity.setId(cmd.getId()); entity.setId(cmd.getId());
OrgPersonnelEntity result = orgPersonnelDomainService.modify(entity); OrgPersonnelEntity result = orgPersonnelDomainService.modify(entity);
orgPersonnelChangeRecorder.recordChanges(existing, result); orgPersonnelChangeRecorder.recordChanges(existing, result);
OrgPersonnelCO co = toCO(result); OrgPersonnelCO co = orgPersonnelConvertor.toCO(result);
enrich(co); enrich(co);
return SingleResponse.success(co); return SingleResponse.success(co);
} }
@ -151,7 +155,7 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
List<OrgPersonnelCO> records = pageResult.getRecords().stream() List<OrgPersonnelCO> records = pageResult.getRecords().stream()
.map(entity -> { .map(entity -> {
OrgPersonnelCO co = toCO(entity); OrgPersonnelCO co = orgPersonnelConvertor.toCO(entity);
enrich(co); enrich(co);
return co; return co;
}) })
@ -175,134 +179,4 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
orgPersonnelViewEnricher.enrichPersonnel(co); orgPersonnelViewEnricher.enrichPersonnel(co);
} }
} }
private OrgPersonnelEntity toEntity(OrgPersonnelAddCmd cmd) {
OrgPersonnelEntity entity = new OrgPersonnelEntity();
entity.setUserName(cmd.getUserName());
entity.setAccount(cmd.getAccount());
entity.setGenderCode(cmd.getGenderCode());
entity.setGenderName(cmd.getGenderName());
entity.setBirthDate(cmd.getBirthDate());
entity.setIdCardNo(cmd.getIdCardNo());
entity.setCurrentAddress(cmd.getCurrentAddress());
entity.setOfficeAddress(cmd.getOfficeAddress());
entity.setEducationCode(cmd.getEducationCode());
entity.setEducationName(cmd.getEducationName());
entity.setGraduateSchool(cmd.getGraduateSchool());
entity.setMajor(cmd.getMajor());
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
applyPersonnelExtFields(entity, cmd);
entity.setDeptId(cmd.getDeptId());
entity.setPostId(cmd.getPostId());
entity.setJoinWorkDate(cmd.getJoinWorkDate());
return entity;
}
private OrgPersonnelEntity toEntity(OrgPersonnelModifyCmd cmd) {
OrgPersonnelEntity entity = new OrgPersonnelEntity();
entity.setUserName(cmd.getUserName());
entity.setAccount(cmd.getAccount());
entity.setGenderCode(cmd.getGenderCode());
entity.setGenderName(cmd.getGenderName());
entity.setBirthDate(cmd.getBirthDate());
entity.setIdCardNo(cmd.getIdCardNo());
entity.setCurrentAddress(cmd.getCurrentAddress());
entity.setOfficeAddress(cmd.getOfficeAddress());
entity.setEducationCode(cmd.getEducationCode());
entity.setEducationName(cmd.getEducationName());
entity.setGraduateSchool(cmd.getGraduateSchool());
entity.setMajor(cmd.getMajor());
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
applyPersonnelExtFields(entity, cmd);
entity.setDeptId(cmd.getDeptId());
entity.setPostId(cmd.getPostId());
entity.setJoinWorkDate(cmd.getJoinWorkDate());
return entity;
}
private void applyPersonnelExtFields(OrgPersonnelEntity entity, OrgPersonnelAddCmd cmd) {
entity.setPersonTypeCode(cmd.getPersonTypeCode());
entity.setPersonTypeName(cmd.getPersonTypeName());
entity.setQualScope(cmd.getQualScope());
entity.setProfessionalLevelCode(cmd.getProfessionalLevelCode());
entity.setProfessionalLevelName(cmd.getProfessionalLevelName());
entity.setEvaluatorCertNo(cmd.getEvaluatorCertNo());
entity.setEducationTypeCode(cmd.getEducationTypeCode());
entity.setEducationTypeName(cmd.getEducationTypeName());
entity.setEducationLevelCode(cmd.getEducationLevelCode());
entity.setEducationLevelName(cmd.getEducationLevelName());
entity.setTitleCode(cmd.getTitleCode());
entity.setRegisterEngineerFlag(cmd.getRegisterEngineerFlag());
entity.setPublications(cmd.getPublications());
entity.setAbilityDeclaration(cmd.getAbilityDeclaration());
entity.setWorkExperience(cmd.getWorkExperience());
entity.setProofMaterialUrl(cmd.getProofMaterialUrl());
entity.setTechnicalDirectorFlag(cmd.getTechnicalDirectorFlag());
entity.setProcessControlLeaderFlag(cmd.getProcessControlLeaderFlag());
}
private void applyPersonnelExtFields(OrgPersonnelEntity entity, OrgPersonnelModifyCmd cmd) {
entity.setBasicDisciplineMajorId(cmd.getBasicDisciplineMajorId());
entity.setPersonTypeCode(cmd.getPersonTypeCode());
entity.setPersonTypeName(cmd.getPersonTypeName());
entity.setQualScope(cmd.getQualScope());
entity.setProfessionalLevelCode(cmd.getProfessionalLevelCode());
entity.setProfessionalLevelName(cmd.getProfessionalLevelName());
entity.setEvaluatorCertNo(cmd.getEvaluatorCertNo());
entity.setEducationTypeCode(cmd.getEducationTypeCode());
entity.setEducationTypeName(cmd.getEducationTypeName());
entity.setEducationLevelCode(cmd.getEducationLevelCode());
entity.setEducationLevelName(cmd.getEducationLevelName());
entity.setTitleCode(cmd.getTitleCode());
entity.setRegisterEngineerFlag(cmd.getRegisterEngineerFlag());
entity.setPublications(cmd.getPublications());
entity.setAbilityDeclaration(cmd.getAbilityDeclaration());
entity.setWorkExperience(cmd.getWorkExperience());
entity.setProofMaterialUrl(cmd.getProofMaterialUrl());
}
private OrgPersonnelCO toCO(OrgPersonnelEntity entity) {
if (entity == null) {
return null;
}
OrgPersonnelCO co = new OrgPersonnelCO();
co.setId(entity.getId());
co.setDeptId(entity.getDeptId());
co.setPostId(entity.getPostId());
co.setUserName(entity.getUserName());
co.setAccount(entity.getAccount());
co.setGenderCode(entity.getGenderCode());
co.setGenderName(entity.getGenderName());
co.setBirthDate(entity.getBirthDate());
co.setIdCardNo(entity.getIdCardNo());
co.setCurrentAddress(entity.getCurrentAddress());
co.setOfficeAddress(entity.getOfficeAddress());
co.setEducationCode(entity.getEducationCode());
co.setEducationName(entity.getEducationName());
co.setGraduateSchool(entity.getGraduateSchool());
co.setMajor(entity.getMajor());
co.setEmploymentStatusCode(entity.getEmploymentStatusCode());
co.setEmploymentStatusName(entity.getEmploymentStatusName());
co.setPersonTypeCode(entity.getPersonTypeCode());
co.setPersonTypeName(entity.getPersonTypeName());
co.setQualScope(entity.getQualScope());
co.setProfessionalLevelCode(entity.getProfessionalLevelCode());
co.setProfessionalLevelName(entity.getProfessionalLevelName());
co.setEvaluatorCertNo(entity.getEvaluatorCertNo());
co.setEducationTypeCode(entity.getEducationTypeCode());
co.setEducationTypeName(entity.getEducationTypeName());
co.setEducationLevelCode(entity.getEducationLevelCode());
co.setEducationLevelName(entity.getEducationLevelName());
co.setTitleCode(entity.getTitleCode());
co.setRegisterEngineerFlag(entity.getRegisterEngineerFlag());
co.setPublications(entity.getPublications());
co.setAbilityDeclaration(entity.getAbilityDeclaration());
co.setWorkExperience(entity.getWorkExperience());
co.setProofMaterialUrl(entity.getProofMaterialUrl());
co.setTenantId(entity.getTenantId());
co.setJoinWorkDate(entity.getJoinWorkDate());
return co;
}
} }