Compare commits

...

3 Commits

Author SHA1 Message Date
zhangxing 3216a7ec45 energy-biz-anomaly和energy-biz-appraise服务改造 2026-08-28 17:02:21 +08:00
zhangxing 807070f777 index修改完成 2026-08-28 16:38:24 +08:00
zhangxing fc8dd86ff1 加一下公共类替代之前私有包中的类 2026-08-28 14:43:42 +08:00
43 changed files with 1708 additions and 50 deletions

22
AGENTS.md Normal file
View File

@ -0,0 +1,22 @@
# 项目协作规则
## Git 操作
- 允许并要求将本次任务新增或修改的文件直接执行 `git add`,无需再次询问用户。
- 禁止自动创建 Git 提交、推送分支或创建 Pull Request。
- Git 提交及所有远程发布操作必须由用户本人执行。
- 允许执行只读 Git 操作,例如查看状态、差异、日志和分支。
## 代码格式
- 新增或修改代码后必须完成格式化,再进行编译验证和 `git add`
- Java 代码使用 4 个空格缩进;注解、字段、方法及每条语句独立成行,禁止把多个声明或方法压缩在同一行。
- import 按项目现有风格整理并删除重复、无用的 import保持类、方法和泛型声明具有正常的空格与换行。
## 数据库操作
- 项目数据库为 Oracle连接地址为 `jdbc:oracle:thin:@//192.168.1.102:1521/ORCLPDB`,用户及默认 Schema 为 `ENERGYX`
- 允许直接执行只读查询,用于查看数据库结构、表数据、索引、约束和执行计划。
- 禁止未经用户明确允许执行任何 DDL包括创建、修改、删除或截断数据库对象。
- 禁止未经用户明确允许执行任何数据写入,包括 `INSERT`、`UPDATE`、`DELETE`、`MERGE` 以及存储过程产生的写操作。
- 数据库密码不得写入项目文件、日志或提交记录。

View File

@ -0,0 +1,5 @@
# energy-framework-compat
该模块只保存旧私有框架 API 的兼容壳,目的是让业务模块保持原包名和调用方式完成迁移。
所有标有 `TODO 原框架实现待迁移` 的方法都需要从原项目核对并补回。依赖登录上下文、租户、日志切面和导出行为的方法不得把当前占位实现视为正式业务实现。

View File

@ -0,0 +1,56 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springenergy</groupId>
<artifactId>EnergyX</artifactId>
<version>${revision}</version>
</parent>
<artifactId>energy-framework-compat</artifactId>
<name>${project.artifactId}</name>
<description>旧私有框架类的迁移壳;实现需要从原项目逐项补回</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-models.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
package org.springenergy.common.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
//已经根据原始依赖补齐逻辑
public class BaseIds implements Serializable {
private static final long serialVersionUID = -5061707315531209798L;
private List<Long> ids;
}

View File

@ -0,0 +1,5 @@
package org.springenergy.core.boot.ctrl;
/** 已经根据原始依赖补齐逻辑 */
public class EnergyController {
}

View File

@ -0,0 +1,68 @@
package org.springenergy.core.excel.util;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.handler.WriteHandler;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* 使用公共 EasyExcel 实现的 Excel 导出工具
*
* <p>保留旧框架的包名和导出方法签名业务模块无需修改</p>
* 已经根据原始依赖补齐逻辑
*/
public final class ExcelUtil {
private static final String XLSX_CONTENT_TYPE =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
private ExcelUtil() {
}
public static <T> void export(HttpServletResponse response, List<T> dataList, Class<T> clazz) {
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
export(response, fileName, "导出数据", dataList, clazz);
}
public static <T> void export(HttpServletResponse response, String fileName, String sheetName,
List<T> dataList, Class<T> clazz) {
write(response, fileName, sheetName, dataList, null, clazz);
}
public static <T> void export(HttpServletResponse response, String fileName, String sheetName,
List<T> dataList, WriteHandler writeHandler, Class<T> clazz) {
write(response, fileName, sheetName, dataList, writeHandler, clazz);
}
private static <T> void write(HttpServletResponse response, String fileName, String sheetName,
List<T> dataList, WriteHandler writeHandler, Class<T> clazz) {
try {
response.setContentType(XLSX_CONTENT_TYPE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name())
.replace("+", "%20");
response.setHeader(
"Content-Disposition",
"attachment;filename=" + encodedFileName + ".xlsx;filename*=UTF-8''"
+ encodedFileName + ".xlsx"
);
ExcelWriterBuilder writerBuilder = EasyExcel
.write(response.getOutputStream(), clazz)
.autoCloseStream(false);
if (writeHandler != null) {
writerBuilder.registerWriteHandler(writeHandler);
}
writerBuilder.sheet(sheetName).doWrite(dataList);
} catch (Exception exception) {
throw new IllegalStateException("Excel 导出失败", exception);
}
}
}

View File

@ -0,0 +1,15 @@
package org.springenergy.core.log.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
//已经根据原始依赖补齐逻辑
public @interface ApiLog {
String value() default "";
}

View File

@ -0,0 +1,55 @@
package org.springenergy.core.mp.base;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
//已经根据原始依赖补齐逻辑
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("主键id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("创建人")
private Long createUser;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("创建部门")
private Long createDept;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
private Date createTime;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("更新人")
private Long updateUser;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("业务状态")
private Integer status;
@TableLogic
@ApiModelProperty("是否已删除")
private Integer isDeleted;
}

