Selaa lähdekoodia

设备之系统——保养检修 V3
导入Excel

hyq 1 vuosi sitten
vanhempi
commit
df7639a3e7
13 muutettua tiedostoa jossa 542 lisäystä ja 17 poistoa
  1. 7 0
      cx-equipment/cx-equipment-common/pom.xml
  2. 122 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/config/EquMaintenanceStandardListener.java
  3. 177 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/excel/EquMaintenanceStandardTemplate.java
  4. 13 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquMaintenanceStandardService.java
  5. 1 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquPartsSetoutStandardService.java
  6. 16 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/MaintenanceService.java
  7. 10 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquMaintenanceStandardServiceImpl.java
  8. 1 0
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquPartsSetoutStandardServiceImpl.java
  9. 75 1
      cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/MaintenanceServiceImpl.java
  10. 13 11
      cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/EquipmentTypeEnum.java
  11. 41 0
      cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/MaintenanceTypeEnum.java
  12. 50 0
      cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/PlantEnum.java
  13. 16 5
      cx-equipment/cx-equipment-server/src/main/java/com/rongwei/bsserver/sys/controller/MaintenanceController.java

+ 7 - 0
cx-equipment/cx-equipment-common/pom.xml

@@ -57,5 +57,12 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.3.2</version>
+        </dependency>
+
     </dependencies>
 </project>

+ 122 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/config/EquMaintenanceStandardListener.java

@@ -0,0 +1,122 @@
+package com.rongwei.bscommon.sys.config;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.read.listener.ReadListener;
+import com.alibaba.excel.util.ListUtils;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.rongwei.bscommon.sys.dao.EquMaintenancePartDao;
+import com.rongwei.bscommon.sys.excel.EquMaintenanceStandardTemplate;
+import com.rongwei.bscommon.sys.feign.RwAdminFeign;
+import com.rongwei.bscommon.sys.utils.CommonUtils;
+import com.rongwei.bsentity.domain.EquMaintenancePartDo;
+import com.rongwei.bsentity.domain.EquMaintenanceStandardDo;
+import com.rongwei.bsentity.enums.EquipmentTypeEnum;
+import com.rongwei.bsentity.enums.MaintenanceTypeEnum;
+import com.rongwei.bsentity.enums.PlantEnum;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommon.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.*;
+
+/**
+ * @author shangmi
+ * @title ExcelListener
+ * @date 2023/12/7 16:09
+ * @description EquMaintenanceStandard监听器
+ */
+@Slf4j
+public class EquMaintenanceStandardListener extends AnalysisEventListener<EquMaintenanceStandardTemplate> {
+
+    private static final String[] NON_SET = {"equipmenttype","maintenancetype","maintenancesite","maintenancecontext","precontrol","means"};
+
+    private List<EquMaintenanceStandardDo> maintenanceStandardList = new ArrayList<>();
+
+    private List<String> errorData = new ArrayList<>();
+
+    @Override
+    public void invoke(EquMaintenanceStandardTemplate maintenanceStandardTemplate, AnalysisContext analysisContext) {
+        try {
+            log.info("解析到一条数据:{}",maintenanceStandardTemplate);
+            for (Field field : maintenanceStandardTemplate.getClass().getDeclaredFields()){
+                field.setAccessible(true);
+                String name = field.getName();
+                if (Objects.isNull(field.get(maintenanceStandardTemplate))&& Arrays.asList(NON_SET).contains(name)){
+                    errorData.add((analysisContext.readRowHolder().getRowIndex()+1)+"行存在必填数据为空的情况,请填写完整!");
+                }
+            }
+            EquMaintenanceStandardDo e = migrateDate(maintenanceStandardTemplate);
+            maintenanceStandardList.add(e);
+        }catch (Exception e){
+            log.error(e.getMessage());
+        }
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+    }
+
+    public List<EquMaintenanceStandardDo> getMaintenanceStandardList(){
+        return this.maintenanceStandardList;
+    }
+
+
+    public List<String> getErrorData(){
+        return this.errorData;
+    }
+
+
+
+
+    /**
+     * 数据转换
+     *
+     * @param equMaintenanceStandardTemplate
+     * @return {@link EquMaintenanceStandardDo}
+     * @date 2023/12/8 10:14
+     * @author shangmi
+     *
+     */
+
+    private EquMaintenanceStandardDo migrateDate(EquMaintenanceStandardTemplate equMaintenanceStandardTemplate){
+        Date date = new Date();
+        SysUserVo currentUser = CommonUtils.getCurrentUser();
+        EquMaintenanceStandardDo equMaintenanceStandardDo = new EquMaintenanceStandardDo();
+        BeanUtils.copyProperties(equMaintenanceStandardTemplate,equMaintenanceStandardDo);
+        equMaintenanceStandardDo.setMaintenancetype(MaintenanceTypeEnum.messageOf(equMaintenanceStandardTemplate.getMaintenancetype()).toString())
+                .setEquipmenttype(EquipmentTypeEnum.messageOf(equMaintenanceStandardTemplate.getEquipmenttype()).toString())
+                .setCreatedate(date)
+                .setModifydate(date)
+                .setId(SecurityUtil.getUUID())
+                // .setTenantid(currentUser.getTenantid())
+                .setTenantid("0001S31000000000J0TR")
+                // .setCreateusername(currentUser.getName())
+                // .setCreateuserid(currentUser.getId())
+                // .setModifyusername(currentUser.getName())
+                // .setModifyuserid(currentUser.getId())
+                .setIsoutsource(String.valueOf("是".equals(equMaintenanceStandardTemplate.getIsoutsource())?0:1))
+                .setJan("是".equals(equMaintenanceStandardTemplate.getJan())?1:null)
+                .setFeb("是".equals(equMaintenanceStandardTemplate.getFeb())?1:null)
+                .setMar("是".equals(equMaintenanceStandardTemplate.getMar())?1:null)
+                .setApr("是".equals(equMaintenanceStandardTemplate.getApr())?1:null)
+                .setMay("是".equals(equMaintenanceStandardTemplate.getMay())?1:null)
+                .setJun("是".equals(equMaintenanceStandardTemplate.getJun())?1:null)
+                .setJul("是".equals(equMaintenanceStandardTemplate.getJul())?1:null)
+                .setAug("是".equals(equMaintenanceStandardTemplate.getAug())?1:null)
+                .setSep("是".equals(equMaintenanceStandardTemplate.getSep())?1:null)
+                .setOct("是".equals(equMaintenanceStandardTemplate.getOct())?1:null)
+                .setNov("是".equals(equMaintenanceStandardTemplate.getNov())?1:null)
+                .setDecember("是".equals(equMaintenanceStandardTemplate.getDecember())?1:null);
+        return equMaintenanceStandardDo;
+    }
+}

