Преглед изворни кода

批量审核添加操作轨迹

lixiaolong пре 5 дана
родитељ
комит
ba097beb04

+ 18 - 17
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.jzg.commons.core.base.BaseModel;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.io.Serial;
@@ -22,39 +23,39 @@ public class PtlAgreementCost extends BaseModel {
 
     @Serial
     private static final long serialVersionUID = -985496146546865007L;
-    @TableId(type = IdType.ASSIGN_ID)
+    @Schema(description = "主键")
     private String id;
-
+    @Schema(description = "协议ID")
     private String ptlAgreementId;
-
+    @Schema(description = "承保规则ID")
     private String coverRuleId;
-
+    @Schema(description = "险种")
     private String productName;
-
+    @Schema(description = "险种ID")
     private String productId;
-
+    @Schema(description = "生效时间")
     private Date effectiveTime;
-
+    @Schema(description = "失效时间")
     private Date failureTime;
-
+    @Schema(description = "优先级")
     private Integer priorityLevel;
-
+    @Schema(description = "审核方式")//:0-自动审核;1-手动审核
     private int auditMethod;
-
+    @Schema(description = "费用描述")
     private String costDescribe;
-
+    @Schema(description = "审核状态")//:0-申请审核;1-审核通过;2-审核未通过
     private Integer approved;
-
+    @Schema(description = "审核描述")
     private String reviewDescription;
-
+    @Schema(description = "是否有效")//:0-生效中;1-已失效
     private int isValid;
-
+    @Schema(description = "是否启用")//:0-启用;1-停用
     private int isEnabled;
-
+    @Schema(description = "费用规则")
     private String costRules;
-
+    @Schema(description = "审核时间")
     private LocalDateTime auditTime;
-
+    @Schema(description = "审核人")
     private String auditPerson;
 
 }

+ 63 - 4
commons/src/main/java/com/jzg/commons/util/comparble/CompatibleUtils.java

@@ -112,6 +112,32 @@ public class CompatibleUtils {
         FIELD_DESCRIPTION_MAP.put("auditPerson", "审核人");
     }
 
+    /** PO 状态字段码值映射(用于操作轨迹 compareResultList 中文展示) */
+    private static final Map<String, String> APPROVED_MAP = new HashMap<>();
+    static {
+        APPROVED_MAP.put("0", "申请审核");
+        APPROVED_MAP.put("1", "审核通过");
+        APPROVED_MAP.put("2", "审核未通过");
+    }
+
+    private static final Map<String, String> AUDIT_METHOD_MAP = new HashMap<>();
+    static {
+        AUDIT_METHOD_MAP.put("0", "自动审核");
+        AUDIT_METHOD_MAP.put("1", "手动审核");
+    }
+
+    private static final Map<String, String> IS_VALID_MAP = new HashMap<>();
+    static {
+        IS_VALID_MAP.put("0", "生效中");
+        IS_VALID_MAP.put("1", "已失效");
+    }
+
+    private static final Map<String, String> IS_ENABLED_MAP = new HashMap<>();
+    static {
+        IS_ENABLED_MAP.put("0", "启用");
+        IS_ENABLED_MAP.put("1", "停用");
+    }
+
     // ============ 字典解析器(由外部注入) ============
     private static DictLabelResolver dictLabelResolver;
 
