Przeglądaj źródła

bugFix 增加安全附件导入功能

xiahan 1 rok temu
rodzic
commit
a106d0697b

+ 17 - 0
bs-common/src/main/java/com/rongwei/safecommon/utils/CXCommonUtils.java

@@ -33,6 +33,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDate;
 import java.util.*;
+import java.util.function.BooleanSupplier;
 import java.util.stream.Collectors;
 
 import static com.rongwei.safecommon.utils.SaveConstans.*;
@@ -349,4 +350,20 @@ public class CXCommonUtils {
         return commonFeginClient.upload(file, relationid);
     }
 
+    /**
+     * 参数校验
+     *
+     * @param booleanSupplier
+     * @param returnMsg
+     * @param errorMsg
+     * @param errorMsgParameter
+     */
+    public static void parameterCheck(BooleanSupplier booleanSupplier, String returnMsg, String errorMsg, Object... errorMsgParameter) {
+        if (booleanSupplier.getAsBoolean()) {
+            log.error(errorMsg, errorMsgParameter);
+            if (org.apache.commons.lang.StringUtils.isNotBlank(returnMsg)) {
+                throw new RuntimeException(returnMsg);
+            }
+        }
+    }
 }

+ 6 - 0
cx-safe-check/cx-save-check-common/pom.xml

@@ -31,6 +31,12 @@
             <artifactId>easyexcel</artifactId>
             <version>3.3.2</version>
         </dependency>
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-base</artifactId>
+            <version>4.4.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 14 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/dao/SaveCheckCommonDao.java

@@ -1,9 +1,13 @@
 package com.rongwei.sfcommon.sys.dao;
 
 
+import com.rongwe.scentity.vo.CheckAreaVo;
 import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
 import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 
@@ -30,4 +34,14 @@ public interface SaveCheckCommonDao {
                                                         @Param("tenantId") String tenantId);
 
     List<UserMailOrgVo> getUserInfoByTenantIdAndRoleCode(@Param("tenantId") String tenantId,@Param("roleCodes") List<String> roleCodes);
+
+    @Select("select * from sys_file_item where ID = #{id}")
+    SysFileItemDo getFileItemByID(@Param("id") String id);
+
+
+    List<CheckAreaVo> getCheckArea(@Param("tenantid")String tenantid);
+
+    List<SysOrganizationDo> getOrgByTenantId(@Param("tenantid")String tenantid);
+
+    List<SysUserDo> getUserInfoByTenantId(@Param("tenantid")String tenantid);
 }

+ 4 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/AspSafeAttachmentsService.java

@@ -4,9 +4,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwe.scentity.domian.AspSafeAttachmentsDo;
 import com.rongwei.rwcommon.base.R;
 
+import java.util.Map;
+
 /**
  *
  */
 public interface AspSafeAttachmentsService extends IService<AspSafeAttachmentsDo> {
   R stateUpdateScheduledTasks();
+
+  R importExcel(Map<String, String> queryParameter);
 }

+ 184 - 1
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspSafeAttachmentsServiceImpl.java

@@ -1,19 +1,34 @@
 package com.rongwei.sfcommon.sys.service.impl;
 
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.scentity.domian.AspSafeAttachmentsDo;
+import com.rongwe.scentity.vo.CheckAreaVo;
+import com.rongwe.scentity.vo.ImportAspSafeAttachmentsVo;
 import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import com.rongwei.safecommon.utils.CXCommonUtils;
 import com.rongwei.sfcommon.sys.dao.AspSafeAttachmentsDao;
 import com.rongwei.sfcommon.sys.dao.SaveCheckCommonDao;
 import com.rongwei.sfcommon.sys.service.AspSafeAttachmentsService;
+import com.rongwei.sfcommon.utils.ClassExcelVerifyHandler;
+import lombok.SneakyThrows;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.temporal.ChronoUnit;
@@ -42,10 +57,20 @@ public class AspSafeAttachmentsServiceImpl extends ServiceImpl<AspSafeAttachment
      * 特种设备管理员
      */
     public static final String SPECIAL_EQUIPMENT_ADMINISTRATOR = "role031";
+    public static final String EMPTY_ERROR_MSG = "第%s行 %s 为空";
+    public static final String DATE_FORMAT_ERROR_MSG = "第%s行 %s 时间格式不正确";
+    public static final List<SimpleDateFormat> DATE_FORMAT_LIST = new ArrayList<SimpleDateFormat>() {{
+        add(new SimpleDateFormat("yyyy-MM-dd"));
+        add(new SimpleDateFormat("yyyy/MM/dd"));
+        add(new SimpleDateFormat("yyyy.MM.dd"));
+        add(new SimpleDateFormat("yyyyMMdd"));
+    }};
 
     private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
     @Autowired
     private SaveCheckCommonDao saveCheckCommonDao;
