From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsBizLogServiceImpl.java |  131 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 131 insertions(+), 0 deletions(-)

diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsBizLogServiceImpl.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsBizLogServiceImpl.java
new file mode 100644
index 0000000..d384505
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsBizLogServiceImpl.java
@@ -0,0 +1,131 @@
+package jnpf.limsService.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import jnpf.limsEntity.LimsBizLogEntity;
+import jnpf.limsEntity.bizlog.BizLogAction;
+import jnpf.limsEntity.bizlog.BizLogType;
+import jnpf.limsEntity.bizlog.LimsBizLogQueryParam;
+import jnpf.limsEntity.bizlog.LimsBizLogVo;
+import jnpf.limsMapper.LimsBizLogMapper;
+import jnpf.limsService.LimsBizLogService;
+import jnpf.permission.UserApi;
+import jnpf.permission.entity.UserEntity;
+import jnpf.util.DateUtil;
+import jnpf.util.UploaderUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class LimsBizLogServiceImpl
+        extends ServiceImpl<LimsBizLogMapper, LimsBizLogEntity>
+        implements LimsBizLogService {
+
+    @Autowired
+    private UserApi userApi;
+
+    @Override
+    public List<LimsBizLogVo> listByBizCode(LimsBizLogQueryParam q) {
+        QueryWrapper<LimsBizLogEntity> wrapper = new QueryWrapper<>();
+        wrapper.lambda()
+                .eq(LimsBizLogEntity::getBizCode, q.getBizCode())
+                .eq(LimsBizLogEntity::getDeleteMark, 0);
+        if (StringUtils.hasText(q.getBizType())) {
+            wrapper.lambda().eq(LimsBizLogEntity::getBizType, q.getBizType());
+        }
+        if (StringUtils.hasText(q.getActionType())) {
+            wrapper.lambda().eq(LimsBizLogEntity::getActionType, q.getActionType());
+        }
+        if (StringUtils.hasText(q.getOperatorUserId())) {
+            wrapper.lambda().eq(LimsBizLogEntity::getOperatorUserId, q.getOperatorUserId());
+        }
+        if (q.getStartTime() != null) {
+            wrapper.lambda().ge(LimsBizLogEntity::getCreatorTime, q.getStartTime());
+        }
+        if (q.getEndTime() != null) {
+            wrapper.lambda().le(LimsBizLogEntity::getCreatorTime, q.getEndTime());
+        }
+        wrapper.lambda().orderByDesc(LimsBizLogEntity::getCreatorTime).orderByDesc(LimsBizLogEntity::getLogSeq);
+
+        Page<LimsBizLogEntity> page = new Page<>(q.getCurrentPage(), q.getPageSize());
+        Page<LimsBizLogEntity> result = this.page(page, wrapper);
+        List<LimsBizLogEntity> rows = result.getRecords();
+
+        // 鎵归噺琛� user 淇℃伅
+        List<String> userIds = rows.stream()
+                .map(LimsBizLogEntity::getOperatorUserId)
+                .filter(StringUtils::hasText)
+                .distinct()
+                .collect(Collectors.toList());
+        Map<String, UserEntity> userMap = new HashMap<>();
+        if (!userIds.isEmpty()) {
+            List<UserEntity> users = userApi.getUserName(userIds);
+            if (users != null) {
+                userMap = users.stream().collect(Collectors.toMap(UserEntity::getId, u -> u, (a, b) -> a));
+            }
+        }
+
+        List<LimsBizLogVo> voList = new ArrayList<>(rows.size());
+        for (LimsBizLogEntity e : rows) {
+            voList.add(toVo(e, userMap));
+        }
+        // 鎶� total 鍐欏洖 Pagination 鍏ュ弬锛孋ontroller 澶嶅埗鍒� PaginationVO 鍗冲彲
+        q.setData(voList, result.getTotal());
+        return voList;
+    }
+
+    private LimsBizLogVo toVo(LimsBizLogEntity e, Map<String, UserEntity> userMap) {
+        LimsBizLogVo vo = new LimsBizLogVo();
+        vo.setId(e.getId());
+        vo.setLogSeq(e.getLogSeq());
+        vo.setBizCode(e.getBizCode());
+        vo.setBizType(e.getBizType());
+        vo.setActionType(e.getActionType());
+        vo.setActionLabel(e.getActionLabel());
+        vo.setCreatorTime(e.getCreatorTime() == null ? null
+                : DateUtil.dateToString(e.getCreatorTime(), "yyyy-MM-dd HH:mm"));
+        vo.setCreatorUserId(e.getOperatorUserId());
+
+        BizLogAction action = parseAction(e.getActionType());
+        vo.setType(action == null ? null : action.getFrontendType());
+
+        UserEntity user = userMap.get(e.getOperatorUserId());
+        if (user != null) {
+            vo.setCreatorUserName(user.getRealName());
+            vo.setHeadIcon(UploaderUtil.uploaderImg(user.getHeadIcon()));
+        }
+
+        // JSON 瀛楃涓茬洿鎺ラ�忎紶锛屽墠绔� JSON.parse 瑙f瀽锛堜笌骞冲彴鍘熺敓鏃ュ織涓�鑷达級
+        vo.setDataLog(e.getDataLog());
+        vo.setExtraJson(e.getExtraJson());
+        return vo;
+    }
+
+    private BizLogAction parseAction(String code) {
+        if (code == null) return null;
+        for (BizLogAction a : BizLogAction.values()) {
+            if (a.getCode().equals(code)) return a;
+        }
+        return null;
+    }
+
+    /** 浠呬緵鍒囬潰/璋冪敤鏂规煡 bizType 鏂囨锛岀洰鍓嶆湭鐩存帴鐢紝淇濈暀鎵╁睍 */
+    @SuppressWarnings("unused")
+    private BizLogType parseType(String code) {
+        if (code == null) return null;
+        for (BizLogType t : BizLogType.values()) {
+            if (t.getCode().equals(code)) return t;
+        }
+        return null;
+    }
+}

--
Gitblit v1.8.0