Merge remote-tracking branch 'origin/dev' into dev

dev
luotaiqian 2026-07-07 16:10:18 +08:00
commit bb1b58df2d
14 changed files with 288 additions and 23 deletions

View File

@ -1,12 +1,18 @@
package org.qinan.safetyeval.adapter.web;
import io.swagger.annotations.Api;
import org.qinan.safetyeval.client.dto.PageResponse;
import org.qinan.safetyeval.client.dto.SingleResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.qinan.safetyeval.client.api.OrgDepartmentApi;
import org.qinan.safetyeval.client.co.OrgDepartmentCO;
import org.qinan.safetyeval.client.dto.*;
import org.qinan.safetyeval.infrastructure.dataobject.base.Req;
import org.qinan.safetyeval.client.dto.OrgDepartmentAddCmd;
import org.qinan.safetyeval.client.dto.OrgDepartmentModifyCmd;
import org.qinan.safetyeval.client.dto.OrgDepartmentPageQuery;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -34,8 +40,8 @@ public class OrgDepartmentController {
@ApiOperation("查询部门详情")
@GetMapping("/get")
public SingleResponse<OrgDepartmentCO> get(@ApiParam("主键ID") @RequestParam Long id) {
return orgDepartmentApi.get(id);
public SingleResponse<OrgDepartmentCO> get(@ApiParam("主键ID") @RequestParam String id) {
return orgDepartmentApi.get(Long.parseLong(id));
}
@ApiOperation("修改部门")
@ -46,8 +52,8 @@ public class OrgDepartmentController {
@ApiOperation("删除部门")
@PostMapping("/delete")
public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestBody Req<Long> req) {
return orgDepartmentApi.delete(req.getData());
public SingleResponse<Void> delete(@ApiParam("主键ID") @RequestParam String id) {
return orgDepartmentApi.delete(Long.parseLong(id));
}
@ApiOperation("分页查询部门")

View File

@ -52,8 +52,8 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
@Override
public SingleResponse<OrgDepartmentCO> modify(OrgDepartmentModifyCmd cmd) {
OrgDepartmentEntity entity = new OrgDepartmentEntity();
entity.setId(cmd.getId());
entity.setParentId(cmd.getParentId());
entity.setId(cmd.getId() != null ? Long.parseLong(cmd.getId()) : null);
entity.setParentId(cmd.getParentId() != null ? Long.parseLong(cmd.getParentId()) : null);
entity.setDeptName(cmd.getDeptName());
entity.setManagerName(cmd.getManagerName());
entity.setManagerAccount(cmd.getManagerAccount());
@ -94,14 +94,14 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
return null;
}
OrgDepartmentCO co = new OrgDepartmentCO();
co.setId(entity.getId());
co.setParentId(entity.getParentId());
co.setId(entity.getId() != null ? String.valueOf(entity.getId()) : null);
co.setParentId(entity.getParentId() != null ? String.valueOf(entity.getParentId()) : null);
co.setDeptName(entity.getDeptName());
co.setManagerName(entity.getManagerName());
co.setManagerAccount(entity.getManagerAccount());
co.setDeptLevelCode(entity.getDeptLevelCode());
co.setDeptLevelName(entity.getDeptLevelName());
co.setTenantId(entity.getTenantId());
co.setTenantId(entity.getTenantId() != null ? String.valueOf(entity.getTenantId()) : null);
return co;
}
}

View File

@ -96,6 +96,9 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
domainQuery.setPersonnelId(query.getPersonnelId());
domainQuery.setCertName(query.getCertName());
domainQuery.setCertTypeCode(query.getCertTypeCode());
domainQuery.setCertNo(query.getCertNo());
domainQuery.setCertCategoryName(query.getCertCategoryName());
domainQuery.setOperationCategoryName(query.getOperationCategoryName());
PageResult<OrgPersonnelCertEntity> pageResult = orgPersonnelCertDomainService.page(domainQuery);

View File

@ -12,10 +12,10 @@ import lombok.Data;
public class OrgDepartmentCO {
@ApiModelProperty(value = "主键ID")
private Long id;
private String id;
@ApiModelProperty(value = "父部门ID")
private Long parentId;
private String parentId;
@ApiModelProperty(value = "部门名称")
private String deptName;
@ -33,5 +33,5 @@ public class OrgDepartmentCO {
private String deptLevelName;
@ApiModelProperty(value = "租户ID")
private Long tenantId;
private String tenantId;
}

View File

@ -12,10 +12,10 @@ import lombok.Data;
public class OrgDepartmentModifyCmd {
@ApiModelProperty(value = "主键ID")
private Long id;
private String id;
@ApiModelProperty(value = "上级部门id0为根")
private Long parentId;
private String parentId;
@ApiModelProperty(value = "部门名称")
private String deptName;

View File

@ -24,4 +24,13 @@ public class OrgPersonnelCertPageQuery extends BasePageQuery {
@ApiModelProperty(value = "证书类型编码")
private Long certTypeCode;
@ApiModelProperty(value = "证书编号")
private String certNo;
@ApiModelProperty(value = "证书类别名称")
private String certCategoryName;
@ApiModelProperty(value = "证书作业类别名称")
private String operationCategoryName;
}

View File

@ -116,4 +116,7 @@ public class OrgPersonnelEntity {
/** 租户ID */
private Long tenantId;
/** 删除标识false 未删除 / true 已删除) */
private String deleteEnum;
}

View File

@ -17,6 +17,10 @@ public interface OrgPersonnelGateway {
OrgPersonnelEntity getByAccount(String account);
OrgPersonnelEntity findAnyByAccount(String account);
OrgPersonnelEntity restore(OrgPersonnelEntity entity);
OrgPersonnelEntity findByUserName(String userName);
OrgPersonnelEntity modify(OrgPersonnelEntity entity);

View File

@ -30,4 +30,13 @@ public class OrgPersonnelCertQuery {
/** 证书类型 */
private Long certTypeCode;
/** 证书编号 */
private String certNo;
/** 证书类别名称 */
private String certCategoryName;
/** 证书作业类别名称 */
private String operationCategoryName;
}

View File

@ -21,10 +21,14 @@ public class OrgPersonnelDomainService {
private OrgPersonnelGateway orgPersonnelGateway;
public OrgPersonnelEntity add(OrgPersonnelEntity entity) {
assertAccountUnique(entity.getAccount(), null);
if (entity.getEmploymentStatusCode() == null) {
entity.setEmploymentStatusCode(1);
entity.setEmploymentStatusName("在职");
applyEmploymentDefault(entity);
OrgPersonnelEntity existing = orgPersonnelGateway.findAnyByAccount(entity.getAccount());
if (existing != null) {
if (!isSoftDeleted(existing)) {
throw new BizException(ErrorCode.ORG_PERSONNEL_ACCOUNT_EXISTS);
}
entity.setId(existing.getId());
return orgPersonnelGateway.restore(entity);
}
return orgPersonnelGateway.save(entity);
}
@ -144,9 +148,21 @@ public class OrgPersonnelDomainService {
if (!StringUtils.hasText(account)) {
return;
}
OrgPersonnelEntity found = orgPersonnelGateway.getByAccount(account);
if (found != null && (excludeId == null || !found.getId().equals(excludeId))) {
OrgPersonnelEntity found = orgPersonnelGateway.findAnyByAccount(account);
if (found != null && !isSoftDeleted(found)
&& (excludeId == null || !found.getId().equals(excludeId))) {
throw new BizException(ErrorCode.ORG_PERSONNEL_ACCOUNT_EXISTS);
}
}
private void applyEmploymentDefault(OrgPersonnelEntity entity) {
if (entity.getEmploymentStatusCode() == null) {
entity.setEmploymentStatusCode(1);
entity.setEmploymentStatusName("在职");
}
}
private boolean isSoftDeleted(OrgPersonnelEntity entity) {
return entity != null && "true".equals(entity.getDeleteEnum());
}
}

View File

@ -1,5 +1,6 @@
package org.qinan.safetyeval.infrastructure.dataobject;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -51,6 +52,11 @@ public class OrgPersonnelDO {
private String proofMaterialUrl;
// ---- GBS默认字段 ----
/**
* false-true-
* varchar
*/
@TableLogic(value = "false", delval = "true")
private String deleteEnum;
private String remarks;
private String createName;

View File

@ -94,6 +94,15 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
if (query.getCertTypeCode() != null) {
wrapper.eq(OrgPersonnelCertDO::getCertTypeCode, query.getCertTypeCode());
}
if (StringUtils.hasText(query.getCertNo())) {
wrapper.like(OrgPersonnelCertDO::getCertNo, query.getCertNo());
}
if (StringUtils.hasText(query.getCertCategoryName())) {
wrapper.like(OrgPersonnelCertDO::getCertCategoryName, query.getCertCategoryName());
}
if (StringUtils.hasText(query.getOperationCategoryName())) {
wrapper.like(OrgPersonnelCertDO::getOperationCategoryName, query.getOperationCategoryName());
}
Page<OrgPersonnelCertDO> page = new Page<>(query.getPageNum(), query.getPageSize());
IPage<OrgPersonnelCertDO> result = orgPersonnelCertMapper.selectPage(page, wrapper);

View File

@ -11,6 +11,8 @@ import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
import org.qinan.safetyeval.infrastructure.support.OrgPersonnelRawRepository;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -32,11 +34,24 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
@Resource
private OrgContextResolver orgContextResolver;
@Resource
private OrgPersonnelRawRepository orgPersonnelRawRepository;
@Override
public OrgPersonnelEntity save(OrgPersonnelEntity entity) {
OrgPersonnelDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
try {
orgPersonnelMapper.insert(dataObject);
}
catch (DuplicateKeyException ex) {
OrgPersonnelEntity existing = findAnyByAccount(entity.getAccount());
if (existing == null || !"true".equals(existing.getDeleteEnum())) {
throw ex;
}
entity.setId(existing.getId());
return restore(entity);
}
entity.setId(dataObject.getId());
InsertFieldDefaults.apply(entity);
entity.setTenantId(dataObject.getTenantId());
@ -61,6 +76,26 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
return toEntity(dataObject);
}
@Override
public OrgPersonnelEntity findAnyByAccount(String account) {
if (!StringUtils.hasText(account)) {
return null;
}
Long orgId = orgContextResolver.resolveOrgId(null);
OrgPersonnelDO dataObject = orgPersonnelRawRepository.selectAnyByOrgIdAndAccount(orgId, account);
return toEntity(dataObject);
}
@Override
public OrgPersonnelEntity restore(OrgPersonnelEntity entity) {
OrgPersonnelDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
dataObject.setDeleteEnum("false");
InsertFieldDefaults.applyForUpdate(dataObject);
orgPersonnelRawRepository.restoreById(dataObject);
return get(entity.getId());
}
@Override
public OrgPersonnelEntity findByUserName(String userName) {
if (!StringUtils.hasText(userName)) {
@ -207,6 +242,7 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
entity.setWorkExperience(dataObject.getWorkExperience());
entity.setProofMaterialUrl(dataObject.getProofMaterialUrl());
entity.setTenantId(dataObject.getTenantId());
entity.setDeleteEnum(dataObject.getDeleteEnum());
return entity;
}
}

View File

@ -0,0 +1,164 @@
package org.qinan.safetyeval.infrastructure.support;
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
/**
* MyBatis-Plus {@code @TableLogic}
*/
@Repository
public class OrgPersonnelRawRepository {
@Resource
private JdbcTemplate jdbcTemplate;
public OrgPersonnelDO selectAnyByOrgIdAndAccount(Long orgId, String account) {
String sql = "SELECT * FROM org_personnel WHERE org_id = ? AND account = ? LIMIT 1";
List<OrgPersonnelDO> rows = jdbcTemplate.query(sql, this::mapRow, orgId, account);
return rows.isEmpty() ? null : rows.get(0);
}
public int restoreById(OrgPersonnelDO dataObject) {
String sql = "UPDATE org_personnel SET "
+ "org_id = ?, dept_id = ?, post_id = ?, user_name = ?, account = ?, "
+ "gender_code = ?, gender_name = ?, birth_date = ?, id_card_no = ?, "
+ "current_address = ?, office_address = ?, education_code = ?, education_name = ?, "
+ "graduate_school = ?, major = ?, employment_status_code = ?, employment_status_name = ?, "
+ "person_type_code = ?, person_type_name = ?, qual_scope = ?, "
+ "professional_level_code = ?, professional_level_name = ?, evaluator_cert_no = ?, "
+ "education_type_code = ?, education_type_name = ?, education_level_code = ?, education_level_name = ?, "
+ "title_name = ?, register_engineer_flag = ?, publications = ?, ability_declaration = ?, "
+ "work_experience = ?, proof_material_url = ?, delete_enum = 'false', "
+ "update_time = ?, update_id = ?, update_name = ? "
+ "WHERE id = ?";
return jdbcTemplate.update(sql,
dataObject.getOrgId(),
dataObject.getDeptId(),
dataObject.getPostId(),
dataObject.getUserName(),
dataObject.getAccount(),
dataObject.getGenderCode(),
dataObject.getGenderName(),
dataObject.getBirthDate(),
dataObject.getIdCardNo(),
dataObject.getCurrentAddress(),
dataObject.getOfficeAddress(),
dataObject.getEducationCode(),
dataObject.getEducationName(),
dataObject.getGraduateSchool(),
dataObject.getMajor(),
dataObject.getEmploymentStatusCode(),
dataObject.getEmploymentStatusName(),
dataObject.getPersonTypeCode(),
dataObject.getPersonTypeName(),
dataObject.getQualScope(),
dataObject.getProfessionalLevelCode(),
dataObject.getProfessionalLevelName(),
dataObject.getEvaluatorCertNo(),
dataObject.getEducationTypeCode(),
dataObject.getEducationTypeName(),
dataObject.getEducationLevelCode(),
dataObject.getEducationLevelName(),
dataObject.getTitleName(),
dataObject.getRegisterEngineerFlag(),
dataObject.getPublications(),
dataObject.getAbilityDeclaration(),
dataObject.getWorkExperience(),
dataObject.getProofMaterialUrl(),
dataObject.getUpdateTime(),
dataObject.getUpdateId(),
dataObject.getUpdateName(),
dataObject.getId());
}
private OrgPersonnelDO mapRow(ResultSet rs, int rowNum) throws SQLException {
OrgPersonnelDO row = new OrgPersonnelDO();
row.setId(rs.getLong("id"));
row.setOrgId(rs.getLong("org_id"));
long deptId = rs.getLong("dept_id");
if (!rs.wasNull()) {
row.setDeptId(deptId);
}
long postId = rs.getLong("post_id");
if (!rs.wasNull()) {
row.setPostId(postId);
}
row.setUserName(rs.getString("user_name"));
row.setAccount(rs.getString("account"));
int genderCode = rs.getInt("gender_code");
if (!rs.wasNull()) {
row.setGenderCode(genderCode);
}
row.setGenderName(rs.getString("gender_name"));
java.sql.Date birthDate = rs.getDate("birth_date");
if (birthDate != null) {
row.setBirthDate(birthDate.toLocalDate());
}
row.setIdCardNo(rs.getString("id_card_no"));
row.setCurrentAddress(rs.getString("current_address"));
row.setOfficeAddress(rs.getString("office_address"));
row.setEducationCode(rs.getString("education_code"));
row.setEducationName(rs.getString("education_name"));
row.setGraduateSchool(rs.getString("graduate_school"));
row.setMajor(rs.getString("major"));
int employmentStatusCode = rs.getInt("employment_status_code");
if (!rs.wasNull()) {
row.setEmploymentStatusCode(employmentStatusCode);
}
row.setEmploymentStatusName(rs.getString("employment_status_name"));
row.setPersonTypeCode(rs.getString("person_type_code"));
row.setPersonTypeName(rs.getString("person_type_name"));
row.setQualScope(rs.getString("qual_scope"));
row.setProfessionalLevelCode(rs.getString("professional_level_code"));
row.setProfessionalLevelName(rs.getString("professional_level_name"));
row.setEvaluatorCertNo(rs.getString("evaluator_cert_no"));
row.setEducationTypeCode(rs.getString("education_type_code"));
row.setEducationTypeName(rs.getString("education_type_name"));
row.setEducationLevelCode(rs.getString("education_level_code"));
row.setEducationLevelName(rs.getString("education_level_name"));
row.setTitleName(rs.getString("title_name"));
int registerEngineerFlag = rs.getInt("register_engineer_flag");
if (!rs.wasNull()) {
row.setRegisterEngineerFlag(registerEngineerFlag);
}
row.setPublications(rs.getString("publications"));
row.setAbilityDeclaration(rs.getString("ability_declaration"));
row.setWorkExperience(rs.getString("work_experience"));
row.setProofMaterialUrl(rs.getString("proof_material_url"));
row.setDeleteEnum(rs.getString("delete_enum"));
row.setRemarks(rs.getString("remarks"));
row.setCreateName(rs.getString("create_name"));
row.setUpdateName(rs.getString("update_name"));
long tenantId = rs.getLong("tenant_id");
if (!rs.wasNull()) {
row.setTenantId(tenantId);
}
int version = rs.getInt("version");
if (!rs.wasNull()) {
row.setVersion(version);
}
LocalDateTime createTime = rs.getTimestamp("create_time") != null
? rs.getTimestamp("create_time").toLocalDateTime() : null;
row.setCreateTime(createTime);
LocalDateTime updateTime = rs.getTimestamp("update_time") != null
? rs.getTimestamp("update_time").toLocalDateTime() : null;
row.setUpdateTime(updateTime);
long createId = rs.getLong("create_id");
if (!rs.wasNull()) {
row.setCreateId(createId);
}
long updateId = rs.getLong("update_id");
if (!rs.wasNull()) {
row.setUpdateId(updateId);
}
row.setEnv(rs.getString("env"));
return row;
}
}