+    @Autowired
+    private ClassExcelVerifyHandler verifyHandler;
 
     @Override
     public R stateUpdateScheduledTasks() {
@@ -92,6 +117,11 @@ public class AspSafeAttachmentsServiceImpl extends ServiceImpl<AspSafeAttachment
         return R.ok();
     }
 
+    /**
+     * 发送消息提醒
+     *
+     * @param sendNotifyMap
+     */
     public void sendNotify(Map<AspSafeAttachmentsDo, List<String>> sendNotifyMap) {
         sendNotifyMap.forEach((k, v) -> {
             // 发送消息提醒
@@ -101,6 +131,159 @@ public class AspSafeAttachmentsServiceImpl extends ServiceImpl<AspSafeAttachment
                     k.getId(), SAFETY_ATTACHMENT_VERIFICATION, false);
         });
     }
+
+    /**
+     * 导入excel
+     *
+     * @param queryParameter
+     * @return
+     */
+    @SneakyThrows
+    @Override
+    public R importExcel(Map<String, String> queryParameter) {
+        String fileId = queryParameter.getOrDefault("fileId", "");
+        CXCommonUtils.parameterCheck(() -> StringUtils.isBlank(fileId), "请上传文件", "文件ID为空");
+        SysFileItemDo fileItemDo = saveCheckCommonDao.getFileItemByID(fileId);
+        CXCommonUtils.parameterCheck(() -> fileItemDo == null, "文件解析有误!请联系管理员", "无法根据文件ID:{},获取到文件信息", fileId);
+        String realPath = fileItemDo.getFullpath();
+        CXCommonUtils.parameterCheck(() -> StringUtils.isBlank(realPath), "文件解析有误!请联系管理员", "根据文件ID:{},无法获取到文件路径", fileId);
+        File file = new File(realPath);
+        CXCommonUtils.parameterCheck(() -> !file.exists(), "文件解析有误!请联系管理员", "根据文件地址:{},无法获取文件", realPath);
+        ImportParams params = new ImportParams();
+        params.setTitleRows(0);
+        params.setHeadRows(1);
+        params.setVerifyHandler(verifyHandler);
+        List<ImportAspSafeAttachmentsVo> userList = ExcelImportUtil.importExcel(file, ImportAspSafeAttachmentsVo.class, params);
+        log.info("userList:{}",userList);
+        // 存放异常数据
+        List<String> errorMsgList = new ArrayList<>();
+        // 解析后的数据
+        List<AspSafeAttachmentsDo> saveList = new ArrayList<>();
+        ImportAspSafeAttachmentsVo importAspSafeAttachmentsVo;
+        SysUserVo currentUser = CXCommonUtils.getCurrentUser();
+        String tenantId = currentUser.getOrganizationDoList().get(0).getFullpid().split(",")[1];
+        //获取区域信息
+        Map<String, String> checkAreaMap = saveCheckCommonDao.getCheckArea(tenantId).stream().collect(Collectors.toMap(CheckAreaVo::getName, CheckAreaVo::getId, (v1, v2) -> v1));
+        // 获取组织机构信息
+        Map<String, String> orgMap = saveCheckCommonDao.getOrgByTenantId(tenantId).stream().collect(Collectors.toMap(SysOrganizationDo::getFullname, SysOrganizationDo::getId, (v1, v2) -> v1));
+        // 用户信息
+        Map<String, String> userMap = saveCheckCommonDao.getUserInfoByTenantId(tenantId).stream().collect(Collectors.toMap(SysUserDo::getName, SysUserDo::getId, (v1, v2) -> v1));
+
+        for (int i = 0; i < userList.size(); i++) {
+            importAspSafeAttachmentsVo = userList.get(i);
+            // 数据格式校验
+            checkDataAccuracy(i + 1, importAspSafeAttachmentsVo, errorMsgList);
+
+            if (StringUtils.isNotBlank(importAspSafeAttachmentsVo.getTreeName()) && !checkAreaMap.containsKey(importAspSafeAttachmentsVo.getTreeName())) {
+                errorMsgList.add("第" + (i + 1) + "行树表名称不存在");
+            }
+            if (errorMsgList.isEmpty()) {
+                saveList.add(voToDo(importAspSafeAttachmentsVo, checkAreaMap, orgMap, userMap, tenantId));
+            }
+        }
+        if (!errorMsgList.isEmpty()) {
+            log.error("excel数据异常:{}", errorMsgList);
+            throw new CustomException(StringUtils.join(errorMsgList, ";"));
+        }
+        if (!saveList.isEmpty()) {
+            this.saveBatch(saveList, 100);
+        }
+
+        return R.ok();
+    }
+
+    private void checkDataAccuracy(int index, ImportAspSafeAttachmentsVo importAspSafeAttachmentsVo, List<String> errorMsgList) {
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getTreeName())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "左侧树表"));
+        }
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getAttachmenttype())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "附件类型"));
+        }
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getName())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "名称"));
+        }
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getInspectionstr())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "检验/更换日期"));
+        }
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getNextinspectionstr())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "下次检验/更换日期"));
+        }
+        if (StringUtils.isBlank(importAspSafeAttachmentsVo.getCertificatenumber())) {
+            errorMsgList.add(String.format(EMPTY_ERROR_MSG, index, "证书/报告编号"));
+        }
+        // 校验时间格式是否正确
+        if (StringUtils.isNotBlank(importAspSafeAttachmentsVo.getManufacturestr()) && dateFormatValidation(importAspSafeAttachmentsVo.getManufacturestr()) == null) {
+            errorMsgList.add(String.format(DATE_FORMAT_ERROR_MSG, index, "出厂日期"));
+        }
+        // 校验时间格式是否正确
+        if (StringUtils.isNotBlank(importAspSafeAttachmentsVo.getNextinspectionstr()) && dateFormatValidation(importAspSafeAttachmentsVo.getNextinspectionstr()) == null) {
+            errorMsgList.add(String.format(DATE_FORMAT_ERROR_MSG, index, "下次检验/更换日期"));
+        }
+        // 校验时间格式是否正确
+        if (StringUtils.isNotBlank(importAspSafeAttachmentsVo.getInspectionstr()) &&  dateFormatValidation(importAspSafeAttachmentsVo.getInspectionstr()) == null) {
+            errorMsgList.add(String.format(DATE_FORMAT_ERROR_MSG, index, "检验/更换日期"));
+        }
+    }
+
+    private Date dateFormatValidation(String strDate) {
+        Date date = null;
+        for (SimpleDateFormat simpleDateFormat : DATE_FORMAT_LIST) {
+            try {
+                date = simpleDateFormat.parse(strDate);
+                break;
+            } catch (Exception e) {
+                log.info("时间格式不正确");
+            }
+        }
+        return date;
+    }
+
+    /**
+     * vo 转 do
+     *
+     * @param checkArea
+     * @param vo
+     * @return
+     */
+    private AspSafeAttachmentsDo voToDo(ImportAspSafeAttachmentsVo vo,
+                                        Map<String, String> checkAreaMap,
+                                        Map<String, String> orgMap,
+                                        Map<String, String> userMap,
+                                        String tenantId) {
+        AspSafeAttachmentsDo aspSafeAttachmentsDo = new AspSafeAttachmentsDo();
+        BeanUtils.copyProperties(vo, aspSafeAttachmentsDo);
+        aspSafeAttachmentsDo.setId(SecurityUtil.getUUID());
+        aspSafeAttachmentsDo.setTenantid(tenantId);
+        aspSafeAttachmentsDo.setCreatedate(new Date());
+        aspSafeAttachmentsDo.setMainid(checkAreaMap.get(vo.getTreeName()));
+        aspSafeAttachmentsDo.setUseshopid(orgMap.get(vo.getUseshop()));
+        // 时间转换
+        if (StringUtils.isBlank(vo.getManufacturestr())) {
+            aspSafeAttachmentsDo.setManufacturedate(dateFormatValidation(vo.getManufacturestr()));
+        }
+
+        aspSafeAttachmentsDo.setInspectiondate(dateFormatValidation(vo.getInspectionstr()));
+        aspSafeAttachmentsDo.setNextinspectiondate(dateFormatValidation(vo.getNextinspectionstr()));
+        if (StringUtils.isNotBlank(vo.getResponsible())) {
+            String ids = Arrays.stream(vo.getResponsible().split(",")).map(username -> userMap.get(username)).collect(Collectors.joining(",0"));
+            // 设置责任人ID
+            aspSafeAttachmentsDo.setResponsibleid(ids);
+        }
+
+        LocalDate date1 = aspSafeAttachmentsDo.getNextinspectiondate().toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+        long daysBetween = ChronoUnit.DAYS.between(LocalDate.now(), date1);
+        if (daysBetween <= 30) {
+            aspSafeAttachmentsDo.setReminderstate(HIGH);
+        } else if (daysBetween <= 90) {
+            aspSafeAttachmentsDo.setReminderstate(MIDDLE);
+        } else {
+            aspSafeAttachmentsDo.setReminderstate(LOW);
+        }
+        return aspSafeAttachmentsDo;
+    }
+
 }
 
 

