Browse Source

试验-接入成渝第三方接口开发
1、获取树接口新增合同段字段

LHB 1 day ago
parent
commit
7f6afe13c1

+ 5 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialCyTestType.java

@@ -23,6 +23,11 @@ public class TrialCyTestType {
      */
     @ApiModelProperty("项目id")
     private Long projectId;
+    /**
+     * 项目id
+     */
+    @ApiModelProperty("合同段id")
+    private Long contractId;
     /**
      * ID唯一标识
      */

+ 7 - 47
blade-service/blade-business/src/main/java/org/springblade/business/scheduled/ChenYuTestScheduled.java

@@ -101,6 +101,7 @@ public class ChenYuTestScheduled {
     private CloseableHttpClient httpClient;
     private static final String TOKEN_REDIS_KEY = "blade:cqcy:token";
     private static final String PROJECT_CODE = "cqcyfx";
+    private static final String CONTRACT_CODE = "CYTJ03";
     private static Long PROJECT_ID = null;
     private static final String BASE_URL = "https://apicqcyfx.qdm123.com";
     private final Map<String, Long> contractCodeMap = new ConcurrentHashMap<>();
@@ -209,62 +210,20 @@ public class ChenYuTestScheduled {
         if (!SystemUtils.isLinux()) {
             return;
         }
-
-        contractCodeMap.clear();
-        String token = getToken();
-        ensureProjectIdInitialized();
-
-        if (token == null || PROJECT_ID == null) {
-            log.error("Invalid token or project ID");
-            return;
-        }
-
         try {
-            //获取合同段列表接口
-            Result result = getContractList();
-            if (result == null || result.getState() != 1) {
-                log.error("Failed to get contract sections: {}",
-                        result != null ? result.getMessage() : "No response");
-                return;
-            }
-
-            JSONArray data = (JSONArray) result.getData();
-            if (CollectionUtil.isEmpty(data)) {
-                log.warn("No contract sections found");
-                return;
-            }
-
-            List<String> codes = new ArrayList<>();
-            for (int i = 0; i < data.size(); i++) {
-                JSONObject obj = data.getJSONObject(i);
-                String name = obj.getString("Name");
-                if (StringUtil.isNotBlank(name)) {
-                    codes.add(name);
-                }
-            }
-
-            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 + ")";
-
+            String sql = "SELECT id FROM m_contract_info WHERE contract_number = " + CONTRACT_CODE;
             List<ContractInfo> contracts = jdbcTemplate.query(
                     sql,
-                    codes.toArray(),
                     new BeanPropertyRowMapper<>(ContractInfo.class)
             );
-
-            for (ContractInfo contract : contracts) {
-                contractCodeMap.put(contract.getContractNumber(), contract.getId());
+            if(CollectionUtil.isNotEmpty(contracts)){
+                ContractInfo contractInfo = contracts.get(0);
+                contractCodeMap.put(CONTRACT_CODE, contractInfo.getId());
             }
-
             log.info("Loaded {} contract mappings", contractCodeMap.size());
         } catch (Exception e) {
-            log.error("Error processing contract sections", e);
+            log.error(CONTRACT_CODE + " 合同段编码不存在", e);
         }
     }
 
@@ -600,6 +559,7 @@ public class ChenYuTestScheduled {
             for (TrialCyTestType type : testTypes) {
                 type.setPKeyId(SnowFlakeUtil.getId());
                 type.setProjectId(PROJECT_ID);
+                type.setContractId(contractCodeMap.get(CONTRACT_CODE));
                 type.setFatherId(type.getFatherId() == null || type.getFatherId().isEmpty() ? "0" : type.getFatherId());
             }
             //先删除旧数据