From 37c0a1b706f4a16cc3df7e03bbbaec204f897e8e Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 04 十二月 2024 16:50:32 +0800
Subject: [PATCH] 调整检验任务的检验时间

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  108 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 88 insertions(+), 20 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
index 69a5707..2f368f1 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -27,6 +27,9 @@
 import com.yuanchu.mom.service.*;
 import com.yuanchu.mom.utils.*;
 import com.yuanchu.mom.vo.*;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Value;
@@ -78,6 +81,8 @@
     private ShiftTimeMapper shiftTimeMapper;
     @Resource
     private PerformanceShiftMapper performanceShiftMapper;
+    @Resource
+    private WarehouseHistoryMapper warehouseHistoryMapper;
 
     @Resource
     private WarehouseService warehouseService;
@@ -87,6 +92,9 @@
 
     @Resource
     WordUtils wordUtils;
+
+    @Resource
+    private InsReportMapper insReportMapper;
 
     @Resource
     private InsProductResultMapper insProductResultMapper;
@@ -177,6 +185,12 @@
         if (BeanUtil.isEmpty(order.getInsTime())) {
             insOrder.setInsTime(LocalDateTime.now());//璁㈠崟鐨勬楠屾椂闂�
             insOrderMapper.updateById(insOrder);
+        }
+        InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
+                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                .eq(InsOrderState::getInsSampleId, sampleId)
+                .eq(InsOrderState::getLaboratory, laboratory));
+        if (ObjectUtils.isEmpty(orderState.getInsTime())){
             //鏇存柊妫�楠屼换鍔¤〃鐨勬楠屾椂闂�
             insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
                     .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
@@ -290,7 +304,7 @@
             sampleId = insOrderFile.getInsSampleId();
             insOrderFile.setInsSampleId(null);
         }
-        IPage<InsOrderFile> insOrderFileIPage = insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile), insOrderId, sonLaboratory,sampleId);
+        IPage<InsOrderFile> insOrderFileIPage = insOrderFileMapper.getFileList(page, QueryWrappers.queryWrappers(insOrderFile), insOrderId, sonLaboratory, sampleId);
         map.put("body", insOrderFileIPage);
         return map;
     }
@@ -307,6 +321,9 @@
         if (ObjectUtils.isNotEmpty(sampleId)) {
             insOrderFile.setInsSampleId(sampleId);
         }
