Jelajahi Sumber

dmp-rwd增加arthas-boot.jar包.用于排查线上容器里的问题

lijie 3 tahun lalu
induk
melakukan
ade2755f36

+ 62 - 0
dmp-rwd/pom.xml

@@ -21,11 +21,31 @@
             <groupId>com.persagy</groupId>
             <artifactId>dmp-common</artifactId>
             <version>4.0.0</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi-ooxml</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.persagy</groupId>
             <artifactId>dmp-rwd-funcid-parser</artifactId>
             <version>4.0.0</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.poi</groupId>
+                    <artifactId>poi-ooxml</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -57,8 +77,33 @@
             <version>1.1.22</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-lite</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+        <dependency>
             <groupId>com.querydsl</groupId>
             <artifactId>querydsl-apt</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>javassist</artifactId>
+                    <groupId>org.javassist</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
             <!--<exclusions>
                 <exclusion>
                     <artifactId>guava</artifactId>
@@ -107,6 +152,16 @@
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>bcpkix-jdk15on</artifactId>
+                    <groupId>org.bouncycastle</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+            </exclusions>
             <!--<exclusions>
                 <exclusion>
                     <artifactId>guava</artifactId>
@@ -129,6 +184,12 @@
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-openfeign</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>HdrHistogram</artifactId>
+                    <groupId>org.hdrhistogram</groupId>
+                </exclusion>
+            </exclusions>
             <!--<exclusions>
                 <exclusion>
                     <artifactId>HdrHistogram</artifactId>
@@ -195,6 +256,7 @@
                                     <directory>src/main/resources/</directory>
                                     <includes>
                                         <include>**/*.yml</include>
+                                        <include>**/arthas-boot.jar</include>
                                     </includes>
                                 </resource>
                             </resources>

+ 51 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/constants/CommonConstant.java

@@ -0,0 +1,51 @@
+package com.persagy.dmp.rwd.constants;
+/***
+ * Description: 通用常量类
+ * @author : lijie
+ * @date :2021/4/27 17:13
+ * Update By lijie 2021/4/27 17:13
+ */
+public class CommonConstant {
+    /**uploadFlag,响应头的key:1-成功,0-失败*/
+    //public static final String UPLOAD_FLAG = "uploadFlag";
+    public static final String UPLOAD_FLAG = "successFlag";
+    /**Excel文件的文件后缀*/
+    public static final String EXCEL_SUFFIX = "xlsm";
+    /**响应头:Access-Control-Expose-Headers*/
+    public static final String REPONSE_HEAD_ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers";
+    /**响应头:Content-disposition*/
+    public static final String REPONSE_HEAD_CONTENT_DISPOSITION = "Content-disposition";
+    /**响应头:Content-Type*/
+    public static final String REPONSE_HEAD_CONTENT_TYPE = "Content-Type";
+    /**响应头:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet*/
+    public static final String REPONSE_HEAD_CONTENT_TYPE_SHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+    /**响应头:attachment;filename=*/
+    public static final String REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT = "attachment;filename=";
+    /**系统类型-windows*/
+    public static final String SYSTEM_TYPE_WINDOWS = "windows";
+    /**系统类型-linux/unix*/
+    public static final String SYSTEM_TYPE_LINUX = "linux/unix";
+    /**系统类型-mac*/
+    public static final String SYSTEM_TYPE_MAC = "mac";
+    /**自定义请求头-os-type*/
+    public static final String OS_TYPE = "os-type";
+    /**手机号的正则表达式*/
+    public static final String PHONE_NUM_REGEX = "^$|^[0-9-]{11,13}$";
+    /**邮箱的正则表达式*/
+    public static final String MAIL_REGEX = "^.+@.+(\\..+)+$";
+    /**内容仅包含的正则表达式*/
+    public static final String CONTENT_ILLEGAL_REGEX = "^[0-9A-Za-z]{1,}$";
+    /**内容长度为20的限制*/
+    public static final String CONTENT_LENGTH_20_REGEX = "^$|^.{0,20}$";
+    /**内容长度为50的限制*/
+    public static final String CONTENT_LENGTH_50_REGEX = "^$|^.{0,50}$";
+    /**内容长度为50的限制*/
+    public static final String CONTENT_CHINA_AND_ENGLISH_REGEX = "^[a-zA-Z\u4e00-\u9fa5]{1,20}$";
+    /**生日的正则表达式*/
+    public static final String BIRTHDAY_REGEX = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
+    /**成功标记,1-成功*/
+    public static final String SUCCESS_FLAG_ONE="1";
+    /**成功标记,0-失败*/
+    public static final String SUCCESS_FLAG_ZERO="0";
+
+}

