Quellcode durchsuchen

设备子系统———大修计划任务导入代码暂时搁置

zhoudazhuang vor 1 Jahr
Ursprung
Commit
7295f59901

+ 31 - 21
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquOverhaulPlanningTasksServiceImpl.java

@@ -2,15 +2,15 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bscommon.sys.dao.CommonDao;
 import com.rongwei.bscommon.sys.dao.EquOverhaulPlanningTasksMapperDao;
 import com.rongwei.bscommon.sys.service.EquOverhaulPlanningTasksService;
-import com.rongwei.bscommon.sys.utils.DateUtils;
-import com.rongwei.bscommon.sys.utils.ExcelUtils;
-import com.rongwei.bscommon.sys.utils.ExceptionUtils;
-import com.rongwei.bscommon.sys.utils.StringUtil;
+import com.rongwei.bscommon.sys.utils.*;
 import com.rongwei.bsentity.domain.EquOverhaulPlanningTasksDo;
 import com.rongwei.bsentity.domain.EquWarrantyProviderDo;
 import com.rongwei.rwadmincommon.system.domain.SysDictDo;
+import com.rongwei.rwadmincommon.system.vo.SysOrganizationVo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
@@ -27,6 +27,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -42,42 +43,48 @@ public class EquOverhaulPlanningTasksServiceImpl extends ServiceImpl<EquOverhaul
     @Autowired
     private EquOverhaulPlanningTasksService equOverhaulPlanningTasksService;
 
+    @Autowired
+    private CommonDao commonDao;
+
     @Override
     public R importEquOverhaulPlanningTasks(MultipartFile file) {
         try {
+            // 查询所有工厂数据
+            List<SysOrganizationVo> factoryList = commonDao.getAllFactoryNameAndId();
+            SysUserVo currentUser = CommonUtils.getCurrentUser();
             StringBuilder allStrBuilder = new StringBuilder();
             Sheet sheet = new XSSFWorkbook(file.getInputStream()).getSheetAt(0);
             int lastRowNum = sheet.getLastRowNum();
             List<EquOverhaulPlanningTasksDo> equOverhaulPlanningTasksDos = new ArrayList<>();
             for (int i = 1; i <= lastRowNum; i++) {
                 StringBuilder stringBuilder = new StringBuilder();
+                String taskNumber = "";
+                String factoryId = currentUser.getOrganizationDoList().get(0).getFullpid().split(",")[1];
+                List<SysOrganizationVo> resultList = factoryList.stream().filter(p -> p.getId().equals(factoryId)).collect(Collectors.toList());
+                String factory = resultList.get(0).getFullname();
                 EquOverhaulPlanningTasksDo equOverhaulPlanningTasksDo = new EquOverhaulPlanningTasksDo();
                 Row row = sheet.getRow(i);
                 if (ExcelUtils.isRowEmpty(row)){
                     continue;
                 }
                 String year = row.getCell(0) == null ? "" : row.getCell(0).toString().trim();
-                String taskNumber = row.getCell(1) == null ? "" : row.getCell(1).toString().trim();
-                String factory = row.getCell(2) == null ? "" : row.getCell(2).toString().trim();
-                String dept = row.getCell(3) == null ? "" : row.getCell(3).toString().trim();
-                String equName = row.getCell(4) == null ? "" : row.getCell(4).toString().trim();
-                String equNumber = row.getCell(5) == null ? "" : row.getCell(5).toString().trim();
-                String repairReason = row.getCell(6) == null ? "" : row.getCell(6).toString().trim();
-                Date planStartDate = row.getCell(7) == null ? null : DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(7));
-                Date planEndDate = row.getCell(8) == null ? null : DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(8));
-                String repairProgramme = row.getCell(9) == null ? "" : row.getCell(9).toString().trim();
-                String isDangerous = row.getCell(10) == null ? "" : row.getCell(10).toString().trim();
-                String isOutsourcing = row.getCell(11) == null ? "" : row.getCell(11).toString().trim();
-                String header = row.getCell(12) == null ? "" : row.getCell(12).toString().trim();
-                String others = row.getCell(13) == null ? "" : row.getCell(13).toString().trim();
+                String dept = row.getCell(1) == null ? "" : row.getCell(1).toString().trim();
+                String equName = row.getCell(2) == null ? "" : row.getCell(2).toString().trim();
+                String equNumber = row.getCell(3) == null ? "" : row.getCell(3).toString().trim();
+                String repairReason = row.getCell(4) == null ? "" : row.getCell(4).toString().trim();
+                Date planStartDate = row.getCell(5) == null ? null : DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(5));
+                Date planEndDate = row.getCell(6) == null ? null : DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(6));
+                String repairProgramme = row.getCell(7) == null ? "" : row.getCell(7).toString().trim();
+                String isDangerous = row.getCell(8) == null ? "" : row.getCell(8).toString().trim();
+                String isOutsourcing = row.getCell(9) == null ? "" : row.getCell(9).toString().trim();
+                String header = row.getCell(10) == null ? "" : row.getCell(10).toString().trim();
+                String others = row.getCell(11) == null ? "" : row.getCell(11).toString().trim();
+                String taskStatus = row.getCell(12) == null ? "" : row.getCell(12).toString().trim();
                 if (StringUtils.isBlank(year)){
                     stringBuilder.append("年度必填");
                 }else {
                     year = StringUtil.formatDecimal(year);
                 }
-                if (StringUtils.isBlank(taskNumber)){
-                    stringBuilder.append("任务号必填");
-                }
                 if (StringUtils.isBlank(equName)){
                     stringBuilder.append("设备名称必填");
                 }
@@ -100,7 +107,10 @@ public class EquOverhaulPlanningTasksServiceImpl extends ServiceImpl<EquOverhaul
                             .setIsdangerousoperations(isDangerous)
                             .setIsoutsourcing(isOutsourcing)
                             .setRepairhead(header)
-                            .setOtherrepairengineer(others);
+                            .setOtherrepairengineer(others)
+                            .setTenantid(factoryId)
+                            .setRepairillustrate(repairProgramme)
+                            .setTaskstatus(taskStatus);
                     equOverhaulPlanningTasksDos.add(equOverhaulPlanningTasksDo);
                 }
             }

+ 4 - 4
cx-equipment/cx-equipment-server/src/main/java/com/rongwei/bsserver/sys/controller/EquOverhaulPlanningTasksController.java

@@ -44,10 +44,10 @@ public class EquOverhaulPlanningTasksController {
         if (file == null){
             return R.error("文件解析失败");
         }
-//        String errorMsg = checkUtil.fileCheckDetail(file,"a02f48e0c8024df1980ee5661c72be10");
-//        if (StringUtils.isNotBlank(errorMsg)){
-//            return R.error(errorMsg);
-//        }
+        String errorMsg = checkUtil.fileCheckDetail(file,"a02f48e0c8024df1980ee5661c72be10");
+        if (StringUtils.isNotBlank(errorMsg)){
+            return R.error(errorMsg);
+        }
         return equOverhaulPlanningTasksService.importEquOverhaulPlanningTasks(file);
     }
 }