@@ -418,8 +444,12 @@ public class CompatibleUtils {
                     results.add(buildCompareResult(entityName, key, displayOld, displayNew));
                 }
             } else {
-                String newValue = getValue(newData);
-                String oldValue = getValue(oldData);
+                // 先 getValue 做类型归一化(时间戳、LocalDateTime、BigDecimal...)
+                String rawNew = getValue(newData);
+                String rawOld = getValue(oldData);
+                // 再字典转换(PO 状态 int → 中文描述)
+                String newValue = convertDictValue(key, rawNew != null ? rawNew : newData, attrNameMap, dictLabelMap);
+                String oldValue = convertDictValue(key, rawOld != null ? rawOld : oldData, attrNameMap, dictLabelMap);
                 if (StringUtils.isNotEmpty(newValue) && !Objects.equals(oldValue, newValue)) {
                     String displayOld = (oldValue == null) ? "(空)" : oldValue;
                     results.add(buildCompareResult(entityName, key, displayOld, newValue));
@@ -742,6 +772,18 @@ public class CompatibleUtils {
                 value = new java.math.BigDecimal(value).stripTrailingZeros().toPlainString();
             } catch (NumberFormatException ignored) { }
         }
+        // ★ 时间戳字符串转日期(13位毫秒时间戳,落在合理日期范围)
+        if (value.matches("^\\d{13}$")) {
+            try {
+                long ts = Long.parseLong(value);
+                if (ts >= 946684800000L && ts <= 4102444800000L) {
+                    return LocalDateTime.ofInstant(
+                            java.time.Instant.ofEpochMilli(ts),
+                            java.time.ZoneId.systemDefault()
+                    ).format(DATE_TIME_FORMATTER);
+                }
+            } catch (NumberFormatException ignored) { }
+        }
 
         // 1) 操作符
         if ("operator".equals(fieldKey)) {
@@ -786,8 +828,25 @@ public class CompatibleUtils {
             }
         }
 
-        // 6) 非字典字段直接返回原始值,不做通用字典匹配
-        //    避免数值字段(如 inlet=2)被其他字典的 code 错误匹配
+        // 6) approved → 审核状态
+        if ("approved".equals(fieldKey)) {
+            return APPROVED_MAP.getOrDefault(value, value);
+        }
+        // 7) auditMethod → 审核方式
+        if ("auditMethod".equals(fieldKey)) {
+            return AUDIT_METHOD_MAP.getOrDefault(value, value);
+        }
+        // 8) isValid → 是否有效
+        if ("isValid".equals(fieldKey)) {
+            return IS_VALID_MAP.getOrDefault(value, value);
+        }
+        // 9) isEnabled → 是否启用
+        if ("isEnabled".equals(fieldKey)) {
+            return IS_ENABLED_MAP.getOrDefault(value, value);
+        }
+
+        // 10) 非字典字段直接返回原始值,不做通用字典匹配
+        //     避免数值字段(如 inlet=2)被其他字典的 code 错误匹配
         return value;
     }
 

+ 26 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -357,6 +357,7 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
                 if (ptlAgreementCost.getApproved() == 1 || ptlAgreementCost.getApproved() == 2) {
                     throw new SystemException("该条费用已审核,请勿重复操作");
                 }
+                PtlAgreementCost beforeCost = JSONUtil.toBean(JSONUtil.toJsonStr(ptlAgreementCost), PtlAgreementCost.class);
                 if (ptlAgreementCost.getApproved() == 0) {
                     StateResult stateResult = isSuccessful ?
                             costStateListener.auditSuccess(ptlAgreementCost) :
@@ -371,6 +372,31 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
                         baseMapper.updateById(ptlAgreementCost);
                     }
                 }
+                // 插入操作轨迹表记录
+                OperatorTrajectory operatorTrajectory = new OperatorTrajectory();
+                operatorTrajectory.setId(IdGenerate.nextId());
+                operatorTrajectory.setModuleName("代办事项/报价费用审核");
+                operatorTrajectory.setServiceTag(
+                        "com.jzg.organization.service.impl.PtlAgreementCostServiceImpl.audit()");
+                operatorTrajectory.setEntityName(
+                        "com.jzg.commons.entity.po.PtlAgreementCost");
+                operatorTrajectory.setPrimaryValue(String.join(",", costReviewParam.getIds()));
+                operatorTrajectory.setOperatorType(Crud.U.getCode());
+                Map<String, Object> beforeWrapper = new HashMap<>();
+                beforeWrapper.put("ptlAgreementCost", beforeCost);
+                operatorTrajectory.setBeforeJson(JSONUtil.toJsonStr(beforeWrapper));
+
+                Map<String, Object> afterWrapper = new HashMap<>();
+                afterWrapper.put("ptlAgreementCost", ptlAgreementCost);
+                operatorTrajectory.setAfterJson(JSONUtil.toJsonStr(afterWrapper));
+                operatorTrajectory.setOperationContent("报价费用审核");
+                operatorTrajectory.setSystemCode(baseController.getSystemCode());
+                String userTokenString = baseController.getUserTokenString();
+                JSONObject userInfo = JSONObject.parseObject(userTokenString);
+                operatorTrajectory.setCreateBy(userInfo.getString("username"));
+                operatorTrajectory.setCreateByName(userInfo.getString("name"));
+                operatorTrajectory.setCreateTime(LocalDateTime.now());
+                operatorTrajectoryService.save(operatorTrajectory);
             }
             if (isSuccessful) {
                 return HttpResult.ok("审核成功", costReviewParam.isAutomatic() ? nextDataID() : null);