feat(wms): 添加用户昵称显示功能
- 在WmsCoilPendingActionMapper.xml中关联sys_user表获取创建人和操作人昵称 - 在WmsMaterialCoilMapper.xml中关联sys_user表获取创建人和更新人昵称 - 在WmsCoilPendingActionVo.java和WmsMaterialCoilVo.java中添加createByName和updateByName字段 - 在WmsDeliveryPlanServiceImpl.java中实现根据用户名获取用户昵称的逻辑 - 在WmsMaterialCoilServiceImpl.java中实现批量获取操作人昵称的功能 - 在pom.xml中添加klp-system依赖以支持用户服务调用
This commit is contained in:
@@ -2,6 +2,7 @@ package com.klp.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.klp.common.core.domain.entity.SysUser;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -10,8 +11,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.helper.LoginHelper;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.common.utils.spring.SpringUtils;
|
||||
import com.klp.domain.bo.*;
|
||||
import com.klp.domain.vo.*;
|
||||
import com.klp.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -52,6 +55,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
private final IWmsRawMaterialService rawMaterialService;
|
||||
private final IWmsBomItemService bomItemService;
|
||||
private final IWmsProductService productService;
|
||||
private final ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 查询钢卷物料表
|
||||
@@ -1283,6 +1287,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
Map<String, Map<String, Object>> uniqueSteps = new HashMap<>(); // 用于去重
|
||||
Set<String> allCoilNos = new HashSet<>();
|
||||
|
||||
// 收集所有操作人用户名
|
||||
Set<String> operatorUsernames = new HashSet<>();
|
||||
|
||||
for (WmsGenerateRecordVo qrRecord : allQrRecords) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> contentMap = (Map<String, Object>) objectMapper.readValue(qrRecord.getContent(), Map.class);
|
||||
@@ -1301,6 +1308,12 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
uniqueStep.put("qrcode_serial", qrRecord.getSerialNumber());
|
||||
uniqueStep.put("qrcode_id", qrRecord.getRecordId());
|
||||
uniqueSteps.put(stepKey, uniqueStep);
|
||||
|
||||
// 收集操作人用户名
|
||||
Object operator = step.get("operator");
|
||||
if (operator != null) {
|
||||
operatorUsernames.add(operator.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// 提取钢卷号
|
||||
@@ -1317,6 +1330,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取操作人昵称映射
|
||||
Map<String, String> operatorNicknameMap = getOperatorNicknames(operatorUsernames);
|
||||
|
||||
// 转换为列表并按原始步骤号排序(保持时间顺序)
|
||||
List<Map<String, Object>> allSteps = new ArrayList<>(uniqueSteps.values());
|
||||
|
||||
@@ -1334,6 +1350,14 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
allSteps.get(i).put("display_step", i + 1);
|
||||
// 保留原始步骤号用于调试
|
||||
allSteps.get(i).put("original_step", allSteps.get(i).get("step"));
|
||||
|
||||
// 替换操作人为昵称
|
||||
Object operator = allSteps.get(i).get("operator");
|
||||
if (operator != null) {
|
||||
String username = operator.toString();
|
||||
String nickname = operatorNicknameMap.get(username);
|
||||
allSteps.get(i).put("operator_nickname", nickname != null ? nickname : username);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 如果指定了当前钢卷号,过滤出相关的钢卷号
|
||||
@@ -1409,6 +1433,35 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名获取用户昵称映射
|
||||
* @param usernames 用户名集合
|
||||
* @return 用户名到昵称的映射
|
||||
*/
|
||||
private Map<String, String> getOperatorNicknames(Set<String> usernames) {
|
||||
Map<String, String> nicknameMap = new HashMap<>();
|
||||
if (usernames.isEmpty()) {
|
||||
return nicknameMap;
|
||||
}
|
||||
|
||||
for (String username : usernames) {
|
||||
try {
|
||||
// 通过用户名查找用户
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (user != null) {
|
||||
nicknameMap.put(username, user.getNickName());
|
||||
} else {
|
||||
nicknameMap.put(username, username); // 找不到则使用原用户名
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 出现异常时使用原用户名
|
||||
nicknameMap.put(username, username);
|
||||
}
|
||||
}
|
||||
|
||||
return nicknameMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建步骤唯一标识
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user