+ 177 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/excel/EquMaintenanceStandardTemplate.java

@@ -0,0 +1,177 @@
+package com.rongwei.bscommon.sys.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author shangmi
+ * @title EquMaintenanceStandardTemplate
+ * @date 2023/12/7 13:57
+ * @description 标准库导入模板
+ */
+@Data
+@EqualsAndHashCode
+public class EquMaintenanceStandardTemplate {
+
+
+    /**
+     * table name:EQUIPMENTTYPE
+     * table type:varchar(20)
+     * table comment:设备分类
+     */
+    @ExcelProperty(index = 1)
+    private String equipmenttype;
+
+    /**
+     * table name:MAINTENANCETYPE
+     * table type:varchar(20)
+     * table comment:保养分类
+     */
+    @ExcelProperty(index = 2)
+    private String maintenancetype;
+
+    /**
+     * table name:MAINTENANCESITE
+     * table type:text
+     * table comment:保养部位
+     */
+    @ExcelProperty(index = 3)
+    private String maintenancesite;
+
+    /**
+     * table name:MAINTENANCECONTEXT
+     * table type:text
+     * table comment:保养内容
+     */
+    @ExcelProperty(index = 4)
+    private String maintenancecontext;
+
+    /**
+     * table name:PRECONTROL
+     * table type:text
+     * table comment:预控标准要求
+     */
+    @ExcelProperty(index = 5)
+    private String precontrol;
+
+    /**
+     * table name:EQUIPMENTSUPPORT
+     * table type:text
+     * table comment:设备保障域控措施
+     */
+    @ExcelProperty(index = 6)
+    private String equipmentsupport;
+
+    /**
+     * table name:MEANS
+     * table type:text
+     * table comment:保养/预防方法
+     */
+    @ExcelProperty(index = 7)
+    private String means;
+
+    /**
+     * table name:ISOUTSOURCE
+     * table type:varchar(10)
+     * table comment:是否委外
+     */
+    @ExcelProperty(index = 8)
+    private String isoutsource;
+
+    /**
+     * table name:JAN
+     * table type:int
+     * table comment:1月
+     */
+    @ExcelProperty(index = 9)
+    private String jan;
+
+    /**
+     * table name:FEB
+     * table type:int
+     * table comment:2月
+     */
+    @ExcelProperty(index = 10)
+    private String feb;
+
+    /**
+     * table name:MAR
+     * table type:int
+     * table comment:3月
+     */
+    @ExcelProperty(index = 11)
+    private String mar;
+
+    /**
+     * table name:APR
+     * table type:int
+     * table comment:4月
+     */
+    @ExcelProperty(index = 12)
+    private String apr;
+
+    /**
+     * table name:MAY
+     * table type:int
+     * table comment:5月
+     */
+    @ExcelProperty(index = 13)
+    private String may;
+
+    /**
+     * table name:JUN
+     * table type:int
+     * table comment:6月
+     */
+    @ExcelProperty(index = 14)
+    private String jun;
+
+    /**
+     * table name:JUL
+     * table type:int
+     * table comment:7月
+     */
+    @ExcelProperty(index = 15)
+    private String jul;
+
+    /**
+     * table name:AUG
+     * table type:int
+     * table comment:8月
+     */
+    @ExcelProperty(index = 16)
+    private String aug;
+
+    /**
+     * table name:SEP
+     * table type:int
+     * table comment:9月
+     */
+    @ExcelProperty(index = 17)
+    private String sep;
+
+    /**
+     * table name:OCT
+     * table type:int
+     * table comment:10月
+     */
+    @ExcelProperty(index = 18)
+    private String oct;
+
+    /**
+     * table name:NOV
+     * table type:int
+     * table comment:11月
+     */
+    @ExcelProperty(index = 19)
+    private String nov;
+
+    /**
+     * table name:DECEMBER
+     * table type:int
+     * table comment:12月
+     */
+    @ExcelProperty(index = 20)
+    private String december;
+}

