| | |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | .eq(PkMaster::getSampleCode, pkMaster.getSampleCode()) |
| | | .eq(PkMaster::getModel, pkMaster.getModel()) |
| | | .eq(PkMaster::getTemperature, pkMaster.getTemperature())); |
| | | if (ObjectUtils.isEmpty(master)) { |
| | | throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采数据"); |
| | | if (ObjectUtils.isNotEmpty(master)) { |
| | | //throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采数据"); |
| | | List<PkSlave> pkSlaves = pkSlaveMapper.selectList1(master.getIsid()); |
| | | if (CollectionUtils.isEmpty(pkSlaves)) { |
| | | throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采子数据"); |
| | | } |
| | | //查询对应的检验单表 |
| | | InsOrder insOrder = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).eq(InsOrder::getEntrustCode, pkMaster.getEntrustCode())); |
| | | if (ObjectUtils.isEmpty(insOrder)) { |
| | | throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode()); |
| | | } |
| | | //查询对应检验样品id |
| | | InsSample insSample = insSampleMapper.selectOne(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, insOrder.getId()) |
| | | .eq(InsSample::getSampleCode, pkMaster.getSampleCode()) |
| | | .eq(InsSample::getModel, pkMaster.getModel())); |
| | | if (ObjectUtils.isEmpty(insSample)) { |
| | | throw new ErrorException("没有找到对应委托单下的该样品" + pkMaster.getSampleCode()); |
| | | } |
| | | //查询对应检验项目 |
| | | Map<String, Object> map = insOrderPlanService.temCycle(insSample.getId(), pkMaster.getCycles(), pkMaster.getTemperature()); |
| | | List<ProductVo> productVos = (List<ProductVo>) map.get("productVos"); |
| | | if (CollectionUtils.isNotEmpty(productVos)) { |
| | | //todo 如果温度循环的项目nm有改动这里需要改动 @zss |
| | | for (PkSlave pkSlave : pkSlaves) { |
| | | for (ProductVo productVo : productVos) { |
| | | if (pkSlave.getInsBushingId().equals(productVo.getBushColor()) && |
| | | pkSlave.getInsFibersId().equals(productVo.getCode()) && |
| | | pkSlave.getInsFiberId().equals(productVo.getColor())) { |
| | | //找到对应的数据(对应套管光纤的数据) |
| | | List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, productVo.getInsProduct().getId())); |
| | | InsProductResult result; |
| | | if (CollectionUtils.isEmpty(results)) { |
| | | result = new InsProductResult(); |
| | | } else { |
| | | result = results.get(0); |
| | | } |
| | | result.setInsProductId(productVo.getInsProduct().getId());//检验项目id |
| | | List<Map<String, Object>> iv = new ArrayList<>(); |
| | | List<Map<String, Object>> cv = new ArrayList<>(); |
| | | if (productVo.getInsProduct().getInspectionItemClass().equals("1310nm")) { |
| | | //1310nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) ? pkSlave.getWeaken1310A().toString() : null); |
| | | iv.add(map1); |
| | | //1310nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B()) ? pkSlave.getWeaken1310B().toString() : null); |
| | | iv.add(map2); |
| | | //1310nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = 0.0; |
| | | if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B())) { |
| | | v = (pkSlave.getWeaken1310A() + pkSlave.getWeaken1310B()) / 2; |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1310B())) { |
| | | v = pkSlave.getWeaken1310A(); |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1310B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1310A())) { |
| | | v = pkSlave.getWeaken1310B(); |
| | | } else { |
| | | throw new ErrorException("1310的两端都没有数据!!!"); |
| | | } |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1550nm")) { |
| | | //1550nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) ? pkSlave.getWeaken1550A().toString() : null); |
| | | iv.add(map1); |
| | | //1550nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B()) ? pkSlave.getWeaken1550B().toString() : null); |
| | | iv.add(map2); |
| | | //1550nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = 0.0; |
| | | if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B())) { |
| | | v = (pkSlave.getWeaken1550A() + pkSlave.getWeaken1550B()) / 2; |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1550B())) { |
| | | v = pkSlave.getWeaken1550A(); |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1550B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1550A())) { |
| | | v = pkSlave.getWeaken1550B(); |
| | | } else { |
| | | throw new ErrorException("1550的两端都没有数据!!!"); |
| | | } |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1625nm")) { |
| | | //1625nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) ? pkSlave.getWeaken1625A().toString() : null); |
| | | iv.add(map1); |
| | | //1625nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B()) ? pkSlave.getWeaken1625B().toString() : null); |
| | | iv.add(map2); |
| | | //1625nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = 0.0; |
| | | if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B())) { |
| | | v = (pkSlave.getWeaken1625A() + pkSlave.getWeaken1625B()) / 2; |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1625B())) { |
| | | v = pkSlave.getWeaken1625A(); |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1625B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1625A())) { |
| | | v = pkSlave.getWeaken1625B(); |
| | | } else { |
| | | throw new ErrorException("1625的两端都没有数据!!!"); |
| | | } |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1383nm")) { |
| | | //1383nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) ? pkSlave.getWeaken1383A().toString() : null); |
| | | iv.add(map1); |
| | | //1383nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B()) ? pkSlave.getWeaken1383B().toString() : null); |
| | | iv.add(map2); |
| | | //1383nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = 0.0; |
| | | if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B())) { |
| | | v = (pkSlave.getWeaken1383A() + pkSlave.getWeaken1310B()) / 2; |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1383B())) { |
| | | v = pkSlave.getWeaken1383A(); |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1383B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1383A())) { |
| | | v = pkSlave.getWeaken1383B(); |
| | | } else { |
| | | throw new ErrorException("1383的两端都没有数据!!!"); |
| | | } |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1490nm")) { |
| | | //1490nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) ? pkSlave.getWeaken1490A().toString() : null); |
| | | iv.add(map1); |
| | | //1490nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B()) ? pkSlave.getWeaken1490B().toString() : null); |
| | | iv.add(map2); |
| | | //1490nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = 0.0; |
| | | if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) && ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B())) { |
| | | v = (pkSlave.getWeaken1490A() + pkSlave.getWeaken1310B()) / 2; |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490A()) && ObjectUtils.isEmpty(pkSlave.getWeaken1490B())) { |
| | | v = pkSlave.getWeaken1490A(); |
| | | } else if (ObjectUtils.isNotEmpty(pkSlave.getWeaken1490B()) && ObjectUtils.isEmpty(pkSlave.getWeaken1490A())) { |
| | | v = pkSlave.getWeaken1490B(); |
| | | } else { |
| | | throw new ErrorException("1490的两端都没有数据!!!"); |
| | | } |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else { |
| | | throw new ErrorException("没有找到该温度的检验项目" + productVo.getInsProduct().getInspectionItemClass()); |
| | | } |
| | | result.setInsValue(JSON.toJSONString(iv));//检验值 |
| | | result.setComValue(JSON.toJSONString(cv));//计算值 |
| | | if (BeanUtil.isEmpty(result.getId())) { |
| | | result.setCreateUser(userId); |
| | | result.setUpdateUser(userId); |
| | | insProductResultMapper.insert(result); |
| | | } else { |
| | | result.setUpdateUser(userId); |
| | | result.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(result); |
| | | } |
| | | |
| | | InsProduct insProduct = productVo.getInsProduct(); |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | String comple = insProductResult.getComValue().split(":")[1].split("\"")[1]; |
| | | //首先查看温度是否是20度常温 |
| | | if (!pkMaster.getTemperature().equals("20℃(常温)")) { |
| | | //如果不是先查询是否有值 |
| | | int a = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")).stream().map(InsProduct::getInsResult).anyMatch(ObjectUtils::isEmpty) ? 1 : 0; |
| | | if (a == 1) { |
| | | throw new ErrorException("先获取20℃(常温)的检验值,再获取其他温度" + pkMaster.getSampleCode()); |
| | | } else { |
| | | //计算衰减差 |
| | | InsProduct insPro = null; |
| | | switch (insProduct.getInspectionItemClass()) { |
| | | case "1310nm": |
| | | //查询20℃(常温)1310nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1310nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1310nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1550nm": |
| | | //查询20℃(常温)1550nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1550nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1625nm": |
| | | //查询20℃(常温)1625nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1625nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1383nm": |
| | | //查询20℃(常温)1383nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1383nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1383nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1490nm": |
| | | //查询20℃(常温)1490nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1490nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1490nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | } |
| | | InsProductResult insProductRes = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insPro.getId())); |
| | | double abs = Math.abs(Double.parseDouble(insProductRes.getComValue().split(":")[1].split("\"")[1]) - Double.parseDouble(comple)); |
| | | BigDecimal scale = BigDecimal.valueOf(abs).setScale(3, RoundingMode.HALF_UP); |
| | | insProduct.setLastValue(String.valueOf(scale)); |
| | | String ask = insProduct.getAsk(); |
| | | int insResult = 1; |
| | | switch (ask.charAt(0)) { |
| | | case '<': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) < Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '>': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) > Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '=': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) == Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '≤': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) <= Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '≥': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) >= Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | } |
| | | insProduct.setInsResult(insResult); |
| | | } |
| | | } else { |
| | | //如果是20度常温,需要给出合格的结论 |
| | | insProduct.setInsResult(1);//20度常温的检验项默认为合格 |
| | | } |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getAccount, master.getDetectionPeople())); |
| | | if (ObjectUtils.isEmpty(user)) { |
| | | throw new ErrorException("lims系统没有找到该用户" + master.getDetectionPeople()); |
| | | } |
| | | insProductUserMapper.insert(new InsProductUser(null, user.getId(), master.getDetectionDate(), insProduct.getId())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //给温度循环的检验项目绑定设备 |
| | | InsProduct product = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "温度循环")); |
| | | if (ObjectUtils.isEmpty(product)) { |
| | | throw new ErrorException("没有找到对应委托单下该样品的相关温度循环检验项目"); |
| | | } |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, product.getId())); |
| | | if (ObjectUtils.isEmpty(insProductResult)) { |
| | | insProductResult = new InsProductResult(); |
| | | insProductResult.setInsProductId(product.getId()); |
| | | } |
| | | if (ObjectUtils.isEmpty(insProductResult.getEquipValue())) { |
| | | List<Map<String, Object>> dv = new ArrayList<>(); |
| | | Map<String, Object> map4 = new HashMap<>(); |
| | | map4.put("v", "JCZX-TX-TT02006"); |
| | | dv.add(map4); |
| | | Map<String, Object> map5 = new HashMap<>(); |
| | | map5.put("v", "JCZX-TX-TT02001"); |
| | | dv.add(map5); |
| | | insProductResult.setEquipValue(JSON.toJSONString(dv)); |
| | | List<Map<String, Object>> dn = new ArrayList<>(); |
| | | Map<String, Object> map6 = new HashMap<>(); |
| | | map6.put("v", "步入式高低温湿热试验箱"); |
| | | dn.add(map6); |
| | | Map<String, Object> map7 = new HashMap<>(); |
| | | map7.put("v", "步入式高低温试验箱"); |
| | | dn.add(map7); |
| | | insProductResult.setEquipName(JSON.toJSONString(dn)); |
| | | if (BeanUtil.isEmpty(insProductResult.getId())) { |
| | | insProductResult.setCreateUser(userId); |
| | | insProductResult.setUpdateUser(userId); |
| | | insProductResultMapper.insert(insProductResult); |
| | | } else { |
| | | insProductResult.setUpdateUser(userId); |
| | | insProductResult.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(insProductResult); |
| | | } |
| | | } |
| | | } |
| | | List<PkSlave> pkSlaves = pkSlaveMapper.selectList1(master.getIsid()); |
| | | if (CollectionUtils.isEmpty(pkSlaves)) { |
| | | throw new ErrorException("没有找到对应委托单" + pkMaster.getEntrustCode() + "的数采子数据"); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //温度循环数采总体 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int temDataAcquisition2(PkMaster pkMaster) { |
| | | //查询出所有循环次数和温度,然后循环调用temDataAcquisition接口 |
| | | //查询对应的检验单表 |
| | | InsOrder insOrder = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery().eq(InsOrder::getState, 1).eq(InsOrder::getEntrustCode, pkMaster.getEntrustCode())); |
| | | if (ObjectUtils.isEmpty(insOrder)) { |
| | |
| | | if (ObjectUtils.isEmpty(insSample)) { |
| | | throw new ErrorException("没有找到对应委托单下的该样品" + pkMaster.getSampleCode()); |
| | | } |
| | | //查询对应检验项目 |
| | | Map<String, Object> map = insOrderPlanService.temCycle(insSample.getId(), pkMaster.getCycles(), pkMaster.getTemperature()); |
| | | List<ProductVo> productVos = (List<ProductVo>) map.get("productVos"); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | throw new ErrorException("没有找到对应委托单下该样品的相关温度循环检验项目的循环" + pkMaster.getCycles() + "次+温度" + pkMaster.getTemperature()); |
| | | } |
| | | |
| | | //todo 如果温度循环的项目nm有改动这里需要改动 @zss |
| | | for (PkSlave pkSlave : pkSlaves) { |
| | | for (ProductVo productVo : productVos) { |
| | | if (pkSlave.getInsBushingId().equals(productVo.getBushColor()) && |
| | | pkSlave.getInsFibersId().equals(productVo.getCode()) && |
| | | pkSlave.getInsFiberId().equals(productVo.getColor())) { |
| | | //找到对应的数据(对应套管光纤的数据) |
| | | List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, productVo.getInsProduct().getId())); |
| | | InsProductResult result; |
| | | if (CollectionUtils.isEmpty(results)) { |
| | | result = new InsProductResult(); |
| | | } else { |
| | | result = results.get(0); |
| | | } |
| | | result.setInsProductId(productVo.getInsProduct().getId());//检验项目id |
| | | List<Map<String, Object>> iv = new ArrayList<>(); |
| | | List<Map<String, Object>> cv = new ArrayList<>(); |
| | | if (productVo.getInsProduct().getInspectionItemClass().equals("1310nm")) { |
| | | //1310nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", pkSlave.getWeaken1310A().toString()); |
| | | iv.add(map1); |
| | | //1310nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", pkSlave.getWeaken1310B().toString()); |
| | | iv.add(map2); |
| | | //1310nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = (pkSlave.getWeaken1310A() + pkSlave.getWeaken1310B()) / 2; |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1550nm")) { |
| | | //1550nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", pkSlave.getWeaken1550A().toString()); |
| | | iv.add(map1); |
| | | //1550nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", pkSlave.getWeaken1550B().toString()); |
| | | iv.add(map2); |
| | | //1550nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = (pkSlave.getWeaken1550A() + pkSlave.getWeaken1550B()) / 2; |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1625nm")) { |
| | | //1625nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", pkSlave.getWeaken1625A().toString()); |
| | | iv.add(map1); |
| | | //1625nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", pkSlave.getWeaken1625B().toString()); |
| | | iv.add(map2); |
| | | //1625nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = (pkSlave.getWeaken1625A() + pkSlave.getWeaken1625B()) / 2; |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1383nm")) { |
| | | //1383nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", pkSlave.getWeaken1383A().toString()); |
| | | iv.add(map1); |
| | | //1383nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", pkSlave.getWeaken1383B().toString()); |
| | | iv.add(map2); |
| | | //1383nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = (pkSlave.getWeaken1383A() + pkSlave.getWeaken1383B()) / 2; |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else if (productVo.getInsProduct().getInspectionItemClass().equals("1490nm")) { |
| | | //1490nm外端 |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("u", userId + ""); |
| | | map1.put("v", pkSlave.getWeaken1490A().toString()); |
| | | iv.add(map1); |
| | | //1490nm内端 |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("u", userId + ""); |
| | | map2.put("v", pkSlave.getWeaken1490B().toString()); |
| | | iv.add(map2); |
| | | //1490nm衰减系数 |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | double v = (pkSlave.getWeaken1490A() + pkSlave.getWeaken1490B()) / 2; |
| | | BigDecimal decimal = BigDecimal.valueOf(v).setScale(3, RoundingMode.HALF_UP); |
| | | map3.put("v", String.valueOf(decimal)); |
| | | cv.add(map3); |
| | | } else { |
| | | throw new ErrorException("没有找到该温度的检验项目" + productVo.getInsProduct().getInspectionItemClass()); |
| | | } |
| | | result.setInsValue(JSON.toJSONString(iv));//检验值 |
| | | result.setComValue(JSON.toJSONString(cv));//计算值 |
| | | if (BeanUtil.isEmpty(result.getId())) { |
| | | result.setCreateUser(userId); |
| | | result.setUpdateUser(userId); |
| | | insProductResultMapper.insert(result); |
| | | } else { |
| | | result.setUpdateUser(userId); |
| | | result.setUpdateTime(LocalDateTime.now()); |
| | | insProductResultMapper.updateById(result); |
| | | } |
| | | |
| | | InsProduct insProduct = productVo.getInsProduct(); |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | String comple = insProductResult.getComValue().split(":")[1].split("\"")[1]; |
| | | //首先查看温度是否是20度常温 |
| | | if (!pkMaster.getTemperature().equals("20℃(常温)")) { |
| | | //如果不是先查询是否有值 |
| | | int a = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")).stream().map(InsProduct::getInsResult).anyMatch(ObjectUtils::isEmpty) ? 1 : 0; |
| | | if (a == 1) { |
| | | throw new ErrorException("先获取20℃(常温)的检验值,再获取其他温度" + pkMaster.getSampleCode()); |
| | | } else { |
| | | //计算衰减差 |
| | | InsProduct insPro = null; |
| | | switch (insProduct.getInspectionItemClass()) { |
| | | case "1310nm": |
| | | //查询20℃(常温)1310nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1310nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1310nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1550nm": |
| | | //查询20℃(常温)1550nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1550nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1625nm": |
| | | //查询20℃(常温)1625nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1625nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1625nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1383nm": |
| | | //查询20℃(常温)1383nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1383nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1383nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | case "1490nm": |
| | | //查询20℃(常温)1490nm的衰减系数 |
| | | try { |
| | | insPro = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "1") |
| | | .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)") |
| | | .eq(InsProduct::getInspectionItemClass, "1490nm") |
| | | .eq(InsProduct::getInsFiberId, productVo.getInsProduct().getInsFiberId())); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("没有查到20℃(常温),1490nm项目" + productVo.getInsProduct().getInsFiberId() + "光纤的检验项目"); |
| | | } |
| | | break; |
| | | } |
| | | InsProductResult insProductRes = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insPro.getId())); |
| | | double abs = Math.abs(Double.parseDouble(insProductRes.getComValue().split(":")[1].split("\"")[1]) - Double.parseDouble(comple)); |
| | | BigDecimal scale = BigDecimal.valueOf(abs).setScale(3, RoundingMode.HALF_UP); |
| | | insProduct.setLastValue(String.valueOf(scale)); |
| | | String ask = insProduct.getAsk(); |
| | | int insResult = 1; |
| | | switch (ask.charAt(0)) { |
| | | case '<': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) < Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '>': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) > Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '=': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) == Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '≤': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) <= Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | case '≥': |
| | | insResult = Double.parseDouble(insProduct.getLastValue()) >= Double.parseDouble(ask.substring(1)) ? 1 : 0; |
| | | break; |
| | | } |
| | | insProduct.setInsResult(insResult); |
| | | } |
| | | } else { |
| | | //如果是20度常温,需要给出合格的结论 |
| | | insProduct.setInsResult(1);//20度常温的检验项默认为合格 |
| | | } |
| | | insProduct.setUpdateUser(userId); |
| | | insProductMapper.updateById(insProduct); |
| | | User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getAccount, master.getDetectionPeople())); |
| | | if (ObjectUtils.isEmpty(user)) { |
| | | throw new ErrorException("lims系统没有找到该用户" + master.getDetectionPeople()); |
| | | } |
| | | insProductUserMapper.insert(new InsProductUser(null, user.getId(), master.getDetectionDate(), insProduct.getId())); |
| | | } |
| | | //查找样品下所有温度循环的项目 |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getState, 1) |
| | | .isNull(InsProduct::getTemplateId) |
| | | .isNotNull(InsProduct::getInspectionItemClass)); |
| | | //过滤出所有循环次数和温度 |
| | | List<String> collect1 = insProducts.stream().map(InsProduct::getInspectionItem).distinct().collect(Collectors.toList()); |
| | | List<String> collect2 = insProducts.stream().map(InsProduct::getInspectionItemSubclass).distinct().collect(Collectors.toList()); |
| | | for (String s : collect1) { |
| | | for (String s1 : collect2) { |
| | | PkMaster master = new PkMaster(); |
| | | master.setEntrustCode(pkMaster.getEntrustCode()); |
| | | master.setSampleCode(pkMaster.getSampleCode()); |
| | | master.setModel(pkMaster.getModel()); |
| | | master.setCycles(s); |
| | | master.setTemperature(s1); |
| | | temDataAcquisition(master); |
| | | } |
| | | } |
| | | |
| | | //给温度循环的检验项目绑定设备 |
| | | InsProduct product = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getInspectionItem, "温度循环")); |
| | | if (ObjectUtils.isEmpty(map)) { |
| | | throw new ErrorException("没有找到对应委托单下该样品的相关温度循环检验项目"); |
| | | } |
| | | InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, product.getId())); |
| | | if(ObjectUtils.isEmpty(insProductResult.getEquipValue())) { |
| | | List<Map<String, Object>> dv = new ArrayList<>(); |
| | | Map<String, Object> map4 = new HashMap<>(); |
| | | map4.put("v", "JCZX-TX-TT02006"); |
| | | dv.add(map4); |
| | | Map<String, Object> map5 = new HashMap<>(); |
| | | map5.put("v", "JCZX-TX-TT02001"); |
| | | dv.add(map5); |
| | | insProductResult.setEquipValue(JSON.toJSONString(dv)); |
| | | List<Map<String, Object>> dn = new ArrayList<>(); |
| | | Map<String, Object> map6 = new HashMap<>(); |
| | | map6.put("v", "步入式高低温湿热试验箱"); |
| | | dn.add(map6); |
| | | Map<String, Object> map7 = new HashMap<>(); |
| | | map7.put("v", "步入式高低温试验箱"); |
| | | dn.add(map7); |
| | | insProductResult.setEquipName(JSON.toJSONString(dn)); |
| | | insProductResultMapper.updateById(insProductResult); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //温度循环数采总体 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int temDataAcquisition2(PkMaster pkMaster) { |
| | | return 0; |
| | | } |
| | | } |