+        if (ObjectUtils.isNotEmpty(sonLaboratory)) {
+            insOrderFile.setSonLaboratory(sonLaboratory);
+        }
         insOrderFile.setFileName(filename);
         if (contentType != null && contentType.startsWith("image/")) {
             // 鏄浘鐗�
@@ -322,7 +339,7 @@
             if (!realpath.exists()) {
                 realpath.mkdirs();
             }
-            pathName = UUID.randomUUID() + "_"+file.getOriginalFilename().replace("#", "&");
+            pathName = UUID.randomUUID() + "_" + file.getOriginalFilename().replace("#", "&");
             urlString = realpath + "/" + pathName;
             file.transferTo(new File(urlString));
             insOrderFile.setFileUrl(pathName);
@@ -332,7 +349,7 @@
             if (ObjectUtils.isNotEmpty(sonLaboratory) && (sonLaboratory.equals("杩戝満") || sonLaboratory.equals("杩滃満")) &&
                     split[split.length - 1].equals("csv")) {
                 //鍒ゆ柇鏄摢绉峜sv鏂囦欢,鏄惁鏈夆�斺��
-                if (!file.getOriginalFilename().contains("鈥斺��")) {
+                if (sonLaboratory.equals("杩戝満")) {
                     fuSheUtils.getFuSheWord1(sonLaboratory, insOrderFile);
                 } else {
                     fuSheUtils.getFuSheWord2(sonLaboratory, insOrderFile);
@@ -396,7 +413,7 @@
         } else {
             InsOrderState insOrderState = new InsOrderState();
             insOrderState.setInsOrderId(insSample.getInsOrderId());
-            insOrderState.setInsOrderId(insSample.getId());
+            insOrderState.setInsSampleId(insSample.getId());
             insOrderState.setLaboratory(sonLaboratory);
             insOrderState.setInsState(0);
             insOrderState.setNum(1);//鍒濆鏄涓�娆�
@@ -475,11 +492,60 @@
                 //鑾峰彇鏈�鍚庝竴琛岀殑num锛屽嵆鎬昏鏁般�傛澶勪粠0寮�濮�
                 int maxRow = sheet.getLastRowNum();
                 for (int row = 0; row <= maxRow; row++) {
+                    XSSFRow xssfRow = sheet.getRow(row);
                     //鑾峰彇鏈�鍚庡崟鍏冩牸num锛屽嵆鎬诲崟鍏冩牸鏁� ***娉ㄦ剰锛氭澶勪粠1寮�濮嬭鏁�***
                     int maxRol = sheet.getRow(row).getLastCellNum();
                     StringBuilder aLine = new StringBuilder();
-                    for (int rol = 0; rol < maxRol; rol++) {
+                    /*for (int rol = 0; rol < maxRol; rol++) {
                         aLine.append(sheet.getRow(row).getCell(rol)).append(",");
+                    }*/
+                    for (int rol = 0; rol < maxRol; rol++) {
+                        XSSFCell cell = xssfRow.getCell(rol);
+                        if (cell == null) {
+                            aLine.append(",");
+                        } else {
+                            switch (cell.getCellType()) {
+                                case FORMULA:
+                                    // 璁$畻鍏紡骞惰幏鍙栫粨鏋�
+                                    CellValue cellValue = xssfWorkbook.getCreationHelper().createFormulaEvaluator().evaluate(cell);
+                                    switch (cellValue.getCellType()) {
+                                        case NUMERIC:
+                                            String formattedValue = String.format("%.4f", cellValue.getNumberValue());
+                                            aLine.append(formattedValue);
+                                            break;
+                                        case STRING:
+                                            aLine.append(cellValue.getStringValue());
+                                            break;
+                                        case BOOLEAN:
+                                            aLine.append(cellValue.getBooleanValue());
+                                            break;
+                                        case ERROR:
+                                            aLine.append("#ERR!");
+                                            break;
+                                        default:
+                                            aLine.append("");
+                                            break;
+                                    }
+                                    break;
+                                case NUMERIC:
+                                    String formattedValue = String.format("%.4f", cell.getNumericCellValue());
+                                    aLine.append(formattedValue);
+                                    break;
+                                case STRING:
+                                    aLine.append(cell.getStringCellValue());
+                                    break;
+                                case BOOLEAN:
+                                    aLine.append(cell.getBooleanCellValue());
+                                    break;
+                                case ERROR:
+                                    aLine.append("#ERR!");
+                                    break;
+                                default:
+                                    aLine.append("");
+                                    break;
+                            }
+                            aLine.append(",");
+                        }
                     }
                     String substring = aLine.substring(0, aLine.length() - 1);
                     result.append(substring).append("\n");
@@ -679,16 +745,15 @@
             throw new ErrorException("棰戠巼涓嶈兘涓虹┖");
         }
         Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
+        //鏌ヨ鏍峰搧淇℃伅
+        InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId());
         //鏌ヨ妫�楠屽崟淇℃伅
-        InsOrder insOrder = insOrderMapper.selectById(insProductResultDtos.getOrderId());
         InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
-                .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId())
+                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                 .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId())
                 .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory())
                 .orderByDesc(InsOrderState::getId)
                 .last("LIMIT 1"));// 纭繚鍙彇涓�鏉¤褰�
-        //鏌ヨ鏍峰搧淇℃伅
-        InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId());
         List<Integer> list = new ArrayList<>();
         /*鏂板妫�楠岄」鐩楠屽�艰褰曡〃(閲囧彇鍏堝垹鍚庡)*/
         insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery()
@@ -730,8 +795,9 @@
                 //缁撹
                 int ressult = 1;
                 String valueStr = insProductResult2.getValue();
+                String regex = "[\u4e00-\u9fa5]";
                 if (!insProduct.getAsk().contains(",")) {
-                    if (insProduct.getAsk().equals("/")) {
+                    if (insProduct.getAsk().equals("/") || Pattern.compile(regex).matcher(insProduct.getAsk()).find()) {
                         ressult = 3; //涓嶅垽瀹�
                     } else if (!isValueValid(valueStr, new String[]{insProduct.getAsk()})) {
                         ressult = 0; //涓嶅悎鏍�
@@ -793,10 +859,10 @@
             insSampleMapper.updateById(insSample);
         }
         /*鍒ゆ柇璇ョ珯鐐圭殑妫�楠岄」鐩槸鍚﹀叏閮ㄥ凡妫�*/
-        int count = insProductMapper.selectInsProductCountByOrderId(insProductResultDtos.getOrderId());
+        int count = insProductMapper.selectInsProductCountByOrderId(insSample.getInsOrderId());
         if (count == 0) {
             insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate()
-                    .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId())
+                    .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                     .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId())
                     .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory())
                     .set(InsOrderState::getInsState, 2));
