| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { |
| | | insOrder.setState(0); |
| | | //判断选择的委托单位与制单人的委托单位是否一致 |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | String company = userMapper.selectById(userId).getCompany(); |
| | | if (!company.equals(insOrder.getCompanyId()+"")) { |
| | | //如果不一致那么委托人字段必填 |
| | | if (ObjectUtils.isEmpty(insOrder.getPrepareUser())){ |
| | | throw new ErrorException("委托人不能为空"); |
| | | } |
| | | }else { |
| | | //如果一致,那么制单人就是委托人 |
| | | insOrder.setPrepareUser(insOrder.getCustom()); |
| | | } |
| | | //客户代号 |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | String code = custom.getCode2(); |
| | |
| | | for (BushingDto bushingDto : a.getBushing()) { |
| | | bushingDto.setInsSampleId(a.getId()); |
| | | insBushingMapper.insert(bushingDto); |
| | | //光纤不为空 |
| | | if (bushingDto.getFiber().size() != 0) { |
| | | for (FiberDto fiberDto : bushingDto.getFiber()) { |
| | | fiberDto.setInsBushingId(bushingDto.getId()); |
| | |
| | | addInsProductMethod(a.getId(), a.getInsProduct(), fiberDto.getId(), 2, true); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false); |
| | | } |
| | | } else { |
| | | } |
| | | //光纤带不为空 |
| | | else if ( bushingDto.getFibers().size()!=0){ |
| | | for (FibersDto fibersDto : bushingDto.getFibers()) { |
| | | fibersDto.setInsBushingId(bushingDto.getId()); |
| | | fibersDto.setCode(this.giveCode.giveCode("", "ins_fibers", "", "yyMMdd")); |
| | |
| | | addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1, false); |
| | | } |
| | | } |
| | | //都为空 只配置了套管 这种情况只限于项目是含有松套管的 |
| | | // else { |
| | | // String collect = a.getInsProduct().stream().map(InsProduct::getInspectionItem).distinct().collect(Collectors.joining(",")); |
| | | // if (collect.contains("松套管")){ |
| | | // //获取检验项目中包含松套管的检验项目 |
| | | // List<InsProduct> products = a.getInsProduct().stream().filter(insProduct -> insProduct.getInspectionItem().contains("松套管")).collect(Collectors.toList()); |
| | | // |
| | | // }else { |
| | | // throw new ErrorException("样品的光纤配置信息里面没有配置光纤带信息也没有光纤信息,请重新配置保存再提交下单!!!"); |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type, Boolean is) { |
| | | InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(sampleId).getInsOrderId()); |
| | | String name = insSampleMapper.selMethodById(sampleId); |
| | | for (InsProduct product : productList) { |
| | | if (product.getState() == 1 && !product.getInspectionItem().equals("光纤接头损耗")) { |
| | | //判断光缆的温度循环项目添加 |
| | | if (insOrder.getSampleType().equals("光缆") && product.getInspectionItem().equals("温度循环") && type != 0) { |
| | | //判断选择的标准方法是委托要求还是其他标准方法 |
| | | String name = insSampleMapper.selMethodById(sampleId); |
| | | if (!name.equals("委托要求")) { |
| | | //判断标准方法的温度循环的要求描述是否有填写 |
| | | if (ObjectUtils.isEmpty(product.getTell()) || product.getTell().equals("")) { |
| | |
| | | throw new ErrorException("温度循环的要求描述格式异常,请参照温度范围:20℃,-40℃,65℃;保温时间:12h; 循环次数:2次; 光纤(1310nm,1550nm)附加衰减不大于0.03dB/km"); |
| | | } |
| | | //拼接 |
| | | String s=null; |
| | | String s=""; |
| | | for (int i = 0; i < nm.length; i++) { |
| | | s+= "20℃(常温)," + nm[i] + ",null;"; |
| | | for (int j = 0; j < message.length; j++) { |
| | |
| | | } |
| | | } |
| | | insProductService.saveBatch(insProductess); |
| | | } else { |
| | | } |
| | | else { |
| | | if (!is) { |
| | | switch (type) { |
| | | case 1: |
| | |
| | | if (StringUtils.isEmpty(code)) { |
| | | code = ""; |
| | | } |
| | | String code2 = customMapper.selectById(insOrder.getCompanyId()).getCode2(); |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | String code2 = custom.getCode2(); |
| | | if (!custom.getCompany().equals(insOrder.getCompany())){ |
| | | Custom one = customMapper.selectOne(Wrappers.<Custom>lambdaQuery().eq(Custom::getCompany, insOrder.getCompany())); |
| | | insOrder.setCompanyId(one.getId()); |
| | | code2=one.getCode2(); |
| | | } |
| | | //String code2 = customMapper.selectById(insOrder.getCompanyId()).getCode2(); |
| | | insOrder.setEntrustCode(giveCode.giveCode2("JCZX/" + code + "-" + code2 + "-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMM")); |
| | | } |
| | | return insOrderMapper.updateById(insOrder); |
| | |
| | | .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); |
| | | try { |
| | | // 新建ExcelWriter |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); |
| | | // 新建ExcelWriter |
| | | ExcelWriter excelWriter = |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) |
| | | .build(); |
| | | for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { |
| | | String sheetName = companyDataEntry.getKey(); |
| | | List<CostStatisticsDto> dataList = companyDataEntry.getValue(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet(sheetName).head(CostStatisticsDto.class).build(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet(sheetName) |
| | | .head(CostStatisticsDto.class) |
| | | .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) |
| | | .build(); |
| | | excelWriter.write(dataList, mainSheet); |
| | | } |
| | | // 关闭流 |