zss
2024-08-04 87794ed4e7b7cf7b13f7deef5da3e3ff03255d81
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -135,6 +135,7 @@
    @Resource
    private InsOrderFileMapper insOrderFileMapper;
    @Override
    public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
        Map<String, Object> map = new HashMap<>();
@@ -153,13 +154,15 @@
                laboratory = departLims;
            }
        }
        Integer userId =null;
        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId()) ) {
        String userName = null;
        Integer userId = null;
        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
            userId = map1.get("userId");
            insOrderPlanDTO.setUserId(userId.longValue());
            userName=userMapper.selectById(map1.get("userId")).getName();
            insOrderPlanDTO.setUserId(null);
        }
        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//试验室
        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory,laboratory);
        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory);
        map.put("body", insOrderPage);
        return map;
    }
@@ -187,7 +190,7 @@
            insOrderPlanDTO.setUserId(userId.longValue());
        }
        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//试验室
        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory,laboratory);
        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId, sonLaboratory, laboratory);
        map.put("body", insOrderPage);
        return map;
    }
@@ -200,7 +203,7 @@
        }
        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
        Integer userId = map1.get("userId");
        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1,entity.getSonLaboratory());
        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 0, entity.getSonLaboratory());
        return insSampleUserMapper.insert(insSampleUser) > 0;
    }
@@ -238,8 +241,6 @@
                insProducts = insSampleMapper.getInsProduct3(id);
                break;
        }
        // 数采新增
        getDeviceMessage(insProducts, request);
        Set<Integer> set = new HashSet<>();
        Map<Integer, String> map2 = new HashMap<>();
@@ -248,33 +249,6 @@
        return insProducts;
    }
    private List<InsProduct> getDeviceMessage(List<InsProduct> insProducts, HttpServletRequest request) {
        String ipAddress = request.getRemoteAddr();
        // 防止回环地址变为IPv6
        String ip =  ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress;
        insProducts.forEach(i -> {
            Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem(), i.getInspectionItemSubclass(), i.getSampleType());
            if (ObjectUtils.isNotEmpty(devices) && ObjectUtils.isNotEmpty(devices.get("file_type")) && ObjectUtils.isNotEmpty(devices.get("collect_url"))) {
                InsProductResult insProductResult = i.getInsProductResult();
                if (ObjectUtils.isEmpty(insProductResult)) {
                    insProductResult = new InsProductResult();
                }
                List<Object> list = new ArrayList<>();
                Map<Object, Object> hashMap = new HashMap<>();
                hashMap.put("v", devices.get("device_name"));
                list.add(hashMap);
                insProductResult.setEquipName(JSON.toJSON(list).toString());
                List<Object> listValue = new ArrayList<>();
                Map<Object, Object> hashMapValue = new HashMap<>();
                hashMapValue.put("v", devices.get("management_number"));
                listValue.add(hashMapValue);
                insProductResult.setEquipName(JSON.toJSON(list).toString());
                insProductResult.setEquipValue(JSON.toJSON(listValue).toString());
                i.setInsProductResult(insProductResult);
            }
        });
        return insProducts;
    }
    @Override
    public List<String> checkSubmitPlan(Integer orderId, String laboratory) {
        List<String> collect = new ArrayList<>();
@@ -353,9 +327,9 @@
                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)).collect(Collectors.toList());
                    if (insProducts.size()==collect.size()) {
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    }else {
                    } else {
                        insFiber.setState(0);//未检验
                    }
                }
@@ -365,9 +339,9 @@
                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)).collect(Collectors.toList());
                    if (insProducts.size()==collect.size()) {
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    }else {
                    } else {
                        insFiber.setState(0);//未检验
                    }
                }
@@ -378,9 +352,9 @@
                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)).collect(Collectors.toList());
                    if (insProducts.size()==collect.size()) {
                    if (insProducts.size() == collect.size()) {
                        insFiber.setState(1);//已检验
                    }else {
                    } else {
                        insFiber.setState(0);//未检验
                    }
                }
