Browse Source

2026-06-12

RoHs优化
master
fengyuan_yang 2 days ago
parent
commit
6891f679d5
  1. 12
      src/main/java/com/spring/modules/rohs/entity/RohsEntity.java
  2. 49
      src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java

12
src/main/java/com/spring/modules/rohs/entity/RohsEntity.java

@ -218,11 +218,23 @@ public class RohsEntity implements Serializable {
*/ */
private String hsfApprover; private String hsfApprover;
/**
* HSF审批人名称;分隔前端展示
*/
@TableField(exist = false)
private String hsfApproverName;
/** /**
* Inform Related people * Inform Related people
*/ */
private String relatedPeople; private String relatedPeople;
/**
* Inform Related people名称前端展示
*/
@TableField(exist = false)
private String relatedPeopleName;
/** /**
* 有效期数值 * 有效期数值
*/ */

49
src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java

@ -77,6 +77,13 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
new Query<RohsEntity>().getPage(params), new Query<RohsEntity>().getPage(params),
params params
); );
List<RohsEntity> records = page.getRecords();
if (records != null && !records.isEmpty()) {
Map<String, String> userDisplayCache = new HashMap<>();
for (RohsEntity rohs : records) {
fillUserDisplayFields(rohs, userDisplayCache);
}
}
return new PageUtils(page); return new PageUtils(page);
} }
@ -85,6 +92,7 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
public RohsEntity getDetail(String site, String referenceNo) { public RohsEntity getDetail(String site, String referenceNo) {
RohsEntity rohs = this.baseMapper.getDetailWithNames(site, referenceNo); RohsEntity rohs = this.baseMapper.getDetailWithNames(site, referenceNo);
if (rohs != null) { if (rohs != null) {
fillUserDisplayFields(rohs, new HashMap<>());
rohs.setMaterialList(this.getMaterialList(site, referenceNo)); rohs.setMaterialList(this.getMaterialList(site, referenceNo));
} }
return rohs; return rohs;
@ -529,6 +537,47 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
return String.valueOf(valueObj); return String.valueOf(valueObj);
} }
private void fillUserDisplayFields(RohsEntity rohs, Map<String, String> userDisplayCache) {
if (rohs == null) {
return;
}
rohs.setHsfApproverName(convertUserCodeListToDisplay(rohs.getHsfApprover(), userDisplayCache));
rohs.setRelatedPeopleName(convertUserCodeListToDisplay(rohs.getRelatedPeople(), userDisplayCache));
}
private String convertUserCodeListToDisplay(String userCodeList, Map<String, String> userDisplayCache) {
if (StringUtils.isBlank(userCodeList)) {
return "";
}
String[] users = userCodeList.replace(";", ",").split(",");
List<String> userDisplayList = new ArrayList<>();
for (String userCode : users) {
String normalizedCode = StringUtils.trim(userCode);
if (StringUtils.isBlank(normalizedCode)) {
continue;
}
userDisplayList.add(resolveUserDisplay(normalizedCode, userDisplayCache));
}
return String.join(";", userDisplayList);
}
private String resolveUserDisplay(String userCode, Map<String, String> userDisplayCache) {
if (StringUtils.isBlank(userCode)) {
return "";
}
String normalizedCode = userCode.trim();
if (userDisplayCache.containsKey(normalizedCode)) {
return userDisplayCache.get(normalizedCode);
}
String userDisplay = normalizedCode;
SysUserEntity sysUser = sysUserDao.queryByUserName(normalizedCode);
if (sysUser != null && StringUtils.isNotBlank(sysUser.getUserDisplay())) {
userDisplay = sysUser.getUserDisplay().trim();
}
userDisplayCache.put(normalizedCode, userDisplay);
return userDisplay;
}
private void sanitizeHsfStandard(RohsEntity rohs) { private void sanitizeHsfStandard(RohsEntity rohs) {
if (rohs == null) { if (rohs == null) {
return; return;

Loading…
Cancel
Save