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/LimsShebeiYiqiXinxiServiceImpl.java | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 209 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiXinxiServiceImpl.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiXinxiServiceImpl.java
new file mode 100644
index 0000000..969e835
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiXinxiServiceImpl.java
@@ -0,0 +1,209 @@
+package jnpf.limsService.impl;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import jnpf.audit.sdk.annotation.AuditLog;
+import jnpf.base.service.SuperServiceImpl;
+import jnpf.exception.DataException;
+import jnpf.limsEntity.LimsShebeiYiqiJiliangEntity;
+import jnpf.limsEntity.LimsShebeiYiqiXinxiEntity;
+import jnpf.limsEntity.LimsShebeiYiqiYanzhengEntity;
+import jnpf.limsMapper.LimsShebeiYiqiJiliangMapper;
+import jnpf.limsMapper.LimsShebeiYiqiXinxiMapper;
+import jnpf.limsMapper.LimsShebeiYiqiYanzhengMapper;
+import jnpf.limsService.LimsShebeiYiqiXinxiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+@Service
+public class LimsShebeiYiqiXinxiServiceImpl
+ extends SuperServiceImpl<LimsShebeiYiqiXinxiMapper, LimsShebeiYiqiXinxiEntity>
+ implements LimsShebeiYiqiXinxiService {
+
+ private static final String BIZ_STATUS_YIBAOFEI = "yibaofei";
+ private static final String XINGNENG_ZHUANGTAI_ZHUNYONG = "zhunyong";
+ @Autowired
+ private LimsShebeiYiqiYanzhengMapper limsShebeiYiqiYanzhengMapper;
+
+ @Autowired
+ private LimsShebeiYiqiJiliangMapper limsShebeiYiqiJiliangMapper;
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ @AuditLog(action = "SCRAP", label = "浠櫒鎶ュ簾", bizType = "SHEBEI_YIQI",
+ bizCodeExpr = "#yiqiId", bizCodeRequired = false, targetTable = "lims_shebei_yiqi_xinxi",
+ targetIdExpr = "#yiqiId", diff = true, entityClass = LimsShebeiYiqiXinxiEntity.class)
+ public void baofei(String yiqiId) throws DataException {
+ String id = trimToEmpty(yiqiId);
+ if (id.isEmpty()) {
+ throw new DataException("浠櫒ID(yiqi_id)涓嶈兘涓虹┖");
+ }
+
+ LimsShebeiYiqiXinxiEntity yiqi = this.getById(id);
+ if (yiqi == null) {
+ throw new DataException("浠櫒淇℃伅涓嶅瓨鍦細" + id);
+ }
+
+ LimsShebeiYiqiXinxiEntity update = new LimsShebeiYiqiXinxiEntity();
+ update.setId(id);
+ update.setBizStatus(BIZ_STATUS_YIBAOFEI);
+ if (!this.updateById(update)) {
+ throw new DataException("浠櫒鎶ュ簾澶辫触锛岃鍒锋柊鍚庨噸璇�");
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ @AuditLog(action = "ENABLE", label = "浠櫒鎵归噺鍚敤", bizType = "SHEBEI_YIQI",
+ bizCodeExpr = "", bizCodeRequired = false, targetTable = "lims_shebei_yiqi_xinxi",
+ targetIdExpr = "#yiqiIds[0]", diff = true,
+ entityClass = LimsShebeiYiqiXinxiEntity.class)
+ public int qiyong(List<String> yiqiIds) throws DataException {
+ List<String> ids = normalizeIds(yiqiIds);
+ if (ids.isEmpty()) {
+ throw new DataException("浠櫒ID鍒楄〃(yiqi_ids)涓嶈兘涓虹┖");
+ }
+
+ LimsShebeiYiqiXinxiEntity update = new LimsShebeiYiqiXinxiEntity();
+ update.setXingnengZhuangtai(XINGNENG_ZHUANGTAI_ZHUNYONG);
+ LambdaUpdateWrapper<LimsShebeiYiqiXinxiEntity> wrapper = new LambdaUpdateWrapper<>();
+ wrapper.in(LimsShebeiYiqiXinxiEntity::getId, ids);
+ int updated = this.baseMapper.update(update, wrapper);
+ if (updated <= 0) {
+ throw new DataException("鏈壘鍒板彲鍚敤鐨勪华鍣ㄤ俊鎭�");
+ }
+ return updated;
+ }
+
+ @Override
+ public void checkTodayJiaoyan(String yiqiId, LocalDateTime jiaoyanShijian) throws DataException {
+ String id = trimToEmpty(yiqiId);
+ if (id.isEmpty()) {
+ throw new DataException("浠櫒ID(yiqi_id)涓嶈兘涓虹┖");
+ }
+ if (jiaoyanShijian == null) {
+ throw new DataException("鏍″噯鏃堕棿(jiaoyan_shijian)涓嶈兘涓虹┖");
+ }
+
+ LocalDateTime startTime = jiaoyanShijian.toLocalDate().atStartOfDay();
+ LocalDateTime endTime = startTime.plusDays(1);
+ if (this.baseMapper.existsTodayJiaoyan(id, startTime, endTime)) {
+ throw new DataException("璇ヤ华鍣ㄨ澶囦粖鏃ュ凡鏍″噯杩囷紝涓嶉渶瑕侀噸澶嶆牎鍑嗭紒");
+ }
+ }
+
+ @Override
+ public void checkShiyong(String yiqiId) throws DataException {
+ String id = trimToEmpty(yiqiId);
+ if (id.isEmpty()) {
+ throw new DataException("浠櫒ID(yiqi_id)涓嶈兘涓虹┖");
+ }
+
+ LocalDateTime startTime = LocalDate.now().atStartOfDay();
+ LocalDateTime endTime = startTime.plusDays(1);
+ if (this.baseMapper.requiresTodayJiaoyan(id, startTime, endTime)) {
+ throw new DataException("璇ヤ华鍣ㄨ澶囦粖鏃ラ渶瑕佹牎鍑嗭紝璇疯繘琛屾棩甯告牎鍑嗭紒");
+ }
+ if (this.baseMapper.existsUsingYiqi(id)) {
+ throw new DataException("璇ヤ华鍣ㄨ澶囨鍦ㄤ娇鐢紝璇风◢鍚庯紒");
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ @AuditLog(action = "VERIFY_CONFIRM", label = "纭浠櫒楠岃瘉", bizType = "SHEBEI_YIQI",
+ bizCodeExpr = "#yanzhengId", bizCodeRequired = false, targetTable = "lims_shebei_yiqi_xinxi",
+ targetIdExpr = "T(jnpf.limsService.support.LimsAuditTargetIds).yiqiByVerification(#yanzhengId)",
+ diff = true, entityClass = LimsShebeiYiqiXinxiEntity.class)
+ public void confirmYanzheng(String yanzhengId) throws DataException {
+ String id = trimToEmpty(yanzhengId);
+ if (id.isEmpty()) {
+ throw new DataException("浠櫒楠岃瘉ID(yanzheng_id)涓嶈兘涓虹┖");
+ }
+
+ LimsShebeiYiqiYanzhengEntity yanzheng = limsShebeiYiqiYanzhengMapper.selectById(id);
+ if (yanzheng == null) {
+ throw new DataException("浠櫒楠岃瘉璁板綍涓嶅瓨鍦細" + id);
+ }
+
+ LimsShebeiYiqiXinxiEntity update = new LimsShebeiYiqiXinxiEntity();
+ update.setShangciYanzhengShijian(yanzheng.getShangciYanzhengShijian());
+ update.setXiaciYanzhengShijian(yanzheng.getXiaciYanzhengShijian());
+ update.setYanzhengZhouqi(yanzheng.getYanzhengZhouqi());
+ update.setYanzhengShijianDanwei(yanzheng.getYanzhengShijianDanwei());
+ update.setTiqianTixingShijian(yanzheng.getTiqianTixingShijian());
+ update.setTixingShijianDanwei(yanzheng.getTixingShijianDanwei());
+ update.setYanzhengTixingRiqi(yanzheng.getYanzhengTixingRiqi());
+ updateYiqiXinxi(yanzheng.getYiqiId(), update, id, "浠櫒楠岃瘉璁板綍");
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ @AuditLog(action = "MEASURE_CONFIRM", label = "纭浠櫒璁¢噺", bizType = "SHEBEI_YIQI",
+ bizCodeExpr = "#jiliangId", bizCodeRequired = false, targetTable = "lims_shebei_yiqi_xinxi",
+ targetIdExpr = "T(jnpf.limsService.support.LimsAuditTargetIds).yiqiByMeasurement(#jiliangId)",
+ diff = true, entityClass = LimsShebeiYiqiXinxiEntity.class)
+ public void confirmJiliang(String jiliangId) throws DataException {
+ String id = trimToEmpty(jiliangId);
+ if (id.isEmpty()) {
+ throw new DataException("浠櫒璁¢噺ID(jiliang_id)涓嶈兘涓虹┖");
+ }
+
+ LimsShebeiYiqiJiliangEntity jiliang = limsShebeiYiqiJiliangMapper.selectById(id);
+ if (jiliang == null) {
+ throw new DataException("浠櫒璁¢噺璁板綍涓嶅瓨鍦細" + id);
+ }
+
+ LimsShebeiYiqiXinxiEntity update = new LimsShebeiYiqiXinxiEntity();
+ update.setShangciJiliangShijian(jiliang.getShangciJiliangShijian());
+ update.setXiaciJiliangShijian(jiliang.getXiaciJiliangShijian());
+ update.setJiliangZhouqi(jiliang.getJiliangZhouqi());
+ update.setJiliangShijianDanwei(jiliang.getJiliangShijianDanwei());
+ update.setTiqianTixingShijian(jiliang.getTiqianTixingShijian());
+ update.setTixingShijianDanwei(jiliang.getTixingShijianDanwei());
+ update.setJiliangTixingRiqi(jiliang.getJiliangTixingRiqi());
+ updateYiqiXinxi(jiliang.getYiqiId(), update, id, "浠櫒璁¢噺璁板綍");
+ }
+
+ private void updateYiqiXinxi(String yiqiId, LimsShebeiYiqiXinxiEntity update,
+ String recordId, String recordDescription) throws DataException {
+ yiqiId = trimToEmpty(yiqiId);
+ if (yiqiId.isEmpty()) {
+ throw new DataException(recordDescription + "鏈叧鑱斾华鍣�(yiqi_id)锛�" + recordId);
+ }
+ if (this.getById(yiqiId) == null) {
+ throw new DataException("鍏宠仈浠櫒淇℃伅涓嶅瓨鍦細" + yiqiId);
+ }
+
+ update.setId(yiqiId);
+ if (!this.updateById(update)) {
+ throw new DataException(recordDescription + "鍚屾浠櫒淇℃伅澶辫触锛岃鍒锋柊鍚庨噸璇�");
+ }
+ }
+
+ private List<String> normalizeIds(List<String> yiqiIds) {
+ Set<String> ids = new LinkedHashSet<>();
+ if (yiqiIds == null) {
+ return new ArrayList<>(ids);
+ }
+ for (String yiqiId : yiqiIds) {
+ String id = trimToEmpty(yiqiId);
+ if (!id.isEmpty()) {
+ ids.add(id);
+ }
+ }
+ return new ArrayList<>(ids);
+ }
+
+ private String trimToEmpty(String value) {
+ return value == null ? "" : value.trim();
+ }
+
+}
--
Gitblit v1.8.0