From 36ccc814cb2499757a0cfd5525d5e8d0c2309b64 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 27 十一月 2024 16:02:42 +0800
Subject: [PATCH] 企业微信的消息提醒的信息改成单号样品名+检验下单的模版保存,如果存在同名的情况,将原有的情况覆盖掉,并添加提示框+首页展示添加样品名称

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  136 +++++++++++++++++++++++++++++++++------------
 1 files changed, 99 insertions(+), 37 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 5036ca7..9f01917 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;
@@ -307,6 +315,9 @@
         if (ObjectUtils.isNotEmpty(sampleId)) {
             insOrderFile.setInsSampleId(sampleId);
         }
+        if (ObjectUtils.isNotEmpty(sonLaboratory)) {
+            insOrderFile.setSonLaboratory(sonLaboratory);
+        }
         insOrderFile.setFileName(filename);
         if (contentType != null && contentType.startsWith("image/")) {
             // 鏄浘鐗�
@@ -396,7 +407,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 +486,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 +739,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 +789,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 +853,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 +926,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 +1012,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 +1093,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 +1143,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 +1158,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 +1182,6 @@
                 throw new ErrorException("鐢佃矾璇曢獙鐨勭珯鐐规姤鍛婄敓鎴愭湁璇�,璇疯仈绯诲紑鍙戜汉鍛樿皟鏁�!");
             }
         }
-        /*// 鍒犻櫎鏁伴噰閲囬泦娆℃暟
-        String key = "frequency" + ":" + submitPlanDto.getEntrustCode() + ":*";
-        RedisUtil.delsLike(key);*/
 
         /*鐢熸垚浜ч噺宸ユ椂*/
         //鏍¢獙濡傛灉杩欎釜浜鸿繖涓娴嬮」鐩凡缁忔坊鍔犺繃浜嗗垯涓嶉渶瑕佸啀鏂板
@@ -1145,27 +1208,26 @@
                 }
                 for (AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours : submitPlanDto.getAuxiliaryOutputWorkingHoursList()) {
                     InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours.getInsProductId());
-                    if (isWithinRange) {
-                        //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮
-                        auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
-                        auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//闈炲姞鐝伐鏃�
-                        auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
-                    } else {
-                        //鍔犵彮
-                        auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿
-                        auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//鍔犵彮宸ユ椂
-                        auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺
-                    }
-                    auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
-                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-                    DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-                    auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡
-                    LocalDateTime localDateTime = LocalDateTime.now();
-                    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);
+                        if (isWithinRange) {
+                            //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮
+                            auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
+                            auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//闈炲姞鐝伐鏃�
+                            auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
+                        } else {
+                            //鍔犵彮
+                            auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿
+                            auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//鍔犵彮宸ユ椂
+                            auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺
+                        }
+                        auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                        auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//鏃ユ湡
+                        LocalDateTime localDateTime = LocalDateTime.now();
+                        DateTime parse = DateUtil.parse(localDateTime.format(formatter));
+                        auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
+                        auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
+                        auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
                 }
             }
         }

--
Gitblit v1.9.3