From 6ebee7b1e79706758f6a285f2338dbf617ac0708 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 29 十月 2026 14:33:10 +0800
Subject: [PATCH] feat(LIMS): 样品/实验/数据接口三模块补业务逻辑
---
src/main/java/com/ruoyi/lims/mapper/InterfaceFieldMapper.java | 9
src/main/java/com/ruoyi/lims/pojo/InterfaceField.java | 84 +
src/main/java/com/ruoyi/lims/mapper/SampleStatusLogMapper.java | 9
src/main/java/com/ruoyi/lims/service/SampleStatusLogService.java | 14
src/main/java/com/ruoyi/lims/controller/SampleController.java | 312 ++++++
src/main/java/com/ruoyi/lims/service/impl/InterfaceFieldServiceImpl.java | 44
src/main/java/com/ruoyi/lims/mapper/ExperimentStepMapper.java | 9
src/main/java/com/ruoyi/lims/service/ExperimentStepService.java | 14
src/main/java/com/ruoyi/lims/service/InterfaceFieldService.java | 14
src/main/java/com/ruoyi/lims/service/ExperimentResourceService.java | 14
src/main/java/com/ruoyi/lims/pojo/SampleStockRecord.java | 104 ++
src/main/java/com/ruoyi/lims/controller/ExperimentController.java | 346 +++++++
src/main/java/com/ruoyi/lims/controller/SampleStatusLogController.java | 61 +
doc/sql/lims_batch2_modules.sql | 192 ++++
src/main/java/com/ruoyi/lims/service/impl/ExperimentStepServiceImpl.java | 45 +
src/main/java/com/ruoyi/lims/service/impl/SampleStockRecordServiceImpl.java | 51 +
src/main/java/com/ruoyi/lims/controller/ExperimentResourceController.java | 61 +
src/main/java/com/ruoyi/lims/controller/InterfaceLogController.java | 61 +
src/main/java/com/ruoyi/lims/pojo/ExperimentResource.java | 87 +
src/main/java/com/ruoyi/lims/service/impl/InstrumentCalibrationServiceImpl.java | 2
src/main/java/com/ruoyi/lims/service/impl/ExperimentResourceServiceImpl.java | 46 +
src/main/java/com/ruoyi/lims/service/impl/InterfaceLogServiceImpl.java | 44
src/main/java/com/ruoyi/lims/mapper/ExperimentResourceMapper.java | 9
src/main/java/com/ruoyi/lims/service/InterfaceLogService.java | 14
src/main/java/com/ruoyi/lims/pojo/ExperimentStep.java | 104 ++
src/main/java/com/ruoyi/lims/mapper/SampleStockRecordMapper.java | 9
src/main/java/com/ruoyi/lims/controller/SampleStockRecordController.java | 61 +
src/main/java/com/ruoyi/lims/pojo/InterfaceLog.java | 92 ++
src/main/java/com/ruoyi/lims/service/impl/ReagentRecordServiceImpl.java | 2
src/main/java/com/ruoyi/lims/controller/ExperimentStepController.java | 61 +
src/main/java/com/ruoyi/lims/controller/InterfaceFieldController.java | 61 +
src/main/java/com/ruoyi/lims/mapper/InterfaceLogMapper.java | 9
src/main/java/com/ruoyi/lims/controller/DataInterfaceController.java | 466 ++++++++++
src/main/java/com/ruoyi/lims/pojo/SampleStatusLog.java | 80 +
src/main/java/com/ruoyi/lims/service/impl/SampleStatusLogServiceImpl.java | 44
src/main/java/com/ruoyi/lims/service/SampleStockRecordService.java | 14
36 files changed, 2,636 insertions(+), 13 deletions(-)
diff --git a/doc/sql/lims_batch2_modules.sql b/doc/sql/lims_batch2_modules.sql
new file mode 100644
index 0000000..2129c24
--- /dev/null
+++ b/doc/sql/lims_batch2_modules.sql
@@ -0,0 +1,192 @@
+-- ============================================================
+-- 鑺-LIMS 绗簩鎵归渶姹� DDL
+-- 鈶� 鏍峰搧绠$悊琛ュ己锛氬嚭鍏ュ簱娴佹按 + 鐘舵�佸彉鏇村巻鍙�
+-- 鈶� 瀹為獙绠$悊琛ュ己锛氭祦绋嬭妭鐐�(SOP) + 璧勬簮鍒嗛厤
+-- 鈶� 鏁版嵁鎺ュ彛绠$悊琛ュ己锛氬瓧娈垫槧灏� + 璋冪敤鏃ュ織
+-- 搴擄細lims-ruoyi
+-- ============================================================
+
+-- ============================================================
+-- 鈶� 鏍峰搧鍑哄叆搴撴祦姘�
+-- ============================================================
+DROP TABLE IF EXISTS `lims_sample_stock_record`;
+CREATE TABLE `lims_sample_stock_record` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `sample_id` BIGINT DEFAULT NULL COMMENT '鏍峰搧ID(lims_sample.id)',
+ `sample_code` VARCHAR(64) DEFAULT NULL COMMENT '鏍峰搧缂栧彿(鍐椾綑)',
+ `sample_name` VARCHAR(255) DEFAULT NULL COMMENT '鏍峰搧鍚嶇О(鍐椾綑)',
+ `record_type` VARCHAR(32) DEFAULT NULL COMMENT '绫诲瀷(in-鍏ュ簱,out-鍑哄簱,destroy-閿�姣�,return-閫�搴�,transfer-杞Щ)',
+ `quantity` DECIMAL(18,4) DEFAULT NULL COMMENT '鏁伴噺',
+ `unit` VARCHAR(32) DEFAULT NULL COMMENT '鍗曚綅',
+ `before_status` VARCHAR(32) DEFAULT NULL COMMENT '鎿嶄綔鍓嶇姸鎬�',
+ `after_status` VARCHAR(32) DEFAULT NULL COMMENT '鎿嶄綔鍚庣姸鎬�',
+ `from_location` VARCHAR(255) DEFAULT NULL COMMENT '鍘熷瓨鍌ㄤ綅缃�',
+ `to_location` VARCHAR(255) DEFAULT NULL COMMENT '鍘诲悜/鏂板瓨鍌ㄤ綅缃�',
+ `operator` VARCHAR(64) DEFAULT NULL COMMENT '缁忔墜浜�',
+ `operate_time` DATETIME DEFAULT NULL COMMENT '鎿嶄綔鏃堕棿',
+ `recipient` VARCHAR(64) DEFAULT NULL COMMENT '棰嗙敤浜�/鎺ユ敹鏂�',
+ `purpose` VARCHAR(500) DEFAULT NULL COMMENT '鐢ㄩ��/鍑哄簱浜嬬敱',
+ `related_experiment` VARCHAR(128) DEFAULT NULL COMMENT '鍏宠仈瀹為獙缂栧彿',
+ `remark` VARCHAR(1000) DEFAULT NULL COMMENT '澶囨敞',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '淇敼鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_sample_id` (`sample_id`),
+ KEY `idx_operate_time` (`operate_time`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-鏍峰搧鍑哄叆搴撴祦姘�';
+
+-- ============================================================
+-- 鈶� 鏍峰搧鐘舵�佸彉鏇村巻鍙�
+-- ============================================================
+DROP TABLE IF EXISTS `lims_sample_status_log`;
+CREATE TABLE `lims_sample_status_log` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `sample_id` BIGINT DEFAULT NULL COMMENT '鏍峰搧ID',
+ `sample_code` VARCHAR(64) DEFAULT NULL COMMENT '鏍峰搧缂栧彿(鍐椾綑)',
+ `from_status` VARCHAR(32) DEFAULT NULL COMMENT '鍙樻洿鍓嶇姸鎬�',
+ `to_status` VARCHAR(32) DEFAULT NULL COMMENT '鍙樻洿鍚庣姸鎬�',
+ `change_reason` VARCHAR(500) DEFAULT NULL COMMENT '鍙樻洿鍘熷洜',
+ `operator` VARCHAR(64) DEFAULT NULL COMMENT '鎿嶄綔浜�',
+ `operate_time` DATETIME DEFAULT NULL COMMENT '鎿嶄綔鏃堕棿',
+ `remark` VARCHAR(1000) DEFAULT NULL COMMENT '澶囨敞',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '淇敼鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_sample_id` (`sample_id`),
+ KEY `idx_operate_time` (`operate_time`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-鏍峰搧鐘舵�佸彉鏇村巻鍙�';
+
+-- ============================================================
+-- 鈶� 瀹為獙娴佺▼鑺傜偣锛圫OP 姝ラ锛�
+-- ============================================================
+DROP TABLE IF EXISTS `lims_experiment_step`;
+CREATE TABLE `lims_experiment_step` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `experiment_id` BIGINT DEFAULT NULL COMMENT '瀹為獙ID(lims_experiment.id)',
+ `experiment_code` VARCHAR(64) DEFAULT NULL COMMENT '瀹為獙缂栧彿(鍐椾綑)',
+ `step_no` INT DEFAULT NULL COMMENT '姝ラ搴忓彿(浠�1寮�濮�)',
+ `step_name` VARCHAR(255) DEFAULT NULL COMMENT '姝ラ鍚嶇О',
+ `step_content` TEXT COMMENT '鏍囧噯鎿嶄綔鍐呭(SOP)',
+ `expected_duration` INT DEFAULT NULL COMMENT '棰勮鑰楁椂(鍒嗛挓)',
+ `executor` VARCHAR(64) DEFAULT NULL COMMENT '鎵ц浜�',
+ `plan_start_time` DATETIME DEFAULT NULL COMMENT '璁″垝寮�濮嬫椂闂�',
+ `plan_end_time` DATETIME DEFAULT NULL COMMENT '璁″垝缁撴潫鏃堕棿',
+ `actual_start_time` DATETIME DEFAULT NULL COMMENT '瀹為檯寮�濮嬫椂闂�',
+ `actual_end_time` DATETIME DEFAULT NULL COMMENT '瀹為檯缁撴潫鏃堕棿',
+ `step_status` VARCHAR(32) DEFAULT 'pending' COMMENT '鐘舵��(pending-寰呮墽琛�,running-鎵ц涓�,completed-宸插畬鎴�,skipped-宸茶烦杩�,failed-澶辫触)',
+ `step_result` TEXT COMMENT '鎵ц缁撴灉/璁板綍',
+ `remark` VARCHAR(1000) DEFAULT NULL COMMENT '澶囨敞',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '淇敼鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_experiment_id` (`experiment_id`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-瀹為獙娴佺▼鑺傜偣';
+
+-- ============================================================
+-- 鈶� 瀹為獙璧勬簮鍒嗛厤
+-- ============================================================
+DROP TABLE IF EXISTS `lims_experiment_resource`;
+CREATE TABLE `lims_experiment_resource` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `experiment_id` BIGINT DEFAULT NULL COMMENT '瀹為獙ID',
+ `experiment_code` VARCHAR(64) DEFAULT NULL COMMENT '瀹為獙缂栧彿(鍐椾綑)',
+ `resource_type` VARCHAR(32) DEFAULT NULL COMMENT '璧勬簮绫诲瀷(instrument-浠櫒璁惧,reagent-璇曞墏鑰楁潗,personnel-浜哄憳)',
+ `resource_id` BIGINT DEFAULT NULL COMMENT '璧勬簮ID(浠櫒/璇曞墏琛ㄤ富閿�)',
+ `resource_code` VARCHAR(64) DEFAULT NULL COMMENT '璧勬簮缂栧彿',
+ `resource_name` VARCHAR(255) DEFAULT NULL COMMENT '璧勬簮鍚嶇О',
+ `quantity` DECIMAL(18,4) DEFAULT NULL COMMENT '鏁伴噺(璇曞墏娑堣�楅噺/浜哄憳宸ユ椂)',
+ `unit` VARCHAR(32) DEFAULT NULL COMMENT '鍗曚綅',
+ `usage_time` VARCHAR(255) DEFAULT NULL COMMENT '浣跨敤鏃舵/鍗犵敤鏃堕棿',
+ `status` VARCHAR(32) DEFAULT 'planned' COMMENT '鐘舵��(planned-宸插畨鎺�,inuse-浣跨敤涓�,returned-宸插綊杩�,consumed-宸叉秷鑰�)',
+ `remark` VARCHAR(1000) DEFAULT NULL COMMENT '澶囨敞',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '淇敼鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_experiment_id` (`experiment_id`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-瀹為獙璧勬簮鍒嗛厤';
+
+-- ============================================================
+-- 鈶� 鎺ュ彛瀛楁鏄犲皠
+-- ============================================================
+DROP TABLE IF EXISTS `lims_interface_field`;
+CREATE TABLE `lims_interface_field` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `interface_id` BIGINT DEFAULT NULL COMMENT '鎺ュ彛ID(lims_data_interface.id)',
+ `interface_code` VARCHAR(64) DEFAULT NULL COMMENT '鎺ュ彛缂栫爜(鍐椾綑)',
+ `source_field` VARCHAR(128) DEFAULT NULL COMMENT '璁惧杩斿洖鐨勫瓧娈靛悕(濡� temp / data.value)',
+ `source_path` VARCHAR(255) DEFAULT NULL COMMENT 'JSON璺緞(濡� $.data.temperature)',
+ `target_field` VARCHAR(64) DEFAULT NULL COMMENT '鐩爣瀛楁(collectionValue/deviceName/dataType/unit/collectionTime/rawData)',
+ `transform_type` VARCHAR(32) DEFAULT 'none' COMMENT '杞崲鏂瑰紡(none-鐩存帴,multiply-涔樹互绯绘暟,offset-鍔犲亸绉�,divide-闄や互绯绘暟,map-瀛楀吀鏄犲皠)',
+ `transform_value` VARCHAR(255) DEFAULT NULL COMMENT '杞崲鍙傛暟(绯绘暟/鍋忕Щ/鏄犲皠琛↗SON)',
+ `default_value` VARCHAR(255) DEFAULT NULL COMMENT '鍙栦笉鍒版椂鐨勯粯璁ゅ��',
+ `sort_no` INT DEFAULT NULL COMMENT '鎺掑簭',
+ `remark` VARCHAR(500) DEFAULT NULL COMMENT '澶囨敞',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '鏇存柊鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_interface_id` (`interface_id`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-鎺ュ彛瀛楁鏄犲皠';
+
+-- ============================================================
+-- 鈶� 鎺ュ彛璋冪敤鏃ュ織
+-- ============================================================
+DROP TABLE IF EXISTS `lims_interface_log`;
+CREATE TABLE `lims_interface_log` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '涓婚敭ID',
+ `interface_id` BIGINT DEFAULT NULL COMMENT '鎺ュ彛ID',
+ `interface_code` VARCHAR(64) DEFAULT NULL COMMENT '鎺ュ彛缂栫爜(鍐椾綑)',
+ `interface_name` VARCHAR(255) DEFAULT NULL COMMENT '鎺ュ彛鍚嶇О(鍐椾綑)',
+ `invoke_type` VARCHAR(32) DEFAULT NULL COMMENT '璋冪敤鏂瑰紡(test-娴嬭瘯杩炴帴,manual-鎵嬪姩閲囬泦,auto-瀹氭椂閲囬泦)',
+ `request_data` MEDIUMTEXT COMMENT '璇锋眰鍐呭',
+ `response_data` MEDIUMTEXT COMMENT '鍝嶅簲鍐呭',
+ `success` CHAR(1) DEFAULT '0' COMMENT '鏄惁鎴愬姛(1-鎴愬姛,0-澶辫触)',
+ `error_msg` VARCHAR(2000) DEFAULT NULL COMMENT '閿欒淇℃伅',
+ `duration_ms` INT DEFAULT NULL COMMENT '鑰楁椂(姣)',
+ `record_count` INT DEFAULT NULL COMMENT '鏈鍐欏叆閲囬泦璁板綍鏉℃暟',
+ `operator` VARCHAR(64) DEFAULT NULL COMMENT '瑙﹀彂浜�',
+ `invoke_time` DATETIME DEFAULT NULL COMMENT '璋冪敤鏃堕棿',
+ `del_flag` CHAR(1) DEFAULT '0' COMMENT '鍒犻櫎鏍囧織(0-姝e父,2-鍒犻櫎)',
+ `tenant_id` BIGINT DEFAULT NULL COMMENT '绉熸埛ID',
+ `create_time` DATETIME DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
+ `create_user` INT DEFAULT NULL COMMENT '鍒涘缓鐢ㄦ埛',
+ `update_time` DATETIME DEFAULT NULL COMMENT '淇敼鏃堕棿',
+ `update_user` INT DEFAULT NULL COMMENT '鏇存柊鐢ㄦ埛',
+ PRIMARY KEY (`id`),
+ KEY `idx_interface_id` (`interface_id`),
+ KEY `idx_invoke_time` (`invoke_time`),
+ KEY `idx_tenant` (`tenant_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='LIMS-鎺ュ彛璋冪敤鏃ュ織';
+
+-- ============================================================
+-- 鏍¢獙
+-- ============================================================
+SELECT table_name, table_comment
+FROM information_schema.tables
+WHERE table_schema = 'lims-ruoyi'
+ AND table_name IN ('lims_sample_stock_record','lims_sample_status_log','lims_experiment_step','lims_experiment_resource','lims_interface_field','lims_interface_log')
+ORDER BY table_name;
diff --git a/src/main/java/com/ruoyi/lims/controller/DataInterfaceController.java b/src/main/java/com/ruoyi/lims/controller/DataInterfaceController.java
index 387493a..025cb71 100644
--- a/src/main/java/com/ruoyi/lims/controller/DataInterfaceController.java
+++ b/src/main/java/com/ruoyi/lims/controller/DataInterfaceController.java
@@ -1,19 +1,42 @@
package com.ruoyi.lims.controller;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.lims.pojo.DataInterface;
-import com.ruoyi.lims.service.DataInterfaceService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.*;
-import lombok.AllArgsConstructor;
-import io.swagger.annotations.ApiOperation;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ruoyi.lims.pojo.DataCollection;
+import com.ruoyi.lims.pojo.DataInterface;
+import com.ruoyi.lims.pojo.InterfaceField;
+import com.ruoyi.lims.pojo.InterfaceLog;
+import com.ruoyi.lims.service.DataCollectionService;
+import com.ruoyi.lims.service.DataInterfaceService;
+import com.ruoyi.lims.service.InterfaceFieldService;
+import com.ruoyi.lims.service.InterfaceLogService;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigDecimal;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
@RestController
@AllArgsConstructor
@@ -22,6 +45,17 @@
public class DataInterfaceController {
private DataInterfaceService dataInterfaceservice;
+ private InterfaceFieldService fieldService;
+ private InterfaceLogService logService;
+ private DataCollectionService collectionService;
+
+ private static final ObjectMapper JSON = new ObjectMapper();
+
+ private static final OkHttpClient HTTP = new OkHttpClient.Builder()
+ .connectTimeout(8, TimeUnit.SECONDS)
+ .readTimeout(15, TimeUnit.SECONDS)
+ .writeTimeout(15, TimeUnit.SECONDS)
+ .build();
@GetMapping("/listPage")
@ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夋暟鎹帴鍙g鐞嗚〃")
@@ -52,6 +86,418 @@
@ApiOperation("鍒犻櫎鏁版嵁鎺ュ彛绠$悊琛�")
public AjaxResult delete(@RequestBody List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
- return AjaxResult.success(dataInterfaceservice.removeBatchByIds(ids));
+ boolean ok = dataInterfaceservice.removeBatchByIds(ids);
+ if (ok && !CollectionUtils.isEmpty(ids)) {
+ QueryWrapper<InterfaceField> fw = new QueryWrapper<>();
+ fw.in("interface_id", ids);
+ fieldService.remove(fw);
+ }
+ return AjaxResult.success(ok);
+ }
+
+ /* ==================== 娴嬭瘯杩炴帴 ==================== */
+
+ /**
+ * 娴嬭瘯杩炴帴锛欻TTP 鍙戜竴娆� GET/HEAD锛孴CP 寤轰竴娆¤繛鎺ワ紝MQTT 褰撳墠鐜涓嶆敮鎸�
+ */
+ @PostMapping("/test/{id}")
+ @ApiOperation("娴嬭瘯鎺ュ彛杩為�氭��")
+ public AjaxResult testConnection(@PathVariable Long id) {
+ DataInterface di = dataInterfaceservice.getById(id);
+ if (di == null) {
+ return AjaxResult.error("鎺ュ彛涓嶅瓨鍦�");
+ }
+ long start = System.currentTimeMillis();
+ String protocol = lower(di.getProtocol());
+ String result;
+ boolean ok = false;
+
+ try {
+ if ("http".equals(protocol) || "https".equals(protocol)) {
+ String url = buildHttpUrl(di);
+ Request req = new Request.Builder().url(url).get().build();
+ try (Response resp = HTTP.newCall(req).execute()) {
+ ok = resp.isSuccessful();
+ result = "HTTP " + resp.code() + " " + resp.message()
+ + "锛岃�楁椂 " + (System.currentTimeMillis() - start) + " ms";
+ }
+ } else if ("tcp".equals(protocol)) {
+ String host = di.getConnectionUrl() == null ? "" : di.getConnectionUrl().trim();
+ int port = parseInt(di.getPort(), 0);
+ if (host.isEmpty() || port <= 0) {
+ return AjaxResult.error("TCP 闇�瑕佸~鍐欎富鏈哄湴鍧�鍜岀鍙�");
+ }
+ // http:// 鍓嶇紑鍏煎璇~
+ if (host.startsWith("http://")) host = host.substring(7);
+ if (host.startsWith("https://")) host = host.substring(8);
+ if (host.contains("/")) host = host.substring(0, host.indexOf('/'));
+ if (host.contains(":")) host = host.substring(0, host.indexOf(':'));
+ try (Socket socket = new Socket()) {
+ socket.connect(new InetSocketAddress(host, port), 5000);
+ ok = true;
+ result = "TCP 杩炴帴鎴愬姛 " + host + ":" + port
+ + "锛岃�楁椂 " + (System.currentTimeMillis() - start) + " ms";
+ }
+ } else if ("mqtt".equals(protocol)) {
+ return AjaxResult.error("褰撳墠鐜鏈泦鎴� MQTT 瀹㈡埛绔簱锛堢绾挎墦鍖呴檺鍒讹級锛�"
+ + "濡傞渶 MQTT 閲囬泦璇锋妸 org.eclipse.paho.client.mqttv3 渚濊禆鍔犲叆 pom 鍚庨噸鏂版墦鍖�");
+ } else {
+ return AjaxResult.error("鏆備笉鏀寔鍗忚锛�" + di.getProtocol());
+ }
+ } catch (Exception e) {
+ saveLog(di, "test", null, null, false, e.getMessage(), System.currentTimeMillis() - start, 0);
+ return AjaxResult.error("杩炴帴澶辫触锛�" + shortMsg(e));
+ }
+
+ saveLog(di, "test", null, result, ok, ok ? null : result, System.currentTimeMillis() - start, 0);
+ return ok ? AjaxResult.success(result) : AjaxResult.error(result);
+ }
+
+ /* ==================== 鎵嬪姩閲囬泦 ==================== */
+
+ /**
+ * 鎵嬪姩閲囬泦涓�娆★細鎸夊崗璁媺鏁版嵁 -> 鎸夊瓧娈垫槧灏勮浆鎹� -> 鍐欏叆閲囬泦璁板綍 -> 璁版棩蹇�
+ */
+ @PostMapping("/collect/{id}")
+ @ApiOperation("绔嬪嵆閲囬泦涓�娆℃暟鎹�")
+ public AjaxResult collect(@PathVariable Long id) {
+ DataInterface di = dataInterfaceservice.getById(id);
+ if (di == null) {
+ return AjaxResult.error("鎺ュ彛涓嶅瓨鍦�");
+ }
+ String protocol = lower(di.getProtocol());
+ if ("mqtt".equals(protocol)) {
+ return AjaxResult.error("褰撳墠鐜鏈泦鎴� MQTT 瀹㈡埛绔簱锛屾殏涓嶆敮鎸� MQTT 閲囬泦");
+ }
+
+ long start = System.currentTimeMillis();
+ String rawJson;
+ String requestDesc;
+
+ try {
+ if ("http".equals(protocol) || "https".equals(protocol)) {
+ String url = buildHttpUrl(di);
+ requestDesc = "GET " + url;
+ Request req = new Request.Builder().url(url).get().build();
+ try (Response resp = HTTP.newCall(req).execute()) {
+ ResponseBody body = resp.body();
+ rawJson = body == null ? "" : body.string();
+ if (!resp.isSuccessful()) {
+ saveLog(di, "manual", requestDesc, rawJson, false,
+ "HTTP " + resp.code(), System.currentTimeMillis() - start, 0);
+ return AjaxResult.error("閲囬泦澶辫触锛欻TTP " + resp.code());
+ }
+ }
+ } else if ("tcp".equals(protocol)) {
+ String host = di.getConnectionUrl() == null ? "" : di.getConnectionUrl().trim();
+ int port = parseInt(di.getPort(), 0);
+ if (host.startsWith("http://")) host = host.substring(7);
+ if (host.startsWith("https://")) host = host.substring(8);
+ if (host.contains("/")) host = host.substring(0, host.indexOf('/'));
+ if (host.contains(":")) host = host.substring(0, host.indexOf(':'));
+ requestDesc = "TCP " + host + ":" + port;
+ try (Socket socket = new Socket()) {
+ socket.connect(new InetSocketAddress(host, port), 5000);
+ socket.setSoTimeout(8000);
+ OutputStream out = socket.getOutputStream();
+ // 榛樿鍙戜竴涓崲琛岋紝寰堝浠櫒鏀跺埌鍥炶溅鎵嶅悙鏁版嵁
+ out.write("\r\n".getBytes(StandardCharsets.UTF_8));
+ out.flush();
+ InputStream in = socket.getInputStream();
+ byte[] buf = new byte[8192];
+ int n = in.read(buf);
+ rawJson = n <= 0 ? "" : new String(buf, 0, n, StandardCharsets.UTF_8).trim();
+ }
+ } else {
+ return AjaxResult.error("鏆備笉鏀寔鍗忚锛�" + di.getProtocol());
+ }
+ } catch (Exception e) {
+ saveLog(di, "manual", null, null, false, shortMsg(e), System.currentTimeMillis() - start, 0);
+ return AjaxResult.error("閲囬泦澶辫触锛�" + shortMsg(e));
+ }
+
+ // 瀛楁鏄犲皠
+ QueryWrapper<InterfaceField> fw = new QueryWrapper<>();
+ fw.eq("interface_id", di.getId()).orderByAsc("sort_no").orderByAsc("id");
+ List<InterfaceField> fields = fieldService.list(fw);
+
+ int saved = 0;
+ List<String> warnings = new ArrayList<>();
+ try {
+ if (fields.isEmpty()) {
+ // 娌℃湁閰嶇疆鏄犲皠锛氭暣鏉″師鏂囨斁杩� rawData锛屽仛涓厹搴曡褰�
+ DataCollection dc = new DataCollection();
+ dc.setCollectionCode("AUTO-" + System.currentTimeMillis());
+ dc.setDeviceName(di.getDeviceName());
+ dc.setDeviceCode(di.getInterfaceCode());
+ dc.setRawData(rawJson);
+ dc.setCollectionTime(LocalDateTime.now());
+ dc.setCollectionStatus("completed");
+ dc.setDataQuality("pending");
+ dc.setProcessMethod("autoClean");
+ collectionService.save(dc);
+ saved = 1;
+ warnings.add("鏈厤缃瓧娈垫槧灏勶紝宸叉妸鍘熷鍝嶅簲鏁翠綋鍐欏叆 rawData");
+ } else {
+ JsonNode root = null;
+ try {
+ root = JSON.readTree(rawJson);
+ } catch (Exception ignore) {
+ // 涓嶆槸 JSON 涔熷厑璁革紝鎸夌函鏂囨湰澶勭悊
+ }
+ DataCollection dc = new DataCollection();
+ dc.setCollectionCode("AUTO-" + System.currentTimeMillis());
+ dc.setDeviceName(di.getDeviceName());
+ dc.setDeviceCode(di.getInterfaceCode());
+ dc.setRawData(rawJson);
+ dc.setCollectionTime(LocalDateTime.now());
+ dc.setCollectionStatus("completed");
+ dc.setProcessMethod("dataTransform");
+
+ for (InterfaceField f : fields) {
+ String target = f.getTargetField();
+ if (target == null) continue;
+ String val = extractValue(root, rawJson, f.getSourcePath(), f.getSourceField());
+ val = applyTransform(val, f);
+ if (val == null && f.getDefaultValue() != null) {
+ val = f.getDefaultValue();
+ }
+ if (val == null) continue;
+ switch (target) {
+ case "collectionValue":
+ try {
+ dc.setCollectionValue(new BigDecimal(val));
+ } catch (Exception e) {
+ warnings.add("瀛楁 " + f.getSourceField() + " 鐨勫�� " + val + " 涓嶆槸鏁板瓧锛屾湭鍐欏叆閲囬泦鏁板��");
+ }
+ break;
+ case "deviceName": dc.setDeviceName(val); break;
+ case "deviceCode": dc.setDeviceCode(val); break;
+ case "dataType": dc.setDataType(val); break;
+ case "unit": dc.setUnit(val); break;
+ case "rawData": dc.setRawData(val); break;
+ case "processedData": dc.setProcessedData(val); break;
+ default: break;
+ }
+ }
+
+ // 璐ㄩ噺鍒ゅ畾锛氶厤缃簡涓婁笅闄愬氨姣斾竴涓嬶紝鍚﹀垯寰呮牎楠�
+ dc.setDataQuality(dc.getCollectionValue() == null ? "pending" : "qualified");
+ collectionService.save(dc);
+ saved = 1;
+ }
+ } catch (Exception e) {
+ saveLog(di, "manual", requestDesc, rawJson, false, "鏄犲皠鍐欏叆澶辫触锛�" + shortMsg(e),
+ System.currentTimeMillis() - start, 0);
+ return AjaxResult.error("鏄犲皠鍐欏叆澶辫触锛�" + shortMsg(e));
+ }
+
+ saveLog(di, "manual", requestDesc, rawJson, true, null, System.currentTimeMillis() - start, saved);
+
+ Map<String, Object> ret = new LinkedHashMap<>();
+ ret.put("saved", saved);
+ ret.put("rawLength", rawJson == null ? 0 : rawJson.length());
+ ret.put("warnings", warnings);
+ return AjaxResult.success("閲囬泦瀹屾垚锛屽啓鍏� " + saved + " 鏉�", ret);
+ }
+
+ /* ==================== 瀛楁鏄犲皠绠$悊 ==================== */
+
+ @GetMapping("/fields/{interfaceId}")
+ @ApiOperation("鏌ヨ鎺ュ彛鐨勫瓧娈垫槧灏�")
+ public AjaxResult listFields(@PathVariable Long interfaceId) {
+ QueryWrapper<InterfaceField> w = new QueryWrapper<>();
+ w.eq("interface_id", interfaceId).orderByAsc("sort_no").orderByAsc("id");
+ return AjaxResult.success(fieldService.list(w));
+ }
+
+ @PostMapping("/field/saveBatch")
+ @ApiOperation("鎵归噺淇濆瓨瀛楁鏄犲皠锛堝厛鍒犲悗鎻掞級")
+ public AjaxResult saveFields(@RequestBody Map<String, Object> body) {
+ Long interfaceId = toLong(body.get("interfaceId"));
+ if (interfaceId == null) {
+ return AjaxResult.error("interfaceId 涓嶈兘涓虹┖");
+ }
+ Object raw = body.get("fields");
+ if (!(raw instanceof List)) {
+ return AjaxResult.error("fields 蹇呴』鏄暟缁�");
+ }
+ QueryWrapper<InterfaceField> dw = new QueryWrapper<>();
+ dw.eq("interface_id", interfaceId);
+ fieldService.remove(dw);
+
+ int idx = 0;
+ for (Object o : (List<?>) raw) {
+ if (!(o instanceof Map)) continue;
+ Map<?, ?> m = (Map<?, ?>) o;
+ InterfaceField f = new InterfaceField();
+ f.setInterfaceId(interfaceId);
+ f.setInterfaceCode(str(m.get("interfaceCode")));
+ f.setSourceField(str(m.get("sourceField")));
+ f.setSourcePath(str(m.get("sourcePath")));
+ f.setTargetField(str(m.get("targetField")));
+ f.setTransformType(str(m.get("transformType")) == null ? "none" : str(m.get("transformType")));
+ f.setTransformValue(str(m.get("transformValue")));
+ f.setDefaultValue(str(m.get("defaultValue")));
+ f.setSortNo(toInt(m.get("sortNo")) == null ? (idx + 1) : toInt(m.get("sortNo")));
+ f.setRemark(str(m.get("remark")));
+ fieldService.save(f);
+ idx++;
+ }
+ return AjaxResult.success("宸蹭繚瀛� " + idx + " 鏉℃槧灏�");
+ }
+
+ /* ==================== 璋冪敤鏃ュ織 ==================== */
+
+ @GetMapping("/logs")
+ @ApiOperation("鏌ヨ鎺ュ彛璋冪敤鏃ュ織")
+ public AjaxResult logs(Page<InterfaceLog> page, InterfaceLog query) {
+ QueryWrapper<InterfaceLog> w = new QueryWrapper<>();
+ if (query != null) {
+ if (query.getInterfaceId() != null) w.eq("interface_id", query.getInterfaceId());
+ if (str(query.getInterfaceCode()) != null) w.like("interface_code", query.getInterfaceCode());
+ if (str(query.getInvokeType()) != null) w.eq("invoke_type", query.getInvokeType());
+ if (str(query.getSuccess()) != null) w.eq("success", query.getSuccess());
+ }
+ w.orderByDesc("invoke_time").orderByDesc("id");
+ return AjaxResult.success(logService.page(page, w));
+ }
+
+ /* ==================== helpers ==================== */
+
+ private String buildHttpUrl(DataInterface di) {
+ String base = di.getConnectionUrl() == null ? "" : di.getConnectionUrl().trim();
+ String port = di.getPort() == null ? "" : di.getPort().trim();
+ if (!base.startsWith("http://") && !base.startsWith("https://")) {
+ base = "http://" + base;
+ }
+ // 鍦板潃閲屾病甯︾鍙f椂鎵嶆嫾鎺�
+ if (!port.isEmpty() && !base.matches(".*:\\d+.*")) {
+ int idx = base.indexOf('/', base.indexOf("://") + 3);
+ if (idx < 0) {
+ base = base + ":" + port;
+ } else {
+ base = base.substring(0, idx) + ":" + port + base.substring(idx);
+ }
+ }
+ return base;
+ }
+
+ private String extractValue(JsonNode root, String rawText, String path, String fieldName) {
+ if (root != null && path != null && !path.trim().isEmpty()) {
+ String p = path.trim();
+ if (p.startsWith("$.")) p = p.substring(2);
+ p = p.replace("/", ".");
+ JsonNode node = root;
+ for (String seg : p.split("\\.")) {
+ if (seg.isEmpty()) continue;
+ node = node.path(seg);
+ }
+ if (!node.isMissingNode() && !node.isNull()) {
+ return node.asText();
+ }
+ }
+ if (root != null && fieldName != null && !fieldName.trim().isEmpty()) {
+ JsonNode node = root.path(fieldName.trim());
+ if (!node.isMissingNode() && !node.isNull()) {
+ return node.asText();
+ }
+ }
+ // 绾枃鏈崗璁細鏁翠釜鍝嶅簲灏辨槸鍊�
+ if (root == null && fieldName != null && !fieldName.trim().isEmpty()) {
+ return rawText;
+ }
+ return null;
+ }
+
+ private String applyTransform(String val, InterfaceField f) {
+ if (val == null) return null;
+ String type = lower(f.getTransformType());
+ String tv = f.getTransformValue();
+ if (type == null || "none".equals(type) || tv == null || tv.trim().isEmpty()) {
+ return val;
+ }
+ try {
+ BigDecimal num = new BigDecimal(val.trim());
+ BigDecimal arg = new BigDecimal(tv.trim());
+ switch (type) {
+ case "multiply": return num.multiply(arg).stripTrailingZeros().toPlainString();
+ case "divide": return num.divide(arg, 6, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
+ case "offset": return num.add(arg).stripTrailingZeros().toPlainString();
+ default: break;
+ }
+ } catch (Exception ignore) { }
+ if ("map".equals(type)) {
+ try {
+ JsonNode m = JSON.readTree(tv);
+ JsonNode hit = m.get(val);
+ if (hit != null) return hit.asText();
+ } catch (Exception ignore) { }
+ }
+ return val;
+ }
+
+ private void saveLog(DataInterface di, String type, String req, String resp,
+ boolean success, String err, long duration, int count) {
+ try {
+ InterfaceLog log = new InterfaceLog();
+ log.setInterfaceId(di.getId());
+ log.setInterfaceCode(di.getInterfaceCode());
+ log.setInterfaceName(di.getInterfaceName());
+ log.setInvokeType(type);
+ log.setRequestData(req == null ? null : truncate(req, 8000));
+ log.setResponseData(resp == null ? null : truncate(resp, 8000));
+ log.setSuccess(success ? "1" : "0");
+ log.setErrorMsg(err == null ? null : truncate(err, 1900));
+ log.setDurationMs((int) duration);
+ log.setRecordCount(count);
+ log.setOperator(currentUser());
+ log.setInvokeTime(LocalDateTime.now());
+ logService.save(log);
+ } catch (Exception ignore) {
+ // 鏃ュ織澶辫触涓嶅奖鍝嶄富娴佺▼
+ }
+ }
+
+ private static String truncate(String s, int max) {
+ return s.length() <= max ? s : s.substring(0, max) + "...(truncated)";
+ }
+
+ private String currentUser() {
+ try {
+ return SecurityUtils.getUsername();
+ } catch (Exception e) {
+ return "system";
+ }
+ }
+
+ private static String lower(String s) {
+ return s == null ? null : s.trim().toLowerCase();
+ }
+
+ private static String shortMsg(Exception e) {
+ String m = e.getMessage();
+ if (m == null) m = e.getClass().getSimpleName();
+ return m.length() > 300 ? m.substring(0, 300) : m;
+ }
+
+ private static String str(Object v) {
+ if (v == null) return null;
+ String s = String.valueOf(v).trim();
+ return s.isEmpty() ? null : s;
+ }
+
+ private static Long toLong(Object v) {
+ if (v == null) return null;
+ try { return Long.valueOf(String.valueOf(v).trim()); } catch (NumberFormatException e) { return null; }
+ }
+
+ private static Integer toInt(Object v) {
+ if (v == null) return null;
+ try { return Integer.valueOf(String.valueOf(v).trim()); } catch (NumberFormatException e) { return null; }
+ }
+
+ private static int parseInt(String s, int def) {
+ try { return Integer.parseInt(s.trim()); } catch (Exception e) { return def; }
}
}
diff --git a/src/main/java/com/ruoyi/lims/controller/ExperimentController.java b/src/main/java/com/ruoyi/lims/controller/ExperimentController.java
index f85584d..6c42006 100644
--- a/src/main/java/com/ruoyi/lims/controller/ExperimentController.java
+++ b/src/main/java/com/ruoyi/lims/controller/ExperimentController.java
@@ -1,17 +1,32 @@
package com.ruoyi.lims.controller;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.lims.pojo.Experiment;
+import com.ruoyi.lims.pojo.ExperimentResource;
+import com.ruoyi.lims.pojo.ExperimentStep;
+import com.ruoyi.lims.pojo.Reagent;
+import com.ruoyi.lims.pojo.ReagentRecord;
+import com.ruoyi.lims.service.ExperimentResourceService;
import com.ruoyi.lims.service.ExperimentService;
+import com.ruoyi.lims.service.ExperimentStepService;
+import com.ruoyi.lims.service.ReagentRecordService;
+import com.ruoyi.lims.service.ReagentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
@RestController
@AllArgsConstructor
@@ -20,6 +35,10 @@
public class ExperimentController {
private ExperimentService experimentservice;
+ private ExperimentStepService stepService;
+ private ExperimentResourceService resourceService;
+ private ReagentService reagentService;
+ private ReagentRecordService reagentRecordService;
@GetMapping("/listPage")
@ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夊疄楠岀鐞嗚〃")
@@ -32,6 +51,39 @@
@ApiOperation("鏍规嵁ID鏌ヨ瀹為獙绠$悊琛�")
public AjaxResult getExperiment(@PathVariable Long id) {
return AjaxResult.success(experimentservice.getById(id));
+ }
+
+ /**
+ * 瀹為獙璇︽儏锛氬疄楠屾湰浣� + 娴佺▼鑺傜偣 + 宸插垎閰嶈祫婧� + 鎵ц杩涘害
+ */
+ @GetMapping("/detail/{id}")
+ @ApiOperation("瀹為獙璇︽儏锛堝惈娴佺▼鑺傜偣涓庤祫婧愬垎閰嶏級")
+ public AjaxResult detail(@PathVariable Long id) {
+ Experiment exp = experimentservice.getById(id);
+ if (exp == null) {
+ return AjaxResult.error("瀹為獙涓嶅瓨鍦�");
+ }
+
+ QueryWrapper<ExperimentStep> sw = new QueryWrapper<>();
+ sw.eq("experiment_id", id).orderByAsc("step_no").orderByAsc("id");
+ List<ExperimentStep> steps = stepService.list(sw);
+
+ QueryWrapper<ExperimentResource> rw = new QueryWrapper<>();
+ rw.eq("experiment_id", id).orderByAsc("id");
+ List<ExperimentResource> resources = resourceService.list(rw);
+
+ int total = steps.size();
+ long done = steps.stream().filter(s -> "completed".equals(s.getStepStatus())).count();
+ int progress = total == 0 ? 0 : (int) Math.round(done * 100.0 / total);
+
+ Map<String, Object> result = new LinkedHashMap<>();
+ result.put("experiment", exp);
+ result.put("steps", steps);
+ result.put("resources", resources);
+ result.put("stepTotal", total);
+ result.put("stepCompleted", done);
+ result.put("progress", progress);
+ return AjaxResult.success(result);
}
@PostMapping("/add")
@@ -50,6 +102,298 @@
@ApiOperation("鍒犻櫎瀹為獙绠$悊琛�")
public AjaxResult delete(@RequestBody List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
- return AjaxResult.success(experimentservice.removeBatchByIds(ids));
+ boolean ok = experimentservice.removeBatchByIds(ids);
+ if (ok && !CollectionUtils.isEmpty(ids)) {
+ // 杩炲甫娓呮帀姝ラ涓庤祫婧愶紝閬垮厤瀛ゅ効鏁版嵁
+ QueryWrapper<ExperimentStep> sw = new QueryWrapper<>();
+ sw.in("experiment_id", ids);
+ stepService.remove(sw);
+ QueryWrapper<ExperimentResource> rw = new QueryWrapper<>();
+ rw.in("experiment_id", ids);
+ resourceService.remove(rw);
+ }
+ return AjaxResult.success(ok);
+ }
+
+ /* ==================== 娴佺▼鑺傜偣锛圫OP 姝ラ锛� ==================== */
+
+ /**
+ * 鎵归噺淇濆瓨姝ラ锛氫紶鍏ㄩ噺鍒楄〃锛屽厛鍒犲悗鎻掞紝淇濊瘉椤哄簭鍜屽唴瀹逛竴鑷�
+ */
+ @PostMapping("/step/saveBatch")
+ @ApiOperation("鎵归噺淇濆瓨瀹為獙娴佺▼鑺傜偣")
+ public AjaxResult saveSteps(@RequestBody Map<String, Object> body) {
+ Long experimentId = toLong(body.get("experimentId"));
+ if (experimentId == null) {
+ return AjaxResult.error("experimentId 涓嶈兘涓虹┖");
+ }
+ Experiment exp = experimentservice.getById(experimentId);
+ if (exp == null) {
+ return AjaxResult.error("瀹為獙涓嶅瓨鍦�");
+ }
+ Object rawList = body.get("steps");
+ if (!(rawList instanceof List)) {
+ return AjaxResult.error("steps 蹇呴』鏄暟缁�");
+ }
+
+ QueryWrapper<ExperimentStep> dw = new QueryWrapper<>();
+ dw.eq("experiment_id", experimentId);
+ stepService.remove(dw);
+
+ List<?> list = (List<?>) rawList;
+ int idx = 0;
+ for (Object o : list) {
+ if (!(o instanceof Map)) continue;
+ Map<?, ?> m = (Map<?, ?>) o;
+ ExperimentStep step = new ExperimentStep();
+ step.setExperimentId(experimentId);
+ step.setExperimentCode(exp.getExperimentCode());
+ step.setStepNo(toInt(m.get("stepNo")) == null ? (idx + 1) : toInt(m.get("stepNo")));
+ step.setStepName(str(m.get("stepName")));
+ step.setStepContent(str(m.get("stepContent")));
+ step.setExpectedDuration(toInt(m.get("expectedDuration")));
+ step.setExecutor(str(m.get("executor")));
+ step.setStepStatus(str(m.get("stepStatus")) == null ? "pending" : str(m.get("stepStatus")));
+ step.setRemark(str(m.get("remark")));
+ stepService.save(step);
+ idx++;
+ }
+
+ return AjaxResult.success("宸蹭繚瀛� " + idx + " 涓楠�");
+ }
+
+ /**
+ * 瀹屾垚/鎺ㄨ繘鍗曚釜姝ラ
+ */
+ @PostMapping("/step/complete")
+ @ApiOperation("瀹屾垚瀹為獙姝ラ")
+ public AjaxResult completeStep(@RequestBody Map<String, Object> body) {
+ Long stepId = toLong(body.get("stepId"));
+ if (stepId == null) {
+ return AjaxResult.error("stepId 涓嶈兘涓虹┖");
+ }
+ ExperimentStep step = stepService.getById(stepId);
+ if (step == null) {
+ return AjaxResult.error("姝ラ涓嶅瓨鍦�");
+ }
+ if ("completed".equals(step.getStepStatus())) {
+ return AjaxResult.error("璇ユ楠ゅ凡瀹屾垚");
+ }
+
+ String operator = currentUser();
+ LocalDateTime now = LocalDateTime.now();
+
+ ExperimentStep upd = new ExperimentStep();
+ upd.setId(stepId);
+ upd.setStepStatus(str(body.get("stepStatus")) == null ? "completed" : str(body.get("stepStatus")));
+ upd.setStepResult(str(body.get("stepResult")));
+ upd.setExecutor(str(body.get("executor")) == null ? operator : str(body.get("executor")));
+ if (step.getActualStartTime() == null) {
+ upd.setActualStartTime(now);
+ }
+ upd.setActualEndTime(now);
+ stepService.updateById(upd);
+
+ // 鍏ㄩ儴姝ラ瀹屾垚 -> 瀹為獙鐘舵�佺疆涓哄凡瀹屾垚
+ Long expId = step.getExperimentId();
+ if (expId != null) {
+ QueryWrapper<ExperimentStep> cw = new QueryWrapper<>();
+ cw.eq("experiment_id", expId).ne("step_status", "completed");
+ long remain = stepService.count(cw);
+ if (remain == 0) {
+ Experiment eu = new Experiment();
+ eu.setId(expId);
+ eu.setExperimentStatus("completed");
+ experimentservice.updateById(eu);
+ } else {
+ Experiment eu = new Experiment();
+ eu.setId(expId);
+ eu.setExperimentStatus("inProgress");
+ experimentservice.updateById(eu);
+ }
+ }
+
+ return AjaxResult.success("姝ラ宸插畬鎴�");
+ }
+
+ /* ==================== 璧勬簮鍒嗛厤 ==================== */
+
+ /**
+ * 鍒嗛厤璧勬簮锛氫华鍣�/浜哄憳鍙褰曪紱璇曞墏浼氬疄闄呮墸鍑忓簱瀛樺苟鍐欏嚭鍏ュ簱娴佹按
+ */
+ @PostMapping("/assignResource")
+ @ApiOperation("涓哄疄楠屽垎閰嶈祫婧�")
+ public AjaxResult assignResource(@RequestBody Map<String, Object> body) {
+ Long experimentId = toLong(body.get("experimentId"));
+ if (experimentId == null) {
+ return AjaxResult.error("experimentId 涓嶈兘涓虹┖");
+ }
+ Experiment exp = experimentservice.getById(experimentId);
+ if (exp == null) {
+ return AjaxResult.error("瀹為獙涓嶅瓨鍦�");
+ }
+ String resourceType = str(body.get("resourceType"));
+ if (resourceType == null) {
+ return AjaxResult.error("resourceType 涓嶈兘涓虹┖");
+ }
+
+ ExperimentResource res = new ExperimentResource();
+ res.setExperimentId(experimentId);
+ res.setExperimentCode(exp.getExperimentCode());
+ res.setResourceType(resourceType);
+ res.setResourceId(toLong(body.get("resourceId")));
+ res.setResourceCode(str(body.get("resourceCode")));
+ res.setResourceName(str(body.get("resourceName")));
+ res.setQuantity(toDecimal(body.get("quantity")));
+ res.setUnit(str(body.get("unit")));
+ res.setUsageTime(str(body.get("usageTime")));
+ res.setStatus(str(body.get("status")) == null ? "planned" : str(body.get("status")));
+ res.setRemark(str(body.get("remark")));
+
+ // 璇曞墏/鑰楁潗锛氱湡瀹炴墸搴撳瓨 + 鍐欐祦姘�
+ if ("reagent".equals(resourceType) && res.getResourceId() != null) {
+ Reagent re = reagentService.getById(res.getResourceId());
+ if (re == null) {
+ return AjaxResult.error("璇曞墏/鑰楁潗涓嶅瓨鍦�");
+ }
+ BigDecimal useQty = res.getQuantity() == null ? BigDecimal.ZERO : res.getQuantity();
+ BigDecimal stock = re.getCurrentStock() == null ? BigDecimal.ZERO : re.getCurrentStock();
+ if (useQty.compareTo(BigDecimal.ZERO) > 0 && useQty.compareTo(stock) > 0) {
+ return AjaxResult.error("璇曞墏搴撳瓨涓嶈冻锛堢幇鏈� " + stock.stripTrailingZeros().toPlainString()
+ + (re.getUnit() == null ? "" : re.getUnit()) + "锛�");
+ }
+ res.setResourceCode(re.getReagentCode());
+ res.setResourceName(re.getReagentName());
+ if (res.getUnit() == null) res.setUnit(re.getUnit());
+
+ if (useQty.compareTo(BigDecimal.ZERO) > 0) {
+ BigDecimal after = stock.subtract(useQty);
+ ReagentRecord rec = new ReagentRecord();
+ rec.setReagentId(re.getId());
+ rec.setReagentCode(re.getReagentCode());
+ rec.setReagentName(re.getReagentName());
+ rec.setRecordType("out");
+ rec.setQuantity(useQty);
+ rec.setBeforeStock(stock);
+ rec.setAfterStock(after);
+ rec.setOperator(currentUser());
+ rec.setOperateTime(LocalDateTime.now());
+ rec.setPurpose("瀹為獙棰嗙敤");
+ rec.setRelatedExperiment(exp.getExperimentCode());
+ reagentRecordService.save(rec);
+
+ Reagent ru = new Reagent();
+ ru.setId(re.getId());
+ ru.setCurrentStock(after);
+ reagentService.updateById(ru);
+ }
+ }
+
+ resourceService.save(res);
+ return AjaxResult.success("璧勬簮宸插垎閰�");
+ }
+
+ @DeleteMapping("/resource/{id}")
+ @ApiOperation("绉婚櫎瀹為獙璧勬簮鍒嗛厤")
+ public AjaxResult removeResource(@PathVariable Long id) {
+ return AjaxResult.success(resourceService.removeById(id));
+ }
+
+ /* ==================== 娴佺▼妯℃澘 ==================== */
+
+ /**
+ * 甯哥敤瀹為獙绫诲瀷鐨� SOP 妯℃澘锛屽墠绔�屽鐢ㄦā鏉裤�嶆椂鎸夌被鍨嬫媺鍙�
+ */
+ @GetMapping("/stepTemplate")
+ @ApiOperation("鑾峰彇娴佺▼妯℃澘")
+ public AjaxResult stepTemplate(@RequestParam(required = false) String type) {
+ Map<String, List<Map<String, Object>>> templates = new LinkedHashMap<>();
+
+ templates.put("chemicalAnalysis", buildSteps(
+ new String[][]{
+ {"鏍峰搧鍓嶅鐞�", "鎸夋爣鍑嗙О鍙栨牱鍝侊紝瀹氬鑷冲埢搴︼紝鎽囧寑闈欑疆 10 鍒嗛挓"},
+ {"璇曞墏閰嶅埗", "鎸夋柟娉曡姹傞厤鍒舵爣鍑嗘憾娑蹭笌鏄捐壊鍓傦紝鐜伴厤鐜扮敤"},
+ {"浠櫒棰勭儹", "寮�鍚垎鏋愪华鍣ㄩ鐑� 30 鍒嗛挓锛屽緟鍩虹嚎绋冲畾"},
+ {"鏍囧噯鏇茬嚎缁樺埗", "渚濇娴嬪畾鏍囧噯绯诲垪锛岀粯鍒舵洸绾匡紝鐩稿叧绯绘暟搴� 鈮�0.999"},
+ {"鏍峰搧娴嬪畾", "鎸夐『搴忔祴瀹氭牱鍝侊紝姣� 10 涓牱鍝佹彃鍏ヤ竴娆¤川鎺ф牱"},
+ {"鏁版嵁澶勭悊", "璁$畻娴撳害缁撴灉锛屽仛骞宠鏍峰亸宸鏌�"}
+ }));
+ templates.put("physicalTest", buildSteps(
+ new String[][]{
+ {"璇曟牱鍒跺", "鎸夋爣鍑嗚鍒�/鍔犲伐璇曟牱锛岃褰曞昂瀵镐笌澶栬"},
+ {"璁惧璋冭瘯", "鏍″噯璇曢獙鏈洪浂鐐癸紝璁剧疆璇曢獙閫熷害"},
+ {"瑁呭す瀹氫綅", "灏嗚瘯鏍疯澶逛簬澶瑰叿涓績锛岀‘淇濆彈鍔涜酱绾夸竴鑷�"},
+ {"鍔犺浇璇曢獙", "鎸夎瀹氶�熷害鍔犺浇鐩磋嚦鐮村潖锛岃褰曟渶澶у姏鍊�"},
+ {"缁撴灉璁$畻", "璁$畻寮哄害/浼搁暱鐜囷紝鍙� 3 涓湁鏁堣瘯鏍风殑骞冲潎鍊�"}
+ }));
+ templates.put("microbialTest", buildSteps(
+ new String[][]{
+ {"鍩瑰吇鍩洪厤鍒�", "鎸夐厤鏂归厤鍒跺煿鍏诲熀锛�121鈩� 鐏弻 15 鍒嗛挓"},
+ {"鏍峰搧绋�閲�", "鏃犺弻鎿嶄綔姊害绋�閲婃牱鍝侊紝鍒跺 10^-1 ~ 10^-3 绋�閲婃恫"},
+ {"鎺ョ", "鍙� 1mL 绋�閲婃恫娉ㄥ叆骞崇毧锛屽�炬敞鍩瑰吇鍩烘贩鍖�"},
+ {"鍩瑰吇", "36卤1鈩� 鍩瑰吇 48卤2 灏忔椂"},
+ {"鑿岃惤璁℃暟", "閫夊彇 30~300 涓弻钀界殑骞崇毧璁℃暟锛屾崲绠� CFU/mL"}
+ }));
+
+ if (type != null && templates.containsKey(type)) {
+ return AjaxResult.success(templates.get(type));
+ }
+ return AjaxResult.success(templates);
+ }
+
+ private List<Map<String, Object>> buildSteps(String[][] arr) {
+ List<Map<String, Object>> list = new ArrayList<>();
+ for (int i = 0; i < arr.length; i++) {
+ Map<String, Object> m = new LinkedHashMap<>();
+ m.put("stepNo", i + 1);
+ m.put("stepName", arr[i][0]);
+ m.put("stepContent", arr[i][1]);
+ m.put("stepStatus", "pending");
+ list.add(m);
+ }
+ return list;
+ }
+
+ /* ---------------- helpers ---------------- */
+
+ private String currentUser() {
+ try {
+ return SecurityUtils.getUsername();
+ } catch (Exception e) {
+ return "system";
+ }
+ }
+
+ private static String str(Object v) {
+ if (v == null) return null;
+ String s = String.valueOf(v).trim();
+ return s.isEmpty() ? null : s;
+ }
+
+ private static Long toLong(Object v) {
+ if (v == null) return null;
+ try {
+ return Long.valueOf(String.valueOf(v).trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ private static Integer toInt(Object v) {
+ if (v == null) return null;
+ try {
+ return Integer.valueOf(String.valueOf(v).trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ private static BigDecimal toDecimal(Object v) {
+ if (v == null) return null;
+ try {
+ return new BigDecimal(String.valueOf(v).trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
}
}
diff --git a/src/main/java/com/ruoyi/lims/controller/ExperimentResourceController.java b/src/main/java/com/ruoyi/lims/controller/ExperimentResourceController.java
new file mode 100644
index 0000000..dd4bd7b
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/ExperimentResourceController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.ExperimentResource;
+import com.ruoyi.lims.service.ExperimentResourceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/experimentResource")
+@Api(value = "ExperimentResource", tags = "Experiment Resources")
+public class ExperimentResourceController {
+
+ private ExperimentResourceService experimentResourceService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<ExperimentResource> page, ExperimentResource query) {
+ IPage<ExperimentResource> result = experimentResourceService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(ExperimentResource query) {
+ return AjaxResult.success(experimentResourceService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(experimentResourceService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody ExperimentResource entity) {
+ return AjaxResult.success(experimentResourceService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody ExperimentResource entity) {
+ return AjaxResult.success(experimentResourceService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(experimentResourceService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/controller/ExperimentStepController.java b/src/main/java/com/ruoyi/lims/controller/ExperimentStepController.java
new file mode 100644
index 0000000..322571e
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/ExperimentStepController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.ExperimentStep;
+import com.ruoyi.lims.service.ExperimentStepService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/experimentStep")
+@Api(value = "ExperimentStep", tags = "Experiment Steps")
+public class ExperimentStepController {
+
+ private ExperimentStepService experimentStepService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<ExperimentStep> page, ExperimentStep query) {
+ IPage<ExperimentStep> result = experimentStepService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(ExperimentStep query) {
+ return AjaxResult.success(experimentStepService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(experimentStepService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody ExperimentStep entity) {
+ return AjaxResult.success(experimentStepService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody ExperimentStep entity) {
+ return AjaxResult.success(experimentStepService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(experimentStepService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/controller/InterfaceFieldController.java b/src/main/java/com/ruoyi/lims/controller/InterfaceFieldController.java
new file mode 100644
index 0000000..0cd4fbd
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/InterfaceFieldController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.InterfaceField;
+import com.ruoyi.lims.service.InterfaceFieldService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/interfaceField")
+@Api(value = "InterfaceField", tags = "Interface Fields")
+public class InterfaceFieldController {
+
+ private InterfaceFieldService interfaceFieldService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<InterfaceField> page, InterfaceField query) {
+ IPage<InterfaceField> result = interfaceFieldService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(InterfaceField query) {
+ return AjaxResult.success(interfaceFieldService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(interfaceFieldService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody InterfaceField entity) {
+ return AjaxResult.success(interfaceFieldService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody InterfaceField entity) {
+ return AjaxResult.success(interfaceFieldService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(interfaceFieldService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/controller/InterfaceLogController.java b/src/main/java/com/ruoyi/lims/controller/InterfaceLogController.java
new file mode 100644
index 0000000..3baf83b
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/InterfaceLogController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.InterfaceLog;
+import com.ruoyi.lims.service.InterfaceLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/interfaceLog")
+@Api(value = "InterfaceLog", tags = "Interface Logs")
+public class InterfaceLogController {
+
+ private InterfaceLogService interfaceLogService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<InterfaceLog> page, InterfaceLog query) {
+ IPage<InterfaceLog> result = interfaceLogService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(InterfaceLog query) {
+ return AjaxResult.success(interfaceLogService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(interfaceLogService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody InterfaceLog entity) {
+ return AjaxResult.success(interfaceLogService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody InterfaceLog entity) {
+ return AjaxResult.success(interfaceLogService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(interfaceLogService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/controller/SampleController.java b/src/main/java/com/ruoyi/lims/controller/SampleController.java
index b707596..d3db77b 100644
--- a/src/main/java/com/ruoyi/lims/controller/SampleController.java
+++ b/src/main/java/com/ruoyi/lims/controller/SampleController.java
@@ -1,17 +1,27 @@
package com.ruoyi.lims.controller;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.lims.pojo.Sample;
+import com.ruoyi.lims.pojo.SampleStatusLog;
+import com.ruoyi.lims.pojo.SampleStockRecord;
import com.ruoyi.lims.service.SampleService;
+import com.ruoyi.lims.service.SampleStatusLogService;
+import com.ruoyi.lims.service.SampleStockRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
@RestController
@AllArgsConstructor
@@ -20,6 +30,13 @@
public class SampleController {
private SampleService sampleservice;
+ private SampleStockRecordService stockRecordService;
+ private SampleStatusLogService statusLogService;
+
+ private static final String ST_IN_STOCK = "inStock";
+ private static final String ST_OUT_STOCK = "outStock";
+ private static final String ST_TESTING = "testing";
+ private static final String ST_DESTROYED = "destroyed";
@GetMapping("/listPage")
@ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夋牱鍝佺鐞嗚〃")
@@ -34,16 +51,75 @@
return AjaxResult.success(sampleservice.getById(id));
}
+ /**
+ * 鏍峰搧璇︽儏锛氭牱鍝佹湰浣� + 鍑哄叆搴撴祦姘� + 鐘舵�佸彉鏇村巻鍙�
+ */
+ @GetMapping("/detail/{id}")
+ @ApiOperation("鏍峰搧璇︽儏锛堝惈鍑哄叆搴撴祦姘翠笌鐘舵�佸彉鏇村巻鍙诧級")
+ public AjaxResult detail(@PathVariable Long id) {
+ Sample sample = sampleservice.getById(id);
+ if (sample == null) {
+ return AjaxResult.error("鏍峰搧涓嶅瓨鍦�");
+ }
+
+ QueryWrapper<SampleStockRecord> rw = new QueryWrapper<>();
+ rw.eq("sample_id", id).orderByDesc("operate_time").orderByDesc("id");
+ List<SampleStockRecord> records = stockRecordService.list(rw);
+
+ QueryWrapper<SampleStatusLog> sw = new QueryWrapper<>();
+ sw.eq("sample_id", id).orderByDesc("operate_time").orderByDesc("id");
+ List<SampleStatusLog> logs = statusLogService.list(sw);
+
+ Map<String, Object> result = new LinkedHashMap<>();
+ result.put("sample", sample);
+ result.put("stockRecords", records);
+ result.put("statusLogs", logs);
+ return AjaxResult.success(result);
+ }
+
@PostMapping("/add")
@ApiOperation("鏂板鏍峰搧绠$悊琛�")
public AjaxResult add(@RequestBody Sample sample) {
- return AjaxResult.success(sampleservice.save(sample));
+ boolean ok = sampleservice.save(sample);
+ // 鏂板缓鏍峰搧榛樿瑙嗕负涓�娆″叆搴擄紝琛ヤ竴鏉℃祦姘达紝鏂逛究杩芥函
+ if (ok && sample.getId() != null) {
+ SampleStockRecord rec = new SampleStockRecord();
+ rec.setSampleId(sample.getId());
+ rec.setSampleCode(sample.getSampleCode());
+ rec.setSampleName(sample.getSampleName());
+ rec.setRecordType("in");
+ rec.setQuantity(sample.getQuantity());
+ rec.setUnit(sample.getUnit());
+ rec.setAfterStatus(sample.getSampleStatus());
+ rec.setToLocation(sample.getStorageLocation());
+ rec.setOperator(currentUser());
+ rec.setOperateTime(LocalDateTime.now());
+ rec.setPurpose("鏍峰搧鐧昏鍏ュ簱");
+ stockRecordService.save(rec);
+ }
+ return AjaxResult.success(ok);
}
@PostMapping("/update")
@ApiOperation("淇敼鏍峰搧绠$悊琛�")
public AjaxResult update(@RequestBody Sample sample) {
- return AjaxResult.success(sampleservice.updateById(sample));
+ Sample old = sampleservice.getById(sample.getId());
+ boolean ok = sampleservice.updateById(sample);
+
+ // 鐘舵�佽鎵嬪伐鏀瑰姩鏃剁暀鐥�
+ if (ok && old != null && sample.getSampleStatus() != null
+ && !sample.getSampleStatus().equals(old.getSampleStatus())) {
+ SampleStatusLog log = new SampleStatusLog();
+ log.setSampleId(sample.getId());
+ log.setSampleCode(old.getSampleCode());
+ log.setFromStatus(old.getSampleStatus());
+ log.setToStatus(sample.getSampleStatus());
+ log.setChangeReason("琛ㄥ崟淇敼");
+ log.setOperator(currentUser());
+ log.setOperateTime(LocalDateTime.now());
+ statusLogService.save(log);
+ }
+ return AjaxResult.success(ok);
}
@DeleteMapping("/delete")
@@ -52,4 +128,236 @@
if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
return AjaxResult.success(sampleservice.removeBatchByIds(ids));
}
+
+ /**
+ * 鏍峰搧鍑哄簱锛氭牎楠岀姸鎬佷笌鏁伴噺 -> 鍐欐祦姘� -> 鍐欑姸鎬佸巻鍙� -> 鏇存柊鏍峰搧鐘舵��
+ */
+ @PostMapping("/outStock")
+ @ApiOperation("鏍峰搧鍑哄簱")
+ public AjaxResult outStock(@RequestBody Map<String, Object> body) {
+ Long sampleId = toLong(body.get("sampleId"));
+ if (sampleId == null) {
+ return AjaxResult.error("sampleId 涓嶈兘涓虹┖");
+ }
+ Sample sample = sampleservice.getById(sampleId);
+ if (sample == null) {
+ return AjaxResult.error("鏍峰搧涓嶅瓨鍦�");
+ }
+ if (ST_DESTROYED.equals(sample.getSampleStatus())) {
+ return AjaxResult.error("鏍峰搧宸查攢姣侊紝涓嶈兘鍑哄簱");
+ }
+ if (ST_OUT_STOCK.equals(sample.getSampleStatus())) {
+ return AjaxResult.error("鏍峰搧宸叉槸鍑哄簱鐘舵�侊紝鏃犻渶閲嶅鍑哄簱");
+ }
+
+ BigDecimal qty = toDecimal(body.get("quantity"));
+ if (qty == null || qty.compareTo(BigDecimal.ZERO) <= 0) {
+ return AjaxResult.error("鍑哄簱鏁伴噺蹇呴』澶т簬 0");
+ }
+ BigDecimal stock = sample.getQuantity() == null ? BigDecimal.ZERO : sample.getQuantity();
+ if (qty.compareTo(stock) > 0) {
+ return AjaxResult.error("鍑哄簱鏁伴噺瓒呰繃褰撳墠搴撳瓨锛堢幇鏈� " + stock.stripTrailingZeros().toPlainString()
+ + (sample.getUnit() == null ? "" : sample.getUnit()) + "锛�");
+ }
+
+ String beforeStatus = sample.getSampleStatus();
+ BigDecimal afterQty = stock.subtract(qty);
+ // 鍏ㄩ儴鍑哄簱鍒欑疆涓哄嚭搴撶姸鎬侊紝閮ㄥ垎鍑哄簱淇濇寔鍘熺姸鎬�
+ String afterStatus = afterQty.compareTo(BigDecimal.ZERO) == 0 ? ST_OUT_STOCK : beforeStatus;
+
+ SampleStockRecord rec = new SampleStockRecord();
+ rec.setSampleId(sample.getId());
+ rec.setSampleCode(sample.getSampleCode());
+ rec.setSampleName(sample.getSampleName());
+ rec.setRecordType("out");
+ rec.setQuantity(qty);
+ rec.setUnit(sample.getUnit());
+ rec.setBeforeStatus(beforeStatus);
+ rec.setAfterStatus(afterStatus);
+ rec.setFromLocation(sample.getStorageLocation());
+ rec.setToLocation(str(body.get("toLocation")));
+ rec.setRecipient(str(body.get("recipient")));
+ rec.setPurpose(str(body.get("purpose")));
+ rec.setRelatedExperiment(str(body.get("relatedExperiment")));
+ rec.setRemark(str(body.get("remark")));
+ rec.setOperator(currentUser());
+ rec.setOperateTime(LocalDateTime.now());
+ stockRecordService.save(rec);
+
+ if (!eq(beforeStatus, afterStatus)) {
+ SampleStatusLog log = new SampleStatusLog();
+ log.setSampleId(sample.getId());
+ log.setSampleCode(sample.getSampleCode());
+ log.setFromStatus(beforeStatus);
+ log.setToStatus(afterStatus);
+ log.setChangeReason("鍑哄簱" + (str(body.get("purpose")) == null ? "" : "锛�" + str(body.get("purpose"))));
+ log.setOperator(currentUser());
+ log.setOperateTime(LocalDateTime.now());
+ statusLogService.save(log);
+ }
+
+ Sample upd = new Sample();
+ upd.setId(sample.getId());
+ upd.setQuantity(afterQty);
+ upd.setSampleStatus(afterStatus);
+ if (str(body.get("toLocation")) != null) {
+ upd.setStorageLocation(str(body.get("toLocation")));
+ }
+ sampleservice.updateById(upd);
+
+ Map<String, Object> ret = new LinkedHashMap<>();
+ ret.put("sampleId", sample.getId());
+ ret.put("beforeQuantity", stock);
+ ret.put("afterQuantity", afterQty);
+ ret.put("beforeStatus", beforeStatus);
+ ret.put("afterStatus", afterStatus);
+ return AjaxResult.success("鍑哄簱鎴愬姛", ret);
+ }
+
+ /**
+ * 鏍峰搧鍏ュ簱锛堣拷鍔犳暟閲忔垨鏂板缓鍚庤ˉ褰曪級
+ */
+ @PostMapping("/inStock")
+ @ApiOperation("鏍峰搧鍏ュ簱")
+ public AjaxResult inStock(@RequestBody Map<String, Object> body) {
+ Long sampleId = toLong(body.get("sampleId"));
+ if (sampleId == null) {
+ return AjaxResult.error("sampleId 涓嶈兘涓虹┖");
+ }
+ Sample sample = sampleservice.getById(sampleId);
+ if (sample == null) {
+ return AjaxResult.error("鏍峰搧涓嶅瓨鍦�");
+ }
+ BigDecimal qty = toDecimal(body.get("quantity"));
+ if (qty == null || qty.compareTo(BigDecimal.ZERO) <= 0) {
+ return AjaxResult.error("鍏ュ簱鏁伴噺蹇呴』澶т簬 0");
+ }
+
+ String beforeStatus = sample.getSampleStatus();
+ BigDecimal stock = sample.getQuantity() == null ? BigDecimal.ZERO : sample.getQuantity();
+ BigDecimal afterQty = stock.add(qty);
+ String afterStatus = ST_OUT_STOCK.equals(beforeStatus) ? ST_IN_STOCK : beforeStatus;
+
+ SampleStockRecord rec = new SampleStockRecord();
+ rec.setSampleId(sample.getId());
+ rec.setSampleCode(sample.getSampleCode());
+ rec.setSampleName(sample.getSampleName());
+ rec.setRecordType("in");
+ rec.setQuantity(qty);
+ rec.setUnit(sample.getUnit());
+ rec.setBeforeStatus(beforeStatus);
+ rec.setAfterStatus(afterStatus);
+ rec.setToLocation(str(body.get("toLocation")) == null ? sample.getStorageLocation() : str(body.get("toLocation")));
+ rec.setRecipient(str(body.get("recipient")));
+ rec.setPurpose(str(body.get("purpose")) == null ? "鏍峰搧鍏ュ簱" : str(body.get("purpose")));
+ rec.setRemark(str(body.get("remark")));
+ rec.setOperator(currentUser());
+ rec.setOperateTime(LocalDateTime.now());
+ stockRecordService.save(rec);
+
+ if (!eq(beforeStatus, afterStatus)) {
+ SampleStatusLog log = new SampleStatusLog();
+ log.setSampleId(sample.getId());
+ log.setSampleCode(sample.getSampleCode());
+ log.setFromStatus(beforeStatus);
+ log.setToStatus(afterStatus);
+ log.setChangeReason("鍏ュ簱");
+ log.setOperator(currentUser());
+ log.setOperateTime(LocalDateTime.now());
+ statusLogService.save(log);
+ }
+
+ Sample upd = new Sample();
+ upd.setId(sample.getId());
+ upd.setQuantity(afterQty);
+ upd.setSampleStatus(afterStatus);
+ if (str(body.get("toLocation")) != null) {
+ upd.setStorageLocation(str(body.get("toLocation")));
+ }
+ sampleservice.updateById(upd);
+
+ Map<String, Object> ret = new LinkedHashMap<>();
+ ret.put("sampleId", sample.getId());
+ ret.put("beforeQuantity", stock);
+ ret.put("afterQuantity", afterQty);
+ ret.put("beforeStatus", beforeStatus);
+ ret.put("afterStatus", afterStatus);
+ return AjaxResult.success("鍏ュ簱鎴愬姛", ret);
+ }
+
+ /**
+ * 鏍峰搧鐘舵�佹祦杞紙鍦ㄥ簱/妫�娴嬩腑/鍑哄簱/閿�姣侊級
+ */
+ @PostMapping("/changeStatus")
+ @ApiOperation("鏍峰搧鐘舵�佹祦杞�")
+ public AjaxResult changeStatus(@RequestBody Map<String, Object> body) {
+ Long sampleId = toLong(body.get("sampleId"));
+ String toStatus = str(body.get("toStatus"));
+ if (sampleId == null || toStatus == null) {
+ return AjaxResult.error("sampleId 鍜� toStatus 涓嶈兘涓虹┖");
+ }
+ Sample sample = sampleservice.getById(sampleId);
+ if (sample == null) {
+ return AjaxResult.error("鏍峰搧涓嶅瓨鍦�");
+ }
+ String fromStatus = sample.getSampleStatus();
+ if (eq(fromStatus, toStatus)) {
+ return AjaxResult.error("鏍峰搧宸插浜庤鐘舵��");
+ }
+
+ SampleStatusLog log = new SampleStatusLog();
+ log.setSampleId(sample.getId());
+ log.setSampleCode(sample.getSampleCode());
+ log.setFromStatus(fromStatus);
+ log.setToStatus(toStatus);
+ log.setChangeReason(str(body.get("changeReason")));
+ log.setOperator(currentUser());
+ log.setOperateTime(LocalDateTime.now());
+ statusLogService.save(log);
+
+ Sample upd = new Sample();
+ upd.setId(sample.getId());
+ upd.setSampleStatus(toStatus);
+ sampleservice.updateById(upd);
+
+ return AjaxResult.success("鐘舵�佸凡鏇存柊");
+ }
+
+ /* ---------------- helpers ---------------- */
+
+ private String currentUser() {
+ try {
+ return SecurityUtils.getUsername();
+ } catch (Exception e) {
+ return "system";
+ }
+ }
+
+ private static String str(Object v) {
+ if (v == null) return null;
+ String s = String.valueOf(v).trim();
+ return s.isEmpty() ? null : s;
+ }
+
+ private static Long toLong(Object v) {
+ if (v == null) return null;
+ try {
+ return Long.valueOf(String.valueOf(v).trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ private static BigDecimal toDecimal(Object v) {
+ if (v == null) return null;
+ try {
+ return new BigDecimal(String.valueOf(v).trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ private static boolean eq(String a, String b) {
+ return a == null ? b == null : a.equals(b);
+ }
}
diff --git a/src/main/java/com/ruoyi/lims/controller/SampleStatusLogController.java b/src/main/java/com/ruoyi/lims/controller/SampleStatusLogController.java
new file mode 100644
index 0000000..06af557
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/SampleStatusLogController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.SampleStatusLog;
+import com.ruoyi.lims.service.SampleStatusLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/sampleStatusLog")
+@Api(value = "SampleStatusLog", tags = "Sample Status Logs")
+public class SampleStatusLogController {
+
+ private SampleStatusLogService sampleStatusLogService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<SampleStatusLog> page, SampleStatusLog query) {
+ IPage<SampleStatusLog> result = sampleStatusLogService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(SampleStatusLog query) {
+ return AjaxResult.success(sampleStatusLogService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(sampleStatusLogService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody SampleStatusLog entity) {
+ return AjaxResult.success(sampleStatusLogService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody SampleStatusLog entity) {
+ return AjaxResult.success(sampleStatusLogService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(sampleStatusLogService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/controller/SampleStockRecordController.java b/src/main/java/com/ruoyi/lims/controller/SampleStockRecordController.java
new file mode 100644
index 0000000..d896adf
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/controller/SampleStockRecordController.java
@@ -0,0 +1,61 @@
+package com.ruoyi.lims.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.lims.pojo.SampleStockRecord;
+import com.ruoyi.lims.service.SampleStockRecordService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/lims/sampleStockRecord")
+@Api(value = "SampleStockRecord", tags = "Sample Stock Records")
+public class SampleStockRecordController {
+
+ private SampleStockRecordService sampleStockRecordService;
+
+ @GetMapping("/listPage")
+ @ApiOperation("Paged query")
+ public AjaxResult listPage(Page<SampleStockRecord> page, SampleStockRecord query) {
+ IPage<SampleStockRecord> result = sampleStockRecordService.listPage(page, query);
+ return AjaxResult.success(result);
+ }
+
+ @GetMapping("/listAll")
+ @ApiOperation("List all by sample or experiment")
+ public AjaxResult listAll(SampleStockRecord query) {
+ return AjaxResult.success(sampleStockRecordService.listByExperimentOrSample(query));
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation("Get by id")
+ public AjaxResult getById(@PathVariable Long id) {
+ return AjaxResult.success(sampleStockRecordService.getById(id));
+ }
+
+ @PostMapping("/add")
+ @ApiOperation("Add")
+ public AjaxResult add(@RequestBody SampleStockRecord entity) {
+ return AjaxResult.success(sampleStockRecordService.save(entity));
+ }
+
+ @PostMapping("/update")
+ @ApiOperation("Update")
+ public AjaxResult update(@RequestBody SampleStockRecord entity) {
+ return AjaxResult.success(sampleStockRecordService.updateById(entity));
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("Batch delete")
+ public AjaxResult delete(@RequestBody List<Long> ids) {
+ if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("ids required");
+ return AjaxResult.success(sampleStockRecordService.removeBatchByIds(ids));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/ExperimentResourceMapper.java b/src/main/java/com/ruoyi/lims/mapper/ExperimentResourceMapper.java
new file mode 100644
index 0000000..1f5d20a
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/ExperimentResourceMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.ExperimentResource;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ExperimentResourceMapper extends BaseMapper<ExperimentResource> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/ExperimentStepMapper.java b/src/main/java/com/ruoyi/lims/mapper/ExperimentStepMapper.java
new file mode 100644
index 0000000..b40d65b
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/ExperimentStepMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.ExperimentStep;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ExperimentStepMapper extends BaseMapper<ExperimentStep> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/InterfaceFieldMapper.java b/src/main/java/com/ruoyi/lims/mapper/InterfaceFieldMapper.java
new file mode 100644
index 0000000..8d775fb
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/InterfaceFieldMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.InterfaceField;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface InterfaceFieldMapper extends BaseMapper<InterfaceField> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/InterfaceLogMapper.java b/src/main/java/com/ruoyi/lims/mapper/InterfaceLogMapper.java
new file mode 100644
index 0000000..9d30ac9
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/InterfaceLogMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.InterfaceLog;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface InterfaceLogMapper extends BaseMapper<InterfaceLog> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/SampleStatusLogMapper.java b/src/main/java/com/ruoyi/lims/mapper/SampleStatusLogMapper.java
new file mode 100644
index 0000000..ae47d00
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/SampleStatusLogMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.SampleStatusLog;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SampleStatusLogMapper extends BaseMapper<SampleStatusLog> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/mapper/SampleStockRecordMapper.java b/src/main/java/com/ruoyi/lims/mapper/SampleStockRecordMapper.java
new file mode 100644
index 0000000..98982d3
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/mapper/SampleStockRecordMapper.java
@@ -0,0 +1,9 @@
+package com.ruoyi.lims.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.lims.pojo.SampleStockRecord;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SampleStockRecordMapper extends BaseMapper<SampleStockRecord> {
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/pojo/ExperimentResource.java b/src/main/java/com/ruoyi/lims/pojo/ExperimentResource.java
new file mode 100644
index 0000000..2adedf4
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/ExperimentResource.java
@@ -0,0 +1,87 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_experiment_resource")
+public class ExperimentResource implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Experiment id")
+ private Long experimentId;
+
+ @ApiModelProperty(value = "Experiment code")
+ private String experimentCode;
+
+ @ApiModelProperty(value = "Type: instrument/reagent/personnel")
+ private String resourceType;
+
+ @ApiModelProperty(value = "Resource id")
+ private Long resourceId;
+
+ @ApiModelProperty(value = "Resource code")
+ private String resourceCode;
+
+ @ApiModelProperty(value = "Resource name")
+ private String resourceName;
+
+ @ApiModelProperty(value = "Quantity")
+ private BigDecimal quantity;
+
+ @ApiModelProperty(value = "Unit")
+ private String unit;
+
+ @ApiModelProperty(value = "Usage time")
+ private String usageTime;
+
+ @ApiModelProperty(value = "Status: planned/inuse/returned/consumed")
+ private String status;
+
+ @ApiModelProperty(value = "Remark")
+ private String remark;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/pojo/ExperimentStep.java b/src/main/java/com/ruoyi/lims/pojo/ExperimentStep.java
new file mode 100644
index 0000000..3fac93e
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/ExperimentStep.java
@@ -0,0 +1,104 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_experiment_step")
+public class ExperimentStep implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Experiment id")
+ private Long experimentId;
+
+ @ApiModelProperty(value = "Experiment code")
+ private String experimentCode;
+
+ @ApiModelProperty(value = "Step number")
+ private Integer stepNo;
+
+ @ApiModelProperty(value = "Step name")
+ private String stepName;
+
+ @ApiModelProperty(value = "Step SOP content")
+ private String stepContent;
+
+ @ApiModelProperty(value = "Expected duration minutes")
+ private Integer expectedDuration;
+
+ @ApiModelProperty(value = "Executor")
+ private String executor;
+
+ @ApiModelProperty(value = "Plan start")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime planStartTime;
+
+ @ApiModelProperty(value = "Plan end")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime planEndTime;
+
+ @ApiModelProperty(value = "Actual start")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime actualStartTime;
+
+ @ApiModelProperty(value = "Actual end")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime actualEndTime;
+
+ @ApiModelProperty(value = "Status: pending/running/completed/skipped/failed")
+ private String stepStatus;
+
+ @ApiModelProperty(value = "Step result")
+ private String stepResult;
+
+ @ApiModelProperty(value = "Remark")
+ private String remark;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/pojo/InterfaceField.java b/src/main/java/com/ruoyi/lims/pojo/InterfaceField.java
new file mode 100644
index 0000000..1781d11
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/InterfaceField.java
@@ -0,0 +1,84 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_interface_field")
+public class InterfaceField implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Interface id")
+ private Long interfaceId;
+
+ @ApiModelProperty(value = "Interface code")
+ private String interfaceCode;
+
+ @ApiModelProperty(value = "Source field name")
+ private String sourceField;
+
+ @ApiModelProperty(value = "JSON path")
+ private String sourcePath;
+
+ @ApiModelProperty(value = "Target field")
+ private String targetField;
+
+ @ApiModelProperty(value = "Transform: none/multiply/offset/divide/map")
+ private String transformType;
+
+ @ApiModelProperty(value = "Transform value")
+ private String transformValue;
+
+ @ApiModelProperty(value = "Default value")
+ private String defaultValue;
+
+ @ApiModelProperty(value = "Sort")
+ private Integer sortNo;
+
+ @ApiModelProperty(value = "Remark")
+ private String remark;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/pojo/InterfaceLog.java b/src/main/java/com/ruoyi/lims/pojo/InterfaceLog.java
new file mode 100644
index 0000000..6c53291
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/InterfaceLog.java
@@ -0,0 +1,92 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_interface_log")
+public class InterfaceLog implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Interface id")
+ private Long interfaceId;
+
+ @ApiModelProperty(value = "Interface code")
+ private String interfaceCode;
+
+ @ApiModelProperty(value = "Interface name")
+ private String interfaceName;
+
+ @ApiModelProperty(value = "Type: test/manual/auto")
+ private String invokeType;
+
+ @ApiModelProperty(value = "Request")
+ private String requestData;
+
+ @ApiModelProperty(value = "Response")
+ private String responseData;
+
+ @ApiModelProperty(value = "Success 1/0")
+ private String success;
+
+ @ApiModelProperty(value = "Error message")
+ private String errorMsg;
+
+ @ApiModelProperty(value = "Duration ms")
+ private Integer durationMs;
+
+ @ApiModelProperty(value = "Record count")
+ private Integer recordCount;
+
+ @ApiModelProperty(value = "Operator")
+ private String operator;
+
+ @ApiModelProperty(value = "Invoke time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime invokeTime;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/pojo/SampleStatusLog.java b/src/main/java/com/ruoyi/lims/pojo/SampleStatusLog.java
new file mode 100644
index 0000000..4b21910
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/SampleStatusLog.java
@@ -0,0 +1,80 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_sample_status_log")
+public class SampleStatusLog implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Sample id")
+ private Long sampleId;
+
+ @ApiModelProperty(value = "Sample code")
+ private String sampleCode;
+
+ @ApiModelProperty(value = "From status")
+ private String fromStatus;
+
+ @ApiModelProperty(value = "To status")
+ private String toStatus;
+
+ @ApiModelProperty(value = "Change reason")
+ private String changeReason;
+
+ @ApiModelProperty(value = "Operator")
+ private String operator;
+
+ @ApiModelProperty(value = "Operate time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime operateTime;
+
+ @ApiModelProperty(value = "Remark")
+ private String remark;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/pojo/SampleStockRecord.java b/src/main/java/com/ruoyi/lims/pojo/SampleStockRecord.java
new file mode 100644
index 0000000..c2900ef
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/pojo/SampleStockRecord.java
@@ -0,0 +1,104 @@
+package com.ruoyi.lims.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("lims_sample_stock_record")
+public class SampleStockRecord implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty(value = "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty(value = "Sample id")
+ private Long sampleId;
+
+ @ApiModelProperty(value = "Sample code")
+ private String sampleCode;
+
+ @ApiModelProperty(value = "Sample name")
+ private String sampleName;
+
+ @ApiModelProperty(value = "Type: in/out/destroy/return/transfer")
+ private String recordType;
+
+ @ApiModelProperty(value = "Quantity")
+ private BigDecimal quantity;
+
+ @ApiModelProperty(value = "Unit")
+ private String unit;
+
+ @ApiModelProperty(value = "Status before")
+ private String beforeStatus;
+
+ @ApiModelProperty(value = "Status after")
+ private String afterStatus;
+
+ @ApiModelProperty(value = "From location")
+ private String fromLocation;
+
+ @ApiModelProperty(value = "To location")
+ private String toLocation;
+
+ @ApiModelProperty(value = "Operator")
+ private String operator;
+
+ @ApiModelProperty(value = "Operate time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime operateTime;
+
+ @ApiModelProperty(value = "Recipient")
+ private String recipient;
+
+ @ApiModelProperty(value = "Purpose")
+ private String purpose;
+
+ @ApiModelProperty(value = "Related experiment")
+ private String relatedExperiment;
+
+ @ApiModelProperty(value = "Remark")
+ private String remark;
+
+ @ApiModelProperty(value = "Delete flag")
+ private String delFlag;
+
+ @ApiModelProperty(value = "Tenant id")
+ @TableField(fill = FieldFill.INSERT)
+ private Long tenantId;
+
+ @ApiModelProperty(value = "Create time")
+ @TableField(fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty(value = "Create user")
+ @TableField(fill = FieldFill.INSERT)
+ private Integer createUser;
+
+ @ApiModelProperty(value = "Update time")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "Update user")
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Integer updateUser;
+
+}
diff --git a/src/main/java/com/ruoyi/lims/service/ExperimentResourceService.java b/src/main/java/com/ruoyi/lims/service/ExperimentResourceService.java
new file mode 100644
index 0000000..8c4c0b7
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/ExperimentResourceService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.ExperimentResource;
+
+import java.util.List;
+
+public interface ExperimentResourceService extends IService<ExperimentResource> {
+ IPage<ExperimentResource> listPage(Page<ExperimentResource> page, ExperimentResource query);
+
+ List<ExperimentResource> listByExperimentOrSample(ExperimentResource query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/ExperimentStepService.java b/src/main/java/com/ruoyi/lims/service/ExperimentStepService.java
new file mode 100644
index 0000000..99e9b09
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/ExperimentStepService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.ExperimentStep;
+
+import java.util.List;
+
+public interface ExperimentStepService extends IService<ExperimentStep> {
+ IPage<ExperimentStep> listPage(Page<ExperimentStep> page, ExperimentStep query);
+
+ List<ExperimentStep> listByExperimentOrSample(ExperimentStep query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/InterfaceFieldService.java b/src/main/java/com/ruoyi/lims/service/InterfaceFieldService.java
new file mode 100644
index 0000000..7172c52
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/InterfaceFieldService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.InterfaceField;
+
+import java.util.List;
+
+public interface InterfaceFieldService extends IService<InterfaceField> {
+ IPage<InterfaceField> listPage(Page<InterfaceField> page, InterfaceField query);
+
+ List<InterfaceField> listByExperimentOrSample(InterfaceField query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/InterfaceLogService.java b/src/main/java/com/ruoyi/lims/service/InterfaceLogService.java
new file mode 100644
index 0000000..d250c12
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/InterfaceLogService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.InterfaceLog;
+
+import java.util.List;
+
+public interface InterfaceLogService extends IService<InterfaceLog> {
+ IPage<InterfaceLog> listPage(Page<InterfaceLog> page, InterfaceLog query);
+
+ List<InterfaceLog> listByExperimentOrSample(InterfaceLog query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/SampleStatusLogService.java b/src/main/java/com/ruoyi/lims/service/SampleStatusLogService.java
new file mode 100644
index 0000000..aeebfea
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/SampleStatusLogService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.SampleStatusLog;
+
+import java.util.List;
+
+public interface SampleStatusLogService extends IService<SampleStatusLog> {
+ IPage<SampleStatusLog> listPage(Page<SampleStatusLog> page, SampleStatusLog query);
+
+ List<SampleStatusLog> listByExperimentOrSample(SampleStatusLog query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/SampleStockRecordService.java b/src/main/java/com/ruoyi/lims/service/SampleStockRecordService.java
new file mode 100644
index 0000000..5b86a9a
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/SampleStockRecordService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.lims.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.lims.pojo.SampleStockRecord;
+
+import java.util.List;
+
+public interface SampleStockRecordService extends IService<SampleStockRecord> {
+ IPage<SampleStockRecord> listPage(Page<SampleStockRecord> page, SampleStockRecord query);
+
+ List<SampleStockRecord> listByExperimentOrSample(SampleStockRecord query);
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/ExperimentResourceServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/ExperimentResourceServiceImpl.java
new file mode 100644
index 0000000..68ae80e
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/ExperimentResourceServiceImpl.java
@@ -0,0 +1,46 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.ExperimentResourceMapper;
+import com.ruoyi.lims.pojo.ExperimentResource;
+import com.ruoyi.lims.service.ExperimentResourceService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class ExperimentResourceServiceImpl extends ServiceImpl<ExperimentResourceMapper, ExperimentResource> implements ExperimentResourceService {
+
+ @Override
+ public IPage<ExperimentResource> listPage(Page<ExperimentResource> page, ExperimentResource query) {
+ QueryWrapper<ExperimentResource> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getExperimentId() != null) { wrapper.eq("experiment_id", query.getExperimentId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getExperimentCode()), "experiment_code", query.getExperimentCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getResourceType()), "resource_type", query.getResourceType());
+ wrapper.like(StringUtils.isNotEmpty(query.getResourceCode()), "resource_code", query.getResourceCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getResourceName()), "resource_name", query.getResourceName());
+ wrapper.like(StringUtils.isNotEmpty(query.getUnit()), "unit", query.getUnit());
+ wrapper.like(StringUtils.isNotEmpty(query.getUsageTime()), "usage_time", query.getUsageTime());
+ wrapper.like(StringUtils.isNotEmpty(query.getStatus()), "status", query.getStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getRemark()), "remark", query.getRemark());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<ExperimentResource> listByExperimentOrSample(ExperimentResource query) {
+ QueryWrapper<ExperimentResource> w = new QueryWrapper<>();
+ if (query != null && query.getExperimentId() != null) {
+ w.eq("experiment_id", query.getExperimentId());
+ }
+ w.orderByAsc("id");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/ExperimentStepServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/ExperimentStepServiceImpl.java
new file mode 100644
index 0000000..94794a7
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/ExperimentStepServiceImpl.java
@@ -0,0 +1,45 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.ExperimentStepMapper;
+import com.ruoyi.lims.pojo.ExperimentStep;
+import com.ruoyi.lims.service.ExperimentStepService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class ExperimentStepServiceImpl extends ServiceImpl<ExperimentStepMapper, ExperimentStep> implements ExperimentStepService {
+
+ @Override
+ public IPage<ExperimentStep> listPage(Page<ExperimentStep> page, ExperimentStep query) {
+ QueryWrapper<ExperimentStep> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getExperimentId() != null) { wrapper.eq("experiment_id", query.getExperimentId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getExperimentCode()), "experiment_code", query.getExperimentCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getStepName()), "step_name", query.getStepName());
+ wrapper.like(StringUtils.isNotEmpty(query.getStepContent()), "step_content", query.getStepContent());
+ wrapper.like(StringUtils.isNotEmpty(query.getExecutor()), "executor", query.getExecutor());
+ wrapper.like(StringUtils.isNotEmpty(query.getStepStatus()), "step_status", query.getStepStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getStepResult()), "step_result", query.getStepResult());
+ wrapper.like(StringUtils.isNotEmpty(query.getRemark()), "remark", query.getRemark());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<ExperimentStep> listByExperimentOrSample(ExperimentStep query) {
+ QueryWrapper<ExperimentStep> w = new QueryWrapper<>();
+ if (query != null && query.getExperimentId() != null) {
+ w.eq("experiment_id", query.getExperimentId());
+ }
+ w.orderByAsc("id");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/InstrumentCalibrationServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/InstrumentCalibrationServiceImpl.java
index 1b500b1..f9e6a1c 100644
--- a/src/main/java/com/ruoyi/lims/service/impl/InstrumentCalibrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/lims/service/impl/InstrumentCalibrationServiceImpl.java
@@ -19,6 +19,8 @@
public IPage<InstrumentCalibration> listPage(Page<InstrumentCalibration> page, InstrumentCalibration query) {
QueryWrapper<InstrumentCalibration> wrapper = new QueryWrapper<>();
if (query != null) {
+ // ID filters
+ if (query.getInstrumentId() != null) { wrapper.eq("instrument_id", query.getInstrumentId()); }
wrapper.like(StringUtils.isNotEmpty(query.getInstrumentCode()), "instrument_code", query.getInstrumentCode());
wrapper.like(StringUtils.isNotEmpty(query.getInstrumentName()), "instrument_name", query.getInstrumentName());
wrapper.like(StringUtils.isNotEmpty(query.getRecordType()), "record_type", query.getRecordType());
diff --git a/src/main/java/com/ruoyi/lims/service/impl/InterfaceFieldServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/InterfaceFieldServiceImpl.java
new file mode 100644
index 0000000..5207720
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/InterfaceFieldServiceImpl.java
@@ -0,0 +1,44 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.InterfaceFieldMapper;
+import com.ruoyi.lims.pojo.InterfaceField;
+import com.ruoyi.lims.service.InterfaceFieldService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class InterfaceFieldServiceImpl extends ServiceImpl<InterfaceFieldMapper, InterfaceField> implements InterfaceFieldService {
+
+ @Override
+ public IPage<InterfaceField> listPage(Page<InterfaceField> page, InterfaceField query) {
+ QueryWrapper<InterfaceField> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getInterfaceId() != null) { wrapper.eq("interface_id", query.getInterfaceId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getInterfaceCode()), "interface_code", query.getInterfaceCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getSourceField()), "source_field", query.getSourceField());
+ wrapper.like(StringUtils.isNotEmpty(query.getSourcePath()), "source_path", query.getSourcePath());
+ wrapper.like(StringUtils.isNotEmpty(query.getTargetField()), "target_field", query.getTargetField());
+ wrapper.like(StringUtils.isNotEmpty(query.getTransformType()), "transform_type", query.getTransformType());
+ wrapper.like(StringUtils.isNotEmpty(query.getTransformValue()), "transform_value", query.getTransformValue());
+ wrapper.like(StringUtils.isNotEmpty(query.getDefaultValue()), "default_value", query.getDefaultValue());
+ wrapper.like(StringUtils.isNotEmpty(query.getRemark()), "remark", query.getRemark());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<InterfaceField> listByExperimentOrSample(InterfaceField query) {
+ QueryWrapper<InterfaceField> w = new QueryWrapper<>();
+ w.orderByDesc("id");
+ w.last("limit 200");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/InterfaceLogServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/InterfaceLogServiceImpl.java
new file mode 100644
index 0000000..fe9bf14
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/InterfaceLogServiceImpl.java
@@ -0,0 +1,44 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.InterfaceLogMapper;
+import com.ruoyi.lims.pojo.InterfaceLog;
+import com.ruoyi.lims.service.InterfaceLogService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class InterfaceLogServiceImpl extends ServiceImpl<InterfaceLogMapper, InterfaceLog> implements InterfaceLogService {
+
+ @Override
+ public IPage<InterfaceLog> listPage(Page<InterfaceLog> page, InterfaceLog query) {
+ QueryWrapper<InterfaceLog> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getInterfaceId() != null) { wrapper.eq("interface_id", query.getInterfaceId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getInterfaceCode()), "interface_code", query.getInterfaceCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getInterfaceName()), "interface_name", query.getInterfaceName());
+ wrapper.like(StringUtils.isNotEmpty(query.getInvokeType()), "invoke_type", query.getInvokeType());
+ wrapper.like(StringUtils.isNotEmpty(query.getRequestData()), "request_data", query.getRequestData());
+ wrapper.like(StringUtils.isNotEmpty(query.getResponseData()), "response_data", query.getResponseData());
+ wrapper.like(StringUtils.isNotEmpty(query.getSuccess()), "success", query.getSuccess());
+ wrapper.like(StringUtils.isNotEmpty(query.getErrorMsg()), "error_msg", query.getErrorMsg());
+ wrapper.like(StringUtils.isNotEmpty(query.getOperator()), "operator", query.getOperator());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<InterfaceLog> listByExperimentOrSample(InterfaceLog query) {
+ QueryWrapper<InterfaceLog> w = new QueryWrapper<>();
+ w.orderByDesc("id");
+ w.last("limit 200");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/ReagentRecordServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/ReagentRecordServiceImpl.java
index 0fdece6..447019f 100644
--- a/src/main/java/com/ruoyi/lims/service/impl/ReagentRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/lims/service/impl/ReagentRecordServiceImpl.java
@@ -19,6 +19,8 @@
public IPage<ReagentRecord> listPage(Page<ReagentRecord> page, ReagentRecord query) {
QueryWrapper<ReagentRecord> wrapper = new QueryWrapper<>();
if (query != null) {
+ // ID filters
+ if (query.getReagentId() != null) { wrapper.eq("reagent_id", query.getReagentId()); }
wrapper.like(StringUtils.isNotEmpty(query.getReagentCode()), "reagent_code", query.getReagentCode());
wrapper.like(StringUtils.isNotEmpty(query.getReagentName()), "reagent_name", query.getReagentName());
wrapper.like(StringUtils.isNotEmpty(query.getRecordType()), "record_type", query.getRecordType());
diff --git a/src/main/java/com/ruoyi/lims/service/impl/SampleStatusLogServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/SampleStatusLogServiceImpl.java
new file mode 100644
index 0000000..342f7a1
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/SampleStatusLogServiceImpl.java
@@ -0,0 +1,44 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.SampleStatusLogMapper;
+import com.ruoyi.lims.pojo.SampleStatusLog;
+import com.ruoyi.lims.service.SampleStatusLogService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class SampleStatusLogServiceImpl extends ServiceImpl<SampleStatusLogMapper, SampleStatusLog> implements SampleStatusLogService {
+
+ @Override
+ public IPage<SampleStatusLog> listPage(Page<SampleStatusLog> page, SampleStatusLog query) {
+ QueryWrapper<SampleStatusLog> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getSampleId() != null) { wrapper.eq("sample_id", query.getSampleId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getSampleCode()), "sample_code", query.getSampleCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getFromStatus()), "from_status", query.getFromStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getToStatus()), "to_status", query.getToStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getChangeReason()), "change_reason", query.getChangeReason());
+ wrapper.like(StringUtils.isNotEmpty(query.getOperator()), "operator", query.getOperator());
+ wrapper.like(StringUtils.isNotEmpty(query.getRemark()), "remark", query.getRemark());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<SampleStatusLog> listByExperimentOrSample(SampleStatusLog query) {
+ QueryWrapper<SampleStatusLog> w = new QueryWrapper<>();
+ if (query != null && query.getSampleId() != null) {
+ w.eq("sample_id", query.getSampleId());
+ }
+ w.orderByDesc("id");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/lims/service/impl/SampleStockRecordServiceImpl.java b/src/main/java/com/ruoyi/lims/service/impl/SampleStockRecordServiceImpl.java
new file mode 100644
index 0000000..84eaa95
--- /dev/null
+++ b/src/main/java/com/ruoyi/lims/service/impl/SampleStockRecordServiceImpl.java
@@ -0,0 +1,51 @@
+package com.ruoyi.lims.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.lims.mapper.SampleStockRecordMapper;
+import com.ruoyi.lims.pojo.SampleStockRecord;
+import com.ruoyi.lims.service.SampleStockRecordService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class SampleStockRecordServiceImpl extends ServiceImpl<SampleStockRecordMapper, SampleStockRecord> implements SampleStockRecordService {
+
+ @Override
+ public IPage<SampleStockRecord> listPage(Page<SampleStockRecord> page, SampleStockRecord query) {
+ QueryWrapper<SampleStockRecord> wrapper = new QueryWrapper<>();
+ if (query != null) {
+ // ID filters
+ if (query.getSampleId() != null) { wrapper.eq("sample_id", query.getSampleId()); }
+ wrapper.like(StringUtils.isNotEmpty(query.getSampleCode()), "sample_code", query.getSampleCode());
+ wrapper.like(StringUtils.isNotEmpty(query.getSampleName()), "sample_name", query.getSampleName());
+ wrapper.like(StringUtils.isNotEmpty(query.getRecordType()), "record_type", query.getRecordType());
+ wrapper.like(StringUtils.isNotEmpty(query.getUnit()), "unit", query.getUnit());
+ wrapper.like(StringUtils.isNotEmpty(query.getBeforeStatus()), "before_status", query.getBeforeStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getAfterStatus()), "after_status", query.getAfterStatus());
+ wrapper.like(StringUtils.isNotEmpty(query.getFromLocation()), "from_location", query.getFromLocation());
+ wrapper.like(StringUtils.isNotEmpty(query.getToLocation()), "to_location", query.getToLocation());
+ wrapper.like(StringUtils.isNotEmpty(query.getOperator()), "operator", query.getOperator());
+ wrapper.like(StringUtils.isNotEmpty(query.getRecipient()), "recipient", query.getRecipient());
+ wrapper.like(StringUtils.isNotEmpty(query.getPurpose()), "purpose", query.getPurpose());
+ wrapper.like(StringUtils.isNotEmpty(query.getRelatedExperiment()), "related_experiment", query.getRelatedExperiment());
+ wrapper.like(StringUtils.isNotEmpty(query.getRemark()), "remark", query.getRemark());
+ }
+ wrapper.orderByDesc("id");
+ return baseMapper.selectPage(page, wrapper);
+ }
+
+ @Override
+ public java.util.List<SampleStockRecord> listByExperimentOrSample(SampleStockRecord query) {
+ QueryWrapper<SampleStockRecord> w = new QueryWrapper<>();
+ if (query != null && query.getSampleId() != null) {
+ w.eq("sample_id", query.getSampleId());
+ }
+ w.orderByDesc("id");
+ return baseMapper.selectList(w);
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3