1 年間 前
コミット
dc19398163

+ 95 - 0
platform-dao/src/main/java/com/platform/dao/vo/export/sb/ExportYiBiaoSbInfoVO.java

@@ -0,0 +1,95 @@
+package com.platform.dao.vo.export.sb;
+
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDate;
+
+/**
+ * @Description 设备基础信息导出VO
+ * @Author liuyu
+ * @Date 2021-04-21 21:05:46
+ * @Version Copyright (c) 2021,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class ExportYiBiaoSbInfoVO implements Serializable {
+
+    /**
+     * 主键
+     */
+    @Excel(name = "主键")
+    private String id;
+
+    /**
+     * 设备位置
+     */
+    @Excel(name = "车间")
+    private String positionName;
+
+    /**
+     * 具体位置
+     */
+    @Excel(name = "位置")
+    private String cph;
+
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号")
+    private String no;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String name;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "规格、型号")
+    private String model;
+
+
+    /**
+     * 生产商
+     */
+    @Excel(name = "厂牌")
+    private String producerId;
+
+    /**
+     * 使用位置
+     */
+    @Excel(name = "出厂编号")
+    private String zzh;
+
+    /**
+     * 使用位置
+     */
+    @Excel(name = "管理编号")
+    private String positionNo;
+
+    /**
+     * 下次检定日期
+     */
+    @Excel(name = "有效期限", exportFormat = "yyyy/MM/dd")
+    private LocalDate nextCheckDate;
+
+
+    /**
+     * 检定单位
+     */
+    @Excel(name = "检定单位")
+    private String dph;
+
+
+    /**
+     * 是否强检1:强检,2:非强检
+     */
+    @Excel(name = "是否强检1:强检,2:非强检")
+    private Integer checkType;
+
+}

+ 35 - 2
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -26,6 +26,7 @@ import com.platform.dao.util.TreeUtil;
 import com.platform.dao.vo.export.sb.ExportSbInfoDetailVO;
 import com.platform.dao.vo.export.sb.ExportSbInfoMeasureVO;
 import com.platform.dao.vo.export.sb.ExportSbInfoVO;
+import com.platform.dao.vo.export.sb.ExportYiBiaoSbInfoVO;
 import com.platform.dao.vo.sb.SbInfoVO;
 import com.platform.dao.vo.sb.SbInfoWorkplaceVO;
 import com.platform.dao.vo.sb.SbTypeVO;
@@ -37,6 +38,7 @@ import com.platform.service.sb.SbInfoService;
 import com.platform.service.upms.SysUserRoleService;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -275,14 +277,14 @@ public class SbInfoController {
                 log.setId(IdGeneratorUtils.getObjectId());
                 setCreateUserInfo(log);
                 log.setSbId(vo.getId());
-                String str = "设备位号为:" + (vo.getPositionNo() == null ? "" : vo.getPositionNo() )+ ",设备位置为:" + (vo.getPositionName() == null ? "" : vo.getPositionName()) + "的设备:" + vo.getName() + "于" + log.getCreatedTime() + "被" + log.getCreatedUserName() + "停用";
+                String str = "设备位号为:" + (vo.getPositionNo() == null ? "" : vo.getPositionNo() )+ ",设备位置为:" + (vo.getPositionName() == null ? "" : vo.getPositionName()) + "的设备:"
+                        + vo.getName() + "于" + log.getCreatedTime() + "被" + log.getCreatedUserName() + "删除";
 
 //                stringBuffer.append("设备位号为:"+vo.getPositionNo()==null?"":vo.getPositionNo()+",设备位置为:"+vo.getPositionName()==null?"":vo.getPositionName()+"的设备:"+vo.getName()+"于"+log.getCreatedTime()+"被"+log.getCreatedUserName()+"删除");
                 log.setContent(str);
                 measureLogs.add(log);
             }
         }
-
         sbMeasureLogMapper.insertListforComplex(measureLogs);
         return new R<>();
     }
@@ -448,6 +450,21 @@ public class SbInfoController {
         ExcelUtil.exportResponseDict(response, ExportSbInfoVO.class, BeanConverterUtil.copyListProperties(list, ExportSbInfoVO.class), "设备基础信息");
     }
 
