zss
2024-07-31 0e2e829f10a5e5b239d6583d6be3afbcaed0dcc0
PK8000处理调试+各种bug调试优化
已修改11个文件
917 ■■■■■ 文件已修改
cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/service/impl/PkMasterServiceImpl.java 659 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderPlanController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/dto/SampleProductDto2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/InsOrderPlanService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsSampleMapper.xml 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java
@@ -283,6 +283,7 @@
    @ApiOperation(value = "温度循环数采总体")
    @PostMapping("/temDataAcquisition2")
    @ValueAuth
    public Result<?> temDataAcquisition2(@RequestBody PkMaster pkMaster) {
        return Result.success(pkMasterService.temDataAcquisition2(pkMaster));
    }
cnas-server/src/main/java/com/yuanchu/mom/service/impl/PkMasterServiceImpl.java
@@ -23,6 +23,7 @@
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
 * <p>
@@ -76,13 +77,362 @@
                .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)) {
@@ -96,287 +446,26 @@
        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;
    }
}
inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderPlanController.java
@@ -116,8 +116,8 @@
    @ValueClassify("检验任务")
    @ApiOperation(value = "检验任务提交")
    @PostMapping("/submitPlan")
    public Result<?> submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, String sampleCode) {
        int num = insOrderPlanService.submitPlan(orderId, laboratory, verifyUser, entrustCode, sampleCode);
    public Result<?> submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) {
        int num = insOrderPlanService.submitPlan(orderId, laboratory, verifyUser, entrustCode);
        return num == 1 ? Result.success() : Result.fail("提交失败,部分项目还未进行检验");
    }
inspect-server/src/main/java/com/yuanchu/mom/dto/SampleProductDto2.java
@@ -41,7 +41,7 @@
    private String inspectionValueType;
    @ValueTableShow(value = 12, name = "试验要求")
    private String ask;
    private String tell;
    @ValueTableShow(value = 13, name = "检验结果")
    private String lastValue;
inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
@@ -48,6 +48,8 @@
    List<Map<String, Object>> getReportModel(@Param("orderId") Integer orderId, @Param("id") Integer id, @Param("laboratory") String laboratory);
    SampleVo getDetailById(Integer sampleId);
    String selMethodById(Integer sampleId);
}
inspect-server/src/main/java/com/yuanchu/mom/service/InsOrderPlanService.java
@@ -28,7 +28,7 @@
    int verifyPlan(Integer orderId, String laboratory, Integer type, String tell);
    int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, String sampleCode);
    int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode);
    List<InsProduct> getInsProduct(Integer id, Integer type, String laboratory, HttpServletRequest request);
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -3447,6 +3447,11 @@
                throw new RuntimeException(e);
            }
        }
        else {
            //复核不通过将把复核的负责人去掉
            Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId();
            insSampleUserMapper.deleteById(id);
        }
        return 1;
    }
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -41,6 +41,8 @@
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;
/**
@@ -122,7 +124,7 @@
    @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));
@@ -283,64 +285,62 @@
            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("温升试验")) {
@@ -419,6 +419,67 @@
                }
            }
        }
    }
    //温度循环的处理
    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
@@ -546,7 +607,7 @@
    }
    @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(",");
@@ -574,7 +635,7 @@
            // 新建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);
            // 关闭流
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -1,5 +1,6 @@
package com.yuanchu.mom.service.impl;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,6 +21,7 @@
import com.yuanchu.mom.service.StandardProductListService2;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
@@ -72,6 +74,8 @@
                list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree1);
            }
        }
        String[] split1 = insSample.getFactory().split(" - ");
        list = list.stream().filter(list1 -> list1.getSample().equals(split1[3])).collect(Collectors.toList());
        list = list.stream().filter(a -> {
            try {
                if (a.getSection() != null && !Objects.equals(a.getSection(), "")) {
@@ -138,6 +142,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page) {
        String[] trees = tree.split(" - ");
        try{
inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -133,7 +133,7 @@
        from (
        select
        i.id,isa.sample_code,isa.sample,isa.model,isa.ins_state,ip.state,ip.unit,ip.inspection_item,ip.inspection_item_subclass,
        ip.son_laboratory,ip.inspection_item_type,ip.inspection_value_type,ip.ask,ip.`last_value`,ip.ins_result,ipr.equip_value
        ip.son_laboratory,ip.inspection_item_type,ip.inspection_value_type,ip.tell,ip.`last_value`,ip.ins_result,ipr.equip_value
        from ins_sample isa
        left join ins_order i on isa.ins_order_id = i.id
        left join ins_product ip on isa.id = ip.ins_sample_id
@@ -193,7 +193,7 @@
        c.price,
        c.cost,
        c.inspection_item,
        cus.company,
        i.company,
        u.`name`,
        i.create_user,
        c.ins_sample_id
@@ -406,7 +406,7 @@
        c.price,
        c.cost,
        c.inspection_item,
        cus.company,
        i.company,
        u.`name`,
        i.create_user,
        c.ins_sample_id,
inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -56,7 +56,7 @@
        ORDER BY ins_sample_id, id
        ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        LEFT JOIN user  ON isu.user_id = user.id
        LEFT JOIN user ON isu.user_id = user.id
        WHERE
        io.state = 1
        # AND io.ins_state != 5
@@ -94,41 +94,6 @@
        select * from(
        SELECT
        a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,<!--(ios.verify_user = #{userId})--> verify_user
        <!--FROM
        (
        SELECT
        io.id,
        io.entrust_code,
        io.type,
        io.appointed,
        io.send_time,
        io.sample_type,
        isu.user_id,
        ip.son_laboratory,
        io.ins_time
        FROM
        ins_order io
        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
        LEFT JOIN ( SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        WHERE
        io.state = 1
        # AND io.ins_state != 5
        and send_time is not null
        and (isu.user_id = #{userId} OR isu.user_id is NULL)
        GROUP BY
        ip.son_laboratory,
        io.id
        ) a
        LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
        left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM
        ins_sample_user GROUP BY ins_sample_id) md where td.id = md.id and user_id = #{userId}) isu2 on
        isu2.ins_sample_id = a.id
        ORDER BY
        a.user_id DESC,
        a.type DESC,
        a.id
        ) b-->
        FROM
        (
        SELECT
@@ -157,7 +122,7 @@
        ORDER BY ins_sample_id, id
        ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        LEFT JOIN user  ON isu.user_id = user.id
        LEFT JOIN user ON isu.user_id = user.id
        WHERE
        io.state = 1
        # AND io.ins_state != 5
@@ -185,7 +150,7 @@
        a.type DESC,
        a.id
        ) b
        where ins_state is not null)A
        where ins_state is not null )A
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
@@ -241,7 +206,7 @@
          and state = 1
          and ins_fiber_id is null
          and ins_fibers_id is null
        and isa.sample_code NOT REGEXP '/'
          and isa.sample_code NOT REGEXP '/'
    </select>
    <select id="getInsOrderAndSample" resultMap="sampleDto">
        select isa.*,
@@ -332,7 +297,8 @@
               method,
               man_day,
               bsm,
               tell as ask,
                ask,
               tell ,
               `last_value`,
               ip.ins_result  ip_ins_result,
               state,
@@ -350,7 +316,7 @@
                 left join ins_product ip on isa.id = ip.ins_sample_id
                 left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_order_id = #{id}
            and ip.standard_method_list_id is not null
          and ip.standard_method_list_id is not null
          and state = 1
    </select>
@@ -431,7 +397,7 @@
          and ip.son_laboratory = #{laboratory}
          and ins_fiber_id is null
          and ins_fibers_id is null
        and standard_method_list_id is not null
          and standard_method_list_id is not null
    </select>
    <select id="getInsProduct2" resultMap="product">
        select ip.id          ip_id,
@@ -671,6 +637,12 @@
               code methodName
        from ins_sample is2
                 inner join standard_method sm on standard_method_list_id = sm.id
        where is2.id=#{sampleId}
        where is2.id = #{sampleId}
    </select>
    <select id="selMethodById" resultType="java.lang.String">
        select code
        from standard_method
        where id = (select standard_method_list_id from ins_sample where id = #{sampleId})
    </select>
</mapper>