From bb120c51ecba1bb4a16224352a6e8f620fdff79f Mon Sep 17 00:00:00 2001
From: zhuo <2089219845@qq.com>
Date: 星期五, 28 二月 2025 15:16:12 +0800
Subject: [PATCH] 清除控制台直接打印

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |  601 ++++++++++++++++++++++++++----------------------------
 1 files changed, 290 insertions(+), 311 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index ca01fca..5b7231d 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -34,7 +34,6 @@
 import com.ruoyi.common.constant.InsOrderTypeConstants;
 import com.ruoyi.common.core.domain.entity.Custom;
 import com.ruoyi.common.core.domain.entity.InformationNotification;
-import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.core.domain.entity.User;
 import com.ruoyi.common.utils.*;
 import com.ruoyi.framework.exception.ErrorException;
@@ -42,19 +41,23 @@
 import com.ruoyi.inspect.mapper.*;
 import com.ruoyi.inspect.pojo.*;
 import com.ruoyi.inspect.service.*;
+import com.ruoyi.inspect.util.HackLoopTableRenderPolicy;
 import com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo;
 import com.ruoyi.inspect.vo.InsOrderPlanVO;
 import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
 import com.ruoyi.performance.mapper.PerformanceShiftMapper;
 import com.ruoyi.performance.mapper.ShiftTimeMapper;
 import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHours;
+import com.ruoyi.performance.pojo.AuxiliaryOutputWorkingHoursTemporary;
 import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursService;
+import com.ruoyi.performance.service.AuxiliaryOutputWorkingHoursTemporaryService;
 import com.ruoyi.system.mapper.CustomMapper;
 import com.ruoyi.system.mapper.UserMapper;
 import com.ruoyi.system.service.ISysDictTypeService;
 import com.ruoyi.system.service.InformationNotificationService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.xwpf.usermodel.*;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -116,11 +119,9 @@
     @Resource
     private InsProductUserMapper insProductUserMapper;
     @Resource
-    private InsUnPassService insUnPassService;
-    @Resource
-    private AuxiliaryOutputWorkingHoursMapper auxiliaryOutputWorkingHoursMapper;
-    @Resource
     private AuxiliaryOutputWorkingHoursService auxiliaryOutputWorkingHoursService;
+    @Resource
+    private AuxiliaryOutputWorkingHoursTemporaryService auxiliaryOutputWorkingHoursTemporaryService;
     @Resource
     private InformationNotificationService informationNotificationService;
     @Resource
@@ -129,7 +130,6 @@
     private CustomMapper customMapper;
     @Value("${file.path}")
     private String imgUrl;
-
     @Resource
     private InsOrderFileMapper insOrderFileMapper;
     @Resource
@@ -499,13 +499,6 @@
                     }
                 }
 
-                //鏌ヨ妫�楠屽崟淇℃伅
-                // 娣诲姞宸ユ椂
-                InsProduct finalInsProduct = insProductMapper.selectById(product.getId());
-                threadPoolTaskExecutor.execute(() -> {
-                    InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
-                    this.addAuxiliary(userId, finalInsProduct, insOrder);
-                });
             }
         });
         String sampleIdStr = insContext.keySet().stream().findFirst().orElse(null);
@@ -590,8 +583,27 @@
         return insSampleUserMapper.insert(insSampleUser);
     }
 
+    /**
+     * 鏌ヨ妯℃澘鍐呭
+     * @param order
+     * @param insProducts
+     */
     private void getTemplateThing(InsOrder order, List<InsProduct> insProducts) {
         Set<Integer> set = new HashSet<>();
+        // 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴
+//        List<String> itemNameList = insProducts.stream().map(insProduct -> {
+//            String itemName = "";
+//            if (StringUtils.isNotBlank(insProduct.getInspectionItemClass())) {
+//                itemName += insProduct.getInspectionItemClass().trim();
+//            }
+//            if (StringUtils.isNotBlank(insProduct.getInspectionItem())) {
+//                itemName += insProduct.getInspectionItem().trim();
+//            }
+//            if (StringUtils.isNotBlank(insProduct.getInspectionItemSubclass())) {
+//                itemName += insProduct.getInspectionItemSubclass().trim();
+//            }
+//            return itemName;
+//        }).collect(Collectors.toList());
         // 鏌ヨ璁㈠崟鐘舵�佸垽鏂槸鍚︽槸鏌ュ巻鍙叉ā鏉�
         if (order.getIsFirstSubmit() != null && order.getIsFirstSubmit().equals(1)) {
             InsOrderState insOrderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
@@ -611,8 +623,9 @@
                                 .eq(InsOrderStandardTemplate::getInsOrderId, order.getId()));
                         thing = one.getThing();
                         if (StrUtil.isNotEmpty(thing)) {
-                            JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0)));
-                            JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config")));
+                            thing = GZipUtil.uncompress(thing);
+                            JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0);
+                            JSONObject config = sheet.getJSONObject("config");
                             List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class);
                             Map<String, Object> style = new HashMap<>();
                             style.put("rowlen", config.get("rowlen"));
