From 1117418aaaba5a8bce27bac222ac21fe68cff960 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 21 五月 2025 10:03:23 +0800
Subject: [PATCH] 消息提醒加两个字段

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  364 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 308 insertions(+), 56 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 dd80cec..3232b3b 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
@@ -24,6 +24,7 @@
 import com.yuanchu.mom.service.*;
 import com.yuanchu.mom.utils.*;
 import com.yuanchu.mom.vo.*;
+import org.apache.poi.hwpf.usermodel.*;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -35,6 +36,7 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import java.io.*;
 import java.nio.file.Files;
@@ -48,6 +50,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+
+import org.apache.poi.hwpf.HWPFDocument;
 
 /**
  * 妫�楠屼换鍔�-涓氬姟瀹炵幇灞�
@@ -142,7 +146,9 @@
         }
         String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
         insOrderPlanDTO.setSonLaboratory(null);
-        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory);
+        String sampleCode = insOrderPlanDTO.getSampleCode();
+        insOrderPlanDTO.setSampleCode(null);
+        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory,sampleCode);
         map.put("body", insOrderPage);
         return map;
     }
@@ -311,6 +317,7 @@
 
     @Override
     public Object uploadFile(Integer orderId, MultipartFile file, String sonLaboratory, Integer sampleId) {
+        InsOrder insOrder = insOrderMapper.selectById(orderId);
         String urlString;
         String pathName;
         String path;
@@ -345,7 +352,7 @@
             insOrderFile.setFileUrl(pathName);
             insOrderFileMapper.insert(insOrderFile);
             String[] split = filename.split("\\.");
-            if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("杩戝満") && split[split.length - 1].equals("csv")) {
+            if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("杩戝満") && (split[split.length - 1].equals("csv") || split[split.length - 1].equals("xlsx"))) {
                 fuSheUtils.getFuSheWord1(sonLaboratory, insOrderFile);
             } else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("杩滃満") && split[split.length - 1].equals("xlsx")) {
                 fuSheUtils.getFuSheWord2(sonLaboratory, insOrderFile);
@@ -353,6 +360,16 @@
                 dianLuUtils.readDianLuFile1(sampleId, insOrderFile);
             } else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("鐢佃矾璇曢獙") && split[split.length - 1].equals("csv") && filename.contains("椹绘尝")) {
                 dianLuUtils.readDianLuFile2(sampleId, insOrderFile);
+            } else if (ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("鐢佃矾璇曢獙") && split[split.length - 1].equals("csv") && insOrder.getSampleType().equals("鏃犳簮鍣ㄤ欢")) {
+                dianLuUtils.readDianLuFile3(sampleId, insOrderFile);
+            }
+            // 鐢佃矾瀹為獙杩斿洖鏂囦欢鍚�
+            if(ObjectUtils.isNotEmpty(sonLaboratory) && sonLaboratory.equals("鐢佃矾璇曢獙")){
+                return pathName;
+            }
+            // 闇囧姩doc鏂囦欢瑙f瀽
+            if(filename.toLowerCase().contains(".doc") && sonLaboratory.equals("鎸姩")){
+                return docAnalysis(urlString,orderId,sampleId,file.getOriginalFilename());
             }
         } catch (Exception e) {
             throw new ErrorException(e.getMessage());
@@ -410,6 +427,7 @@
             if (orderState.getInsState() == 6) {
                 orderState.setInsState(0);
                 orderState.setNum(orderState.getNum() + 1);//閫掑
+                orderState.setCreateTime(LocalDateTime.now());
                 insOrderStateMapper.updateById(orderState);
             }
         } else {
@@ -421,10 +439,17 @@
             insOrderState.setNum(1);//鍒濆鏄涓�娆�
             insOrderStateMapper.insert(insOrderState);
         }
+        //鍚屼竴鏍峰搧鍦ㄥ叾浠栫珯鐐瑰叆搴撲箣鍚庨渶瑕佸皢鍏朵粬绔欑偣鐨勪换鍔′笉鏄剧ず
+        insOrderStateMapper.update(null,Wrappers.<InsOrderState>lambdaUpdate()
+        .eq(InsOrderState::getInsOrderId,insSample.getInsOrderId())
+        .eq(InsOrderState::getInsSampleId,insSample.getId())
+        .eq(InsOrderState::getInsState,6)//澶嶆牳缁х画璇曢獙
+        .ne(InsOrderState::getLaboratory,sonLaboratory)
+        .set(InsOrderState::getIsOut,1));//涓嶆樉绀�
         return 1;
     }
 
-    //鎵爜鍑哄簱
+    //鎵爜鍑哄簱(鍙湁澶嶆牳缁撴潫鎵嶄細璋冪敤)
     @Override
     public int outInsOrderState(String sonLaboratory, String sampleCode, String entrustCode) {
         //鍒ゆ柇璇ユ牱鍝佺殑妫�楠屼换鍔℃槸鍚﹀凡缁忕粨鏉�(缁х画璇曢獙鎴栬�呮槸缁撴潫璇曢獙)
@@ -439,22 +464,18 @@
         if (!collect.contains(sonLaboratory)) {
             throw new ErrorException("璇ユ牱鍝佹病鏈�" + sonLaboratory + "绔欑偣鐨勭浉鍏抽」鐩�,璇锋煡鐪嬩笅鍗曡鎯�!");
         }
+        //鍒ゆ柇璇ヤ换鍔℃槸鍚︽槸缁撴潫璇曢獙
         //鍒ゆ柇璇ヨ鍗曟槸鍚︾珯鐐逛换鍔℃湁(缁х画璇曢獙鎴栬�呮槸缁撴潫璇曢獙)
-        List<InsOrderState> orderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
-                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
-                .eq(InsOrderState::getInsState, 5));//缁撴潫璇曢獙
-        if (CollectionUtils.isEmpty(orderStates)) {
-            List<InsOrderState> orderStates1 = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
-                    .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
-                    .eq(InsOrderState::getInsSampleId, insSample.getId())
-                    .eq(InsOrderState::getLaboratory, sonLaboratory)
-                    .eq(InsOrderState::getInsState, 6));//缁х画璇曢獙
-            if (CollectionUtils.isEmpty(orderStates1)) {
-                throw new ErrorException("璇ユ牱鍝佺殑妫�楠屼换鍔¤繕娌℃湁缁撴潫璇曢獙鎴栫户缁瘯楠�,鏆傛椂鏃犳硶鍑哄簱!");
-            }
+        InsOrderState orderStates = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
+                .eq(InsOrderState::getLaboratory,sonLaboratory)
+                .eq(InsOrderState::getInsSampleId, insSample.getId())
+                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId()));
+        if (orderStates.getInsState()!=5) {
+                throw new ErrorException("褰撳墠鏍峰搧鐨勭珯鐐逛换鍔″苟涓嶆槸澶嶆牳鐨勭粨鏉熻瘯楠�,鏃犻渶鎵嬪姩鍑哄簱!");
         }
-        boolean a = true;
-        warehouseService.outWarehouse(sampleCode, a, entrustCode);
+        orderStates.setIsOut(1);
+        insOrderStateMapper.updateById(orderStates);//澶嶆牳缁撴潫鍑哄簱涔嬪悗鍒楄〃涓嶆樉绀�
+        warehouseService.outWarehouse(sampleCode, true, entrustCode);
         return 0;
     }
 
@@ -648,6 +669,16 @@
                     }
                 } catch (Exception e) {
                     result.setAfterCheck("");//''
+                }
+                //瀹為獙缁撴灉
+                try {
+                    JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("testResult")));
+                    if (resValue.get("v") != null) {
+                        Object o = JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v");
+                        result.setTestResult(o.equals("") ? null : (o.toString()));
+                    }
+                } catch (Exception e) {
+                    result.setTestResult("");//''
                 }
                 //璁惧缂栧彿
                 if (jo.get("equipValue") != null) {
@@ -888,7 +919,123 @@
         for (InsProductResultDto insProductResultDto : insProductResultDtos.getInsProductResultDtos()) {
             saveInsContext2(insProductResultDto);
         }
-       return  1;
+        return 1;
+    }
+
+    /**
+     * 闇囧姩doc鏂囦欢瑙f瀽
+     * @param urlString
+     * @param orderId
+     * @param sampleId
+     * @param originFileName
+     * @return
+     */
+    private Map<String, String> docAnalysis(String urlString,Integer orderId,Integer sampleId,String originFileName) {
+        Map<String, String> analysisMap = new HashMap<>();
+        try {
+            File file = new File(urlString);
+            HWPFDocument document = new HWPFDocument(new FileInputStream(file));
+            Range range = document.getRange();
+            TableIterator tableIterator = new TableIterator(range);
+            List<Table> tableList = new ArrayList<>();
+            while (tableIterator.hasNext()) {
+                tableList.add(tableIterator.next());
+            }
+            for (int tableIndex = 0; tableIndex < tableList.size(); tableIndex++) {
+                // 鍙栫涓�涓〃鍗曢檺鍒跺弬鏁扮殑  鎸姩鍙板瀷鍙枫�佽繍鍔ㄩ儴浠剁瓑鏁堣川閲忋�佽瘯浠惰川閲忔暟鍊�
+                if(tableIndex == 0){
+                    Table table = tableList.get(0);
+                    for (int i = 0; i < table.numRows(); i++) {
+                        if(table.getRow(i).numCells() < 2){
+                            continue;
+                        }
+                        String columnText = ObjectUtils.isEmpty(table.getRow(i).getCell(0))? "" : table.getRow(i).getCell(0).text();
+                        String columnValue = ObjectUtils.isEmpty(table.getRow(i).getCell(1))? "" : table.getRow(i).getCell(1).text();
+                        if(columnValue.contains("\u0007")){
+                            columnValue = columnValue.replace("\u0007","");
+                        }
+                        if(columnText.contains("\u0007")){
+                            columnText = columnText.replace("\u0007","");
+                        }
+                        if(columnText.equals("鎸姩鍙板瀷鍙�")){
+                            analysisMap.put("11",columnValue);
+                        }
+                        if(columnText.equals("杩愬姩閮ㄤ欢绛夋晥璐ㄩ噺")){
+                            analysisMap.put("12",columnValue);
+                        }
+                        if(columnText.equals("璇曚欢璐ㄩ噺")){
+                            analysisMap.put("1",columnValue);
+                        }
+                    }
+                }
+                //鍙栫涓�涓〃鍗曡緭鍏ラ�氶亾鍙傛暟绗竴鏉℃暟鎹�
+                if(tableIndex == 1){
+                    Table table = tableList.get(1);
+                    if(ObjectUtils.isNotEmpty(table) && table.numRows() > 1 && table.getRow(1).numCells() >= 3){
+                        String columnValue = ObjectUtils.isEmpty(table.getRow(1).getCell(2))? "" : table.getRow(1).getCell(2).text();
+                        if(columnValue.contains("\u0007")){
+                            columnValue = columnValue.replace("\u0007","");
+                        }
+                        analysisMap.put("9",columnValue);
+                    }
+                }
+                // 鍙栨渶鍚庝竴涓〃鍗曠涓夌鍥涜淇℃伅
+                if(tableIndex == tableList.size() - 1){
+                    Table table = tableList.get(tableIndex);
+                    for (int i = 0; i < table.numRows(); i++) {
+                        if(table.getRow(i).numCells() < 2){
+                            continue;
+                        }
+                        String columnText = ObjectUtils.isEmpty(table.getRow(i).getCell(0))? "" : table.getRow(i).getCell(0).text();
+                        String columnValue = ObjectUtils.isEmpty(table.getRow(i).getCell(1))? "" : table.getRow(i).getCell(1).text();
+                        if(columnValue.contains("\u0007")){
+                            columnValue = columnValue.replace("\u0007","");
+                        }
+                        if(columnText.contains("\u0007")){
+                            columnText = columnText.replace("\u0007","");
+                        }
+                        if(columnText.contains("鎬昏繍琛屾椂闂�")){
+                            analysisMap.put("13",columnValue);
+                        }
+                        if(columnText.contains("璇曢獙鎵鏁�")){
+                            analysisMap.put("10",columnValue);
+                        }
+                    }
+                }
+            }
+            // 鍥剧墖缁戝畾
+            List<Picture> pictureList = document.getPicturesTable().getAllPictures();
+            String[] split = originFileName.split("\\.");
+            String docName = "";
+            if(null != split && split.length > 0){
+                docName = split[0];
+            }
+            for (Picture picture : pictureList) {
+                byte[] pictureData = picture.getContent();
+                File imgDir = new File(imgUrl);
+                if (!imgDir.exists()) {
+                    imgDir.mkdirs();
+                }
+                String filename = docName + "_" + UUID.randomUUID()+".png";
+                File pictureFile = new File(imgUrl + File.separatorChar + filename);
+                // 鍒涘缓杈撳嚭娴佷互灏嗗浘鐗囨暟鎹啓鍏ュ埌鎸囧畾璺緞
+                try (OutputStream outputStream = new FileOutputStream(pictureFile)) {
+                    // 鍐欏叆鏁版嵁
+                    outputStream.write(pictureData);
+                }
+                InsOrderFile insOrderFile = new InsOrderFile();
+                insOrderFile.setInsOrderId(orderId);
+                insOrderFile.setInsSampleId(sampleId);
+                insOrderFile.setSonLaboratory("鎸姩");
+                insOrderFile.setType(1);
+                insOrderFile.setFileName(filename);
+                insOrderFile.setFileUrl(filename);
+                insOrderFileMapper.insert(insOrderFile);
+            }
+        }catch (Exception e){
+            log.error(e.getMessage());
+        }
+        return analysisMap;
     }
 
     //娓╂箍搴﹁瘯楠�+鍔熺巼璇曢獙鐨勪繚瀛樻楠屽唴瀹�
@@ -917,19 +1064,19 @@
             }
         }
         // 澶勭悊鍏朵粬姣旇緝鏉′欢
-        if (ask.startsWith(">")) {
+        if (ask.startsWith(">") || ask.startsWith("锛�")) {
             double threshold = Double.parseDouble(ask.substring(1));
             return s > threshold;
         } else if (ask.startsWith("鈮�")) {
             double threshold = Double.parseDouble(ask.substring(1));
             return s >= threshold;
-        } else if (ask.startsWith("<")) {
+        } else if (ask.startsWith("<")|| ask.startsWith("锛�")) {
             double threshold = Double.parseDouble(ask.substring(1));
             return s < threshold;
         } else if (ask.startsWith("鈮�")) {
             double threshold = Double.parseDouble(ask.substring(1));
             return s <= threshold;
-        } else if (ask.equals("=")) {
+        } else if (ask.equals("=")|| ask.startsWith("锛�")) {
             double exactValue = Double.parseDouble(ask.substring(1));
             return s == exactValue;
         }
@@ -976,7 +1123,7 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) throws IOException {
+    public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell)  {
         LocalDateTime now = LocalDateTime.now();
         Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
         List<InsUnPass> insUnPasses = new ArrayList<>();
@@ -1047,6 +1194,15 @@
                             .set(InsOrderState::getInsState, 6)
                             .set(InsOrderState::getVerifyTell, tell)
                             .set(InsOrderState::getVerifyUser, userId));