+ 13 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquMaintenanceStandardService.java

@@ -24,4 +24,17 @@ public interface EquMaintenanceStandardService extends IService<EquMaintenanceSt
      */
 
     List<EquMaintenanceStandardDo> getPlanTypeByList(String planType);
+
+    /**
+     * 获得唯一性校验值(所有数据)
+     *
+     * @param
+     * @return {@link List<EquMaintenanceStandardDo>}
+     * @date 2023/12/8 15:05
+     * @author shangmi
+     *
+     */
+
+    List<EquMaintenanceStandardDo> getUniqueDateByAll();
+
 }

+ 1 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquPartsSetoutStandardService.java

@@ -1,6 +1,7 @@
 package com.rongwei.bscommon.sys.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.EquMaintenanceStandardDo;
 import com.rongwei.bsentity.domain.EquPartsSetoutStandardDo;
 
 import java.util.List;

+ 16 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/MaintenanceService.java

@@ -5,6 +5,9 @@ import com.rongwei.bsentity.dto.BatchCreateDTO;
 import com.rongwei.bsentity.dto.PlanYearCopyDTO;
 import com.rongwei.bsentity.dto.TaskCreatorDTO;
 import com.rongwei.rwcommon.base.R;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
 
 /**
  * @author shangmi
@@ -46,4 +49,17 @@ public interface MaintenanceService  {
      */
 
     R saveYearByTask(PlanYearCopyDTO planYearCopy);
+
+    /**
+     * 导入Excel添加标准库
+     *
+     * @param multipartFile
+     * @return {@link R}
+     * @date 2023/12/7 18:50
+     * @author shangmi
+     *
+     */
+
+    R uploadStandardSave(MultipartFile multipartFile) throws Exception;
+
 }

+ 10 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquMaintenanceStandardServiceImpl.java

@@ -31,4 +31,14 @@ public class EquMaintenanceStandardServiceImpl extends ServiceImpl<EquMaintenanc
 
         return maintenanceStandardDao.selectList(queryWrapper);
     }
