| | |
| | | import com.yuanchu.mom.utils.*; |
| | | import com.yuanchu.mom.vo.*; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private String imgUrl; |
| | | |
| | | @Resource |
| | | private InsBushingService insBushingService; |
| | | |
| | | @Resource |
| | | private InsBushingMapper insBushingMapper; |
| | | |
| | | @Resource |
| | | private InsFiberMapper insFiberMapper; |
| | | |
| | | @Resource |
| | | private InsFibersMapper insFibersMapper; |
| | | |
| | | @Resource |
| | | private InsOrderFileMapper insOrderFileMapper; |
| | | |
| | | @Override |
| | |
| | | } |
| | | Map<String, Object> map = insOrderService.getInsOrderAndSample(id, laboratory); |
| | | List<SampleProductDto> list = JSON.parseArray(JSON.toJSONString(map.get("sampleProduct")), SampleProductDto.class); |
| | | for (SampleProductDto samples : list) { |
| | | if (BeanUtil.isEmpty(samples.getInsProduct())) continue; |
| | | samples.setBushing(insBushingService.selectBushingBySampleId(samples.getId())); |
| | | } |
| | | map.put("sampleProduct", list); |
| | | return map; |
| | | } |
| | |
| | | case 0: |
| | | //样品 |
| | | insProducts = insSampleMapper.getInsProduct1(id, laboratory); |
| | | if (insProducts.size()==0){ |
| | | if (insProducts.size() == 0) { |
| | | insProducts = insSampleMapper.getIns2Product1(id, laboratory); |
| | | } |
| | | break; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<InsProduct> getInsProduct2(Integer id, Integer type, String laboratory, HttpServletRequest request,Integer num) { |
| | | 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); |
| | | insProducts = insSampleMapper.get2InsProduct1(id, laboratory, num); |
| | | if (insProducts.size() == 0) { |
| | | throw new ErrorException("当前检验数据还没有保存,保存之后有数据历史"); |
| | | } |
| | | break; |
| | | case 1: |
| | | //光纤带 |
| | |
| | | } |
| | | } |
| | | |
| | | //切换记录模版查询检验内容 |
| | | @Override |
| | | public Map<String, Object> getReportModel(Integer sampleId) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //先查出套管 |
| | | List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId)); |
| | | List<InsFibers> fibers = new ArrayList<>(); |
| | | List<InsFiber> fiber = new ArrayList<>(); |
| | | List<InsBushing> bush = new ArrayList<>(); |
| | | for (InsBushing insBushing : insBushings) { |
| | | //再查询出所有的光纤带 |
| | | List<InsFibers> insFibers = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery().eq(InsFibers::getInsBushingId, insBushing.getId())); |
| | | List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId())); |
| | | if (CollectionUtils.isNotEmpty(insFibers)) { |
| | | for (InsFibers insFiber : insFibers) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFibersId, insFiber.getId())); |
| | | List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | if (insProducts.size() == collect.size()) { |
| | | insFiber.setState(1);//已检验 |
| | | } else { |
| | | insFiber.setState(0);//未检验 |
| | | } |
| | | } |
| | | fibers.addAll(insFibers); |
| | | //查出光纤带下所有的光纤 |
| | | List<InsFiber> fiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().in(InsFiber::getInsFibersId, insFibers.stream().map(InsFibers::getId).collect(Collectors.toList()))); |
| | | for (InsFiber insFiber : fiberList) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId())); |
| | | List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | if (insProducts.size() == collect.size()) { |
| | | insFiber.setState(1);//已检验 |
| | | } else { |
| | | insFiber.setState(0);//未检验 |
| | | } |
| | | } |
| | | fiber.addAll(fiberList); |
| | | } |
| | | //如果套管下没有光纤带就只有光纤了 |
| | | else if (CollectionUtils.isNotEmpty(insFiberList)) { |
| | | for (InsFiber insFiber : insFiberList) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId())); |
| | | List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | if (insProducts.size() == collect.size()) { |
| | | insFiber.setState(1);//已检验 |
| | | } else { |
| | | insFiber.setState(0);//未检验 |
| | | } |
| | | } |
| | | fiber.addAll(insFiberList); |
| | | } |
| | | //如果光纤带和光纤都没有就只有套管(松套管) |
| | | else { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsBushId, insBushing.getId())); |
| | | List<Integer> collect = insProducts.stream() |
| | | .map(InsProduct::getInsResult) |
| | | .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList()); |
| | | if (insProducts.size() == collect.size()) { |
| | | insBushing.setState(1);//已检验 |
| | | } else { |
| | | insBushing.setState(0);//未检验 |
| | | } |
| | | bush.add(insBushing); |
| | | } |
| | | } |
| | | map.put("光纤带", fibers); |
| | | map.put("光纤", fiber); |
| | | map.put("套管", bush); |
| | | return map; |
| | | } |
| | | |
| | | //温度循环查看列表数据(包括通过样品id,循环次数,温度,循环次数进行筛选) |
| | | @Override |
| | | public Map<String, Object> temCycle(Integer sampleId, String inspectionItem, String inspectionItemSubclass) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //样品信息 |
| | | SampleVo sampleVo = insSampleMapper.getDetailById(sampleId); |
| | | map.put("sampleVo", sampleVo); |
| | | List<ProductVo> productVos = new ArrayList<>(); |
| | | //先查出这个样品下有哪些管色标,光纤带,光纤色标 |
| | | //先查出套管 |
| | | List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId)); |
| | | if (insBushings.size() > 0) { |
| | | //通信--温度循环 |
| | | for (InsBushing insBushing : insBushings) { |
| | | //再查询出所有的光纤带 |
| | | List<InsFibers> insFibers = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery().eq(InsFibers::getInsBushingId, insBushing.getId())); |
| | | if (CollectionUtils.isNotEmpty(insFibers)) { |
| | | for (InsFibers insFiber : insFibers) { |
| | | //查出光纤带下所有的光纤 |
| | | List<InsFiber> fiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsFibersId, insFiber.getId())); |
| | | for (InsFiber fiber : fiberList) { |
| | | //再根据关联的光纤配置的id和循环次数和温度和样品id进行查询检验项目 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem) |
| | | .eq(InsProduct::getInspectionItemSubclass, inspectionItemSubclass) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | productVo.setCode(insFiber.getCode()); |
| | | productVo.setColor(fiber.getColor()); |
| | | productVo.setBushColor(insBushing.getColor()); |
| | | if (ObjectUtils.isNotEmpty(insProductResult)) { |
| | | insProduct.setInsProductResult(insProductResult); |
| | | } |
| | | //求同等条件下1次循环20度常温的计算值 |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass()) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())).getId())); |
| | | if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) { |
| | | insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | //如果套管下没有光纤带就只有光纤了 |
| | | List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId())); |
| | | for (InsFiber fiber : insFiberList) { |
| | | //再根据关联的光纤配置的id和循环次数和温度和样品id进行查询检验项目 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem) |
| | | .eq(InsProduct::getInspectionItemSubclass, inspectionItemSubclass) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | productVo.setCode("-"); |
| | | productVo.setColor(fiber.getColor()); |
| | | productVo.setBushColor(fiber.getBushColor()); |
| | | insProduct.setInsProductResult(insProductResult); |
| | | //求同等条件下1次循环20度常温的计算值 |
| | | InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass()) |
| | | .eq(InsProduct::getInsFiberId, fiber.getId())).getId())); |
| | | if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) { |
| | | insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList()); |
| | | } else { |
| | | //电力--热循环和温升试验 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, sampleId) |
| | | .eq(InsProduct::getInspectionItem, inspectionItem)); |
| | | for (InsProduct insProduct : insProducts) { |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | ProductVo productVo = new ProductVo(); |
| | | if (ObjectUtils.isNotEmpty(insProductResult)) { |
| | | insProduct.setInsProductResult(insProductResult); |
| | | } |
| | | productVo.setInsProduct(insProduct); |
| | | productVos.add(productVo); |
| | | } |
| | | } |
| | | map.put("productVos", productVos); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> upPlanUser2(Integer orderId) { |
| | | List<Integer> sampleId = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList()); |
| | |
| | | |
| | | |
| | | @Override |
| | | public void saveInsContext(Map<String, Object> insContext,Integer num) { |
| | | public void saveInsContext(Map<String, Object> insContext, Integer num) { |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | CompletableFuture.supplyAsync(() -> { |
| | | insContext.forEach((k, v) -> { |
| | |
| | | InsProduct insProduct = new InsProduct(); |
| | | insProduct.setId(Integer.parseInt(k)); |
| | | List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getNum, num) |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | InsProductResult result; |
| | | if (CollectionUtils.isEmpty(results)) { |
| | |
| | | insSampleMapper.updateById(insSample); |
| | | /*校验一下result表*/ |
| | | List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery() |
| | | .eq(InsProductResult::getNum, num) |
| | | .eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | if (insProductResults.size() > 1) { |
| | | for (int i = 1; i < insProductResults.size(); i++) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int verifyPlan(Integer orderId, String laboratory, Integer type, String tell) { |
| | | public int verifyPlan(Integer orderId, String laboratory, Integer type, String tell) throws IOException { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | List<InsUnPass> insUnPasses = new ArrayList<>(); |
| | |
| | | .set(InsOrderState::getVerifyUser, userId)); |
| | | break; |
| | | } |
| | | /*复核完成之后生成他自己的站点报告(仅限辐射试验检测(近场,远场)和电路试验)*/ |
| | | /*switch (laboratory) { |
| | | case "近场": |
| | | uploadFile(orderId, null); |
| | | break; |
| | | case "远场": |
| | | uploadFile(orderId, null); |
| | | break; |
| | | case "电路试验": |
| | | uploadFile(orderId, generateExcelFile(orderId,laboratory)); |
| | | break; |
| | | default: |
| | | break; |
| | | }*/ |
| | | return 1; |
| | | } |
| | | |
| | | //生成电路试验的excel文件 |
| | | private MultipartFile generateExcelFile(Integer orderId, String laboratory) throws IOException{ |
| | | // 创建一个Workbook对象 |
| | | Workbook workbook = new XSSFWorkbook(); |
| | | |
| | | // 创建第一个Sheet |
| | | Sheet sheet1 = workbook.createSheet("Sheet1"); |
| | | Row row1 = sheet1.createRow(0); |
| | | Cell cell1 = row1.createCell(0); |
| | | cell1.setCellValue("Hello, Sheet1"); |
| | | |
| | | // 创建第二个Sheet |
| | | Sheet sheet2 = workbook.createSheet("Sheet2"); |
| | | Row row2 = sheet2.createRow(0); |
| | | Cell cell2 = row2.createCell(0); |
| | | cell2.setCellValue("Hello, Sheet2"); |
| | | |
| | | // 将Workbook写入到字节数组中 |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | workbook.write(outputStream); |
| | | workbook.close(); |
| | | |
| | | byte[] excelBytes = outputStream.toByteArray(); |
| | | |
| | | // 创建MultipartFile对象 |
| | | MultipartFile multipartFile = new MockMultipartFile( |
| | | "file", "example.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", new ByteArrayInputStream(excelBytes)); |
| | | |
| | | return multipartFile; |
| | | } |
| | | |
| | | private void getTemplateThing(Set<Integer> set, Map<Integer, String> map2, List<InsProduct> insProducts) { |
| | |
| | | .isNull(InsProduct::getInsResult) |
| | | .or() |
| | | .eq(InsProduct::getInsResult, 2) |
| | | ) |
| | | .isNull(InsProduct::getInsFiberId) |
| | | .isNull(InsProduct::getInsFibersId)); |
| | | insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory)); |
| | | )); |
| | | if (insProducts.size() > 0) { |
| | | String str = ""; |
| | | int count = 0; |
| | |
| | | /*如果是C类订单且是下发到质量部,则直接复核通过(结束试验)*/ |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | if (insOrder.getOrderType().equals("C") && insOrder.getDepartmentLims().equals("质量部")) { |
| | | verifyPlan(orderId, laboratory, 2, null); |
| | | try { |
| | | verifyPlan(orderId, laboratory, 2, null); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else { |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | //LIMS系统消息推送 |