@@ -635,8 +648,8 @@
                 thing = standardTemplateService.getStandTempThingById(product.getTemplateId());
             }
             if (StrUtil.isNotEmpty(thing)) {
-                JSONObject sheet = JSON.parseObject(JSON.toJSONString(JSON.parseArray(JSON.toJSONString(JSON.parseObject(thing).get("data"))).get(0)));
-                JSONObject config = JSON.parseObject(JSON.toJSONString(sheet.get("config")));
+                JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0);
+                JSONObject config = sheet.getJSONObject("config");
                 List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class);
                 Map<String, Object> style = new HashMap<>();
                 style.put("rowlen", config.get("rowlen"));
@@ -646,6 +659,90 @@
                 product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId()));
             }
         }
+    }
+
+    /**
+     * todo: 娓呴櫎娌℃湁浣跨敤鐨勬楠岄」
+     * @param sheet
+     * @param itemNameList
+     */
+    private static void eliminateItem(JSONObject sheet, List<String> itemNameList) {
+        // 鑾峰彇鍒� 妫�楠岄」鍒嗙被+妫�楠岄」+妫�楠屽瓙椤圭殑鎷兼帴,濡傛灉妯℃澘閲岀殑淇℃伅璺熸帴鍙h繑鍥炵殑妫�楠岄」淇℃伅鑳藉鍖归厤鍒欏睍绀哄嚭鏉�
+
+        // 寰幆琛屾暟鍒ゆ柇鏄惁
+        JSONArray dataListJSONArray = sheet.getJSONArray("data");
+
+        // 娣诲姞鍧愭爣map
+        Map<String, String> coordinatesMap = new HashMap<>();
+
+        // 闇�瑕佺Щ闄ょ殑绱㈠紩
+        List<Integer> deleteIndex = new ArrayList<>();
+        // 寰幆鍒�
+        for (int r = 0; r < dataListJSONArray.size(); r++) {
+            JSONArray dataList = dataListJSONArray.getJSONArray(r);
+            // 寰幆琛�
+            String itemName = "";
+            // 鍒ゆ柇鏄惁鏄剧ず
+            boolean isShow = false;
+
+            for (int c = 0; c < dataList.size(); c++) {
+                // 鏌ヨ鎵规敞
+                JSONObject jsonObject = dataList.getJSONObject(c);
+                try {
+                    if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」鍒嗙被")) {
+                        String value = jsonObject.getString("v").trim();
+                        itemName += value;
+                        // 娣诲姞鍧愭爣
+                        String coordinates = coordinatesJoint(r, c);
+                        coordinatesMap.put(coordinates, value);
+                        isShow = true;
+                    } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠岄」")) {
+                        String value = jsonObject.getString("v").trim();
+                        itemName += value;
+                        // 娣诲姞鍧愭爣
+                        String coordinates = coordinatesJoint(r, c);
+                        coordinatesMap.put(coordinates, value);
+                        isShow = true;
+                    } else if (jsonObject.getJSONObject("ps").getString("value").equals("妫�楠屽瓙椤�")) {
+                        String value = jsonObject.getString("v").trim();
+                        itemName += value;
+                        // 娣诲姞鍧愭爣
+                        String coordinates = coordinatesJoint(r, c);
+                        coordinatesMap.put(coordinates, value);
+                        isShow = true;
+                    }
+                } catch (Exception e) {
+                    // 鍒ゆ柇鏄惁鏈塵c鍚堝苟鍗曞厓鏍�
+                    if (jsonObject != null && jsonObject.getJSONObject("mc") != null) {
+                        // 鏌ヨ鍧愭爣杩涜娣诲姞
+                        String value = coordinatesMap.get(coordinatesJoint(jsonObject.getJSONObject("mc").getInteger("r"), jsonObject.getJSONObject("mc").getInteger("c")));
+                        if (StringUtils.isNotBlank(value) && !itemName.contains(value)) {
+                            itemName += value;
+                        }
+                    }
+                }
+            }
+            // 鍒ゆ柇璇ヨ鍗曟槸鍚︽湁鏀规楠岄」, 娌℃湁鍓旈櫎
+            if (isShow) {
+                if (!itemNameList.contains(itemName)) {
+                    dataListJSONArray.remove(r);
+                    r--;
+                }
+            }
+        }
+    }
+
+
+    /**
+     * 鍧愭爣鎷兼帴
+     * @param r 妯潗鏍�
+     * @param c 绾靛潗鏍�
+     * @return
+     */
+    private static String coordinatesJoint(int r, int c) {
+        String coordinates = "";
+        coordinates = "r:" + r + ",c:" + c;
+        return coordinates;
     }
 
     @Override
