reformat code

This commit is contained in:
chenxudong 2024-12-13 16:12:27 +08:00
parent 7360a4d1fa
commit 4ad81053fb
38 changed files with 586 additions and 494 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>

View File

@ -18,7 +18,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
private LoginInterceptor loginInterceptor;
/**
*
* @param registry registry
*/
@Override

View File

@ -1,6 +1,6 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.resp.*;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.service.EDDataService;

View File

@ -11,30 +11,35 @@ public interface CategoryMapper extends BaseMapper<Category> {
/**
* 获取顶级节点
*
* @return
*/
List<Category> selectTopCategories();
/**
* 获取所有节点
*
* @return
*/
List<Category> selectAllCategories();
/**
* 获取节点通过编码ID
*
* @return
*/
List<Category> selectCategories(Category category);
/**
* 获取子节点通过父ID
*
* @return
*/
List<Category> selectChildCategories(Category category);
/**
* 创建目录树节点数据
*
* @return
*/
Boolean createCategory(Category category);

View File

@ -12,6 +12,7 @@ import java.util.List;
public interface EDDataMapper extends BaseMapper<EDDataInfo> {
/**
* 创建文件/文件夹数据信息
*
* @param edDataInfo
* @return
*/
@ -19,6 +20,7 @@ public interface EDDataMapper extends BaseMapper<EDDataInfo> {
/**
* 获取文件信息列表
*
* @param parames
* @return
*/
@ -26,6 +28,7 @@ public interface EDDataMapper extends BaseMapper<EDDataInfo> {
/**
* 更新文件信息
*
* @param parames
* @return
*/

View File

@ -15,18 +15,23 @@ public interface EDDataMappers {
/**
* 文件数据扩展模型入参转换
*
* @param request
* @return
*/
EDDataParams getEDDataParames(EDDataRequest request);
/**
* 文件数据扩展模型入参转换
*
* @param request
* @return
*/
EDDataInfo getEDDataInfo(EDDataRequest request);
/**
* 指标卡扩展模型返回
*
* @param edDataPage
* @return
*/

View File

@ -9,6 +9,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 插入
*
* @param token
* @return
*/
@ -16,6 +17,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 查询
*
* @param token
* @return Token
*/
@ -23,6 +25,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 删除token
*
* @param token
* @return
*/

View File

@ -13,6 +13,7 @@ public interface UserMapper {
/**
* 插入
*
* @param user
* @return
*/
@ -20,6 +21,7 @@ public interface UserMapper {
/**
* 编辑
*
* @param user
* @return
*/
@ -27,6 +29,7 @@ public interface UserMapper {
/**
* 发布
*
* @param publishParam
* @return
*/
@ -34,6 +37,7 @@ public interface UserMapper {
/**
* 通过工号查询用户
*
* @param workNumber
* @return
*/
@ -41,6 +45,7 @@ public interface UserMapper {
/**
* 通过用户编码查询用户
*
* @param userId
* @return
*/
@ -48,6 +53,7 @@ public interface UserMapper {
/**
* 通过用户编码查询用户
*
* @param searchKeywords
* @return
*/
@ -55,6 +61,7 @@ public interface UserMapper {
/**
* 查询数据总条目数
*
* @param searchKeywords
* @return
*/
@ -62,6 +69,7 @@ public interface UserMapper {
/**
* 通过用户ID删除用户
*
* @param userId
* @return
*/

View File

@ -18,6 +18,7 @@ public interface UserMappers {
/**
* 用户Request转用户模型
*
* @param userRequest
* @return
*/
@ -25,6 +26,7 @@ public interface UserMappers {
/**
* 用户登录Request转用户登录模型
*
* @param loginRequest
* @return
*/
@ -32,6 +34,7 @@ public interface UserMappers {
/**
* 获取单条用户信息Request转用户模型
*
* @param user
* @return
*/
@ -40,6 +43,7 @@ public interface UserMappers {
/**
* 用户发布request转用户发布参数模型
*
* @param userPublishRequest
* @return
*/
@ -47,6 +51,7 @@ public interface UserMappers {
/**
* 获取单条用户信息Request转用户模型
*
* @param searchUserRequest
* @return
*/
@ -54,6 +59,7 @@ public interface UserMappers {
/**
* 获取用户列表转response列表
*
* @param users
* @return
*/
@ -61,6 +67,7 @@ public interface UserMappers {
/**
* 编辑用户Request转用户模型
*
* @param userModiRequest
* @return
*/
@ -68,6 +75,7 @@ public interface UserMappers {
/**
* 校验工号唯一性Request转用户模型
*
* @param userWorkNumRequest
* @return
*/
@ -75,6 +83,7 @@ public interface UserMappers {
/**
* 删除单条用户信息Request转用户模型
*
* @param userDeleteRequest
* @return
*/

View File

@ -8,6 +8,7 @@ import java.io.Serializable;
/**
* 分页综合返回
*
* @author
* @version $Id: IndicatorCardPage.java, v 0.1 2024-08-14 17:30
*/

View File

@ -16,6 +16,7 @@ import java.util.Map;
public interface EDDataService {
/**
* 创建文件夹
*
* @param request
* @return
*/
@ -24,6 +25,7 @@ public interface EDDataService {
/**
* 获取文件信息列表
*
* @param request
* @return
*/
@ -31,6 +33,7 @@ public interface EDDataService {
/**
* 更新文件信息
*
* @param request
* @return
*/
@ -38,6 +41,7 @@ public interface EDDataService {
/**
* 获取子文件数量
*
* @param request
* @return
*/
@ -45,6 +49,7 @@ public interface EDDataService {
/**
* 上传
*
* @param request
* @return
*/
@ -60,6 +65,7 @@ public interface EDDataService {
/**
* 导出数据
*
* @param dataIdArr
* @return
*/
@ -67,6 +73,7 @@ public interface EDDataService {
/**
* 导入数据
*
* @param fileChunkDTO
* @return
*/
@ -74,6 +81,7 @@ public interface EDDataService {
/**
* 获取已经上传的分片
*
* @param identifier
* @return
*/
@ -82,6 +90,7 @@ public interface EDDataService {
/**
* 合并分片
*
* @param identifier
* @param fileName
* @param totalChunks
@ -92,6 +101,7 @@ public interface EDDataService {
/**
* 检查分片是否存在
*
* @param fileChunkDTO
* @return
*/

View File

@ -8,6 +8,7 @@ public interface TokenService {
/**
* 创建令牌
*
* @param loginInfo
* @return 令牌
*/
@ -15,6 +16,7 @@ public interface TokenService {
/**
* 创建用户令牌
*
* @param user
* @param tokenStr
* @return

View File

@ -7,6 +7,7 @@ public interface UserService {
/**
* 用户登录
*
* @param loginRequest
* @return
*/
@ -14,6 +15,7 @@ public interface UserService {
/**
* 新增用户信息
*
* @param userRequest
* @return
*/
@ -21,6 +23,7 @@ public interface UserService {
/**
* 编辑用户信息
*
* @param userModiRequest
* @return
*/
@ -29,6 +32,7 @@ public interface UserService {
/**
* 发布用户
*
* @param userPublishRequest
* @return
*/
@ -36,6 +40,7 @@ public interface UserService {
/**
* 校验工号唯一性
*
* @param workNumberRequest
* @return
*/
@ -43,6 +48,7 @@ public interface UserService {
/**
* 通过用户编码获取单条用户信息
*
* @param getSingleUserRequest
* @return
*/
@ -50,6 +56,7 @@ public interface UserService {
/**
* 查询用户信息
*
* @param searchUserRequest
* @return
*/
@ -57,6 +64,7 @@ public interface UserService {
/**
* 刪除用戶逻辑删除
*
* @param userDeleteRequest
* @return
*/
@ -64,6 +72,7 @@ public interface UserService {
/**
* 用户登出
*
* @param token
* @return
*/

View File

@ -39,6 +39,7 @@ public class CategoryServiceImpl implements CategoryService {
/**
* 递归列表
*
* @param list
* @param category
*/
@ -54,6 +55,7 @@ public class CategoryServiceImpl implements CategoryService {
/**
* 得到子节点列表
*
* @param list
* @param category
* @return
@ -72,6 +74,7 @@ public class CategoryServiceImpl implements CategoryService {
/**
* 判断是否有子节点
*
* @param list
* @param category
* @return

View File

@ -56,27 +56,23 @@ import java.util.stream.Collectors;
@Slf4j
public class EDDataServiceImpl implements EDDataService {
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
// 文件夹名称分隔符
private static final String FOLDER_NAME_SEPARATOR = "_";
@Resource
private EDDataMapper edDataMapper;
@Resource
private CategoryMapper categoryMapper;
@Value("${data.windows.path}")
private String uploadFilePath;
@Value("${data.file.storage.dir}")
private String fileStorageDir;
@Value("${data.import.cache.dir}")
private String importCacheDir;
@Value("${file.encode.passwd}")
private String encodePasswd;
@Value("${data.type.folder}")
private String dataTypeFolder;
@Value("${data.windows.path}")
private String windowsDir;
@Value("${data.file.cache.dir}")
@ -88,11 +84,6 @@ public class EDDataServiceImpl implements EDDataService {
@Value("${data.type.file}")
private String dataTypeFile;
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
// 文件夹名称分隔符
private static final String FOLDER_NAME_SEPARATOR = "_";
@Override
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
@ -123,8 +114,7 @@ public class EDDataServiceImpl implements EDDataService {
}
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception
{
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception {
// 获取上级目录的名称
String fileName = edDataInfo.getDataName();
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
@ -135,9 +125,7 @@ public class EDDataServiceImpl implements EDDataService {
if (categoryParentList.size() < 1) {
throw new Exception("上级文件夹不存在");
}
else
{
} else {
// 获取新文件夹路径信息
categoryParent = categoryParentList.get(0);
@ -149,8 +137,7 @@ public class EDDataServiceImpl implements EDDataService {
EDDataParams folderParames = new EDDataParams();
folderParames.setParentId(edDataInfo.getCategoryId());
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
for(EDDataInfo fileInfo : childFileInfoList)
{
for (EDDataInfo fileInfo : childFileInfoList) {
if (fileInfo.getDataName().equals(edDataInfo.getDataName())) {
throw new Exception("文件夹已存在");
}
@ -169,6 +156,7 @@ public class EDDataServiceImpl implements EDDataService {
/**
* 获取数据存储目录
*
* @return
*/
public String getDataStoragePath() {
@ -287,13 +275,10 @@ public class EDDataServiceImpl implements EDDataService {
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
parames.setDataId(null);
for (EDDataInfo edDataInfo : edDataInfoList) {
if(edDataInfo.getDataType().equals(dataTypeFolder))
{
if (edDataInfo.getDataType().equals(dataTypeFolder)) {
parames.setParentId(edDataInfo.getDataId());
childFileCount += getChildFileCount(parames);
}
else if(edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1))
{
} else if (edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1)) {
++childFileCount;
}
}
@ -337,8 +322,7 @@ public class EDDataServiceImpl implements EDDataService {
EDDataParams folderParames = new EDDataParams();
folderParames.setParentId(categoryId);
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
for(EDDataInfo fileInfo : childFileInfoList)
{
for (EDDataInfo fileInfo : childFileInfoList) {
if (fileInfo.getDataName().equals(fileFullName)) {
throw new Exception("上传的文件已存在");
}
@ -408,15 +392,12 @@ public class EDDataServiceImpl implements EDDataService {
fileParames.setDataId(edDataInfo.getDataId());
if(fileInput.getSize() == saveFile.length())
{
if (fileInput.getSize() == saveFile.length()) {
Path source = Paths.get(fileCacheFullPath);
Path target = Paths.get(fileSaveFullPath);
Files.move(source, target);
fileParames.setSaveStatus("success");
}
else
{
} else {
saveFile.delete();
fileParames.setSaveStatus("failure");
}
@ -439,6 +420,7 @@ public class EDDataServiceImpl implements EDDataService {
/**
* 获取时间戳字符串
*
* @return
*/
public String getTimeStampString() {
@ -448,6 +430,7 @@ public class EDDataServiceImpl implements EDDataService {
/**
* 获取数据缓存目录
*
* @return
*/
public String getDataCachePath() {
@ -486,8 +469,7 @@ public class EDDataServiceImpl implements EDDataService {
.body(new InputStreamResource(fileSystemResource.getInputStream()));
}
private String getFilePathOfFolder1(String categoryId)
{
private String getFilePathOfFolder1(String categoryId) {
String filePathOfFolder = ""; //文件存放在文件夹的路径
String categoryIdHighest = categoryId; //最高级的目录编码
@ -660,11 +642,9 @@ public class EDDataServiceImpl implements EDDataService {
}
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
}
catch (Exception e) {
} catch (Exception e) {
log.error("导出数据异常..", e);
}
finally {
} finally {
// 删除 导出数据的 缓存目录
FileUtil.del(exportDataCachePath);
}
@ -874,8 +854,7 @@ public class EDDataServiceImpl implements EDDataService {
&& FileUtil.exist(importFileCachePath)
&& FileUtil.exist(importFileCacheFullPath)
&& !FileUtil.exist(fileStorageFullPath)
)
{
) {
if (fileInfo.getDataType().equals(dataTypeFolder)) {
if (!FileUtil.exist(fileStorageFullPath)) {
FileUtil.mkdir(fileStorageFullPath);
@ -887,9 +866,7 @@ public class EDDataServiceImpl implements EDDataService {
}
importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
}
else
{
} else {
importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
}
}

View File

@ -28,7 +28,6 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -45,6 +44,7 @@ public class UserServiceImpl implements UserService {
/**
* 用户登录
*
* @param loginRequest
* @return
*/
@ -106,6 +106,7 @@ public class UserServiceImpl implements UserService {
/**
* 新增用户信息
*
* @param userRequest
* @return
*/
@ -124,6 +125,7 @@ public class UserServiceImpl implements UserService {
/**
* 修改用户信息
*
* @param userModiRequest
* @return
*/
@ -137,6 +139,7 @@ public class UserServiceImpl implements UserService {
/**
* 发布用户信息
*
* @param userPublishRequest
* @return
*/

View File

@ -9,15 +9,12 @@ loggerPath=electromagnetic-data
logging.level.com.aliyun.fsi.insurance=${LOG_LEVEL:INFO}
#日志配置
logging.config=classpath:${LOG_CONFIG:log4j2-spring.xml}
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://139.224.43.89:3306/em_data?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
spring.datasource.username=comac
spring.datasource.password=2024*Comac
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=10MB
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
@ -25,7 +22,6 @@ mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
pagehelper.helperDialect=mysql
pagehelper.reasonable=false
server.port=8888
#windows文件存储目录
data.windows.path=E:/comacFileStorage/
#文件缓存路径

View File

@ -4,7 +4,8 @@
<property name="LOG_LEVEL" value="INFO"/>
<property name="APP_NAME" value="electromagnetic-data"/>
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="LOG_LAYOUT"
value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
</properties>

View File

@ -4,7 +4,8 @@
<property name="LOG_LEVEL" value="DEBUG"/>
<property name="APP_NAME" value="electromagnetic-data"/>
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="LOG_LAYOUT"
value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
</properties>

View File

@ -18,8 +18,18 @@
</resultMap>
<sql id="selectUserVo">
select category_type_id, parent_id, category_id, category_name, category_status,
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
select category_type_id,
parent_id,
category_id,
category_name,
category_status,
creator,
creator_name,
gmt_create,
modifier,
modifier_name,
gmt_modified,
effect_flag
from ed_category
</sql>

View File

@ -28,7 +28,8 @@
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag"/>
</resultMap>
<sql id="Base_Column_list">
id,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
id
,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
implant_json,data_status,note,editor,gmt_batch_upload,save_status,creator,creator_name,gmt_create,modifier,modifier_name,
gmt_modified,effect_flag
</sql>
@ -51,7 +52,8 @@
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP}, #{saveStatus,jdbcType=VARCHAR},
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP},
#{saveStatus,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)

View File

@ -11,7 +11,8 @@
</resultMap>
<sql id="selectTokenVo">
select id, user_id, token, is_long_term, created_at, expire_at from tokens
select id, user_id, token, is_long_term, created_at, expire_at
from tokens
</sql>
<insert id="insert" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Token">
@ -37,7 +38,9 @@
</select>
<delete id="deleteToken" parameterType="String">
delete from tokens where token=#{token}
delete
from tokens
where token = #{token}
</delete>
</mapper>

View File

@ -25,9 +25,25 @@
</resultMap>
<sql id="selectUserVo">
select user_id, user_name, work_number, mobile, user_dept, user_title, user_pwd,
join_time, is_published, salt, user_status, internship_end_date,
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
select user_id,
user_name,
work_number,
mobile,
user_dept,
user_title,
user_pwd,
join_time,
is_published,
salt,
user_status,
internship_end_date,
creator,
creator_name,
gmt_create,
modifier,
modifier_name,
gmt_modified,
effect_flag
from ed_users
</sql>
@ -102,7 +118,8 @@
</foreach>
</update>
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultMap="UserResultMap">
<select id="search" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
resultMap="UserResultMap">
SELECT *
FROM ed_users
<where>
@ -146,7 +163,8 @@
LIMIT #{pageSize} OFFSET #{pageIndex}
</select>
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords" resultType="Integer">
<select id="getTotalCount" parameterType="com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords"
resultType="Integer">
SELECT COUNT(*)
FROM ed_users
<where>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>

View File

@ -6,15 +6,23 @@ package com.electromagnetic.industry.software.common.enums;
*/
public interface ErrorLevels {
/** INFO级别 */
/**
* INFO级别
*/
public static final String INFO = "1";
/** WARN级别 */
/**
* WARN级别
*/
public static final String WARN = "3";
/** ERROR级别 */
/**
* ERROR级别
*/
public static final String ERROR = "5";
/** FATAL级别 */
/**
* FATAL级别
*/
public static final String FATAL = "7";
}

View File

@ -2,17 +2,25 @@ package com.electromagnetic.industry.software.common.enums;
public interface ErrorTypes {
/** 系统错误 */
/**
* 系统错误
*/
public static final String SYSTEM = "0";
/** 业务错误 */
/**
* 业务错误
*/
@Deprecated
public static final String BIZ = "1";
/** 第三方错误 */
/**
* 第三方错误
*/
@Deprecated
public static final String THIRD_PARTY = "2";
/** 业务错误,客户感知 */
/**
* 业务错误客户感知
*/
public static final String BIZ_CUSTOMER = "9";
}

View File

@ -4,34 +4,52 @@ import java.io.Serializable;
public class ResultCode implements Serializable {
/** 序列ID */
private static final long serialVersionUID = 3951948353107763580L;
/** 结果码固定前缀 */
/**
* 结果码固定前缀
*/
protected static final String PREFIX = "CE";
/** 结果码版本 */
/**
* 序列ID
*/
private static final long serialVersionUID = 3951948353107763580L;
/**
* 结果码版本
*/
private String version;
/** 结果码级别[第9位]INFO-1,WARN-3,ERROR-5,FATAL-7参见<code>ResultCodeLevel</code>定义 */
/**
* 结果码级别[第9位]INFO-1,WARN-3,ERROR-5,FATAL-7参见<code>ResultCodeLevel</code>定义
*/
private String codeLevel;
/** 结果码类型[第10位]SUCCESS-0,BIZ_ERROR-1,SYS_ERROR-2,THIRD_ERROR-3参见<code>ResultCodeType</code>定义 */
/**
* 结果码类型[第10位]SUCCESS-0,BIZ_ERROR-1,SYS_ERROR-2,THIRD_ERROR-3参见<code>ResultCodeType</code>定义
*/
private String codeType;
/** 系统编号[第11-13位],见<code>SystemCode</code>定义 */
/**
* 系统编号[第11-13位]<code>SystemCode</code>定义
*/
private String systemCode;
/** 系统名称 */
/**
* 系统名称
*/
private String systemName;
/** 具体结果码[第14-17位] */
/**
* 具体结果码[第14-17位]
*/
private String errorSpecific;
/** 错误英文简称 */
/**
* 错误英文简称
*/
private String errorName;
/** 结果码信息描述,可空 */
/**
* 结果码信息描述可空
*/
private String description;
// ~~~ 构造方法

View File

@ -4,7 +4,6 @@ package com.electromagnetic.industry.software.common.util;
import cn.hutool.core.codec.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
@ -15,6 +14,7 @@ import java.security.Security;
/**
* <p>Description: [AES对称加密和解密]</p>
*
* @description:
* @author:
* @create: 2022/07/06 10:52
@ -24,6 +24,7 @@ public class AESUtils {
/**
* <p>Discription:[加密]</p>
* Created on 2022/07/06 10:52
*
* @param content 明文 用JSON.toJSONString(Map<String, String> map)转换的json字符串
* @param key 加解密规则 访客系统提供key
* @return String 密文
@ -72,6 +73,7 @@ public class AESUtils {
/**
* 前端使用ECB后端解密方法
*
* @param enc
* @param key
* @return

View File

@ -6,8 +6,6 @@ import java.net.NetworkInterface;
public class IdWorker {
private static IdWorker idWorker=new IdWorker();
// 时间起始标记点作为基准一般取系统的最近时间一旦确定不能变动
private final static long twepoch = 1288834974657L;
// 机器标识位数
@ -26,26 +24,24 @@ public class IdWorker {
private final static long datacenterIdShift = sequenceBits + workerIdBits;
// 时间毫秒左移22位
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
private static IdWorker idWorker = new IdWorker();
/* 上次生产id时间戳 */
private static long lastTimestamp = -1L;
// 0并发控制
private long sequence = 0L;
private final long workerId;
// 数据标识id部分
private final long datacenterId;
// 0并发控制
private long sequence = 0L;
public IdWorker() {
this.datacenterId = getDatacenterId(maxDatacenterId);
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
}
/**
* @param workerId
* 工作机器ID
* @param datacenterId
* 序列号
* @param workerId 工作机器ID
* @param datacenterId 序列号
*/
public IdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
@ -57,47 +53,6 @@ public class IdWorker {
this.workerId = workerId;
this.datacenterId = datacenterId;
}
/**
* 获取下一个ID
*
* @return
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
// 当前毫秒内+1
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
// 当前毫秒内计数满了则等待下一秒
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
// ID偏移组合生成最终的ID并返回ID
long nextId = ((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return nextId;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
/**
* <p>
@ -143,6 +98,7 @@ public class IdWorker {
}
return id;
}
public static long getSnowFlakeId() {
return idWorker.nextId();
}
@ -151,4 +107,46 @@ public class IdWorker {
return String.valueOf(getSnowFlakeId());
}
/**
* 获取下一个ID
*
* @return
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
// 当前毫秒内+1
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
// 当前毫秒内计数满了则等待下一秒
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
// ID偏移组合生成最终的ID并返回ID
long nextId = ((timestamp - twepoch) << timestampLeftShift)
| (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return nextId;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
}

View File

@ -55,16 +55,12 @@ public class SignUtils {
}
public static Boolean equals(String v1, String v2) {
if (v1 == null && v2 == null)
{
if (v1 == null && v2 == null) {
return true;
}
if (v1 != null && v2 != null && v1.equals(v2))
{
if (v1 != null && v2 != null && v1.equals(v2)) {
return true;
}
else
{
} else {
return false;
}
}
@ -73,21 +69,15 @@ public class SignUtils {
String temp = null;
if (params.get(key) == null) {
return defaultValue;
}
else if(params.get(key).getClass().isArray())
{
} else if (params.get(key).getClass().isArray()) {
temp = getArray(params, key)[0];
}
else
{
} else {
temp = params.get(key).toString();
}
if (temp != null) {
temp = temp.replaceAll("%", "\\%");
}
if(temp==null)
{
if (temp == null) {
return defaultValue;
}
return temp;