+ 10 - 4
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/sys/service/impl/AspSpecialEquipmentCertificateServiceImpl.java

@@ -3,6 +3,8 @@ package com.rongwei.sfcommon.sys.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwe.scentity.domian.AspSpecialEquipmentCertificateDo;
 import com.rongwe.scentity.vo.UserMailOrgVo;
+import com.rongwei.rwadmincommon.system.domain.SysDictDo;
+import com.rongwei.rwadmincommon.system.service.SysDictService;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.safecommon.utils.CXCommonUtils;
 import com.rongwei.sfcommon.sys.dao.AspSpecialEquipmentCertificateDao;
@@ -11,7 +13,6 @@ import com.rongwei.sfcommon.sys.service.AspSpecialEquipmentCertificateService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
@@ -22,9 +23,7 @@ import java.util.stream.Collectors;
 
 import static com.rongwei.safecommon.utils.SaveConstans.*;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.PERSONNEL_CERTIFICATES_CONTENT;
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.SAFETY_ATTACHMENT_VERIFICATION_CONTENT;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.PERSONNEL_CERTIFICATES_TITLE;
-import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.SAFETY_ATTACHMENT_VERIFICATION_TITLE;
 import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.PERSONNEL_CERTIFICATES;
 
 /**
@@ -48,6 +47,8 @@ public class AspSpecialEquipmentCertificateServiceImpl extends ServiceImpl<AspSp
     private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
     @Autowired
     private SaveCheckCommonDao saveCheckCommonDao;
+    @Autowired
+    private SysDictService sysDictService;
 
     @Override
     public R stateUpdateScheduledTasks() {
@@ -95,10 +96,15 @@ public class AspSpecialEquipmentCertificateServiceImpl extends ServiceImpl<AspSp
 
 
     public void sendNotify(Map<AspSpecialEquipmentCertificateDo, List<String>> sendNotifyMap) {
+        // 获取数据字典
+        List<SysDictDo> aspCheckItemType = sysDictService.getDictsByType("asp_check_item_type");
         sendNotifyMap.forEach((k, v) -> {
+            SysDictDo sysDictDo = aspCheckItemType.stream()
+                    .filter(info -> info.getValue().equals(k.getCertificatesort()))
+                    .findFirst().orElse(null);
             // 发送消息提醒
             CXCommonUtils.sendNotify(PERSONNEL_CERTIFICATES_TITLE,
-                    String.format(PERSONNEL_CERTIFICATES_CONTENT, k.getName(), k.getOrgname(), k.getCertificatesort(),
+                    String.format(PERSONNEL_CERTIFICATES_CONTENT, k.getName(), k.getOrgname(), sysDictDo == null ? "" : sysDictDo.getName(),
                             k.getReviewdate()), null, v.stream().distinct().collect(Collectors.toList()),
                     k.getId(), PERSONNEL_CERTIFICATES, false);
         });

+ 58 - 0
cx-safe-check/cx-save-check-common/src/main/java/com/rongwei/sfcommon/utils/ClassExcelVerifyHandler.java

@@ -0,0 +1,58 @@
+package com.rongwei.sfcommon.utils;
+
+import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
+import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
+import cn.hutool.core.util.ObjectUtil;
+import lombok.SneakyThrows;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Field;
+
+/**
+ * ClassExcelVerifyHandler class
+ *
+ * @author XH
+ * @date 2024/06/19
+ */
+@Component
+public class ClassExcelVerifyHandler implements IExcelVerifyHandler<Object> {
+    @SneakyThrows
+    @Override
+    public ExcelVerifyHandlerResult verifyHandler(Object obj) {
+        ExcelVerifyHandlerResult result=new ExcelVerifyHandlerResult(true);
+        if (ObjectUtil.isNotNull(obj)){
+            //判断对象属性是否全部为空
+            boolean b = areAllFieldsNull(obj);
+            result.setSuccess(!b);
+        }
+        return result;
+    }
+
+    private  boolean areAllFieldsNull(Object obj) {
+        if (obj == null) {
+            // 如果对象是null,我们返回true(尽管这可能不是你所期望的)
+            // 或者你可以抛出一个异常,取决于你的用例
+            return true;
+        }
+
+        Class<?> clazz = obj.getClass();
+        Field[] fields = clazz.getDeclaredFields();
+
+        for (Field field : fields) {
+            field.setAccessible(true); // 允许访问私有字段
+            try {
+                if (field.get(obj) != null) {
+                    // 如果找到任何非null的字段,返回false
+                    return false;
+                }
+            } catch (IllegalAccessException e) {
+                // 这通常不会发生,因为我们已经设置了setAccessible(true)
+                // 但为了完整性,我们还是捕获了这个异常
+                throw new RuntimeException(e);
+            }
+        }
+        // 如果没有找到任何非null的字段,返回true
+        return true;
+    }
+}