@@ -403,7 +377,7 @@
        //先查出这个样品下有哪些管色标,光纤带,光纤色标
        //先查出套管
        List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId));
        if (insBushings.size()>0) {
        if (insBushings.size() > 0) {
            //通信--温度循环
            for (InsBushing insBushing : insBushings) {
                //再查询出所有的光纤带
@@ -430,13 +404,13 @@
                                    insProduct.setInsProductResult(insProductResult);
                                }
                                //求同等条件下1次循环20度常温的计算值
                                InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId,insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                        .eq(InsProduct::getInsSampleId,sampleId)
                                InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                        .eq(InsProduct::getInsSampleId, sampleId)
                                        .eq(InsProduct::getInspectionItem, "1")
                                        .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                        .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass())
                                        .eq(InsProduct::getInsFiberId, fiber.getId())).getId() ));
                                if (ObjectUtils.isNotEmpty(insProductResult1) &&!insProductResult1.getComValue().equals("[]")) {
                                        .eq(InsProduct::getInsFiberId, fiber.getId())).getId()));
                                if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) {
                                    insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]);
                                }
                                productVo.setInsProduct(insProduct);
@@ -444,8 +418,7 @@
                            }
                        }
                    }
                }
                else {
                } else {
                    //如果套管下没有光纤带就只有光纤了
                    List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId()));
                    for (InsFiber fiber : insFiberList) {
@@ -463,12 +436,12 @@
                            productVo.setBushColor(fiber.getBushColor());
                            insProduct.setInsProductResult(insProductResult);
                            //求同等条件下1次循环20度常温的计算值
                            InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId,insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                    .eq(InsProduct::getInsSampleId,sampleId)
                            InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
                                    .eq(InsProduct::getInsSampleId, sampleId)
                                    .eq(InsProduct::getInspectionItem, "1")
                                    .eq(InsProduct::getInspectionItemSubclass, "20℃(常温)")
                                    .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass())
                                    .eq(InsProduct::getInsFiberId, fiber.getId())).getId() ));
                                    .eq(InsProduct::getInsFiberId, fiber.getId())).getId()));
                            if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) {
                                insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]);
                            }
