소스 검색

备件和保养导入

guarantee-lsq 2 년 전
부모
커밋
5dbeda9fc3

+ 8 - 7
platform-dao/src/main/java/com/platform/dao/entity/check/CheckStandard.java

@@ -14,6 +14,7 @@ import java.util.List;
 
 import lombok.experimental.Accessors;
 import com.platform.common.bean.DataScope;
+
 import javax.persistence.Transient;
 
 /**
@@ -25,15 +26,15 @@ import javax.persistence.Transient;
 @Data
 @Accessors(chain = true)
 @Table(name = "t_check_standard")
-public class CheckStandard implements Serializable{
+public class CheckStandard implements Serializable {
 
     /**
      * 主键
      */
-        @Id
+    @Id
     private String id;
 
-        private BigDecimal isGet;
+    private BigDecimal isGet;
     /**
      * 设备id
      */
@@ -146,9 +147,9 @@ public class CheckStandard implements Serializable{
      */
     private LocalDateTime updateTime;
 
-   /**
-    * 数据权限
-    */
+    /**
+     * 数据权限
+     */
     @Transient
     private DataScope dataScope;
 
@@ -160,7 +161,7 @@ public class CheckStandard implements Serializable{
 
     /**
      * 保养图片
-     * */
+     */
     private List<SysFile> checkImgList;
     /**
      * 保养手册

+ 7 - 7
platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

@@ -1691,15 +1691,15 @@ public class CustomExcelImportUtil {
             }
            // String index = getCellValue(row.getCell(0));
             try {
-                record.setParentName(row.getCell(3).getStringCellValue());
+                record.setParentName(row.getCell(2).getStringCellValue());
                 //record.setMiddleName(row.getCell(2).getStringCellValue());
                 //record.setChildName(getCellValue(row.getCell(3)));
-                record.setName(row.getCell(2).getStringCellValue());
-                record.setNo(getCellValue(row.getCell(1)));
-                record.setInitNo(getCellValue(row.getCell(9)));
-                record.setGgxh(getCellValue(row.getCell(8)));
-                record.setUnit(row.getCell(7).getStringCellValue());
-                String value = getCellValue(row.getCell(6));
+                record.setName(row.getCell(1).getStringCellValue());
+                record.setNo(getCellValue(row.getCell(0)));
+                record.setInitNo(getCellValue(row.getCell(8)));
+                record.setGgxh(getCellValue(row.getCell(7)));
+                record.setUnit(row.getCell(6).getStringCellValue());
+                String value = getCellValue(row.getCell(5));
                 if (StringUtils.isBlank(value)) {
                     record.setInitialValue(0.0);
                 } else {

+ 8 - 3
platform-dao/src/main/java/com/platform/dao/vo/export/check/ExportCheckStandardVO.java

@@ -6,7 +6,6 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 
 /**
  * @Description 点检标准导出VO
@@ -36,8 +35,8 @@ public class ExportCheckStandardVO implements Serializable {
     /**
      * 设备等级
      */
-    @Excel(name = "设备等级", orderNum = "4", dicCode = "SBINFO_LEVEL")
-    private Integer sbLevel;
+    @Excel(name = "维护等级 1:一级 2:二级 3:三级", orderNum = "4", dicCode = "CHECK_PLAN_LEVEL")
+    private Integer level;
     /**
      * 设备第一维修人
      */
@@ -90,4 +89,10 @@ public class ExportCheckStandardVO implements Serializable {
      */
     @Excel(name = "标准工时", orderNum = "15")
     private String standardHours;
+
+    /**
+     * 标准类型
+     */
+    @Excel(name = "标准类型 1 点检  2 保养 3 润滑", orderNum = "16")
+    private Integer type;
 }

+ 29 - 17
platform-dao/src/main/java/com/platform/dao/vo/export/sqarepartmanage/ExportSparePartInfoVO.java

@@ -23,86 +23,98 @@ public class ExportSparePartInfoVO implements Serializable {
     /**
      * 主键
      */
-    @Excel(name = "主键", orderNum = "1")
-    private String id;
+/*    @Excel(name = "主键", orderNum = "1")
+    private String id;*/
 
     /**
      * 备件编码
      */
-    @Excel(name = "编码", orderNum = "2")
+    @Excel(name = "编码", orderNum = "1")
     private String no;
 
     /**
      * 名称
      */
-    @Excel(name = "名称", orderNum = "3")
+    @Excel(name = "名称", orderNum = "2")
     private String name;
     /**
      * 大类编码名称
      */
-    @Excel(name = "类别", orderNum = "4")
+    @Excel(name = "类别", orderNum = "3")
     private String typeName;
     /**
      * 单价
      */
-    @Excel(name = "单价", orderNum = "5")
+    @Excel(name = "单价", orderNum = "4")
     private Double initialValue;
 
     /**
      * 计量单位: 1-件;2-台;3-条; 4-个
      */
-    @Excel(name = "计量单位", orderNum = "6")
+    @Excel(name = "计量单位;参照备注【计量单位说明】", orderNum = "5")
     private String unit;
 
     /**
      * 规格型号:使用的sb_guige
      */
-    @Excel(name = "规格型号", orderNum = "7")
+    @Excel(name = "规格型号", orderNum = "6")
     private String ggxh;
 
     /**
      * 规格型号:使用的sb_guige
      */
-    @Excel(name = "原厂编号", orderNum = "8")
+    @Excel(name = "原厂编号", orderNum = "7")
     private String initNo;
    /**
      * 备件等级:1-一级; 2-二级;3-三级
      */
-    @Excel(name = "备件等级", orderNum = "9", dicCode = "SPARE_PART_INFO_LEVEL")
+    @Excel(name = "备件等级 1:一级; 2:二级;3:三级", orderNum = "8", dicCode = "SPARE_PART_INFO_LEVEL")
     private Integer level;
     /**
      * 使用周期:月
      */
-    @Excel(name = "使用周期(月)", orderNum = "10")
+    @Excel(name = "使用周期(月)", orderNum = "9")
     private BigDecimal usePeriod;
     /**
      * 寿命周期:月
      */
-    @Excel(name = "寿命周期(月)", orderNum = "11")
+    @Excel(name = "寿命周期(月)", orderNum = "10")
     private BigDecimal agePeriod;
     /**
      * 采购到货周期:天
      */
-    @Excel(name = "采购到货周期(天)", orderNum = "12")
+    @Excel(name = "采购到货周期(天)", orderNum = "11")
     private BigDecimal purchasePeriod;
     /**
      * 生产商
      */
-    @Excel(name = "生产商", orderNum = "13")
+    @Excel(name = "生产商", orderNum = "12")
     private String producerName;
     /**
      * 最高库存
      */
-    @Excel(name = "最高库存", orderNum = "14")
+    @Excel(name = "最高库存", orderNum = "13")
     private BigDecimal maxStock;
     /**
      * 最低库存
      */
-    @Excel(name = "最低库存", orderNum = "15")
+    @Excel(name = "最低库存", orderNum = "14")
     private BigDecimal minStock;
     /**
      * 当前库存
      */
-    @Excel(name = "当前库存", orderNum = "16")
+    @Excel(name = "当前库存", orderNum = "15")
     private BigDecimal currentStock;
+
+    /**
+     * 用途
+     */
+    @Excel(name = "用途 1 设备配件 2 工程物资", orderNum = "16",dicCode = "SPARE_USE_TYPE")
+    private Integer yt;
+
+    /**
+     * 是否专用备件
+     */
+    @Excel(name = "是否专用备件 1 是 0 否", orderNum = "17",dicCode = "YES_NO")
+    private Integer isSpecial;
 }

+ 44 - 2
platform-service/src/main/java/com/platform/service/check/impl/CheckStandardServiceImpl.java

@@ -15,6 +15,7 @@ import com.platform.dao.dto.part.PartInfoDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
 import com.platform.dao.dto.store.InStoreDetailDTO;
 import com.platform.dao.entity.check.*;
+import com.platform.dao.entity.firm.FirmProducer;
 import com.platform.dao.entity.maintain.MaintainProjectStandardRelation;
 import com.platform.dao.entity.maintain.MaintainStandardParam;
 import com.platform.dao.entity.part.PartInfo;
@@ -22,6 +23,7 @@ import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbType;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
+import com.platform.dao.entity.sqarepartmanage.SpareType;
 import com.platform.dao.entity.store.InStoreDetail;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.entity.upms.SysUser;
@@ -33,7 +35,10 @@ import com.platform.dao.mapper.sb.SbInfoMapper;
 import com.platform.dao.mapper.upms.SysFileMapper;
 import com.platform.dao.mapper.upms.SysUserMapper;
 import com.platform.dao.util.CustomExcelImportUtil;
+import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.util.MessageTemplateUtil;
+import com.platform.dao.vo.export.check.ExportCheckStandardVO;
+import com.platform.dao.vo.export.sqarepartmanage.ExportSparePartInfoVO;
 import com.platform.dao.vo.query.check.CheckStandardSpareVO;
 import com.platform.dao.vo.query.check.CheckStandardVO;
 import com.platform.dao.vo.sb.SbInfoVO;
@@ -439,7 +444,44 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String importListByAdd(MultipartFile file) {
-        int addNum = 0;
+        List<CheckStandard> checkStandardList = null;
+        try{
+            List<ExportCheckStandardVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO.class, 1);
+            if(CollectionUtil.isNotEmpty(list)) {
+                checkStandardList = new ArrayList<>();
+                for (ExportCheckStandardVO importVO : list) {
+                    CheckStandard info = BeanConverterUtil.copyObjectProperties(importVO, CheckStandard.class);
+                    // 根据设备编号和名称,获取保养人
+                    SbInfo sbInfo = new SbInfo();
+                    sbInfo.setName(importVO.getSbName());
+                    sbInfo.setNo(importVO.getSbNo());
+                    sbInfo = sbInfoMapper.selectOne(sbInfo);
+                    if(sbInfo != null){
+                        info.setSbId(sbInfo.getId());
+                        info.setCheckUserId(sbInfo.getRepairUser());
+                        info.setCheckUserType(2);
+                    }
+                    String selectMaxNo = mapper.selectMaxNo();
+                    if(StringUtils.isBlank(selectMaxNo)){
+                        info.setNo("00001");
+                    }else{
+                        String newStr = selectMaxNo.replaceFirst("^0*", "");
+                        int count = Integer.valueOf(newStr) + 1;
+                        String str1 = String.format("%05d", count);
+                        info.setNo(str1);
+                    }
+                    info.setId(IdGeneratorUtils.getObjectId());
+                    checkStandardList.add(info);
+                }
+                mapper.insertListforComplex(checkStandardList);
+            }
+            return "成功: "  +  file.getOriginalFilename()+ ";";
+        }catch (Exception e) {
+            System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
+            return ("失败:" +  file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
+
+        }
+        /*int addNum = 0;
         List<String> modelError = new ArrayList<String>();
         try {
             List<CheckStandard> items = CustomExcelImportUtil.importCheckStandardList(file.getInputStream());
@@ -489,7 +531,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
             System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
             return ("失败:" +  file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
 
-        }
+        }*/
     }
 
     @Override

+ 47 - 6
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java

@@ -18,6 +18,8 @@ import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
 import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
 import com.platform.dao.dto.store.StoreDTO;
 import com.platform.dao.entity.check.CheckJob;
+import com.platform.dao.entity.firm.FirmProducer;
+import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbModel;
 import com.platform.dao.entity.sb.SbModelSpareBom;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
@@ -28,6 +30,7 @@ import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.enums.*;
 import com.platform.dao.mapper.check.CheckJobMapper;
 import com.platform.dao.mapper.check.CheckStandardSpareMapper;
+import com.platform.dao.mapper.firm.FirmProducerMapper;
 import com.platform.dao.mapper.sb.SbInfoMapper;
 import com.platform.dao.mapper.sb.SbModelMapper;
 import com.platform.dao.mapper.sb.SbModelSpareBomMapper;
@@ -38,7 +41,10 @@ import com.platform.dao.mapper.store.SpareStoreMapper;
 import com.platform.dao.mapper.store.StoreMapper;
 import com.platform.dao.mapper.upms.SysFileMapper;
 import com.platform.dao.util.CustomExcelImportUtil;
+import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.util.MessageTemplateUtil;
+import com.platform.dao.vo.export.sb.ExportSbInfoVO;
+import com.platform.dao.vo.export.sqarepartmanage.ExportSparePartInfoVO;
 import com.platform.dao.vo.query.check.CheckStandardSpareVO;
 import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
 import com.platform.dao.vo.sb.SbInfoVO;
@@ -92,6 +98,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     private CheckJobMapper checkJobMapper;
     private CheckStandardSpareMapper checkStandardSpareMapper;
     private CheckStandardService checkStandardService;
+    private FirmProducerMapper firmProducerMapper;
 
 
     @Override
@@ -937,7 +944,41 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String importListByAdd(MultipartFile file) {
-        int addNum = 0;
+        List<SparePartInfo> spareList = null;
+        List<SpareType> typeList = spareTypeMapper.selectAll();
+        try{
+            List<ExportSparePartInfoVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportSparePartInfoVO.class, 1);
+            if(CollectionUtil.isNotEmpty(list)){
+                spareList = new ArrayList<>();
+                for(ExportSparePartInfoVO importVO : list){
+                    SparePartInfo info = BeanConverterUtil.copyObjectProperties(importVO,SparePartInfo.class);
+                    // typeName
+                    for (SpareType type : typeList) {
+                        if (type.getName().equals(info.getTypeName())) {
+                            info.setTypeId(type.getId());
+                            info.setParentTypeId(type.getParentId());
+                        }
+                    }
+                    // 生产厂商
+                    if(StringUtils.isNotBlank(info.getProducerName())){
+                        FirmProducer firmProducer = new FirmProducer();
+                        firmProducer.setName(info.getProducerName().trim());
+                        firmProducer = firmProducerMapper.selectOne(firmProducer);
+                        if(firmProducer != null){
+                            info.setProducerId(firmProducer.getId());
+                        }
+                    }
+                    info.setId(IdGeneratorUtils.getObjectId());
+                    spareList.add(info);
+                }
+                mapper.insertListforComplex(spareList);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new BusinessException(e.getMessage());
+        }
+        return "总计新增导入:" + (spareList.size());
+        /*int addNum = 0;
         List<String> modelExist = new ArrayList<String>();
         List<SparePartInfoVO> addItems = new ArrayList<SparePartInfoVO>();
         List<String> modelError = new ArrayList<String>();
@@ -971,7 +1012,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                         item.setTypeId(item.getChildTypeId());
                     } else {
                         item.setTypeId(item.getMiddleTypeId());
-                    }
+                    }*/
 
                     // 设置型号bom
                     /*boolean findModel = false;
@@ -1037,7 +1078,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     }*/
 
                     // 设置库存,还是从库存里面走,但是如果名称一样怎么办,还是需要从这里走
-                    SpareStore spareStore = new SpareStore();
+                    /*SpareStore spareStore = new SpareStore();
                     spareStore.setSpareId(item.getId());
                     spareStore.setId(IdGeneratorUtils.getObjectId());
                     spareStore.setStoreId(item.getStoreId());
@@ -1059,12 +1100,12 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
                     addItemsReal = BeanConverterUtil.copyListProperties(addItems, SparePartInfo.class);
                     mapper.insertListforComplex(addItemsReal);
                 }
-               /* if(!CollectionUtils.isEmpty(addSbModelItems)){
+               *//* if(!CollectionUtils.isEmpty(addSbModelItems)){
                     sbModelMapper.insertListforComplex(addSbModelItems);
                 }
                 if(!CollectionUtils.isEmpty(bomList)){
                     sbModelSpareBomMapper.insertListforComplex(bomList);
-                }*/
+                }*//*
                 if (!CollectionUtils.isEmpty(spareStoreList)) {
                     spareStoreMapper.insertListforComplex(spareStoreList);
                 }
@@ -1072,7 +1113,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
             return "总计新增导入:" + (addItems.size());
         } catch (Exception e) {
             throw new BusinessException(e.getMessage());
-        }
+        }*/
     }
 
     @Override