View File

@ -0,0 +1,15 @@
package org.springenergy.core.mp.base;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import javax.validation.constraints.NotEmpty;
//已经根据原始依赖补齐逻辑
public interface BaseService<T> extends IService<T> {
boolean deleteLogic(@NotEmpty List<Long> ids);
boolean changeStatus(@NotEmpty List<Long> ids, Integer status);
}

View File

@ -0,0 +1,146 @@
package org.springenergy.core.mp.base;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import org.springenergy.core.secure.EnergyUser;
import org.springenergy.core.secure.utils.AuthUtil;
import org.springenergy.core.tool.utils.BeanUtil;
import org.springenergy.core.tool.utils.DateUtil;
import org.springenergy.core.tool.utils.Func;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@Validated
//已经根据原始依赖补齐逻辑
public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity>
extends ServiceImpl<M, T> implements BaseService<T> {
@Override
public boolean save(T entity) {
resolveEntity(entity);
return super.save(entity);
}
@Override
public boolean saveBatch(Collection<T> entityList, int batchSize) {
entityList.forEach(this::resolveEntity);
return super.saveBatch(entityList, batchSize);
}
@Override
public boolean updateById(T entity) {
resolveEntity(entity);
return super.updateById(entity);
}
@Override
public boolean updateBatchById(Collection<T> entityList, int batchSize) {
entityList.forEach(this::resolveEntity);
return super.updateBatchById(entityList, batchSize);
}
@Override
public boolean saveOrUpdate(T entity) {
return entity.getId() == null ? save(entity) : updateById(entity);
}
@Override
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
entityList.forEach(this::resolveEntity);
return super.saveOrUpdateBatch(entityList, batchSize);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteLogic(@NotEmpty List<Long> ids) {
EnergyUser user = AuthUtil.getUser();
List<T> entities = new ArrayList<>(ids.size());
for (Long id : ids) {
T entity = BeanUtil.newInstance(currentModelClass());
if (user != null) {
entity.setUpdateUser(user.getUserId());
}
entity.setUpdateTime(DateUtil.now());
entity.setId(id);
entities.add(entity);
}
return super.updateBatchById(entities) && super.removeByIds(ids);
}
@Override
public boolean changeStatus(@NotEmpty List<Long> ids, Integer status) {
EnergyUser user = AuthUtil.getUser();
List<T> entities = new ArrayList<>(ids.size());
for (Long id : ids) {
T entity = BeanUtil.newInstance(currentModelClass());
if (user != null) {
entity.setUpdateUser(user.getUserId());
}
entity.setUpdateTime(DateUtil.now());
entity.setId(id);
entity.setStatus(status);
entities.add(entity);
}
return super.updateBatchById(entities);
}
private void resolveEntity(T entity) {
EnergyUser user = AuthUtil.getUser();
Date now = DateUtil.now();
if (entity.getId() == null) {
if (user != null) {
entity.setCreateUser(user.getUserId());
entity.setCreateDept(Func.firstLong(user.getDeptId()));
entity.setUpdateUser(user.getUserId());
}
if (entity.getStatus() == null) {
entity.setStatus(1);
}
entity.setCreateTime(now);
} else if (user != null) {
entity.setUpdateUser(user.getUserId());
}
entity.setUpdateTime(now);
entity.setIsDeleted(0);
resolveTenantId(entity);
}
private void resolveTenantId(T entity) {
Field tenantIdField = findField(entity.getClass(), "tenantId");
if (tenantIdField == null) {
return;
}
try {
Method getter = entity.getClass().getMethod("getTenantId");
Object tenantId = getter.invoke(entity);
if (tenantId == null || tenantId.toString().trim().isEmpty()) {
Method setter = entity.getClass().getMethod("setTenantId", String.class);
setter.invoke(entity, new Object[] {null});
}
} catch (ReflectiveOperationException exception) {
throw new IllegalStateException("处理实体 tenantId 字段失败", exception);
}
}
private Field findField(Class<?> type, String fieldName) {
Class<?> currentType = type;
while (currentType != null) {
try {
return currentType.getDeclaredField(fieldName);
} catch (NoSuchFieldException ignored) {
currentType = currentType.getSuperclass();
}
}
return null;
}
}

View File

@ -0,0 +1,27 @@
package org.springenergy.core.mp.support;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.stream.Collectors;
public abstract class BaseEntityWrapper<E, V> {
public BaseEntityWrapper() {
}
public abstract V entityVO(E entity);
public List<V> listVO(List<E> list) {
return (List)list.stream().map(this::entityVO).collect(Collectors.toList());
}
public IPage<V> pageVO(IPage<E> pages) {
List<V> records = this.listVO(pages.getRecords());
IPage<V> pageVo = new Page(pages.getCurrent(), pages.getSize(), pages.getTotal());
pageVo.setRecords(records);
return pageVo;
}
}

View File

