commit 62682dcb5b169e55352e8f0739a0fe0efef7a4ba
Author: wht <1309375318@qq.com>
Date: Mon Mar 31 12:03:06 2025 +0800
init: plm service
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a2a3040
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/LOG_HOME_IS_UNDEFINED/PROJECT_NAME_IS_UNDEFINED-task.log b/LOG_HOME_IS_UNDEFINED/PROJECT_NAME_IS_UNDEFINED-task.log
new file mode 100644
index 0000000..e69de29
diff --git a/LOG_HOME_IS_UNDEFINED/PROJECT_NAME_IS_UNDEFINED.log b/LOG_HOME_IS_UNDEFINED/PROJECT_NAME_IS_UNDEFINED.log
new file mode 100644
index 0000000..e69de29
diff --git a/commons/.gitignore b/commons/.gitignore
new file mode 100644
index 0000000..a2a3040
--- /dev/null
+++ b/commons/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/commons/.mvn/wrapper/MavenWrapperDownloader.java b/commons/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..a45eb6b
--- /dev/null
+++ b/commons/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ private static final String WRAPPER_VERSION = "0.5.6";
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if (mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if (mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if (!outputFile.getParentFile().exists()) {
+ if (!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+ String username = System.getenv("MVNW_USERNAME");
+ char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+ }
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/commons/.mvn/wrapper/maven-wrapper.jar b/commons/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..2cc7d4a
Binary files /dev/null and b/commons/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/commons/.mvn/wrapper/maven-wrapper.properties b/commons/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..642d572
--- /dev/null
+++ b/commons/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
diff --git a/commons/pom.xml b/commons/pom.xml
new file mode 100644
index 0000000..5783f05
--- /dev/null
+++ b/commons/pom.xml
@@ -0,0 +1,286 @@
+
+
+ 4.0.0
+
+ com.centricsoftware
+ plmservice
+ 2.0
+ ../pom.xml
+
+
+ commons
+ 2.1
+ jar
+ Demo project for Spring Boot
+
+
+ 1.8
+ 4.1
+ 7.0.1
+ 2.6.12
+ 1.0.3
+
+
+ 4.1.2
+ 3.6
+ 1.4.7
+ 2.0.0
+ 1.3.17
+ 1.56
+ 2.0
+ 1.1.1
+ 5.5.13
+ 5.2.0
+ 8.5.2
+ 3.4.0
+ 1.3.8
+ 3.3.3
+ 2.4.0
+
+
+
+
+
+ org.springframework.data
+ spring-data-elasticsearch
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+ provided
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ true
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+ commons-io
+ commons-io
+ 2.6
+
+
+ org.bouncycastle
+ bcprov-jdk15on
+ ${bcprov-jdk15on.version}
+
+
+
+ org.apache.velocity
+ velocity-engine-core
+ ${velocity-engine-core.version}
+
+
+
+ javax.ws.rs
+ jsr311-api
+ ${jsr311-api.version}
+
+
+ com.centricsoftware
+ config
+
+
+ com.centricsoftware
+ mybatis
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.antlr
+ ST4
+ ${st4.version}
+
+
+
+
+
+
+ com.oracle
+ ojdbc6
+
+
+
+ net.sourceforge.jexcelapi
+ jxl
+ ${jxl.version}
+
+
+
+ org.apache.poi
+ poi
+ ${poi.version}
+
+
+
+ org.apache.poi
+ poi-ooxml
+ ${poi.version}
+
+
+
+ net.sf.jxls
+ jxls-core
+ ${jxl.core.version}
+
+
+
+ commons-net
+ commons-net
+ ${commons-net.version}
+
+
+
+ org.codehaus.jettison
+ jettison
+ ${jettson.version}
+
+
+
+ javax.mail
+ mail
+ ${mail.version}
+
+
+
+ jcifs
+ jcifs
+ ${jcifs.version}
+
+
+ javax.servlet
+ servlet-api
+
+
+
+
+
+ com.itextpdf
+ itextpdf
+ ${itextpdf.version}
+
+
+
+ com.itextpdf
+ itext-asian
+ ${itext-asian.version}
+
+
+ com.alibaba
+ easyexcel
+ ${easyexcel.version}
+
+
+ com.jayway.jsonpath
+ json-path
+ ${json-path.version}
+
+
+
+
+
+
+
+
+
+ com.microsoft.sqlserver
+ mssql-jdbc
+
+
+
+ com.google.zxing
+ core
+ ${zxing.core.version}
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+ 2.0.0.RELEASE
+
+
+ io.github.openfeign
+ feign-core
+
+
+
+
+ io.github.openfeign
+ feign-core
+ 10.1.0
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.1.0
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.3
+
+
+ io.github.openfeign.form
+ feign-form
+ 3.8.0
+
+
+ io.github.openfeign.form
+ feign-form-spring
+ 3.8.0
+
+
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.9
+
+
+
+ org.springframework
+ spring-test
+ 5.2.9.RELEASE
+
+
+
+
+
+
+ AsposeJavaAPI
+ Aspose Java API
+ https://repository.aspose.com/repo/
+
+
+
+ plmservice-commons
+
+
+ src/main/resources
+
+ license.xml
+
+ true
+
+
+
+
+
diff --git a/commons/src/main/java/com/centricsoftware/commons/ant/ControllerLog.java b/commons/src/main/java/com/centricsoftware/commons/ant/ControllerLog.java
new file mode 100644
index 0000000..196eed6
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/ant/ControllerLog.java
@@ -0,0 +1,40 @@
+package com.centricsoftware.commons.ant;
+
+import org.springframework.stereotype.Component;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义注解,拦截Controller
+ * @author ZhengGong
+ * @date 2019/6/25
+ */
+@Target({ElementType.TYPE,ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Component
+public @interface ControllerLog {
+ String value() default "";
+
+ /**
+ * 是否记录响应信息
+ * @author liaochangjiang
+ * @since 2024-05-07 17:11
+ */
+ boolean response() default false;
+
+ /**
+ * 是否接口日志
+ */
+ boolean interfaceLog() default false;
+
+ /**
+ * 请求报文中key的字段,支持getByPath
+ */
+ String requestId() default "";
+
+ /**
+ * 响应报文中成功的字段,支持getByPath
+ */
+ String responseId() default "";
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/ant/ServiceLog.java b/commons/src/main/java/com/centricsoftware/commons/ant/ServiceLog.java
new file mode 100644
index 0000000..dea5a98
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/ant/ServiceLog.java
@@ -0,0 +1,15 @@
+package com.centricsoftware.commons.ant;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义注解,拦截service
+ * @author ZhengGong
+ * @date 2019/6/25
+ */
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ServiceLog {
+ String value() default "";
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/PlmPageReqVo.java b/commons/src/main/java/com/centricsoftware/commons/dto/PlmPageReqVo.java
new file mode 100644
index 0000000..f171193
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/PlmPageReqVo.java
@@ -0,0 +1,13 @@
+package com.centricsoftware.commons.dto;
+
+import lombok.Data;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+@Data
+@ToString(callSuper = true)
+@Accessors(chain = true)
+public class PlmPageReqVo {
+ private Long pageNum = 1L;
+ private Long pageSize = 10L;
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/PlmUtilsException.java b/commons/src/main/java/com/centricsoftware/commons/dto/PlmUtilsException.java
new file mode 100644
index 0000000..8c4af1d
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/PlmUtilsException.java
@@ -0,0 +1,35 @@
+package com.centricsoftware.commons.dto;
+
+import com.centricsoftware.commons.em.ResCode;
+import com.centricsoftware.commons.exception.BaseException;
+
+/**
+ * @Description: PLM工具类异常基类
+ * @Author: ZhengGong
+ * @CreateDate: 2019/5/20 15:11
+ * @Company: Centric
+ */
+public class PlmUtilsException extends BaseException {
+
+ public PlmUtilsException(ResCode code) {
+ super(code);
+ }
+
+ public PlmUtilsException(ResCode code, Object data) {
+ super(code,data);
+ }
+
+ public PlmUtilsException(Integer code, String message) {
+ super(code,message);
+ }
+
+ public PlmUtilsException(Integer code, String message, Object data) {
+ super(code,message,data);
+ }
+
+ public PlmUtilsException(ResCode code, Throwable e){
+ super(code);
+ }
+
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/ResEntity.java b/commons/src/main/java/com/centricsoftware/commons/dto/ResEntity.java
new file mode 100644
index 0000000..62d70f8
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/ResEntity.java
@@ -0,0 +1,37 @@
+package com.centricsoftware.commons.dto;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 返回信息实体类
+ * @author ZhengGong
+ * @date 2020/4/16
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ResEntity implements Serializable {
+ /**
+ * 错误编号
+ */
+ private Integer code;
+ /**
+ * 错误信息
+ */
+ private String msg;
+ /**
+ * 返回对象
+ */
+ private Object data;
+ /**
+ * 是否成功
+ */
+ private boolean success;
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/WebResponse.java b/commons/src/main/java/com/centricsoftware/commons/dto/WebResponse.java
new file mode 100644
index 0000000..857bff9
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/WebResponse.java
@@ -0,0 +1,132 @@
+package com.centricsoftware.commons.dto;
+
+
+import cn.hutool.core.util.StrUtil;
+import com.centricsoftware.commons.em.ResCode;
+import com.centricsoftware.commons.exception.BaseException;
+import lombok.extern.slf4j.Slf4j;
+import org.stringtemplate.v4.ST;
+
+import java.net.URLEncoder;
+
+/**
+ * 接口返回信息
+ * @author ZhengGong
+ * @date 2019/9/16
+ */
+@Slf4j
+public class WebResponse {
+
+ /**
+ * 失败返回特定的消息实体
+ * @param code 错误代码
+ * @param message 错误信息
+ * @param data 具体消息实体
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity failure(Integer code, String message, Object data) {
+ return ResEntity.builder().code(code).msg(message).data(data).success(false).build();
+ }
+
+ /**
+ * 失败返回特定的消息实体
+ * @param code 错误代码
+ * @param message 错误信息
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity failure(Integer code, String message) {
+ return ResEntity.builder().code(code).msg(message).success(false).build();
+ }
+
+ /**
+ * 失败返回特定的消息实体
+ * @param respCode 错误代码封装枚举类
+ * @param data 具体消息实体
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity failure(ResCode respCode, Object data) {
+ return getStringObjectMap(respCode, data,false);
+ }
+
+ /**
+ * 失败返回特定的消息实体
+ * @param respCode 错误代码封装枚举类
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity failure(ResCode respCode) {
+ return getStringObjectMap(respCode,false);
+ }
+
+ /**
+ * 失败返回特定的消息实体
+ * @param e 错误基类
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity failure(T e){
+ return failure(e.getCode(),e.getMessage(),e.getData());
+ }
+
+
+
+ /**
+ * 错误302到具体的页面
+ * @param stp 模板链接
+ * @param msg 错误信息
+ * @return 页面链接
+ */
+ public static String failurePage(String stp,String msg) {
+ try {
+ ST st=new ST(stp);
+ st.add("ERROR", URLEncoder.encode(msg,"UTF-8"));
+ return "redirect:"+st.render();
+ } catch (Exception e) {
+ log.error("error:",e);
+ return null;
+ }
+ }
+
+
+ /**
+ * 成功返回特定的状态码和信息
+ * @param respCode 成功代码封装枚举类
+ * @param data 具体消息实体
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity success(ResCode respCode, Object data) {
+ return getStringObjectMap(respCode, data,true);
+ }
+
+ private static ResEntity getStringObjectMap(ResCode respCode, Object data, Boolean success) {
+ return ResEntity.builder().code( respCode.getCode()).msg( respCode.getMessage()).data(data).success(success).build();
+ }
+
+ /**
+ * 成功返回特定的状态码和信息
+ * @param respCode 成功代码封装枚举类
+ * @return 消息实体ResEntity
+ */
+ public static ResEntity success(ResCode respCode) {
+ return getStringObjectMap(respCode,true);
+ }
+
+ private static ResEntity getStringObjectMap(ResCode respCode, Boolean success) {
+ return ResEntity.builder().code(respCode.getCode()).msg(respCode.getMessage()).success(success).build();
+ }
+
+ public static ResEntity failure(String message){
+ return ResEntity.builder().code(ResCode.ERROR.getCode()).msg(message).success(false).build();
+ }
+ public static ResEntity success(String message){
+ return ResEntity.builder().code(ResCode.SUCCESS.getCode()).msg(message).success(true).build();
+ }
+
+ public static ResEntity autoResponse(Object obj,String error) {
+ if(StrUtil.isBlank(error)){
+ return ResEntity.builder().code(ResCode.SUCCESS.getCode()).msg(ResCode.SUCCESS.getMessage()).success(true).data(obj).build();
+ }else{
+ return ResEntity.builder().code(ResCode.ERROR.getCode()).msg(error).success(false).data(obj).build();
+ }
+
+ }
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumList.java b/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumList.java
new file mode 100644
index 0000000..9b321d3
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumList.java
@@ -0,0 +1,31 @@
+package com.centricsoftware.commons.dto.enum4cache;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Data
+public class EnumList {
+
+ private String dependsOn;
+
+ private String description;
+
+ private List enums;
+
+ private String nodeName;
+
+ private List values;
+
+ private List enumValues;
+
+ private Map descCache;//描述:fullname 和 fullname:描述
+
+ private Map displayEnCache;//翻译值:fullname
+
+ private Map displayZhCache;//翻译值:fullname
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumValue.java b/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumValue.java
new file mode 100644
index 0000000..1d50c7d
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/dto/enum4cache/EnumValue.java
@@ -0,0 +1,20 @@
+package com.centricsoftware.commons.dto.enum4cache;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Data
+public class EnumValue {
+
+ private boolean active;
+
+ private String dependsOn;
+
+ private String description;
+
+ private String nodeName;
+
+ private String value;
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/em/C8ImportTypeEnum.java b/commons/src/main/java/com/centricsoftware/commons/em/C8ImportTypeEnum.java
new file mode 100644
index 0000000..04d136a
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/em/C8ImportTypeEnum.java
@@ -0,0 +1,14 @@
+package com.centricsoftware.commons.em;
+
+public enum C8ImportTypeEnum {
+ REF,
+ STRING,
+ BOOLEAN,
+ ENUM,
+ ENUM_DESC,
+ ENUM_DISPLAY,
+ TIME,
+ INTEGER,
+ DOUBLE,
+ REFLIST
+}
\ No newline at end of file
diff --git a/commons/src/main/java/com/centricsoftware/commons/em/C8NativeExportType.java b/commons/src/main/java/com/centricsoftware/commons/em/C8NativeExportType.java
new file mode 100644
index 0000000..b32cf5a
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/em/C8NativeExportType.java
@@ -0,0 +1,5 @@
+package com.centricsoftware.commons.em;
+
+public enum C8NativeExportType {
+ STRING, DOUBLE, INTEGER, BOOLEAN, URL, URL_ID, ENUM, ENUM_KEY, ENUM_DESC, ENUM_DISPLAY, TIME, LONG
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/em/ResCode.java b/commons/src/main/java/com/centricsoftware/commons/em/ResCode.java
new file mode 100644
index 0000000..21e78bf
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/em/ResCode.java
@@ -0,0 +1,67 @@
+package com.centricsoftware.commons.em;
+
+import lombok.Getter;
+
+/**
+ * 错误码枚举类
+ *
+ * @author ZhengGong
+ * @date 2019/6/12
+ */
+@Getter
+public enum ResCode {
+
+ SUCCESS(0, "成功!"),
+ OK(200, "OK"),
+ ERROR(201, "失败"),
+ REQUEST_NOT_FOUND(202, "请求不存在!"),
+ HTTP_BAD_METHOD(203, "请求方式不支持!"),
+ BAD_REQUEST(204, "请求异常!"),
+ PARAM_NOT_MATCH(205, "参数不匹配!"),
+ PARAM_NOT_NULL(206, "参数不能为空!"),
+ JSON_PARSE_ERROR(207, "JSON转换异常"),
+ C8_UNSUPPORTED_ENCODING_ERROR(208, "双编码异常"),
+ AUTHORIZE_ERROR(209, "请求未授权!"),
+ AUTHORIZE_UP_ERROR(210, "请求未授权,账号或密码错误!"),
+ CONFIG_NOT_INIT(666, "配置未初始化!"),
+
+ /**
+ * 业务类
+ */
+ DMP_DATA_NULL(3001, "找不到对应的数据,或者数据已经同步成功"),
+ DMP_DATA_TRANSLATE_FAIL(3002, "调用DMP同步数据失败,请重试"),
+ DMP_FILE_URL_ILLEGAL(3003, "获取到的DMP文件路径不合法"),
+ DMP_FILE_PUBLISH_ERROR(3004, "DMP发布文件失败"),
+ SKU_CODE_NOTFOUND(3005, "SKU CODE没有找到相关的SKU数据"),
+ SKU_CODE_DUPLICATE(3006, "SKU CODE找出重复的数据,请联系管理员"),
+ SKU_CODE_EMPTY(3007, "SKU CODE为空"),
+
+
+ RECORD_LOCK(888, "数据正在执行更新,已被锁定,请稍后再试"),
+ SYSTEM_RUNTIME_ERROR(999, "系统异常!");
+
+ private Integer code;
+
+ private String message;
+
+ ResCode(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ /**
+ * 通过code返回枚举
+ *
+ * @param code
+ * @return
+ */
+ public static ResCode parse(Integer code) {
+ ResCode[] values = values();
+ for (ResCode value : values) {
+ if (value.getCode().equals(code)) {
+ return value;
+ }
+ }
+ throw new RuntimeException("Unknown code of ResultEnum");
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/exception/BaseException.java b/commons/src/main/java/com/centricsoftware/commons/exception/BaseException.java
new file mode 100644
index 0000000..48318ec
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/exception/BaseException.java
@@ -0,0 +1,52 @@
+package com.centricsoftware.commons.exception;
+
+import com.centricsoftware.commons.em.ResCode;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 异常基类
+ * @author ZhengGong
+ * @date 2019/6/18
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class BaseException extends RuntimeException {
+ private Integer code;
+ private String message;
+ private Object data;
+
+ public BaseException(ResCode resCode) {
+ super(resCode.getMessage());
+ this.code = resCode.getCode();
+ this.message = resCode.getMessage();
+ }
+
+ public BaseException(ResCode resCode, Object data) {
+ this(resCode);
+ this.data = data;
+ }
+
+ public BaseException(Integer code, String message) {
+ super(message);
+ this.code = code;
+ this.message = message;
+ }
+
+ public BaseException(Integer code, String message, Object data) {
+ this(code, message);
+ this.data = data;
+ }
+
+ public BaseException(ResCode code, Throwable e){
+ this(code);
+ data = e;
+ }
+
+ public ResCode getResCode(){
+ return ResCode.parse(code);
+ }
+
+
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/exception/C8UnsupportedEncodingException.java b/commons/src/main/java/com/centricsoftware/commons/exception/C8UnsupportedEncodingException.java
new file mode 100644
index 0000000..f692844
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/exception/C8UnsupportedEncodingException.java
@@ -0,0 +1,30 @@
+package com.centricsoftware.commons.exception;
+
+import com.centricsoftware.commons.em.ResCode;
+
+/**
+ * c8 uri双编码异常
+ * @author zheng.gong
+ * @date 2020/5/12
+ */
+public class C8UnsupportedEncodingException extends BaseException {
+ public C8UnsupportedEncodingException(ResCode code) {
+ super(code);
+ }
+
+ public C8UnsupportedEncodingException(ResCode code, Object data) {
+ super(code,data);
+ }
+
+ public C8UnsupportedEncodingException(Integer code, String message) {
+ super(code,message);
+ }
+
+ public C8UnsupportedEncodingException(Integer code, String message, Object data) {
+ super(code,message,data);
+ }
+
+ public C8UnsupportedEncodingException(ResCode code, Throwable e){
+ super(code);
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/exception/ParamException.java b/commons/src/main/java/com/centricsoftware/commons/exception/ParamException.java
new file mode 100644
index 0000000..5adcb8c
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/exception/ParamException.java
@@ -0,0 +1,30 @@
+package com.centricsoftware.commons.exception;
+
+import com.centricsoftware.commons.em.ResCode;
+
+/**
+ * 参数异常
+ * @author ZhengGong
+ * @date 2019/9/16
+ */
+public class ParamException extends BaseException {
+ public ParamException(ResCode code) {
+ super(code);
+ }
+
+ public ParamException(ResCode code, Object data) {
+ super(code,data);
+ }
+
+ public ParamException(Integer code, String message) {
+ super(code,message);
+ }
+
+ public ParamException(Integer code, String message, Object data) {
+ super(code,message,data);
+ }
+
+ public ParamException(ResCode code, Throwable e){
+ super(code);
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/exception/RequestArgsException.java b/commons/src/main/java/com/centricsoftware/commons/exception/RequestArgsException.java
new file mode 100644
index 0000000..5fa9503
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/exception/RequestArgsException.java
@@ -0,0 +1,31 @@
+package com.centricsoftware.commons.exception;
+
+import com.centricsoftware.commons.em.ResCode;
+import com.centricsoftware.commons.exception.BaseException;
+
+/**
+ * 请求参数异常
+ * @author ZhengGong
+ * @date 2019/9/16
+ */
+public class RequestArgsException extends BaseException {
+ public RequestArgsException(ResCode resCode) {
+ super(resCode);
+ }
+
+ public RequestArgsException(ResCode resCode, Object data) {
+ super(resCode, data);
+ }
+
+ public RequestArgsException(Integer code, String message) {
+ super(code, message);
+ }
+
+ public RequestArgsException(Integer code, String message, Object data) {
+ super(code, message, data);
+ }
+
+ public RequestArgsException(ResCode code, Throwable e) {
+ super(code, e);
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/utils/CSVParser.java b/commons/src/main/java/com/centricsoftware/commons/utils/CSVParser.java
new file mode 100644
index 0000000..b71530f
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/utils/CSVParser.java
@@ -0,0 +1,91 @@
+package com.centricsoftware.commons.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+/**
+ * csv处理工具类
+ * 同类方法 {@link cn.hutool.core.text.csv.CsvUtil}
+ * @author zheng.gong
+ * @date 2020/4/27
+ */
+public class CSVParser {
+
+ public List parse(File file) throws Exception {
+ List result = new ArrayList();
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
+ try {
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ result.add(parseLine(line));
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+
+ return result;
+ }
+
+ enum State {
+ Normal, QuoteBegin, Quote, QuoteEnd,
+ }
+
+ public String[] parseLine(String line) {
+ ArrayList list = new ArrayList();
+ State state = State.Normal;
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < line.length(); ++i) {
+ char ch = line.charAt(i);
+ switch (state) {
+ case Normal:
+ if (ch == ',') {
+ list.add(sb.toString());
+ sb.setLength(0);
+ } else if (ch == '"') {
+ state = State.QuoteBegin;
+ } else {
+ sb.append(ch);
+ }
+ break;
+ case QuoteBegin:
+ if (ch == '"') {
+ state = State.Normal;
+ sb.append('"');
+ } else {
+ state = State.Quote;
+ sb.append(ch);
+ }
+ break;
+ case Quote:
+ if (ch == '"') {
+ state = State.QuoteEnd;
+ } else {
+ sb.append(ch);
+ }
+ break;
+ case QuoteEnd:
+ if (ch == ',') {
+ state = State.Normal;
+ list.add(sb.toString());
+ sb.setLength(0);
+ } else if (ch == '"') {
+ state = State.Quote;
+ sb.append('"');
+ } else {
+ state = State.Normal;
+ sb.append(ch);
+ }
+ break;
+ }
+ }
+ list.add(sb.toString());
+ return list.toArray(new String[list.size()]);
+ }
+
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/utils/CommonUtil.java b/commons/src/main/java/com/centricsoftware/commons/utils/CommonUtil.java
new file mode 100644
index 0000000..0bb9ef7
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/utils/CommonUtil.java
@@ -0,0 +1,602 @@
+package com.centricsoftware.commons.utils;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.Map.Entry;
+
+@Slf4j
+public class CommonUtil {
+
+ public static final String DAY_FORMAT = "yyyy-MM-dd";
+ public static final String DAY_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+ public static final String YMD = "yyyyMMdd";
+ public static final String YYMD = "yyMMdd";
+ public static final String YYMD_HMS = "yyMMddHHmmss";
+ public static final String YMD_DASH = "yyyy-MM-dd";
+ public static final String YMD_SLASH = "yyyy/MM/dd";
+ public static final String YMD_HMS = "yyyyMMddHHmmss";
+ public static final String YMD_HMSS = "yyyyMMddHHmmssSSS";
+ public static final String YMD_HMS_DASH = "yyyy-MM-dd HH:mm:ss";
+ public static final String HMS_DASH = "HH:mm:ss";
+
+
+ /**
+ * 转换timestamp
+ *
+ * @param attrvalue
+ * @param attrformat
+ * @param CLASSNAME
+ * @return
+ * @author GHUANG
+ * @version 2019年6月10日 上午11:56:16
+ */
+ public static String parseTimestamp(String attrvalue, String attrformat, String CLASSNAME) {
+ DateFormat format = new SimpleDateFormat(attrformat);
+ String svalue = "";
+ try {
+ Timestamp ts = new Timestamp(format.parse(attrvalue).getTime());
+ long tsvalue = ts.getTime() / 1000;
+ svalue = String.valueOf(tsvalue);
+ } catch (Exception e) {
+ log.error(CLASSNAME, e);
+ }
+ return svalue;
+ }
+
+ public static String getCurrentDate(String format) {
+ SimpleDateFormat sm = new SimpleDateFormat(format);
+ return sm.format(new Date());
+ }
+
+ public static String createTimeNo() {
+ SimpleDateFormat fullDateFormat = new SimpleDateFormat("yyyyMMdd");
+ fullDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT+8:00"));
+ String currentTime = fullDateFormat.format(new Date(System.currentTimeMillis()));
+ return currentTime;
+ }
+
+ public static String createTime() {
+ Timestamp d = new Timestamp(System.currentTimeMillis());
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 定义格式
+ return df.format(d);
+ }
+
+ public static String createCurrentTimestamp(String CLASSNAME) {
+ String svalue = "";
+ try {
+ Timestamp d = new Timestamp(System.currentTimeMillis());
+ long tsvalue = d.getTime() / 1000;
+ svalue = String.valueOf(tsvalue);
+ } catch (Exception e) {
+ log.error(CLASSNAME, e);
+ }
+ return svalue;
+ }
+
+ public static HashMap changeStr2Map(String mapStr) {
+ HashMap map = new HashMap();
+ String cms = mapStr.replace("{", "").replace("}", "");
+ String[] mapStrs = cms.split(",");
+ for (String s : mapStrs) {
+ String[] ms = s.split("=");
+ System.out.println(s);
+ if (ms.length == 2) {
+ map.put(ms[0], ms[1]);
+ }
+
+ }
+ return map;
+ }
+
+ public static String escapeUrl(String value) {
+ if (value == null) {
+ return "";
+ }
+ String s = value.replaceAll("&", "&");
+ s = s.replaceAll("<", "<");
+ s = s.replaceAll(">", ">");
+ s = s.replaceAll("\"", """);
+ s = s.replaceAll("'", "'");
+
+ return s;
+
+ }
+
+ /**
+ * 拆分List
+ *
+ * @param list
+ * @param len
+ * @return
+ * @author GHUANG
+ * @version 2019年11月5日 下午3:35:49
+ */
+ public static List splitList(List list, int len) {
+ List result = new ArrayList();
+ log.info("input list={},core={}",list,len);
+ if (list == null || list.size() == 0 || len < 1) {
+ result.add(list);
+ } else {
+
+ int size = list.size();
+ int count = (size + len - 1) / len;
+
+ for (int i = 0; i < count; i++) {
+ List subList = list.subList(i * len, ((i + 1) * len > size ? size : len * (i + 1)));
+ result.add(subList);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 拆分List
+ *
+ * @param map
+ * @param len
+ * @return
+ * @author GHUANG
+ * @version 2019年11月5日 下午3:35:49
+ */
+ public static List splitMap(LinkedHashMap> map, int len) {
+ List result = new ArrayList();
+ if (map == null || map.size() == 0 || len < 1) {
+ result.add(map);
+ } else {
+
+ int size = map.size();
+ int count = (size + len - 1) / len;
+ for (int i = 0; i < count; i++) {
+ int fromIndex = i * len;
+ int toIndex = ((i + 1) * len > size ? size : len * (i + 1));
+ LinkedHashMap> newmap = new LinkedHashMap>();
+ int j = 0;
+ for (Entry> entry : map.entrySet()) {
+ if (j >= fromIndex && j < toIndex) {
+ newmap.put(entry.getKey(), entry.getValue());
+ }
+ j++;
+ }
+ result.add(newmap);
+ }
+ }
+ return result;
+ }
+
+ public static String escapeSpecUrl(String value) {
+ if (value == null) {
+ return "";
+ }
+ String s = value.replaceAll("&", "&");
+ s = s.replaceAll("\"", """);
+ s = s.replaceAll("'", "'");
+
+ // s = stripBadChar(s);
+ return s;
+
+ }
+
+ public static String getExtractXML(ArrayList> list, String spec) {
+ String extractXML = "";
+ extractXML += "\n";
+ for (int i = 0; i < list.size(); i++) {
+ HashMap map = list.get(i);
+ String path = map.get("path");
+ if (path.length() > 0) {
+ path = " Path=\"" + path + "\"";
+ } else {
+ path = "";
+ }
+ extractXML += " \n";
+ }
+ if (extractXML.length() > 0) {
+ extractXML += spec;
+ }
+ extractXML += "\n";
+ return extractXML;
+ }
+
+ public static String getQueryXML(String nodetype, ArrayList> list, String notcondition,
+ String order) {
+ // TODO Auto-generated method stub
+ String queryXML = "";
+ queryXML += "\n";
+ queryXML += " \n";
+ queryXML += " \n";
+ if (notcondition.length() > 0) {
+ queryXML += notcondition;
+ }
+ queryXML += " \n";
+ for (HashMap map : list) {
+ String path = map.get("path");
+ String attrkey = map.get("key");
+ String attrvalue = map.get("value");
+ String attrtype = map.get("type");
+ if (attrtype.equalsIgnoreCase("string")) {
+ queryXML += " \n";
+ } else if (attrtype.equalsIgnoreCase("ref")) {
+ queryXML += " \n";
+ } else if (attrtype.equalsIgnoreCase("double")) {
+ queryXML += " \n";
+ }
+ }
+ queryXML += " \n";
+ queryXML += " \n";
+ queryXML += order;
+ queryXML += "\n";
+
+ return queryXML;
+ }
+
+ public static Locale getLocaleFromLocaleName(String localeName) {
+ Locale locale = null;
+ if (!StringUtils.isEmpty(localeName)) {
+ locale = Locale.forLanguageTag(localeName.replace('_', '-'));
+ }
+ return locale;
+ }
+
+ public static String stripBadChar(String s) {
+ StringBuilder out = new StringBuilder(s.length() * 6);
+ byte[] bytes = s.getBytes();
+
+ for (int j = 0; j < bytes.length; ++j) {
+ byte b = bytes[j];
+ int i = b;
+ if (i < 0) {
+ i = 256 + i;
+ }
+ if (i > '~') {
+ String cc = "" + i + ";";
+ out.append(cc);
+ } else {
+ char current = (char) b;
+ if ((current == 0x9) ||
+ (current == 0xA) ||
+ (current == 0xD) ||
+ ((current >= 0x20) && (current <= 0xD7FF)) ||
+ ((current >= 0xE000) && (current <= 0xFFFD)) ||
+ ((current >= 0x10000) && (current <= 0x10FFFF))) {
+ out.append(current);
+ }
+ }
+ }
+
+ s = out.toString();
+ return s;
+
+ }
+
+ public static String writeFileToDisk(byte[] img, String filePath, String fileName) {
+ String path = "";
+ try {
+ File folder = new File(filePath);
+ if (!folder.exists()) {
+ folder.mkdirs();
+ }
+ path = filePath + fileName;
+ File file = new File(path);
+ FileOutputStream fops = new FileOutputStream(file);
+ fops.write(img);
+ fops.flush();
+ fops.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return path;
+ }
+
+ /**
+ *
+ * @param json
+ * @param classname
+ * @param LOG
+ * @return
+ * @author GHUANG
+ * @version 2019年6月10日 下午1:08:45
+ */
+// public static HashMap parseXML(String type, JSONObject json, String classname) throws Exception{
+//
+// String keys = CSProperties.getValue("cs." + type + ".import.keys", "");
+//
+// List keylist = Arrays.asList(keys.split(","));
+// HashMap objmap = new HashMap();
+// try {
+// for (String key : keylist) {
+// String xml = "";
+// String attrname = CSProperties.getValue("cs." + type + ".import." + key + ".attrname", "");
+// String attrtype = CSProperties.getValue("cs." + type + ".import." + key + ".attrtype", "");
+// String refobj = CSProperties.getValue("cs." + type + ".import." + key + ".refobject", "");
+// String refkey = CSProperties.getValue("cs." + type + ".import." + key + ".refkey", "");
+// String refpath = CSProperties.getValue("cs." + type + ".import." + key + ".refpath", "");
+// String attrpath = CSProperties.getValue("cs." + type + ".import." + key + ".attrpath", "");
+// if (json.isNull(key)) {
+// continue;
+// }
+// if (json.has(key)) {
+// String attrvalue = json.getString(key);
+// if (attrtype.equals("enumKEY")) {
+// xml += "";
+// ;
+// } else if (attrtype.equals("enumNAME")) {
+// for (Entry gmap : NodeUtil.zhLocaleMap.entrySet()) {
+// if (gmap.getValue().equals(attrvalue) && gmap.getKey().contains(refobj)) {
+// xml += "";
+//
+// }
+// }
+// } else if (attrtype.equals("time")) {
+// String timestr = CommonUtil.parseTimestamp(attrvalue, refobj, classname);
+// xml += "";
+// } else if (attrtype.equals("integer")) {
+// xml += "";
+// } else if (attrtype.equals("ref")) {
+// String queryxml = "\r\n" +
+// "";
+// List refobjlist = NodeUtil.queryBOByXML(queryxml);
+// if (refobjlist.size() > 0) {
+// xml += "";
+//
+// }
+// } else if (attrtype.equals("reflist")) {
+// List valuelist = Arrays.asList(attrvalue);
+// if (valuelist.size() > 0) {
+// xml += "";
+// for (String value : valuelist) {
+// String queryxml = "\r\n" +
+// "";
+// List refobjlist = NodeUtil.queryBOByXML(queryxml);
+// xml += "[" + refobjlist.get(0) + "]";
+// }
+// xml += "";
+// }
+// } else {
+// xml += " ";
+//
+// }
+// }
+// if (attrpath == null || attrpath.length() == 0) {
+// if (objmap.containsKey("default")) {
+// String tempxml = (String) objmap.get("default");
+// objmap.put("default", xml + tempxml);
+// } else {
+// objmap.put("default", xml);
+// }
+// } else {
+// System.out.println("---" + attrpath);
+// if (objmap.containsKey(attrpath)) {
+// String tempxml = (String) objmap.get(attrpath);
+// objmap.put(attrpath, xml + tempxml);
+// } else {
+// objmap.put(attrpath, xml);
+// }
+// }
+// }
+// } catch (Exception e) {
+// log.info(classname, e);
+// }
+// return objmap;
+// }
+
+ /**
+ * 四舍五入
+ *
+ * @param attrvalue
+ * @param dot
+ * @return
+ * @author GHUANG
+ * @version 2019年6月18日 下午7:27:30
+ */
+ public static String changeDot(String attrvalue, int dot) {
+ BigDecimal db = new BigDecimal(attrvalue);
+ return String.valueOf(db.setScale(dot, BigDecimal.ROUND_HALF_UP).doubleValue());
+ }
+
+ public static void saveToFile(String fileName, InputStream in) throws IOException {
+ FileOutputStream fos = null;
+ BufferedInputStream bis = null;
+ int BUFFER_SIZE = 1024;
+ byte[] buf = new byte[BUFFER_SIZE];
+ int size = 0;
+ bis = new BufferedInputStream(in);
+ File f = new File(fileName);
+ if (!f.exists())//
+ {
+ File parentDir = new File(f.getParent());
+ if (!parentDir.exists())//
+ {
+ parentDir.mkdirs();
+ }
+ f.createNewFile();
+ }
+
+ fos = new FileOutputStream(fileName);
+ while ((size = bis.read(buf)) != -1) {
+ fos.write(buf, 0, size);
+ }
+ fos.close();
+ bis.close();
+ }
+
+ public static byte[] readInputStream(InputStream inStream) throws Exception {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int len = 0;
+ while ((len = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, len);
+ }
+ inStream.close();
+ return outStream.toByteArray();
+ }
+
+ public static String parseTime(String timeValue, String format) {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ String resultValue = "";
+ try {
+ long timeLongValue = Long.parseLong(timeValue);
+ if (timeLongValue > 0) {
+ Timestamp ts = new Timestamp(timeLongValue);
+ resultValue = sdf.format(ts);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return resultValue;
+ }
+
+ public static String inputStream2String(InputStream is)
+ throws UnsupportedEncodingException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
+ StringBuffer sb = new StringBuffer();
+ String line = null;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return sb.toString();
+ }
+
+ /***
+ * 删除文件夹
+ *
+ * @param folderPath 文件夹完整绝对路径
+ */
+ public static void delFolder(String folderPath) {
+ try {
+ delAllFile(folderPath); // 删除完里面所有内容
+ File myFilePath = new File(folderPath);
+ boolean b = myFilePath.delete(); // 删除空文件夹
+ if(!b){
+ log.error("删除文件失败,路径错误!");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /***
+ * 删除指定文件夹下所有文件
+ *
+ * @param path
+ * 文件夹完整绝对路径
+ * @return
+ */
+ public static boolean delAllFile(String path) {
+ boolean flag = false;
+ File file = new File(path);
+ if (!file.exists()) {
+ return flag;
+ }
+ if (!file.isDirectory()) {
+ return flag;
+ }
+ String[] tempList = file.list();
+ File temp = null;
+ for (int i = 0; i < tempList.length; i++) {
+ if (path.endsWith(File.separator)) {
+ temp = new File(path + tempList[i]);
+ } else {
+ temp = new File(path + File.separator + tempList[i]);
+ }
+ if (temp.isFile()) {
+ temp.delete();
+ }
+ if (temp.isDirectory()) {
+ delAllFile(path + "/" + tempList[i]);// 先删除文件夹里面的文件
+ delFolder(path + "/" + tempList[i]);// 再删除空文件夹
+ flag = true;
+ }
+ }
+ return flag;
+ }
+
+ /**
+ * 查找类及其父类的所有属性
+ * @param clazz
+ * @return
+ */
+ public static List getAllFields(Class clazz) {
+ List fields = Lists.newArrayList();
+ while (clazz != null) {
+ fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
+ clazz = clazz.getSuperclass();
+ }
+ return fields;
+ }
+ /**
+ * 四舍五入
+ * @param d
+ * @param bitNum
+ * @return
+ */
+ public static double getDouble(double d,int bitNum){
+ BigDecimal b = BigDecimal.valueOf(d);//增加计算精度的处理,四舍弃,五入
+ return b.setScale(bitNum, BigDecimal.ROUND_HALF_UP).doubleValue();//保留3位小数
+ }
+
+ /**
+ * 去掉数值末尾的0
+ * @param d
+ * @param bitNum
+ * @return
+ */
+ public static String getDoubleString(double d,int bitNum){
+ BigDecimal b = BigDecimal.valueOf(d);//增加计算精度的处理,四舍弃,五入
+ return b.setScale(bitNum, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();//保留3位小数
+ }
+
+ public static String timestamp2Date(String str_num,String format ) {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ if(StrUtil.isBlank(str_num)) str_num = "0";
+ if (str_num.length() == 13) {
+ String date = sdf.format(new Date(Long.parseLong(str_num)));
+ //LogUtil.debug("timestamp2Date"+ "将13位时间戳:" + str_num + "转化为字符串:", date);
+ return date;
+ } else if(!"0".equals(str_num)) {
+ String date = sdf.format(new Date(Integer.parseInt(str_num) * 1000L));
+ //LogUtil.debug("timestamp2Date" + "将10位时间戳:" + str_num + "转化为字符串:", date);
+ return date;
+ }else
+ return "";
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/utils/EncodeUtils.java b/commons/src/main/java/com/centricsoftware/commons/utils/EncodeUtils.java
new file mode 100644
index 0000000..317e829
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/utils/EncodeUtils.java
@@ -0,0 +1,143 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package com.centricsoftware.commons.utils;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+/**
+ * 封装各种格式的编码解码工具类.
+ * 1.Commons-Codec的 hex/base64 编码
+ * 2.自制的base62 编码
+ * 3.Commons-Lang的xml/html escape
+ * 4.JDK提供的URLEncoder
+ *
+ * @author calvin
+ * @version 2016-01-15
+ */
+public class EncodeUtils {
+ private static final String DEFAULT_URL_ENCODING = "UTF-8";
+ private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
+
+ /**
+ * Hex编码.
+ */
+ public static String encodeHex(byte[] input) {
+ return new String(Hex.encodeHex(input));
+ }
+
+ /**
+ * Hex解码.
+ */
+ public static byte[] decodeHex(String input) throws DecoderException {
+ return Hex.decodeHex(input.toCharArray());
+ }
+
+ /**
+ * Base64编码.
+ */
+ public static String encodeBase64(byte[] input) {
+ return new String(Base64.encodeBase64(input));
+ }
+
+ /**
+ * Base64编码.
+ */
+ public static String encodeBase64(String input) {
+ try {
+ return new String(Base64.encodeBase64(input.getBytes(DEFAULT_URL_ENCODING)));
+ } catch (UnsupportedEncodingException e) {
+ return "";
+ }
+ }
+
+ /**
+ * Base64解码.
+ */
+ public static byte[] decodeBase64(String input) {
+ return Base64.decodeBase64(input.getBytes());
+ }
+
+ /**
+ * Base64解码.
+ */
+ public static String decodeBase64String(String input) {
+ try {
+ return new String(Base64.decodeBase64(input.getBytes()), DEFAULT_URL_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ return "";
+ }
+ }
+
+ /**
+ * Base62编码。
+ */
+ public static String encodeBase62(byte[] input) {
+ char[] chars = new char[input.length];
+ for (int i = 0; i < input.length; i++) {
+ chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)];
+ }
+ return new String(chars);
+ }
+
+ /**
+ * Html 转码.
+ */
+ public static String escapeHtml(String html) {
+ return StringEscapeUtils.escapeHtml4(html);
+ }
+
+ /**
+ * Html 解码.
+ */
+ public static String unescapeHtml(String htmlEscaped) {
+ return StringEscapeUtils.unescapeHtml4(htmlEscaped);
+ }
+
+ /**
+ * Xml 转码.
+ */
+ public static String escapeXml(String xml) {
+ return StringEscapeUtils.escapeXml10(xml);
+ }
+
+ /**
+ * Xml 解码.
+ */
+ public static String unescapeXml(String xmlEscaped) {
+ return StringEscapeUtils.unescapeXml(xmlEscaped);
+ }
+
+ /**
+ * URL 编码, Encode默认为UTF-8.
+ */
+ public static String urlEncode(String part) {
+ try {
+ return URLEncoder.encode(part, DEFAULT_URL_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ return "";
+ }
+ }
+
+ /**
+ * URL 解码, Encode默认为UTF-8.
+ */
+ public static String urlDecode(String part) {
+ try {
+ return URLDecoder.decode(part, DEFAULT_URL_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ return "";
+ }
+ }
+
+ public static void main(String[] args){
+ System.out.println(EncodeUtils.encodeBase64("plm.2021.666"));
+ }
+}
diff --git a/commons/src/main/java/com/centricsoftware/commons/utils/ExcelUtil.java b/commons/src/main/java/com/centricsoftware/commons/utils/ExcelUtil.java
new file mode 100644
index 0000000..029dc7e
--- /dev/null
+++ b/commons/src/main/java/com/centricsoftware/commons/utils/ExcelUtil.java
@@ -0,0 +1,1150 @@
+package com.centricsoftware.commons.utils;
+
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.poi.excel.ExcelReader;
+import cn.hutool.poi.excel.ExcelWriter;
+import jxl.Cell;
+import jxl.CellType;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.*;
+import jxl.format.UnderlineStyle;
+import jxl.write.Boolean;
+import jxl.write.Number;
+import jxl.write.*;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.jxls.util.Util;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.nio.channels.FileChannel;
+import java.util.*;
+import java.util.regex.Pattern;
+
+//import com.aspose.cells.License;
+//import com.aspose.cells.SaveFormat;
+
+/**
+ * excel
+ * 处理工具类,同类方法
+ * {@link cn.hutool.poi.excel.ExcelReader}
+ * {@link cn.hutool.poi.excel.ExcelFileUtil}
+ * {@link cn.hutool.poi.excel.ExcelUtil}
+ * {@link cn.hutool.poi.excel.ExcelWriter}
+ * {@link cn.hutool.poi.excel.ExcelPicUtil}
+ * @author zheng.gong
+ * @date 2020/4/27
+ */
+@Slf4j
+public class ExcelUtil {
+ public ExcelUtil() {
+
+ }
+
+ /**
+ * 获取破解excel转换成pdf文件的license文件
+ *
+ * @return
+ */
+// public static boolean getLicense() {
+// // 获取license文件路径
+// String license = "license.xml";
+// boolean result = false;
+// try {
+// // 获取文件
+// ClassPathResource resource = new ClassPathResource(license);
+// // 获取输入流
+// InputStream is = resource.getInputStream();
+// // 通过License的set方法进行破解转换
+// License aposeLic = new License();
+// aposeLic.setLicense(is);
+// result = true;
+// is.close();
+// } catch (Exception e) {
+// log.error("破解excel转换pdf文件的license错误",e);
+// }
+// return result;
+// }
+
+ /**
+ * @param excelPath
+ * 需要被转换的excel全路径带文件名
+ * @param pdfPath
+ * 转换之后pdf的全路径带文件名
+ */
+// public static void excel2pdf(String excelPath, String pdfPath) {
+// if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
+// return;
+// }
+// log.info("License文件验证成功!");
+// try {
+// log.info("开始转换pdf文件");
+// // 原始excel路径
+// long old = System.currentTimeMillis();
+// // 创建一个工作空间
+// com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(excelPath);
+// // 获取文件输出流
+// FileOutputStream fileOS = new FileOutputStream(new File(pdfPath));
+// // 进行保存,SaveFormat内部有声明可以导出的文件类型,可自由选择
+// wb.save(fileOS, SaveFormat.PDF);
+// fileOS.close();
+// long now = System.currentTimeMillis();
+// log.info("共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+
+ /**
+ *
+ * @param filePath
+ */
+ public static void readExcel(String filePath) {
+ try {
+ InputStream is = new FileInputStream(filePath);
+ Workbook rwb = Workbook.getWorkbook(is);
+ Sheet st = rwb.getSheet("original");
+ Cell c00 = st.getCell(0, 0);
+ String strc00 = c00.getContents();
+ if (c00.getType() == CellType.LABEL) {
+ LabelCell labelc00 = (LabelCell) c00;
+ strc00 = labelc00.getString();
+ }
+ System.out.println(strc00);
+ rwb.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 根据配置文件,导出需要的数据
+ * @param templatePath 模板文件路径
+ * @param list 根据配置文件生成的对应数据
+ * @return ExcelWriter
+ */
+ public static ExcelWriter exportExcelByConfig(String templatePath, List