| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveInsContext(Map<String, Object> insContext) { |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | CompletableFuture.supplyAsync(() -> { |
| | |
| | | } |
| | | result.setInsValue(JSON.toJSONString(iv)); |
| | | } |
| | | if (jo.get("comValue") != null) { |
| | | if (jo.get("comValue") != null && !Objects.equals(jo.get("comValue"), "")) { |
| | | JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue"))); |
| | | List<Map<String, Object>> cv = new ArrayList<>(); |
| | | for (Object o : jsonArray2) { |
| | |
| | | } |
| | | result.setComValue(JSON.toJSONString(cv)); |
| | | } |
| | | JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue"))); |
| | | if (resValue.get("v") != null) { |
| | | insProduct.setLastValue(JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v") + ""); |
| | | } |
| | | try { |
| | | JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue"))); |
| | | if (resValue.get("v") != null) { |
| | | Object o = JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v"); |
| | | insProduct.setLastValue(o==null?null:(o + "")); |
| | | } |
| | | }catch (Exception e){} |
| | | if (jo.get("equipValue") != null) { |
| | | JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue"))); |
| | | List<Map<String, Object>> ev = new ArrayList<>(); |
| | |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | }); |
| | | return null; |
| | | return insContext.keySet().stream().findFirst().orElse(null); |
| | | }).thenAccept(res -> { |
| | | if(res!=null){ |
| | | int pId = Integer.parseInt(res.replaceAll("\\D+", "")); |
| | | InsProduct insProduct = insProductMapper.selectById(pId); |
| | | // 通过pId 获取当前样本id |
| | | int sampleId = insProductMapper.selectById(pId).getInsSampleId(); |
| | | // 通过样本id获取订单id |
| | | int orderId = insSampleMapper.selectById(sampleId).getInsOrderId(); |
| | | // 通过订单id查找所有样本id |
| | | List<Integer> sampleIds = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList()); |
| | | // 通过检查每一个样本id查到属于检验项结论 is null的数量 |
| | | Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, sampleIds).isNull(InsProduct::getInsResult).eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory())); |
| | | // is null的数量为0是将订单状态表的状态改为已检验 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, sampleIds).isNull(InsProduct::getInsResult).eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory())); |
| | | insProducts.forEach(insProduct1 -> { |
| | | System.out.println(insProduct1.getInsResult()); |
| | | System.out.println(insProduct1.getId()); |
| | | }); |
| | | if (count == 0) { |
| | | insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, orderId) |
| | | .eq(InsOrderState::getLaboratory, insProduct.getSonLaboratory()) |
| | | .set(InsOrderState::getInsState, 2)); |
| | | } |
| | | } |
| | | }).exceptionally(e -> { |
| | | e.printStackTrace(); |
| | | return null; |
| | |
| | | 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) { |
| | |
| | | if ("参数".equals(v.get("v"))) delSet.add(jo1.get("c") + ""); |
| | | } |
| | | } |
| | | // TODO: 2024/5/5 下列循环缺少word合并单元格的操作 |
| | | for (int i = 0; i < temp.size(); i++) { |
| | | JSONObject jo1 = temp.get(i); |
| | | TextRenderData textRenderData = new TextRenderData(); |
| | |
| | | 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) { |
| | |
| | | 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()); |
| | |
| | | } 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( |
| | |
| | | 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); |
| | |
| | | product.setTemplate(new ArrayList<>()); |
| | | continue; |
| | | } |
| | | if (set.add(product.getTemplateId())) { |
| | | if (product.getTemplateId() != null && set.add(product.getTemplateId())) { |
| | | map2.put(product.getTemplateId(), standardTemplateService.getStandTempThingById(product.getTemplateId()) + ""); |
| | | } |
| | | String thing = map2.get(product.getTemplateId()); |
| | |
| | | style.put("columnlen", config.get("columnlen")); |
| | | product.setTemplate(cellData); |
| | | product.setStyle(style); |
| | | product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId())); |
| | | } |
| | | } |
| | | } |