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/LimsJieyangTuihuiServiceImpl.java | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsJieyangTuihuiServiceImpl.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsJieyangTuihuiServiceImpl.java
new file mode 100644
index 0000000..4e76fdd
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsJieyangTuihuiServiceImpl.java
@@ -0,0 +1,89 @@
+package jnpf.limsService.impl;
+
+import jnpf.audit.sdk.annotation.AuditLog;
+
+import jnpf.base.UserInfo;
+import jnpf.base.service.SuperServiceImpl;
+import jnpf.exception.DataException;
+import jnpf.limsEntity.LimsJieyangTuihuiEntity;
+import jnpf.limsMapper.LimsJieyangTuihuiMapper;
+import jnpf.limsService.LimsJieyangTuihuiService;
+import jnpf.util.UserProvider;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Service
+public class LimsJieyangTuihuiServiceImpl
+ extends SuperServiceImpl<LimsJieyangTuihuiMapper, LimsJieyangTuihuiEntity>
+ implements LimsJieyangTuihuiService {
+
+ @Override
+ @AuditLog(action = "CREATE", label = "鏍峰搧閫�鍥炶褰曟柊澧�", bizType = "JIEYANG",
+ bizCodeExpr = "#entity.jianyanLiushuihao", targetTable = "lims_jieyang_tuihui",
+ targetIdExpr = "#result?.id", diff = true, entityClass = LimsJieyangTuihuiEntity.class)
+ public LimsJieyangTuihuiEntity createTuihui(LimsJieyangTuihuiEntity entity) {
+ if (entity.getJianyanLiushuihao() == null || entity.getJianyanLiushuihao().isEmpty()) {
+ throw new DataException("妫�楠屾祦姘村彿涓嶈兘涓虹┖");
+ }
+ if (entity.getJieyangBanzuId() == null || entity.getJieyangBanzuId().isEmpty()) {
+ throw new DataException("鎺ユ牱鐝粍 id 涓嶈兘涓虹┖");
+ }
+ BigDecimal tuihui = parsePositive(entity.getTuihuiShuliang(), "閫�鍥炴暟閲�");
+
+ BigDecimal ketuihui = parseOptional(entity.getKetuihuiShuliang());
+ if (ketuihui != null && tuihui.compareTo(ketuihui) > 0) {
+ throw new DataException("閫�鍥炴暟閲忎笉鑳藉ぇ浜庡彲閫�鍥炴暟閲�");
+ }
+
+ // 缁撲綑鏁伴噺锛氬墠绔嫢鏈紶锛屽垯鎸� (ketuihui - tuihui) 鍏滃簳
+ if ((entity.getJieyuShuliang() == null || entity.getJieyuShuliang().isEmpty())
+ && ketuihui != null) {
+ entity.setJieyuShuliang(ketuihui.subtract(tuihui).toPlainString());
+ }
+
+ if (entity.getCunruRen() == null || entity.getCunruRen().isEmpty()) {
+ UserInfo userInfo = UserProvider.getUser();
+ entity.setCunruRen(userInfo.getUserId());
+ }
+ if (entity.getCunruShijian() == null) {
+ entity.setCunruShijian(new Date());
+ }
+
+ entity.setDeleteMark(null);
+ entity.setDeleteTime(null);
+ entity.setDeleteUserId(null);
+
+ if (!this.save(entity)) {
+ throw new DataException("閫�鍥炶褰曚繚瀛樺け璐�");
+ }
+ return entity;
+ }
+
+ private BigDecimal parsePositive(String value, String fieldName) {
+ if (value == null || value.isEmpty()) {
+ throw new DataException(fieldName + "涓嶈兘涓虹┖");
+ }
+ try {
+ BigDecimal v = new BigDecimal(value.trim());
+ if (v.signum() <= 0) {
+ throw new DataException(fieldName + "蹇呴』澶т簬 0");
+ }
+ return v;
+ } catch (NumberFormatException e) {
+ throw new DataException(fieldName + "蹇呴』鏄暟瀛�");
+ }
+ }
+
+ private BigDecimal parseOptional(String value) {
+ if (value == null || value.isEmpty()) {
+ return null;
+ }
+ try {
+ return new BigDecimal(value.trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+}
--
Gitblit v1.8.0