@@ -787,6 +884,21 @@
             }
         }
 
+        // 娣诲姞宸ユ椂
+        // 鍒犻櫎鍘熸湰璁㈠崟宸ユ椂
+        auxiliaryOutputWorkingHoursService.remove(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
+                .eq(AuxiliaryOutputWorkingHours::getOrderId, orderId));
+        // 鏌ヨ宸ユ椂鏆傚瓨
+        List<AuxiliaryOutputWorkingHoursTemporary> hoursTemporaries = auxiliaryOutputWorkingHoursTemporaryService.list(Wrappers.<AuxiliaryOutputWorkingHoursTemporary>lambdaQuery()
+                .eq(AuxiliaryOutputWorkingHoursTemporary::getOrderId, orderId));
+        List<AuxiliaryOutputWorkingHours> outputWorkingHours = hoursTemporaries.stream().map(hoursTemporary -> {
+            AuxiliaryOutputWorkingHours workingHours = new AuxiliaryOutputWorkingHours();
+            BeanUtil.copyProperties(hoursTemporary, workingHours);
+            workingHours.setId(null);
+            return workingHours;
+        }).collect(Collectors.toList());
+        auxiliaryOutputWorkingHoursService.saveBatch(outputWorkingHours);
+
         // 鎴愬搧鎶芥牱娣诲姞鍚堟牸鐘舵��
         // 鍒ゆ柇鏄惁鏈夋娊鏍蜂俊鎭�
         if (order.getQuarterItemId() != null) {
@@ -864,59 +976,6 @@
         }
 
         return 1;
-    }
-
-    public int pxToCm(int px) {
-        return px / 9;
-    }
-
-    // 鑾峰彇涓や釜localDateTime鐨勬瘡涓�澶�
-    public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) {
-        List<LocalDateTime> localDateTimes = new ArrayList<>();
-        LocalDate currentDate = start.toLocalDate();
-        LocalDateTime currentLocalDateTime = start;
-        while (!currentDate.isAfter(end.toLocalDate())) {
-            localDateTimes.add(currentLocalDateTime);
-            currentLocalDateTime = currentLocalDateTime.plusDays(1);
-            currentDate = currentDate.plusDays(1);
-        }
-        return localDateTimes;
-    }
-
-    public static String getWeek(String dayStr) {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        try {
-            Date date = sdf.parse(dayStr);
-            Calendar calendar = Calendar.getInstance();
-            calendar.setTime(date);
-            int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
-            int day = calendar.get(Calendar.DAY_OF_MONTH);
-            return getWeekDay(dayOfWeek);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public static String getWeekDay(int dayOfWeek) {
-        switch (dayOfWeek) {
-            case Calendar.MONDAY:
-                return "鍛ㄤ竴";
-            case Calendar.TUESDAY:
-                return "鍛ㄤ簩";
-            case Calendar.WEDNESDAY:
-                return "鍛ㄤ笁";
-            case Calendar.THURSDAY:
-                return "鍛ㄥ洓";
-            case Calendar.FRIDAY:
-                return "鍛ㄤ簲";
-            case Calendar.SATURDAY:
-                return "鍛ㄥ叚";
-            case Calendar.SUNDAY:
-                return "鍛ㄦ棩";
-            default:
-                return "鏈煡";
-        }
     }
 
 
@@ -1054,7 +1113,6 @@
      * @param orderId
      */
     private void generateReport(Integer orderId) {
-        List<InsUnPass> insUnPasses = new ArrayList<>();
         /*鏍峰搧涓嬬殑椤圭洰鍙鏈変竴涓」鐩笉鍚堟牸鍒欐楠岀粨鏋滀负0,鍚﹀垯涓�1*/
         //杩欓噷鐨刬nsSamples鏄鍗曚笅鐨勬墍鏈夋牱鍝佸寘鎷�("/")
         List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId));
@@ -1070,25 +1128,7 @@
                 insSample.setInsResult(1);
             }
             insSampleMapper.updateById(insSample);
-            /*澶嶆牳閫氳繃鍚庯紝灏嗕笉鍚堟牸鐨勯」鐩俊鎭坊鍔犲埌ins_un_pass琛ㄤ腑*/
-            for (InsProduct insProduct : insProducts) {
-                if (insProduct.getInsResult() == 0) {
-                    InsUnPass insUnPass = new InsUnPass();
-                    insUnPass.setId(null);
-                    insUnPass.setModel(insSample.getModel());
-                    insUnPass.setSample(insSample.getSample());
-                    insUnPass.setInspectionItem(insProduct.getInspectionItem());
-                    insUnPass.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());
-                    insUnPass.setLastValue(insProduct.getLastValue());
-                    insUnPass.setEntrustCode(insOrderMapper.selectById(orderId).getEntrustCode());
-                    List<Integer> userIds = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery().eq(InsProductUser::getInsProductId, insProduct.getId())).stream().map(InsProductUser::getCreateUser).distinct().collect(Collectors.toList());
-                    String name = userMapper.selectBatchIds(userIds).stream().map(User::getName).collect(Collectors.joining(","));
-                    insUnPass.setName(name);
-                    insUnPasses.add(insUnPass);
-                }
-            }
         }