+ 45 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/controller/BatchHandleObjectController.java

@@ -0,0 +1,45 @@
+package com.persagy.dmp.rwd.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.persagy.common.criteria.JacksonCriteria;
+import com.persagy.common.web.PagedResponse;
+import com.persagy.dmp.config.DmpParameterStorage;
+import com.persagy.dmp.rwd.config.RwdConstants;
+import com.persagy.dmp.rwd.handler.BusinessException;
+import com.persagy.dmp.rwd.handler.ResponseCode;
+import com.persagy.dmp.rwd.model.RelationInstanceModel;
+import com.persagy.dmp.rwd.service.BatchHandleObjectService;
+import lombok.RequiredArgsConstructor;
+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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@RestController
+@RequestMapping("/rwd/instance/object/")
+@RequiredArgsConstructor
+public class BatchHandleObjectController {
+
+    private final BatchHandleObjectService batchHandleObjectService;
+    /***
+     * Description: 下载模板接口
+     * @param response : 响应对象
+     * @return : void  
+     * @author : lijie
+     * @date :2021/9/22 9:54
+     * Update By lijie 2021/9/22 9:54
+     */
+    @PostMapping("downloadObjectTemplateFile")
+    public void query(HttpServletResponse response) throws IOException {
+        String groupCode = DmpParameterStorage.getGroupCode();
+        if (StrUtil.isBlank(groupCode)) {
+            throw new BusinessException(ResponseCode.A0402.getCode(),"缺少集团编码");
+        }
+        batchHandleObjectService.downloadObjectTemplateFile(response,groupCode);
+    }
+
+}

+ 109 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/handler/BusinessException.java

