inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -27,6 +27,9 @@
import com.yuanchu.mom.service.*;
import com.yuanchu.mom.utils.*;
import com.yuanchu.mom.vo.*;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
@@ -78,6 +81,8 @@
    private ShiftTimeMapper shiftTimeMapper;
    @Resource
    private PerformanceShiftMapper performanceShiftMapper;
    @Resource
    private WarehouseHistoryMapper warehouseHistoryMapper;
    @Resource
    private WarehouseService warehouseService;
@@ -87,6 +92,9 @@
    @Resource
    WordUtils wordUtils;
    @Resource
    private InsReportMapper insReportMapper;
    @Resource
    private InsProductResultMapper insProductResultMapper;
@@ -307,6 +315,9 @@
        if (ObjectUtils.isNotEmpty(sampleId)) {
            insOrderFile.setInsSampleId(sampleId);
        }
        if (ObjectUtils.isNotEmpty(sonLaboratory)) {
            insOrderFile.setSonLaboratory(sonLaboratory);
        }
        insOrderFile.setFileName(filename);
        if (contentType != null && contentType.startsWith("image/")) {
            // 是图片
@@ -332,7 +343,7 @@
            if (ObjectUtils.isNotEmpty(sonLaboratory) && (sonLaboratory.equals("近场") || sonLaboratory.equals("远场")) &&
                    split[split.length - 1].equals("csv")) {
                //判断是哪种csv文件,是否有——
                if (!file.getOriginalFilename().contains("——")) {
                if (sonLaboratory.equals("近场")) {
                    fuSheUtils.getFuSheWord1(sonLaboratory, insOrderFile);
                } else {
                    fuSheUtils.getFuSheWord2(sonLaboratory, insOrderFile);
@@ -396,7 +407,7 @@
        } else {
            InsOrderState insOrderState = new InsOrderState();
            insOrderState.setInsOrderId(insSample.getInsOrderId());
            insOrderState.setInsOrderId(insSample.getId());
            insOrderState.setInsSampleId(insSample.getId());
            insOrderState.setLaboratory(sonLaboratory);
            insOrderState.setInsState(0);
            insOrderState.setNum(1);//初始是第一次
@@ -475,11 +486,60 @@
                //获取最后一行的num,即总行数。此处从0开始
                int maxRow = sheet.getLastRowNum();
                for (int row = 0; row <= maxRow; row++) {
                    XSSFRow xssfRow = sheet.getRow(row);
                    //获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
                    int maxRol = sheet.getRow(row).getLastCellNum();
                    StringBuilder aLine = new StringBuilder();
                    for (int rol = 0; rol < maxRol; rol++) {
                    /*for (int rol = 0; rol < maxRol; rol++) {
                        aLine.append(sheet.getRow(row).getCell(rol)).append(",");
                    }*/
                    for (int rol = 0; rol < maxRol; rol++) {
                        XSSFCell cell = xssfRow.getCell(rol);
                        if (cell == null) {
                            aLine.append(",");
                        } else {
                            switch (cell.getCellType()) {
                                case FORMULA:
                                    // 计算公式并获取结果
                                    CellValue cellValue = xssfWorkbook.getCreationHelper().createFormulaEvaluator().evaluate(cell);
                                    switch (cellValue.getCellType()) {
                                        case NUMERIC:
                                            String formattedValue = String.format("%.4f", cellValue.getNumberValue());
                                            aLine.append(formattedValue);
                                            break;
                                        case STRING:
                                            aLine.append(cellValue.getStringValue());
                                            break;
                                        case BOOLEAN:
                                            aLine.append(cellValue.getBooleanValue());
                                            break;
                                        case ERROR:
                                            aLine.append("#ERR!");
                                            break;
                                        default:
                                            aLine.append("");
                                            break;
                                    }
                                    break;
                                case NUMERIC:
                                    String formattedValue = String.format("%.4f", cell.getNumericCellValue());
                                    aLine.append(formattedValue);
                                    break;
                                case STRING:
                                    aLine.append(cell.getStringCellValue());
                                    break;
                                case BOOLEAN:
                                    aLine.append(cell.getBooleanCellValue());
                                    break;
                                case ERROR:
                                    aLine.append("#ERR!");
                                    break;
                                default:
                                    aLine.append("");
                                    break;
                            }
                            aLine.append(",");
                        }
                    }
                    String substring = aLine.substring(0, aLine.length() - 1);
                    result.append(substring).append("\n");
@@ -679,16 +739,15 @@
            throw new ErrorException("频率不能为空");
        }
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        //查询样品信息
        InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId());
        //查询检验单信息
        InsOrder insOrder = insOrderMapper.selectById(insProductResultDtos.getOrderId());
        InsOrderState orderState = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
                .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId())
                .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId())
                .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory())
                .orderByDesc(InsOrderState::getId)
                .last("LIMIT 1"));// 确保只取一条记录
        //查询样品信息
        InsSample insSample = insSampleMapper.selectById(insProductResultDtos.getSampleId());
        List<Integer> list = new ArrayList<>();
        /*新增检验项目检验值记录表(采取先删后增)*/
        insProductResult2Mapper.delete(Wrappers.<InsProductResult2>lambdaQuery()
@@ -730,8 +789,9 @@
                //结论
                int ressult = 1;
                String valueStr = insProductResult2.getValue();
                String regex ="[\u4e00-\u9fa5]";
                if (!insProduct.getAsk().contains(",")) {
                    if (insProduct.getAsk().equals("/")) {
                    if (insProduct.getAsk().equals("/") || Pattern.compile(regex).matcher(insProduct.getAsk()).find()) {
                        ressult = 3; //不判定
                    } else if (!isValueValid(valueStr, new String[]{insProduct.getAsk()})) {
                        ressult = 0; //不合格
@@ -793,10 +853,10 @@
            insSampleMapper.updateById(insSample);
        }
        /*判断该站点的检验项目是否全部已检*/
        int count = insProductMapper.selectInsProductCountByOrderId(insProductResultDtos.getOrderId());
        int count = insProductMapper.selectInsProductCountByOrderId(insSample.getInsOrderId());
        if (count == 0) {
            insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate()
                    .eq(InsOrderState::getInsOrderId, insProductResultDtos.getOrderId())
                    .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                    .eq(InsOrderState::getInsSampleId, insProductResultDtos.getSampleId())
                    .eq(InsOrderState::getLaboratory, insProductResultDtos.getSonLaboratory())
                    .set(InsOrderState::getInsState, 2));
@@ -866,7 +926,7 @@
            if (ObjectUtils.isEmpty(s)) {
                continue;
            }
            double numericValue = Double.parseDouble(s);
            double numericValue = Math.abs(Double.parseDouble(s));
            boolean valid = Arrays.stream(valuesToCheck)
                    .allMatch(v -> getResult(numericValue, v));
            if (!valid) {
@@ -952,7 +1012,7 @@
                            .set(InsOrderState::getCreateTime, LocalDateTime.now()));
                    break;
                case 1:
                    //继续试验:该站点任务结束(可以再次扫码检验);
                    //继续试验:该样品该站点任务结束(可以再次扫码检验);
                    insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate()
                            .eq(InsOrderState::getInsOrderId, insSample.getInsOrderId())
                            .eq(InsOrderState::getInsSampleId, sampleId)
@@ -1033,6 +1093,11 @@
        List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                .eq(InsProduct::getInsSampleId, insSample.getId())
                .eq(InsProduct::getSonLaboratory, submitPlanDto.getLaboratory())
                .and(wrapper -> wrapper
                        .isNull(InsProduct::getInsResult)
                        .or()
                        .eq(InsProduct::getInsResult, 2)
                )
                .eq(InsProduct::getState, 1));
        if (insProducts.size() > 0) {
            String str = "";
@@ -1078,7 +1143,7 @@
        info.setCreateUser(insProductMapper.selectUserById(userId).get("name"));
        info.setMessageType("2");
        info.setTheme("复核通知");
        info.setContent("您有一条检验任务待复核消息");
        info.setContent("您有一条检验任务待复核消息,订单号是:" + insOrder.getEntrustCode() + ",样品名称为:"+insSample.getSample());
        info.setSenderId(userId);
        info.setConsigneeId(submitPlanDto.getVerifyUser());
        info.setViewStatus(false);
@@ -1093,7 +1158,8 @@
        map.put("msgtype", "text");//消息类型 text:文本
        map.put("agentid", 1000517);//应用id
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("content", "您有一条检验任务待复核消息,订单号是:" + insOrder.getEntrustCode() + ",请前往LIMS系统查看。<a href=\"https://ztwxlims.ztt.cn:7443/enter\">中天通信LIMS系统 </a>");
        hashMap.put("content", "您有一条检验任务待复核消息,订单号是:" + insOrder.getEntrustCode() + ",样品名称为:"+insSample.getSample()+
                ",请前往LIMS系统查看。请点击<a href=\"https://ztwxlims.ztt.cn:7443/enter\">中天通信LIMS系统 </a>");
        map.put("text", hashMap);//消息内容
        map.put("safe", 0);//是否保密消息.0否
        map.put("enable_id_trans", 0);//是否开启id转译.0否
@@ -1116,9 +1182,6 @@
                throw new ErrorException("电路试验的站点报告生成有误,请联系开发人员调整!");
            }
        }
        /*// 删除数采采集次数
        String key = "frequency" + ":" + submitPlanDto.getEntrustCode() + ":*";
        RedisUtil.delsLike(key);*/
        /*生成产量工时*/
        //校验如果这个人这个检测项目已经添加过了则不需要再新增
@@ -1145,27 +1208,26 @@
                }
                for (AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours : submitPlanDto.getAuxiliaryOutputWorkingHoursList()) {
                    InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours.getInsProductId());
                    if (isWithinRange) {
                        //在时间内就是正常上班
                        auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号
                        auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//非加班工时
                        auxiliaryOutputWorkingHours.setAmount(1);//非加班数量
                    } else {
                        //加班
                        auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//加班委托单号
                        auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//加班工时
                        auxiliaryOutputWorkingHours.setOvertimeAmount(1);//加班数量
                    }
                    auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组
                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                    DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                    auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期
                    LocalDateTime localDateTime = LocalDateTime.now();
                    DateTime parse = DateUtil.parse(localDateTime.format(formatter));
                    auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期
                    auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次
                    auxiliaryOutputWorkingHours.setCheck(userId);//检测人
                    auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
                        if (isWithinRange) {
                            //在时间内就是正常上班
                            auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//非加班委托单号
                            auxiliaryOutputWorkingHours.setWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//非加班工时
                            auxiliaryOutputWorkingHours.setAmount(1);//非加班数量
                        } else {
                            //加班
                            auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//加班委托单号
                            auxiliaryOutputWorkingHours.setOvertimeWorkTime(auxiliaryOutputWorkingHours.getOutputWorkTime());//加班工时
                            auxiliaryOutputWorkingHours.setOvertimeAmount(1);//加班数量
                        }
                        auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//工时分组
                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                        auxiliaryOutputWorkingHours.setDateTime(LocalDateTime.now().toLocalDate().atStartOfDay().format(formatters));//日期
                        LocalDateTime localDateTime = LocalDateTime.now();
                        DateTime parse = DateUtil.parse(localDateTime.format(formatter));
                        auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//星期
                        auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//周次
                        auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
                }
            }
        }