-        insUnPassService.saveBatch(insUnPasses);
         InsOrder insOrder = insOrderMapper.selectById(orderId);
         // 鎶芥鍙樻垚濮旀墭妫�楠�
         if (insOrder.getOrderType().equals(InsOrderTypeConstants.SPOT_CHECK)) {
@@ -1880,6 +1920,8 @@
                     put("seal1", null);
                 }});
         try {
+            // 淇敼鎹㈣鍜屽悎骞堕棶棰�
+            updaeMerge(template.getXWPFDocument(), true);
             String name = insReport.getCode().replace("/", "") + "-J.docx";
             template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
             insReport.setUrl("/word/" + name);
@@ -1894,8 +1936,6 @@
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
-        // 淇敼鎹㈣鍜屽悎骞堕棶棰�
-        updaeMerge(insReport, null, true);
     }
 
     /**
@@ -2263,10 +2303,19 @@
         tables.forEach(table -> {
             table.put("tableSize", tables.size() + 1);
         });
+        // 璁惧淇℃伅
         List<Map<String, String>> deviceList = null;
-        if (deviceSet.size() != 0) {
+        if (CollectionUtils.isNotEmpty(deviceSet)) {
             deviceList = insOrderMapper.selectDeviceList(deviceSet);
         }
+        if (CollectionUtils.isNotEmpty(deviceList)) {
+            int count = 1;
+            for (Map<String, String> stringMap : deviceList) {
+                stringMap.put("index", String.valueOf(count));
+                count++;
+            }
+        }
+
         Map<String, String> codeStr = new HashMap<>();
         codeStr.put("鎶ュ憡缂栧彿", insReport.getCode());
         codeStr.put("鏍峰搧鍚嶇О", insOrder.getSample());
@@ -2274,7 +2323,6 @@
         codeStr.put("鍙戞斁鏃ユ湡", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
 
         String modelStr = CollUtil.join(models, "\n");
-        String finalModelStr = modelStr;
 
         // 妫�娴嬬被鍨�
         String orderType = null;
@@ -2288,11 +2336,10 @@
         String formType = iSysDictTypeService.selectLabelByDict(DictDataConstants.FORM_TYPE, insOrder.getFormType());
 
         // 鏍峰搧鐘舵��
-        String sampleStatus = iSysDictTypeService.selectLabelByDict(DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus());;
+        String sampleStatus = iSysDictTypeService.selectLabelByDict(DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus());
+        ;
 
-        ConfigureBuilder builder = Configure.builder();
-        builder.useSpringEL(true);
-        List<Map<String, String>> finalDeviceList = deviceList;
+        // 鍏徃淇℃伅
         Custom custom = customMapper.selectById(insOrder.getCompanyId());
 
         // 鏌ヨ鍒ゆ柇鏄惁鏈変笉鍒ゅ畾椤圭洰,鍜屽叏閮芥槸鍒ゅ畾椤�
@@ -2382,12 +2429,18 @@
         environment = (ObjectUtils.isNotEmpty(insOrder.getTemperature()) ? insOrder.getTemperature() + "鈩� " : "") + (ObjectUtils.isNotEmpty(insOrder.getHumidity()) ? insOrder.getHumidity() + "%" : "");
         String finalEnvironment = environment;
         LocalDateTime finalSendTime = sendTime;
-
         String finalResultCh = resultCh;
         String finalResultEn = resultEn;
         String finalOrderType = orderType;
+        List<Map<String, String>> finalDeviceList = deviceList;
+        String finalModelStr = modelStr;
+
         InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
-        XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
+        Configure configure = Configure.builder()
+                .bind("deviceList", new HackLoopTableRenderPolicy())
+                .build();
+
+        XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(
                 new HashMap<String, Object>() {{
                     put("order", insOrder);
                     put("report", insReport);
@@ -2422,6 +2475,8 @@
                     put("sampleStatus", sampleStatus);
                 }});
         try {
+            // 淇敼鎹㈣鍜屽悎骞堕棶棰�
+            updaeMerge(template.getXWPFDocument(), false);
             String name = insReport.getCode().replace("/", "") + ".docx";
             template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
             insReport.setUrl("/word/" + name);
@@ -2434,8 +2489,6 @@
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
-        // 淇敼鎹㈣鍜屽悎骞堕棶棰�
-        updaeMerge(insReport, deviceList, false);
     }
 
     /**
@@ -2506,188 +2559,165 @@
 
     /**
      * 鍚堝苟鍗曞厓鏍�
-     * @param insReport
-     * @param deviceList
      */