+    @Override
+    public List<EquMaintenanceStandardDo> getUniqueDateByAll() {
+        LambdaQueryWrapper<EquMaintenanceStandardDo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.select(EquMaintenanceStandardDo::getEquipmenttype,
+                EquMaintenanceStandardDo::getTenantid,
+                EquMaintenanceStandardDo::getMaintenancecontext,
+                EquMaintenanceStandardDo::getMaintenancesite,
+                EquMaintenanceStandardDo::getMaintenancetype);
+        return maintenanceStandardDao.selectList(queryWrapper);
+    }
 }

+ 1 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquPartsSetoutStandardServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bscommon.sys.dao.EquPartsSetoutStandardDao;
 import com.rongwei.bscommon.sys.service.EquPartsSetoutStandardService;
+import com.rongwei.bsentity.domain.EquMaintenanceStandardDo;
 import com.rongwei.bsentity.domain.EquPartsSetoutStandardDo;
 import com.rongwei.bsentity.domain.EquPartsSetoutTaskDo;
 import org.checkerframework.checker.units.qual.A;

+ 75 - 1
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/MaintenanceServiceImpl.java

@@ -1,5 +1,9 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSON;
+import com.rongwei.bscommon.sys.config.EquMaintenanceStandardListener;
+import com.rongwei.bscommon.sys.excel.EquMaintenanceStandardTemplate;
 import com.rongwei.bscommon.sys.feign.RwAdminFeign;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.utils.CommonUtils;
@@ -8,6 +12,8 @@ import com.rongwei.bsentity.dto.BatchCreateDTO;
 import com.rongwei.bsentity.dto.PlanYearCopyDTO;
 import com.rongwei.bsentity.dto.TaskCreatorDTO;
 import com.rongwei.bsentity.enums.EquipmentTypeEnum;
+import com.rongwei.bsentity.enums.MaintenanceTypeEnum;
+import com.rongwei.bsentity.enums.PlantEnum;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
@@ -16,7 +22,9 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -220,6 +228,72 @@ public class MaintenanceServiceImpl implements MaintenanceService {
         }
     }
 