@@ -479,8 +452,7 @@
                }
            }
            productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList());
        }
        else {
        } else {
            //电力--热循环和温升试验
            List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                    .eq(InsProduct::getInsSampleId, sampleId)
@@ -564,6 +536,7 @@
                        insProduct.setLastValue(o.equals("") ? null : (o.toString()));
                    }
                } catch (Exception e) {
                    insProduct.setLastValue("");//''
                }
                if (jo.get("equipValue") != null) {
                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue")));
@@ -592,6 +565,7 @@
                    String ir = JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + "";
                    insProduct.setInsResult(Integer.parseInt(ir));
                } catch (Exception e) {
                    insProduct.setInsResult(2);//待定
                }
                if (BeanUtil.isEmpty(result.getId())) {
                    result.setCreateUser(userId);
@@ -616,9 +590,9 @@
                PerformanceShift performanceShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
                        .eq(PerformanceShift::getUserId, userId)
                        .eq(PerformanceShift::getWorkTime, today));
                if (ObjectUtils.isNotEmpty(performanceShift)){
                if (ObjectUtils.isNotEmpty(performanceShift)) {
                    ShiftTime shiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, performanceShift.getShift()));
                    if (ObjectUtils.isNotEmpty(shiftTime)){
                    if (ObjectUtils.isNotEmpty(shiftTime)) {
                        DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm");
                        LocalTime now = LocalTime.now();
                        LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma);
@@ -644,7 +618,7 @@
                                .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)) {
                        if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && ObjectUtils.isEmpty(count2) && ObjectUtils.isEmpty(count1)) {
                            AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
                            if (isWithinRange) {
                                //在时间内就是正常上班
@@ -654,7 +628,7 @@
                                auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号
                                auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//非加班工时
                                auxiliaryOutputWorkingHours.setAmount(1);//非加班数量
                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//产量工时
                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时
                                auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组
                                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                                DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -672,7 +646,7 @@
                                auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//加班委托单号
                                auxiliaryOutputWorkingHours.setOvertimeWorkTime(insProduct.getManHour());//加班工时
                                auxiliaryOutputWorkingHours.setOvertimeAmount(1);//加班数量
                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//产量工时
                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//产量工时
                                auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组
                                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                                DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -734,7 +708,7 @@
    //交接
    @Override
    public int upPlanUser(Integer userId, Integer orderId,String sonLaboratory) {
    public int upPlanUser(Integer userId, Integer orderId, String sonLaboratory) {
        InsSampleUser insSampleUser = new InsSampleUser();
        insSampleUser.setUserId(userId);
        insSampleUser.setInsSampleId(orderId);
@@ -1118,8 +1092,8 @@
                    if (i % number == 0) {
                        List<RowRenderData> rows = new ArrayList<>();
                        //表格的行数 × √ ✖ ✔
                        long count1 = size-(index-1)*number < number ? size-(index-1)*number + 3 : number + 3;
                        for (int j = 0; j <count1 ; j++) {
                        long count1 = size - (index - 1) * number < number ? size - (index - 1) * number + 3 : number + 3;
                        for (int j = 0; j < count1; j++) {
                            RowRenderData rowRenderData = new RowRenderData();
                            RowStyle rowStyle = new RowStyle();
                            rowStyle.setHeight(40);
@@ -1161,8 +1135,7 @@
                                        cellRenderData.setParagraphs(paragraphRenderDataList);
                                        cells.add(cellRenderData);
                                    }
                                }
                                else if (j == 1) {
                                } else if (j == 1) {
                                    //第二行
                                    if (k == 0) {
                                        //第一列
@@ -1205,8 +1178,7 @@
                                        cellRenderData.setParagraphs(paragraphRenderDataList);
                                        cells.add(cellRenderData);
                                    }
                                }
                                else if (j == count1-1) {
                                } else if (j == count1 - 1) {
                                    //最后一行
                                    if (k == 0 || k == 1) {
                                        //前两列
@@ -1224,8 +1196,7 @@
                                        cellRenderData.setParagraphs(paragraphRenderDataList);
                                        cells.add(cellRenderData);
                                    }
                                }
                                else {
                                } else {
                                    if (k == 0) {
                                        //第一列
                                        textRenderData.setText((j - 1) + "");
@@ -1593,7 +1564,7 @@
                    if (i % 16 == 0) {
                        //样品数量超过16需要新增表格
                        List<RowRenderData> rows = new ArrayList<>();
                        int count2 = sampleList.size()-(index41-1)*16 < 16 ? (int) (sampleList.size() - (index41 - 1) * 16 + 1) : 17;
                        int count2 = sampleList.size() - (index41 - 1) * 16 < 16 ? (int) (sampleList.size() - (index41 - 1) * 16 + 1) : 17;
                        //表格的行数
                        for (int j = 0; j < count2; j++) {
                            RowRenderData rowRenderData = new RowRenderData();
@@ -1649,8 +1620,7 @@
                                        cellRenderData.setParagraphs(paragraphRenderDataList);
                                        cells.add(cellRenderData);
                                    }
                                }
                                else {
                                } else {
                                    if (k == 0) {
                                        //第一列
                                        textRenderData.setText(sampleList.get(0).getModel() + "∑44");
@@ -1789,7 +1759,7 @@
            } catch (Exception e) {
                throw new ErrorException("找不到检验人的签名");
            }
            if (ObjectUtils.isEmpty(signatureUrl)  || signatureUrl.equals("")) {
            if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) {
                throw new ErrorException("找不到检验人的签名");
            }
            //Custom custom = customMapper.selectById(user.get("company"));
@@ -3479,8 +3449,7 @@
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        else {
        } else {
            //复核不通过将把复核的负责人去掉
            Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId();
            insSampleUserMapper.deleteById(id);
@@ -3522,7 +3491,11 @@
                .in(InsProduct::getInsSampleId, ids)
                .eq(InsProduct::getSonLaboratory, laboratory)
                .eq(InsProduct::getState, 1)
                .isNull(InsProduct::getInsResult)
                .and(wrapper -> wrapper
                        .isNull(InsProduct::getInsResult)
                        .or()
                        .eq(InsProduct::getInsResult, 2)
                )
                .isNull(InsProduct::getInsFiberId)
                .isNull(InsProduct::getInsFibersId));
        insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory));
@@ -3548,7 +3521,7 @@
                    insProductMapper.updateById(product);
                }
                //如果是热循环或者是温升试验
                else if (product.getInspectionItem().equals("热循环") || product.getInspectionItem().equals("温升试验")){
                else if (product.getInspectionItem().equals("热循环") || product.getInspectionItem().equals("温升试验")) {
                    //查询这些项目下的其他检验项目是否全部检验
                    List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                            .eq(InsProduct::getInsSampleId, product.getInsSampleId())
@@ -3564,8 +3537,7 @@
                        product.setInsResult(1);
                    }
                    insProductMapper.updateById(product);
                }
                else {
                } else {
                    count++;
                    str += "<br/>" + count + ":" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>";
                }
@@ -3590,7 +3562,7 @@
        InsSampleUser insSampleUser = new InsSampleUser();
        insSampleUser.setUserId(verifyUser);
        insSampleUser.setInsSampleId(orderId);
        insSampleUser.setState(0);
        insSampleUser.setState(1);
        insSampleUser.setSonLaboratory(laboratory);
        insSampleUserMapper.insert(insSampleUser);
        /*校验一下result表*/