-    private void updaeMerge(InsReport insReport, List<Map<String, String>> deviceList, boolean isSmall) {
+    private void updaeMerge(XWPFDocument document, boolean isSmall) {
         // 澶勭悊鍚堝苟鍗曞厓鏍肩殑闂
-        String path = wordUrl + insReport.getUrl().replaceFirst("/word", "");
-        try {
-            // 鑾峰彇鏂囨。涓殑鎵�鏈夎〃鏍�
-            FileInputStream stream = new FileInputStream(path);
-            XWPFDocument document = new XWPFDocument(stream);
-            List<XWPFTable> xwpfTables = document.getTables();
-            // 閬嶅巻琛ㄦ牸锛屼絾璺宠繃绗竴涓〃鏍硷紙濡傛灉deviceList涓簄ull锛屽垯棰濆璺宠繃绗簩涓級
-            for (int i = 1; i < xwpfTables.size() - (deviceList == null ? 1 : 2); i++) {
-                // 鍒涘缓涓�涓狧ashSet鏉ュ瓨鍌ㄥ敮涓�鐨勫瓧绗︿覆锛堣繖閲屽熀浜�"鈭�"鍒嗗壊鍚庣殑绗簩閮ㄥ垎锛�
-                Set<String> set1 = new HashSet<>();
-                // 鍒涘缓涓�涓狧ashMap鏉ュ瓨鍌ㄦ瘡涓敮涓�瀛楃涓插強鍏跺搴旂殑鍗曞厓鏍间綅缃俊鎭�
-                Map<String, Map<String, Integer>> maps = new HashMap<>();
-                // 閬嶅巻褰撳墠琛ㄦ牸鐨勬墍鏈夎
-                for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) {
-                    // 閬嶅巻褰撳墠琛岀殑鎵�鏈夊崟鍏冩牸
-                    for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) {
-                        // 妫�鏌ュ崟鍏冩牸鏂囨湰涓槸鍚﹀寘鍚�"鈭�"
-                        if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("鈭�") > -1) {
-                            String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("鈭�");
-                            // 濡傛灉鍒嗗壊鍚庣殑绗簩閮ㄥ垎鏄柊鐨勶紙鍗充箣鍓嶆湭鍑虹幇杩囷級锛屽垯娣诲姞鍒皊et1骞跺垱寤轰綅缃俊鎭痬ap
-                            if (set1.add(split[1])) {
-                                Map<String, Integer> map = new HashMap<>();
-                                // 瀛樺偍璧峰琛屻�佽捣濮嬪垪銆佺粨鏉熻锛堝綋鍓嶈锛夈�佺粨鏉熷垪锛堝綋鍓嶅垪锛�
-                                map.put("sr", j);
-                                map.put("sc", k);
-                                map.put("er", j + 0);
-                                map.put("ec", k + 0);
-                                maps.put(split[1], map);
-                            } else {
-                                // 濡傛灉宸插瓨鍦紝鍒欐洿鏂扮粨鏉熻鎴栫粨鏉熷垪
-                                Map<String, Integer> map1 = maps.get(split[1]);
-                                if (j == map1.get("sr")) {
-                                    map1.put("ec", map1.get("ec") + 1);
-                                } else if (k == map1.get("sc")) {
-                                    map1.put("er", map1.get("er") + 1);
-                                }
+        // 鑾峰彇鏂囨。涓殑鎵�鏈夎〃鏍�
+        List<XWPFTable> xwpfTables = document.getTables();
+        // 閬嶅巻琛ㄦ牸
+        for (int i = 1; i < xwpfTables.size(); i++) {
+            // 鍒涘缓涓�涓狧ashSet鏉ュ瓨鍌ㄥ敮涓�鐨勫瓧绗︿覆锛堣繖閲屽熀浜�"鈭�"鍒嗗壊鍚庣殑绗簩閮ㄥ垎锛�
+            Set<String> set1 = new HashSet<>();
+            // 鍒涘缓涓�涓狧ashMap鏉ュ瓨鍌ㄦ瘡涓敮涓�瀛楃涓插強鍏跺搴旂殑鍗曞厓鏍间綅缃俊鎭�
+            Map<String, Map<String, Integer>> maps = new HashMap<>();
+            // 閬嶅巻褰撳墠琛ㄦ牸鐨勬墍鏈夎
+            for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) {
+                // 閬嶅巻褰撳墠琛岀殑鎵�鏈夊崟鍏冩牸
+                for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) {
+                    // 妫�鏌ュ崟鍏冩牸鏂囨湰涓槸鍚﹀寘鍚�"鈭�"
+                    if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("鈭�") > -1) {
+                        String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("鈭�");
+                        // 濡傛灉鍒嗗壊鍚庣殑绗簩閮ㄥ垎鏄柊鐨勶紙鍗充箣鍓嶆湭鍑虹幇杩囷級锛屽垯娣诲姞鍒皊et1骞跺垱寤轰綅缃俊鎭痬ap
+                        if (set1.add(split[1])) {
+                            Map<String, Integer> map = new HashMap<>();
+                            // 瀛樺偍璧峰琛屻�佽捣濮嬪垪銆佺粨鏉熻锛堝綋鍓嶈锛夈�佺粨鏉熷垪锛堝綋鍓嶅垪锛�
+                            map.put("sr", j);
+                            map.put("sc", k);
+                            map.put("er", j + 0);
+                            map.put("ec", k + 0);
+                            maps.put(split[1], map);
+                        } else {
+                            // 濡傛灉宸插瓨鍦紝鍒欐洿鏂扮粨鏉熻鎴栫粨鏉熷垪
+                            Map<String, Integer> map1 = maps.get(split[1]);
+                            if (j == map1.get("sr")) {
+                                map1.put("ec", map1.get("ec") + 1);
+                            } else if (k == map1.get("sc")) {
+                                map1.put("er", map1.get("er") + 1);
                             }
-                            // 鍒ゆ柇灏忛珮鎶ュ憡杩樻槸澶ф姤鍛�
-                            if (isSmall) {
-                                // 鑾峰彇鍗曞厓鏍�
-                                XWPFTableCell cell = xwpfTables.get(i).getRows().get(j).getTableCells().get(k);
-                                XWPFParagraph paragraph = cell.getParagraphArray(0);
-                                String originalText = paragraph.getText();
-                                String newText = originalText.split("鈭�")[0];
-                                List<XWPFRun> runs = paragraph.getRuns();
-                                for (XWPFRun run : runs) {
-                                    run.setText("", 0); // 娓呯┖ run 涓殑鏂囨湰
-                                }
-                                if (!runs.isEmpty()) {
-                                    XWPFRun run = runs.get(0);
-                                    run.setText(newText);
-
-                                    // 澶嶅埗鏍峰紡
-                                    run.setFontFamily(paragraph.getRuns().get(0).getFontFamily());
-                                    run.setFontSize(paragraph.getRuns().get(0).getFontSize());
-                                    run.setBold(paragraph.getRuns().get(0).isBold());
-                                    run.setItalic(paragraph.getRuns().get(0).isItalic());
-                                    run.setUnderline(paragraph.getRuns().get(0).getUnderline());
-                                    run.setColor(paragraph.getRuns().get(0).getColor());
-                                }
-
-                                cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
-                                paragraph.setAlignment(ParagraphAlignment.CENTER);
-                            } else {
-                                // 绉婚櫎鍖呭惈"鈭�"鐨勬钀斤紝骞堕噸鏂拌缃崟鍏冩牸鏂囨湰鍜屾牱寮�
-                                String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("鈭�")[0];
-                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
-                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str);
-                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
-                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(ParagraphAlignment.CENTER);
+                        }
+                        // 鍒ゆ柇灏忛珮鎶ュ憡杩樻槸澶ф姤鍛�
+                        if (isSmall) {
+                            // 鑾峰彇鍗曞厓鏍�
+                            XWPFTableCell cell = xwpfTables.get(i).getRows().get(j).getTableCells().get(k);
+                            XWPFParagraph paragraph = cell.getParagraphArray(0);
+                            String originalText = paragraph.getText();
+                            String newText = originalText.split("鈭�")[0];
+                            List<XWPFRun> runs = paragraph.getRuns();
+                            for (XWPFRun run : runs) {
+                                run.setText("", 0); // 娓呯┖ run 涓殑鏂囨湰
                             }
+                            if (!runs.isEmpty()) {
+                                XWPFRun run = runs.get(0);
+                                run.setText(newText);
+
+                                // 澶嶅埗鏍峰紡
+                                run.setFontFamily(paragraph.getRuns().get(0).getFontFamily());
+                                run.setFontSize(paragraph.getRuns().get(0).getFontSize());
+                                run.setBold(paragraph.getRuns().get(0).isBold());
+                                run.setItalic(paragraph.getRuns().get(0).isItalic());
+                                run.setUnderline(paragraph.getRuns().get(0).getUnderline());
+                                run.setColor(paragraph.getRuns().get(0).getColor());
+                            }
+
+                            cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
+                            paragraph.setAlignment(ParagraphAlignment.CENTER);
+                        } else {
+                            // 绉婚櫎鍖呭惈"鈭�"鐨勬钀斤紝骞堕噸鏂拌缃崟鍏冩牸鏂囨湰鍜屾牱寮�
+                            String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("鈭�")[0];
+                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
+                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str);
+                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
+                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(ParagraphAlignment.CENTER);
                         }
                     }
                 }
+            }
 
-                // 鍗曞厓鏍兼帓搴�, 閬垮厤鏍煎紡閿欎贡
-                List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet());
-                entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc"));
+            // 鍗曞厓鏍兼帓搴�, 閬垮厤鏍煎紡閿欎贡
+            List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet());
+            entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc"));
 
