zss
2025-02-28 ede49ec7133b86d9db9dc1f0328418dcdaaef8aa
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -652,6 +652,16 @@
                } catch (Exception e) {
                    result.setAfterCheck("");//''
                }
                //实验结果
                try {
                    JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("testResult")));
                    if (resValue.get("v") != null) {
                        Object o = JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v");
                        result.setTestResult(o.equals("") ? null : (o.toString()));
                    }
                } catch (Exception e) {
                    result.setTestResult("");//''
                }
                //设备编号
                if (jo.get("equipValue") != null) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue")));
@@ -920,19 +930,19 @@
            }
        }
        // 处理其他比较条件
        if (ask.startsWith(">")) {
        if (ask.startsWith(">") || ask.startsWith(">")) {
            double threshold = Double.parseDouble(ask.substring(1));
            return s > threshold;
        } else if (ask.startsWith("≥")) {
            double threshold = Double.parseDouble(ask.substring(1));
            return s >= threshold;
        } else if (ask.startsWith("<")) {
        } else if (ask.startsWith("<")|| ask.startsWith("<")) {
            double threshold = Double.parseDouble(ask.substring(1));
            return s < threshold;
        } else if (ask.startsWith("≤")) {
            double threshold = Double.parseDouble(ask.substring(1));
            return s <= threshold;
        } else if (ask.equals("=")) {
        } else if (ask.equals("=")|| ask.startsWith("=")) {
            double exactValue = Double.parseDouble(ask.substring(1));
            return s == exactValue;
        }
@@ -979,7 +989,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell) throws IOException {
    public int verifyPlan(Integer sampleId, String laboratory, Integer type, String tell)  {
        LocalDateTime now = LocalDateTime.now();
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        List<InsUnPass> insUnPasses = new ArrayList<>();
@@ -1063,10 +1073,15 @@
                    //如果订单类型是原理样机,则该订单直接闭环
                    List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId()));
                    for (InsSample sample : insSamples) {
                        outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
                        try{
                            outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
                        }catch (Exception e){
                        }
                    }
                    insOrder.setState(4);
                    insOrderMapper.updateById(insOrder);
                    /*生成对应的检验报告*/
                    List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
                    createReport(insOrder.getId(),insReportDto1s);
                    break;
            }
        }
@@ -1075,7 +1090,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) throws IOException {
    public int verifyPlan2(Integer sampleId, String laboratory, Integer type, String tell) {
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        InsSample insSample = insSampleMapper.selectById(sampleId);
        InsOrder insOrder = insOrderMapper.selectById(insSample.getInsOrderId());
@@ -1088,11 +1103,6 @@
                .orderByDesc(InsOrderState::getId)
                .last("LIMIT 1")); // 确保只取一条记录
        if (record != null) {
            //更新记录
            insOrderUserMapper.update(null, Wrappers.<InsOrderUser>lambdaUpdate()
                    .eq(InsOrderUser::getInsOrderStateId, record.getId())
                    .eq(InsOrderUser::getNum, record.getNum())
                    .set(InsOrderUser::getTell, tell));
            switch (type) {
                case 0:
                    //再次试验:该单子退回到检验状态(排序改成当前的最后),次数递增(保留以前的数据);
@@ -1104,7 +1114,6 @@
                            .set(InsOrderState::getVerifyUser, userId)
                            .set(InsOrderState::getNum, record.getNum() + 1)//次数加1
                            .set(InsOrderState::getCreateTime, LocalDateTime.now()));
                    insOrder.setState(3);
                    break;
                case 1:
                    //继续试验:该样品该站点任务结束(可以再次扫码检验);
@@ -1127,7 +1136,6 @@
                                .set(InsOrderState::getVerifyTell, tell)
                                .set(InsOrderState::getVerifyUser, userId));
                    }
                    insOrder.setState(3);
                    break;
                case 2:
                    //结束试验:此委托单停止试验(无法再次检验)。
@@ -1153,14 +1161,33 @@
                    //出库
                    List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSample.getInsOrderId()));
                    for (InsSample sample : insSamples) {
                        outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
                        try{
                            outInsOrderState(laboratory, sample.getSampleCode(), insOrder.getEntrustCode());
                        }catch (Exception e){
                        }
                    }
                    insOrder.setState(4);
                    /*生成对应的检验报告*/
                    List<InsReportDto1> insReportDto1s=insOrderUserMapper.selectInsReportDto1(insOrder.getId());
                    createReport(insOrder.getId(),insReportDto1s);
                    break;
            }
            insOrderMapper.updateById(insOrder);
        }
        return 1;
    }
    /*生成对应的检验报告*/
    private void createReport(Integer orderId,List<InsReportDto1> insReportDto1s){
        for (InsReportDto1 insReportDto1 : insReportDto1s) {
            if (ObjectUtils.isNotEmpty(insReportDto1.getInsReportDto2s())){
                wordUtils.generateReport(orderId, insReportDto1);
//                try{
//                    wordUtils.generateReport(orderId, insReportDto1);
//                }catch (Exception e){
//                    throw new ErrorException("报告格式生成有误,请联系管理员!");
//                }
            }
        }
    }
    private void getTemplateThing
@@ -1221,8 +1248,8 @@
            String str = "";
            int count = 0;
            for (InsProduct product : insProducts) {
                //辐射试验,温湿度试验,功率试验的检验项目,不需要去手动填写检验值,只需要上传表格文件就可以了,后台提交的时候校验跳过这个检验项目
                if (product.getInspectionItem().equals("辐射试验") || product.getInspectionItem().equals("温湿度试验") || product.getInspectionItem().equals("功率试验")) {
                //温湿度试验,功率试验的检验项目,不需要去手动填写检验值,只需要上传表格文件就可以了,后台提交的时候校验跳过这个检验项目
                if ( product.getInspectionItem().equals("温湿度试验") || product.getInspectionItem().equals("功率试验")) {
                    product.setInsResult(3);//不判定
                    insProductMapper.updateById(product);
                    continue;