@@ -0,0 +1,109 @@
+package com.persagy.dmp.rwd.handler;
+
+
+/**
+ * @description 
+ * @author zhangqiankun
+ * @since 2020年8月26日:	下午5:17:08
+ */
+public class BusinessException extends RuntimeException {
+	private static final long serialVersionUID = -3325873096967595156L;
+
+	/** 异常编码 */
+	private String errorCode;
+    /** 异常描述 */
+    private String errorDesc;
+    /** 响应content中的数据,可加可不加 */
+    private Object respJson;
+
+    public BusinessException() {
+        super();
+    }
+
+    public BusinessException(Throwable e) {
+        super(e);
+    }
+
+    public BusinessException(String message, Throwable e) {
+        super(message, e);
+    }
+
+    /**
+     * @param errorDesc
+     */
+    public BusinessException(String errorDesc) {
+    	super(errorDesc);
+        this.errorCode = ResponseCode.B0001.getCode();
+        this.errorDesc = errorDesc;
+    }
+    
+    /**
+     * 业务异常错误码和错误描述构造器
+     *
+     * @param errorCode
+     * @param errorDesc
+     */
+    public BusinessException(String errorCode, String errorDesc) {
+    	super(errorDesc);
+        this.errorCode = errorCode;
+        this.errorDesc = errorDesc;
+    }
+    
+    public BusinessException(String errorCode, String errorDesc, Object respJson) {
+    	super(errorDesc);
+        this.errorCode = errorCode;
+        this.errorDesc = errorDesc;
+        this.respJson = respJson;
+    }
+
+    /**
+     * 业务异常信息、错误码和错误描述构造器
+     *
+     * @param message 后台日志看
+     * @param errorCode 错误码
+     * @param errorDesc	给前端看
+     */
+    public BusinessException(String message, String errorCode, String errorDesc, Object respJson) {
+        super(message);
+        this.errorCode = errorCode;
+        this.errorDesc = errorDesc;
+        this.respJson = respJson;
+    }
+
+    public BusinessException(Throwable cause, String errorCode, String errorDesc) {
+        super(cause);
+        this.errorCode = errorCode;
+        this.errorDesc = errorDesc;
+    }
+
+    public BusinessException(String message, Throwable cause, String errorCode, String errorDesc) {
+        super(message, cause);
+        this.errorCode = errorCode;
+        this.errorDesc = errorDesc;
+    }
+
+    public String getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(String errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public String getErrorDesc() {
+        return errorDesc;
+    }
+
+    public void setErrorDesc(String errorDesc) {
+        this.errorDesc = errorDesc;
+    }
+
+	public Object getRespJson() {
+		return respJson;
+	}
+
+	public void setRespJson(Object respJson) {
+		this.respJson = respJson;
+	}
+    
+}

+ 71 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/handler/ResponseCode.java

@@ -0,0 +1,71 @@
+package com.persagy.dmp.rwd.handler;
+
+/**
+ * @description 
+ * @author zhangqiankun
+ * @since 2020年8月26日:	下午5:17:08
+ */
+public enum ResponseCode {
+    /** 通用返回值 */
+	A00000("00000", "success"),
+    A10000("10000", "failure"),
+    A0001("A0001", "用户端错误"),
+    A0100("A0100", "用户注册错误"),
+    A0135("A0135", "Method Not Allowed"),
+    A0136("A0136", "Unsupported Media Type"),
+    A0137("A0137", "Not Acceptable"),
+    A0151("A0151", "手机格式校验失败"),
+	A0152("A0152", "地址格式校验失败"),
+	A0153("A0153", "邮箱格式校验失败"),
+    A0154("A0154", "账号名称重复"),
+    A0155("A0155", "员工编号重复"),
+    A0156("A0156", "手机号重复"),
+    A0157("A0157", "邮箱重复"),
+    A0201("A0201", "用户账户不存在"),
+    A0202("A0202", "用户账户被冻结"),
+    A0203("A0203", "用户账户已作废"),
+    A0210("A0210", "用户名/密码错误"),
+	A0220("A0220", "用户身份校验失败"),
+	A0301("A0301", "访问未授权"),
+	A0302("A0302", "正在授权中"),
+	A0303("A0303", "拒绝授权申请"),
+	A0311("A0311", "授权已过期"),
+	A0324("A0324", "网关访问受限"),
+	A0340("A0340", "签名异常"),
+	A0400("A0400", "用户请求参数错误"),
+	A0402("A0402", "无效的用户输入"),
+	A0422("A0422", "地址不在服务范围"),
+	A0427("A0427", "请求JSON 解析失败"),
+    B0001("B0001", "系统执行出错"),
+    B0300("B0300", "系统资源异常"),
+    C0001("C0001", "调用第三方服务出错"),
+    C0100("C0100", "中间件服务出错"),
+    C0110("C0110", "RPC服务出错"),
+    C0134("C0134", "不支持的数据格式"),
+    C0320("C0320", "数据不存在"),
+    C0341("C0341", "主键冲突"),
+	Z9999("Z9999", "系统繁忙");
+	
+    private String code;
+    
+    private String desc;
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    private ResponseCode(String code, String desc) {
+        this.desc = desc;
+        this.code = code;
+    }
+
+    @Override
+    public String toString() {
+        return this.code + "_" + this.desc;
+    }
+
+}

+ 25 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/service/BatchHandleObjectService.java

@@ -0,0 +1,25 @@
+package com.persagy.dmp.rwd.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/***
+ * Description: 对象的上传下载逻辑处理类
+ * @author : lijie
+ * @date :2021/9/22 9:55
+ * Update By lijie 2021/9/22 9:55
+ */
+public interface BatchHandleObjectService {
+
+    /***
+     * Description: 下载模板接口
+     * @param response : 响应对象
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 9:54
+     * Update By lijie 2021/9/22 9:54
+     */
+    void downloadObjectTemplateFile(HttpServletResponse response,String groupCode) throws IOException;
+
+}

+ 98 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/service/DownloadService.java

@@ -0,0 +1,98 @@
+package com.persagy.dmp.rwd.service;
+
+import com.persagy.dmp.rwd.constants.CommonConstant;
+import com.persagy.dmp.rwd.util.FileUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.springframework.core.io.Resource;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+
+/***
+ * Description: 下载Excel的公共逻辑抽象类
+ * @author : lijie
+ * @date :2021/4/28 17:22
+ * Update By lijie 2021/4/28 17:22
+ */
+@Slf4j
+public abstract class DownloadService {
+
+    private static final String CONFIG_PATH_PREFIX="file:./config";
+    private static final String CLASS_PATH_PREFIX="classpath:.";
+
+    /***
+     * Description: 公共下载方法的壳子
+     * @return : void
+     * @author : lijie
+     * @date :2021/4/28 16:55
+     * Update By lijie 2021/4/28 16:55
+     */
+    public void downloadFile() throws IOException {
+        String filePath = getFilePath();
+        Resource[] resolverResources = FileUtil.getResource(CONFIG_PATH_PREFIX+filePath, CLASS_PATH_PREFIX+filePath);
+        if (resolverResources.length<=0){
+            return;
+        }
+        Resource resolverResource = resolverResources[0];
+        String filename = resolverResource.getFilename();
+        InputStream inputStream = resolverResource.getInputStream();
+        Workbook workbook = null;
+        HttpServletResponse response = getHttpServletResponse();
+        try {
+            workbook = WorkbookFactory.create(inputStream);
+            handleWorkbook(workbook);
+            // 为文件命名
+            response.setHeader(CommonConstant.REPONSE_HEAD_CONTENT_DISPOSITION,
+                    CommonConstant.REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT + URLEncoder.encode(filename, "UTF-8"));
+            response.addHeader(CommonConstant.REPONSE_HEAD_CONTENT_TYPE, CommonConstant.REPONSE_HEAD_CONTENT_TYPE_SHEET);
+            response.addHeader(CommonConstant.UPLOAD_FLAG, CommonConstant.SUCCESS_FLAG_ONE);
+            workbook.write(response.getOutputStream());
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            response.addHeader(CommonConstant.UPLOAD_FLAG,CommonConstant.SUCCESS_FLAG_ZERO);
+        } finally {
+            try {
+                inputStream.close();
+            } catch (IOException ignored) {
+                log.error("关闭文件流失败");
+            }
+            if (workbook != null) {
+                try {
+                    workbook.close();
+                } catch (IOException ignored) {
+                    log.error("关闭工作簿失败");
+                }
+            }
+        }
+    }
+    /***
+     * Description: 核心处理业务逻辑的方法
+     * @param workbook : 工作簿
+     * @return : void
+     * @author : lijie
+     * @date :2021/4/28 17:20
+     * Update By lijie 2021/4/28 17:20
+     */
+    protected abstract void handleWorkbook(Workbook workbook);
+    /***
+     * Description: 获取文件路径
+     * @return : java.lang.String
+     * @author : lijie
+     * @date :2021/4/28 17:21
+     * Update By lijie 2021/4/28 17:21
+     */
+    protected abstract String getFilePath();
+    /***
+     * Description: 获取响应对象
+     * @return : javax.servlet.http.HttpServletResponse
+     * @author : lijie
+     * @date :2021/4/28 17:21
+     * Update By lijie 2021/4/28 17:21
+     */
+    protected abstract HttpServletResponse getHttpServletResponse();
+
+}

+ 287 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/service/impl/BatchHandleObjectServiceImpl.java

@@ -0,0 +1,287 @@
+package com.persagy.dmp.rwd.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.RowUtil;
+import cn.hutool.poi.excel.WorkbookUtil;
+import cn.hutool.poi.excel.cell.CellUtil;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.common.criteria.JacksonCriteria;
+import com.persagy.common.web.ListResponse;
+import com.persagy.common.web.PagedResponse;
+import com.persagy.dmp.rwd.entity.FuncidDef;
+import com.persagy.dmp.rwd.entity.QFuncidDef;
+import com.persagy.dmp.rwd.handler.BusinessException;
+import com.persagy.dmp.rwd.handler.ResponseCode;
+import com.persagy.dmp.rwd.model.ClassDefModel;
+import com.persagy.dmp.rwd.model.FuncidDefModel;
+import com.persagy.dmp.rwd.repository.FuncidDefRepository;
+import com.persagy.dmp.rwd.service.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.SheetUtil;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.text.Collator;
+import java.util.*;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/***
+ * Description: 对象的上传下载逻辑处理类
+ * @author : lijie
+ * @date :2021/9/22 9:55
+ * Update By lijie 2021/9/22 9:55
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class BatchHandleObjectServiceImpl extends BaseService implements BatchHandleObjectService {
+    /**中文比较器*/
+    public final static Collator CHINA_COLLATOR = Collator.getInstance(Locale.CHINA);
+    /**功能点逻辑处理类*/
+    private final FuncidDefService funcidDefService;
+    /**类型定义逻辑处理类*/
+    private final ClassDefService classDefService;
+    /**物理世界对象批量导入模板的位置*/
+    private static final String TEMPLATE_FILE_PATH="/template/ObjectInfoTemplate.xlsx";
+    /**建筑功能类型sheet*/
+    private static final String BUILDING_FUNC_TYPE_SHEET_NAME="buildingFuncTypes";
+    /**空间分区sheet*/
+    private static final String SPACE_ZONES_SHEET_NAME="spaceZones";
+    /**空间功能类型sheet*/
+    private static final String SPACE_FUNC_TYPES_SHEET_NAME="roomFuncTypes";
+
+
+    /***
+     * Description: 下载模板接口
+     * @param response : 响应对象
+     * @param groupCode : 集团编码
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 9:54
+     * Update By lijie 2021/9/22 9:54
+     */
+    @Override
+    public void downloadObjectTemplateFile(HttpServletResponse response,String groupCode) throws IOException {
+        // 下载Excel模板类
+        new DownloadService() {
+            @Override
+            protected void handleWorkbook(Workbook workbook) {
+                // 1.填充对象类数据
+                fillDataToWorkbook(workbook,groupCode);
+            }
+
+            @Override
+            protected String getFilePath() {
+                return TEMPLATE_FILE_PATH;
+            }
+
+            @Override
+            protected HttpServletResponse getHttpServletResponse() {
+                return response;
+            }
+        }.downloadFile();
+    }
+    /***
+     * Description: 填充对象数据
+     * @param workbook : 工作簿
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 10:23
+     * Update By lijie 2021/9/22 10:23
+     */
+    private void fillDataToWorkbook(Workbook workbook,String groupCode) {
+        // 1.填充建筑功能类型
+        fillBuildFuncDataToWorkbook(workbook,groupCode);
+        // 2.设置建筑功能类型的下拉框-交给Excel自己实现
+        // constructBuildFuncComboBox(workbook);
+        // 3.填充楼层编码-因标准字典暂无该信息点,暂时根据已有的枚举值写死
+        // fillFloorIdentitiesDataToWorkbook(workbook,groupCode);
+        // 4.填充空间分区
+        fillSpaceZoneDataToWorkbook(workbook,groupCode);
+        // 5.填充空间功能类型
+        fillSpaceFuncTypesDataToWorkbook(workbook,groupCode);
+    }
+    /***
+     * Description: 填充空间功能类型
+     * @param workbook : 工作簿
+     * @param groupCode : 集团编码
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 19:51
+     * Update By lijie 2021/9/22 19:51
+     */
+    private void fillSpaceFuncTypesDataToWorkbook(Workbook workbook, String groupCode) {
+        // 1.根据集团编码查询空间功能类型
+        Sheet spaceFuncTypesSheet = WorkbookUtil.getOrCreateSheet(workbook, SPACE_FUNC_TYPES_SHEET_NAME);
+        JacksonCriteria criteria = JacksonCriteria.newInstance();
+        criteria.getCriteria().put("classCode","GeneralZone").put("code","roomFuncType");
+        ListResponse<FuncidDefModel> funcidDefModelListResponse = funcidDefService
+                .queryFuncid(groupCode, null, null, null, criteria);
+        if (!funcidDefModelListResponse.success()){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"空间功能类型不存在");
+        }
+        List<FuncidDefModel> data = funcidDefModelListResponse.getData();
+        if (CollUtil.isEmpty(data)){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"空间功能类型不存在");
+        }
+        FuncidDefModel defModel = data.get(0);
+        ArrayNode spaceFuncTypeArr = defModel.getDataSource();
+        if (spaceFuncTypeArr.size()<=0){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"空间功能类型不存在");
+        }
+        // 2.使用队列获取建筑功能类型的名称及code
+        Map<String,String> funcNameMap = analysisTreeDataToNameMap(spaceFuncTypeArr);
+        // 3.将内容写到Excel里
+        writeDataToSheet(funcNameMap,spaceFuncTypesSheet);
+    }
+
+    /***
+     * Description: 填充空间分区数据
+     * @param workbook : 工作簿
+     * @param groupCode : 集团编码
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 19:11
+     * Update By lijie 2021/9/22 19:11
+     */
+    private void fillSpaceZoneDataToWorkbook(Workbook workbook, String groupCode) {
+        // 1.根据集团编码查询空间分区
+        Sheet zonesSheet = WorkbookUtil.getOrCreateSheet(workbook, SPACE_ZONES_SHEET_NAME);
+        JacksonCriteria jacksonCriteria = JacksonCriteria.newInstance();
+        jacksonCriteria.getCriteria().put("objType","space");
+        ListResponse<ClassDefModel> listResponse = classDefService.queryClass(groupCode, null, null, null, true, jacksonCriteria);
+        if (!listResponse.success()){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"空间分区不存在");
+        }
+        List<ClassDefModel> classDefModels = listResponse.getData();
+        if (CollUtil.isEmpty(classDefModels)){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"空间分区不存在");
+        }
+        // 2.根据分区名称进行排序
+        classDefModels.sort((m1,m2)->CHINA_COLLATOR.compare(m1.getName(),m2.getName()));
+        // 3.填充分区名称数据
+        int j=0;
+        for (ClassDefModel classDefModel : classDefModels) {
+            if (classDefModel.getCode().equals(classDefModel.getObjType().name())) {
+                continue;
+            }
+            CellUtil.setCellValue(CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(zonesSheet, j), 0), classDefModel.getName(), null);
+            CellUtil.setCellValue(CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(zonesSheet, j), 1), classDefModel.getCode(), null);
+            j++;
+        }
+    }
+
+    /***
+     * Description: 构建建筑功能类型的下拉框
+     * @param workbook : 工作簿
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 17:06
+     * Update By lijie 2021/9/22 17:06
+     */
+    private void constructBuildFuncComboBox(Workbook workbook) {}
+
+    /***
+     * Description: 填充建筑功能类型
+     * @param workbook : 工作簿
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 14:29
+     * Update By lijie 2021/9/22 14:29
+     */
+    private void fillBuildFuncDataToWorkbook(Workbook workbook,String groupCode) {
+        Sheet buildingFuncTypeSheet = WorkbookUtil.getOrCreateSheet(workbook, BUILDING_FUNC_TYPE_SHEET_NAME);
+        // 1.查询建筑功能类型数据
+        JacksonCriteria criteria = JacksonCriteria.newInstance();
+        criteria.getCriteria().put("classCode","building").put("code","buildFuncType");
+        ListResponse<FuncidDefModel> funcidDefModelListResponse = funcidDefService
+                .queryFuncid(groupCode, null, null, null, criteria);
+        if (!funcidDefModelListResponse.success()){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"建筑功能类型不存在");
+        }
+        List<FuncidDefModel> data = funcidDefModelListResponse.getData();
+        if (CollUtil.isEmpty(data)){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"建筑功能类型不存在");
+        }
+        FuncidDefModel defModel = data.get(0);
+        ArrayNode buildFuncDataSource = defModel.getDataSource();
+        if (buildFuncDataSource.size()<=0){
+            throw new BusinessException(ResponseCode.C0320.getCode(),"建筑功能类型不存在");
+        }
+        // 2.使用队列获取建筑功能类型的名称及code
+        Map<String,String> funcNameMap = analysisTreeDataToNameMap(buildFuncDataSource);
+        // 3.将内容写到Excel里
+        writeDataToSheet(funcNameMap,buildingFuncTypeSheet);
+    }
+    /***
+     * Description: 写数据到sheet中 
+     * @param funcNameMap : 功能名称映射
+     * @param supSheet : 填写的sheet对象
+     * @return : void  
+     * @author : lijie
+     * @date :2021/9/22 19:59
+     * Update By lijie 2021/9/22 19:59
+     */
+    private void writeDataToSheet(Map<String, String> funcNameMap, Sheet supSheet) {
+        Set<Map.Entry<String, String>> entries = funcNameMap.entrySet();
+        List<Map.Entry<String, String>> list = new ArrayList<>(entries);
+        list.sort((e1,e2)->CHINA_COLLATOR.compare(e1.getValue(),e2.getValue()));
+        int i=0;
+        for (Map.Entry<String, String> entry : list) {
+            String key = entry.getKey();
+            String value = entry.getValue();
+            CellUtil.setCellValue(CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(supSheet,i),0),value,null);
+            CellUtil.setCellValue(CellUtil.getOrCreateCell(RowUtil.getOrCreateRow(supSheet,i),1),key,null);
+            i++;
+        }
+    }
+
+    /***
+     * Description: 获得code与名称的映射
+     * @param arrayNode : 节点数组
+     * @return : void
+     * @author : lijie
+     * @date :2021/9/22 19:57
+     * Update By lijie 2021/9/22 19:57
+     */
+    private Map<String, String> analysisTreeDataToNameMap(ArrayNode arrayNode) {
+        Map<String, List<JsonNode>> map = new HashMap<>();
+        arrayNode.forEach(node->{
+            String parentCode = node.has("parentCode")?node.get("parentCode").asText("0"):"0";
+            List<JsonNode> sonList = map
+                    .getOrDefault(parentCode, new ArrayList<>());
+            sonList.add(node);
+            map.put(parentCode,sonList);
+        });
+        Map<String, String> funcNameMap = new HashMap<>();
+        Queue<JsonNode> queue = new ConcurrentLinkedQueue<>(map.getOrDefault("0", new ArrayList<>()));
+        while (!queue.isEmpty()){
+            JsonNode jsonNode = queue.poll();
+            String parentCode = jsonNode.has("parentCode")?jsonNode.get("parentCode").asText("0"):"0";
+            if ("0".equals(parentCode)){
+                funcNameMap.put(jsonNode.get("code").asText(""),jsonNode.get("name").asText(""));
+                queue.addAll(map.getOrDefault(jsonNode.get("code").asText(""),new ArrayList<>()));
+                continue;
+            }
+            String parentText = funcNameMap.getOrDefault(parentCode, "");
+            if (StrUtil.isBlank(parentText)){
+                funcNameMap.put(jsonNode.get("code").asText(""),jsonNode.get("name").asText(""));
+                queue.addAll(map.getOrDefault(jsonNode.get("code").asText(""),new ArrayList<>()));
+                continue;
+            }
+            funcNameMap.put( jsonNode.get("code").asText(""),
+                    parentText+StrUtil.DASHED+jsonNode.get("name").asText(""));
+            queue.addAll(map.getOrDefault(jsonNode.get("code").asText(""),new ArrayList<>()));
+        }
+        return funcNameMap;
+    }
+}

