zss
2024-08-08 69f3d9e338f29af69def24839e9b8cdd276a0472
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -336,7 +336,7 @@
                for (InsFibers insFiber : insFibers) {
                    List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFibersId, insFiber.getId()));
                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm!=2).collect(Collectors.toList());
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    } else {
@@ -349,7 +349,7 @@
                for (InsFiber insFiber : fiberList) {
                    List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId()));
                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm!=2).collect(Collectors.toList());
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    } else {
@@ -363,7 +363,7 @@
                for (InsFiber insFiber : insFiberList) {
                    List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId()));
                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm!=2).collect(Collectors.toList());
                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    } else {
@@ -378,7 +378,7 @@
                        .eq(InsProduct::getInsBushId, insBushing.getId()));
                List<Integer> collect = insProducts.stream()
                        .map(InsProduct::getInsResult)
                        .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm!=2).collect(Collectors.toList());
                        .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
                if (insProducts.size() == collect.size()) {
                    insBushing.setState(1);//已检验
                } else {
@@ -516,6 +516,7 @@
                insProduct.setId(Integer.parseInt(k));
                List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
                        .eq(InsProductResult::getInsProductId, insProduct.getId()));
                InsProduct product = insProductMapper.selectById(insProduct.getId());
                InsProductResult result;
                if (CollectionUtils.isEmpty(results)) {
                    result = new InsProductResult();
@@ -523,7 +524,16 @@
                    result = results.get(0);
                }
                result.setInsProductId(Integer.parseInt(k));
                /*校验一下result表*/
                List<InsProductResult> insProductResultss = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
                        .eq(InsProductResult::getInsProductId, insProduct.getId()));
                if (insProductResultss.size() > 1) {
                    for (int i = 1; i < insProductResultss.size(); i++) {
                        insProductResultMapper.deleteById(insProductResultss.get(i));
                    }
                }
                InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, Integer.parseInt(k)));
                //检验值
                if (jo.get("insValue") != null) {
                    JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue")));
                    List<Map<String, Object>> iv = new ArrayList<>();
@@ -546,6 +556,7 @@
                    }
                    result.setInsValue(JSON.toJSONString(iv));
                }
                //计算值
                if (jo.get("comValue") != null && !Objects.equals(jo.get("comValue"), "")) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue")));
                    List<Map<String, Object>> cv = new ArrayList<>();
@@ -557,6 +568,7 @@
                    }
                    result.setComValue(JSON.toJSONString(cv));
                }
                //最终值
                try {
                    JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue")));
                    if (resValue.get("v") != null) {
@@ -566,6 +578,7 @@
                } catch (Exception e) {
                    insProduct.setLastValue("");//''
                }
                //设备编号
                if (jo.get("equipValue") != null) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue")));
                    List<Map<String, Object>> ev = new ArrayList<>();
@@ -577,6 +590,7 @@
                    }
                    result.setEquipValue(JSON.toJSONString(ev));
                }
                //设备名称
                if (jo.get("equipName") != null) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipName")));
                    List<Map<String, Object>> ev = new ArrayList<>();
@@ -588,6 +602,7 @@
                    }
                    result.setEquipName(JSON.toJSONString(ev));
                }
                //结论
                try {
                    JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult")));
                    String ir = JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + "";
@@ -607,7 +622,6 @@
                /*如果是第一次选择设备信息,且还有其余样品也有同一个经验项目,那么所有样品的该项目都用这个设备信息*/
                //先查询是否还有其余样品
                InsProduct product = insProductMapper.selectById(insProduct.getId());
                Integer insSampleId = product.getInsSampleId();
                List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSampleMapper.selectById(insSampleId).getInsOrderId()));
@@ -623,9 +637,9 @@
                                .eq(InsProduct::getInspectionItemSubclassEn, product.getInspectionItemSubclassEn())
                                .eq(InsProduct::getTemplateId, product.getTemplateId())
                                .eq(InsProduct::getStandardMethodListId, product.getStandardMethodListId())
                                .eq(InsProduct::getInsBushId,product.getInsBushId())
                                .eq(InsProduct::getInsFibersId,product.getInsFibersId())
                                .eq(InsProduct::getInsFiberId,product.getInsFiberId())
                                .eq(InsProduct::getInsBushId, product.getInsBushId())
                                .eq(InsProduct::getInsFibersId, product.getInsFibersId())
                                .eq(InsProduct::getInsFiberId, product.getInsFiberId())
                        );
                        if (ObjectUtils.isNotEmpty(product1)) {
                            //如果存在项目,查询是否有表
@@ -685,18 +699,30 @@
                            isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime);
                        }
                        //加班
                        AuxiliaryOutputWorkingHours count1 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                        List<AuxiliaryOutputWorkingHours> count1s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                                .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
                                .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
                                .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
                                .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()));
                                .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode())
                                .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode()));
                        if (count1s.size() > 1) {
                            for (int i = 1; i < count1s.size(); i++) {
                                auxiliaryOutputWorkingHoursMapper.deleteById(count1s.get(i));
                            }
                        }
                        //非加班
                        AuxiliaryOutputWorkingHours count2 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                        List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                                .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
                                .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
                                .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
                                .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
                        if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && ObjectUtils.isEmpty(count2) && ObjectUtils.isEmpty(count1)) {
                                .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())
                                .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode()));
                        if (count2s.size() > 1) {
                            for (int i = 1; i < count2s.size(); i++) {
                                auxiliaryOutputWorkingHoursMapper.deleteById(count2s.get(i));
                            }
                        }
                        if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && CollectionUtils.isEmpty(count2s) && CollectionUtils.isEmpty(count1s)) {
                            AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
                            if (isWithinRange) {
                                //在时间内就是正常上班
@@ -3459,7 +3485,7 @@
                        put("createTime", now.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
                        put("createTimeEn", monthNames[now.getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                        put("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + insOrder.getInsTime().getDayOfMonth() + ", " + insOrder.getInsTime().getYear());
                        put("writeUrl", null);
                        put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create());
                        put("images", images);