qushaowei
2024-01-15 cb7eb6fa3477e624f7112a2eac632783b96bf4b4
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/DailyInspectionStandardController.java
@@ -269,9 +269,11 @@
        int successLines = 0, errorLines = 0;
        //a = 1开始读取点检项目;b = 1开始读取周保养项目;c = 1该设备导入信息存在错误;projectColumnIndex点检项目所在列;maintenanceColumnIndex周保养项目所在列
        int a = 0,b = 0,c = 0,projectColumnIndex = -1,maintenanceColumnIndex = 0;
        //表头标题
        String title = "";
        String dailyInspectionStandardId = null;
        String equipmentNum = null;
        DailyInspectionStandard dailyInspectionStandard = new DailyInspectionStandard();
        DailyInspectionStandard dailyInspectionStandard = null;
        List<DailyInspectionStandardDetail> dailyInspectionStandardDetailList = new ArrayList<>();
        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
            MultipartFile file = entity.getValue();
@@ -293,18 +295,26 @@
                        Sheet sheet = workbook.getSheetAt(i);
                        for (Row row : sheet) {
                            // 遍历每一个单元格
                            for (Cell cell : row) {
//                            for (Cell cell : row) {
                            for(int j = 0;j < 5;j++){
                                // 处理单元格数据,例如输出单元格的值
                                Cell cell = row.getCell(j);
//                                if("STRING".equals(cell.getCellType().toString())|| "BLANK".equals(cell.getCellType().toString())){
                                if("STRING".equals(cell.getCellType().toString())|| "BLANK".equals(cell.getCellType().toString())){
                                    //点检周期存在,判断设备统一编码是否存在
                                    if(cell.getStringCellValue().contains("设备名称:")){
                                        String[] tybh1  = cell.getStringCellValue().split("统一编号:");
                                    String strCell = cell.getStringCellValue();
                                    if(strCell.contains("生产设备自主维护点检表")){
                                        title = strCell.trim().substring(11).trim();
                                    }
                                    if(strCell.contains("设备名称:")){
                                        String[] tybh1  = strCell.split("统一编号:");
                                        String[] tybh2 = tybh1[1].split("年");
                                        equipmentNum = tybh2[0].trim().substring(0,tybh2[0].trim().length()-4).trim();
//                                        equipmentNum = tybh2[0].trim().substring(0,tybh2[0].trim().length()-4).trim();
                                        equipmentNum = tybh2[0].trim();
                                        /*String year =  tybh2[0].trim().substring(tybh2[0].trim().length()-4,tybh2[0].trim().length()).trim();
                                        String[] month1 = tybh2[1].split("月");
                                        String month = month1[0].trim();
                                        String[] unit1 = cell.getStringCellValue().split("单位:");
                                        String[] unit1 = strCell.split("单位:");
                                        String unit = unit1[1].trim();*/
                                        Equipment equipment = equipmentService.lambdaQuery().eq(Equipment::getNum,equipmentNum).eq(Equipment::getDelFlag, CommonConstant.DEL_FLAG_0).one();
                                        if(equipment == null){
@@ -320,12 +330,15 @@
                                                errorLines++;
                                            }else {
                                                c = 0;
                                                dailyInspectionStandard.setNum(identityService.getNumByTypeAndLength("DailylnspectionStandard",4));
                                                String num = identityService.getNumByTypeAndLength("DailylnspectionStandard", 4);
                                                dailyInspectionStandard = new DailyInspectionStandard();
                                                dailyInspectionStandard.setNum(num);
                                                dailyInspectionStandard.setVersionStatus("2");
                                                dailyInspectionStandard.setVersion("1.0");
                                                dailyInspectionStandard.setAssignMode("1");
                                                dailyInspectionStandard.setEquipmentId(equipment.getId());
                                                dailyInspectionStandard.setApprovalStatus("1");
                                                dailyInspectionStandard.setApprovalStatus("5");
                                                dailyInspectionStandard.setDisUda1(title);
                                                //dailyInspectionStandardService.save(dailyInspectionStandard);
                                                //dailyInspectionStandardId = dailyInspectionStandard.getId();
                                            }
@@ -334,23 +347,24 @@
                                    }
                                    //设备统一编码存在,判断点检项目是否存在
                                    if(c == 0){
                                        System.out.print(cell.getStringCellValue() + "\t");
                                        if(cell.getStringCellValue().contains("点检项目")){
                                        System.out.print(strCell + "\t");
                                        if(strCell.contains("点检项目")){
                                            a = 1;
                                            projectColumnIndex = cell.getColumnIndex();
                                            break;
                                        }
                                        if(cell.getStringCellValue().contains("维护责任人签字")){
                                        if(strCell.contains("维护责任人签字")){
                                            a = 0;
                                        }
                                        if(projectColumnIndex == cell.getColumnIndex() && a == 1){
                                            DailyInspectionStandardDetail dailyInspectionStandardDetail = new DailyInspectionStandardDetail();
                                            dailyInspectionStandardDetail.setDailyInspectionStandardId(dailyInspectionStandardId);
                                            String dayInspectionProjectName = row.getCell(projectColumnIndex).toString();
                                            String standard = row.getCell(projectColumnIndex+1).toString();
                                            //查询点击项目,如果没有新增点检项目
                                            String standard = row.getCell(projectColumnIndex+3).toString();
                                            //查询点检项目,如果没有新增点检项目
                                            if(StringUtils.isNotBlank(dayInspectionProjectName)){
                                                List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,dayInspectionProjectName).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list();
                                                List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,dayInspectionProjectName)
                                                        .eq(InspectionProject::getDetectionStandard,standard).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list();
                                                if(CollectionUtils.isEmpty(inspectionProjectList)){
                                                    InspectionProject inspectionProject = new InspectionProject();
                                                    inspectionProject.setNum(identityService.getNumByTypeAndLength("InspectionProject",4));
@@ -372,12 +386,13 @@
                                            }
                                            break;
                                        }
                                        if(cell.getStringCellValue().contains("周保养项目")){
                                        if(strCell.contains("周保养项目")){
                                            b = 1;
                                            maintenanceColumnIndex = cell.getColumnIndex();
                                            break;
                                        }
                                        if(cell.getStringCellValue().contains("周保养操作者执行")){
                                        if(strCell.contains("周保养操作者执行")){
                                            b = 0;
                                            dailyInspectionStandardService.save(dailyInspectionStandard);
                                            for(DailyInspectionStandardDetail dailyInspectionStandardDetail : dailyInspectionStandardDetailList){
@@ -392,9 +407,10 @@
                                            DailyInspectionStandardDetail dailyInspectionStandardDetail = new DailyInspectionStandardDetail();
                                            dailyInspectionStandardDetail.setDailyInspectionStandardId(dailyInspectionStandardId);
                                            String weekInspectionProjectName = row.getCell(maintenanceColumnIndex).toString();
                                            String inspectionStandardName = row.getCell(maintenanceColumnIndex+1).toString();
                                            String inspectionStandardName = row.getCell(maintenanceColumnIndex+3).toString();
                                            if(StringUtils.isNotBlank(weekInspectionProjectName)){
                                                List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,weekInspectionProjectName).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list();
                                                List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,weekInspectionProjectName)
                                                        .eq(InspectionProject::getDetectionStandard,inspectionStandardName).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list();
                                                if(CollectionUtils.isEmpty(inspectionProjectList)){
                                                    InspectionProject inspectionProject = new InspectionProject();
                                                    inspectionProject.setNum(identityService.getNumByTypeAndLength("InspectionProject",4));
@@ -456,6 +472,7 @@
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        dailyInspectionStandard.setWritePerson(sysUser.getRealname());
        dailyInspectionStandard.setId("");
        dailyInspectionStandard.setAssignMode("1");
        dailyInspectionStandard.setApprovalStatus("1");
        dailyInspectionStandard.setCreateTime(new Date());
        dailyInspectionStandard.setTakeEffectTime(null);