-                // 鎸夌収椤哄簭娣诲姞杩涢泦鍚�
-                List<String> list = new ArrayList<>();
-                for (Map.Entry<String, Map<String, Integer>> entry : entries) {
-                    list.add(entry.getKey());
-                }
+            // 鎸夌収椤哄簭娣诲姞杩涢泦鍚�
+            List<String> list = new ArrayList<>();
+            for (Map.Entry<String, Map<String, Integer>> entry : entries) {
+                list.add(entry.getKey());
+            }
 
-                for (int a = list.size() - 1; a >= 0; a--) {
-                    Map<String, Integer> v = maps.get(list.get(a));
-                    for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) {
-                        if (v.get("ec") > v.get("sc")) {
-                            try {
-                                TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec"));
-                            } catch (Exception e) {
-                            }
-                        }
-                    }
-                    if (v.get("er") > v.get("sr")) {
+            for (int a = list.size() - 1; a >= 0; a--) {
+                Map<String, Integer> v = maps.get(list.get(a));
+                for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) {
+                    if (v.get("ec") > v.get("sc")) {
                         try {
-                            TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er"));
+                            TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec"));
                         } catch (Exception e) {
                         }
                     }
                 }
+                if (v.get("er") > v.get("sr")) {
+                    try {
+                        TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er"));
+                    } catch (Exception e) {
+                    }
+                }
             }
