inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java
@@ -150,6 +150,7 @@ return Result.success(insReportService.upAll(file)); } //取消2.26 @ValueAuth @ApiOperation(value = "查出该订单下每个样品下每个站点的检验次数") @GetMapping("/getInsOrderStateCount") @@ -157,6 +158,7 @@ return Result.success(insReportService.getInsOrderStateCount(id)); } //取消2.26 @ValueClassify("报告编制") @ApiOperation(value = "判断是否生成总报告") @PostMapping("/isReport") inspect-server/src/main/java/com/yuanchu/mom/mapper/InsOrderUserMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.dto.InsOrderUserDto; import com.yuanchu.mom.dto.InsReportDto1; import com.yuanchu.mom.pojo.InsOrderUser; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; @@ -26,4 +27,7 @@ IPage<InsOrderUserDto> selectInsOrderUserDto(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end, @Param("sonLaboratory") String sonLaboratory, Page page); IPage<InsOrderUserDto> selectInsOrderUserDto2(@Param("ids") List<Integer> ids, Page page); //根据订单id查询出需要生成报告的所有样品的所有数据 List<InsReportDto1> selectInsReportDto1(@Param("id") Integer id); } inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -979,7 +979,7 @@ @Override @Transactional(rollbackFor = Exception.class) public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) throws IOException { public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) { LocalDateTime now = LocalDateTime.now(); Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); List<InsUnPass> insUnPasses = new ArrayList<>(); @@ -1069,8 +1069,9 @@ } } insOrder.setState(4); insOrderMapper.updateById(insOrder); /*生成对应的检验报告*/ List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId()); createReport(insOrder.getId(),insReportDto1s); break; } } @@ -1079,7 +1080,7 @@ @Override @Transactional(rollbackFor = Exception.class) public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) throws IOException { public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) { Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); InsSample insSample = insSampleMapper.selectById(sampleId); InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId()); @@ -1103,7 +1104,6 @@ .set(InsOrderState::getVerifyUser, userId) .set(InsOrderState::getNum, record.getNum() + 1)//次数加1 .set(InsOrderState::getCreateTime, LocalDateTime.now())); insOrder.setState(1); break; case 1: //继续试验:该样品该站点任务结束(可以再次扫码检验); @@ -1126,7 +1126,6 @@ .set(InsOrderState::getVerifyTell, tell) .set(InsOrderState::getVerifyUser, userId)); } insOrder.setState(1); break; case 2: //结束试验:此委托单停止试验(无法再次检验)。 @@ -1155,17 +1154,31 @@ try{ outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode()); }catch (Exception e){ } } insOrder.setState(4); /*生成对应的检验报告*/ List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId()); createReport(insOrder.getId(),insReportDto1s); break; } insOrderMapper.updateById(insOrder); } return 1; } /*生成对应的检验报告*/ private void createReport(Integer orderId,List<InsReportDto1> insReportDto1s){ for (InsReportDto1 insReportDto1 : insReportDto1s) { if (ObjectUtils.isNotEmpty(insReportDto1.getInsReportDto2s())){ try{ wordUtils.generateReport(orderId, insReportDto1); }catch (Exception e){ throw new ErrorException("报告格式生成有误,请联系管理员!"); } } } } private void getTemplateThing (Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) { for (InsProduct product : insProducts) { inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
@@ -230,6 +230,7 @@ insReport.setState(0);//提交状态改为待提交 return insReportMapper.updateById(insReport); } insReportMapper.updateById(insReport); //获取批准人的签名地址 String signatureUrl; try { @@ -252,7 +253,15 @@ ProcessReport processReport = new ProcessReport(); processReport.setInsReportCode(insReport.getCode()); processReportMapper.insert(processReport); return insReportMapper.updateById(insReport); /*检验单结束*/ List<InsReport> insReports = insReportMapper.selectList(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getInsOrderId, insReport.getInsOrderId())); List<Integer> list = insReports.stream().map(InsReport::getIsRatify).distinct().collect(Collectors.toList()); if (list.size()==1 && list.contains(1)){ InsOrder insOrder = insOrderMapper.selectById(insReport.getInsOrderId()); insOrder.setState(4); insOrderMapper.updateById(insOrder); } return 0; } @Override inspect-server/src/main/java/com/yuanchu/mom/utils/FuSheUtils.java
@@ -60,6 +60,7 @@ Exceldata exceldata = new Exceldata(); Map<Integer, Object> project = new HashMap<>(); HashMap<String, Object> datas1 = new HashMap<>(); HashMap<String, Object> biaozhun = new HashMap<>(); Boolean exitLoop = false; for (int i = 0; i < workbook.getNumberOfSheets(); i++) { String s = ""; @@ -90,13 +91,39 @@ default: System.out.print("NULL\t"); } } else { } else { switch (cell.getCellType()) { case STRING: if (cell.getColumnIndex() == 1) { exitLoop = true; break; } // if (cell.getColumnIndex() == 1) { // if (cell.getStringCellValue().equals("指标")) { // for (Cell cell1 : row) { // switch (cell1.getCellType()) { // case STRING: // biaozhun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getStringCellValue()); // break; // case NUMERIC: // System.out.print(cell1.getNumericCellValue() + "\t"); // break; // case BOOLEAN: // System.out.print(cell1.getBooleanCellValue() + "\t"); // break; // case FORMULA: // System.out.print(cell1.getCellFormula() + "\t"); // break; // default: // System.out.print("NULL\t"); // } // } // }else { // exitLoop = true; // } // break; // } if (StringUtils.isNotEmpty(s)) { datas.put(s, list); } @@ -162,7 +189,6 @@ } } System.out.println(map); int size = map.size(); for (String s1 : map.keySet()) { String o = map.get(s1).toString(); List<String> collect = Arrays.stream(o.split(",")).collect(Collectors.toList()); @@ -183,7 +209,7 @@ } } System.out.println(map); createWord(sonLaboratory, document, exceldata, map, insOrderFile); createWord(sonLaboratory, document, exceldata, map, biaozhun, insOrderFile); } catch (IOException e) { e.printStackTrace(); } finally { @@ -255,28 +281,9 @@ default: System.out.print("NULL\t"); } } else if (row.getRowNum() == 1) { switch (cell.getCellType()) { case STRING: biaozhun.put(project.get(cell.getColumnIndex()).toString(), cell.getStringCellValue()); break; case NUMERIC: System.out.print(cell.getNumericCellValue() + "\t"); break; case BOOLEAN: System.out.print(cell.getBooleanCellValue() + "\t"); break; case FORMULA: System.out.print(cell.getCellFormula() + "\t"); break; default: System.out.print("NULL\t"); } } else if (row.getRowNum() > 2) { else if (row.getRowNum() > 2) { if (cell.getColumnIndex() == 0 && StringUtils.isNotEmpty(cell.getStringCellValue())) { if (map2.size() != 0) { map2.put(port, list); datas1.put(jiaodu, map2); @@ -320,7 +327,28 @@ } } } else { } else if (value.equals("指标")) { for (Cell cell1 : row) { switch (cell1.getCellType()) { case STRING: biaozhun.put(project.get(cell1.getColumnIndex()).toString(), cell1.getStringCellValue()); break; case NUMERIC: System.out.print(cell1.getNumericCellValue() + "\t"); break; case BOOLEAN: System.out.print(cell1.getBooleanCellValue() + "\t"); break; case FORMULA: System.out.print(cell1.getCellFormula() + "\t"); break; default: System.out.print("NULL\t"); } } } else { biaoji = true; } break; @@ -369,7 +397,6 @@ Map<String, List<HashMap<String, Object>>> numbers = (Map<String, List<HashMap<String, Object>>>) datas1.get(s); for (String s1 : numbers.keySet()) { List<HashMap<String, Object>> hashMaps = numbers.get(s1); List<Integer> floatList = new ArrayList<>(); for (Map<String, Object> number : hashMaps) { number.put("端口", s1); @@ -458,7 +485,7 @@ } //近场 public void createWord(String sonLaboratory, XWPFDocument document, Exceldata exceldata, HashMap<String, Object> map, InsOrderFile insOrderFile) throws IOException { public void createWord(String sonLaboratory, XWPFDocument document, Exceldata exceldata, HashMap<String, Object> map, HashMap<String, Object> bz, InsOrderFile insOrderFile) throws IOException { int size = 1; XWPFParagraph paragraphs = document.createParagraph(); XWPFRun runs = paragraphs.createRun(); @@ -567,20 +594,26 @@ paragraph1.setAlignment(ParagraphAlignment.CENTER); XWPFRun run1 = paragraph1.createRun(); run1.setText(s2); // 调用方法提取第一个括号内的内容 String firstContent = extractFirstContentFromBrackets(s2); if (firstContent != null) { // 单位 XWPFParagraph paragraph2 = table.getRow(0).getCell(2).getParagraphArray(0); paragraph2.setAlignment(ParagraphAlignment.CENTER); XWPFRun run2 = paragraph2.createRun(); run2.setText(firstContent); if (s2.contains("增益")) { run2.setText("dBi"); } else if (s2.contains("波瓣宽度") || s2.contains("波束宽度") || s2.contains("下倾角")) { run2.setText("°"); } else if (s2.contains("前后比") || s2.contains("交叉极化") || s2.contains("旁瓣抑制") || s2.contains("下降") || s2.contains("零点填充") || s2.contains("副瓣电平")) { run2.setText("dB"); } else if (s2.contains("效率") || s2.contains("扇区占比")) { run2.setText("%"); } else { System.out.println("没有找到括号内的内容。"); run2.setText(""); } XWPFParagraph paragraph3 = table.getRow(0).getCell(3).getParagraphArray(0); paragraph3.setAlignment(ParagraphAlignment.CENTER); XWPFRun run3 = paragraph3.createRun(); run3.setText("/"); if (bz.get(s2) != null) { run3.setText(bz.get(s2).toString()); }else run3.setText(""); XWPFParagraph paragraph4 = table.getRow(0).getCell(4).getParagraphArray(0); paragraph4.setAlignment(ParagraphAlignment.CENTER); XWPFRun run4 = paragraph4.createRun(); @@ -725,8 +758,6 @@ List<String> collect = Arrays.stream(split).collect(Collectors.toList()); collect.sort((o1, o21) -> Integer.parseInt(o1.substring((o1.length() - 1))) - Integer.parseInt(o21.substring(o21.length() - 1))); int size1 = 0; List<Map<String, Object>> list = new ArrayList<>(); @@ -762,14 +793,6 @@ XWPFTable table = document.createTable(row, cell); table.setWidth("100%"); /* // 合并单元格 mergeCellsHorizontally(table, 0, 0, 7);*/ //垂直 mergeCellsVertically(table, 0, 0, row - 1); mergeCellsVertically(table, 1, 0, row - 1); @@ -792,22 +815,28 @@ XWPFRun run1 = paragraph1.createRun(); run1.setText(s2); // 调用方法提取第一个括号内的内容 String firstContent = extractFirstContentFromBrackets(s2); if (firstContent != null) { // 单位 XWPFParagraph paragraph2 = table.getRow(0).getCell(2).getParagraphArray(0); XWPFRun run2 = paragraph2.createRun(); run2.setText(firstContent); if (s2.contains("增益")) { run2.setText("dBi"); } else if (s2.contains("波瓣宽度") || s2.contains("波束宽度") || s2.contains("下倾角")) { run2.setText("°"); } else if (s2.contains("前后比") || s2.contains("交叉极化") || s2.contains("旁瓣抑制") || s2.contains("下降") || s2.contains("零点填充") || s2.contains("副瓣电平")) { run2.setText("dB"); } else if (s2.contains("效率") || s2.contains("扇区占比")) { run2.setText("%"); } else { System.out.println("没有找到括号内的内容。"); run2.setText(""); } XWPFParagraph paragraph3 = table.getRow(0).getCell(3).getParagraphArray(0); paragraph3.setAlignment(ParagraphAlignment.CENTER); XWPFRun run3 = paragraph3.createRun(); if (bz.get(s2) != null) { run3.setText(bz.get(s2).toString()); } }else run3.setText(""); XWPFParagraph paragraph4 = table.getRow(0).getCell(4).getParagraphArray(0); @@ -815,6 +844,7 @@ run4.setText("频率(MHz)"); XWPFParagraph paragraph5 = table.getRow(0).getCell(5).getParagraphArray(0); paragraph5.setAlignment(ParagraphAlignment.CENTER); XWPFRun run5 = paragraph5.createRun(); run5.setText("端口"); @@ -911,18 +941,5 @@ } } // 提取第一个括号内的内容 public static String extractFirstContentFromBrackets(String str) { // 定义正则表达式,匹配括号内的内容,同时支持中文和英文括号 Pattern pattern = Pattern.compile("\\((.*?)\\)|\\((.*?)\\)"); Matcher matcher = pattern.matcher(str); // 查找第一个匹配的内容 if (matcher.find()) { // 获取括号内的内容,判断是中文括号还是英文括号 return matcher.group(1) != null ? matcher.group(1) : matcher.group(2); } return null; // 如果没有找到匹配项,则返回null } } inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java
@@ -2611,7 +2611,8 @@ Long productCount1 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) .eq(InsProduct::getInsResult, 3)); productSize1.set(productSize1.get() + Integer.parseInt(productCount1 + "")); // productSize1.set(productSize1.get() + Integer.parseInt(productCount1 + "")); productSize1.set(productSize1.get() + Integer.parseInt(0 + "")); //不合格 Long productCount2 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) @@ -2621,7 +2622,8 @@ Long productCount3 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() .eq(InsProduct::getInsSampleId, s.getId()) .eq(InsProduct::getInsResult, 1)); productSize3.set(productSize3.get() + Integer.parseInt(productCount3 + "")); // productSize3.set(productSize3.get() + Integer.parseInt(productCount3 + "")); productSize3.set(productSize3.get() + Integer.parseInt(productCount3+productCount1 + "")); //将项目按照站点进行分类 Map<String, List<InsProduct>> listMap = s.getInsProduct().stream().collect(Collectors.groupingBy(InsProduct::getSonLaboratory)); // 创建一个 Map 将站点和项目ID的映射关系 inspect-server/src/main/resources/mapper/InsOrderUserMapper.xml
@@ -46,4 +46,26 @@ #{id} </foreach> </select> <resultMap id="InsReportDto1Map" type="com.yuanchu.mom.dto.InsReportDto1"> <id property="sampleId" column="sampleId" jdbcType="INTEGER"/> <collection property="insReportDto2s" resultMap="insReportDto2s"/> </resultMap> <resultMap id="insReportDto2s" type="com.yuanchu.mom.dto.InsReportDto2"> <result column="laboratory" property="laboratory"/> <result column="num" property="num"/> <result column="insOrderUsersId" property="insOrderUsersId"/> </resultMap> <select id="selectInsReportDto1" resultMap="InsReportDto1Map"> select isa.id sampleId, ios.laboratory , iou.num, iou.id insOrderUsersId from ins_sample isa left join ins_order_state ios on isa.id = ios.ins_sample_id left join ins_order_user iou on ios.id = iou.ins_order_state_id where isa.ins_order_id=#{id} order by isa.id,ios.laboratory </select> </mapper>