@@ -866,7 +932,7 @@
             if (ObjectUtils.isEmpty(s)) {
                 continue;
             }
-            double numericValue = Double.parseDouble(s);
+            double numericValue = Math.abs(Double.parseDouble(s));
             boolean valid = Arrays.stream(valuesToCheck)
                     .allMatch(v -> getResult(numericValue, v));
             if (!valid) {
@@ -952,7 +1018,7 @@
                             .set(InsOrderState::getCreateTime, LocalDateTime.now()));
                     break;
                 case 1:
-                    //缁х画璇曢獙:璇ョ珯鐐逛换鍔$粨鏉�(鍙互鍐嶆鎵爜妫�楠�)锛�
+                    //缁х画璇曢獙:璇ユ牱鍝佽绔欑偣浠诲姟缁撴潫(鍙互鍐嶆鎵爜妫�楠�)锛�
                     insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
                             .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                             .eq(InsOrderState::getInsSampleId, sampleId)
@@ -1033,6 +1099,11 @@
         List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                 .eq(InsProduct::getInsSampleId, insSample.getId())
                 .eq(InsProduct::getSonLaboratory, submitPlanDto.getLaboratory())
+                .and(wrapper -> wrapper
+                        .isNull(InsProduct::getInsResult)
+                        .or()
+                        .eq(InsProduct::getInsResult, 2)
+                )
                 .eq(InsProduct::getState, 1));
         if (insProducts.size() > 0) {
             String str = "";
@@ -1078,7 +1149,7 @@
         info.setCreateUser(insProductMapper.selectUserById(userId).get("name"));
         info.setMessageType("2");
         info.setTheme("澶嶆牳閫氱煡");
-        info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅");
+        info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample());
         info.setSenderId(userId);
         info.setConsigneeId(submitPlanDto.getVerifyUser());
         info.setViewStatus(false);
@@ -1093,7 +1164,8 @@
         map.put("msgtype", "text");//娑堟伅绫诲瀷 text:鏂囨湰
         map.put("agentid", 1000517);//搴旂敤id
         HashMap<String, Object> hashMap = new HashMap<>();
-        hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",璇峰墠寰�LIMS绯荤粺鏌ョ湅銆�<a href=\"https://ztwxlims.ztt.cn:7443/enter\">涓ぉ閫氫俊LIMS绯荤粺 </a>");
+        hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample() +
+                ",璇峰墠寰�LIMS绯荤粺鏌ョ湅銆傝鐐瑰嚮<a href=\"https://ztwxlims.ztt.cn:7443/enter\">涓ぉ閫氫俊LIMS绯荤粺 </a>");
         map.put("text", hashMap);//娑堟伅鍐呭
         map.put("safe", 0);//鏄惁淇濆瘑娑堟伅.0鍚�
         map.put("enable_id_trans", 0);//鏄惁寮�鍚痠d杞瘧.0鍚�
@@ -1116,9 +1188,6 @@
                 throw new ErrorException("鐢佃矾璇曢獙鐨勭珯鐐规姤鍛婄敓鎴愭湁璇�,璇疯仈绯诲紑鍙戜汉鍛樿皟鏁�!");
             }
         }
-        /*// 鍒犻櫎鏁伴噰閲囬泦娆℃暟
-        String key = "frequency" + ":" + submitPlanDto.getEntrustCode() + ":*";
-        RedisUtil.delsLike(key);*/
 
         /*鐢熸垚浜ч噺宸ユ椂*/
         //鏍¢獙濡傛灉杩欎釜浜鸿繖涓娴嬮」鐩凡缁忔坊鍔犺繃浜嗗垯涓嶉渶瑕佸啀鏂板
@@ -1164,7 +1233,6 @@
                     DateTime parse = DateUtil.parse(localDateTime.format(formatter));
                     auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
                     auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
-                    auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
                     auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
                 }
             }

--
Gitblit v1.9.3