From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/AppLimsController.java | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 111 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/AppLimsController.java b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/AppLimsController.java
new file mode 100644
index 0000000..8f83e00
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/limsController/AppLimsController.java
@@ -0,0 +1,111 @@
+package jnpf.limsController;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired; // 鏇挎崲@Resource閬垮厤鍏煎鎬ч棶棰�
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鍩轰簬鏁版嵁琛�+鏉′欢鏌ヨ瀛愯〃鏁版嵁锛圝ava鐗圝NPF 6.1锛�
+ * 淇锛氭浛鎹Resource涓篅Autowired瑙e喅娉ㄨВAPI鍏煎鎬ч棶棰�
+ */
+@Slf4j // 娣诲姞鏃ュ織璁板綍
+@Tag(name = "Lims甯哥敤鏁版嵁", description = "瀹㈡埛鑱旂郴浜哄瓙琛ㄦ暟鎹煡璇�")
+@RestController
+@RequestMapping("/custom")
+@RequiredArgsConstructor
+public class AppLimsController {
+ // 鏍稿績淇锛氱敤@Autowired鏇挎崲@Resource锛岄伩鍏峧avax.annotation.Resource鐨勫吋瀹规�ч棶棰�
+ // @Resource // 娉ㄩ噴鎺夊師娉ㄨВ锛岃В鍐砽ookup()鏂规硶涓嶅瓨鍦ㄧ殑闂
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+
+ // 甯搁噺瀹氫箟锛氶伩鍏嶇‖缂栫爜锛屾彁楂樺彲缁存姢鎬�
+ private static final String SUB_TABLE_NAME = "lims_quality_manager_item";
+ private static final String QUERY_FIELDS = "contact_name, contact_phone, create_time";
+
+ /**
+ * 鏌ヨ瀹㈡埛鑱旂郴浜哄瓙琛ㄦ暟鎹�
+ * @param customerId 瀹㈡埛ID锛堝叧鑱旀潯浠讹紝蹇呭~锛�
+ * @param status 鐘舵�侊紙鑷畾涔夋潯浠讹紝蹇呭~锛屽1-鏈夋晥 2-鏃犳晥锛�
+ * @return JNPF鏍囧噯鏍煎紡鏁版嵁
+ */
+ @Operation(summary = "鎴栬�呰川閲忔爣鍑嗕俊鎭�", description = "鎴栬�呰川閲忔爣鍑嗕俊鎭�")
+ @GetMapping("/querySubTableByCondition") // 绉婚櫎鍚庣紑2锛屽懡鍚嶇粺涓�
+ public JSONObject querySubTableByCondition(
+ @Parameter(description = "璐ㄩ噺鏍囧噯ID", required = true)
+ @RequestParam String customerId,
+
+ @Parameter(description = "鐘舵�侊紙1-鏈夋晥 2-鏃犳晥锛�", required = true)
+ @RequestParam Integer status) {
+
+ // 鍒濆鍖栬繑鍥炵粨鏋�
+ JSONObject result = new JSONObject();
+ result.put("code", 200);
+ result.put("msg", "鏌ヨ鎴愬姛");
+ result.put("data", new JSONObject());
+
+ try {
+ // 1. 鍙傛暟鏍¢獙
+ if (!StringUtils.hasText(customerId)) {
+ result.put("code", 400);
+ result.put("msg", "瀹㈡埛ID涓嶈兘涓虹┖");
+ return result;
+ }
+ if (status == null || (status != 1 && status != 2)) {
+ result.put("code", 400);
+ result.put("msg", "鐘舵�佸�煎彧鑳芥槸1锛堟湁鏁堬級鎴�2锛堟棤鏁堬級");
+ return result;
+ }
+
+ // 2. 鏋勯�犲弬鏁板寲SQL锛堥槻SQL娉ㄥ叆锛�
+ String sql = String.format("SELECT * FROM %s WHERE f_foreign_id = ? ORDER BY item_sort DESC",
+ SUB_TABLE_NAME);
+
+ // 3. 鎵ц鏌ヨ
+ List<Map<String, Object>> dataList = jdbcTemplate.queryForList(sql, customerId);
+
+ // 4. 澶勭悊绌虹粨鏋�
+ if (dataList == null) {
+ dataList = Collections.emptyList();
+ }
+
+ // 5. 灏佽杩斿洖鏁版嵁锛堢鍚圝NPF鏍囧噯锛�
+ JSONObject data = new JSONObject();
+ data.put("list", dataList);
+ data.put("total", dataList.size()); // 琛ュ厖鎬绘暟锛屽寮烘帴鍙e疄鐢ㄦ��
+ result.put("data", data);
+
+ log.info("鏌ヨ瀹㈡埛鑱旂郴浜哄瓙琛ㄦ垚鍔燂紝瀹㈡埛ID锛歿}锛岀姸鎬侊細{}锛屾煡璇㈢粨鏋滄暟锛歿}", customerId, status, dataList.size());
+
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ // 鏃犳暟鎹紓甯革細鍙嬪ソ鎻愮ず锛屼笉杩斿洖500
+ result.put("msg", "鏈煡璇㈠埌绗﹀悎鏉′欢鐨勫鎴疯仈绯讳汉鏁版嵁");
+ log.warn("鏌ヨ瀹㈡埛鑱旂郴浜哄瓙琛ㄦ棤鏁版嵁锛屽鎴稩D锛歿}锛岀姸鎬侊細{}", customerId, status);
+ } catch (Exception e) {
+ // 鍏朵粬寮傚父锛氳褰曡缁嗘棩蹇楋紝杩斿洖鍙嬪ソ鎻愮ず
+ result.put("code", 500);
+ result.put("msg", "鏌ヨ澶辫触锛氱郴缁熷紓甯�");
+ log.error("鏌ヨ瀹㈡埛鑱旂郴浜哄瓙琛ㄥけ璐ワ紝瀹㈡埛ID锛歿}锛岀姸鎬侊細{}", customerId, status, e);
+ }
+
+ return result;
+ }
+
+ @GetMapping("/testApi")
+ public void testApi(){
+ log.info("杩涘叆鎺ュ彛");
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0