diff --git a/README.md b/README.md index 537d3921f78ad00cbaa94e0639062e10e298c344..e3da47f4f9973e13e598e8fb4cb96cab06468f59 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# operation-control-platform - +以运营管控平台为顶层,构建标准物理模型、服务、应用等核心资源库,对服务、数据模型注册、变更、发布进行管控,实时监控“三区四层”架构运营情况,对模型、服务、应用异常情况自动告警,全面支撑PMS3.0数字化架构的落地与持续迭代。 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..281bcc242731a264b999add57cb0e5cfbdd49885 --- /dev/null +++ b/pom.xml @@ -0,0 +1,230 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.2 + + + com.pms.ocp + operation-control-platform + 0.0.1-SNAPSHOT + + + 1.8 + 2.4.2 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-aop + + + com.baomidou + mybatis-plus-boot-starter + 3.4.1 + + + + + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.12 + + + com.alibaba + fastjson + 1.2.62 + + + + io.jsonwebtoken + jjwt + 0.9.0 + + + + org.postgresql + postgresql + 9.4.1212.jre7 + + + + + org.projectlombok + lombok + + + org.apache.commons + commons-lang3 + 3.9 + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.9 + + + + javax.validation + validation-api + 1.1.0.Final + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + cn.hutool + hutool-all + 5.7.16 + + + + org.springframework.boot + spring-boot-starter-redis + 1.4.1.RELEASE + + + redis.clients + jedis + 3.1.0 + + + + com.google.code.gson + gson + 2.8.6 + + + + javax.validation + validation-api + 2.0.1.Final + + + + + + org.apache.poi + poi + 4.1.1 + + + + org.apache.poi + poi-ooxml + 4.1.1 + + + + + cn.afterturn + easypoi-base + 4.3.0 + + + cn.afterturn + easypoi-web + 4.3.0 + + + cn.afterturn + easypoi-annotation + 4.3.0 + + + + + + + dev + + true + + + dev + + + + uat + + false + + + uat + + + + prod + + false + + + prod + + + + + + + + ${project.basedir}/src/main/resources + + **/*.* + + + application-*.properties + + true + + + ${project.basedir}/src/main/resources + + application-${spring.profiles.active}.properties + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.beagle.base.StartApp + + + + + diff --git a/src/main/java/com/pms/ocp/OcpApplication.java b/src/main/java/com/pms/ocp/OcpApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..9884e645e18bb485697c2881e18ef8edd36cd483 --- /dev/null +++ b/src/main/java/com/pms/ocp/OcpApplication.java @@ -0,0 +1,39 @@ +package com.pms.ocp; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.Bean; + +import java.util.TimeZone; + +/** + * @Auther: wangjian + * @Date: 2022/2/21 15:48 + * @Description:启动类 + */ + +@SpringBootApplication +@MapperScan(basePackages = {"com.pms.ocp.mapper"}) +@ConfigurationPropertiesScan +//@EnableScheduling +public class OcpApplication { + public static void main(String[] args) { + TimeZone.setDefault(TimeZone.getTimeZone("GMT+8")); + SpringApplication.run(OcpApplication.class, args); + } + + /** + * 注册分页插件 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); + return interceptor; + } +} diff --git a/src/main/java/com/pms/ocp/common/annotation/OperationLog.java b/src/main/java/com/pms/ocp/common/annotation/OperationLog.java new file mode 100644 index 0000000000000000000000000000000000000000..64bae0ea0afe872525176e060adea066be0a4c71 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/annotation/OperationLog.java @@ -0,0 +1,34 @@ +package com.pms.ocp.common.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 操作日志 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/16 + */ +@Inherited +@Documented +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface OperationLog { + /** + * 操作日志描述 + */ + String desc(); + /** + * 操作日志类型 + */ + OperationType type(); + /** + * 是否记录 设置false 则不做任何处理 + */ + boolean record() default true; +} diff --git a/src/main/java/com/pms/ocp/common/annotation/OperationType.java b/src/main/java/com/pms/ocp/common/annotation/OperationType.java new file mode 100644 index 0000000000000000000000000000000000000000..10418ea4a8e4c5aeb1d4c0044e3331ac9ffc3447 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/annotation/OperationType.java @@ -0,0 +1,31 @@ +package com.pms.ocp.common.annotation; + +/** + * 操作日志枚举操作类型 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/16 + */ +public enum OperationType { + /** + * 新增类型 + */ + ADD, + /** + * 修改类型 + */ + MODIFY, + /** + * 删除类型 + */ + DELETE, + /** + * 导入类型 + */ + IMPORT, + /** + * 导出类型 + */ + EXPORT +} diff --git a/src/main/java/com/pms/ocp/common/aspect/InterfaceLogAspect.java b/src/main/java/com/pms/ocp/common/aspect/InterfaceLogAspect.java new file mode 100644 index 0000000000000000000000000000000000000000..f457ec24ec5525962a5b7e2221ad0aa104e9c39b --- /dev/null +++ b/src/main/java/com/pms/ocp/common/aspect/InterfaceLogAspect.java @@ -0,0 +1,77 @@ +package com.pms.ocp.common.aspect; + +import java.util.HashMap; +import java.util.Map; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import com.alibaba.fastjson.JSONObject; + +import lombok.extern.slf4j.Slf4j; + +/** + * 统一接口日志记录 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/6 + */ +@Order(1) +@Slf4j +@Aspect +@Component +public class InterfaceLogAspect { + + @Before("execution(* com.beagle.base.controller..*.*(..))") + public void before(JoinPoint joinPoint) { + // 打印接口请求参数日志 + this.logInterfaceRequest(joinPoint); + } + + @Around("execution(* com.beagle.base.controller..*.*(..))") + public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + long startTime = System.currentTimeMillis(); + Object result = proceedingJoinPoint.proceed(); + log.info("interface responseBody : " + (result != null ? JSONObject.toJSONString(result) : null)); + log.info("interface time-consuming :{}", System.currentTimeMillis() - startTime); + return result; + } + + /** + * 打印接口请求参数日志 + * + * @param joinPoint + * 连接点 + */ + private void logInterfaceRequest(JoinPoint joinPoint) { + try { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); + String[] parameterNames = methodSignature.getParameterNames(); + Map paramMap = new HashMap<>(10); + Object[] args = joinPoint.getArgs(); + if (parameterNames.length <= args.length) { + for (int i = 0; i < parameterNames.length; i++) { + paramMap.put(parameterNames[i], args[i]); + } + } + log.info("interface url : " + + (attributes != null ? attributes.getRequest().getRequestURL() : null)); + log.info("interface className : " + joinPoint.getTarget().getClass().getName()); + log.info("interface methodName : " + joinPoint.getSignature().getName()); + log.info("interface requestBody : " + JSONObject.toJSONString(paramMap)); + } catch (Exception exception) { + log.error("InterfaceLogAspect.before Exception", exception); + } + } +} diff --git a/src/main/java/com/pms/ocp/common/component/ApplicationContextUtil.java b/src/main/java/com/pms/ocp/common/component/ApplicationContextUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..05305c85b388f4f318f222a336e465bb1399a0eb --- /dev/null +++ b/src/main/java/com/pms/ocp/common/component/ApplicationContextUtil.java @@ -0,0 +1,26 @@ +package com.pms.ocp.common.component; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * Bean 工具类 + * + * @author wuwanli + */ +@Component +public class ApplicationContextUtil implements ApplicationContextAware { + + private static ApplicationContext applicationContext; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + ApplicationContextUtil.applicationContext = applicationContext; + } + + public static T getBean(Class clazz) throws BeansException { + return applicationContext.getBean(clazz); + } +} diff --git a/src/main/java/com/pms/ocp/common/component/LogbackFilter.java b/src/main/java/com/pms/ocp/common/component/LogbackFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..06d63d07e85b9bd2d06599036964130ebb91f768 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/component/LogbackFilter.java @@ -0,0 +1,57 @@ +package com.pms.ocp.common.component; + +import java.io.IOException; +import java.util.UUID; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.slf4j.MDC; + +/** + * 日志统一增加traceId + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/6 + */ +public class LogbackFilter implements Filter { + + private static final String TRACE_ID = "traceId"; + @Override + public void init(FilterConfig filterConfig) throws ServletException { + Filter.super.init(filterConfig); + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + boolean result = this.insertMdc(); + try { + filterChain.doFilter(servletRequest, servletResponse); + } finally { + if (result) { + MDC.remove(TRACE_ID); + } + } + } + + private boolean insertMdc() { + try { + UUID uuid = UUID.randomUUID(); + String uniqueId = uuid.toString().replace("-", ""); + MDC.put(TRACE_ID, uniqueId); + return true; + } catch (Exception exception) { + return false; + } + } + @Override + public void destroy() { + Filter.super.destroy(); + } +} diff --git a/src/main/java/com/pms/ocp/common/constants/BusinessConstants.java b/src/main/java/com/pms/ocp/common/constants/BusinessConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..4b27c91de14566f6ede1a32a6b71738ccab16f51 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/BusinessConstants.java @@ -0,0 +1,28 @@ +package com.pms.ocp.common.constants; + +/** + * 业务常量 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/4 + */ +public interface BusinessConstants { + + /** + * 已删除 + */ + int DELETED_FLAG = 0; + /** + * 未删除 + */ + int NOT_DELETED = 1; + /** + * 是历史数据 + */ + int IS_HISTORY_DATA = 1; + /** + * 不是历史数据 + */ + int NOT_HISTORY_DATA = 0; +} diff --git a/src/main/java/com/pms/ocp/common/constants/BusinessNameConstant.java b/src/main/java/com/pms/ocp/common/constants/BusinessNameConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..8269f765eabc504fb194b65bc25dfaca9fa003bc --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/BusinessNameConstant.java @@ -0,0 +1,11 @@ +package com.pms.ocp.common.constants; + +/** + * @author huxiuwu + * @version 1.0 + * @date 2022/1/6 15:06 + */ +public interface BusinessNameConstant { + + String SHEET_NAME_ONE = "统建服务调用统计"; +} diff --git a/src/main/java/com/pms/ocp/common/constants/ChooseDateType.java b/src/main/java/com/pms/ocp/common/constants/ChooseDateType.java new file mode 100644 index 0000000000000000000000000000000000000000..a3a567f484e4cf39782b71da81d235f0b3ffe9d2 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/ChooseDateType.java @@ -0,0 +1,32 @@ +package com.pms.ocp.common.constants; + +public enum ChooseDateType { + ONE_WEEK(1, "最近一周"), + ONE_MONTH(2, "最近一个月"), + THREE_MONTHS(3, "最近三个月"); + private Integer code; + private String desc; + + ChooseDateType(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + public Integer getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + public static ChooseDateType getChooseDateType(Integer code) { + ChooseDateType[] values = ChooseDateType.values(); + for (ChooseDateType c : values) { + if (c.getCode().equals(code)) { + return c; + } + } + return null; + } +} diff --git a/src/main/java/com/pms/ocp/common/constants/CodeEnum.java b/src/main/java/com/pms/ocp/common/constants/CodeEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..882e30d8db2232f90fc8245a8f396bbafbf5da9b --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/CodeEnum.java @@ -0,0 +1,66 @@ +package com.pms.ocp.common.constants; + +import lombok.Getter; + +/** + * @author wuwanli + * @version 1.0 + * @date 2021/8/4 + */ +public enum CodeEnum { + /** + * 处理成功 + */ + SUCCESS("200", "处理成功", true), + /** + * 必填参数为空 + */ + REQUIRED_PARAMETER_EMPTY("0", "必填参数为空", false), + /** + * 参数类型错误 + */ + PARAMETER_TYPE_ERROR("0", "Parameter type error", false), + /** + * 未登录 + */ + NOT_LOGIN("401001", "用户未登录", false), + /** + * 用户名或密码错误 + */ + LOGIN_FAIL("401002", "用户名或密码错误", false), + /** + * 无权限访问 + */ + NO_PERMISSION("401003", "无权限访问", false), + /** + * 系统异常 + */ + UNKNOWN("9999", "System abnormal", false), + /** + * 数据异常 + */ + NO_DATA("555", "数据库数据异常", false), + UP_DATA_FAIL("401005", "更新失败", false), + INSERT_FAIL("401006", "插入数据失败", false); + + /** + * 构造函数 + * + * @param code 响应码 + * @param desc 响应描述 + */ + CodeEnum(String code, String desc, boolean success) { + this.code = code; + this.desc = desc; + this.success = success; + } + + @Getter + private final String code; + + @Getter + private final String desc; + @Getter + private final boolean success; + +} \ No newline at end of file diff --git a/src/main/java/com/pms/ocp/common/constants/DateConstants.java b/src/main/java/com/pms/ocp/common/constants/DateConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..f91c1ad6479f5ecb9bf1aad9c9469c4dde624528 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/DateConstants.java @@ -0,0 +1,14 @@ +package com.pms.ocp.common.constants; + +/** + * 业务常量 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/4 + */ +public interface DateConstants { + + String DATE_END = " 23:59:59"; + String DATE_START = " 00:00:00"; +} diff --git a/src/main/java/com/pms/ocp/common/constants/NumberConstant.java b/src/main/java/com/pms/ocp/common/constants/NumberConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..5dd3911c27ecce2f159f9dbb0c50d45d4a7b6f82 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/NumberConstant.java @@ -0,0 +1,23 @@ +package com.pms.ocp.common.constants; + +import javax.validation.constraints.Negative; + +/** + * @author admin + * @version 1.0 + * @date 2021/12/11 10:50 + */ +public interface NumberConstant { + + Integer ZERO = 0; + Integer ONE = 1; + Integer TEN = 10; + Integer TWO = 2; + Integer THREE = 3; + Integer FOUR = 4; + Integer MINUS_THIRTY = -30; + Integer NEGATIVE_SEVEN = -7; + Integer MINUS_NINETY = -90; + + +} diff --git a/src/main/java/com/pms/ocp/common/constants/SymbolConstants.java b/src/main/java/com/pms/ocp/common/constants/SymbolConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..6a5dd8ea233dc0933d56b29871ba145daa04d570 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/constants/SymbolConstants.java @@ -0,0 +1,26 @@ +package com.pms.ocp.common.constants; + +/** + * 符号常量 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/4 + */ +public interface SymbolConstants { + /** + * 英文分号 + */ + String SEMICOLON_EN = ";"; + /** + * 一个空格 + */ + String BLANK = " "; + /** + * 点分割符 + */ + String POINT = "."; + + String XLSX_SUFFIX=".xlsx"; + String XLS_SUFFIX=".xls"; +} diff --git a/src/main/java/com/pms/ocp/common/exception/BeagleException.java b/src/main/java/com/pms/ocp/common/exception/BeagleException.java new file mode 100644 index 0000000000000000000000000000000000000000..84d6f3f30b924bd0906c870003fdf993e057d8e1 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/exception/BeagleException.java @@ -0,0 +1,44 @@ +package com.pms.ocp.common.exception; + +import lombok.Getter; + +/** + * @author wuwanli + * @date 2021/8/3 + */ +public class BeagleException extends RuntimeException { + /** + * 错误码 + */ + @Getter + protected String errorCode; + /** + * 错误信息 + */ + @Getter + protected String errorMsg; + + public BeagleException() { + super(); + } + + public BeagleException(String errorMsg) { + super(errorMsg); + this.errorMsg = errorMsg; + } + public BeagleException(String errorCode, String errorMsg) { + super(errorMsg); + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } + + public BeagleException(String errorMsg, Throwable cause) { + super(errorMsg, cause); + } + + public BeagleException(String errorCode, String errorMsg, Throwable cause) { + super(errorCode, cause); + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } +} diff --git a/src/main/java/com/pms/ocp/common/exception/GlobalExceptionHandler.java b/src/main/java/com/pms/ocp/common/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..5724c55a3ffff48430f8d359ca9845b88edb2929 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/exception/GlobalExceptionHandler.java @@ -0,0 +1,39 @@ +package com.pms.ocp.common.exception; + +import com.pms.ocp.common.utils.BeagleStringUtils; +import com.pms.ocp.model.vo.BaseResponse; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import com.pms.ocp.common.constants.CodeEnum; + +import lombok.extern.slf4j.Slf4j; + +/** + * @author wuwanli + * @version 1.0 + * @date 2021/8/5 + */ +@Slf4j +@RestControllerAdvice +public class GlobalExceptionHandler { + + @ExceptionHandler(value = BeagleException.class) + public BaseResponse beagleExceptionHandler(BeagleException beagleException) { + log.error("GlobalExceptionHandler.beagleExceptionHandler", beagleException); + BaseResponse baseResponse = new BaseResponse(); + if (BeagleStringUtils.isBlank(beagleException.getErrorCode())) { + baseResponse.setResponseCode(CodeEnum.UNKNOWN); + } else { + baseResponse.setCode(beagleException.getErrorCode()); + baseResponse.setDesc(beagleException.getErrorMsg()); + } + return baseResponse; + } + + @ExceptionHandler(value = Exception.class) + public BaseResponse exceptionHandler(Exception exception) { + log.error("GlobalExceptionHandler.exceptionHandler", exception); + return new BaseResponse(CodeEnum.UNKNOWN); + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/BeagleStringUtils.java b/src/main/java/com/pms/ocp/common/utils/BeagleStringUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..563349ce31a8b5fb5d42af1fc92c08fd1e5bdce1 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/BeagleStringUtils.java @@ -0,0 +1,26 @@ +package com.pms.ocp.common.utils; + +import org.apache.commons.lang3.StringUtils; + +/** + * 字符串工具类 + * + * @author wuwanli + * @version 1.0 + * @date 2021/8/4 + */ +public class BeagleStringUtils { + + public static boolean isBlank(CharSequence cs) { + return StringUtils.isBlank(cs); + } + public static boolean isEmpty(CharSequence cs) { + return StringUtils.isEmpty(cs); + } + public static boolean isNotBlank(CharSequence cs) { + return StringUtils.isNotBlank(cs); + } + public static boolean isNotEmpty(CharSequence cs) { + return StringUtils.isNotEmpty(cs); + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/DateUtils.java b/src/main/java/com/pms/ocp/common/utils/DateUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..a135959860c9bf4089cb058b55097dbc401f1539 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/DateUtils.java @@ -0,0 +1,331 @@ +package com.pms.ocp.common.utils; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * @author huxiuwu + * @version 1.0 + * @date 2022/1/4 20:14 + */ +public class DateUtils { + private DateUtils() { + } + + public static SimpleDateFormat sdf() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + } + + /** + * 获取当天的开始时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getDayBegin() { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return sdf().format(cal.getTime()); + } + + /** + * 获取当天的结束时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getDayEnd() { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + return sdf().format(cal.getTime()); + } + + /** + * 获取昨天的开始时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getBeginDayOfYesterday(Integer dayNum) { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + cal.add(Calendar.DAY_OF_MONTH, dayNum); + return sdf().format(cal.getTime()); + } + + /** + * 获取昨天的结束时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getEndDayOfYesterday(Integer dayNum) { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + cal.add(Calendar.DAY_OF_MONTH,dayNum); + return sdf().format(cal.getTime()); + } + + /** + * 获得本周一0点时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesWeekmorning() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0) + day_of_week = 7; + c.add(Calendar.DATE, -day_of_week + 1); + return format.format(c.getTime()); + } + + /** + * 获得本周日24点时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesWeeknight() { + SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd 23:59:59"); + Calendar c = Calendar.getInstance(); + int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1; + if (day_of_week == 0) + day_of_week = 7; + c.add(Calendar.DATE, -day_of_week + 7); + return formatDate.format(c.getTime()); + } + + /** + * 根据当前日期获得最近n周的日期区间(不包含本周) + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getFromToDate(SimpleDateFormat sdf, Date date, int n, int option, int k) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1; + int offset = 0 == option ? 1 - dayOfWeek : 7 - dayOfWeek; + int amount = 0 == option ? offset - (n - 1 + k) * 7 : offset - k * 7; + calendar.add(Calendar.DATE, amount); + return sdf.format(calendar.getTime()); + } + + /** + * 获取上周的开始时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getBeginDayOfLastWeek() { + //上周日期 + SimpleDateFormat sdf = sdf(); + String beginDate = getFromToDate(sdf, new Date(), 1, 0, 1); + + Calendar calendar = Calendar.getInstance(); + try { + calendar.setTime(sdf.parse(beginDate)); + } catch (Exception e) { + e.printStackTrace(); + } + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + return sdf.format(calendar.getTime()); + } + + + /** + * 获取上周的结束时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getEndDayOfLastWeek() { + //上周日期 + SimpleDateFormat sdf = sdf(); + String endDate = getFromToDate(sdf, new Date(), 1, 1, 1); + + Calendar calendar = Calendar.getInstance(); + try { + calendar.setTime(sdf.parse(endDate)); + } catch (Exception e) { + e.printStackTrace(); + } + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + return sdf.format(calendar.getTime()); + } + + /** + * 获得本月第一天0点时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesMonthMorning() { + Calendar cal = Calendar.getInstance(); + cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); + return sdf().format(cal.getTime()); + } + + /** + * 获得本月最后一天24点时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesMonthNight() { + Calendar cal = Calendar.getInstance(); + cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 23, 59, 59); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + cal.set(Calendar.HOUR_OF_DAY, 23); + return sdf().format(cal.getTime()); + } + + // 获得上月第一天0点时间 + + /** + * 获取昨天的开始时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesLastMonthMorning(Integer last) { + //上月日期 + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, last); + int lastMonthMaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH); + c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), lastMonthMaxDay, 23, 59, 59); + + //按格式输出 + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-01 00:00:00"); + String gTime = sdf2.format(c.getTime()); //上月第一天 + return gTime; + } + + /** + * 获得上月最后一天24点时间 + * + * @author huxiuwu + * @date 2022/1/4 + **/ + public static String getTimesLastMonthNight(Integer lastMonth) { + //上月日期 + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, lastMonth); + SimpleDateFormat sdf = sdf(); + int lastMonthMaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH); + c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), lastMonthMaxDay, 23, 59, 59); + + //按格式输出 + String g_time = sdf.format(c.getTime()); + return g_time; + } + + + public static Date asDate(LocalDate localDate) { + return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + } + + public static Date asDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + public static LocalDate asLocalDate(Date date) { + return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate(); + } + + public static LocalDateTime asLocalDateTime(Date date) { + return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime(); + } + + /** + * 当前时间前后几个月 + * + * @param month + * @return + */ + public static Timestamp getAssignMonthTime(Integer month) { + return Timestamp.valueOf(LocalDateTime.now().plusMonths(month)); + } + + /** + * 上一周 + * + * @return + */ + + public static Timestamp getLaskWeek() { + DateTime dateTime = DateUtil.lastWeek(); + return new Timestamp(dateTime.getTime()); + } + + /** + * 获取月份 整数 + * + * @param timestamp + * @return + */ + public static Integer getMonth(Timestamp timestamp) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(timestamp.getTime()); + return calendar.get(Calendar.MONTH) + 1; + } + + public static Timestamp getBeginTimeOfMonth(int year, int month) { + YearMonth yearMonth = YearMonth.of(year, month); + LocalDate localDate = yearMonth.atDay(1); + LocalDateTime startOfDay = localDate.atStartOfDay(); + ZonedDateTime zonedDateTime = startOfDay.atZone(ZoneId.of("Asia/Shanghai")); + Date from = Date.from(zonedDateTime.toInstant()); + return new Timestamp(from.getTime()); + } + + public static Timestamp getEndTimeOfMonth(int year, int month) { + YearMonth yearMonth = YearMonth.of(year, month); + LocalDate endOfMonth = yearMonth.atEndOfMonth(); + LocalDateTime localDateTime = endOfMonth.atTime(23, 59, 59, 999); + ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai")); + Date from = Date.from(zonedDateTime.toInstant()); + return new Timestamp(from.getTime()); + } + + public static String getLastMonth() { + LocalDate today = LocalDate.now(); + today = today.minusMonths(1); + DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM"); + return formatters.format(today); + } + + public static String getYearAndMonth(Integer offset) { + LocalDate today = LocalDate.now(); + today = today.minusMonths(offset); + DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM"); + return formatters.format(today); + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/ExcelImportUtils.java b/src/main/java/com/pms/ocp/common/utils/ExcelImportUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..3e6cc3aca98ac4a0448d55261e339163c2b319db --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/ExcelImportUtils.java @@ -0,0 +1,111 @@ +package com.pms.ocp.common.utils; + +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; + +/** + * @Auther: wangjian + * @Date: 2022/1/17 10:00 + * @Description: + */ +public class ExcelImportUtils { + //@描述:判断是否是2003版的excel,返回true是2003 + public static boolean isExcel2003(String filePath) { + return filePath.matches("^.+\\.(?i)(xls)$"); + } + + //@描述:判断是否是2007版的Excel,返回true是2007 + public static boolean isExcel2007(String filePath) { + return filePath.matches("^.+\\.(?i)(xlsx)$"); + } + + /* + @描述:验证excel文件 + @param:filePath + @return + */ + public static boolean validateExcel(String filePath) { + if (filePath == null || !(isExcel2003(filePath)) || !(isExcel2007(filePath))) { + return false; + } else { + return true; + } + } + + /** + * 创建标题样式 + * + * @param wb + * @return + */ + public static HSSFCellStyle createTitleCellStyle(HSSFWorkbook wb) { + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直对齐 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + //背景颜色 cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex()); + + HSSFFont headerFont1 = (HSSFFont) wb.createFont(); // 创建字体样式 + headerFont1.setBold(true); //字体加粗 + headerFont1.setFontName("黑体"); // 设置字体类型 + headerFont1.setFontHeightInPoints((short) 15); // 设置字体大小 + cellStyle.setFont(headerFont1); // 为标题样式设置字体样式 + + return cellStyle; + } + + /** + * 创建表头样式 + * + * @param wb + * @return + */ + public static HSSFCellStyle createHeadCellStyle(HSSFWorkbook wb) { + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setWrapText(true);// 设置自动换行 + //背景颜色 cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); + cellStyle.setAlignment(HorizontalAlignment.CENTER); //水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //垂直对齐 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + cellStyle.setBottomBorderColor(IndexedColors.BLACK.index); + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + HSSFFont headerFont = (HSSFFont) wb.createFont(); // 创建字体样式 + headerFont.setBold(true); //字体加粗 + headerFont.setFontName("黑体"); // 设置字体类型 + headerFont.setFontHeightInPoints((short) 12); // 设置字体大小 + cellStyle.setFont(headerFont); // 为标题样式设置字体样式 + + return cellStyle; + } + + /** + * 创建内容样式 + * + * @param wb + * @return + */ + public static HSSFCellStyle createContentCellStyle(HSSFWorkbook wb) { + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + // 生成12号字体 + HSSFFont font = wb.createFont(); + font.setColor((short) 8); + font.setFontHeightInPoints((short) 12); + cellStyle.setFont(font); + + return cellStyle; + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/ExcelUtils.java b/src/main/java/com/pms/ocp/common/utils/ExcelUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..702429d3a423961e11fd38d9f9415939807009db --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/ExcelUtils.java @@ -0,0 +1,132 @@ +package com.pms.ocp.common.utils; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.beans.BeanUtils; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * @author huxiuwu + * @version 1.0 + * @date 2022/1/5 21:13 + */ +public class ExcelUtils { + + /** + * 导出excel通用方法 + * + * @param response 响应对象 + * @param list 传入list + * @param fileName 文件名称 + * @param sheetName sheet页名称 + * @param clazz 类对象 + * @return void + * @author huxiuwu + * @date 2022/1/5 + **/ +// public static void writeExcel(HttpServletResponse response, List list, String fileName, String sheetName, Class clazz, HttpServletRequest request) { +// try { +// String characterEncoding = request.getCharacterEncoding(); +// //获取需要导出的数据 +// WriteCellStyle headWriteCellStyle = new WriteCellStyle(); +// //设置头居中 +// headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); +// //内容策略 +// WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); +// //设置 水平居中 +// contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); +// HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); +// response.setContentType("application/vnd.ms-excel;charset=" + characterEncoding); +// response.setCharacterEncoding(characterEncoding); +// // 这里URLEncoder.encode可以防止中文乱码 当然和easyExcel没有关系 +// String excelName = URLEncoder.encode(fileName, characterEncoding); +// response.setHeader("Content-disposition", "attachment;filename=" + excelName + SymbolConstants.XLS_SUFFIX); +// // 这里需要设置不关闭流 +// EasyExcel.write(response.getOutputStream(), clazz). +// autoCloseStream(Boolean.FALSE). +// registerWriteHandler(horizontalCellStyleStrategy). +// sheet(sheetName).doWrite(list); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } + + /** + * Excel导出 + * + * @param response response + * @param fileName 文件名 + * @param list 数据List + * @param pojoClass 对象Class + */ + public static void exportExcel(HttpServletResponse response, String fileName, Collection list, Class pojoClass) throws IOException { + if (StringUtils.isBlank(fileName)) { + //当前日期 + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + fileName = df.format(new Date()); + } + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(fileName, fileName, ExcelType.XSSF), pojoClass, list); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls"); + ServletOutputStream out = response.getOutputStream(); + workbook.write(out); + out.flush(); + } + + /** + * Excel导出,先sourceList转换成List,再导出 + * + * @param response response + * @param fileName 文件名 + * @param sourceList 原数据List + * @param targetClass 目标对象Class + */ + public static void exportExcelToTarget(HttpServletResponse response, String fileName, Collection sourceList, Class targetClass) throws Exception { + List targetList = new ArrayList<>(sourceList.size()); + for (Object source : sourceList) { + Object target = targetClass.newInstance(); + BeanUtils.copyProperties(source, target); + targetList.add(target); + } + exportExcel(response, fileName, targetList, targetClass); + } + + + /** + * Excel导出----设置title---sheetName---要求Collection list是Class pojoClass类型的 + * + * @param response response + * @param fileName 文件名 + * @param list 数据List + * @param pojoClass 对象Class + */ + public static void exportExcel(HttpServletResponse response, String title, String sheetName, String fileName, Collection list, Class pojoClass) throws IOException { + if (StringUtils.isBlank(fileName)) { + //当前日期 + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + fileName = df.format(new Date()); + } + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, sheetName, ExcelType.HSSF), pojoClass, list); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls"); + ServletOutputStream out = response.getOutputStream(); + workbook.write(out); + out.flush(); + } + + +} diff --git a/src/main/java/com/pms/ocp/common/utils/JSONCopyUtil.java b/src/main/java/com/pms/ocp/common/utils/JSONCopyUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..3bdd2c4ac5b861639df2c2ad8c226b6a30f0b5b8 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/JSONCopyUtil.java @@ -0,0 +1,66 @@ +package com.pms.ocp.common.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +/** + * @ClassName: JSONCopyUtil + * @Author: laizonghao + * @Description: 基于fastjson的实体复制工具类 + * @Date: 2020/9/12 15:12 + */ +public class JSONCopyUtil { + + /** + * 对象复制 + * @param o + * @param clazz + * @param + * @return + */ + public static T copyObject(Object o, Class clazz) { + return JSON.parseObject(JSON.toJSONString(o), clazz); + } + + public static T copyObject(String jsonString, Class clazz) { + return JSON.parseObject(jsonString, clazz); + } + + /** + * List复制 + * @param o + * @param clazz + * @param + * @return + */ + public static List copyArray(Object o, Class clazz) { + return JSONArray.parseArray(JSON.toJSONString(o), clazz); + } + + public static List copyArray(String jsonString, Class clazz) { + return JSONArray.parseArray(jsonString, clazz); + } + + + /** + * 从文本中提取数据 + * @param str + * @return + */ + public static String getStringNum(String str) { + str = str.trim(); + StringBuilder str2 = new StringBuilder(); + if (StringUtils.isNotBlank(str)) { + for (int i = 0; i < str.length(); i++) { + //加一个分隔符判断 - 45 , 44 + if ((str.charAt(i) >= 48 && str.charAt(i) <= 57) || str.charAt(i) == 44 || str.charAt(i) == 45) { + str2.append(str.charAt(i)); + } + } + } + return str2.toString(); + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/MapUtils.java b/src/main/java/com/pms/ocp/common/utils/MapUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..26dc69c0cfaee8ab3c83b067f7080a057cbaf56b --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/MapUtils.java @@ -0,0 +1,32 @@ +package com.pms.ocp.common.utils; + +import java.util.*; + +/** + * @Author: admin + * @Description: + * @Date: 2021/12/8 9:31 + * @Version: V1.0 + */ +public class MapUtils { + + /** + * Map 排序 + * + * @param map + * @return Map + */ + public static Map> treeMapDesc(Map> map) { + Map> treeMapDesc = new TreeMap<>(new Comparator() { + + @Override + public int compare(Date o1, Date o2) { + return o2.compareTo(o1); + } + }); + for (Map.Entry> e : map.entrySet()) { + treeMapDesc.put(e.getKey(), e.getValue()); + } + return treeMapDesc; + } +} diff --git a/src/main/java/com/pms/ocp/common/utils/PageRequest.java b/src/main/java/com/pms/ocp/common/utils/PageRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..ad0c4bdb2902d1cc779061201f3f12d79c5af9db --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/PageRequest.java @@ -0,0 +1,24 @@ +package com.pms.ocp.common.utils; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +/** + * @param + * @author admin + */ +@Data +@ApiModel(value = "分页工具类",description = "分页工具类") +public class PageRequest { + + private static final long serialVersionUID = 8167917284229912157L; + + @ApiModelProperty(value = "当前页码") + private int pageSize; + @ApiModelProperty(value = "每页大小") + private int pageNum; + @ApiModelProperty(value = "其他查询条件") + private T query; +} \ No newline at end of file diff --git a/src/main/java/com/pms/ocp/common/utils/SysDateUtil.java b/src/main/java/com/pms/ocp/common/utils/SysDateUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..1b02b4bb13f5d3b9d250f7acb037e8d4f79aeb91 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/SysDateUtil.java @@ -0,0 +1,33 @@ +package com.pms.ocp.common.utils; + +import cn.hutool.core.date.DateTime; +import com.pms.ocp.common.constants.DateConstants; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @Author: admin + * @Description: date工具类 + * @Date: 2021/11/25 16:34 + * @Version: V1.0 + */ +public class SysDateUtil { + + public static String getYesterdayStr(DateTime dateTime) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + return format.format(dateTime) + DateConstants.DATE_END; + } + + public static Date getDateStr(String dateTime) throws ParseException { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return format.parse(dateTime); + } + + + public static String getYesterdayStrShort(DateTime dateTime) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + return format.format(dateTime); + } +} \ No newline at end of file diff --git a/src/main/java/com/pms/ocp/common/utils/ValueUtil.java b/src/main/java/com/pms/ocp/common/utils/ValueUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..cbd0d999df8889e69c3ca1f904c01b45c307dac4 --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/ValueUtil.java @@ -0,0 +1,28 @@ +package com.pms.ocp.common.utils; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @Author: admin + * @Description: + * @Date: 2021/11/26 19:48 + * @Version: V1.0 + */ +@Component +@NoArgsConstructor +@AllArgsConstructor +@Data +public class ValueUtil { + @Value("${system.company_name}") + private String companyName; + @Value("${system.company_code}") + private String companyCode; + + public ValueUtil getCompany() { + return new ValueUtil(companyName, companyCode); + } +} \ No newline at end of file diff --git a/src/main/java/com/pms/ocp/controller/ModelBaseController.java b/src/main/java/com/pms/ocp/controller/ModelBaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..c381a9ecfd5b51675e6b433c4d0d534f737f1626 --- /dev/null +++ b/src/main/java/com/pms/ocp/controller/ModelBaseController.java @@ -0,0 +1,231 @@ +package com.pms.ocp.controller; + +import com.pms.ocp.model.vo.ResponseVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +/** + * @Auther: wangjian + * @Date: 2022/2/21 16:17 + * @Description:模型库管理接口 + */ + +@Slf4j +@RequestMapping("/model-base/v1") +@RestController +@Api(tags = "模型库管理接口") +public class ModelBaseController { + + /** + * 模型分类-查询 + * + * @return + */ + @ApiOperation("模型分类-查询") + @GetMapping("/model/type") + public ResponseVO getModelType() { + return ResponseVO.ok(); + } + + /** + * 模型分类-增加 + * + * @return + */ + @ApiOperation("模型分类-增加") + @PostMapping("/model/type") + public ResponseVO createModelType() { + return ResponseVO.ok(); + } + + /** + * 模型分类-删除 + * + * @return + */ + @ApiOperation("模型分类-删除") + @DeleteMapping("/model/type") + public ResponseVO deleteModelType() { + return ResponseVO.ok(); + } + + /** + * 模型分类-修改 + * + * @return + */ + @ApiOperation("模型分类-修改") + @PutMapping("/model/type") + public ResponseVO updateModelType() { + return ResponseVO.ok(); + } + + /** + * 模型-查询 + * + * @return + */ + @ApiOperation("模型-查询") + @GetMapping("/model") + public ResponseVO getModel() { + return ResponseVO.ok(); + } + + /** + * 模型-增加 + * + * @return + */ + @ApiOperation("模型-增加") + @PostMapping("/model") + public ResponseVO createModel() { + return ResponseVO.ok(); + } + + /** + * 模型-删除 + * + * @return + */ + @ApiOperation("模型-删除") + @DeleteMapping("/model") + public ResponseVO deleteModel() { + return ResponseVO.ok(); + } + + /** + * 模型-修改 + * + * @return + */ + @ApiOperation("模型-修改") + @PutMapping("/model") + public ResponseVO updateModel() { + return ResponseVO.ok(); + } + + /** + * 模型-下发/批量下发 + * TODO + * + * @return + */ + @ApiOperation("模型-下发|批量下发") + @PostMapping("/issue/model") + public ResponseVO issueModel() { + return ResponseVO.ok(); + } + + /** + * 模型注册-上传 + * + * @return + */ + @ApiOperation("模型注册-上传") + @PostMapping("/register/model") + public ResponseVO registerModel() { + return ResponseVO.ok(); + } + + /** + * 模型订阅-增加 + * + * @return + */ + @ApiOperation("模型订阅-增加") + @PostMapping("/model/subscribe") + public ResponseVO createModelSubscribe() { + return ResponseVO.ok(); + } + + /** + * 模型订阅-查询 + * + * @return + */ + @ApiOperation("模型订阅-查询") + @GetMapping("/model/subscribe") + public ResponseVO getModelSubscribe() { + return ResponseVO.ok(); + } + + /** + * 模型事记-查询 + * + * @return + */ + @ApiOperation("模型事记-查询") + @GetMapping("/model/note") + public ResponseVO getModelNote() { + return ResponseVO.ok(); + } + + /** + * 模型事记-增加 + * + * @return + */ + @ApiOperation("模型事记-增加") + @PostMapping("/model/note") + public ResponseVO createModelNote() { + return ResponseVO.ok(); + } + + /** + * 模型属性-增加 + * + * @return + */ + @ApiOperation("模型属性-增加") + @PostMapping("/model/property") + public ResponseVO createModelProperty() { + return ResponseVO.ok(); + } + + /** + * 模型属性-查询 + * + * @return + */ + @ApiOperation("模型属性-查询") + @GetMapping("/model/property") + public ResponseVO getModelProperty() { + return ResponseVO.ok(); + } + + /** + * 模型属性-修改 + * + * @return + */ + @ApiOperation("模型属性-修改") + @PutMapping("/model/property") + public ResponseVO updateModelProperty() { + return ResponseVO.ok(); + } + + /** + * 模型属性-删除 + * + * @return + */ + @ApiOperation("模型属性-删除") + @DeleteMapping("/model/property") + public ResponseVO deleteModelProperty() { + return ResponseVO.ok(); + } + + /** + * 模型拓扑关系-查询 + * + * @return + */ + @ApiOperation("模型拓扑关系-查询") + @GetMapping("/model/topology") + public ResponseVO getModelTopology() { + return ResponseVO.ok(); + } + +} diff --git a/src/main/java/com/pms/ocp/mapper/ModelIssueMapper.java b/src/main/java/com/pms/ocp/mapper/ModelIssueMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..c48501bb9588767b4fe9f7d467b63c704bfecb6c --- /dev/null +++ b/src/main/java/com/pms/ocp/mapper/ModelIssueMapper.java @@ -0,0 +1,15 @@ +package com.pms.ocp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pms.ocp.model.entity.Model; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:25 + * @Description:模型订阅数据层接口 + */ + +@Mapper +public interface ModelIssueMapper extends BaseMapper { +} diff --git a/src/main/java/com/pms/ocp/mapper/ModelMapper.java b/src/main/java/com/pms/ocp/mapper/ModelMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..97657cbec38acade32ba9ccc4d01d6a2abbc9e71 --- /dev/null +++ b/src/main/java/com/pms/ocp/mapper/ModelMapper.java @@ -0,0 +1,15 @@ +package com.pms.ocp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pms.ocp.model.entity.Model; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:25 + * @Description:模型数据层接口 + */ + +@Mapper +public interface ModelMapper extends BaseMapper { +} diff --git a/src/main/java/com/pms/ocp/mapper/ModelNoteMapper.java b/src/main/java/com/pms/ocp/mapper/ModelNoteMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..e58a485bdebbcbb4cdc0788417769497f81363c6 --- /dev/null +++ b/src/main/java/com/pms/ocp/mapper/ModelNoteMapper.java @@ -0,0 +1,15 @@ +package com.pms.ocp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pms.ocp.model.entity.Model; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:25 + * @Description:模型事记数据层接口 + */ + +@Mapper +public interface ModelNoteMapper extends BaseMapper { +} diff --git a/src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java b/src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..a78f2da7c0e0d8d2a6d4039ab525d4cd274fea25 --- /dev/null +++ b/src/main/java/com/pms/ocp/mapper/ModelPropertyMapper.java @@ -0,0 +1,15 @@ +package com.pms.ocp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pms.ocp.model.entity.Model; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:25 + * @Description:模型属性数据层接口 + */ + +@Mapper +public interface ModelPropertyMapper extends BaseMapper { +} diff --git a/src/main/java/com/pms/ocp/mapper/ModelTypeMapper.java b/src/main/java/com/pms/ocp/mapper/ModelTypeMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..4ef568f6cdc700196b1a4f4517b5fc7ce73b666a --- /dev/null +++ b/src/main/java/com/pms/ocp/mapper/ModelTypeMapper.java @@ -0,0 +1,15 @@ +package com.pms.ocp.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pms.ocp.model.entity.Model; +import org.apache.ibatis.annotations.Mapper; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:25 + * @Description:模型类型数据层接口 + */ + +@Mapper +public interface ModelTypeMapper extends BaseMapper { +} diff --git a/src/main/java/com/pms/ocp/model/dto/ApiParamDTO.java b/src/main/java/com/pms/ocp/model/dto/ApiParamDTO.java new file mode 100644 index 0000000000000000000000000000000000000000..ae930a4d75f71393bb4039da076494388574773d --- /dev/null +++ b/src/main/java/com/pms/ocp/model/dto/ApiParamDTO.java @@ -0,0 +1,40 @@ +package com.pms.ocp.model.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Auther: wangjian + * @Date: 2022/1/17 12:45 + * @Description:应用与服务的传输参数 + */ + +@ApiModel(value = "应用与服务的传输参数") +@Data +public class ApiParamDTO { + + @ApiModelProperty(value = "网省编码") + private String companyCode; + + @ApiModelProperty(value = "应用编码") + private String tenantCode; + + @ApiModelProperty(value = "服务编码") + private String apiCode; + + @ApiModelProperty(value = "分组编号") + private String groupId; + + @ApiModelProperty(value = "分组上级编号") + private String groupPid; + + @ApiModelProperty(value = "分组等级") + private String groupLvl; + + @ApiModelProperty(value = "应用名称") + private String tenantName; + + @ApiModelProperty(value = "时期类型") + private String periodCategory; +} diff --git a/src/main/java/com/pms/ocp/model/entity/Model.java b/src/main/java/com/pms/ocp/model/entity/Model.java new file mode 100644 index 0000000000000000000000000000000000000000..4b664974a9ccafe19a40fbe70ca0e32e286ccaa3 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/entity/Model.java @@ -0,0 +1,35 @@ +package com.pms.ocp.model.entity; + +import lombok.Data; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:26 + * @Description:模型对象 + */ + +@Data +//@TableName("mp_user") +public class Model { + + +} + +// model_id +// model_name +// model_code +// equip_type +// domain_type +// model_group_id +// model_group_name +// model_table +// model_relation +// Is_use +// model_promotion +// company_id +// company_name +// model_dispidx +// model_user_id +// model_user_name +// model_ctime +// model_mtime diff --git a/src/main/java/com/pms/ocp/model/entity/ModelIssue.java b/src/main/java/com/pms/ocp/model/entity/ModelIssue.java new file mode 100644 index 0000000000000000000000000000000000000000..2b693ab0b190a0ad40fffd8504a43aba78cfd056 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/entity/ModelIssue.java @@ -0,0 +1,13 @@ +package com.pms.ocp.model.entity; + +import lombok.Data; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:40 + * @Description:模型订阅对象 + */ + +@Data +public class ModelIssue { +} diff --git a/src/main/java/com/pms/ocp/model/entity/ModelNote.java b/src/main/java/com/pms/ocp/model/entity/ModelNote.java new file mode 100644 index 0000000000000000000000000000000000000000..289d008973af357498f996a1a92d52f5b392a724 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/entity/ModelNote.java @@ -0,0 +1,9 @@ +package com.pms.ocp.model.entity; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:52 + * @Description:模型事记对象 + */ +public class ModelNote { +} diff --git a/src/main/java/com/pms/ocp/model/entity/ModelProperty.java b/src/main/java/com/pms/ocp/model/entity/ModelProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..f9c55c55785c1106588369cd25c13bc42e502e70 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/entity/ModelProperty.java @@ -0,0 +1,13 @@ +package com.pms.ocp.model.entity; + +import lombok.Data; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:40 + * @Description:模型属性对象 + */ + +@Data +public class ModelProperty { +} diff --git a/src/main/java/com/pms/ocp/model/entity/ModelType.java b/src/main/java/com/pms/ocp/model/entity/ModelType.java new file mode 100644 index 0000000000000000000000000000000000000000..925b3c303f6c05047f01c23a1ef7ac455523b996 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/entity/ModelType.java @@ -0,0 +1,9 @@ +package com.pms.ocp.model.entity; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:52 + * @Description:模型类型对象 + */ +public class ModelType { +} diff --git a/src/main/java/com/pms/ocp/model/vo/BaseResponse.java b/src/main/java/com/pms/ocp/model/vo/BaseResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..3322445e102d9593546d7b73aec718bf0ebeb346 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/vo/BaseResponse.java @@ -0,0 +1,49 @@ +package com.pms.ocp.model.vo; + +import com.pms.ocp.common.constants.CodeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; + +/** + * @author wuwanli + * @version 1.0 + * @date 2021/8/5 + */ +@Data +@ToString +@ApiModel(value = "BaseResponse返回对象", description = "BaseResponse返回对象") +public class BaseResponse implements Serializable { + private static final long serialVersionUID = -3715259891657893705L; + /** + * 返回码 + */ + @ApiModelProperty(value = "返回码") + private String code; + /** + * 返回描述 + */ + @ApiModelProperty(value = "返回描述") + private String desc; + @ApiModelProperty(value = "是否成功") + private boolean success; + + public BaseResponse() { + super(); + } + + public BaseResponse(CodeEnum codeEnum) { + this.code = codeEnum.getCode(); + this.desc = codeEnum.getDesc(); + this.success = codeEnum.isSuccess(); + } + + public void setResponseCode(CodeEnum codeEnum) { + this.code = codeEnum.getCode(); + this.desc = codeEnum.getDesc(); + this.success = codeEnum.isSuccess(); + } +} diff --git a/src/main/java/com/pms/ocp/model/vo/ModelVO.java b/src/main/java/com/pms/ocp/model/vo/ModelVO.java new file mode 100644 index 0000000000000000000000000000000000000000..455dc6bc82c232d598e229a794c82737f9405174 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/vo/ModelVO.java @@ -0,0 +1,19 @@ +package com.pms.ocp.model.vo; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:56 + * @Description: + */ + +@Data +@NoArgsConstructor +//@AllArgsConstructor +@ApiModel(value = "中台服务运营看板_网省切换数据_服务表", description = "中台服务运营看板_网省切换数据_服务表") +public class ModelVO { +} diff --git a/src/main/java/com/pms/ocp/model/vo/ResponseVO.java b/src/main/java/com/pms/ocp/model/vo/ResponseVO.java new file mode 100644 index 0000000000000000000000000000000000000000..ac92f9968600588a9c69a06a802e11041ab602e1 --- /dev/null +++ b/src/main/java/com/pms/ocp/model/vo/ResponseVO.java @@ -0,0 +1,61 @@ +package com.pms.ocp.model.vo; + +import com.pms.ocp.common.constants.CodeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @author wuwanli + * @version 1.0 + * @date 2021/8/5 + */ + +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "返回对象", description = "返回对象") +public class ResponseVO extends BaseResponse { + private static final long serialVersionUID = 2445069102311188334L; + /** + * 封装的返回对象 + */ + @ApiModelProperty(value = "封装的返回对象") + private T data; + + public ResponseVO() { + super(); + } + + public ResponseVO(CodeEnum codeEnum) { + this.setCode(codeEnum.getCode()); + this.setDesc(codeEnum.getDesc()); + this.setSuccess(codeEnum.isSuccess()); + } + + + public static ResponseVO ok() { + return new ResponseVO<>(CodeEnum.SUCCESS); + } + + public static ResponseVO ok(T data) { + ResponseVO r = new ResponseVO(CodeEnum.SUCCESS); + r.setData(data); + return r; + } + + public static ResponseVO error(CodeEnum codeEnum) { + return new ResponseVO(codeEnum); + } + + public static ResponseVO error(String msg) { + ResponseVO tResponseVO = new ResponseVO<>(); + tResponseVO.setCode("0"); + tResponseVO.setDesc(msg); + tResponseVO.setSuccess(false); + return tResponseVO; + } + +} \ No newline at end of file diff --git a/src/main/java/com/pms/ocp/service/ModelIssueService.java b/src/main/java/com/pms/ocp/service/ModelIssueService.java new file mode 100644 index 0000000000000000000000000000000000000000..67ef6173d8b7328c57d1c5e766b453d7104c1e6e --- /dev/null +++ b/src/main/java/com/pms/ocp/service/ModelIssueService.java @@ -0,0 +1,54 @@ +package com.pms.ocp.service; + +import com.pms.ocp.model.entity.ModelIssue; +import com.pms.ocp.model.entity.ModelType; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:07 + * @Description:模型订阅业务层接口 + */ +public interface ModelIssueService { + + /** + * 创建模型订阅 + * + * @param modelIssueo + * @return + */ + Integer createModelIssue(ModelIssue modelIssueo); + + /** + * 删除模型订阅 + * + * @param modelId + * @return + */ + Integer deleteModelIssue(String modelId); + + /** + * 更新模型订阅 + * + * @param modelIssueo + * @return + */ + Integer updateModelIssue(ModelIssue modelIssueo); + + /** + * 获取模型订阅 + * + * @param + * @return + */ + List getModelIssueList(); + + /** + * 获取模型订阅列表 + * + * @param modelId + * @return + */ + ModelType getModelIssue(String modelId); +} diff --git a/src/main/java/com/pms/ocp/service/ModelNoteService.java b/src/main/java/com/pms/ocp/service/ModelNoteService.java new file mode 100644 index 0000000000000000000000000000000000000000..f473d0b530eddb8602c4e67362f77971dbee22e4 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/ModelNoteService.java @@ -0,0 +1,53 @@ +package com.pms.ocp.service; + +import com.pms.ocp.model.entity.ModelNote; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:08 + * @Description:模型事记业务层接口 + */ +public interface ModelNoteService { + + /** + * 创建模型事记 + * + * @param modelNote + * @return + */ + Integer createModelNote(ModelNote modelNote); + + /** + * 删除模型事记 + * + * @param modelId + * @return + */ + Integer deleteModelNote(String modelId); + + /** + * 更新模型事记 + * + * @param modelNote + * @return + */ + Integer updateModelNote(ModelNote modelNote); + + /** + * 获取模型事记 + * + * @param + * @return + */ + List getModelNoteList(); + + /** + * 获取模型事记列表 + * + * @param modelId + * @return + */ + ModelNote getModelNote(String modelId); +} diff --git a/src/main/java/com/pms/ocp/service/ModelPropertyService.java b/src/main/java/com/pms/ocp/service/ModelPropertyService.java new file mode 100644 index 0000000000000000000000000000000000000000..2ac49e699ce04cb04a8f100759b99125e7ffb08f --- /dev/null +++ b/src/main/java/com/pms/ocp/service/ModelPropertyService.java @@ -0,0 +1,54 @@ +package com.pms.ocp.service; + +import com.pms.ocp.model.entity.ModelProperty; +import com.pms.ocp.model.entity.ModelType; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:03 + * @Description:模型属性业务层接口 + */ +public interface ModelPropertyService { + + /** + * 创建模型属性 + * + * @param modelProperty + * @return + */ + Integer createModelProperty(ModelProperty modelProperty); + + /** + * 删除模型属性 + * + * @param modelId + * @return + */ + Integer deleteModelProperty(String modelId); + + /** + * 更新模型属性 + * + * @param modelProperty + * @return + */ + Integer updateModelProperty(ModelProperty modelProperty); + + /** + * 获取模型属性 + * + * @param + * @return + */ + List getModelPropertyList(); + + /** + * 获取模型属性列表 + * + * @param modelId + * @return + */ + ModelProperty getModelProperty(String modelId); +} diff --git a/src/main/java/com/pms/ocp/service/ModelService.java b/src/main/java/com/pms/ocp/service/ModelService.java new file mode 100644 index 0000000000000000000000000000000000000000..c8577d58983014dcf1b6290b7b8791bc373dfd9c --- /dev/null +++ b/src/main/java/com/pms/ocp/service/ModelService.java @@ -0,0 +1,53 @@ +package com.pms.ocp.service; + +import com.pms.ocp.model.entity.Model; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:03 + * @Description:模型业务层接口 + */ +public interface ModelService { + + /** + * 创建模型 + * + * @param model + * @return + */ + Integer createModel(Model model); + + /** + * 删除模型 + * + * @param modelId + * @return + */ + Integer deleteModel(String modelId); + + /** + * 更新模型 + * + * @param model + * @return + */ + Integer updateModel(Model model); + + /** + * 获取模型 + * + * @param + * @return + */ + List getModelList(); + + /** + * 获取模型列表 + * + * @param modelId + * @return + */ + Model getModel(String modelId); +} diff --git a/src/main/java/com/pms/ocp/service/ModelTypeService.java b/src/main/java/com/pms/ocp/service/ModelTypeService.java new file mode 100644 index 0000000000000000000000000000000000000000..653be3c614eebcac44b05a9552488bbe9141c475 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/ModelTypeService.java @@ -0,0 +1,54 @@ +package com.pms.ocp.service; + +import com.pms.ocp.model.entity.Model; +import com.pms.ocp.model.entity.ModelType; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:07 + * @Description:模型类型业务层接口 + */ +public interface ModelTypeService { + + /** + * 创建模型分类 + * + * @param modelType + * @return + */ + Integer createModelType(ModelType modelType); + + /** + * 删除模型分类 + * + * @param modelId + * @return + */ + Integer deleteModelType(String modelId); + + /** + * 更新模型分类 + * + * @param modelType + * @return + */ + Integer updateModelType(ModelType modelType); + + /** + * 获取模型分类 + * + * @param + * @return + */ + List getModelTypeList(); + + /** + * 获取模型分类列表 + * + * @param modelId + * @return + */ + ModelType getModelType(String modelId); +} diff --git a/src/main/java/com/pms/ocp/service/impl/ModelIssueServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/ModelIssueServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8ae8c863e730313146ed117305ad8872a1405bc5 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/impl/ModelIssueServiceImpl.java @@ -0,0 +1,42 @@ +package com.pms.ocp.service.impl; + +import com.pms.ocp.model.entity.ModelIssue; +import com.pms.ocp.model.entity.ModelType; +import com.pms.ocp.service.ModelIssueService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:22 + * @Description:模型订阅业务层实现 + */ + +@Service +public class ModelIssueServiceImpl implements ModelIssueService { + @Override + public Integer createModelIssue(ModelIssue modelIssueo) { + return null; + } + + @Override + public Integer deleteModelIssue(String modelId) { + return null; + } + + @Override + public Integer updateModelIssue(ModelIssue modelIssueo) { + return null; + } + + @Override + public List getModelIssueList() { + return null; + } + + @Override + public ModelType getModelIssue(String modelId) { + return null; + } +} diff --git a/src/main/java/com/pms/ocp/service/impl/ModelNoteServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/ModelNoteServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..15992913e444a934bd7b6a9d79e2ab1b28039108 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/impl/ModelNoteServiceImpl.java @@ -0,0 +1,41 @@ +package com.pms.ocp.service.impl; + +import com.pms.ocp.model.entity.ModelNote; +import com.pms.ocp.service.ModelNoteService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:21 + * @Description:模型事记业务层实现 + */ + +@Service +public class ModelNoteServiceImpl implements ModelNoteService { + @Override + public Integer createModelNote(ModelNote modelNote) { + return null; + } + + @Override + public Integer deleteModelNote(String modelId) { + return null; + } + + @Override + public Integer updateModelNote(ModelNote modelNote) { + return null; + } + + @Override + public List getModelNoteList() { + return null; + } + + @Override + public ModelNote getModelNote(String modelId) { + return null; + } +} diff --git a/src/main/java/com/pms/ocp/service/impl/ModelPropertyServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/ModelPropertyServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5d2c762e88c959b4305e986318850b55d1f5727a --- /dev/null +++ b/src/main/java/com/pms/ocp/service/impl/ModelPropertyServiceImpl.java @@ -0,0 +1,41 @@ +package com.pms.ocp.service.impl; + +import com.pms.ocp.model.entity.ModelProperty; +import com.pms.ocp.service.ModelPropertyService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:21 + * @Description:模型属性业务层实现 + */ + +@Service +public class ModelPropertyServiceImpl implements ModelPropertyService { + @Override + public Integer createModelProperty(ModelProperty modelProperty) { + return null; + } + + @Override + public Integer deleteModelProperty(String modelId) { + return null; + } + + @Override + public Integer updateModelProperty(ModelProperty modelProperty) { + return null; + } + + @Override + public List getModelPropertyList() { + return null; + } + + @Override + public ModelProperty getModelProperty(String modelId) { + return null; + } +} diff --git a/src/main/java/com/pms/ocp/service/impl/ModelServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/ModelServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..899aa929e12ed7bba72683cc06a31904401f8be4 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/impl/ModelServiceImpl.java @@ -0,0 +1,83 @@ +package com.pms.ocp.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.pms.ocp.mapper.ModelMapper; +import com.pms.ocp.model.entity.Model; +import com.pms.ocp.service.ModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:21 + * @Description:模型业务层实现 + */ + +@Service +public class ModelServiceImpl implements ModelService { + + + @Autowired + private ModelMapper modelMapper; + + /** + * 创建模型 + * + * @param model + * @return + */ + @Override + public Integer createModel(Model model) { + return modelMapper.insert(model); + } + + /** + * 删除模型 + * + * @param modelId + * @return + */ + @Override + public Integer deleteModel(String modelId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("model_id", modelId); + return modelMapper.delete(queryWrapper); + } + + /** + * 更新模型 + * + * @param model + * @return + */ + @Override + public Integer updateModel(Model model) { + return modelMapper.updateById(model); + } + + /** + * 获取模型列表 + * + * @param + * @return + */ + @Override + public List getModelList() { + return modelMapper.selectList(null); + } + + /** + * 获取模型 + * + * @param modelId + * @return + */ + @Override + public Model getModel(String modelId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("model_id", modelId); + return modelMapper.selectOne(queryWrapper); + } +} diff --git a/src/main/java/com/pms/ocp/service/impl/ModelTypeServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/ModelTypeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2ea908f30408439d66ef8ce475f987338a921ce9 --- /dev/null +++ b/src/main/java/com/pms/ocp/service/impl/ModelTypeServiceImpl.java @@ -0,0 +1,42 @@ +package com.pms.ocp.service.impl; + +import com.pms.ocp.model.entity.ModelType; +import com.pms.ocp.service.ModelTypeService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Auther: wangjian + * @Date: 2022/2/22 16:21 + * @Description:模型类型业务层实现 + */ + +@Service +public class ModelTypeServiceImpl implements ModelTypeService { + + @Override + public Integer createModelType(ModelType modelType) { + return null; + } + + @Override + public Integer deleteModelType(String modelId) { + return null; + } + + @Override + public Integer updateModelType(ModelType modelType) { + return null; + } + + @Override + public List getModelTypeList() { + return null; + } + + @Override + public ModelType getModelType(String modelId) { + return null; + } +} diff --git a/src/main/resources/META-INF/spring-configuration-metadata.json b/src/main/resources/META-INF/spring-configuration-metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..e998be8bf90d898eab5cf5969d56dd1228cd01f5 --- /dev/null +++ b/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,203 @@ +{ + "groups": [ + { + "name": "beagle", + "type": "com.pms.ocp.common.config.ApplicationKey", + "sourceType": "com.pms.ocp.common.config.ApplicationKey" + }, + { + "name": "beagle.jwt", + "type": "com.pms.ocp.common.config.ApplicationKey$Jwt", + "sourceType": "com.pms.ocp.common.config.ApplicationKey" + }, + { + "name": "spring.datasource", + "type": "com.zaxxer.hikari.HikariDataSource", + "sourceType": "com.pms.ocp.common.config.BeanConfig", + "sourceMethod": "dataSource()" + } + ], + "properties": [ + { + "name": "beagle.jwt.expire-time", + "type": "java.lang.String", + "sourceType": "com.pms.ocp.common.config.ApplicationKey$Jwt" + }, + { + "name": "beagle.jwt.secret-key", + "type": "java.lang.String", + "sourceType": "com.pms.ocp.common.config.ApplicationKey$Jwt" + }, + { + "name": "beagle.jwt.token-prefix", + "type": "java.lang.String", + "sourceType": "com.pms.ocp.common.config.ApplicationKey$Jwt" + }, + { + "name": "spring.datasource.allow-pool-suspension", + "type": "java.lang.Boolean", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.auto-commit", + "type": "java.lang.Boolean", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.catalog", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.connection-init-sql", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.connection-test-query", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.connection-timeout", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.data-source-class-name", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.data-source-j-n-d-i", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.data-source-properties", + "type": "java.util.Properties", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.driver-class-name", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.exception-override-class-name", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.health-check-properties", + "type": "java.util.Properties", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.health-check-registry", + "type": "java.lang.Object", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.idle-timeout", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.initialization-fail-timeout", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.isolate-internal-queries", + "type": "java.lang.Boolean", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.jdbc-url", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.leak-detection-threshold", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.login-timeout", + "type": "java.lang.Integer", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.max-lifetime", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.maximum-pool-size", + "type": "java.lang.Integer", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.metric-registry", + "type": "java.lang.Object", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.metrics-tracker-factory", + "type": "com.zaxxer.hikari.metrics.MetricsTrackerFactory", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.minimum-idle", + "type": "java.lang.Integer", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.password", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.pool-name", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.read-only", + "type": "java.lang.Boolean", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.register-mbeans", + "type": "java.lang.Boolean", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.scheduled-executor", + "type": "java.util.concurrent.ScheduledExecutorService", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.schema", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.transaction-isolation", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.username", + "type": "java.lang.String", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + }, + { + "name": "spring.datasource.validation-timeout", + "type": "java.lang.Long", + "sourceType": "com.zaxxer.hikari.HikariDataSource" + } + ], + "hints": [] +} \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..88cec2ee0629df9d2d37469741e0d298bea5063c --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,67 @@ + + + + + + + + + + ${PATTERN_FORMAT} + + + + + ${LOG_PATH}/interface_log_%d{yyyyMMdd}.log + ${MAX_HISTORY} + + + ${PATTERN_FORMAT} + + + ${MAX_FILE_SIZE} + + + + + ${LOG_PATH}/error_log_%d{yyyyMMdd}.log + ${MAX_HISTORY} + + + ${PATTERN_FORMAT} + + + ${MAX_FILE_SIZE} + + + + + ${LOG_PATH}/service_log_%d{yyyyMMdd}.log + ${MAX_HISTORY} + + + ${PATTERN_FORMAT} + + + ${MAX_FILE_SIZE} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/ModelMapper.xml b/src/main/resources/mapper/ModelMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..d8e46b63073867c5bec424190f2b31b2ce1a76a4 --- /dev/null +++ b/src/main/resources/mapper/ModelMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file