+    @Override
+    public R uploadStandardSave(MultipartFile multipartFile) throws Exception {
+        EquMaintenanceStandardListener standardListener = new EquMaintenanceStandardListener();
+        //解析Excel
+        EasyExcel.read(multipartFile.getInputStream(), EquMaintenanceStandardTemplate.class,standardListener).sheet().headRowNumber(4).doRead();
+        //解析有误信息
+        List<String> errorData = standardListener.getErrorData();
+        //解析数据
+        List<EquMaintenanceStandardDo> newMaintenanceStandardList = standardListener.getMaintenanceStandardList();
+        //唯一性数据
+        List<EquMaintenanceStandardDo> oldMaintenanceStandardList = maintenanceStandardService.getUniqueDateByAll();
+        //将新旧两组数据拼接为一个stream,再对stream进行分组,找到分组数量大于1的(说明又重复),将重复的数据拿到原始数据中找到源数据返回回来
+        List<EquMaintenanceStandardDo> maintenanceStandardDoList = Stream.concat(newMaintenanceStandardList.stream(), oldMaintenanceStandardList.stream()).collect(Collectors.groupingBy(info ->
+                        info.getTenantid() + info.getEquipmenttype() + info.getMaintenancetype() + info.getMaintenancesite() + info.getMaintenancecontext(), Collectors.counting()))
+                .entrySet().stream()
+                .filter(info -> info.getValue() > 1)
+                .map(Map.Entry::getKey)
+                .map(info -> newMaintenanceStandardList.stream()
+                        .filter(item -> (item.getTenantid() + item.getEquipmenttype() + item.getMaintenancetype() + item.getMaintenancesite() + item.getMaintenancecontext()).equals(info))
+                        .findFirst().orElse(null))
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+        //拼接返回错误数据
+        if (maintenanceStandardDoList.size()!=0){
+            jointErrorData(maintenanceStandardDoList,errorData);
+        }
+        //判断是否又错误数据
+        if (errorData.size()!=0){
+            return R.error(JSON.toJSONString(errorData));
+        }
+        SysUserVo currentUser = CommonUtils.getCurrentUser();
+        //生成流水号
+        for (EquMaintenanceStandardDo maintenanceStandard : newMaintenanceStandardList){
+            SysSerialVo sysSerialVo = new SysSerialVo();
+            sysSerialVo.setModulecode("equ_maintenance_standard_aq_code_BC");
+            sysSerialVo.setResetrule("date:yyyy");
+            sysSerialVo.setRuleTemplateStr(PlantEnum.addrOf(maintenanceStandard.getTenantid())+"-BYBZ-@{date:yyyyMM}@{serialNumber:#00000}");
+            R serialNumberCode = rwAdminFeign.getSerialNumberCode(sysSerialVo);
+            if ("200".equals(serialNumberCode.getCode())){
+
+                Object data = serialNumberCode.getData();
+                maintenanceStandard.setStandardid(CommonUtils.getObjectByMap(data).get("code").toString());
+            }
+        }
+        maintenanceStandardService.saveBatch(newMaintenanceStandardList,200);
+        return R.ok("导入成功");
+    }
+
+
+    /**
+     * 拼接错误数据
+     *
+     * @param maintenanceStandardList
+     * @param errorData
+     * @return
+     * @date 2023/12/8 16:43
+     * @author shangmi
+     *
+     */
+
+    public void jointErrorData(List<EquMaintenanceStandardDo> maintenanceStandardList,List<String> errorData){
+        maintenanceStandardList.forEach(info ->{
+            errorData.add(PlantEnum.nameOf(info.getTenantid())+",已存在了"+EquipmentTypeEnum.typeOf(Integer.valueOf(info.getEquipmenttype()))+"-"+MaintenanceTypeEnum.typeOf(Integer.valueOf(info.getMaintenancetype()))+"-"+info.getMaintenancesite()+"部位"+info.getMaintenancecontext()+"的保养标准内容,不可重复导入,请检查");
+        });
+
+    }
 
     /**
      * 详细库转移(标准——计划明细)
@@ -277,7 +351,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
             SysSerialVo sysSerialVo = new SysSerialVo();
             sysSerialVo.setModulecode("equ_maintenance_standard_aq_code_BC");
             sysSerialVo.setResetrule("date:yyyy");
-            sysSerialVo.setRuleTemplateStr(maintenanceSchedule.getPlantype()+"-BC-@{date:yyyyMM}@{serialNumber:#00000}");
+            sysSerialVo.setRuleTemplateStr(PlantEnum.addrOf(currentUser.getTenantid())+"-"+maintenanceSchedule.getPlantype()+"-@{date:yyyyMM}@{serialNumber:#00000}");
             R serialNumberCode = rwAdminFeign.getSerialNumberCode(sysSerialVo);
             EquMaintenanceTaskDo equMaintenanceTask = new EquMaintenanceTaskDo();
             BeanUtils.copyProperties( maintenanceSchedule,equMaintenanceTask);

+ 13 - 11
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/EquipmentTypeEnum.java

@@ -1,7 +1,5 @@
 package com.rongwei.bsentity.enums;
 
-import lombok.Data;
-
 import java.util.Arrays;
 import java.util.Objects;
 
@@ -43,21 +41,25 @@ public enum EquipmentTypeEnum {
     FORKLIFT("叉车",20),
     TRAVELLINGCRANE("行车",10)
 ;
+    
+    private final String type;
+    private final Integer message;
 
-    private String type;
-    private int massege;
-
-    EquipmentTypeEnum(String type, int massege) {
+    EquipmentTypeEnum(String type, Integer message) {
         this.type = type;
-        this.massege = massege;
+        this.message = message;
+    }
+
+    public static String typeOf(Integer message){
+        return getMessageByEquipmentTypeEnum(message,null).type;
     }
 
-    public static String typeOf(int massege){
-        return getMessageByEquipmentTypeEnum(massege,null).type;
+    public static Integer messageOf(String type){
+        return getTypeByEquipmentTypeEnum(type,null).message;
     }
 
-    public static EquipmentTypeEnum getMessageByEquipmentTypeEnum(int massege,EquipmentTypeEnum equipmentTypeEnum){
-          return Arrays.stream(values()).filter(info -> massege == info.massege).findFirst().orElse(equipmentTypeEnum);
+    public static EquipmentTypeEnum getMessageByEquipmentTypeEnum(Integer message,EquipmentTypeEnum equipmentTypeEnum){
+          return Arrays.stream(values()).filter(info -> Objects.equals(message, info.message)).findFirst().orElse(equipmentTypeEnum);
     }
 
 

+ 41 - 0
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/MaintenanceTypeEnum.java

@@ -0,0 +1,41 @@
+package com.rongwei.bsentity.enums;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * @author shangmi
+ * @title MaintenanceTypeEnum
+ * @date 2023/12/7 17:27
+ * @description 保养分类数据字典
+ */
+public enum MaintenanceTypeEnum {
+    MACHINERY("机械",1),
+    ELECTRIC("电气",2),
+    REST("其他",99)
+    ;
+    private final String type;
+    private final Integer message;
+
+    MaintenanceTypeEnum(String type,Integer message){
+        this.message = message;
+        this.type = type;
+    }
+
+    public static String  typeOf(Integer message){
+        return getMessageByType(message,null).type;
+    }
+
+    public static Integer messageOf(String type){
+        return getTypeByMessage(type,null).message;
+    }
+
+    public static MaintenanceTypeEnum getMessageByType(Integer message,MaintenanceTypeEnum maintenanceTypeEnum){
+        return Arrays.stream(values()).filter(info -> Objects.equals(info.message, message)).findFirst().orElse(maintenanceTypeEnum);
+    }
+
+
+    private static MaintenanceTypeEnum getTypeByMessage(String type,MaintenanceTypeEnum maintenanceTypeEnum){
+        return Arrays.stream(values()).filter(info -> type.equals(info.type)).findFirst().orElse(maintenanceTypeEnum);
+    }
+}