+ 31 - 1
cx-safe-check/cx-save-check-common/src/main/resources/mybatis/SaveCheckCommonDao.xml

@@ -110,11 +110,41 @@
         LEFT JOIN sys_organization so on suo.ORGID=so.ID and so.DELETED='0'
         <where>
             su.DELETED='0'
-            AND FIND_IN_SET(#{tenantId},so.FULLPID)
+            AND (FIND_IN_SET(#{tenantId},so.FULLPID) or so.ID=#{tenantId})
             AND sr.CODE in
             <foreach collection="roleCodes" item="code" open="(" close=")" separator=",">
                 #{code}
             </foreach>
         </where>
     </select>
+    <select id="getCheckArea" resultType="com.rongwe.scentity.vo.CheckAreaVo">
+        SELECT
+            acia.AREANAME,
+            acia.ID as id,
+            IFNULL(CONCAT(GROUP_CONCAT(b.AREANAME separator '\\'),'\\',acia.AREANAME),acia.AREANAME) as name
+        FROM
+            asp_check_items_area acia
+                LEFT JOIN asp_check_items_area  b ON  FIND_IN_SET(b.ID,acia.FULLPID) and b.DELETED='0'
+        WHERE
+            acia.DELETED = '0'
+            <bind name="pid" value="'%' + tenantid+ '%'" />
+          and (acia.ID=#{tenantid} OR  acia.FULLPID like #{pid})
+        group by  acia.ID
+    </select>
+    <select id="getOrgByTenantId" resultType="com.rongwei.rwadmincommon.system.domain.SysOrganizationDo">
+        <bind name="pid" value="'%' + tenantid+ '%'" />
+        select ID ,FULLNAME from sys_organization where DELETED='0' and (ID=#{tenantid} OR  FULLPID like #{pid})
+    </select>
+    <select id="getUserInfoByTenantId" resultType="com.rongwei.rwadmincommon.system.domain.SysUserDo">
+        select
+        su.ID as id,
+        su.NAME as name
+        from sys_user su
+        lEFT JOIN sys_user_org suo on suo.USERID = su.ID and suo.DELETED = '0'
+        LEFT JOIN sys_organization so on suo.ORGID=so.ID and so.DELETED='0'
+        <where>
+            su.DELETED='0'
+            AND (FIND_IN_SET(#{tenantid},so.FULLPID) or so.ID=#{tenantid})
+        </where>
+    </select>
 </mapper>

+ 6 - 0
cx-safe-check/cx-save-check-entity/pom.xml

@@ -29,5 +29,11 @@
             <artifactId>rw-admin-common</artifactId>
             <version>1.1-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-annotation</artifactId>
+            <version>4.4.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 15 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/CheckAreaVo.java

@@ -0,0 +1,15 @@
+package com.rongwe.scentity.vo;
+
+import lombok.Data;
+
+/**
+ * CheckAreaVo class
+ *
+ * @author XH
+ * @date 2024/06/19
+ */
+@Data
+public class CheckAreaVo {
+    private String name;
+    private String id;
+}

+ 161 - 0
cx-safe-check/cx-save-check-entity/src/main/java/com/rongwe/scentity/vo/ImportAspSafeAttachmentsVo.java

@@ -0,0 +1,161 @@
+package com.rongwe.scentity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * ImportAspSafeAttachmentsVo class
+ *
+ * @author XH
+ * @date 2024/06/19
+ */
+@Data
+public class ImportAspSafeAttachmentsVo  implements Serializable {
+    /**
+     * 树名称
+     */
+    @Excel(name = "左侧树表", orderNum = "0")
+    private String treeName;
+    /**
+     * 附件类型
+     */
+    @Excel(name = "安全附件类型", orderNum = "1")
+    private String attachmenttype;
+    /**
+     * 名称
+     */
+    @Excel(name = "名称", orderNum = "2")
+    private String name;
+    /**
+     * 型号
+     */
+    @Excel(name = "型号", orderNum = "3")
+    private String model;
+    /**
+     * 编号
+     */
+    @Excel(name = "编号", orderNum = "4")
+    private String number;
+    /**
+     * 制造厂
+     */
+    @Excel(name = "制造厂", orderNum = "5")
+    private String manufacturer;
+    /**
+     * 出厂日期
+     */
+    @Excel(name = "出厂日期", orderNum = "6")
+    private String manufacturestr;
+    /**
+     * 检测周期
+     */
+    @Excel(name = "检测周期", orderNum = "7")
+    private String detectionperiod;
+    /**
+     * 检测类型
+     */
+    @Excel(name = "检测类型", orderNum = "8")
+    private String detectiontype;
+    /**
+     * 检测单位
+     */
+    @Excel(name = "检测单位", orderNum = "9")
+    private String testingcompany;
+    /**
+     * 检测/更换日期
+     */
+    @Excel(name = "检验/更换日期", orderNum = "10")
+    private String inspectionstr;
+    /**
+     * 下次检测/更换日期
+     */
+    @Excel(name = "下次检验/更换日期", orderNum = "11")
+    private String nextinspectionstr;
+    /**
+     * 等级
+     */
+    @Excel(name = "等级", orderNum = "12")
+    private String grade;
+    /**
+     * 证书编号
+     */
+    @Excel(name = "证书/报告编号", orderNum = "13")
+    private String certificatenumber;
+    /**
+     * 责任人
+     */
+    @Excel(name = "责任人", orderNum = "14")
+    private String responsible;
+    /**
+     * 数量
+     */
+    @Excel(name = "数量", orderNum = "15")
+    private String quantity;
+    /**
+     * 防雷类型
+     */
+    @Excel(name = "防雷类型", orderNum = "16")
+    private String antilightingtype;
+    /**
+     * 位置编号
+     */
+    @Excel(name = "位置编号", orderNum = "17")
+    private String positionnumber;
+    /**
+     * 使用车间
+     */
+    @Excel(name = "使用车间", orderNum = "18")
+    private String useshop;
+    /**
+     * 使用地点
+     */
+    @Excel(name = "使用地点", orderNum = "19")
+    private String useplace;
+    /**
+     * 安装地点
+     */
+    @Excel(name = "具体安装地点", orderNum = "20")
+    private String installplace;
+    /**
+     * 安装部位
+     */
+    @Excel(name = "安装部位", orderNum = "21")
+    private String installsite;
+    /**
+     * 最大误差
+     */
+    @Excel(name = "最大允许误差", orderNum = "22")
+    private String maximumerror;
+    /**
+     * 测量范围
+     */
+    @Excel(name = "测量范围", orderNum = "23")
+    private String measuringrange;
+    /**
+     * 拾包公司名称
+     */
+    @Excel(name = "拾包公司名称", orderNum = "24")
+    private String pickupcompany;
+
+    /**
+     * 检测气体
+     */
+    @Excel(name = "检测气体", orderNum = "25")
+    private String tracergas;
+    /**
+     * 环境温度
+     */
+    @Excel(name = "环境温度", orderNum = "26")
+    private String ambienttemperature;
+    /**
+     * 工作电压
+     */
+    @Excel(name = "工作电压", orderNum = "27")
+    private String workingvoltage;
+
+    @Excel(name = "备注", orderNum = "28")
+    private String remark;
+
+}

+ 9 - 0
cx-safe-check/cx-save-check-server/src/main/java/com/rongwei/savecheck/controller/AspSafeAttachmentsController.java

@@ -8,9 +8,12 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 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 java.util.Map;
+
 /**
  * AspSafeAttachmentsController class
  *
@@ -31,4 +34,10 @@ public class AspSafeAttachmentsController {
         log.info("安全附件定时任务,更改安全附件预警级别");
         return aspSafeAttachmentsService.stateUpdateScheduledTasks();
     }
+
+    @PostMapping("/import")
+    public R importExport(@RequestBody Map<String, String> queryParameter){
+        log.info("开始导入安全附件信息");
+        return  aspSafeAttachmentsService.importExcel(queryParameter);
+    }
 }