Procházet zdrojové kódy

[task-5313] 失控报告接口+系统权限申请批量导入

huangws před 3 měsíci
rodič
revize
2823e08407

+ 28 - 12
GetDataByView/src/main/java/com/jyxt/getdatabyview/GetDataByViewApplication.java

@@ -6,11 +6,13 @@ import com.jyxt.getdatabyview.view.repository.LISViewRepository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ConfigurableApplicationContext;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -33,8 +35,14 @@ public class GetDataByViewApplication implements CommandLineRunner{
     @Autowired
     private ConfigurableApplicationContext context;
 
-    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport");//
-//    public List<String> lisTableList = Arrays.asList("V_JT_QCMonthReport");//
+    @Autowired
+    private ImportRunner importRunner;
+
+    @Value("${importMode}")
+    private String importMode;
+
+    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport","V_JT_OutOfControlReport");//
+//    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport");//
 
     public static void main(String[] args) {
         SpringApplication.run(GetDataByViewApplication.class, args);
@@ -43,18 +51,26 @@ public class GetDataByViewApplication implements CommandLineRunner{
     @Override
     public void run(String... args) throws Exception {
         log.info("<-------------new turn start...------------->");
-        ibpsRepository.getBasicData();
-        for(String lisTable : lisTableList){
-            List<Map<String, Object>> retList = lisViewRepository.query(lisTable);
-            if(retList != null){
-                handleData.startHandleData(retList,lisTable);
+        if(importMode.equals("0")){
+            ibpsRepository.getBasicData();
+            for(String lisTable : lisTableList){
+                List<Map<String, Object>> retList = lisViewRepository.query(lisTable);
+                if(retList != null){
+                    handleData.startHandleData(retList,lisTable);
+                }
             }
+            //质量指标接口
+            List<Map<String, Object>>qualityIndicatorList  = ibpsRepository.getUndoQualityIndicator();
+            handleData.HandQIData(qualityIndicatorList);
+
+            log.info("<-- -----------this turn finish...------------->");
+            context.close(); // 直接关闭上下文
+        }else{
+            String currentDir = System.getProperty("user.dir");
+            String filePath = currentDir + File.separator + "权限申请.txt";
+            importRunner.importPermissionRequest(filePath);
+            context.close(); // 直接关闭上下文
         }
-        //质量指标接口
-         List<Map<String, Object>>qualityIndicatorList  = ibpsRepository.getUndoQualityIndicator();
-        handleData.HandQIData(qualityIndicatorList);
 
-        log.info("<-- -----------this turn finish...------------->");
-        context.close(); // 直接关闭上下文
     }
 }

+ 164 - 4
GetDataByView/src/main/java/com/jyxt/getdatabyview/HandleData.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.sql.Timestamp;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
@@ -35,6 +36,10 @@ public class HandleData {
 
     public static final Map<String, String> RerunSampleField = new HashMap<>();
 
+    public static final Map<String, String> UnControlReportField = new HashMap<>();
+
+    public static final Map<String, String> PositionTransferField = new HashMap<>();
+
     static {
         // 静态初始化块中填充数据
         RerunSampleField.put("CREATEBY", "bian_zhi_ren_");
@@ -51,6 +56,38 @@ public class HandleData {
         RerunSampleField.put("PATNAME", "xing_ming_");
         RerunSampleField.put("RERUNMETHOD", "fu_jian_fang_shi_");
         RerunSampleField.put("UNIT", "dan_wei_");
+
+        UnControlReportField.put("TestCode","");
+        UnControlReportField.put("QCName","zhi_kong_pin_ming");
+        UnControlReportField.put("QCLot","");
+        UnControlReportField.put("QCDate","");
+        UnControlReportField.put("QCResult","");
+        UnControlReportField.put("SD","");
+        UnControlReportField.put("Quant","");
+        UnControlReportField.put("Qual","");
+        UnControlReportField.put("ErrorType","");
+        UnControlReportField.put("Reason","");
+        UnControlReportField.put("Action","");
+        UnControlReportField.put("QCFinalResult","");
+        UnControlReportField.put("IsInControl","");
+        UnControlReportField.put("AffectsPatientSamples","");
+        UnControlReportField.put("AffectsResultReporting","");
+        UnControlReportField.put("Notes","");
+        UnControlReportField.put("QCFinalResult","");
+
+        PositionTransferField.put("G002","生化免疫组");   //茂源生化
+        PositionTransferField.put("G004","生化免疫组");    //茂源免疫
+        PositionTransferField.put("G032","临检组");   //茂源临检
+        PositionTransferField.put("G009","");   //茂源急诊
+        PositionTransferField.put("G007","分子组");   //茂源分子
+        PositionTransferField.put("G031","微生物组");   //茂源微生物
+        PositionTransferField.put("G036","文化路院区");   //文化大检验
+        PositionTransferField.put("G014","文化路院区");   //文化微生物
+        PositionTransferField.put("Y032","临检组");   //茂源临检(夜班)
+        PositionTransferField.put("Y009","");   //茂源急诊(夜班)
+        PositionTransferField.put("Y036","文化路院区");   //文化大检验(夜班)
+
+
     }
 
 
@@ -59,13 +96,17 @@ public class HandleData {
         retList = cleanExistData(lisTable,retList,existList);
         log.info("table:"+lisTable+" get data:"+retList.size());
         if (lisTable.equals("V_JT_TestCodeRerunRecord")){
-            log.info("ready to get rerun testcode");
+            log.info("ready to analyse rerun testcode");
             HandleRerunSample(retList);
         }
         if (lisTable.equals("V_JT_QCMonthReport")){
-            log.info("ready to get QC month report");
+            log.info("ready to analyse QC month report");
             HandleMonthReport(retList);
         }
+        if (lisTable.equals("V_JT_OutOfControlReport")){
+            log.info("ready to analyse UnControl report");
+            HandleUnControlReport(retList);
+        }
     }
 
     public List<Map<String, Object>> cleanExistData(String lisTable, List<Map<String, Object>> lisList, List<Map<String, Object>> existList) {
@@ -108,6 +149,24 @@ public class HandleData {
             }
             return resultList;
         }
+        if (lisTable.equals("V_JT_OutOfControlReport")) {
+            // 1. 创建Set存储existList中所有 bian_zhi_shi_jian 的值(转换为字符串形式)
+            Set<String> existIdSet = new HashSet<>();
+            for (Map<String, Object> existMap : existList) {
+                Object idObj = existMap.get("bian_zhi_shi_jian");
+                existIdSet.add(idObj == null ? null : idObj.toString());
+            }
+            // 2. 过滤lisList:只保留 bian_zhi_shi_jian 不在 existIdSet 中的元素
+            List<Map<String, Object>> resultList = new ArrayList<>();
+            for (Map<String, Object> testMap : lisList) {
+                Object idObj = testMap.get("CREATETIME");
+                String idStr = idObj == null ? null : idObj.toString();
+                if (!existIdSet.contains(idStr)) {
+                    resultList.add(testMap);
+                }
+            }
+            return resultList;
+        }
         return null;
     }
 
@@ -134,11 +193,11 @@ public class HandleData {
                 String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("CREATEBY")));
                 String auditUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("AUDITUSER")));
                 if (createUserInfo.split("\\^")[0].equals("-1")) {
-                    log.info("error userInfo,skip to insert:"+createUserInfo);
+                    log.warn("error userInfo,skip to insert:"+createUserInfo);
                     continue;
                 }
                 if (auditUserInfo.split("\\^")[0].equals("-1")) {
-                    log.info("error auditUserInfo,skip to insert:"+auditUserInfo);
+                    log.warn("error auditUserInfo,skip to insert:"+auditUserInfo);
                     continue;
                 }
                 LocalDateTime currentDateTime = LocalDateTime.now();
@@ -160,6 +219,8 @@ public class HandleData {
             } else {
                 log.info("fail insert");
             }
+        }else{
+            log.info("No New Rerun Sample exist!");
         }
     }
 