+ 50 - 0
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/enums/PlantEnum.java

@@ -0,0 +1,50 @@
+package com.rongwei.bsentity.enums;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+/**
+ * @author shangmi
+ * @title PlantEnum
+ * @date 2023/12/8 16:26
+ * @description 工厂枚举
+ */
+public enum PlantEnum {
+    CXLB("0001651000000015EFDD","山东创新箔材科技有限公司","CXLB"),
+    CXJL("0001651000000017DRZ1","山东创新精铝金属制造有限公司","CXJL"),
+    CXBC("0001S31000000000J0TR","山东创新板材有限公司","CXBC")
+    ;
+    private final String id;
+    private final String name;
+    private final String addr;
+
+    PlantEnum(String id, String name,String addr) {
+        this.id = id;
+        this.name = name;
+        this.addr = addr;
+    }
+
+    public static String idOf(String name){
+        return getPlantById(name,null).id;
+    }
+
+    public static PlantEnum getPlantById(String name,PlantEnum plantEnum){
+        return Stream.of(values()).filter(info -> name.equals(info.name)).findFirst().orElse(plantEnum);
+    }
+
+    public static String nameOf(String id){
+        return getPlantByName(id,null).name;
+    }
+
+    public static PlantEnum getPlantByName(String id,PlantEnum plantEnum){
+        return Stream.of(values()).filter(info -> id.equals(info.id)).findFirst().orElse(plantEnum);
+    }
+
+    public static String addrOf(String id){
+        return getPlantByName(id,null).addr;
+    }
+
+    public static PlantEnum getPlantByaddr(String id,PlantEnum plantEnum){
+        return Stream.of(values()).filter(info -> id.equals(info.id)).findFirst().orElse(plantEnum);
+    }
+}

+ 16 - 5
cx-equipment/cx-equipment-server/src/main/java/com/rongwei/bsserver/sys/controller/MaintenanceController.java

@@ -1,5 +1,6 @@
 package com.rongwei.bsserver.sys.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.rongwei.bscommon.sys.service.MaintenanceService;
 import com.rongwei.bscommon.sys.utils.ExceptionUtils;
 import com.rongwei.bsentity.dto.BatchCreateDTO;
@@ -9,10 +10,10 @@ import com.rongwei.rwcommon.base.R;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.mail.Multipart;
 
 /**
  * @author shangmi
@@ -64,5 +65,15 @@ public class MaintenanceController {
         }
     }
 
-
+    @PostMapping("importStandardSave")
+    public R uploadStandardSave(@RequestParam("file") MultipartFile multipartFile){
+        try {
+            log.info("进入接口:/maintenance/importStandardSave,入参:{}", multipartFile);
+            return maintenanceService.uploadStandardSave(multipartFile);
+            // return null;
+        }catch (Exception e){
+            ExceptionUtils.printExceptionDetail(e,"导入失败,请检查后再导入:");
+            return R.error(e.getMessage());
+        }
+    }
 }