@ -0,0 +1,55 @@
package org.springenergy.core.mp.support;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map;
import org.springenergy.core.tool.support.Kv;
import org.springenergy.core.tool.utils.BeanUtil;
import org.springenergy.core.tool.utils.Func;
import org.springenergy.core.tool.utils.StringUtil;
public final class Condition {
private Condition() {
}
public static <T> IPage<T> getPage(Query query) {
Page<T> page = new Page<>(Func.toInt(query.getCurrent(), 1), Func.toInt(query.getSize(), 10));
String[] ascArray = Func.toStrArray(query.getAscs());
for (String asc : ascArray) {
page.addOrder(OrderItem.asc(StringUtil.cleanIdentifier(asc)));
}
String[] descArray = Func.toStrArray(query.getDescs());
for (String desc : descArray) {
page.addOrder(OrderItem.desc(StringUtil.cleanIdentifier(desc)));
}
return page;
}
public static <T> QueryWrapper<T> getQueryWrapper(T entity) {
return new QueryWrapper<>(entity);
}
public static <T> QueryWrapper<T> getQueryWrapper(Map<String, Object> query, Class<T> type) {
Kv exclude = Kv.create()
.set("Energy-Auth", "Energy-Auth")
.set("current", "current")
.set("size", "size")
.set("ascs", "ascs")
.set("descs", "descs");
return getQueryWrapper(query, exclude, type);
}
public static <T> QueryWrapper<T> getQueryWrapper(
Map<String, Object> query, Map<String, Object> exclude, Class<T> type) {
exclude.forEach((key, value) -> query.remove(key));
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(BeanUtil.newInstance(type));
SqlKeyword.buildCondition(query, queryWrapper);
return queryWrapper;
}
}

View File

@ -0,0 +1,45 @@
package org.springenergy.core.mp.support;
public class Query {
private Integer current = 1;
private Integer size = 10;
private String ascs;
private String descs;
public Integer getCurrent() {
return current;
}
public Query setCurrent(Integer current) {
this.current = current;
return this;
}
public Integer getSize() {
return size;
}
public Query setSize(Integer size) {
this.size = size;
return this;
}
public String getAscs() {
return ascs;
}
public Query setAscs(String ascs) {
this.ascs = ascs;
return this;
}
public String getDescs() {
return descs;
}
public Query setDescs(String descs) {
this.descs = descs;
return this;
}
}

View File

@ -0,0 +1,96 @@
package org.springenergy.core.mp.support;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Map;
import java.util.regex.Pattern;
import org.springenergy.core.tool.utils.DateUtil;
import org.springenergy.core.tool.utils.Func;
import org.springenergy.core.tool.utils.StringUtil;
public final class SqlKeyword {
private static final String SQL_REGEX =
"(?i)(?<![a-z])('|%|--|insert|delete|select|sleep|count|updatexml|group|union|drop|truncate|alter|grant|execute|exec|xp_cmdshell|call|declare|sql)(?![a-z])";
private static final Pattern PATTERN = Pattern.compile(
"(?:--|[\"';%]|\\binsert\\b|\\bdelete\\b|\\bselect\\b|\\bcount\\b|\\bupdatexml\\b|\\bsleep\\b|group\\s+by|\\bunion\\b|\\bdrop\\b|\\btruncate\\b|\\balter\\b|\\bgrant\\b|\\bexecute\\b|\\bxp_cmdshell\\b|\\bcall\\b|\\bdeclare\\b|\\bsql\\b)");
private static final String SQL_INJECTION_MESSAGE =
"SQL keyword injection prevention processing!";
private static final String DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
private SqlKeyword() {
}
public static void buildCondition(Map<String, Object> query, QueryWrapper<?> wrapper) {
if (Func.isEmpty(query)) {
return;
}
query.forEach((key, value) -> addCondition(key, value, wrapper));
}
private static void addCondition(String key, Object value, QueryWrapper<?> wrapper) {
if (Func.hasEmpty(key, value) || key.endsWith("_ignore")) {
return;
}
String filteredKey = filter(key);
if (filteredKey.endsWith("_equal")) {
wrapper.eq(getColumn(filteredKey, "_equal"), value);
} else if (filteredKey.endsWith("_notequal")) {
wrapper.ne(getColumn(filteredKey, "_notequal"), value);
} else if (filteredKey.endsWith("_likeleft")) {
wrapper.likeLeft(getColumn(filteredKey, "_likeleft"), value);
} else if (filteredKey.endsWith("_likeright")) {
wrapper.likeRight(getColumn(filteredKey, "_likeright"), value);
} else if (filteredKey.endsWith("_notlike")) {
wrapper.notLike(getColumn(filteredKey, "_notlike"), value);
} else if (filteredKey.endsWith("_ge")) {
wrapper.ge(getColumn(filteredKey, "_ge"), value);
} else if (filteredKey.endsWith("_le")) {
wrapper.le(getColumn(filteredKey, "_le"), value);
} else if (filteredKey.endsWith("_gt")) {
wrapper.gt(getColumn(filteredKey, "_gt"), value);
} else if (filteredKey.endsWith("_lt")) {
wrapper.lt(getColumn(filteredKey, "_lt"), value);
} else if (filteredKey.endsWith("_datege")) {
wrapper.ge(getColumn(filteredKey, "_datege"), parseDate(value));
} else if (filteredKey.endsWith("_dategt")) {
wrapper.gt(getColumn(filteredKey, "_dategt"), parseDate(value));
} else if (filteredKey.endsWith("_dateequal")) {
wrapper.eq(getColumn(filteredKey, "_dateequal"), parseDate(value));
} else if (filteredKey.endsWith("_datele")) {
wrapper.le(getColumn(filteredKey, "_datele"), parseDate(value));
} else if (filteredKey.endsWith("_datelt")) {
wrapper.lt(getColumn(filteredKey, "_datelt"), parseDate(value));
} else if (filteredKey.endsWith("_null")) {
wrapper.isNull(getColumn(filteredKey, "_null"));
} else if (filteredKey.endsWith("_notnull")) {
wrapper.isNotNull(getColumn(filteredKey, "_notnull"));
} else {
wrapper.like(getColumn(filteredKey, "_like"), value);
}
}
private static Object parseDate(Object value) {
return DateUtil.parse(String.valueOf(value), DATE_PATTERN);
}
private static String getColumn(String column, String keyword) {
return StringUtil.humpToUnderline(StringUtil.removeSuffix(column, keyword));
}
public static String filter(String parameter) {
if (parameter == null) {
return null;
}
String sql = parameter.replaceAll(SQL_REGEX, "");
if (match(sql)) {
throw new IllegalArgumentException(SQL_INJECTION_MESSAGE);
}
return sql;
}
public static boolean match(String parameter) {
return Func.isNotEmpty(parameter) && PATTERN.matcher(parameter).find();
}
}