@@ -201,6 +262,8 @@ public class HandleData {
                 log.info("fail insert t_dlxmsnzkyfx");
             }
 
+        }else{
+            log.info("No New MonthReport exist!");
         }
     };
 
@@ -281,6 +344,103 @@ public class HandleData {
         return "success";
     }
 
+    public void HandleUnControlReport(List<Map<String, Object>> retList){
+        if (retList.size() > 0) {
+            LocalDateTime currentDateTime = LocalDateTime.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            String formattedDateTime = currentDateTime.format(formatter);
+            Timestamp currentTimestamp = Timestamp.valueOf(currentDateTime);
+            long sequenceCounter = 0;
+            List<Map<String, Object>> insertList = new ArrayList<>();
+            for (Map<String, Object> retMap : retList) {
+                Map<String, Object> insertMap = new HashMap<>();
+                // 生成有序ID:时间戳+自增序列号
+                String orderedId = String.format("%d-%06d",
+                        currentTimestamp.getTime(),  // 使用时间戳
+                        sequenceCounter++            // 自增序列号
+                );
+                insertMap.put("id_", orderedId);
+                insertMap.put("id_", retMap.get("RESULT_NO"));
+                insertMap.put("create_time_", currentTimestamp); // 直接使用Timestamp,避免字符串转换
+                String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(retMap.get("CREATEUSER")));
+                if(createUserInfo.contains("未找到")){
+                    log.warn(createUserInfo);
+                    continue;
+                }
+                insertMap.put("create_by_", createUserInfo.split("@")[0]);
+                insertMap.put("bian_zhi_ren_", createUserInfo.split("@")[0]);
+                insertMap.put("bian_zhi_shi_jian", String.valueOf(retMap.get("CREATETIME")));
+                insertMap.put("di_dian_", ibpsRepository.getPosiByCode("LOCAL"));
+                insertMap.put("shi_fou_guo_shen_", "待推送");
+                insertMap.put("zhuan_ye_zu_", ibpsRepository.getPosiByCode(retMap.get("GROUP_ID").toString()));
+                insertMap.put("cao_zuo_zhe_", createUserInfo.split("@")[0]);
+                insertMap.put("yi_qi_ming_", retMap.get("TESTCODE"));
+                insertMap.put("xiang_mu_ming_", retMap.get("DEVICECODE"));
+                insertMap.put("zhi_kong_pin_ming", retMap.get("QCNAME"));
+                insertMap.put("zhi_kong_pi_hao_", retMap.get("QCLOT"));
+                String qcDate = (String) retMap.get("QCDATE");
+                String formatted = qcDate == null ? null :
+                        LocalDate.parse(qcDate, DateTimeFormatter.ofPattern("yyyyMMdd"))
+                                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                insertMap.put("shi_kong_ri_qi_", formatted);
+                insertMap.put("shi_kong_de_zhi_k", retMap.get("QCRESULT"));
+                insertMap.put("she_ding_ba_zhi_", retMap.get("STANDARD_SD"));
+                //定量解析
+                // 获取原始 QUANT 值
+                String quant = (String) retMap.get("QUANT");
+                Set<String> dingLiangSet = new LinkedHashSet<>(); // 用 LinkedHashSet 保持插入顺序,同时去重
+                List<String> qiTaList = new ArrayList<>();
+                if (quant != null && !quant.trim().isEmpty()) {
+                    String[] parts = quant.split(",");
+                    for (String part : parts) {
+                        String item = part.trim();
+                        if (item.isEmpty()) continue;
+                        if ("1-3s".equals(item)) {
+                            dingLiangSet.add("1");
+                        } else if ("2-2s".equals(item)) {
+                            dingLiangSet.add("2");
+                        } else if ("R-4s".equals(item)) {
+                            dingLiangSet.add("3");
+                        } else {
+                            // 其他情况:归为 4,并记录到 qi_ta_shuo_ming_
+                            dingLiangSet.add("4");
+                            qiTaList.add(item);
+                        }
+                    }
+                }
+                // 拼接 ding_liang_
+                String dingLiangStr = String.join(",", dingLiangSet);
+                // 拼接 qi_ta_shuo_ming_(去重?按需。这里保留所有出现的“其他”项,也可用 Set 去重)
+                String qiTaStr = String.join(",", qiTaList);
+                // 放入 insertMap
+                insertMap.put("ding_liang_", dingLiangStr);
+                insertMap.put("qi_ta_shuo_ming_", qiTaStr);
+
+                insertMap.put("qi_ta_miao_shu_", retMap.get("REASON"));
+                insertMap.put("chu_li_cuo_shi_", "6");
+                insertMap.put("qi_ta_cuo_shi_", retMap.get("ACTION"));
+                insertMap.put("chu_li_hou_zhi_ko", retMap.get("QCFINALRESULT"));
+                insertMap.put("shi_fou_zai_kong_", "是".equals(retMap.get("ISINCONTROL")) ? "2" : "1");
+                insertMap.put("shi_kong_shi_fou_","是".equals(retMap.get("AFFECTSPATIENTSAMPLES")) ? "2" : "1");
+                insertMap.put("shi_fou_ying_xian", "是".equals(retMap.get("AFFECTSRESULTREPORTING")) ? "2" : "1");
+                insertMap.put("shuo_ming_", retMap.get("NOTES"));
+                insertMap.put("fen_xi_yu_zhi_xin", retMap.get("ANALYSIS"));
+                insertList.add(insertMap);
+            }
+            if (!insertList.isEmpty()) {
+                String res = ibpsRepository.saveToTable(insertList, "t_snzkskbgvb", "1");
+//                String res = "1";
+                if ("success".equals(res)) {
+                    log.info("table:t_snzkskbgvb success insert: {} datas", insertList.size());
+                } else {
+                    log.error("fail insert t_snzkskbgvb");
+                }
+            }
+        } else {
+            log.info("No New Uncontrol Report exist!");
+        }
+    }
+
     // 辅助方法:安全获取字符串值,避免空指针异常
     private String getStringValue(Map<String, Object> map, String key) {
         Object value = map.get(key);

+ 199 - 0
GetDataByView/src/main/java/com/jyxt/getdatabyview/ImportRunner.java

@@ -0,0 +1,199 @@
+package com.jyxt.getdatabyview;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.List;
+import java.util.UUID;
+
+@Component
+public class ImportRunner{
+
+    private static final Logger log = LoggerFactory.getLogger(ImportRunner.class);
+
+    @Autowired
+    @Qualifier("secondJdbcTemplate")
+    private JdbcTemplate jdbcTemplate;
+
+
+//    @Override
+//    public void run(String... args) throws Exception {
+//        String currentDir = System.getProperty("user.dir");
+//        String filePath = currentDir + File.separator + "权限申请.txt";
+//        importPermissionRequest(filePath);
+//    }
+
+    public void importPermissionRequest(String filePath) {
+        try (BufferedReader reader = Files.newBufferedReader(Paths.get(filePath))) {
+            // 跳过表头
+            String header = reader.readLine();
+            if (header == null) {
+                log.warn("文件为空: {}", filePath);
+                return;
+            }
+
+            int lineNum = 1; // 当前数据行号(从1开始计数,对应文件第2行)
+            int insertedCount = 0;
+            int skippedCount = 0;
+            // 记录编号
+            Integer recordID=61;
+            String line;
+            while ((line = reader.readLine()) != null) {
+                lineNum++;
+                String[] fields = line.split("\t", -1); // 保留末尾空字段
+
+                // 至少需要9列(到“申请事由”)
+                if (fields.length < 9) {
+                    log.info("第 {} 行:字段数量不足({}个),跳过", lineNum, fields.length);
+                    skippedCount++;
+                    continue;
+                }
+
+                String applicant = trimToNull(fields[0]); // 申请人
+                String deptName = trimToNull(fields[1]);   // 申请部门
+//                if(!deptName.equals("微生物组")){
+//                    continue;
+//                }
+                String applyTimeStr = trimToNull(fields[2]); // 申请时间
+                // fields[3] 是邮箱(不用)
+                String jobNumber = trimToNull(fields[4]);  // 工号
+                String currentRole = trimToNull(fields[5]); // 现有角色
+                String system = trimToNull(fields[6]);     // 申请系统
+                String applyRole = trimToNull(fields[7]);  // 申请角色
+                String reason = trimToNull(fields[8]);     // 申请事由
+
+                // 必填校验
+                if (applicant == null) {
+                    log.info("第 {} 行:申请人为空,跳过", lineNum);
+                    skippedCount++;
+                    continue;
+                }
+                if (deptName == null) {
+                    log.info("第 {} 行:申请部门为空,跳过", lineNum);
+                    skippedCount++;
+                    continue;
+                }
+                if (applyTimeStr == null) {
+                    log.info("第 {} 行:申请时间为空,跳过", lineNum);
+                    skippedCount++;
+                    continue;
+                }
+
+                // 解析时间
+                LocalDateTime applyTime;
+                try {
+                    applyTime = LocalDateTime.parse(applyTimeStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
+                } catch (DateTimeParseException e) {
+                    log.info("第 {} 行:申请时间格式无效 '{}',跳过", lineNum, applyTimeStr);
+                    skippedCount++;
+                    continue;
+                }
+
+                // 查询员工ID(取第一个)
+                List<String> empIds = jdbcTemplate.query(
+                        "SELECT ID_ FROM ibps_party_employee WHERE NAME_ = ? LIMIT 1",
+                        (rs, rowNum) -> rs.getString("ID_"),
+                        applicant
+                );
+                if (empIds.isEmpty()) {
+                    log.info("第 {} 行:未在 ibps_party_employee 中找到申请人 '{}', 跳过", lineNum, applicant);
+                    skippedCount++;
+                    continue;
+                }
+                String employeeId = empIds.get(0);
+
+                // 查询部门ID(取第一个)
+                List<String> deptIds = jdbcTemplate.query(
+                        "SELECT ID_ FROM ibps_party_position WHERE NAME_ = ? LIMIT 1",
+                        (rs, rowNum) -> rs.getString("ID_"),
+                        deptName
+                );
+                if (deptIds.isEmpty()) {
+                    log.info("第 {} 行:未在 ibps_party_position 中找到部门 '{}', 跳过", lineNum, deptName);
+                    skippedCount++;
+                    continue;
+                }
+                String deptId = deptIds.get(0);
+
+                // 生成主键 ID_
+                String recordId = UUID.randomUUID().toString().replace("-", "");
+                if(system.equals("LIS系统")){
+                    // 插入
+                    String sql = "INSERT INTO t_xxxtqxsqb (ID_,bian_zhi_ren_, create_by_, bian_zhi_bu_men_,create_time_, bian_zhi_shi_jian,gong_hao_, gang_wei_,shen_qing_xi_tong, shen_qing_jiao_se, shen_qing_shi_you, shi_fou_guo_shen_,ji_lu_bian_hao_) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
+
+                    Object[] args = {
+                            recordId,
+                            employeeId,
+                            employeeId,
+                            deptId,
+                            Timestamp.valueOf(applyTime),
+                            applyTimeStr,
+                            jobNumber,
+                            currentRole,
+                            system,
+                            applyRole,
+                            reason,
+                            "待推送",
+                            "XTSQ-20251216-"+recordID.toString()
+                    };
+                    jdbcTemplate.update(sql, args);
+                    insertedCount++;
+                    recordID++;
+                }
+                if(system.equals("试剂管理系统")){
+                    // 插入
+                    String sql = "INSERT INTO t_xxxtqxsqb (ID_,bian_zhi_ren_, create_by_, bian_zhi_bu_men_,create_time_, bian_zhi_shi_jian,gong_hao_, gang_wei_,shen_qing_xi_tong, shen_qing_jiao_se, shen_qing_shi_you, shi_fou_guo_shen_,ji_lu_bian_hao_,qi_ta_jiao_se_) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?)";
+
+                    Object[] args = {
+                            recordId,
+                            employeeId,
+                            employeeId,
+                            deptId,
+                            Timestamp.valueOf(applyTime),
+                            applyTimeStr,
+                            jobNumber,
+                            currentRole,
+                            system,
+                            "其他",
+                            reason,
+                            "待推送",
+                            "XTSQ-20251216-"+recordID.toString(),
+                            applyRole
+                    };
+                    jdbcTemplate.update(sql, args);
+                    insertedCount++;
+                    recordID++;
+                }
+
+            }
+
+            log.info("TSV导入完成:成功 {} 行,跳过 {} 行。文件: {}", insertedCount, skippedCount, filePath);
+
+        } catch (IOException e) {
+            log.error("读取文件失败: " + filePath, e);
+            throw new RuntimeException("导入失败", e);
+        }
+    }
+
+    private String trimToNull(String str) {
+        if (str == null) return null;
+        String trimmed = str.trim();
+        return trimmed.isEmpty() ? null : trimmed;
+    }
+
+
+}

+ 21 - 5
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/IBPSRepository.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Repository;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Timestamp;
+import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -37,16 +38,24 @@ public class IBPSRepository {
 
     public List<Map<String, Object>> qryExistData(String lisTable){
         List<Map<String, Object>> existList = null;
+        //V_JT_TestCodeRerunRecord
         if(lisTable.equals("V_JT_TestCodeRerunRecord")){
             String sqlQry = "SELECT * FROM t_fjbbjlb WHERE bian_zhi_shi_jian >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
             log.info("excute sql:"+sqlQry);
             existList = jdbcTemplate.queryForList(sqlQry);
         }
+        //V_JT_QCMonthReport
         if(lisTable.equals("V_JT_QCMonthReport")){
             String sqlQry = "select id_ from t_dlxmsnzkyfx";
             log.info("excute sql:"+sqlQry);
             existList = jdbcTemplate.queryForList(sqlQry);
         }
+        //V_JT_OutOfControlReport
+        if(lisTable.equals("V_JT_OutOfControlReport")){
+            String sqlQry = "select bian_zhi_shi_jian from t_snzkskbgvb WHERE create_time_ >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
+            log.info("excute sql:"+sqlQry);
+            existList = jdbcTemplate.queryForList(sqlQry);
+        }
         return existList;
     }
 
@@ -100,9 +109,12 @@ public class IBPSRepository {
                         String key = entry.getKey();
                         Object value = entry.getValue();
 
-                        if (key.contains("Time") && value instanceof Timestamp) {
+                        if (value == null) {
+                            ps.setNull(index++, Types.VARCHAR);
+                        } else if (value instanceof Timestamp) {
                             ps.setTimestamp(index++, (Timestamp) value);
                         } else {
+                            // 其他所有类型转字符串(包括 Integer, Boolean, Date, String 等)
                             ps.setString(index++, value.toString());
                         }
                     }
@@ -159,19 +171,23 @@ public class IBPSRepository {
                     // 设置SET部分的参数
                     for (String column : columns) {
                         Object value = row.get(column);
-                        if (column.contains("Time") && value instanceof Timestamp) {
+                        if (value == null) {
+                            ps.setNull(index++, Types.VARCHAR);
+                        } else if (value instanceof Timestamp) {
                             ps.setTimestamp(index++, (Timestamp) value);
                         } else {
-                            ps.setString(index++, value != null ? value.toString() : null);
+                            ps.setString(index++, value.toString());
                         }
                     }
 
                     // 设置WHERE条件的id_参数
                     Object idValue = row.get("id_");
-                    if (idValue instanceof Timestamp) {
+                    if (idValue == null) {
+                        ps.setNull(index, Types.VARCHAR);
+                    } else if (idValue instanceof Timestamp) {
                         ps.setTimestamp(index, (Timestamp) idValue);
                     } else {
-                        ps.setString(index, idValue != null ? idValue.toString() : null);
+                        ps.setString(index, idValue.toString());
                     }
                 }
 

+ 15 - 2
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/LISViewRepository.java

@@ -48,7 +48,7 @@ public class LISViewRepository {
         }
         //月分析主表
         if(tableName.equals("V_JT_QCMonthReport")) {
-            // 新增条件判断:当需要检查首日时,验证当前日期是否为1
+            // 新增条件判断:当需要检查首日时,验证当前日期是否为2
             if ("1".equals(onlyQrySecondDay)) {
                 Calendar calendar = Calendar.getInstance();
                 int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
@@ -70,6 +70,19 @@ public class LISViewRepository {
                 return retList;
             }
         }
+        //V_JT_OutOfControlReport
+        if(tableName.equals("V_JT_OutOfControlReport")) {
+            try{
+                String sqlQry = "SELECT * FROM V_JT_OutOfControlReport WHERE CreateTime >= SYSDATE-1 and CreateTime <= SYSDATE";
+                log.info("excute sql:"+sqlQry);
+                retList = jdbcTemplate.queryForList(sqlQry);
+                return retList;
+            } catch (Exception e) {
+                log.error(e.getMessage());
+                e.printStackTrace();
+                return retList;
+            }
+        }
         return retList;
     }
 
@@ -96,7 +109,7 @@ public class LISViewRepository {
             int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
             if (currentDay != 2) {
                 log.info("非当月第二日,跳过查询");
-                return resultList;  // 非1号直接返回空列表
+                return resultList;  // 非2号直接返回空列表
             }
         }
         if(1==2){

+ 2 - 1
GetDataByView/src/main/resources/application.properties

@@ -24,4 +24,5 @@ showTestCodeName=1
 delayLimit=10
 #yyyy?M??
 manualQryMonth=
-resultWithUnit=0
+resultWithUnit=0
+importMode=0