+                    //缁х画璇曢獙鑷姩鍑哄簱
+                    WarehouseHistory history = new WarehouseHistory();
+                    history.setState(2);
+                    history.setInsSampleId(sampleId);
+                    history.setCellId(insSample.getCellId());
+                    history.setWarehouseCode(warehouseHistoryMapper.selectOne(Wrappers.<WarehouseHistory>lambdaQuery()
+                            .eq(WarehouseHistory::getInsSampleId, sampleId).select(WarehouseHistory::getWarehouseCode).orderByDesc(WarehouseHistory::getId).last("limit 1")).getWarehouseCode());
+                    insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate().eq(InsSample::getId, sampleId).set(InsSample::getCellId, null));
+                    warehouseHistoryMapper.insert(history);
                     break;
                 case 2:
                     //缁撴潫璇曢獙:姝ゅ鎵樺崟鍋滄璇曢獙(鏃犳硶鍐嶆妫�楠�)銆�
@@ -1057,27 +1213,123 @@
                             .set(InsOrderState::getInsState, 5)
                             .set(InsOrderState::getVerifyTell, tell)
                             .set(InsOrderState::getVerifyUser, userId));
-                    //濡傛灉璁㈠崟绫诲瀷鏄師鐞嗘牱鏈�,鍒欒璁㈠崟鐩存帴闂幆
-                    if (insOrder.getFormType().equals("鍘熺悊鏍锋満")) {
-                        //鍑哄簱
-                        try {
-                            List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId()));
-                            for (InsSample sample : insSamples) {
-                                outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
-                            }
-                        } catch (Exception e) {
-
-                        }
-                    }
-                    insOrder.setState(4);
-                    insOrderMapper.updateById(insOrder);
+                    /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+                    List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
+                    createReport(insOrder.getId(),insReportDto1s);
                     break;
             }
         }
         return 1;
     }
 
