| | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.function.Function; |
| | | import java.util.function.Predicate; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId,String sonLaboratory) { |
| | | public int upInsOrder(Integer orderId, Integer sampleId, String appointed, Integer userId, String sonLaboratory) { |
| | | InsOrder insOrder = new InsOrder(); |
| | | insOrder.setId(orderId); |
| | | insOrder.setAppointed(LocalDate.parse(appointed)); |
| | |
| | | if (product.getState() == 1 && !product.getInspectionItem().equals("光纤接头损耗")) { |
| | | //判断光缆的温度循环项目添加 |
| | | if (insOrder.getSampleType().equals("光缆") && product.getInspectionItem().equals("温度循环") && type != 0) { |
| | | List<InsProduct> insProductes = new ArrayList<>(); |
| | | List<InsProduct> insProducts = new ArrayList<>(); |
| | | String[] strings = product.getAsk().split(";"); |
| | | |
| | | for (int i = 0; i < strings.length; i++) { |
| | | int count = Integer.parseInt(strings[strings.length - 1]); |
| | | if (i != strings.length - 1) { |
| | | InsProduct insProduct = new InsProduct(); |
| | | switch (type) { |
| | | case 1: |
| | | insProduct.setInsFibersId(id); |
| | | break; |
| | | case 2: |
| | | insProduct.setInsFiberId(id); |
| | | break; |
| | | } |
| | | String[] split = strings[i].split(","); |
| | | if (split[0].equals("20℃")) { |
| | | insProduct.setInspectionItem(count + "");//检验项--循环次数 |
| | | } else { |
| | | insProduct.setInspectionItem("1");//检验项--循环次数 |
| | | } |
| | | insProduct.setInspectionItemSubclass(split[0]);//检验项--温度 |
| | | insProduct.setInspectionItemClass(split[1]);//检验项--光纤项目 |
| | | insProduct.setAsk(split[2]);//检验要求 |
| | | insProduct.setTell(strings[i]);//检验描述 |
| | | insProduct.setInsSampleId(sampleId); |
| | | insProduct.setState(1); |
| | | insProduct.setFactory(product.getFactory()); |
| | | insProduct.setLaboratory(product.getLaboratory()); |
| | | insProduct.setSampleType(product.getSampleType()); |
| | | insProduct.setSample(product.getSample()); |
| | | insProduct.setModel(product.getModel()); |
| | | insProduct.setSonLaboratory(product.getSonLaboratory()); |
| | | insProduct.setUnit(product.getUnit()); |
| | | insProduct.setManHourGroup(product.getManHourGroup()); |
| | | insProduct.setInspectionItemType("0"); |
| | | insProduct.setInspectionValueType("1"); |
| | | insProducts.add(insProduct); |
| | | insProductes.add(insProduct); |
| | | //判断选择的标准方法是委托要求还是其他标准方法 |
| | | String name = insSampleMapper.selMethodById(sampleId); |
| | | if (!name.equals("委托要求")) { |
| | | //判断标准方法的温度循环的要求描述是否有填写 |
| | | if (ObjectUtils.isEmpty(product.getTell()) || product.getTell().equals("")) { |
| | | throw new ErrorException("光缆的温度循环的要求描述为空,需要在标准库配置要求描述!!!"); |
| | | } else { |
| | | //最后一个数据是说明会循环多少次 |
| | | if (count > 1) { |
| | | //循环超过1次 |
| | | for (int j = 2; j <= count; j++) { |
| | | for (InsProduct insProduct : insProducts) { |
| | | if (!insProduct.getInspectionItemSubclass().equals("20℃") && !insProduct.getInspectionItemSubclass().equals("20℃(常温)")) { |
| | | InsProduct insProduct1 = new InsProduct(); |
| | | BeanUtils.copyProperties(insProduct, insProduct1); |
| | | insProduct1.setInspectionItem(j + ""); |
| | | insProductes.add(insProduct1); |
| | | } |
| | | } |
| | | //解析(温度范围:20℃,-40℃,65℃;保温时间:12h; 循环次数:2次; 光纤(1310nm,1550nm)附加衰减不大于0.03dB/km) |
| | | String tell = product.getTell().replace(")", ")") |
| | | .replace("(", "(") |
| | | .replace(")", ")") |
| | | .replace(",", ",") |
| | | .replace(":", ":") |
| | | .replace(";", ";") |
| | | .replace("不大于", "≤") |
| | | .replace("不小于", "≥") |
| | | .replace("大于", ">") |
| | | .replace("小于", "<") |
| | | .replace("等于", "="); |
| | | String[] message=null; |
| | | String[] nm=null; |
| | | String ask=null; |
| | | String count=null; |
| | | try { |
| | | String[] strings = tell.split(";"); |
| | | //温度 |
| | | String temperature = strings[0]; |
| | | String[] split = temperature.split(":"); |
| | | message = split[1].split(","); |
| | | //循环次数 |
| | | count = strings[2].split(":")[1].split("次")[0]; |
| | | //光纤项目和要求值 |
| | | String string = strings[3]; |
| | | nm = string.split("(")[1].split(")")[0].split(","); |
| | | ask = string.split("衰减")[1].split("dB")[0]; |
| | | }catch (Exception e){ |
| | | throw new ErrorException("温度循环的要求描述格式异常,请参照温度范围:20℃,-40℃,65℃;保温时间:12h; 循环次数:2次; 光纤(1310nm,1550nm)附加衰减不大于0.03dB/km"); |
| | | } |
| | | //拼接 |
| | | String s=null; |
| | | for (int i = 0; i < nm.length; i++) { |
| | | s+= "20℃(常温)," + nm[i] + ",null;"; |
| | | for (int j = 0; j < message.length; j++) { |
| | | s+= message[j] + "," + nm[i] + "," + ask + ";" ; |
| | | } |
| | | } |
| | | s+=count; |
| | | product.setAsk(s); |
| | | insProductMapper.updateById(product); |
| | | dealWithTemperatureLoop(type,id,sampleId,product); |
| | | } |
| | | } |
| | | insProductService.saveBatch(insProductes); |
| | | else { |
| | | //20℃(常温),1310nm,null;-40℃,1310nm,≤0.2;75℃,1310nm,<0.3;20℃,1310nm,≤0.1;20℃(常温),1550nm,null;-40℃,1550nm,≤0.2;75℃,1550nm,<0.3;20℃,1550nm,≤0.1;3 |
| | | dealWithTemperatureLoop(type,id,sampleId,product); |
| | | } |
| | | } |
| | | //判断热循环项目的添加和温升试验项目的添加 |
| | | else if (product.getInspectionItem().equals("热循环") || product.getInspectionItem().equals("温升试验")) { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //温度循环的处理 |
| | | private void dealWithTemperatureLoop(Integer type, Integer id,Integer sampleId,InsProduct product) { |
| | | List<InsProduct> insProductes = new ArrayList<>(); |
| | | List<InsProduct> insProducts = new ArrayList<>(); |
| | | String[] strings = product.getAsk().split(";"); |
| | | for (int i = 0; i < strings.length; i++) { |
| | | int count = Integer.parseInt(strings[strings.length - 1]); |
| | | if (i != strings.length - 1) { |
| | | InsProduct insProduct = new InsProduct(); |
| | | switch (type) { |
| | | case 1: |
| | | insProduct.setInsFibersId(id); |
| | | break; |
| | | case 2: |
| | | insProduct.setInsFiberId(id); |
| | | break; |
| | | } |
| | | String[] split = strings[i].split(","); |
| | | if (split[0].equals("20℃")) { |
| | | insProduct.setInspectionItem(count + "");//检验项--循环次数 |
| | | } else { |
| | | insProduct.setInspectionItem("1");//检验项--循环次数 |
| | | } |
| | | insProduct.setInspectionItemSubclass(split[0]);//检验项--温度 |
| | | insProduct.setInspectionItemClass(split[1]);//检验项--光纤项目 |
| | | insProduct.setAsk(split[2]);//检验要求 |
| | | insProduct.setTell(strings[i]);//检验描述 |
| | | insProduct.setInsSampleId(sampleId); |
| | | insProduct.setState(1); |
| | | insProduct.setFactory(product.getFactory()); |
| | | insProduct.setLaboratory(product.getLaboratory()); |
| | | insProduct.setSampleType(product.getSampleType()); |
| | | insProduct.setSample(product.getSample()); |
| | | insProduct.setModel(product.getModel()); |
| | | insProduct.setSonLaboratory(product.getSonLaboratory()); |
| | | insProduct.setUnit(product.getUnit()); |
| | | insProduct.setManHourGroup(product.getManHourGroup()); |
| | | insProduct.setInspectionItemType("0"); |
| | | insProduct.setInspectionValueType("1"); |
| | | insProducts.add(insProduct); |
| | | insProductes.add(insProduct); |
| | | } else { |
| | | //最后一个数据是说明会循环多少次 |
| | | if (count > 1) { |
| | | //循环超过1次 |
| | | for (int j = 2; j <= count; j++) { |
| | | for (InsProduct insProduct : insProducts) { |
| | | if (!insProduct.getInspectionItemSubclass().equals("20℃") && !insProduct.getInspectionItemSubclass().equals("20℃(常温)")) { |
| | | InsProduct insProduct1 = new InsProduct(); |
| | | BeanUtils.copyProperties(insProduct, insProduct1); |
| | | insProduct1.setInspectionItem(j + ""); |
| | | insProductes.add(insProduct1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | insProductService.saveBatch(insProductes); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void export(CostStatisticsDto costStatisticsDto,HttpServletResponse response) throws IOException { |
| | | public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException { |
| | | //查询导出的费用统计数据 |
| | | String dates = costStatisticsDto.getDates(); |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | |
| | | // 新建ExcelWriter |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); |
| | | |
| | | WriteSheet mainSheet = EasyExcel.writerSheet( "样品费用统计导出").head(CostStatisticsDto.class).build(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet("样品费用统计导出").head(CostStatisticsDto.class).build(); |
| | | excelWriter.write(costStatisticsDtos, mainSheet); |
| | | |
| | | // 关闭流 |