Bläddra i källkod

试验-接入成渝第三方接口开发
1、获取合同段列表(成功)
2、获取检测项目树(接口未开发完)

LHB 1 vecka sedan
förälder
incheckning
9cde8fa6de

+ 26 - 29
blade-service/blade-business/src/main/java/org/springblade/business/scheduled/ChenYuTestScheduled.java

@@ -198,14 +198,13 @@ public class ChenYuTestScheduled {
     }
 
     /**
-     * 获取合同段列表 TODO 接口数据待确认
+     * 获取合同段列表
      */
-//    @Scheduled(cron = "0 0 * * * ?")
-    @Scheduled(fixedDelay = 20000)
+    @Scheduled(cron = "0 0 * * * ?")
     public void getContractSectByProjCode() {
-//        if (!SystemUtils.isLinux()) {
-//            return;
-//        }
+        if (!SystemUtils.isLinux()) {
+            return;
+        }
 
         contractCodeMap.clear();
         String token = getToken();
@@ -234,32 +233,30 @@ public class ChenYuTestScheduled {
             List<String> codes = new ArrayList<>();
             for (int i = 0; i < data.size(); i++) {
                 JSONObject obj = data.getJSONObject(i);
-                String code = obj.getString("Code");
                 String name = obj.getString("Name");
-//                if (StringUtil.isNotBlank(code)) {
-//                    codes.add(code);
-//                }
-                contractCodeMap.put(name, Long.valueOf(i));
+                if (StringUtil.isNotBlank(name)) {
+                    codes.add(name);
+                }
+            }
+
+            if (CollectionUtil.isEmpty(codes)) {
+                log.info("No valid contract codes found");
+                return;
             }
 
-//            if (CollectionUtil.isEmpty(codes)) {
-//                log.info("No valid contract codes found");
-//                return;
-//            }
-
-//            // 构建参数化查询
-//            String placeholders = String.join(",", Collections.nCopies(codes.size(), "?"));
-//            String sql = "SELECT * FROM m_contract_info WHERE contract_number IN (" + placeholders + ")";
-//
-//            List<ContractInfo> contracts = jdbcTemplate.query(
-//                    sql,
-//                    codes.toArray(),
-//                    new BeanPropertyRowMapper<>(ContractInfo.class)
-//            );
-
-//            for (ContractInfo contract : contracts) {
-//                contractCodeMap.put(contract.getContractNumber(), contract.getId());
-//            }
+            // 构建参数化查询
+            String placeholders = String.join(",", Collections.nCopies(codes.size(), "?"));
+            String sql = "SELECT * FROM m_contract_info WHERE contract_number IN (" + placeholders + ")";
+
+            List<ContractInfo> contracts = jdbcTemplate.query(
+                    sql,
+                    codes.toArray(),
+                    new BeanPropertyRowMapper<>(ContractInfo.class)
+            );
+
+            for (ContractInfo contract : contracts) {
+                contractCodeMap.put(contract.getContractNumber(), contract.getId());
+            }
 
             log.info("Loaded {} contract mappings", contractCodeMap.size());
         } catch (Exception e) {