-    private void getTemplateThing(Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) {
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) {
+        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
+        InsSample insSample = insSampleMapper.selectById(sampleId);
+        InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
+        /*type=0  鍐嶆璇曢獙; type=1 缁х画璇曢獙 ; type=2 缁撴潫璇曢獙*/
+        // 鏌ヨ鏍规嵁 id 鍊掑簭鎺掑垪鐨勭涓�鏉¤褰�
+        InsOrderState record = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
+                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                .eq(InsOrderState::getInsSampleId, sampleId)
+                .eq(InsOrderState::getLaboratory, laboratory)
+                .orderByDesc(InsOrderState::getId)
+                .last("LIMIT 1")); // 纭繚鍙彇涓�鏉¤褰�
+        if (record != null) {
+            switch (type) {
+                case 0:
+                    //鍐嶆璇曢獙:璇ュ崟瀛愰��鍥炲埌妫�楠岀姸鎬�(鎺掑簭鏀规垚褰撳墠鐨勬渶鍚�),娆℃暟閫掑(淇濈暀浠ュ墠鐨勬暟鎹�)锛�
+                    insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+                            .eq(InsOrderState::getId, record.getId())
+                            .set(InsOrderState::getInsTime, LocalDateTime.now())
+                            .set(InsOrderState::getInsState, 4)
+                            .set(InsOrderState::getVerifyTell, tell)
+                            .set(InsOrderState::getVerifyUser, userId)
+                            .set(InsOrderState::getNum, record.getNum() + 1)//娆℃暟鍔�1
+                            .set(InsOrderState::getCreateTime, LocalDateTime.now()));
+                    break;
+                case 1:
+                    //缁х画璇曢獙:璇ユ牱鍝佽绔欑偣浠诲姟缁撴潫(鍙互鍐嶆鎵爜妫�楠�)锛�
+                    //鍏堝垽鏂笂涓�涓鏍告槸浠�涔堢粨璁�
+                    if (record.getInsState()==4){
+                        insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+                                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                                .eq(InsOrderState::getInsSampleId, sampleId)
+                                .eq(InsOrderState::getLaboratory, laboratory)
+                                .set(InsOrderState::getInsState, 6)
+                                .set(InsOrderState::getVerifyTell, tell)
+                                .set(InsOrderState::getNum, record.getNum() - 1)//娆℃暟-1
+                                .set(InsOrderState::getVerifyUser, userId));
+                    }else {
+                        insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+                                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                                .eq(InsOrderState::getInsSampleId, sampleId)
+                                .eq(InsOrderState::getLaboratory, laboratory)
+                                .set(InsOrderState::getInsState, 6)
+                                .set(InsOrderState::getVerifyTell, tell)
+                                .set(InsOrderState::getVerifyUser, userId));
+                    }
+                    //缁х画璇曢獙闇�瑕佸嚭搴�
+                    WarehouseHistory history = new WarehouseHistory();
+                    history.setState(2);
+                    history.setInsSampleId(sampleId);
+                    history.setCellId(insSample.getCellId());
+                    history.setWarehouseCode(warehouseHistoryMapper.selectOne(Wrappers.<WarehouseHistory>lambdaQuery()
+                            .eq(WarehouseHistory::getInsSampleId, sampleId).select(WarehouseHistory::getWarehouseCode).orderByDesc(WarehouseHistory::getId).last("limit 1")).getWarehouseCode());
+                    insSampleMapper.update(null, Wrappers.<InsSample>lambdaUpdate()
+                            .eq(InsSample::getId, sampleId).set(InsSample::getCellId, null));
+                    warehouseHistoryMapper.insert(history);
+                    break;
+                case 2:
+                    //缁撴潫璇曢獙:姝ゅ鎵樺崟鍋滄璇曢獙(鏃犳硶鍐嶆妫�楠�)銆�
+                    //鍏堝垽鏂笂涓�涓鏍告槸浠�涔堢粨璁�
+                    if (record.getInsState()==4){
+                        insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+                                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                                .eq(InsOrderState::getInsSampleId, sampleId)
+                                .eq(InsOrderState::getLaboratory, laboratory)
+                                .set(InsOrderState::getInsState, 5)
+                                .set(InsOrderState::getIsOut,1)//澶嶆牳缁撴潫鍑哄簱涔嬪悗鍒楄〃涓嶆樉绀�
+                                .set(InsOrderState::getNum, record.getNum() - 1)//娆℃暟-1
+                                .set(InsOrderState::getVerifyTell, tell)
+                                .set(InsOrderState::getVerifyUser, userId));
+                    }else {
+                        insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
+                                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
+                                .eq(InsOrderState::getInsSampleId, sampleId)
+                                .eq(InsOrderState::getLaboratory, laboratory)
+                                .set(InsOrderState::getInsState, 5)
+                                .set(InsOrderState::getIsOut,1)//澶嶆牳缁撴潫鍑哄簱涔嬪悗鍒楄〃涓嶆樉绀�
+                                .set(InsOrderState::getVerifyTell, tell)
+                                .set(InsOrderState::getVerifyUser, userId));
+                    }
+                    /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+                    List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
+                    createReport(insOrder.getId(),insReportDto1s);
+                    break;
+            }
+        }
+        return 1;
+    }
+
+
+    /*鐢熸垚瀵瑰簲鐨勬楠屾姤鍛�*/
+    private void createReport(Integer orderId,List<InsReportDto1> insReportDto1s){
+        for (InsReportDto1 insReportDto1 : insReportDto1s) {
+            if (ObjectUtils.isNotEmpty(insReportDto1.getInsReportDto2s())){
+                wordUtils.generateReport(orderId, insReportDto1);
+//                try{
+//                    wordUtils.generateReport(orderId, insReportDto1);
+//                }catch (Exception e){
+//                    throw new ErrorException("鎶ュ憡鏍煎紡鐢熸垚鏈夎,璇疯仈绯荤鐞嗗憳!");
+//                }
+            }
+        }
+    }
+
+    private void getTemplateThing
+            (Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) {
         for (InsProduct product : insProducts) {
             if (product.getTemplateId() == null) {
                 product.setTemplate(new ArrayList<>());
@@ -1134,8 +1386,8 @@
             String str = "";
             int count = 0;
             for (InsProduct product : insProducts) {
-                //杈愬皠璇曢獙,娓╂箍搴﹁瘯楠�,鍔熺巼璇曢獙鐨勬楠岄」鐩�,涓嶉渶瑕佸幓鎵嬪姩濉啓妫�楠屽��,鍙渶瑕佷笂浼犺〃鏍兼枃浠跺氨鍙互浜�,鍚庡彴鎻愪氦鐨勬椂鍊欐牎楠岃烦杩囪繖涓楠岄」鐩�
-                if (product.getInspectionItem().equals("杈愬皠璇曢獙") || product.getInspectionItem().equals("娓╂箍搴﹁瘯楠�") || product.getInspectionItem().equals("鍔熺巼璇曢獙")) {
+                //娓╂箍搴﹁瘯楠�,鍔熺巼璇曢獙鐨勬楠岄」鐩�,涓嶉渶瑕佸幓鎵嬪姩濉啓妫�楠屽��,鍙渶瑕佷笂浼犺〃鏍兼枃浠跺氨鍙互浜�,鍚庡彴鎻愪氦鐨勬椂鍊欐牎楠岃烦杩囪繖涓楠岄」鐩�
+                if ( product.getInspectionItem().equals("娓╂箍搴﹁瘯楠�") || product.getInspectionItem().equals("鍔熺巼璇曢獙")) {
                     product.setInsResult(3);//涓嶅垽瀹�
                     insProductMapper.updateById(product);
                     continue;
@@ -1174,11 +1426,13 @@
         info.setCreateUser(insProductMapper.selectUserById(userId).get("name"));
         info.setMessageType("2");
         info.setTheme("澶嶆牳閫氱煡");
-        info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample());
+        info.setContent("鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode()+"绔欑偣鏄細"+submitPlanDto.getLaboratory() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample());
         info.setSenderId(userId);
         info.setConsigneeId(submitPlanDto.getVerifyUser());
         info.setViewStatus(false);
         info.setJumpPath("b1-inspect-order-plan");
+        info.setEntrustCode(insOrder.getEntrustCode());//濮旀墭缂栧彿
+        info.setLaboratory(submitPlanDto.getLaboratory());//绔欑偣
         informationNotificationService.addInformationNotification(info);
         //澶嶆牳浜�--妫�楠屽崟鐩稿叧璐熻矗浜�
         InsSampleUser insSampleUser = new InsSampleUser();
@@ -1189,12 +1443,10 @@
         insSampleUserMapper.insert(insSampleUser);
         /*鐢熸垚鐢佃矾璇曢獙鐨勭珯鐐规姤鍛婂苟涓婁紶鍒伴檮浠朵腑*/
         if (submitPlanDto.getLaboratory().equals("鐢佃矾璇曢獙")) {
-//            wordUtils.generateWord(submitPlanDto.getTerm(), orderState);
-            //todo 鐢佃矾绔欑偣鎶ュ憡 姝e紡搴撻儴缃叉斁寮�
-            try {
+            if (!insOrder.getSampleType().equals("鏃犳簮鍣ㄤ欢")) {
                 wordUtils.generateWord(submitPlanDto.getTerm(), orderState);
-            } catch (Exception e) {
-                throw new ErrorException("鐢佃矾璇曢獙鐨勭珯鐐规姤鍛婄敓鎴愭湁璇�,璇疯仈绯诲紑鍙戜汉鍛樿皟鏁�!");
+            } else {
+                wordUtils.generateWord2(submitPlanDto.getTerm(), orderState);
             }
         }
         /*鐢熸垚浜ч噺宸ユ椂*/
@@ -1255,7 +1507,7 @@
         map.put("msgtype", "text");//娑堟伅绫诲瀷 text:鏂囨湰
         map.put("agentid", 1000517);//搴旂敤id
         HashMap<String, Object> hashMap = new HashMap<>();
-        hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode() + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample() +
+        hashMap.put("content", "鎮ㄦ湁涓�鏉℃楠屼换鍔″緟澶嶆牳娑堟伅,璁㈠崟鍙锋槸锛�" + insOrder.getEntrustCode()+"绔欑偣鏄細"+submitPlanDto.getLaboratory() + ",鏍峰搧鍚嶇О涓猴細"  + ",鏍峰搧鍚嶇О涓猴細" + insSample.getSample() +
                 ",璇峰墠寰�LIMS绯荤粺鏌ョ湅銆傝鐐瑰嚮<a href=\"https://ztwxlims.ztt.cn:7443/enter\">涓ぉ閫氫俊LIMS绯荤粺 </a>");
         map.put("text", hashMap);//娑堟伅鍐呭
         map.put("safe", 0);//鏄惁淇濆瘑娑堟伅.0鍚�
@@ -1272,8 +1524,8 @@
         InsSample insSample = insSampleMapper.selectById(orderState.getInsSampleId());
         /*鍒犻櫎璁板綍妫�楠屼换鍔℃瘡娆$殑澶囨敞淇℃伅*/
         insOrderUserMapper.delete(Wrappers.<InsOrderUser>lambdaQuery()
-        .eq(InsOrderUser::getInsOrderStateId,orderState.getId())
-        .eq(InsOrderUser::getNum,orderState.getNum()));
+                .eq(InsOrderUser::getInsOrderStateId, orderState.getId())
+                .eq(InsOrderUser::getNum, orderState.getNum()));
         //鎾ら攢鎻愪氦
         insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
                 .eq(InsOrderState::getInsOrderId, orderState.getInsOrderId())
@@ -1294,15 +1546,15 @@
         informationNotificationService.addInformationNotification(info);
         //鍒犻櫎澶嶆牳浜�--妫�楠屽崟鐩稿叧璐熻矗浜�
         insSampleUserMapper.delete(Wrappers.<InsSampleUser>lambdaQuery()
-        .eq(InsSampleUser::getState,1)
-        .eq(InsSampleUser::getSonLaboratory,orderState.getLaboratory())
-        .eq(InsSampleUser::getUserId,orderState.getVerifyUser())
-        .eq(InsSampleUser::getInsSampleId,orderState.getInsSampleId()));
+                .eq(InsSampleUser::getState, 1)
+                .eq(InsSampleUser::getSonLaboratory, orderState.getLaboratory())
+                .eq(InsSampleUser::getUserId, orderState.getVerifyUser())
+                .eq(InsSampleUser::getInsSampleId, orderState.getInsSampleId()));
         //鍒犻櫎鐢熸垚鐨勬姤鍛�
         if (orderState.getLaboratory().equals("鐢佃矾璇曢獙")) {
             List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery()
                     .eq(InsOrderFile::getType, 2)
-                    .like(InsOrderFile::getFileName,"鐢佃矾鍙傛暟.docx")
+                    .like(InsOrderFile::getFileName, "鐢佃矾鍙傛暟.docx")
                     .eq(InsOrderFile::getInsOrderId, insOrder.getId())
                     .eq(InsOrderFile::getInsSampleId, orderState.getInsSampleId())
                     .eq(InsOrderFile::getSonLaboratory, orderState.getLaboratory()));
@@ -1317,9 +1569,9 @@
         List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, insSample.getId()));
         List<Integer> productIds = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList());
         auxiliaryOutputWorkingHoursMapper.delete(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
-                .eq(AuxiliaryOutputWorkingHours::getSample,insSample.getSampleCode())
-                .in(AuxiliaryOutputWorkingHours::getInsProductId,productIds)
-                .eq(AuxiliaryOutputWorkingHours::getNum,orderState.getNum()));
+                .eq(AuxiliaryOutputWorkingHours::getSample, insSample.getSampleCode())
+                .in(AuxiliaryOutputWorkingHours::getInsProductId, productIds)
+                .eq(AuxiliaryOutputWorkingHours::getNum, orderState.getNum()));
 
         //  todo 浼佷笟寰俊娑堟伅鎺ㄩ�丂zss
         HashMap<String, Object> map = new HashMap<>();

--
Gitblit v1.9.3