diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index fc5702f97a..4e2f0d16ab 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -17,6 +17,9 @@ import org.springframework.cloud.commons.util.InetUtils; import org.springframework.core.env.Environment; import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * desc: 发送日志消息 @@ -25,150 +28,276 @@ import java.text.SimpleDateFormat; * @author: jianjun liu */ public class LogMsgSendFilter extends LevelFilter { - private static final Logger logger = LoggerFactory.getLogger(LogMsgSendFilter.class); - private DingdingMsgSender msgSender = new DingdingMsgSender(); - private String webHook; - private String secret; - private String appName; - - private String activeEnv; - private String serverIp; - - @Override - public FilterReply decide(ILoggingEvent event) { - //如果日志级别等于设置的日志级别 则发送消息 - if (event.getLevel().isGreaterOrEqual(Level.ERROR)) { - try { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("【日志告警】\n"); - - stringBuilder.append("\n"); - - stringBuilder.append("告警级别:" + event.getLevel()); - stringBuilder.append("\n"); - if (StringUtils.isNotBlank(appName)) { - stringBuilder.append("服务名称:" + appName); - stringBuilder.append("\n"); - } - getServerInfo(); - if (StringUtils.isNotBlank(activeEnv)) { - stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName()); - stringBuilder.append("\n"); - } - - if (StringUtils.isNotBlank(serverIp)) { - stringBuilder.append("IP地址:" + serverIp); - stringBuilder.append("\n"); - } - stringBuilder.append("故障时间:" + formatLongTime2Str(event.getTimeStamp())); - stringBuilder.append("\n"); - stringBuilder.append("TraceId:" + Thread.currentThread().getName()); - stringBuilder.append("\n"); - stringBuilder.append("告警信息:" + event.getFormattedMessage()); - stringBuilder.append("\n"); - - IThrowableProxy throwableProxy = event.getThrowableProxy(); - //异常信息处理 暂时处理一级的5行数据 - apendStackInfo(stringBuilder, throwableProxy); - DingTalkTextMsg msg = new DingTalkTextMsg(); - msg.setContent(stringBuilder.toString()); - if (StringUtils.isNotBlank(webHook)) { - msg.setWebHook(webHook); - } - if (StringUtils.isNotBlank(secret)) { - msg.setSecret(secret); - } - boolean flag = msgSender.sendMsgAsync(msg); - if (!flag) { - logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); - } - } catch (Exception e) { - logger.warn("decide exception", e); - } - } - //交给其他filter继续向下处理 - return super.decide(event); - - } - - /** - * desc:获取服务 ip及profile信息 - */ - private void getServerInfo() { - try { - if (serverIp == null) { - InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); - serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); - } - } catch (Exception e) { - logger.warn("getServerInfo get bean InetUtils exception", e); - return; - } - try { - if (activeEnv == null) { - Environment environment = SpringContextUtils.getBean(Environment.class); - String[] activeProfiles = environment.getActiveProfiles(); - if (activeProfiles != null && activeProfiles.length > 0) { - logger.info("activeProfiles:{}", activeProfiles); - activeEnv = activeProfiles[0]; - } - } - } catch (Exception e) { - logger.warn("getServerInfo get bean Environment exception", e); - } - } - - private void apendStackInfo(StringBuilder stringBuilder, IThrowableProxy throwableProxy) { - int defaultRowLine = 5; - if (throwableProxy != null) { - stringBuilder.append("异常信息:") - .append(throwableProxy.getClassName()) - .append(" : ") - .append(throwableProxy.getMessage()) - .append("\n"); - - StackTraceElementProxy[] stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); - StackTraceElementProxy stackTraceElementProxy = null; - - if (stackTraceElementProxyArray.length < defaultRowLine) { - defaultRowLine = stackTraceElementProxyArray.length; - } - for (int i = 0; i < defaultRowLine; i++) { - stackTraceElementProxy = stackTraceElementProxyArray[i]; - StackTraceElement stackTraceElement = stackTraceElementProxy.getStackTraceElement(); - stringBuilder.append("\t\tat "); - stringBuilder.append(stackTraceElement.getClassName()); - stringBuilder.append("."); - stringBuilder.append(stackTraceElement.getMethodName()); - stringBuilder.append("("); - stringBuilder.append(stackTraceElement.getFileName()); - stringBuilder.append(":"); - stringBuilder.append(stackTraceElement.getLineNumber()); - stringBuilder.append(")"); - stringBuilder.append("\n"); - } - } - } - - - private String formatLongTime2Str(long timestamp) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - return dateFormat.format(timestamp); - } - - public void setActiveEnv(String activeEnv) { - this.activeEnv = activeEnv; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public void setWebHook(String webHook) { - this.webHook = webHook; - } - - public void setSecret(String secret) { - this.secret = secret; - } + private static final Logger logger = LoggerFactory.getLogger(LogMsgSendFilter.class); + private DingdingMsgSender msgSender = new DingdingMsgSender(); + private String webHook; + private String secret; + private String appName; + + private String activeEnv; + private String serverIp; + private String baseProjectPackage = "com.epmet"; + + @Override + public FilterReply decide(ILoggingEvent event) { + //如果日志级别等于设置的日志级别 则发送消息 + if (event.getLevel().isGreaterOrEqual(Level.ERROR)) { + try { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("【日志告警】\n"); + + stringBuilder.append("\n"); + + stringBuilder.append("告警级别:" + event.getLevel()); + stringBuilder.append("\n"); + if (StringUtils.isNotBlank(appName)) { + stringBuilder.append("服务名称:" + appName); + stringBuilder.append("\n"); + } + getServerInfo(); + if (StringUtils.isNotBlank(activeEnv)) { + stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName()); + stringBuilder.append("\n"); + } + + if (StringUtils.isNotBlank(serverIp)) { + stringBuilder.append("IP地址:" + serverIp); + stringBuilder.append("\n"); + } + stringBuilder.append("故障时间:" + formatLongTime2Str(event.getTimeStamp())); + stringBuilder.append("\n"); + stringBuilder.append("TraceId:" + Thread.currentThread().getName()); + stringBuilder.append("\n"); + String formattedMessage = event.getFormattedMessage(); + IThrowableProxy throwableProxy = event.getThrowableProxy(); + if (throwableProxy == null && formattedMessage.length() > 1000) { + formattedMessage = formattedMessage.substring(0, getCharacterPosition(formattedMessage, baseProjectPackage, 5)); + } + stringBuilder.append("告警信息:" + formattedMessage); + stringBuilder.append("\n"); + + + //异常信息处理 暂时处理一级的5行数据 + apendStackInfo(stringBuilder, throwableProxy); + DingTalkTextMsg msg = new DingTalkTextMsg(); + msg.setContent(stringBuilder.toString()); + if (StringUtils.isNotBlank(webHook)) { + msg.setWebHook(webHook); + } + if (StringUtils.isNotBlank(secret)) { + msg.setSecret(secret); + } + boolean flag = msgSender.sendMsgAsync(msg); + if (!flag) { + logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); + } + } catch (Exception e) { + logger.warn("decide exception", e); + } + } + //交给其他filter继续向下处理 + return super.decide(event); + + } + + /** + * desc:获取服务 ip及profile信息 + */ + private void getServerInfo() { + try { + if (serverIp == null) { + InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); + serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + } + } catch (Exception e) { + logger.warn("getServerInfo get bean InetUtils exception", e); + return; + } + try { + if (activeEnv == null) { + Environment environment = SpringContextUtils.getBean(Environment.class); + String[] activeProfiles = environment.getActiveProfiles(); + if (activeProfiles != null && activeProfiles.length > 0) { + logger.info("activeProfiles:{}", activeProfiles); + activeEnv = activeProfiles[0]; + } + } + } catch (Exception e) { + logger.warn("getServerInfo get bean Environment exception", e); + } + } + + private void apendStackInfo(StringBuilder stringBuilder, IThrowableProxy throwableProxy) { + int defaultRowLine = 5; + if (throwableProxy != null) { + stringBuilder.append("异常信息:") + .append(throwableProxy.getClassName()) + .append(" : ") + .append(throwableProxy.getMessage()) + .append("\n"); + + StackTraceElementProxy[] stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray(); + StackTraceElementProxy stackTraceElementProxy = null; + + if (stackTraceElementProxyArray.length < defaultRowLine) { + defaultRowLine = stackTraceElementProxyArray.length; + } + for (int i = 0; i < defaultRowLine; i++) { + stackTraceElementProxy = stackTraceElementProxyArray[i]; + StackTraceElement stackTraceElement = stackTraceElementProxy.getStackTraceElement(); + stringBuilder.append("\t\tat "); + stringBuilder.append(stackTraceElement.getClassName()); + stringBuilder.append("."); + stringBuilder.append(stackTraceElement.getMethodName()); + stringBuilder.append("("); + stringBuilder.append(stackTraceElement.getFileName()); + stringBuilder.append(":"); + stringBuilder.append(stackTraceElement.getLineNumber()); + stringBuilder.append(")"); + stringBuilder.append("\n"); + } + } + } + + public static void main(String[] args) { + String msg = "<<<<<<<<异常响应<<<<<<<<:事务流水号:na1597027822634, 执行时长:59ms, 响应数据:{\"code\":8102,\"internalMsg\":\"验证码错误\",\"msg\":\"验证码错误\"}, 异常信息:验证码错误, 堆栈信息:com.epmet.commons.tools.exception.RenException: \n" + + " at com.epmet.service.impl.VolunteerInfoServiceImpl.authenticate(VolunteerInfoServiceImpl.java:91)\n" + + " at com.epmet.service.impl.VolunteerInfoServiceImpl$$FastClassBySpringCGLIB$$7babb2e8.invoke()\n" + + " at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n" + + " at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\n" + + " at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)\n" + + " at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + + " at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)\n" + + " at com.epmet.service.impl.VolunteerInfoServiceImpl$$EnhancerBySpringCGLIB$$f78b4778.authenticate()\n" + + " at com.epmet.controller.ResiVolunteerController.authenticate(ResiVolunteerController.java:59)\n" + + " at com.epmet.controller.ResiVolunteerController$$FastClassBySpringCGLIB$$e023fb55.invoke()\n" + + " at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n" + + " at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\n" + + " at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + + " at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)\n" + + " at com.epmet.commons.tools.aspect.BaseRequestLogAspect.proceed(BaseRequestLogAspect.java:66)\n" + + " at com.epmet.aspect.RequestLogAspect.proceed(RequestLogAspect.java:26)\n" + + " at sun.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)\n" + + " at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" + + " at java.lang.reflect.Method.invoke(Method.java:498)\n" + + " at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)\n" + + " at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)\n" + + " at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + + " at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)\n" + + " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + + " at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)\n" + + " at com.epmet.controller.ResiVolunteerController$$EnhancerBySpringCGLIB$$1c0751c0.authenticate()\n" + + " at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" + + " at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" + + " at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" + + " at java.lang.reflect.Method.invoke(Method.java:498)\n" + + " at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)\n" + + " at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)\n" + + " at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)\n" + + " at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893)\n" + + " at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798)\n" + + " at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\n" + + " at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)\n" + + " at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)\n" + + " at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\n" + + " at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\n" + + " at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)\n" + + " at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\n" + + " at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)\n" + + " at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\n" + + " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + + " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + + " at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)\n" + + " at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)\n" + + " at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)\n" + + " at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)\n" + + " at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\n" + + " at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\n" + + " at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\n" + + " at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)\n" + + " at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\n" + + " at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)\n" + + " at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)\n" + + " at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n" + + " at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n" + + " at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n" + + " at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n" + + " at java.lang.Thread.run(Thread.java:745)"; + + String substring = msg.substring(0, getCharacterPosition(msg, "com.epme1t", 5)); + System.out.println(substring); + } + + + public static int getCharacterPosition(String string, String findStr, int time) { + Matcher slashMatcher = null; + try { + slashMatcher = Pattern.compile(findStr).matcher(string); + int mIdx = 0; + while (slashMatcher.find()) { + mIdx++; + if (mIdx == time) { + break; + } + } + return slashMatcher.start(); + } catch (Exception e) { + logger.warn("getCharacterPosition no matche"); + return 0; + } + } + + + private String formatLongTime2Str(long timestamp) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + return dateFormat.format(timestamp); + } + + public void setActiveEnv(String activeEnv) { + this.activeEnv = activeEnv; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public void setWebHook(String webHook) { + this.webHook = webHook; + } + + public void setSecret(String secret) { + this.secret = secret; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 2bc11e4e43..b8f7c3e3d2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -1,5 +1,6 @@ package com.epmet.controller; +import com.epmet.commons.tools.exception.RenException; import com.epmet.dto.AgencySubTreeDto; import com.epmet.service.StatsDemoService; import lombok.extern.slf4j.Slf4j; @@ -28,8 +29,7 @@ public class DemoController { @GetMapping("testAlarm") public void testAlarm() { //for (int i = 0; i < 20; i++) { - log.error("测试消息"); - //} + throw new RenException("测试消息长度"); } @GetMapping("testtx") diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java index 8e7de04d23..7e86cbaa17 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeCustomerDTO.java @@ -92,6 +92,26 @@ public class CodeCustomerDTO implements Serializable { * 二维码 */ private String qrCode; + /** + * 发布模式 gary:分阶段发布,total:全量发布 + */ + private String releaseType; + /** + * 灰度值 + */ + private Integer garyPercentage; + /** + * 上传时间 + */ + private Date commitTime; + /** + * 提交审核时间 + */ + private Date auditTime; + /** + * 发布时间 + */ + private Date releaseTime; /** * 乐观锁 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java index 65fa58f1cd..65f67e142c 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java @@ -43,6 +43,11 @@ public class CodeOperationHistoryDTO implements Serializable { */ private String customerId; + /** + * 小程序类型 居民端resi,工作端work + */ + private String clientType; + /** * 代码ID */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeVersionInfoResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeVersionInfoResultDTO.java new file mode 100644 index 0000000000..03853d654b --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CodeVersionInfoResultDTO.java @@ -0,0 +1,112 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/8/7 14:00 + */ +@NoArgsConstructor +@Data +public class CodeVersionInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 5822281118416848107L; + /** + * + */ + private CommitBean commit; + /** + * + */ + private AuditBean audit; + /** + * + */ + private ReleaseBean release; + + @NoArgsConstructor + @Data + public static class CommitBean { + private String codeId; + /** + * + */ + private String version; + /** + * + */ + private String codeInfo; + /** + * + */ + private String commitTime; + /** + * + */ + private String modelId; + } + + @NoArgsConstructor + @Data + public static class AuditBean { + private String codeId; + /** + * + */ + private String version; + /** + * + */ + private String codeInfo; + /** + * + */ + private String commitTime; + /** + * + */ + private String auditTime; + /** + * + */ + private String status; + } + + @NoArgsConstructor + @Data + public static class ReleaseBean { + private String codeId; + /** + * + */ + private String version; + /** + * + */ + private String codeInfo; + /** + * + */ + private String commitTime; + /** + * + */ + private String auditTime; + /** + * + */ + private String releaseTime; + /** + * + */ + private String releaseType; + /** + * + */ + private int grayPercentage; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml index 71002a4833..c6a1deb762 100644 --- a/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml +++ b/epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-third-server: container_name: epmet-third-server-dev - image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.116 + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.117 ports: - "8110:8110" network_mode: host # 使用现有网络 diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index 306cb6ed20..b3f78ca43d 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.0.116 + 0.0.117 com.epmet diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java index 25cc536e72..b7b7ca6ed6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java @@ -207,4 +207,12 @@ public class CodeController { codeService.setDomain(customerId); return new Result<>(); } + + @PostMapping("customers") + public Result getCustomerList(@RequestBody UploadListFormDTO formDTO) { + PageData pageData = codeService.getCustomerList(formDTO); + return new Result().ok(pageData); + } + + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index ef9f3d3425..13ad00fc9d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -179,5 +179,18 @@ public class PaCustomerController { return new Result().ok(paCustomerService.getAccountBasicInfo(formDTO)); } + /** + * 获取客户小程序列表 + * @author zhaoqifeng + * @date 2020/8/10 9:43 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("miniprolist") + public Result getCustomerList(@RequestBody UploadListFormDTO formDTO) { + PageData pageData = paCustomerService.getCustomerList(formDTO); + return new Result().ok(pageData); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java index f7a2eee380..0b1916a56a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CodeCustomerDao.java @@ -94,4 +94,51 @@ public interface CodeCustomerDao extends BaseDao { */ CodeCustomerDTO selectUploadCodeByCustomer(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 开发版 + * @author zhaoqifeng + * @date 2020/8/7 15:02 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO selectCommitInfo(@Param("customerId") String customerId, @Param("clientType") String clientType); + /** + * 审核版 + * @author zhaoqifeng + * @date 2020/8/7 15:02 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO selectAuditInfo(@Param("customerId") String customerId, @Param("clientType") String clientType); + /** + * 线上版 + * @author zhaoqifeng + * @date 2020/8/7 15:02 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO selectReleaseInfo(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 上一个已发布版本 + * @author zhaoqifeng + * @date 2020/8/7 15:12 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO selectLastVersion(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 激活上一版本 + * @author zhaoqifeng + * @date 2020/8/7 15:18 + * @param codeId + * @return void + */ + void updateVersion(@Param("codeId") String codeId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java index 126ef49db3..8a5e04675c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java @@ -21,9 +21,11 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.form.ModifyCustomerFormDTO; import com.epmet.dto.form.RegisterByAuthFormDTO; +import com.epmet.dto.form.UploadListFormDTO; import com.epmet.dto.result.CustomerAgencyResultDTO; import com.epmet.dto.result.CustomerAndUserResultDTO; import com.epmet.dto.result.RegisterByAuthResultDTO; +import com.epmet.dto.result.UploadListResultDTO; import com.epmet.entity.PaCustomerEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -86,6 +88,15 @@ public interface PaCustomerDao extends BaseDao { */ String selectCustomerName(@Param("customerId") String customerId); + /** + * 获取已初始化客户列表 + * @author zhaoqifeng + * @date 2020/8/7 17:44 + * @param formDTO + * @return java.util.List + */ + List selectInitCustomerList(UploadListFormDTO formDTO); + /** * @author sun * @Description 查询客户及管理员信息 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java index af21992505..a88d330ff1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeCustomerEntity.java @@ -93,5 +93,26 @@ public class CodeCustomerEntity extends BaseEpmetEntity { */ private String qrCode; + /** + * 发布模式 gary:分阶段发布,total:全量发布 + */ + private String releaseType; + /** + * 灰度值 + */ + private Integer garyPercentage; + /** + * 上传时间 + */ + private Date commitTime; + /** + * 提交审核时间 + */ + private Date auditTime; + /** + * 发布时间 + */ + private Date releaseTime; + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java index 706351f4f7..08ea501e7d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java @@ -43,6 +43,11 @@ public class CodeOperationHistoryEntity extends BaseEpmetEntity { */ private String customerId; + /** + * 小程序类型 居民端resi,工作端work + */ + private String clientType; + /** * 代码ID */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java index bc1ec68f6b..fcbddcd665 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeCustomerService.java @@ -131,4 +131,34 @@ public interface CodeCustomerService extends BaseService { * @return void */ void deleteCode(String customerId, String clientType); + + /** + * 开发版 + * @author zhaoqifeng + * @date 2020/8/7 15:34 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO getCommitInfo(String customerId, String clientType); + + /** + * 审核版 + * @author zhaoqifeng + * @date 2020/8/7 15:34 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO getAuditInfo(String customerId, String clientType); + + /** + * 线上版 + * @author zhaoqifeng + * @date 2020/8/7 15:34 + * @param customerId + * @param clientType + * @return com.epmet.dto.CodeCustomerDTO + */ + CodeCustomerDTO getReleaseInfo(String customerId, String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java index 19928c70f6..a2fb76a0d7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java @@ -2,10 +2,7 @@ package com.epmet.service; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.form.*; -import com.epmet.dto.result.CategoryResultDTO; -import com.epmet.dto.result.QrCodeResultDTO; -import com.epmet.dto.result.ReasonResultDTO; -import com.epmet.dto.result.TemplateListResultDTO; +import com.epmet.dto.result.*; import java.util.List; @@ -54,6 +51,15 @@ public interface CodeService { */ PageData uploadList(UploadListFormDTO formDTO); + /** + * 获取版本信息 + * @author zhaoqifeng + * @date 2020/8/7 15:30 + * @param formDTO + * @return com.epmet.dto.result.CodeVersionInfoResultDTO + */ + CodeVersionInfoResultDTO version(CustomerClientFormDTO formDTO); + /** * 提交审核 * @@ -148,4 +154,13 @@ public interface CodeService { */ void setDomain(String customerId); + /** + * 已初始化客户列表 + * @author zhaoqifeng + * @date 2020/8/7 17:57 + * @param formDTO + * @return com.epmet.commons.tools.page.PageData + */ + PageData getCustomerList(UploadListFormDTO formDTO); + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index 88259e13c9..b9c77f90f3 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -204,4 +204,13 @@ public interface PaCustomerService extends BaseService { * @return com.epmet.dto.result.AccountBasicInfoResultDTO */ AccountBasicInfoResultDTO getAccountBasicInfo(CustomerClientFormDTO formDTO); + + /** + * 获取已初始化客户列表 + * @author zhaoqifeng + * @date 2020/8/7 17:41 + * @param formDTO + * @return com.epmet.commons.tools.page.PageData + */ + PageData getCustomerList(UploadListFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java index 73aa86ccf3..cc3b41531d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java @@ -129,5 +129,20 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl auditingList = codeCustomerService.getAuditingCodeList(formDTO.getSource()); - String customerId = formDTO.getCustomerId(); - if (null != auditingList && auditingList.size() > NumConstant.ZERO) { - auditingList.forEach(code -> { - //获取小程序调用令牌 - AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(code.getCustomerId(), code.getClientType()); - //获取审核结果信息 - CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId()); - //调用微信API获取最新审核状态 - WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); - request.setAuditId(auditResult.getAuditId()); - WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); - if (wxAuditResult.success()) { - WxMaAuditStatusResult result = wxAuditResult.getData(); - if (result.getStatus() == NumConstant.ZERO) { - code.setStatus(CodeConstant.AUDIT_SUCCESS); - auditResult.setResult(CodeConstant.AUDIT_SUCCESS); - saveOperation(customerId, code.getId(), code.getUserVersion(), CodeConstant.OPER_SUCCESS, "审核成功"); - } else if (result.getStatus() == NumConstant.ONE) { - code.setStatus(CodeConstant.AUDIT_FAILED); - auditResult.setResult(CodeConstant.AUDIT_FAILED); - auditResult.setReason(result.getReason()); - auditResult.setScreenShot(result.getScreenshot()); - saveOperation(customerId, code.getId(), code.getUserVersion(), CodeConstant.OPER_FAILED, result.getReason()); - } else if (result.getStatus() == NumConstant.FOUR) { - code.setStatus(CodeConstant.DELAY); - auditResult.setResult(CodeConstant.DELAY); - auditResult.setReason(result.getReason()); - saveOperation(customerId, code.getId(), code.getUserVersion(), CodeConstant.OPER_DELAY, result.getReason()); - } - codeCustomerService.update(code); - codeAuditResultService.update(auditResult); + return codeCustomerService.getCodeList(formDTO); + } + + @Override + public CodeVersionInfoResultDTO version(CustomerClientFormDTO formDTO) { + CodeVersionInfoResultDTO resultDTO = new CodeVersionInfoResultDTO(); + //开发版本 + CodeCustomerDTO commit = codeCustomerService.getCommitInfo(formDTO.getCustomerId(), formDTO.getClientType()); + resultDTO.getCommit().setCodeId(commit.getId()); + resultDTO.getCommit().setCodeInfo(commit.getUserDesc()); + resultDTO.getCommit().setModelId(commit.getTemplateId()); + resultDTO.getCommit().setVersion(commit.getUserVersion()); + resultDTO.getCommit().setCommitTime(DateUtils.format(commit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); + //审核版本 + CodeCustomerDTO audit = codeCustomerService.getAuditInfo(formDTO.getCustomerId(), formDTO.getClientType()); + resultDTO.getAudit().setCodeId(audit.getId()); + resultDTO.getAudit().setVersion(audit.getUserVersion()); + resultDTO.getAudit().setCodeInfo(audit.getUserDesc()); + if (CodeConstant.AUDITING.equals(audit.getStatus())) { + //获取小程序调用令牌 + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + //获取审核结果信息 + CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(audit.getId()); + //调用微信API获取最新审核状态 + WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); + request.setAuditId(auditResult.getAuditId()); + WxResult wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); + if (wxAuditResult.success()) { + WxMaAuditStatusResult result = wxAuditResult.getData(); + if (result.getStatus() == NumConstant.ZERO) { + audit.setStatus(CodeConstant.AUDIT_SUCCESS); + auditResult.setResult(CodeConstant.AUDIT_SUCCESS); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_SUCCESS + , "审核成功"); + } else if (result.getStatus() == NumConstant.ONE) { + audit.setStatus(CodeConstant.AUDIT_FAILED); + auditResult.setResult(CodeConstant.AUDIT_FAILED); + auditResult.setReason(result.getReason()); + auditResult.setScreenShot(result.getScreenshot()); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_FAILED, + result.getReason()); + } else if (result.getStatus() == NumConstant.FOUR) { + audit.setStatus(CodeConstant.DELAY); + auditResult.setResult(CodeConstant.DELAY); + auditResult.setReason(result.getReason()); + saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_DELAY, + result.getReason()); } - }); + codeCustomerService.update(audit); + codeAuditResultService.update(auditResult); + } } - return codeCustomerService.getCodeList(formDTO); + resultDTO.getAudit().setStatus(audit.getStatus()); + resultDTO.getAudit().setCommitTime(DateUtils.format(audit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); + resultDTO.getAudit().setAuditTime(DateUtils.format(audit.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); + //线上版本 + CodeCustomerDTO release = codeCustomerService.getReleaseInfo(formDTO.getCustomerId(), formDTO.getClientType()); + resultDTO.getRelease().setCodeId(release.getId()); + resultDTO.getRelease().setCodeInfo(release.getUserDesc()); + resultDTO.getRelease().setCommitTime(DateUtils.format(release.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); + resultDTO.getRelease().setAuditTime(DateUtils.format(release.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); + resultDTO.getRelease().setReleaseTime(DateUtils.format(release.getReleaseTime(), DateUtils.DATE_TIME_PATTERN)); + resultDTO.getRelease().setReleaseType(release.getReleaseType()); + resultDTO.getRelease().setGrayPercentage(release.getGaryPercentage()); + resultDTO.getRelease().setVersion(release.getUserVersion()); + return resultDTO; } @Override @@ -233,8 +256,8 @@ public class CodeServiceImpl implements CodeService { request.setUgcDeclare(formDTO.getUgcDeclare()); WxResult wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request); if (!wxResult.success()) { - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, - wxResult.getErrorMsg()); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } if(formDTO.getIsSpeed()) { @@ -243,8 +266,8 @@ public class CodeServiceImpl implements CodeService { speedRequest.setAuditId(wxResult.getData()); WxResult wxSpeedResult = wxMaCodeService.speedUpAudit(authInfo.getAuthorizerAccessToken(), speedRequest); if (!wxSpeedResult.success()) { - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, - wxSpeedResult.getErrorMsg()); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxSpeedResult.getErrorMsg()); throw new RenException(wxSpeedResult.getErrorCode(), wxSpeedResult.getErrorMsg()); } } @@ -270,8 +293,8 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.AUDITING); codeCustomerService.update(codeCustomerDTO); - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, - "审核中"); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), + CodeConstant.OPER_SUBMIT, "审核中"); } @Override @@ -302,8 +325,8 @@ public class CodeServiceImpl implements CodeService { //调用微信API撤销审核 WxResult wxResult = wxMaCodeService.undoCodeAudit(authInfo.getAuthorizerAccessToken()); if (!wxResult.success()) { - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, - wxResult.getErrorMsg()); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } //更新审核结果 @@ -315,8 +338,8 @@ public class CodeServiceImpl implements CodeService { //更新审核操作记录描述 codeOperationHistoryService.updateDescribe(codeCustomerDTO.getId(), "已撤回"); - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_UNDO, - "成功"); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), + CodeConstant.OPER_UNDO, "成功"); } @Override @@ -338,15 +361,18 @@ public class CodeServiceImpl implements CodeService { //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.RELEASE_FAILED); codeCustomerService.update(codeCustomerDTO); - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, - wxResult.getErrorMsg()); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), + codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, wxResult.getErrorMsg()); throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); } + //将之前上传信息删除 + codeCustomerService.deleteCode(formDTO.getCustomerId(), codeCustomerDTO.getClientType()); + //更新代码表状态 codeCustomerDTO.setStatus(CodeConstant.RELEASE_SUCCESS); codeCustomerService.update(codeCustomerDTO); - saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_RELEASE, - "发布成功"); + saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), + CodeConstant.OPER_RELEASE, "发布成功"); } @Override @@ -522,9 +548,15 @@ public class CodeServiceImpl implements CodeService { }); } - private void saveOperation(String customerId, String codeId, String version, String operation, String describe) { + @Override + public PageData getCustomerList(UploadListFormDTO formDTO) { + return paCustomerService.getCustomerList(formDTO); + } + + private void saveOperation(String customerId, String clientType, String codeId, String version, String operation, String describe) { CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO(); operationDTO.setCustomerId(customerId); + operationDTO.setClientType(clientType); operationDTO.setCodeId(codeId); operationDTO.setVersion(version); operationDTO.setOperation(operation); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 806be0f664..c77f86e336 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -633,4 +633,12 @@ public class PaCustomerServiceImpl extends BaseServiceImpl list = baseDao.selectInitCustomerList(formDTO); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java index d90eb661d0..3e8994ae50 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java @@ -189,13 +189,11 @@ public class WarrantServiceImpl implements WarrantService { Object createTime = xml.get(ModuleConstant.CREATE_TIME); Date date = componentVerifyTicketServiceImpl.sToDate(createTime.toString()); messagePushTextFormDTO.setWeChatCreateTime(date); -// messagePushTextDao.insertMessageText(messagePushTextFormDTO); String content = messagePushTextFormDTO.getContent(); log.info(String.format(ThirdRunTimeInfoConstant.CONTENT,content)); if(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT.equals(content)){ log.info("收到消息,要回复了......"); -// String returnContent = content+ModuleConstant._CALL_BACK; - String returnContent = "TESTCOMPONENT_MSG_TYPE_TEXT_callback"; + String returnContent = content+ModuleConstant._CALL_BACK; log.info("拼接的回复内容【普通】:"+returnContent); replyTextMessage(request, response, returnContent, toUserName, fromUserName); @@ -240,18 +238,21 @@ public class WarrantServiceImpl implements WarrantService { "> 客户端:"+clientType+"\n\n"+ "> 延时原因:"+result); break; + default: + markdown.setText("机器人生病了......"); + log.info("event为:"+event); + break; } request.setMarkdown(markdown); - log.info("robot需要发送的内容为:"+markdown.getTitle()); + log.info("robot需要发送的内容为:"+markdown.getText()); String url = "https://oapi.dingtalk.com/robot/send?access_token=2438902efbcc15909deb7076963c5cbe2d6fdbfdb9d66750faab2f2cce6eb09f"; String secret = "SECe3c785dd254659608667a4a623acc5a0395636143411617f6e36838b48941e74"; this.sendCodeMsg(request,url,secret); } -/* - public static void main(String[] args) { - WarrantServiceImpl w = new WarrantServiceImpl(); - w.dingDingRobot("审核失败","weapp_audit_fail","机器人测试","居民端"); - }*/ +// public static void main(String[] args) { +// WarrantServiceImpl w = new WarrantServiceImpl(); +// w.dingDingRobot("审核失败","weapp_audit_fail","机器人测试","居民端"); +// } public Result sendCodeMsg(OapiRobotSendRequest request,String url,String secret) { Long timestamp = System.currentTimeMillis(); @@ -263,7 +264,10 @@ public class WarrantServiceImpl implements WarrantService { String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8"); log.info("sign为:"+sign); url = url.concat("×tamp=" + timestamp + "&sign=" + sign); - Result stringResult = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(request)); + log.info("发送url:"+url); + String requestString = JSON.toJSONString(request); + log.info("发送内容:"+requestString); + Result stringResult = HttpClientManager.getInstance().sendPostByJSON(url, requestString); log.info("robot发送消息结果为:"+stringResult.getData()); return stringResult; } catch (Exception e) { @@ -294,22 +298,6 @@ public class WarrantServiceImpl implements WarrantService { replyTextMessage(request, response, content, toUserName, fromUserName); } - - /** - * 立马回应文本消息并最终触达粉丝 - * @param content 文本 - * @param toUserName 发送接收人 - * @param fromUserName 发送人 - * @author zxc - */ - public void processTextMessage(HttpServletRequest request, HttpServletResponse response, - String content,String toUserName, String fromUserName) - throws IOException, DocumentException{ - - } - - - /** * 方法描述: 直接返回给微信开放平台 * @param request @@ -383,24 +371,4 @@ public class WarrantServiceImpl implements WarrantService { log.info("客服发送接口返回值:"+data); } - - /** - * 方法描述: 返回数据到请求方 - * @param data 数据 - * @param response - * @author zxc - */ - public void returnJSON(Object data,HttpServletResponse response) { - try { - ObjectMapper objectMapper = new ObjectMapper(); - JsonEncoding encoding = JsonEncoding.UTF8; - response.setContentType(ModuleConstant.APPLICATION_JSON); - JsonGenerator generator = objectMapper.getJsonFactory(). - createJsonGenerator(response.getOutputStream(), encoding); - objectMapper.writeValue(generator, data); - } catch (Exception e) { - e.printStackTrace(); - } - } - } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.6__thirdUpdate.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.6__thirdUpdate.sql new file mode 100644 index 0000000000..b2e6d411ef --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.6__thirdUpdate.sql @@ -0,0 +1,8 @@ +alter table code_customer add RELEASE_TYPE varchar(10) NULL comment '发布模式 gary:分阶段发布,total:全量发布' after QR_CODE; +alter table code_customer add GARY_PERCENTAGE int(11) NULL comment '灰度值' after RELEASE_TYPE; +alter table code_customer add COMMIT_TIME datetime NULL comment '上传时间' after GARY_PERCENTAGE; +alter table code_customer add AUDIT_TIME datetime NULL comment '提交审核时间' after COMMIT_TIME; +alter table code_customer add RELEASE_TIME datetime NULL comment '发布时间' after AUDIT_TIME; + + +alter table code_operation_history add CLIENT_TYPE datetime NULL comment '小程序类型 居民端resi,工作端work' after CUSTOMER_ID; \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml index c05006ae39..4ef32234ef 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml @@ -21,6 +21,7 @@ + + SELECT ID, + USER_VERSION, + USER_DESC, + TEMPLATE_ID, + COMMIT_TIME + FROM code_customer + WHERE CUSTOMER_ID = #{customerId} + AND CLIENT_TYPE = #{clientType} + AND STATUS = 'unaudited' + AND DEL_FLAG = '0' + + + + + + UPDATE code_customer + SET + DEL_FLAG = '0' + WHERE ID = #{codeId} + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml index ffceb02e07..b14f2a4764 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml @@ -81,6 +81,26 @@ del_flag = 0 AND id = #{customerId} +