+
+    /**
+     * 设备基础信息导出
+     *
+     * @param sbInfoDTO 设备基础信息DTO
+     * @return R
+     */
+    @GetMapping("/export2")
+    @SysLog("仪表基础信息导出")
+    @PreAuthorize("@pms.hasPermission('sb-infos-export')")
+    public void export2(HttpServletResponse response, SbInfoDTO sbInfoDTO) {
+        List<SbInfoVO> list = sbInfoService.selectExportVOList(sbInfoDTO);
+        ExcelUtil.exportResponseDict(response, ExportYiBiaoSbInfoVO.class, BeanConverterUtil.copyListProperties(list, ExportYiBiaoSbInfoVO.class), "仪表基础信息");
+    }
+
     /**
      * 计量设备基础信息导出
      *
@@ -510,6 +527,22 @@ public class SbInfoController {
         return new R<>(result);
     }
 
+    @SysLog("新增导入设备")
+    @PostMapping("/import2")
+    public R importExcelByUpdate2(@RequestParam("type") Integer type, @RequestParam("file") MultipartFile file) throws Exception {
+        String result = "";
+        if(type == 1){
+            result = sbInfoService.importListByAdd(file);
+        }else if(type == 2){
+            result = sbInfoService.importYiBiaoListByUpdateALl(file);
+        }else if(type == 3){// 废弃
+            result = sbInfoService.importListByAddWithStandard(file);
+        } else if(type == 4){// 废弃
+            result = sbInfoService.updateImportUpdateForLongYan(file);
+        }
+        return new R<>(result);
+    }
+
     /**
      * 子设备数量
      *

+ 2 - 0
platform-service/src/main/java/com/platform/service/sb/SbInfoService.java

@@ -289,6 +289,8 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
     String importListByAdd(MultipartFile file);
     String importListByUpdateALl(MultipartFile file);
 
+    String importYiBiaoListByUpdateALl(MultipartFile file);
+
     /**
      * 选择已经到了预警期限内的设备列表
      *

+ 236 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -55,6 +55,7 @@ import com.platform.dao.util.compare.FieldComparedUtils;
 import com.platform.dao.vo.SysUserDeptVO;
 import com.platform.dao.vo.SysUserVO;
 import com.platform.dao.vo.export.sb.ExportSbInfoVO;
+import com.platform.dao.vo.export.sb.ExportYiBiaoSbInfoVO;
 import com.platform.dao.vo.query.sb.SbChangeRecordVO;
 import com.platform.dao.vo.query.upms.SysDeptVO;
 import com.platform.dao.vo.report.SbInfoTypeReportVO;
@@ -2841,6 +2842,241 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
         }
     }
 
+    @Override
+    public String importYiBiaoListByUpdateALl(MultipartFile file) {
+        List<FirmProducer> producerList = firmProducerMapper.selectAll(); // 生产厂商
+        List<SbPosition> positionList = sbPositionMapper.selectAll(); // 设备位置
+        List<SbType> typeList = sbTypeMapper.selectAll(); // 设备类型集合
+        List<SbInfo> addList = new ArrayList<>();  // 待导入集合
+        List<SysUser> users = sysUserMapper.selectAll(); // 用户集合
+        List<String> addTypeList = new ArrayList<>();
+        try {
+            List<ExportYiBiaoSbInfoVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportYiBiaoSbInfoVO.class, 1);
+            if (CollectionUtil.isNotEmpty(list)) {
+                int i = 2;
+                for (ExportYiBiaoSbInfoVO vo : list) {
+                    i++;
+                    // 如果有检定周期,就是需要检定
+                    SbInfo tempInfo = BeanConverterUtil.copyObjectProperties(vo, SbInfo.class);
+//                    if (vo.getSeatNumber() == null) {
+//                        tempInfo.setSeatNumber(30);// 如果为空默认30天提醒
+//                    }
+                    // 对必填字段进行判断
+                    if (StringUtils.isBlank(vo.getPositionNo())) {
+                        throw new BusinessException("第" + i + "行,位号为空,位号为必填项目,请填写;");// 编号为空,复制位号
+                    }
+//                    if (vo.getIsFinancing() == 1 && StringUtils.isBlank(vo.getFinancingNo())) {
+//                        throw new BusinessException("第" + i + "行,是固定资产,但是资产编号为空,请填写;");// 编号为空,复制位号
+//                    }
+                    if (StringUtils.isBlank(vo.getName())) {
+                        throw new BusinessException("第" + i + "行,名称为空,请填写;");// 编号为空,复制位号
+                    }
+                    if (StringUtils.isBlank(vo.getModel())) {
+                        throw new BusinessException("第" + i + "行,型号为空,请填写;");// 编号为空,复制位号
+                    }
+                    if (vo.getDph()!=null&&vo.getDph().trim()!=""){
+                        tempInfo.setDph(vo.getDph());
+                    }
+                    if (vo.getNo()!=null&&vo.getNo().trim()!=""){
+                        tempInfo.setNo(vo.getNo());
+                    }
+//                    if (vo.getLevel() == null || vo.getLevel() < 1 || vo.getLevel() > 3) {
+//                        throw new BusinessException("第" + i + "行,等级为空,A级请填1,B级填2,C级填3;");// 编号为空,复制位号
+//                    }
+//                    if (vo.getUseType() == null || vo.getUseType() < 3 || vo.getUseType() > 5) {
+//                        throw new BusinessException("第" + i + "行,自定义类型为空,生产设备请填3,计量设备填4,特种设备填5;");// 编号为空,复制位号
+//                    }
+
+//                    if (vo.getIdentifyNo()!=null&&vo.getIdentifyNo().trim()!=""){
+//                        tempInfo.setIdentifyNo(vo.getIdentifyNo());
+//                    }
+//
+//                    if (vo.getUseNo()!=null&&vo.getUseNo().trim()!=""){
+//                        tempInfo.setUseNo(vo.getUseNo());
+//                    }
+//
+//                    if (vo.getSbCode()!=null&&vo.getSbCode().trim()!=""){
+//                        tempInfo.setSbCode(vo.getSbCode());
+//                    }
+//
+//                    if (vo.getInstallUnit()!=null&&vo.getInstallUnit().trim()!=""){
+//                        tempInfo.setInstallUnit(vo.getInstallUnit());
+//                    }
+//
+//                    if (vo.getExamResult()!=null&&vo.getExamResult().trim()!=""){
+//                        tempInfo.setExamResult(vo.getExamResult());
+//                    }
+//
+//                    if (vo.getUsePosition()!=null&&vo.getUsePosition().trim()!=""){
+//                        tempInfo.setUsePosition(vo.getUsePosition());
+//                    }
+//
+//                    if (vo.getUseType() == 4) {
+//                        tempInfo.setIsChild(1);
+//                    } else {
+//                        tempInfo.setIsChild(0);
+//                    }
+//                    if (vo.getStatus() == null || (vo.getStatus() != 1 && vo.getStatus() != 2 && vo.getStatus() != 7)) {
+//                        throw new BusinessException("第" + i + "行,状态为空或者状态不对,在库请填1,使用中填2,停用中填7");// 编号为空,复制位号
+//                    }
+                    if (StringUtils.isBlank(vo.getCph())) {
+                        tempInfo.setCph(vo.getPositionNo());// 编号为空,复制位号
+                    }
+                    if (StringUtils.isBlank(vo.getPositionNo())) {
+                        tempInfo.setPositionNo(vo.getPositionNo());// 编号为空,复制位号
+                    }
+//                    if (StringUtils.isNotEmpty(vo.getPpNo())) {
+//                        tempInfo.setIsChild(1);
+//                    }
+//                    if (StringUtils.isNotEmpty(vo.getFinancingNo())) {
+//                        tempInfo.setIsFinancing(1);
+//                    }
+//                    if (vo.getCheckPeriod() != null) {
+//                        tempInfo.setIsMeasure(1);
+//                    }
+//                    if (vo.getCheckPeriod() != null) {
+//                        tempInfo.setIsMeasure(1);
+//                    }
+                    if (vo.getCheckType()!=null){
+                        if (vo.getCheckType() instanceof Integer&&(vo.getCheckType()==1||vo.getCheckType()==2)) {
+                            tempInfo.setCheckType(vo.getCheckType());
+                        }else {
+                            throw new BusinessException("第" + i + "行,检定是否强检填写有误,请检查!");
+                        }
+                    }
+                    if (tempInfo.getIsMeasure() != null && tempInfo.getIsMeasure() == 1) {
+                        if (tempInfo.getNextCheckDate() == null) {
+                            if (tempInfo.getCheckDate() != null) {
+                                if (tempInfo.getCheckPeriod() != null) {
+                                    tempInfo.setNextCheckDate(tempInfo.getCheckDate().plusMonths(tempInfo.getCheckPeriod()));
+                                } else {
+                                    throw new BusinessException("需要检定的设备,检定周期必填");
+                                }
+                            } else {
+                                throw new BusinessException("需要检定的设备,检定日期必填");
+                            }
+                        }
+
+                        // 如果是仪表组,则是自检
+                        if (StringUtils.isNotEmpty(vo.getDph()) && vo.getDph().equals("仪表组")) {
+                            tempInfo.setIsSelf(YesNoEnum.YES.getValue());
+                        } else {
+                            tempInfo.setIsSelf(YesNoEnum.NO.getValue());
+                        }
+                    }
+//                    if (StringUtils.isNotBlank(vo.getTypeName())) { // 设备类型匹配
+//                        boolean findSbType = false;
+//                        for (SbType sbType : typeList) {
+//                            if (sbType.getName().equalsIgnoreCase(vo.getTypeName().trim())) {
+//                                tempInfo.setTypeId(sbType.getId());
+//                                findSbType = true;
+//                                break;
+//                            }
+//                        }
+//                        if (!findSbType) {
+//                            addTypeList.add(vo.getTypeName());
+//                            // throw new BusinessException("系统找不到该设备类型名称,请先添加设备类型, 设备类型名称" + vo.getTypeName());
+//                        }
+//                    }
+                    if (StringUtils.isNotBlank(vo.getPositionName())) { // 设备位置匹配
+                        boolean findPosition = false;
+                        for (SbPosition position : positionList) {
+                            if (position.getName().equalsIgnoreCase(vo.getPositionName().trim())) {
+                                tempInfo.setPositionId(position.getId());
+                                findPosition = true;
+                                break;
+                            }
+                        }
+                        if (!findPosition) {
+                            throw new BusinessException("系统找不到位置名称,请先在基础配置中添加位置, 位置名称" + vo.getPositionName());
+                        }
+                    }
+                    // tempInfo.setProducerId(vo.getProducerName());
+                    /*if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
+                        boolean findProducer = false;
+                        for (FirmProducer producer : producerList) {
+                            if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
+                                tempInfo.setProducerId(producer.getId());
+                                findProducer = true;
+                                break;
+                            }
+                        }
+                        if (!findProducer) {
+                            throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
+                        }
+                    }*/
+                    /*if (StringUtils.isNotBlank(vo.getSaveUserName())) { // 使用人员
+                        boolean findSaveUser = false;
+                        for (SysUser user : users) {
+                            if (user.getRealName().equalsIgnoreCase(vo.getSaveUserName().trim())) {
+                                tempInfo.setSaveUser(user.getUserId());
+                                findSaveUser = true;
+                                break;
+                            }
+                        }
+                        if (!findSaveUser) {
+                            throw new BusinessException("找不到使用人员,请先添加, 名称" + vo.getSaveUserName());
+                        }
+                    }*/
+                    // 如果计量设备 且是需要检定
+//                    if (vo.getUseType() == SbUseType.BGCL.getValue() && vo.getIsMeasure() == YesNoEnum.YES.getValue()) {
+                    SbInfo info = new SbInfo();
+                    info.setId(vo.getId());
+                    if (vo.getId()==null){
+                        throw new BusinessException("第" + i + "行,id不可以为空!");
+                    }
+                    info = sbInfoMapper.selectOne(info);
+                        if (info.getCheckDate() == null && vo.getNextCheckDate() == null) {
+                            throw new BusinessException("上次和下次检定日期,不能全部为空");
+                        }
+//                        if (vo.getNextCheckDate()!=null){
+//                            tempInfo.setNextCheckDate(vo.getNextCheckDate());
+//                        }
+//                        if (vo.getCheckPeriod() == null) {
+//                            throw new BusinessException("检定周期不能为空");
+//                        }
+//                    }
+                    // tempInfo.setId(IdGeneratorUtils.getObjectId());
+                    // 检索自定义字段值
+//                    Class clazz = vo.getClass();
+//                    Field[] fields = clazz.getDeclaredFields();
+//                    StringBuilder paramList = new StringBuilder();
+//                    paramList.append("[");
+//                    for (Field field : fields) {
+//                        Method requestMethod = clazz.getMethod(getGetMethod(field.getName()));
+//                        Object requestVal = requestMethod.invoke(vo);
+//                        Excel excel = field.getAnnotation(Excel.class);
+//                        if (excel != null && excel.styleType() == 1 && requestVal != null) {
+//                            // 拼接自定义字符串
+//                            paramList.append("{\"name\":\"").append(excel.name()).append("\",");
+//                            paramList.append("\"content\":\"").append(requestVal).append("\"},");
+//                        }
+//                    }
+//                    String param = paramList.toString();
+//                    if (param.length() > 1) {
+//                        param = param.substring(0, param.length() - 1);
+//                    }
+//                    param += "]";
+//                    tempInfo.setParamList(param);
+                    tempInfo.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
+                    tempInfo.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
+                    tempInfo.setUpdateTime(LocalDateTime.now());
+                    addList.add(tempInfo);
+                    mapper.updateByPrimaryKeySelective(tempInfo);
+                }
+            }
+
+            if (CollectionUtil.isNotEmpty(addTypeList)) {
+                throw new BusinessException(addTypeList.size() + "个设备类型名称找不到,请先添加:" + addTypeList);
+            }
+
+            return "总计更新:" + (list.size());
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BusinessException(e.getMessage());
+        }
+    }
+
     @Override
     public MyVOPage<SbInfoVO> selectPageInfoForWarn(SbInfoDTO record, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);