+ 119 - 0
dmp-rwd/src/main/java/com/persagy/dmp/rwd/util/FileUtil.java

@@ -0,0 +1,119 @@
+package com.persagy.dmp.rwd.util;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.useragent.OS;
+import cn.hutool.http.useragent.UserAgent;
+import cn.hutool.http.useragent.UserAgentUtil;
+import com.persagy.dmp.rwd.constants.CommonConstant;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.List;
+
+/***
+ * Description: 文件处理公共类
+ * @author : lijie
+ * @date :2021/4/28 16:38
+ * Update By lijie 2021/4/28 16:38
+ */
+@Slf4j
+public class FileUtil {
+
+    /***
+     * Description: 获取资源文件方法
+     * @param configFilePath : 配置文件路径
+     * @param classpathFilePath : 本地路径
+     * @return : org.springframework.core.io.Resource[]
+     * @author : lijie
+     * @date :2021/3/1 14:25
+     * Update By lijie 2021/3/1 14:25
+     */
+    public static Resource[] getResource(String configFilePath, String classpathFilePath) throws IOException {
+        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+        Resource[] resolverResources = resolver.getResources(configFilePath);
+        if (resolverResources.length > 0) {
+            boolean exist = true;
+            for (Resource resource : resolverResources) {
+                if (!resource.exists()) {
+                    exist = false;
+                    break;
+                }
+            }
+            if(exist) {
+                return resolverResources;
+            }
+        }
+        return resolver.getResources(classpathFilePath);
+    }
+
+    /***
+     * Description: 写错误提示语到文件中
+     * @param errorList : 错误提示语列表
+     * @param response : 响应体对象
+     * @author : lijie
+     * @date :2021/3/4 15:33
+     * Update By lijie 2021/3/4 15:33
+     */
+    public static void writeErrorContentToResponse(List<String> errorList,
+                                                   HttpServletResponse response,
+                                                   HttpServletRequest request, String errorFileName){
+        try {
+            ServletOutputStream outputStream = response.getOutputStream();
+            String lineSeparator = getSystemLineSeparator(request);
+            for (String error : errorList) {
+                outputStream.write(error.getBytes());
+                outputStream.write(lineSeparator.getBytes());
+            }
+            // 为文件命名
+            response.setHeader(CommonConstant.REPONSE_HEAD_CONTENT_DISPOSITION,
+                    "attachment;filename=" + URLEncoder.encode(errorFileName, "UTF-8"));
+            response.addHeader(CommonConstant.REPONSE_HEAD_CONTENT_TYPE, "text/plain");
+            response.addHeader(CommonConstant.UPLOAD_FLAG, CommonConstant.SUCCESS_FLAG_ZERO);
+            response.addHeader(CommonConstant.REPONSE_HEAD_ACCESS_CONTROL_EXPOSE_HEADERS,CommonConstant.UPLOAD_FLAG);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /***
+     * Description: 获得请求的换行符
+     * @param request : 请求体
+     * @return : void
+     * @author : lijie
+     * @date :2021/3/13 10:57
+     * Update By lijie 2021/3/13 10:57
+     */
+    private static String getSystemLineSeparator(HttpServletRequest request) {
+        String userAgent = request.getHeader(CommonConstant.OS_TYPE);
+        if (StrUtil.isBlank(userAgent)){
+            return System.lineSeparator();
+        }
+        UserAgent agent = UserAgentUtil.parse(userAgent);
+        OS os = agent.getOs();
+        if (null==os){
+            return System.lineSeparator();
+        }
+        String osStr = agent.getOs().toString().toLowerCase();
+        if (StrUtil.isBlank(osStr)){
+            return System.lineSeparator();
+        }
+        if (osStr.contains(CommonConstant.SYSTEM_TYPE_WINDOWS)){
+            return "\r\n";
+        }
+        if (osStr.contains(CommonConstant.SYSTEM_TYPE_LINUX)){
+            return "\r";
+        }
+        if (osStr.contains(CommonConstant.SYSTEM_TYPE_MAC)){
+            return "\n";
+        }
+        return System.lineSeparator();
+    }
+
+}

TEMPAT SAMPAH
dmp-rwd/src/main/resources/arthas-boot.jar


TEMPAT SAMPAH
dmp-rwd/src/main/resources/template/ObjectInfoTemplate.xlsx