value
2024-04-29 ce7184b9b054e4cd98af2d747545d04ae85c2728
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -276,16 +276,16 @@
            List<Map<String, Object>> tables = new ArrayList<>();
            Set<String> standardMethod = new HashSet<>();
            Set<String> deviceSet = new HashSet<>();
            AtomicReference<String> models = new AtomicReference<>("");
            Set<String> models = new HashSet<>();
            AtomicReference<Integer> productSize = new AtomicReference<>(0);
            String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
            samples.forEach(a -> {
                models.add(a.getModel());
                Set<String> templateSet = new HashSet<>();
                getTemplateThing(set, map2, a);
                for (InsProduct b : a.getInsProduct()) {
                    models.set(models.get()+b.getModel());
                    standardMethod.add(b.getMethodS());
                    productSize.set(productSize.get()+1);
                    productSize.set(productSize.get() + 1);
                    if (b.getInsProductResult() != null) {
                        List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class);
                        for (JSONObject jsonObject : jsonObjects) {
@@ -509,7 +509,8 @@
            String url;
            try {
                InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
                File file = File.createTempFile("temp", ".tmp");OutputStream outputStream = new FileOutputStream(file);
                File file = File.createTempFile("temp", ".tmp");
                OutputStream outputStream = new FileOutputStream(file);
                IOUtils.copy(inputStream, outputStream);
                url = file.getAbsolutePath();
            } catch (FileNotFoundException e) {
@@ -525,8 +526,7 @@
            tables.forEach(table -> {
                table.put("tableSize", tables.size() + 1);
            });
//            List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
            List<Map<String, String>> deviceList = new ArrayList<>();
            List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
            Map<String, String> codeStr = new HashMap<>();
            codeStr.put("报告编号", insReport.getCode());
            codeStr.put("样品名称", insOrder.getSample());
@@ -539,6 +539,11 @@
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            String modelStr = "";
            for (String model : models) {
                modelStr += "," + model;
            }
            String finalModelStr = modelStr;
            ConfigureBuilder builder = Configure.builder();
            builder.useSpringEL(true);
            XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
@@ -553,19 +558,19 @@
                        put("standardMethod", standardMethod2);
                        put("deviceList", deviceList);
                        put("twoCode", Pictures.ofLocal(codePath).create());
                        put("models", models);
                        put("models", finalModelStr.replace(",", ""));
                        put("productSize", productSize);
                        put("createTime", now.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
                        put("createTimeEn", monthNames[now.getMonthValue()-1]+" "+now.getDayOfMonth()+", "+now.getYear());
                        put("createTimeEn", monthNames[now.getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                        put("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue()-1]+" "+now.getDayOfMonth()+", "+now.getYear());
                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                        put("writeUrl", null);
                        put("insUrl", null);
                        put("examineUrl", null);
                        put("ratifyUrl", null);
                    }});
            try {
                String name = now.format(DateTimeFormatter.ofPattern("yy_MM_dd&HH_mm_ss")) + ".docx";
                String name = insReport.getCode().replace("/", "") + ".docx";
                template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
                insReport.setUrl("/word/" + name);
                insReportMapper.insert(insReport);
@@ -598,6 +603,7 @@
                style.put("columnlen", config.get("columnlen"));
                product.setTemplate(cellData);
                product.setStyle(style);
                product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId()));
            }
        }
    }