framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java
@@ -33,7 +33,7 @@ String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); String date2 = LocalDate.now().format(DateTimeFormatter.ofPattern(patten)); int num; num = systemLogMapper.countRowsByNow3(tableName, companyId, laboratory, LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"))) + 1; num = systemLogMapper.countRowsByNow3(tableName, companyId, laboratory, LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) + 1; String nums = num + ""; if (nums.length() == 1) nums = "00" + num; else if (nums.length() == 2) nums = "0" + num; inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderPlanController.java
@@ -138,9 +138,9 @@ @ApiOperation(value = "保存检验内容") @PostMapping("/saveInsContext") @ValueAuth public Result<?> saveInsContext(String param) { public Result<?> saveInsContext(String param,Integer num) { Map<String, Object> param2 = JSON.parseObject(param, Map.class); insOrderPlanService.saveInsContext(param2); insOrderPlanService.saveInsContext(param2,num); return Result.success(); } @@ -215,13 +215,6 @@ return Result.success(insOrderPlanService.deleteInsContext(insProductResultVo)); } @ApiOperation(value = "电路试验的删除互调") @PostMapping("/deleteInsContext2") @ValueAuth public Result<?> deleteInsContext2(String frequency,Integer productId,String often) { return Result.success(insOrderPlanService.deleteInsContext2(frequency,productId,often)); } @ApiOperation(value = "电路试验点击检验选择版本") @PostMapping("/chooseVersion") @ValueAuth @@ -231,4 +224,12 @@ orderState.setVersion(version); return Result.success(insOrderStateService.updateById(orderState)); } @ValueClassify("检验任务") @PostMapping("/getInsProduct2") @ApiOperation("查看检验历史") public Result<?> getInsProduct2(Integer id, Integer type, String laboratory, HttpServletRequest request,Integer num) { return Result.success(insOrderPlanService.getInsProduct2(id, type, laboratory, request,num)); } } inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java
@@ -148,4 +148,11 @@ public Result upAll(MultipartFile file) throws IOException { return Result.success(insReportService.upAll(file)); } @ValueClassify("报告编制") @ApiOperation(value = "判断是否生成总报告") @PostMapping("/isReport") public Result isReport(Integer id,Integer state) { return Result.success(insReportService.isReport(id,state)); } } inspect-server/src/main/java/com/yuanchu/mom/dto/SampleProductDto.java
@@ -22,4 +22,7 @@ //检验人 private String checkName; //次数(检验次数) private Integer num1; } inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
@@ -30,22 +30,29 @@ IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, @Param("ew") QueryWrapper<InsOrderPlanDTO> ew, @Param("userId") Integer userId, @Param("sonLaboratory") String sonLaboratory, @Param("laboratory") String laboratory); List<SampleProductDto> selectSampleProductListByOrderId(Integer id); List<SampleProductDto> selectSampleProductListByOrder2Id(Integer id); List<SampleProductDto> selectSampleProductListByOrderId2(Integer id); List<SampleProductDto> selectSampleProductListByOrder2Id2(Integer id); List<SampleProductDto3> selectSampleProductListByOrderId3(List<Integer> ids); List<SampleProductDto> getInsOrderAndSample(Integer id, String laboratory); List<SampleProductDto> getInsOrderAndSample2(Integer id, String laboratory); String getSampleEn(String sample); List<InsProduct> getInsProduct1(Integer id, String laboratory); List<InsProduct> getInsProduct1(@Param("id") Integer id, @Param("laboratory") String laboratory); List<InsProduct> getIns2Product1(@Param("id") Integer id, @Param("laboratory") String laboratory); List<InsProduct> get2InsProduct1(@Param("id") Integer id, @Param("laboratory") String laboratory, @Param("num") Integer num); List<Map<String, Object>> getReportModel(@Param("orderId") Integer orderId, @Param("id") Integer id, @Param("laboratory") String laboratory); SampleVo getDetailById(Integer sampleId); String selMethodById(Integer sampleId); List<Map<String, String>> selectSampleList(Integer orderId); } inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrderState.java
@@ -87,4 +87,9 @@ * 针对电路试验选择的版本 */ private Integer version; /** * 次数(检测次数) */ private Integer num; } inspect-server/src/main/java/com/yuanchu/mom/pojo/InsProductResult.java
@@ -58,4 +58,9 @@ @TableField(fill = FieldFill.INSERT_UPDATE) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; /** * 次数(检测次数) */ private Integer num; } inspect-server/src/main/java/com/yuanchu/mom/pojo/InsProductResult2.java
@@ -59,9 +59,10 @@ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; @ApiModelProperty("频率") @ApiModelProperty("频段") private String frequency; @ApiModelProperty("频率") @ApiModelProperty("频点") private String often; @ApiModelProperty("端口") @@ -75,4 +76,9 @@ @ApiModelProperty("结论 0不合格 1合格") private Integer result; /** * 次数(检测次数) */ private Integer num; } inspect-server/src/main/java/com/yuanchu/mom/service/InsOrderPlanService.java
@@ -23,7 +23,7 @@ boolean claimInsOrderPlan(InsOrderPlanDTO entity); //普通的保存检验内容 void saveInsContext(Map<String, Object> insContext); void saveInsContext(Map<String, Object> insContext,Integer num); //电路试验的保存检验内容 List<Integer> saveInsContext2(InsProductResultDto insProductResultDtos); @@ -37,6 +37,7 @@ int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode); List<InsProduct> getInsProduct(Integer id, Integer type, String laboratory, HttpServletRequest request); List<InsProduct> getInsProduct2(Integer id, Integer type, String laboratory, HttpServletRequest request,Integer num); List<String> checkSubmitPlan(Integer orderId, String laboratory); @@ -52,5 +53,4 @@ int deleteInsContext(InsProductResultVo insProductResultVo); int deleteInsContext2(String frequency, Integer productId, String often); } inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java
@@ -38,4 +38,7 @@ String downAll(String ids); int upAll(MultipartFile file) throws IOException; //是否生成总报告 int isReport(Integer id,Integer state); } inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -244,6 +244,34 @@ case 0: //样品 insProducts = insSampleMapper.getInsProduct1(id, laboratory); if (insProducts.size()==0){ insProducts = insSampleMapper.getIns2Product1(id, laboratory); } break; case 1: //光纤带 break; case 2: //光纤 break; case 3: //套管 break; } Set<Integer> set = new HashSet<>(); Map<Integer, String> map2 = new HashMap<>(); if (BeanUtil.isEmpty(insProducts)) return null; getTemplateThing(set, map2, insProducts); return insProducts; } @Override public List<InsProduct> getInsProduct2(Integer id, Integer type, String laboratory, HttpServletRequest request,Integer num) { List<InsProduct> insProducts = new ArrayList<>(); switch (type) { case 0: //样品 insProducts = insSampleMapper.get2InsProduct1(id, laboratory,num); break; case 1: //光纤带 @@ -515,20 +543,13 @@ public int deleteInsContext(InsProductResultVo insProductResultVo) { return insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() .eq(InsProductResult2::getFrequency, insProductResultVo.getFrequency()) .eq(InsProductResult2::getNum, insProductResultVo.getNum()) .in(InsProductResult2::getInsProductId, insProductResultVo.getProductIds())); } @Override public int deleteInsContext2(String frequency, Integer productId, String often) { return insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery() .eq(InsProductResult2::getFrequency, frequency) .eq(InsProductResult2::getInsProductId, productId) .eq(InsProductResult2::getOften, often)); } @Override public void saveInsContext(Map<String, Object> insContext) { public void saveInsContext(Map<String, Object> insContext,Integer num) { Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); CompletableFuture.supplyAsync(() -> { insContext.forEach((k, v) -> { @@ -544,6 +565,7 @@ result = results.get(0); } result.setInsProductId(Integer.parseInt(k)); result.setNum(num); //检验值 if (jo.get("insValue") != null) { JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue"))); @@ -750,17 +772,24 @@ Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); //查询检验单信息 InsOrder insOrder = insOrderMapper.selectById(insProductResultDtos.getOrderId()); InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId()) .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() .in(InsProductResult2::getInsProductId, insProductResultDtos.getInsProductResult2s().stream().map(InsProductResult2::getInsProductId).distinct().collect(Collectors.toList())) .eq(InsProductResult2::getNum, orderState.getNum()) .eq(InsProductResult2::getFrequency, insProductResultDtos.getFrequency())); for (InsProductResult2 insProductResult2 : insProductResultDtos.getInsProductResult2s()) { InsProduct insProduct = new InsProduct(); insProduct.setId(insProductResult2.getInsProductId());//项目id InsProductResult2 result2 = new InsProductResult2(); result2.setNum(orderState.getNum()); result2.setInsProductId(insProductResult2.getInsProductId()); //频率 result2.setFrequency(insProductResultDtos.getFrequency()); @@ -1036,7 +1065,7 @@ /*type=0 再次试验; type=1 继续试验 ; type=2 结束试验*/ switch (type) { case 0: /*再次试验:该单子退回到检验状态(排序改成当前的最后);*/ /*再次试验:该单子退回到检验状态(排序改成当前的最后),次数递增(保留以前的数据);*/ //更新原来的检验任务 // 查询根据 id 倒序排列的第一条记录 InsOrderState record = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() @@ -1052,6 +1081,7 @@ .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; @@ -1110,6 +1140,7 @@ insOrderState.setInsOrderId(orderId); insOrderState.setLaboratory(minElement); insOrderState.setInsState(0); insOrderState.setNum(1);//初始是第一次 insOrderStateMapper.insert(insOrderState); } else { //如果继续试验没有其他站点的检验任务那就结束试验 @@ -1125,629 +1156,9 @@ .set(InsOrderState::getInsState, 5) .set(InsOrderState::getVerifyTell, tell) .set(InsOrderState::getVerifyUser, userId)); /*生成报告*/ generateReport(orderId); break; } return 1; } //生成报告 private void generateReport(Integer orderId) { LocalDateTime now = LocalDateTime.now(); InsOrder insOrder = insOrderMapper.selectById(orderId); Map<String, String> user = insProductMapper.selectUserById(insOrder.getUserId()); //samples是过滤掉没有检验项目的样品 List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); InsReport insReport = new InsReport(); insReport.setCode(insOrder.getEntrustCode()); insReport.setInsOrderId(orderId); List<Map<String, Object>> tables = new ArrayList<>(); Set<String> standardMethod = new HashSet<>(); Set<String> deviceSet = new HashSet<>(); 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"}; AtomicReference<String> resultCh = new AtomicReference<>(""); AtomicReference<String> resultEn = new AtomicReference<>(""); /*基础报告(7列)*/ samples.forEach(a -> { Set<Integer> set = new HashSet<>(); Map<Integer, String> map2 = new HashMap<>(); Long productCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, a.getId())); productSize.set(productSize.get() + Integer.parseInt(productCount + "")); models.add(a.getModel()); standardMethod.add(baseMapper.getStandardMethodCode(a.getStandardMethodListId())); getTemplateThing(set, map2, a.getInsProduct()); for (InsProduct b : a.getInsProduct()) { if (b.getInsProductResult() != null) { List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class); for (JSONObject jsonObject : jsonObjects) { if (!"".equals(jsonObject.get("v") + "")) { deviceSet.add(jsonObject.get("v") + ""); } } } } AtomicInteger index = new AtomicInteger(); Set<String> itemSet = new HashSet<>(); List<RowRenderData> rows = new ArrayList<>(); //表格的行数 for (int i = 0; i < 3 + a.getInsProduct().size(); i++) { RowRenderData rowRenderData = new RowRenderData(); RowStyle rowStyle = new RowStyle(); rowStyle.setHeight(40); rowRenderData.setRowStyle(rowStyle); List<CellRenderData> cells = new ArrayList<>(); if (i >= 2 && i < 2 + a.getInsProduct().size()) { if (itemSet.add(a.getInsProduct().get(i - 2).getInspectionItem())) { index.getAndIncrement(); } } //列数 for (int j = 0; j < 7; j++) { CellRenderData cellRenderData = new CellRenderData(); CellStyle cellStyle = new CellStyle(); cellStyle.setVertAlign(XWPFTableCell.XWPFVertAlign.CENTER); cellRenderData.setCellStyle(cellStyle); List<ParagraphRenderData> paragraphRenderDataList = new ArrayList<>(); ParagraphRenderData paragraphRenderData = new ParagraphRenderData(); ParagraphStyle paragraphStyle = new ParagraphStyle(); paragraphStyle.setAlign(ParagraphAlignment.CENTER); paragraphRenderData.setParagraphStyle(paragraphStyle); List<RenderData> renderData = new ArrayList<>(); TextRenderData textRenderData = new TextRenderData(); Style style = new Style(); style.setFontFamily("宋体"); style.setColor("000000"); textRenderData.setStyle(style); if (i == 0) { //第一行 if (j == 0 || j == 1) { //第一列和第二列 textRenderData.setText("样品编号@Sample number∑1"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 2 || j == 3) { //第三列和第四列 textRenderData.setText(a.getSampleCode() + "∑2"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 4) { //第五列 textRenderData.setText("规格型号@Type"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else { //第六列和第七列 textRenderData.setText(a.getModel() + "∑3"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } } else if (i == 1) { //第二行 if (j == 0) { //第一列 textRenderData.setText("序号@No."); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 1 || j == 2) { //第二列和第三列 textRenderData.setText("检测项目@Testing item∑4"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 3) { //第四列 textRenderData.setText("单位@Unit"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 4) { //第五列 textRenderData.setText("标准要求@Requirement"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 5) { //第六列 textRenderData.setText("检验结果@Test result"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else { //第七列 textRenderData.setText("结论@Conclusion"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } } else if (i == 2 + a.getInsProduct().size()) { //最后一行 if (j == 0 || j == 1) { //第一列和第二列 textRenderData.setText("备注∑5"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else { //其余列 textRenderData.setText("“√”表示项目合格,“×”表示项目不合格。@“√” indicates test item is qualified,“×” indicates test item is not qualified ∑6"); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } } else { //其余行 if (j == 0) { //第一列 textRenderData.setText(index + "∑2" + index); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 1) { //第二列 if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemSubclass())) { if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemEn())) { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "@" + a.getInsProduct().get(i - 2).getInspectionItemEn() + "∑3" + index); } else { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "∑3" + index); } } else { if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemEn())) { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "@" + a.getInsProduct().get(i - 2).getInspectionItemEn() + "∑3" + index); } else { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "∑3" + index); } } renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 2) { //第三列 if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemSubclass())) { if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemSubclassEn())) { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItemSubclass() + "@" + a.getInsProduct().get(i - 2).getInspectionItemSubclassEn()); } else { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItemSubclass()); } } else { if (ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getInspectionItemEn())) { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "@" + a.getInsProduct().get(i - 2).getInspectionItemEn() + "∑3" + index); } else { textRenderData.setText(a.getInsProduct().get(i - 2).getInspectionItem() + "∑3" + index); } } renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 3) { //第四列 textRenderData.setText(ObjectUtil.isNotEmpty(a.getInsProduct().get(i - 2).getUnit()) ? a.getInsProduct().get(i - 2).getUnit() : ""); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 4) { //第五列 textRenderData.setText(a.getInsProduct().get(i - 2).getTell()); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else if (j == 5) { //第六列 textRenderData.setText(a.getInsProduct().get(i - 2).getLastValue()); renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } else { //第七列 if (ObjectUtils.isEmpty(a.getInsProduct().get(i - 2).getInsResult())) { textRenderData.setText("-"); } else if (a.getInsProduct().get(i - 2).getInsResult() == 1) { textRenderData.setText("√"); } else if (a.getInsProduct().get(i - 2).getInsResult() == 0) { textRenderData.setText("×"); } else { textRenderData.setText("-"); } renderData.add(textRenderData); paragraphRenderData.setContents(renderData); paragraphRenderDataList.add(paragraphRenderData); cellRenderData.setParagraphs(paragraphRenderDataList); cells.add(cellRenderData); } } } rowRenderData.setCells(cells); if (rowRenderData.getCells().size() != 0) { rows.add(rowRenderData); } } TableRenderData tableRenderData = new TableRenderData(); tableRenderData.setRows(rows); List<TableRenderData> tables1 = new ArrayList<>(); tableRenderData.setRows(new ArrayList<>()); int totalHeight = 0; int pageHeightLimit = 450; // 假设每页的高度限制为500单位 int rowHeight = 0; List<RowRenderData> firstTwoRows = new ArrayList<>(); // 保存前两行以便复制到新表格 List<RowRenderData> endRows = new ArrayList<>(); // 保存最后一行备注以便复制到新表格 // 保存前两行以便复制到新表格 if (rows.size() >= 3) { firstTwoRows.add(rows.get(0)); firstTwoRows.add(rows.get(1)); endRows.add(rows.get(rows.size() - 1)); } for (RowRenderData row : rows) { rowHeight = calculateRowHeight(row); // 自定义方法计算行高 if (totalHeight + rowHeight > pageHeightLimit) { tableRenderData.getRows().addAll(endRows); // 创建新表格并复制前两行 TableRenderData newTableRenderData = new TableRenderData(); newTableRenderData.setRows(new ArrayList<>(firstTwoRows)); //设置样式 TableStyle tableStyle = new TableStyle(); tableStyle.setColWidths(new int[]{650, 1600, 2000, 750, 2800, 1100, 1100}); tableStyle.setWidth("10000"); tableStyle.setAlign(TableRowAlign.CENTER); BorderStyle borderStyle = new BorderStyle(); borderStyle.setColor("000000"); borderStyle.setType(XWPFTable.XWPFBorderType.THICK); borderStyle.setSize(14); tableStyle.setLeftBorder(borderStyle); tableStyle.setTopBorder(borderStyle); tableStyle.setRightBorder(borderStyle); tableStyle.setBottomBorder(borderStyle); tableRenderData.setTableStyle(tableStyle); newTableRenderData.setTableStyle(tableStyle); tables1.add(tableRenderData); tableRenderData = newTableRenderData; totalHeight = 0; } totalHeight += rowHeight; tableRenderData.getRows().add(row); } if (!tableRenderData.getRows().isEmpty()) { //设置样式 TableStyle tableStyle = new TableStyle(); tableStyle.setColWidths(new int[]{650, 1600, 2000, 750, 2800, 1100, 1100}); tableStyle.setWidth("10000"); tableStyle.setAlign(TableRowAlign.CENTER); BorderStyle borderStyle = new BorderStyle(); borderStyle.setColor("000000"); borderStyle.setType(XWPFTable.XWPFBorderType.THICK); borderStyle.setSize(14); tableStyle.setLeftBorder(borderStyle); tableStyle.setTopBorder(borderStyle); tableStyle.setRightBorder(borderStyle); tableStyle.setBottomBorder(borderStyle); tableRenderData.setTableStyle(tableStyle); tables1.add(tableRenderData); } tables1.forEach(table -> { Map<String, Object> tableMap = new HashMap<>(); tableMap.put("table", table); tableMap.put("report", insReport); tables.add(tableMap); }); }); String url; try { InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); File file = File.createTempFile("temp", ".tmp"); OutputStream outputStream = new FileOutputStream(file); IOUtils.copy(inputStream, outputStream); url = file.getAbsolutePath(); } catch (FileNotFoundException e) { throw new ErrorException("找不到模板文件"); } catch (IOException e) { throw new RuntimeException(e); } StringBuilder standardMethod2 = new StringBuilder(); for (String s : standardMethod) { standardMethod2.append("、").append(s); } standardMethod2.replace(0, 1, ""); tables.forEach(table -> { table.put("tableSize", tables.size() + 1); }); List<Map<String, String>> deviceList = null; if (deviceSet.size() != 0) { deviceList = insOrderMapper.selectDeviceList(deviceSet); } Map<String, String> codeStr = new HashMap<>(); codeStr.put("报告编号", insReport.getCode()); codeStr.put("样品名称", insOrder.getSample()); codeStr.put("规格型号", samples.get(0).getModel()); codeStr.put("发放日期", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); String codePath; try { codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{", "") .replaceAll("}", "").replaceAll(",", "").replaceAll("\"", ""), twoCode); } catch (Exception e) { throw new RuntimeException(e); } String modelStr = ""; for (String model : models) { modelStr += "," + model; } String finalModelStr = modelStr; String sampleEn = insSampleMapper.getSampleEn(insOrder.getSample()); String orderType = insOrderMapper.getEnumLabelByValue(insOrder.getOrderType()); String formType = insOrderMapper.getEnumLabelByValue(insOrder.getFormType()); ConfigureBuilder builder = Configure.builder(); builder.useSpringEL(true); List<Map<String, String>> finalDeviceList = deviceList; Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() .eq(InsSampleUser::getInsSampleId, orderId).last("limit 1")).getUserId(); String signatureUrl; try { signatureUrl = userMapper.selectById(userId).getSignatureUrl(); } catch (Exception e) { throw new ErrorException("找不到检验人的签名"); } if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) { throw new ErrorException("找不到检验人的签名"); } Custom custom = customMapper.selectById(insOrder.getCompanyId()); if (!resultCh.get().equals("")) { resultCh.set("依据委托要求," + resultCh.get().replaceFirst("、", "") + "等所检项目不符合要求,其余所检项目均符合要求。"); resultEn.set("According to commissioned requirements," + resultEn.get().replaceFirst("、", "") + " these inspected items do not meet the requirements, all other inspected items meet the requirements."); } else { resultCh.set("依据委托要求,所检项目均符合要求。"); resultEn.set("According to commissioned requirements, all the tested items meet the requirements."); } /*获取附件图片类型*/ List<Map<String, Object>> images = new ArrayList<>(); List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery().eq(InsOrderFile::getType, 1).eq(InsOrderFile::getInsOrderId, orderId)); if (CollectionUtils.isNotEmpty(insOrderFiles)) { insOrderFiles.forEach(insOrderFile -> { Map<String, Object> image = new HashMap<>(); PictureRenderData pictureRenderData = Pictures.ofLocal(imgUrl + "/" + insOrderFile.getFileUrl()).sizeInCm(17, 20).create(); image.put("url", pictureRenderData); image.put("report", insReport); images.add(image); }); } //委托人和电话字段判断 if (ObjectUtils.isEmpty(insOrder.getPrepareUser())) { insOrder.setPrepareUser("/"); } if (ObjectUtils.isEmpty(insOrder.getPhone())) { insOrder.setPhone("/"); } //检验项目的环境 InsProduct insProduct = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).eq(InsProduct::getInsSampleId, samples.get(0).getId())).get(0); String environment = ""; environment = (ObjectUtils.isNotEmpty(insProduct.getTemperature()) ? insProduct.getTemperature() + "℃ " : "") + (ObjectUtils.isNotEmpty(insProduct.getHumidity()) ? insProduct.getHumidity() + "%" : ""); String finalEnvironment = environment; XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( new HashMap<String, Object>() {{ put("order", insOrder); put("report", insReport); put("environment", finalEnvironment); put("custom", custom); put("sampleSize", samples.size()); put("tables", tables); put("tableSize", tables.size() + 1); put("standardMethod", (standardMethod2.toString().equals("null") ? "" : standardMethod2)); put("deviceList", finalDeviceList); put("twoCode", Pictures.ofLocal(codePath).create()); 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("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + insOrder.getInsTime().getDayOfMonth() + ", " + insOrder.getInsTime().getYear()); put("writeUrl", null); put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); put("images", images); put("examineUrl", null); put("ratifyUrl", null); put("sampleEn", sampleEn); put("orderType", orderType); put("getTime", insOrder.getExamineTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); put("getTimeEn", monthNames[insOrder.getExamineTime().getMonthValue() - 1] + " " + insOrder.getExamineTime().getDayOfMonth() + ", " + insOrder.getExamineTime().getYear()); put("seal1", null); put("seal2", null); put("formTypeCh", formType); put("formTypeEn", insOrder.getFormType()); put("resultCh", resultCh.get()); put("resultEn", resultEn.get()); }}); try { String name = insReport.getCode().replace("/", "") + ".docx"; template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name))); insReport.setUrl("/word/" + name); insReportMapper.insert(insReport); insOrder.setInsState(5); insOrderMapper.updateById(insOrder); } catch (IOException e) { throw new RuntimeException(e); } // 处理合并单元格的问题 String path = wordUrl + "/" + insReport.getCode().replace("/", "") + ".docx"; try { FileInputStream stream = new FileInputStream(path); XWPFDocument document = new XWPFDocument(stream); List<XWPFTable> xwpfTables = document.getTables(); for (int i = 1; i < xwpfTables.size() - (deviceList == null ? 1 : 2); i++) { Set<String> set1 = new HashSet<>(); 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("∑"); 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); } } 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<String> list = new ArrayList<>(); for (String s : maps.keySet()) { list.add(s); } 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")) { 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("@")) { 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); } } // 计算行高的方法 private int calculateRowHeight(RowRenderData rowRenderData) { // 实现计算逻辑,可能需要根据单元格内容和字体等参数进行计算 int height = 0; for (CellRenderData cell : rowRenderData.getCells()) { int cellHeight = estimateCellHeight(cell); // 根据内容估算单元格高度 if (cellHeight > height) { height = cellHeight; } } return height; } //根据单元格的文本内容计算实际行高 private int estimateCellHeight(CellRenderData cellRenderData) { // 假设默认行高是40 int defaultHeight = 40; // 获取单元格中的所有段落 List<ParagraphRenderData> paragraphs = cellRenderData.getParagraphs(); int estimatedHeight = 0; // 遍历段落,估算每个段落的高度 for (ParagraphRenderData paragraph : paragraphs) { List<RenderData> contents = paragraph.getContents(); for (RenderData content : contents) { if (content instanceof TextRenderData) { TextRenderData text = (TextRenderData) content; Style style = text.getStyle(); // 假设每行文本的高度为字体大小的1.2倍 Double fontSize = Objects.isNull(style.getFontSize()) ? 12.0 : style.getFontSize(); int lines = (int) Math.ceil(text.getText().length() / 15.0); // 假设每行约15个字符 int textHeight = (int) (fontSize * 1.2 * lines); // 累加段落的高度 estimatedHeight += textHeight; } } } // 返回最大值,确保高度不低于默认高度 return Math.max(estimatedHeight, defaultHeight); } private void getTemplateThing(Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) { @@ -1777,7 +1188,13 @@ @Override public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) { List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() .eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery() .eq(InsOrderState::getInsOrderId, orderId) .eq(InsOrderState::getLaboratory, laboratory) .orderByDesc(InsOrderState::getId) .last("LIMIT 1"));// 确保只取一条记录 List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() .in(InsProduct::getInsSampleId, ids) @@ -1804,6 +1221,7 @@ //电路试验的检验项目,需要在提交的时候再去赋值合格与不合格 if (product.getInspectionItem().equals("电路试验")) { List<Integer> collect = insProductResult2Mapper.selectList(Wrappers.<InsProductResult2>lambdaQuery() .eq(InsProductResult2::getNum, orderState.getNum()) .eq(InsProductResult2::getInsProductId, product.getId())).stream().map(InsProductResult2::getResult).distinct().collect(Collectors.toList()); if (collect.contains(0)) { product.setInsResult(0);//不合格 @@ -1871,6 +1289,7 @@ List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList()); for (Integer ip : ips) { List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() .eq(InsProductResult::getNum, orderState.getNum()) .eq(InsProductResult::getInsProductId, ip)); if (insProductResults.size() > 1) { for (int i = 1; i < insProductResults.size(); i++) { @@ -1884,19 +1303,6 @@ String key = "frequency" + ":" + entrustCode + ":*"; RedisUtil.delsLike(key); return 1; } // 获取两个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) { inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -144,6 +144,7 @@ insOrderState.setInsOrderId(orderId); insOrderState.setLaboratory(sonLaboratory); insOrderState.setInsState(0); insOrderState.setNum(1);//初始是第一次 insOrderStateMapper.insert(insOrderState); //这里是在给分配的指定的人和试验室下发检验人 if (userId != null) { @@ -381,6 +382,9 @@ Map<String, Object> map = new HashMap<>(); InsOrder insOrder = insOrderMapper.selectById(id); List<SampleProductDto> list = insSampleMapper.selectSampleProductListByOrderId2(id); if (list.size()==0){ list = insSampleMapper.selectSampleProductListByOrder2Id2(id); } map.put("insOrder", insOrder); map.put("sampleProduct", list); return map; @@ -393,20 +397,10 @@ insOrder.setExamineTime(LocalDateTime.now()); if (insOrder.getState() == 1) { //审核通过才会生成委托编号 String code = baseMapper.selLaboratoryCode(insOrder.getLaboratory()); if (StringUtils.isEmpty(code)) { code = ""; } Custom custom = customMapper.selectById(order.getCompanyId()); System.out.println("=============" + custom.getCompany()); System.out.println("-------------" + order.getCompany()); String code2 = custom.getCode2(); if (!custom.getCompany().equals(order.getCompany())) { Custom one = customMapper.selectOne(Wrappers.<Custom>lambdaQuery().eq(Custom::getCompany, order.getCompany())); insOrder.setCompanyId(one.getId()); code2 = one.getCode2(); } insOrder.setEntrustCode(giveCode.giveCode2("JCZX/" + code + "-" + code2 + "-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMM")); insOrder.setEntrustCode(giveCode.giveCode2("TXJC-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMMdd")); //系统查询站点任务分布情况,将检验任务下发至最少的站台 List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() .eq(InsSample::getInsOrderId, insOrder.getId()).select(InsSample::getId)); @@ -493,6 +487,9 @@ Map<String, Object> map = new HashMap<>(); InsOrder insOrder = insOrderMapper.selectById2(id); List<SampleProductDto> list = insSampleMapper.getInsOrderAndSample(id, laboratory); if (list.size()==0){ list=insSampleMapper.getInsOrderAndSample2(id, laboratory); } for (SampleProductDto sampleProductDto : list) { List<Integer> ids = sampleProductDto.getInsProduct().stream().map(InsProduct::getId).collect(Collectors.toList()); List<InsProductUser> insProductUsers = insProductUserMapper.selectList(Wrappers.<InsProductUser>lambdaQuery() inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
@@ -1,12 +1,23 @@ package com.yuanchu.mom.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.aspose.words.*; import com.aspose.words.Document; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.data.Pictures; import com.deepoove.poi.config.Configure; import com.deepoove.poi.config.ConfigureBuilder; import com.deepoove.poi.data.*; import com.deepoove.poi.data.style.*; import com.deepoove.poi.data.style.Style; import com.deepoove.poi.util.TableTools; import com.itextpdf.text.BadElementException; import com.itextpdf.text.DocumentException; import com.itextpdf.text.pdf.PdfContentByte; @@ -15,16 +26,18 @@ import com.yuanchu.mom.common.GetLook; import com.yuanchu.mom.common.PrintChina; import com.yuanchu.mom.dto.ReportPageDto; import com.yuanchu.mom.dto.SampleProductDto; import com.yuanchu.mom.exception.ErrorException; import com.yuanchu.mom.mapper.InsOrderMapper; import com.yuanchu.mom.mapper.InsReportMapper; import com.yuanchu.mom.mapper.UserMapper; import com.yuanchu.mom.pojo.InsOrder; import com.yuanchu.mom.pojo.InsReport; import com.yuanchu.mom.pojo.User; import com.yuanchu.mom.mapper.*; import com.yuanchu.mom.pojo.*; import com.yuanchu.mom.service.InsReportService; import com.yuanchu.mom.service.StandardTemplateService; import com.yuanchu.mom.utils.JackSonUtil; import com.yuanchu.mom.utils.MatrixToImageWriter; import com.yuanchu.mom.utils.QueryWrappers; import com.yuanchu.mom.vo.Result; import org.apache.commons.io.IOUtils; import org.apache.poi.xwpf.usermodel.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -44,6 +57,8 @@ import java.util.*; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -73,8 +88,32 @@ @Value("${file.path}") private String imgUrl; @Value("${twoCode}") private String twoCode; @Resource private InsOrderMapper insOrderMapper; @Resource private InsOrderStateMapper insOrderStateMapper; @Resource private InsProductMapper insProductMapper; @Resource private InsSampleMapper insSampleMapper; @Resource private InsSampleUserMapper insSampleUserMapper; @Resource private CustomMapper customMapper; @Resource private InsOrderFileMapper insOrderFileMapper; @Resource private StandardTemplateService standardTemplateService; @Override public Map<String, Object> pageInsReport(Page page, ReportPageDto reportPageDto) { @@ -303,8 +342,7 @@ // 复制文件到指定路径 Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING); inReport("/word/" + pathName, insReport.getId()); } catch (IOException e) { } catch (IOException e) { throw new ErrorException("文件上传失败"); } } @@ -319,6 +357,28 @@ if (unzipDir.exists()) { deleteDirectory(unzipDir); // 删除旧的临时文件夹 } } return 0; } //是否需要生成报告: 0不需要;1需要 @Override @Transactional(rollbackFor = Exception.class) public int isReport(Integer id, Integer state) { //先判断该订单是否可以去生产报告 Long count = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery().eq(InsOrderState::getInsOrderId, id).eq(InsOrderState::getInsState, 5)); if (count > 0) { if (state == 1) { generateReport(id); } else { //结束订单 InsOrder insOrder = new InsOrder(); insOrder.setId(id); insOrder.setState(4); insOrderMapper.updateById(insOrder); } } else { throw new ErrorException("该订单还未结束试验,无法生产报告!"); } return 0; } @@ -425,6 +485,19 @@ os = new FileOutputStream(file); //要转换的word文件 com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); TableCollection tables = doc.getFirstSection().getBody().getTables(); for (Table table : tables) { RowCollection rows = table.getRows(); table.setAllowAutoFit(false); for (Row row : rows) { CellCollection cells = row.getCells(); for (Cell cell : cells) { CellFormat cellFormat = cell.getCellFormat(); cellFormat.setFitText(false); //设置自适应关闭 cellFormat.setWrapText(true); // 设置自动换行 } } } doc.save(os, SaveFormat.PDF); //添加骑缝章 @@ -503,6 +576,369 @@ } stamp.close(); } //生成报告 private void generateReport(Integer orderId) { LocalDateTime now = LocalDateTime.now(); InsOrder insOrder = insOrderMapper.selectById(orderId); //委托部门 departLims String departLims = userMapper.selectDepartLims(insOrder.getPrepareUser()); //samples是过滤掉没有检验项目的样品 List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); if (samples.size()==0){ samples=insSampleMapper.selectSampleProductListByOrder2Id(orderId); } String sampleCode = samples.get(0).getSampleCode(); InsReport insReport = new InsReport(); insReport.setCode(insOrder.getEntrustCode()); insReport.setInsOrderId(orderId); List<Map<String, Object>> tables = new ArrayList<>(); Set<String> standardMethod = new HashSet<>(); Set<String> deviceSet = new HashSet<>(); Set<String> models = new HashSet<>(); AtomicReference<Integer> productSize = new AtomicReference<>(0); AtomicReference<Integer> productSize1 = new AtomicReference<>(0); AtomicReference<Integer> productSize2 = new AtomicReference<>(0); AtomicReference<Integer> productSize3 = new AtomicReference<>(0); String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; samples.forEach(s -> { models.add(s.getModel()); standardMethod.add(insOrderMapper.getStandardMethodCode(s.getStandardMethodListId())); //总数 Long productCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, s.getId())); productSize.set(productSize.get() + Integer.parseInt(productCount + "")); //不判定 Long productCount1 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) .eq(InsProduct::getInsResult,3)); productSize1.set(productSize1.get() + Integer.parseInt(productCount1 + "")); //不合格 Long productCount2 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) .eq(InsProduct::getInsResult,0)); productSize2.set(productSize2.get() + Integer.parseInt(productCount2 + "")); //合格 Long productCount3 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) .eq(InsProduct::getInsResult,1)); productSize3.set(productSize3.get() + Integer.parseInt(productCount3 + "")); for (InsProduct b : s.getInsProduct()) { if (b.getInsProductResult() != null) { List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class); for (JSONObject jsonObject : jsonObjects) { if (!"".equals(jsonObject.get("v") + "")) { deviceSet.add(jsonObject.get("v") + ""); } } } if (b.getInsProductResult2() != null) { for (InsProductResult2 jsonObject : b.getInsProductResult2()) { if (jsonObject.getEquipValue() != null) { deviceSet.add(jsonObject.getEquipValue()); } } } } }); String url; try { InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); File file = File.createTempFile("temp", ".tmp"); OutputStream outputStream = new FileOutputStream(file); IOUtils.copy(inputStream, outputStream); url = file.getAbsolutePath(); } catch (FileNotFoundException e) { throw new ErrorException("找不到模板文件"); } catch (IOException e) { throw new RuntimeException(e); } StringBuilder standardMethod2 = new StringBuilder(); for (String s : standardMethod) { standardMethod2.append("、").append(s); } standardMethod2.replace(0, 1, ""); tables.forEach(table -> { table.put("tableSize", tables.size() + 1); }); List<Map<String, String>> deviceList = null; if (deviceSet.size() != 0) { deviceList = insOrderMapper.selectDeviceList(deviceSet); } Map<String, String> codeStr = new HashMap<>(); codeStr.put("报告编号", insReport.getCode()); codeStr.put("样品名称", insOrder.getSample()); codeStr.put("规格型号", samples.get(0).getModel()); codeStr.put("发放日期", now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); String codePath; try { codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{", "") .replaceAll("}", "").replaceAll(",", "").replaceAll("\"", ""), twoCode); } catch (Exception e) { throw new RuntimeException(e); } String modelStr = ""; for (String model : models) { modelStr += "," + model; } String finalModelStr = modelStr; String sampleEn = insSampleMapper.getSampleEn(insOrder.getSample()); String orderType = insOrderMapper.getEnumLabelByValue(insOrder.getOrderType()); String formType = insOrderMapper.getEnumLabelByValue(insOrder.getFormType()); ConfigureBuilder builder = Configure.builder(); builder.useSpringEL(true); List<Map<String, String>> finalDeviceList = deviceList; List<Map<String, String>> sampleList = insSampleMapper.selectSampleList(orderId); Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() .eq(InsSampleUser::getInsSampleId, orderId).last("limit 1")).getUserId(); String signatureUrl; try { signatureUrl = userMapper.selectById(userId).getSignatureUrl(); } catch (Exception e) { throw new ErrorException("找不到检验人的签名"); } if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) { throw new ErrorException("找不到检验人的签名"); } Custom custom = customMapper.selectById(insOrder.getCompanyId()); /*获取附件图片类型*/ List<Map<String, Object>> images = new ArrayList<>(); List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery().eq(InsOrderFile::getType, 1).eq(InsOrderFile::getInsOrderId, orderId)); if (CollectionUtils.isNotEmpty(insOrderFiles)) { insOrderFiles.forEach(insOrderFile -> { Map<String, Object> image = new HashMap<>(); PictureRenderData pictureRenderData = Pictures.ofLocal(imgUrl + "/" + insOrderFile.getFileUrl()).sizeInCm(17, 20).create(); image.put("url", pictureRenderData); image.put("report", insReport); images.add(image); }); } //委托人和电话字段判断 if (ObjectUtils.isEmpty(insOrder.getPrepareUser())) { insOrder.setPrepareUser("/"); } if (ObjectUtils.isEmpty(insOrder.getPhone())) { insOrder.setPhone("/"); } //检验项目的环境 InsProduct insProduct = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getState, 1).eq(InsProduct::getInsSampleId, samples.get(0).getId())).get(0); String environment = ""; environment = (ObjectUtils.isNotEmpty(insProduct.getTemperature()) ? insProduct.getTemperature() + "℃ " : "") + (ObjectUtils.isNotEmpty(insProduct.getHumidity()) ? insProduct.getHumidity() + "%" : ""); String finalEnvironment = environment; List<SampleProductDto> finalSamples = samples; XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( new HashMap<String, Object>() {{ put("order", insOrder); put("report", insReport); put("departLims", departLims); put("sampleCode", sampleCode); put("environment", finalEnvironment); put("custom", custom); put("sampleSize", finalSamples.size()); put("tables", tables); put("tableSize", tables.size() + 1); put("standardMethod", (standardMethod2.toString().equals("null") ? "" : standardMethod2)); put("deviceList", finalDeviceList); put("sampleList", sampleList); put("twoCode", Pictures.ofLocal(codePath).create()); put("models", finalModelStr.replace(",", "")); put("productSize", productSize); put("productSize1", productSize1); put("productSize2", productSize2); put("productSize3", productSize3); put("createTime", now.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); 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] + " " + insOrder.getInsTime().getDayOfMonth() + ", " + insOrder.getInsTime().getYear()); put("writeUrl", null); put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); put("images", images); put("examineUrl", null); put("ratifyUrl", null); put("sampleEn", sampleEn); put("orderType", orderType); put("getTime", insOrder.getExamineTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); put("getTimeEn", monthNames[insOrder.getExamineTime().getMonthValue() - 1] + " " + insOrder.getExamineTime().getDayOfMonth() + ", " + insOrder.getExamineTime().getYear()); put("seal1", null); put("seal2", null); put("formTypeCh", formType); put("formTypeEn", insOrder.getFormType()); }}); try { String name = insReport.getCode().replace("/", "") + ".docx"; template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name))); insReport.setUrl("/word/" + name); insReportMapper.insert(insReport); insOrder.setInsState(5); insOrderMapper.updateById(insOrder); } catch (IOException e) { throw new RuntimeException(e); } // 处理合并单元格的问题 String path = wordUrl + "/" + insReport.getCode().replace("/", "") + ".docx"; try { FileInputStream stream = new FileInputStream(path); XWPFDocument document = new XWPFDocument(stream); List<XWPFTable> xwpfTables = document.getTables(); for (int i = 1; i < xwpfTables.size() - (deviceList == null ? 1 : 2); i++) { Set<String> set1 = new HashSet<>(); 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("∑"); 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); } } 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(org.apache.poi.xwpf.usermodel.ParagraphAlignment.CENTER); } } } List<String> list = new ArrayList<>(); for (String s : maps.keySet()) { list.add(s); } 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")) { 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("@")) { 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(org.apache.poi.xwpf.usermodel.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); } } // 计算行高的方法 private int calculateRowHeight(RowRenderData rowRenderData) { // 实现计算逻辑,可能需要根据单元格内容和字体等参数进行计算 int height = 0; for (CellRenderData cell : rowRenderData.getCells()) { int cellHeight = estimateCellHeight(cell); // 根据内容估算单元格高度 if (cellHeight > height) { height = cellHeight; } } return height; } //根据单元格的文本内容计算实际行高 private int estimateCellHeight(CellRenderData cellRenderData) { // 假设默认行高是40 int defaultHeight = 40; // 获取单元格中的所有段落 List<ParagraphRenderData> paragraphs = cellRenderData.getParagraphs(); int estimatedHeight = 0; // 遍历段落,估算每个段落的高度 for (ParagraphRenderData paragraph : paragraphs) { List<RenderData> contents = paragraph.getContents(); for (RenderData content : contents) { if (content instanceof TextRenderData) { TextRenderData text = (TextRenderData) content; Style style = text.getStyle(); // 假设每行文本的高度为字体大小的1.2倍 Double fontSize = Objects.isNull(style.getFontSize()) ? 12.0 : style.getFontSize(); int lines = (int) Math.ceil(text.getText().length() / 15.0); // 假设每行约15个字符 int textHeight = (int) (fontSize * 1.2 * lines); // 累加段落的高度 estimatedHeight += textHeight; } } } // 返回最大值,确保高度不低于默认高度 return Math.max(estimatedHeight, defaultHeight); } 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<>()); continue; } String thing = null; if (product.getTemplateId() != null && set.add(product.getTemplateId())) { map2.put(product.getTemplateId(), standardTemplateService.getStandTempThingById(product.getTemplateId()) + ""); thing = map2.get(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"))); List<JSONObject> cellData = JSON.parseArray(JSON.toJSONString(sheet.get("celldata")), JSONObject.class); Map<String, Object> style = new HashMap<>(); style.put("rowlen", config.get("rowlen")); style.put("columnlen", config.get("columnlen")); product.setTemplate(cellData); product.setStyle(style); product.setTemplateName(standardTemplateService.getStandTempNameById(product.getTemplateId())); } } } } inspect-server/src/main/java/com/yuanchu/mom/vo/InsOrderPlanVO.java
@@ -52,5 +52,6 @@ private Integer sort; private Integer version; private Integer num1; } inspect-server/src/main/java/com/yuanchu/mom/vo/InsProductResultVo.java
@@ -8,6 +8,9 @@ //删除频段 public class InsProductResultVo { //次数 private Integer num; //频段 private String frequency; inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -27,7 +27,7 @@ <select id="findInsSampleAndOrder" resultType="com.yuanchu.mom.vo.InsOrderPlanVO"> select * from(select * from( SELECT a.*,ios.ins_state,ios.verify_tell,verify_user,ios.id orderStateId,ios.create_time,ios.sort,sort_time,version a.*,ios.ins_state,ios.verify_tell,verify_user,ios.id orderStateId,ios.create_time,ios.sort,sort_time,version,ios.num num1 FROM ( SELECT @@ -161,6 +161,7 @@ <select id="selectSampleProductListByOrderId" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, @@ -211,25 +212,110 @@ ipr2.equip_name equipName2, ip.method_s from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_order_id = #{id} where isa.ins_order_id = #{id} and state = 1 -- and ins_fiber_id is null -- and ins_fibers_id is null and <!--isa.sample_code NOT REGEXP '/'--> isa.id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) order by case when man_hour_group is NULL then 1 when man_hour_group ='' then 1 else 0 end, and ios.laboratory = #{laboratory} and (ipr2.num = ios.num or ipr2.num is null) and (ipr.num = ios.num or ipr.num is null) and isa.id in (select id1 from (select is2.id id1, ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null) s) order by case when man_hour_group is NULL then 1 when man_hour_group = '' then 1 else 0 end, CASE WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 如果以数字开头,则按照数字大小排序 WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2)AS UNSIGNED) END -- 提取字母后面的数字部分 WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED) END -- 提取字母后面的数字部分 , id asc </select> <select id="selectSampleProductListByOrder2Id" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_class, inspection_item_class_en, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, tell, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ipr2.frequency, ipr2.often, ipr2.port, ipr2.angle, ipr2.value, ipr2.result, ipr2.equip_value equipValue2, ipr2.equip_name equipName2, ip.method_s from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where isa.ins_order_id = #{id} and state = 1 and ios.laboratory = #{laboratory} and isa.id in (select id1 from (select is2.id id1, ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null) s) order by case when man_hour_group is NULL then 1 when man_hour_group = '' then 1 else 0 end, CASE WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 如果以数字开头,则按照数字大小排序 WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED) END -- 提取字母后面的数字部分 ,id asc </select> <select id="getInsOrderAndSample" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, @@ -284,12 +370,82 @@ ip.temperature, ip.humidity from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_order_id = #{id} where isa.ins_order_id = #{id} and state = 1 and ip.son_laboratory = #{laboratory} and ios.laboratory = #{laboratory} and (ipr2.num = ios.num or ipr2.num is null) and (ipr.num = ios.num or ipr.num is null) </select> <select id="getInsOrderAndSample2" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_class, inspection_item_class_en, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ipr.equip_name, ipr2.frequency, ipr2.often, ipr2.port, ipr2.angle, ipr2.value, ipr2.result, ipr2.equip_value equipValue2, ipr2.equip_name equipName2, ip.method_s, ip.tell, ip.dic, ip.temperature, ip.humidity from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where isa.ins_order_id = #{id} and state = 1 and ip.son_laboratory = #{laboratory} and ios.laboratory = #{laboratory} </select> <select id="getSampleEn" resultType="java.lang.String"> select name_en @@ -299,6 +455,7 @@ </select> <select id="selectSampleProductListByOrderId2" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, @@ -349,10 +506,83 @@ ipr2.equip_name equipName2, ip.method_s from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_order_id = #{id} where isa.ins_order_id = #{id} and ip.standard_method_list_id is not null and state = 1 and (ipr2.num = ios.num or ipr2.num is null) and (ipr.num = ios.num or ipr.num is null) order by case when man_hour_group is NULL then 1 when man_hour_group = '' then 1 else 0 end, CASE WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 如果以数字开头,则按照数字大小排序 WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED) END -- 提取字母后面的数字部分 , id asc </select> <select id="selectSampleProductListByOrder2Id2" resultMap="sampleDto"> select isa.*, ios.num num1, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_subclass, inspection_item_subclass_en, inspection_item_class, inspection_item_class_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, tell, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ipr2.frequency, ipr2.often, ipr2.port, ipr2.angle, ipr2.value, ipr2.result, ipr2.equip_value equipValue2, ipr2.equip_name equipName2, ip.method_s from ins_sample isa left join ins_order_state ios on isa.ins_order_id = ios.ins_order_id left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where isa.ins_order_id = #{id} and ip.standard_method_list_id is not null and state = 1 order by case @@ -365,7 +595,6 @@ THEN CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED) END -- 提取字母后面的数字部分 , id asc </select> <select id="selectSampleProductListByOrderId3" resultMap="sampleDto3"> select isa.id, sample_code, @@ -451,6 +680,8 @@ ip.tell, ip.dic from ins_product ip left join ins_sample isa on ip.ins_sample_id = isa.id left join ins_order_state ios on ios.ins_order_id = isa.ins_order_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_sample_id = #{id} @@ -458,7 +689,145 @@ and ip.son_laboratory = #{laboratory} and ins_fiber_id is null and ins_fibers_id is null and standard_method_list_id is not null and ip.standard_method_list_id is not null and ios.laboratory = #{laboratory} and (ipr2.num = ios.num or ipr2.num is null) and (ipr.num = ios.num or ipr.num is null) order by ipr.id, ipr2.id </select> <select id="getIns2Product1" resultMap="product"> select ip.id ip_id, inspection_item, inspection_item_en, inspection_item_class, inspection_item_class_en, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ipr.equip_name, ipr2.frequency, ipr2.often, ipr2.port, ipr2.angle, ipr2.value, ipr2.result, ipr2.equip_value equipValue2, ipr2.equip_name equipName2, ip.method_s, ip.tell, ip.dic from ins_product ip left join ins_sample isa on ip.ins_sample_id = isa.id left join ins_order_state ios on ios.ins_order_id = isa.ins_order_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_sample_id = #{id} and state = 1 and ip.son_laboratory = #{laboratory} and ins_fiber_id is null and ins_fibers_id is null and ip.standard_method_list_id is not null and ios.laboratory = #{laboratory} order by ipr.id, ipr2.id </select> <select id="get2InsProduct1" resultMap="product"> select ip.id ip_id, inspection_item, inspection_item_en, inspection_item_class, inspection_item_class_en, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ipr.equip_name, ipr2.frequency, ipr2.often, ipr2.port, ipr2.angle, ipr2.value, ipr2.result, ipr2.equip_value equipValue2, ipr2.equip_name equipName2, ip.method_s, ip.tell, ip.dic from ins_product ip left join ins_sample isa on ip.ins_sample_id = isa.id left join ins_order_state ios on ios.ins_order_id = isa.ins_order_id left join ins_product_result ipr on ip.id = ipr.ins_product_id left join ins_product_result_2 ipr2 on ip.id = ipr2.ins_product_id where ins_sample_id = #{id} and state = 1 and ip.son_laboratory = #{laboratory} and ins_fiber_id is null and ins_fibers_id is null and ip.standard_method_list_id is not null and ios.laboratory = #{laboratory} and ipr2.num = #{num} and ipr.num = #{num} order by ipr.id, ipr2.id </select> <select id="getReportModel" resultType="java.util.Map"> @@ -486,6 +855,7 @@ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="standardMethodListId" column="standard_method_list_id"/> <result property="unit" column="unit"/> <result property="num1" column="num1"/> <collection property="insProduct" resultMap="product"/> </resultMap> @@ -618,4 +988,11 @@ from standard_method where id = (select standard_method_list_id from ins_sample where id = #{sampleId}) </select> <select id="selectSampleList" resultType="java.util.Map"> select DISTINCT sample_code from ins_sample left join ins_product ip on ins_sample.id = ip.ins_sample_id where ins_order_id = #{orderId} and ip.id is not null </select> </mapper> inspect-server/src/main/resources/static/report-template.docxBinary files differ
user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java
@@ -24,4 +24,6 @@ User getCustom(Integer userId); List<User> getUser(); String selectDepartLims(String prepareUser); } user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java
@@ -162,7 +162,6 @@ user.setPhone(person.getPhoneNumber()); user.setEmail(person.getCompanyEmail()); user.setIsCustom(person.getCompanyId().equals("SC2463") ? 0 : 1); // user.setPassword(DigestUtils.md5DigestAsHex(headerToken.getPassword(person.getEmployeeID()).getBytes())); user.setPassword(DigestUtils.md5DigestAsHex("zttZTT123!".getBytes())); user.setCompany(BeanUtil.isNotEmpty(custom) ? (custom.getId() + "") : companyName); user.setAddress("未填写"); user-server/src/main/resources/mapper/UserMapper.xml
@@ -48,4 +48,8 @@ select * from user where state = 1 # where depart_lims_id=FIND_IN_SET(depart_lims_id, (select GROUP_CONCAT(id SEPARATOR ',') from department_lims where department_lims.name like '%实验室')) </select> <select id="selectDepartLims" resultType="java.lang.String"> select name from department_lims where id= (select SUBSTRING_INDEX(SUBSTRING_INDEX(depart_lims_id, ',', -2), ',', 1) AS depart_lims_id from user where name=#{prepareUser}) </select> </mapper>