-            FileOutputStream fileOutputStream = new FileOutputStream(path);
-            document.write(fileOutputStream);
-            fileOutputStream.close();
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
         }
+
         //澶勭悊涓嫳鏂囨崲琛岀殑闂
-        try {
-            FileInputStream stream1 = new FileInputStream(path);
-            XWPFDocument document1 = new XWPFDocument(stream1);
-            List<XWPFTable> xwpfTables1 = document1.getTables();
-            for (int i = 1; i < xwpfTables1.size() - (deviceList == null ? 1 : 2); i++) {
-                for (int j = 0; j < xwpfTables1.get(i).getRows().size(); j++) {
-                    for (int k = 0; k < xwpfTables1.get(i).getRows().get(j).getTableCells().size(); k++) {
-                        if (xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText().contains("@")) {
-                            if (isSmall) {
-                                // 鑾峰彇鍘熸湁娈佃惤鐨勭涓�涓� XWPFRun
-                                String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
-                                XWPFParagraph oldParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getParagraphs().get(0);
-                                XWPFRun oldRun = oldParagraph.getRuns().get(0);
-                                // 淇濆瓨鍘熸湁鏍峰紡
-                                String fontFamily = oldRun.getFontFamily();
-                                int fontSize = oldRun.getFontSize();
-                                boolean isBold = oldRun.isBold();
-                                boolean isItalic = oldRun.isItalic();
-                                boolean isUnderline = oldRun.getUnderline() != UnderlinePatterns.NONE;
-                                // 鍒犻櫎鍘熸湁娈佃惤
-                                xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
-                                // 娣诲姞鏂版钀�
-                                XWPFParagraph newParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
-                                XWPFRun newRun = newParagraph.createRun();
-                                // 搴旂敤淇濆瓨鐨勬牱寮�
-                                newRun.setFontFamily(fontFamily);
-                                newRun.setFontSize(fontSize);
-                                newRun.setBold(isBold);
-                                newRun.setItalic(isItalic);
-                                if (isUnderline) {
-                                    newRun.setUnderline(UnderlinePatterns.SINGLE);
-                                }
-                                // 璁剧疆鏂版枃鏈�
-                                String[] split = text.split("@");
-                                newRun.setText(split[0]);
-                                if (split.length > 1) {
-                                    newRun.addBreak();
-                                    newRun.setText(split[1]);
-                                }
-                                // 璁剧疆娈佃惤瀵归綈鏂瑰紡
-                                newParagraph.setAlignment(ParagraphAlignment.CENTER);
-                            } else {
-                                String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
-                                String[] split = text.split("@");
-                                xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
-                                XWPFParagraph xwpfParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
-                                XWPFRun run = xwpfParagraph.createRun();
-                                run.setText(split[0]);
-                                if (ObjectUtils.isNotNull(split[1])) {
-                                    run.addBreak();
-                                    run.setText(split[1]);
-                                }
-                                xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
+
+        List<XWPFTable> xwpfTables1 = document.getTables();
+        for (int i = 1; i < xwpfTables1.size(); i++) {
+            for (int j = 0; j < xwpfTables1.get(i).getRows().size(); j++) {
+                for (int k = 0; k < xwpfTables1.get(i).getRows().get(j).getTableCells().size(); k++) {
+                    if (xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText().contains("@")) {
+                        if (isSmall) {
+                            // 鑾峰彇鍘熸湁娈佃惤鐨勭涓�涓� XWPFRun
+                            String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
+                            XWPFParagraph oldParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getParagraphs().get(0);
+                            XWPFRun oldRun = oldParagraph.getRuns().get(0);
+                            // 淇濆瓨鍘熸湁鏍峰紡
+                            String fontFamily = oldRun.getFontFamily();
+                            int fontSize = oldRun.getFontSize();
+                            boolean isBold = oldRun.isBold();
+                            boolean isItalic = oldRun.isItalic();
+                            boolean isUnderline = oldRun.getUnderline() != UnderlinePatterns.NONE;
+                            // 鍒犻櫎鍘熸湁娈佃惤
+                            xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
+                            // 娣诲姞鏂版钀�
+                            XWPFParagraph newParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
+                            XWPFRun newRun = newParagraph.createRun();
+                            // 搴旂敤淇濆瓨鐨勬牱寮�
+                            newRun.setFontFamily(fontFamily);
+                            newRun.setFontSize(fontSize);
+                            newRun.setBold(isBold);
+                            newRun.setItalic(isItalic);
+                            if (isUnderline) {
+                                newRun.setUnderline(UnderlinePatterns.SINGLE);
                             }
+                            // 璁剧疆鏂版枃鏈�
+                            String[] split = text.split("@");
+                            newRun.setText(split[0]);
+                            if (split.length > 1) {
+                                newRun.addBreak();
+                                newRun.setText(split[1]);
+                            }
+                            // 璁剧疆娈佃惤瀵归綈鏂瑰紡
+                            newParagraph.setAlignment(ParagraphAlignment.CENTER);
+                        } else {
+                            String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
+                            String[] split = text.split("@");
+                            xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
+                            XWPFParagraph xwpfParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
+                            XWPFRun run = xwpfParagraph.createRun();
+                            run.setText(split[0]);
+                            if (ObjectUtils.isNotNull(split[1])) {
+                                run.addBreak();
+                                run.setText(split[1]);
+                            }
+                            xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
                         }
                     }
                 }
             }
-            FileOutputStream fileOutputStream1 = new FileOutputStream(path);
-            document1.write(fileOutputStream1);
-            fileOutputStream1.close();
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
         }
     }
 
@@ -4210,7 +4240,6 @@
             License license = new License();
             license.setLicense(is);
             if (!license.getIsLicensed()) {
-                System.out.println("License楠岃瘉涓嶉�氳繃...");
                 return null;
             }
             //鐢熸垚涓�涓┖鐨凱DF鏂囦欢
@@ -4235,56 +4264,6 @@
             }
         }
         return null;
-    }
-
-    /**
-     * 娣诲姞宸ユ椂
-     * @param userId
-     * @param insProduct
-     * @param insOrder
-     */
-    private synchronized void addAuxiliary(Integer userId, InsProduct insProduct, InsOrder insOrder) {
-        if (insProduct.getIsBinding().equals(1)) {
-            return;
-        }
-
-        //棣栧厛鍒ゆ柇褰撳墠浜虹殑褰撳墠鏃堕棿鏄惁鏄帓鐝椂闂村唴,濡傛灉涓嶆槸灏辨槸鍔犵彮
-        LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
-
-        //鏍¢獙濡傛灉杩欎釜浜鸿繖涓娴嬮」鐩凡缁忔坊鍔犺繃浜�
-        List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
-                .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
-                .eq(AuxiliaryOutputWorkingHours::getInsProductId, insProduct.getId()));
-        if (CollectionUtils.isNotEmpty(count2s)) {
-            auxiliaryOutputWorkingHoursMapper.deleteBatchIds(count2s.stream().map(auxiliaryOutputWorkingHours -> auxiliaryOutputWorkingHours.getId()).collect(Collectors.toList()));
-        }
-        if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && StringUtils.isNotBlank(insProduct.getLastValue())) {
-            AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
-            auxiliaryOutputWorkingHours.setInspectionItemClass(insProduct.getInspectionItemClass());//妫�娴嬮」鍒嗙被
-            auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
-            auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
-            auxiliaryOutputWorkingHours.setSample(insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode());//鏍峰搧缂栧彿
-            auxiliaryOutputWorkingHours.setOrderId(insOrder.getId());//璁㈠崟id
-            auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
-            auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//闈炲姞鐝伐鏃�
-            auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
-            auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : BigDecimal.ZERO).add(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : BigDecimal.ZERO));//浜ч噺宸ユ椂
-            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);//妫�娴嬩汉
-            auxiliaryOutputWorkingHours.setPrice(insProduct.getPrice());//鍗曚环
-            auxiliaryOutputWorkingHours.setSampleId(insProduct.getInsSampleId());//鏍峰搧id
-            auxiliaryOutputWorkingHours.setInsProductId(insProduct.getId());//妫�楠岄」id
-
-            auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
-
-        }
     }
 
 }

--
Gitblit v1.9.3