diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/admin/dailyplan/vo/DailyPlanOperationLogRespVO.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/admin/dailyplan/vo/DailyPlanOperationLogRespVO.java index 377d7515..1d4e9bdc 100644 --- a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/admin/dailyplan/vo/DailyPlanOperationLogRespVO.java +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/controller/admin/dailyplan/vo/DailyPlanOperationLogRespVO.java @@ -16,5 +16,6 @@ public class DailyPlanOperationLogRespVO { private Integer changeQty; private String operationReason; private String operator; + private String operatorName; private LocalDateTime operationTime; } diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/dailyplan/DailyPlanServiceImpl.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/dailyplan/DailyPlanServiceImpl.java index 6e0d3518..788cd21d 100644 --- a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/dailyplan/DailyPlanServiceImpl.java +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/service/dailyplan/DailyPlanServiceImpl.java @@ -31,6 +31,8 @@ import cn.code.nl.module.lms.enums.DailyPlanSourceTypeEnum; import cn.code.nl.module.lms.enums.DailyPlanStrategyModeEnum; import cn.code.nl.module.lms.enums.DailyPlanStrategyTypeEnum; import cn.code.nl.module.lms.enums.DailyPlanWorkStatusEnum; +import cn.code.nl.module.system.api.user.AdminUserApi; +import cn.code.nl.module.system.api.user.dto.AdminUserRespDTO; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import jakarta.annotation.Resource; @@ -46,7 +48,10 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.code.nl.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -90,6 +95,8 @@ public class DailyPlanServiceImpl implements DailyPlanService { @Resource private CodeGenApi codeGenApi; @Resource + private AdminUserApi adminUserApi; + @Resource private PlatformTransactionManager transactionManager; /** ERP 幂等推送日计划,并在首次推送并发冲突时进行一次独立事务重试。 */ @@ -234,8 +241,16 @@ public class DailyPlanServiceImpl implements DailyPlanService { if (dailyPlanMapper.selectDailyPlanById(dailyPlanId) == null) { throw exception(DAILY_PLAN_NOT_EXISTS); } - List result = new ArrayList<>(); - for (DailyPlanOperationLogDO log : dailyPlanOperationLogMapper.selectListByDailyPlanId(dailyPlanId)) { + List logs = dailyPlanOperationLogMapper.selectListByDailyPlanId(dailyPlanId); + Set operatorIds = logs.stream() + .map(DailyPlanOperationLogDO::getOperator) + .map(DailyPlanServiceImpl::parseOperatorId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + Map userMap = operatorIds.isEmpty() + ? Map.of() : adminUserApi.getUserMap(operatorIds); + List result = new ArrayList<>(logs.size()); + for (DailyPlanOperationLogDO log : logs) { DailyPlanOperationLogRespVO response = new DailyPlanOperationLogRespVO(); response.setOperationLogId(log.getOperationLogId()); response.setDailyPlanId(log.getDailyPlanId()); @@ -246,12 +261,37 @@ public class DailyPlanServiceImpl implements DailyPlanService { response.setChangeQty(log.getChangeQty()); response.setOperationReason(log.getOperationReason()); response.setOperator(log.getOperator()); + response.setOperatorName(resolveOperatorName(log.getOperator(), userMap)); response.setOperationTime(log.getOperationTime()); result.add(response); } return result; } + /** 批量翻译操作人;ERP 和系统操作不交给用户翻译,避免把非数字标识当用户 ID。 */ + private static String resolveOperatorName(String operator, Map userMap) { + if (ERP_OPERATOR.equalsIgnoreCase(operator)) { + return "ERP"; + } + Long operatorId = parseOperatorId(operator); + if (operatorId == null) { + return "系统"; + } + AdminUserRespDTO user = userMap.get(operatorId); + return user == null ? "未知用户" : user.getNickname(); + } + + private static Long parseOperatorId(String operator) { + if (StrUtil.isBlank(operator) || !operator.chars().allMatch(Character::isDigit)) { + return null; + } + try { + return Long.valueOf(operator); + } catch (NumberFormatException ignored) { + return null; + } + } + /** 查询全部日计划策略。 */ @Override public List getStrategies() { diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/lms/dailyplan/index.ts b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/lms/dailyplan/index.ts index f028b1fe..faece6a9 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/lms/dailyplan/index.ts +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/api/lms/dailyplan/index.ts @@ -123,6 +123,7 @@ export namespace LmsDailyPlanApi { operationTime: number; operationType: string; operator: string; + operatorName?: string; } export interface Strategy { diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/index.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/index.vue index 5b42dbc4..5f63735d 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/index.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/index.vue @@ -124,10 +124,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ type: 'link', auth: ['lms:daily-plan:start'], ifShow: row.orderStatus === ORDER_NOT_STARTED, - popConfirm: { - title: `确认开始日计划「${row.planCode}」吗?`, - confirm: handleStart.bind(null, row), - }, + onClick: handleStart.bind(null, row), }, ]" /> diff --git a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/modules/detail.vue b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/modules/detail.vue index 63090be5..54e4a4a6 100644 --- a/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/modules/detail.vue +++ b/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/apps/web-antdv-next/src/views/lms/daily-plan/management/modules/detail.vue @@ -5,6 +5,7 @@ import { ref } from 'vue'; import { useVbenDrawer } from '@vben/common-ui'; import { DICT_TYPE } from '@vben/constants'; +import { getDictLabel } from '@vben/hooks'; import { formatDateTime } from '@vben/utils'; import { @@ -21,11 +22,51 @@ const DAILY_PLAN_DICT_TYPE = DICT_TYPE as typeof DICT_TYPE & { LMS_DAILY_PLAN_SOURCE_TYPE: string; LMS_DAILY_PLAN_WORK_STATUS: string; }; +const TARGET_LABELS: Record = { + ORDER: '订单', + QUANTITY: '数量', + SLEEVING: '套管', + SORT: '顺序', + STOCKING: '备货', + STRATEGY: '策略', + WEIGHT: '权重', +}; +const TYPE_LABELS: Record = { + APPEND: '追加数量', + CANCEL: '取消', + CREATE: '创建', + FINISH: '结束', + PROGRESS: '更新进度', + RESTORE: '恢复', + START: '开始', + STOP: '停止', + UPDATE: '修改', +}; +const STATUS_OPERATION_TYPES = new Set(['CANCEL', 'FINISH', 'RESTORE', 'START', 'STOP']); function showTime(value?: number) { return value ? formatDateTime(value) : '-'; } +function showTarget(value: string) { + return TARGET_LABELS[value] ?? '其他'; +} + +function showType(value: string) { + return TYPE_LABELS[value] ?? '操作'; +} + +function showLogValue(log: LmsDailyPlanApi.OperationLog, value?: string) { + if (!value) return '-'; + if (!STATUS_OPERATION_TYPES.has(log.operationType)) return value; + const dictType = log.operationTarget === 'ORDER' + ? DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_ORDER_STATUS + : ['SLEEVING', 'STOCKING'].includes(log.operationTarget) + ? DAILY_PLAN_DICT_TYPE.LMS_DAILY_PLAN_WORK_STATUS + : undefined; + return dictType ? (getDictLabel(dictType, value) || '未知状态') : value; +} + const [Drawer, drawerApi] = useVbenDrawer({ showConfirmButton: false, async onOpenChange(isOpen: boolean) { @@ -84,12 +125,12 @@ const [Drawer, drawerApi] = useVbenDrawer({ -
{{ log.operationType }} · {{ log.operationTarget }}
-
{{ showTime(log.operationTime) }} · {{ log.operator || '-' }}
+
{{ showType(log.operationType) }} · {{ showTarget(log.operationTarget) }}
+
{{ showTime(log.operationTime) }} · {{ log.operatorName || '系统' }}
- {{ log.beforeValue || '-' }} → {{ log.afterValue || '-' }} + 变更:{{ showLogValue(log, log.beforeValue) }} → {{ showLogValue(log, log.afterValue) }}
-
数量变化:{{ log.changeQty > 0 ? '+' : '' }}{{ log.changeQty }}
+
数量变化:{{ log.changeQty > 0 ? '+' : '' }}{{ log.changeQty }} 根
原因:{{ log.operationReason }}