View File

@ -0,0 +1,44 @@
package org.springenergy.core.secure;
import java.io.Serializable;
/** TODO 与接入系统登录用户模型对接。 */
public class EnergyUser implements Serializable {
private String tenantId;
private String corpId;
private Long userId;
private String deptId;
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getCorpId() {
return corpId;
}
public void setCorpId(String corpId) {
this.corpId = corpId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
}

View File

@ -0,0 +1,31 @@
package org.springenergy.core.secure.utils;
import org.springenergy.core.secure.EnergyUser;
public final class AuthUtil {
private static final ThreadLocal<EnergyUser> USER_HOLDER = new ThreadLocal<>();
private AuthUtil() {
}
public static String getCorpId() {
throw new UnsupportedOperationException("TODO 与接入系统认证上下文对接 AuthUtil.getCorpId");
}
public static EnergyUser getUser() {
return USER_HOLDER.get();
}
public static void setUser(EnergyUser user) {
if (user == null) {
USER_HOLDER.remove();
} else {
USER_HOLDER.set(user);
}
}
public static void clear() {
USER_HOLDER.remove();
}
}

View File

@ -0,0 +1,13 @@
package org.springenergy.core.tenant.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NonDS {
}

View File

@ -0,0 +1,17 @@
package org.springenergy.core.tenant.mp;
import org.springenergy.core.mp.base.BaseEntity;
/** TODO 租户字段与拦截策略待迁移。 */
public class TenantEntity extends BaseEntity {
private String tenantId;
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
}

View File

@ -0,0 +1,94 @@
package org.springenergy.core.tool.api;
import java.io.Serializable;
/** TODO 原框架实现待迁移。 */
public class R<T> implements Serializable {
private static final long serialVersionUID = 1L;
private int code;
private boolean success;
private T data;
private String msg;
public static <T> R<T> data(T data) {
return data(data, null);
}
public static <T> R<T> data(T data, String msg) {
R<T> result = new R<>();
result.code = 200;
result.success = true;
result.data = data;
result.msg = msg;
return result;
}
public static <T> R<T> data(int code, T data, String msg) {
R<T> result = data(data, msg);
result.code = code;
result.success = code >= 200 && code < 300;
return result;
}
public static <T> R<T> success(String msg) {
return data(null, msg);
}
public static <T> R<T> fail(String msg) {
return fail(500, msg);
}
public static <T> R<T> fail(int code, String msg) {
R<T> result = new R<>();
result.code = code;
result.success = false;
result.msg = msg;
return result;
}
public static <T> R<T> status(boolean status) {
return status ? success("success") : fail("failure");
}
public static boolean isSuccess(R<?> result) {
return result != null && result.isSuccess();
}
public static boolean isNotSuccess(R<?> result) {
return !isSuccess(result);
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}

View File

@ -0,0 +1,8 @@
package org.springenergy.core.tool.constant;
/** TODO 核对原框架常量值。 */
public interface EnergyConstant {
int DB_NOT_DELETED = 0;
int DB_IS_DELETED = 1;
}

View File

@ -0,0 +1,110 @@
package org.springenergy.core.tool.support;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springenergy.core.tool.utils.Func;
import org.springframework.util.LinkedCaseInsensitiveMap;
public class Kv extends LinkedCaseInsensitiveMap<Object> {
private static final long serialVersionUID = 1L;
private Kv() {
}
public static Kv create() {
return new Kv();
}
public static <K, V> HashMap<K, V> newMap() {
return new HashMap<>(16);
}
public Kv set(String attribute, Object value) {
put(attribute, value);
return this;
}
public Kv setAll(Map<? extends String, ?> map) {
if (map != null) {
putAll(map);
}
return this;
}
public Kv setIgnoreNull(String attribute, Object value) {
if (attribute != null && value != null) {
set(attribute, value);
}
return this;
}
public Object getObj(String key) {
return get(key);
}
public <T> T get(String attribute, T defaultValue) {
Object result = get(attribute);
if (result == null) {
return defaultValue;
}
@SuppressWarnings("unchecked")
T value = (T) result;
return value;
}
public String getStr(String attribute) {
return Func.toStr(get(attribute), null);
}
public Integer getInt(String attribute) {
return Func.toInt(get(attribute), -1);
}
public Long getLong(String attribute) {
return Func.toLong(get(attribute), -1L);
}
public Float getFloat(String attribute) {
return Func.toFloat(get(attribute), null);
}
public Double getDouble(String attribute) {
return Func.toDouble(get(attribute), null);
}
public Boolean getBool(String attribute) {
return Func.toBoolean(get(attribute), null);
}
public byte[] getBytes(String attribute) {
return get(attribute, (byte[]) null);
}
public Date getDate(String attribute) {
return get(attribute, (Date) null);
}
public Time getTime(String attribute) {
return get(attribute, (Time) null);
}
public Timestamp getTimestamp(String attribute) {
return get(attribute, (Timestamp) null);
}
public Number getNumber(String attribute) {
return get(attribute, (Number) null);
}
@Override
public Kv clone() {
Kv clone = new Kv();
clone.putAll(this);
return clone;
}
}

View File

@ -0,0 +1,45 @@
package org.springenergy.core.tool.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class BeanUtil extends org.springframework.beans.BeanUtils {
public static <T> T newInstance(Class<T> type) {
try {
return type.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException exception) {
throw new IllegalStateException("无法创建实例: " + type.getName(), exception);
}
}
public static <T> T copy(Object source, Class<T> type) {
if (source == null) {
return null;
}
try {
T target = type.getDeclaredConstructor().newInstance();
copyProperties(source, target);
return target;
} catch (ReflectiveOperationException exception) {
throw new IllegalStateException("TODO 核对原框架 BeanUtil.copy 行为", exception);
}
}
public static <T> List<T> copyToList(Collection<?> source, Class<T> type) {
List<T> result = new ArrayList<>(source.size());
for (Object item : source) {
result.add(copy(item, type));
}
return result;
}
@SuppressWarnings("unchecked")
public static <T> T clone(T source) {
if (source == null) {
return null;
}
return (T) copy(source, source.getClass());
}
}

View File

@ -0,0 +1,174 @@
package org.springenergy.core.tool.utils;
import cn.hutool.core.date.DateTime;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalQuery;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/** Compatibility facade for the original date API. */
public final class DateUtil {
public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";
public static final String PATTERN_DATETIME_MINI = "yyyyMMddHHmmss";
public static final String PATTERN_DATE = "yyyy-MM-dd";
public static final String PATTERN_TIME = "HH:mm:ss";
public static final DateTimeFormatter DATETIME_FORMATTER =
DateTimeFormatter.ofPattern(PATTERN_DATETIME);
public static final DateTimeFormatter DATETIME_MINI_FORMATTER =
DateTimeFormatter.ofPattern(PATTERN_DATETIME_MINI);
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(PATTERN_DATE);
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(PATTERN_TIME);
private DateUtil() {
}
public static Date now() {
return new Date();
}
public static Date plusYears(Date date, int amount) {
return cn.hutool.core.date.DateUtil.offsetMonth(date, amount * 12);
}
public static Date plusMonths(Date date, int amount) {
return cn.hutool.core.date.DateUtil.offsetMonth(date, amount);
}
public static Date plusWeeks(Date date, int amount) {
return cn.hutool.core.date.DateUtil.offsetWeek(date, amount);
}
public static Date plusDays(Date date, long amount) {
return Date.from(date.toInstant().plus(Duration.ofDays(amount)));
}
public static Date plusHours(Date date, long amount) {
return Date.from(date.toInstant().plus(Duration.ofHours(amount)));
}
public static Date plusMinutes(Date date, long amount) {
return Date.from(date.toInstant().plus(Duration.ofMinutes(amount)));
}
public static Date plusSeconds(Date date, long amount) {
return Date.from(date.toInstant().plus(Duration.ofSeconds(amount)));
}
public static Date plusMillis(Date date, long amount) {
return Date.from(date.toInstant().plusMillis(amount));
}
public static Date plus(Date date, TemporalAmount amount) {
return Date.from(date.toInstant().plus(amount));
}
public static Date minusDays(Date date, long amount) {
return plusDays(date, -amount);
}
public static String formatDateTime(Date date) {
return format(date, PATTERN_DATETIME);
}
public static String formatDateTimeMini(Date date) {
return format(date, PATTERN_DATETIME_MINI);
}
public static String formatDate(Date date) {
return format(date, PATTERN_DATE);
}
public static String formatTime(Date date) {
return format(date, PATTERN_TIME);
}
public static String format(Date date, String pattern) {
return cn.hutool.core.date.DateUtil.format(date, pattern);
}
public static String format(TemporalAccessor temporal, String pattern) {
return DateTimeFormatter.ofPattern(pattern).format(temporal);
}
public static Date parse(String value, String pattern) {
DateTime parsed = cn.hutool.core.date.DateUtil.parse(value, pattern);
return new Date(parsed.getTime());
}
public static <T> T parse(String value, String pattern, TemporalQuery<T> query) {
return DateTimeFormatter.ofPattern(pattern).parse(value, query);
}
public static Instant toInstant(LocalDateTime value) {
return value.atZone(ZoneId.systemDefault()).toInstant();
}
public static LocalDateTime toDateTime(Instant value) {
return LocalDateTime.ofInstant(value, ZoneId.systemDefault());
}
public static Date toDate(LocalDateTime value) {
return Date.from(toInstant(value));
}
public static Date toDate(LocalDate value) {
return Date.from(value.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
public static Calendar toCalendar(LocalDateTime value) {
return GregorianCalendar.from(value.atZone(ZoneId.systemDefault()));
}
public static LocalDateTime fromDate(Date value) {
return LocalDateTime.ofInstant(value.toInstant(), ZoneId.systemDefault());
}
public static Duration between(Temporal startInclusive, Temporal endExclusive) {
return Duration.between(startInclusive, endExclusive);
}
public static Period between(LocalDate startDate, LocalDate endDate) {
return Period.between(startDate, endDate);
}
public static Duration between(Date startDate, Date endDate) {
return Duration.between(startDate.toInstant(), endDate.toInstant());
}
public static String secondToTime(Long seconds) {
if (seconds == null || seconds == 0L) {
return "";
}
long days = seconds / 86400L;
long remaining = seconds % 86400L;
long hours = remaining / 3600L;
remaining %= 3600L;
long minutes = remaining / 60L;
long secs = remaining % 60L;
if (days > 0L) {
return StringUtil.format("{}天{}小时{}分{}秒", days, hours, minutes, secs);
}
return StringUtil.format("{}小时{}分{}秒", hours, minutes, secs);
}
public static String today() {
return format(now(), "yyyyMMdd");
}
public static String time() {
return format(now(), PATTERN_DATETIME_MINI);
}
}

View File

@ -0,0 +1,194 @@
package org.springenergy.core.tool.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/** Compatibility facade for the original framework utility methods used by business modules. */
public final class Func {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private Func() {
}
public static boolean isEmpty(Object value) {
return ObjectUtil.isEmpty(value);
}
public static boolean isNotEmpty(Object value) {
return ObjectUtil.isNotEmpty(value);
}
public static boolean isBlank(CharSequence value) {
return StrUtil.isBlank(value);
}
public static boolean isNotBlank(CharSequence value) {
return StrUtil.isNotBlank(value);
}
public static boolean notNull(Object value) {
return value != null;
}
public static boolean hasEmpty(Object... values) {
if (values == null) {
return true;
}
for (Object value : values) {
if (isEmpty(value)) {
return true;
}
}
return false;
}
public static boolean equals(Object first, Object second) {
return Objects.equals(first, second);
}
public static boolean equalsSafe(Object first, Object second) {
return Objects.deepEquals(first, second);
}
public static <T> boolean contains(T[] values, T value) {
return values != null && Arrays.asList(values).contains(value);
}
public static String toStr(Object value) {
return toStr(value, "");
}
public static String toStr(Object value, String defaultValue) {
return value == null || "null".equals(value) ? defaultValue : String.valueOf(value);
}
public static String toStrWithEmpty(Object value, String defaultValue) {
String result = toStr(value, defaultValue);
return result.isEmpty() ? defaultValue : result;
}
public static int toInt(Object value) {
return toInt(value, 0);
}
public static int toInt(Object value, int defaultValue) {
return Convert.toInt(value, defaultValue);
}
public static long toLong(Object value) {
return toLong(value, 0L);
}
public static long toLong(Object value, long defaultValue) {
return Convert.toLong(value, defaultValue);
}
public static Double toDouble(Object value) {
return toDouble(value, -1D);
}
public static Double toDouble(Object value, Double defaultValue) {
return Convert.toDouble(value, defaultValue);
}
public static Float toFloat(Object value, Float defaultValue) {
return Convert.toFloat(value, defaultValue);
}
public static Boolean toBoolean(Object value, Boolean defaultValue) {
return Convert.toBool(value, defaultValue);
}
public static Long[] toLongArray(String value) {
return toLongArray(",", value);
}
public static Long[] toLongArray(String separator, String value) {
if (StrUtil.isBlank(value)) {
return new Long[0];
}
String[] values = value.split(separator);
Long[] result = new Long[values.length];
for (int index = 0; index < values.length; index++) {
result[index] = toLong(values[index].trim(), 0L);
}
return result;
}
public static List<Long> toLongList(String value) {
return Arrays.asList(toLongArray(value));
}
public static List<Long> toLongList(String separator, String value) {
return Arrays.asList(toLongArray(separator, value));
}
public static Long firstLong(String value) {
List<Long> values = toLongList(value);
return values.isEmpty() ? null : values.get(0);
}
public static String[] toStrArray(String value) {
return toStrArray(",", value);
}
public static String[] toStrArray(String separator, String value) {
return StrUtil.isBlank(value) ? new String[0] : value.split(separator);
}
public static List<String> toStrList(String value) {
return Arrays.asList(toStrArray(value));
}
public static List<String> toStrList(String separator, String value) {
return Arrays.asList(toStrArray(separator, value));
}
public static String join(Collection<?> values) {
return CollUtil.join(values, ",");
}
public static String join(Collection<?> values, String separator) {
return CollUtil.join(values, separator);
}
public static String format(String template, Object... arguments) {
return StrUtil.format(template, arguments);
}
public static String randomUUID() {
return IdUtil.fastSimpleUUID();
}
public static <T> T copy(Object source, Class<T> type) {
return BeanUtil.copy(source, type);
}
public static <T> T readJson(String json, Class<T> type) {
try {
return OBJECT_MAPPER.readValue(json, type);
} catch (IOException exception) {
throw new IllegalArgumentException("JSON parsing failed", exception);
}
}
public static <T> T readJson(String json, TypeReference<T> type) {
try {
return OBJECT_MAPPER.readValue(json, type);
} catch (IOException exception) {
throw new IllegalArgumentException("JSON parsing failed", exception);
}
}
}

View File

@ -0,0 +1,8 @@
package org.springenergy.core.tool.utils;
public enum RandomType {
INT,
STRING,
ALL,
CHAR
}

View File

@ -0,0 +1,120 @@
package org.springenergy.core.tool.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import java.util.Collection;
import java.util.Locale;
import java.util.regex.Pattern;
/** Compatibility facade backed by Hutool and the JDK. */
public final class StringUtil {
private static final Pattern SAFE_IDENTIFIER = Pattern.compile("[A-Za-z0-9_.$]+");
private StringUtil() {
}
public static boolean isEmpty(CharSequence value) {
return StrUtil.isEmpty(value);
}
public static boolean isBlank(CharSequence value) {
return StrUtil.isBlank(value);
}
public static boolean isNotBlank(CharSequence value) {
return StrUtil.isNotBlank(value);
}
public static boolean isAllBlank(CharSequence... values) {
return StrUtil.isAllBlank(values);
}
public static boolean isNoneBlank(CharSequence... values) {
return !StrUtil.hasBlank(values);
}
public static boolean equals(CharSequence first, CharSequence second) {
return StrUtil.equals(first, second);
}
public static boolean equalsIgnoreCase(CharSequence first, CharSequence second) {
return StrUtil.equalsIgnoreCase(first, second);
}
public static boolean startsWithIgnoreCase(CharSequence value, CharSequence prefix) {
return StrUtil.startWithIgnoreCase(value, prefix);
}
public static boolean endsWithIgnoreCase(CharSequence value, CharSequence suffix) {
return StrUtil.endWithIgnoreCase(value, suffix);
}
public static String firstCharToUpper(String value) {
return StrUtil.upperFirst(value);
}
public static String firstCharToLower(String value) {
return StrUtil.lowerFirst(value);
}
public static String format(String template, Object... arguments) {
return StrUtil.format(template, arguments);
}
public static String join(Collection<?> values) {
return CollUtil.join(values, ",");
}
public static String join(Collection<?> values, String separator) {
return CollUtil.join(values, separator);
}
public static String randomUUID() {
return IdUtil.fastSimpleUUID();
}
public static String random(int length) {
return RandomUtil.randomString(length);
}
public static String random(int length, RandomType type) {
if (type == RandomType.INT) {
return RandomUtil.randomNumbers(length);
}
if (type == RandomType.CHAR) {
return RandomUtil.randomStringWithoutStr(length, "0123456789");
}
return RandomUtil.randomString(length);
}
public static String removePrefix(String value, String prefix) {
return StrUtil.removePrefix(value, prefix);
}
public static String removeSuffix(String value, String suffix) {
return StrUtil.removeSuffix(value, suffix);
}
public static String toString(Object value) {
return value == null ? null : String.valueOf(value);
}
public static String humpToUnderline(String value) {
return StrUtil.toUnderlineCase(value);
}
public static String cleanIdentifier(String identifier) {
if (isBlank(identifier)) {
throw new IllegalArgumentException("SQL identifier must not be blank");
}
String clean = identifier.trim();
if (!SAFE_IDENTIFIER.matcher(clean).matches()) {
throw new IllegalArgumentException("Illegal SQL identifier: " + identifier);
}
return clean.toLowerCase(Locale.ROOT);
}
}

View File

@ -17,7 +17,6 @@
package org.springenergy.bizAppraise.vo;
import org.springenergy.bizAppraise.entity.BizAppraisePlanEntity;
import org.springenergy.core.tool.node.INode;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -30,6 +29,6 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class BizAppraisePlanVO extends BizAppraisePlanEntity {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}

View File

@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-common</artifactId>
<artifactId>energy-framework-compat</artifactId>
</dependency>
</dependencies>
<packaging>jar</packaging>

View File

@ -35,6 +35,10 @@
</modules>
<dependencies>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-framework-compat</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>

View File

@ -14,6 +14,24 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-framework-compat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
@ -24,17 +42,14 @@
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<artifactId>knife4j-annotations</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-biz-anomaly-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-user-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>

View File

@ -16,8 +16,11 @@
*/
package org.springenergy.bizAnomalyInfo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Desk启动器
@ -25,11 +28,14 @@ import org.springframework.boot.SpringApplication;
* @author Chill
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "org.springenergy")
@MapperScan("org.springenergy.bizAnomalyInfo.mapper")
public class BizAnomalyApplication {
public static void main(String[] args) {
SpringApplication.run(BizAnomalyApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(BizAnomalyApplication.class, args);
}
}

View File

@ -4,8 +4,20 @@ server:
#数据源配置
spring:
application:
name: energy-biz-anomaly
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
url: ${energy.datasource.dev.url}
username: ${energy.datasource.dev.username}
password: ${energy.datasource.dev.password}
dynamic:
enabled: false
driver-class-name: oracle.jdbc.OracleDriver
url: ${ENERGY_DATASOURCE_DEV_URL:${energy.datasource.dev.url:jdbc:oracle:thin:@//192.168.1.102:1521/ORCLPDB}}
username: ${ENERGY_DATASOURCE_DEV_USERNAME:${energy.datasource.dev.username:ENERGYX}}
password: ${ENERGY_DATASOURCE_DEV_PASSWORD:${energy.datasource.dev.password:}}
springfox:
documentation:
enabled: false

View File

@ -0,0 +1,21 @@
spring:
application:
name: energy-biz-anomaly
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
cloud:
nacos:
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
discovery:
server-addr: ${NACOS_ADDR:localhost:8848}
config:
server-addr: ${NACOS_ADDR:localhost:8848}
file-extension: yaml
shared-configs:
- data-id: energy.yaml
group: DEFAULT_GROUP
refresh: true
- data-id: energy-${spring.profiles.active}.yaml
group: DEFAULT_GROUP
refresh: true

View File

@ -14,6 +14,24 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-framework-compat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
@ -24,17 +42,14 @@
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<artifactId>knife4j-annotations</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-biz-appraise-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-user-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>

View File

@ -16,8 +16,11 @@
*/
package org.springenergy.bizAppraise;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Desk启动器
@ -25,11 +28,14 @@ import org.springframework.boot.SpringApplication;
* @author Chill
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "org.springenergy")
@MapperScan("org.springenergy.bizAppraise.mapper")
public class BizAppraiseApplication {
public static void main(String[] args) {
SpringApplication.run(BizAppraiseApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(BizAppraiseApplication.class, args);
}
}

View File

@ -4,8 +4,20 @@ server:
#数据源配置
spring:
application:
name: energy-biz-appraise
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
url: ${energy.datasource.dev.url}
username: ${energy.datasource.dev.username}
password: ${energy.datasource.dev.password}
dynamic:
enabled: false
driver-class-name: oracle.jdbc.OracleDriver
url: ${ENERGY_DATASOURCE_DEV_URL:${energy.datasource.dev.url:jdbc:oracle:thin:@//192.168.1.102:1521/ORCLPDB}}
username: ${ENERGY_DATASOURCE_DEV_USERNAME:${energy.datasource.dev.username:ENERGYX}}
password: ${ENERGY_DATASOURCE_DEV_PASSWORD:${energy.datasource.dev.password:}}
springfox:
documentation:
enabled: false

View File

@ -0,0 +1,21 @@
spring:
application:
name: energy-biz-appraise
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
cloud:
nacos:
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
discovery:
server-addr: ${NACOS_ADDR:localhost:8848}
config:
server-addr: ${NACOS_ADDR:localhost:8848}
file-extension: yaml
shared-configs:
- data-id: energy.yaml
group: DEFAULT_GROUP
refresh: true
- data-id: energy-${spring.profiles.active}.yaml
group: DEFAULT_GROUP
refresh: true

View File

@ -12,28 +12,51 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.0.5.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-framework-compat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-annotations</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-biz-index-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-user-api</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>

View File

@ -16,8 +16,11 @@
*/
package org.springenergy.bizIndexBase;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Desk启动器
@ -25,11 +28,14 @@ import org.springframework.boot.SpringApplication;
* @author Chill
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "org.springenergy")
@MapperScan("org.springenergy.bizIndexBase.mapper")
public class BizIndexApplication {
public static void main(String[] args) {
SpringApplication.run(BizIndexApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(BizIndexApplication.class, args);
}
}

View File

@ -4,8 +4,20 @@ server:
#数据源配置
spring:
application:
name: energy-biz-index
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
url: ${energy.datasource.dev.url}
username: ${energy.datasource.dev.username}
password: ${energy.datasource.dev.password}
dynamic:
enabled: false
driver-class-name: oracle.jdbc.OracleDriver
url: ${ENERGY_DATASOURCE_DEV_URL:${energy.datasource.dev.url:jdbc:oracle:thin:@//192.168.1.102:1521/ORCLPDB}}
username: ${ENERGY_DATASOURCE_DEV_USERNAME:${energy.datasource.dev.username:ENERGYX}}
password: ${ENERGY_DATASOURCE_DEV_PASSWORD:${energy.datasource.dev.password:}}
springfox:
documentation:
enabled: false

View File

@ -0,0 +1,21 @@
spring:
application:
name: energy-biz-index
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
cloud:
nacos:
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
discovery:
server-addr: ${NACOS_ADDR:localhost:8848}
config:
server-addr: ${NACOS_ADDR:localhost:8848}
file-extension: yaml
shared-configs:
- data-id: energy.yaml
group: DEFAULT_GROUP
refresh: true
- data-id: energy-${spring.profiles.active}.yaml
group: DEFAULT_GROUP
refresh: true

View File

@ -74,14 +74,6 @@
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-dict-api</artifactId>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-scope-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -43,8 +43,9 @@
</properties>
<modules>
<module>energy-service</module>
<module>energy-framework-compat</module>
<module>energy-service-api</module>
<module>energy-service</module>
</modules>
<dependencyManagement>
@ -118,6 +119,11 @@
<artifactId>swagger-models</artifactId>
<version>${swagger-models.version}</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-framework-compat</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.springenergy</groupId>
<artifactId>energy-common</artifactId>