Quellcode durchsuchen

配置文件区分开发环境、测试环境、生产环境

lgs vor 11 Monaten
Ursprung
Commit
cd8a4bc15e

+ 20 - 8
src/main/java/com/kexun/service/impl/ReportInfoServiceImpl.java

@@ -9,6 +9,7 @@ import com.kexun.model.dto.ReportInfoDTO;
 import com.kexun.model.ro.ReportInfoRO;
 import com.kexun.service.ReportInfoService;
 import lombok.extern.slf4j.Slf4j;
+import org.omg.CORBA.IRObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,34 +30,44 @@ public class ReportInfoServiceImpl extends ServiceImpl<ReportInfoMapper, ReportI
 
     @Autowired
     private ReportInfoMapper reportInfoMapper;
+
     /**
      * 保存报文信息
+     *
      * @param reportInfo
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void saveReportInfo(ReportInfo reportInfo){
-        super.save(reportInfo);
+    public void saveReportInfo(ReportInfo reportInfo) {
+        //根据business_id查询是否存在,存在的话,执行update语句
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("business_id", reportInfo.getBusinessId());
+        ReportInfo reportInfoResult = super.getOne(queryWrapper);
+        if (reportInfoResult != null) {
+            reportInfo.setId(reportInfoResult.getId());
+        }
+        super.saveOrUpdate(reportInfo);
     }
 
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void updateReportInfo(ReportInfoDTO reportInfoDTO){
+    public void updateReportInfo(ReportInfoDTO reportInfoDTO) {
         reportInfoMapper.updateReportInfo(reportInfoDTO);
     }
 
     /**
      * 按条件查询报文信息
+     *
      * @param reportInfoDTO
      * @return
      */
     @Override
     public List<ReportInfo> listReportInfo(ReportInfoDTO reportInfoDTO) {
         QueryWrapper queryWrapper = new QueryWrapper();
-        if (reportInfoDTO.getStatus()!=null){
-            queryWrapper.eq("status",reportInfoDTO.getStatus());
-        }else {
+        if (reportInfoDTO.getStatus() != null) {
+            queryWrapper.eq("status", reportInfoDTO.getStatus());
+        } else {
             queryWrapper.eq("status", ReportStatusEnum.NO_PRASE.getValue());
         }
         List<ReportInfo> list = reportInfoMapper.selectList(queryWrapper);
@@ -65,11 +76,12 @@ public class ReportInfoServiceImpl extends ServiceImpl<ReportInfoMapper, ReportI
 
     /**
      * 根据主键查询报文信息
+     *
      * @param id
      * @return
      */
-    public ReportInfo getReportInfo(Long id){
-       return reportInfoMapper.selectById(id);
+    public ReportInfo getReportInfo(Long id) {
+        return reportInfoMapper.selectById(id);
     }
 
 

+ 1 - 0
src/main/java/com/kexun/task/ReportParseJobHandler.java

@@ -57,6 +57,7 @@ public class ReportParseJobHandler {
         ReportInfoDTO reportInfoQuery = new ReportInfoDTO();
         reportInfoQuery.setStatus(ReportStatusEnum.NO_PRASE.getValue());
         List<ReportInfo> reportInfos = reportInfoService.listReportInfo(reportInfoQuery);
+
         for (ReportInfo reportInfo : reportInfos) {
             //body报文体是Base64位,先解码 再解压
             String body = reportInfo.getBody();

+ 102 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,102 @@
+#生产环境
+server:
+  port: 8888
+spring:
+  ####redis
+  redis:
+    database: 0
+    host: 127.0.0.1
+    jedis:
+      pool:
+        max-active: 8
+        max-idle: 8
+        max-wait: -1ms
+        min-idle: 0
+#    password: 123456
+    port: 6379
+    timeout: 15000ms
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://39.101.189.130:33306/cr_loan?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: credit
+    password: 1q2w3e4r
+    # 初始化大小,最小,最大
+    initialSize: 5
+    minIdle: 5
+    maxActive: 20
+    # 配置获取连接等待超时的时间(毫秒)
+    maxWait: 60000
+    # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+    timeBetweenEvictionRunsMillis: 60000
+    # 配置有一个连接在连接池中的最小生存时间,单位是毫秒
+    minEvictableIdleTimeMillis: 300000
+    validationQuery: SELECT 1 FROM DUAL
+    testWhileIdle: true
+    testOnBorrow: false
+    testOnReturn: false
+    # 打开PSCache,指定每个连接上PSCache的大小
+    poolPreparedStatements: true
+    maxPoolPreparedStatementPerConnectionSize: 20
+    # 配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙
+    filters: stat, wall, log4j
+    # 通过connectProperties属性来打开mergeSql功能,慢SQL记录
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+###MybatisPlus
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+  type-aliases-package: com.kexun.entity
+  type-handlers-package: com.kexun.typehandler
+
+##日志配置
+logging:
+  config: classpath:log4j.properties
+  level:
+    com.baomidou.mybatisplus.core.mapper: info
+
+config:
+  fileupload:
+    path: "/home/credit/file/"
+    warpath: "/home/credit/file/"
+
+report:
+  file:
+    # xml文件来源路径
+    #xmlSourcePath: "/home/credit/file/zxjx/"
+    xmlSourcePath: "/Users/lgs/work/xml/"
+    # xml文件的备份路径
+    #xmlBackPath: "/home/credit/file/back/"
+    xmlBackPath: "/Users/lgs/work/back/"
+    # 解析出来的json文件
+    #jsonTargetPath: "/home/credit/file/json/"
+    jsonTargetPath: "/Users/lgs/work/json/"
+    # 存放的model文件
+    #modelTargetPath: "/home/credit/file/model/"
+    modelTargetPath: "/Users/lgs/work/model/"
+
+xxl:
+  job:
+    admin:
+      addresses: http://39.101.189.130:8080/xxl-job-admin/
+      ### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
+    executor:
+      appname: admin-api
+      ### 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
+      address:
+      ### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
+      ip:
+        ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口;
+      port: 9999
+        ### 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
+      logpath: /home/credit/logs/xxl-job/
+        ### 执行器日志保存天数 [选填] :值大于3时生效,启用执行器Log文件定期清理功能,否则不生效;
+      logretentiondays: 7
+      ### 执行器通讯TOKEN [选填]:非空时启用;
+    accessToken: default_token
+
+
+
+

+ 102 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,102 @@
+#生产环境
+server:
+  port: 8888
+spring:
+  ####redis
+  redis:
+    database: 0
+    host: 127.0.0.1
+    jedis:
+      pool:
+        max-active: 8
+        max-idle: 8
+        max-wait: -1ms
+        min-idle: 0
+    #    password: 123456
+    port: 6379
+    timeout: 15000ms
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://39.101.189.130:33306/cr_loan?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: credit
+    password: 1q2w3e4r
+    # 初始化大小,最小,最大
+    initialSize: 5
+    minIdle: 5
+    maxActive: 20
+    # 配置获取连接等待超时的时间(毫秒)
+    maxWait: 60000
+    # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+    timeBetweenEvictionRunsMillis: 60000
+    # 配置有一个连接在连接池中的最小生存时间,单位是毫秒
+    minEvictableIdleTimeMillis: 300000
+    validationQuery: SELECT 1 FROM DUAL
+    testWhileIdle: true
+    testOnBorrow: false
+    testOnReturn: false
+    # 打开PSCache,指定每个连接上PSCache的大小
+    poolPreparedStatements: true
+    maxPoolPreparedStatementPerConnectionSize: 20
+    # 配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙
+    filters: stat, wall, log4j
+    # 通过connectProperties属性来打开mergeSql功能,慢SQL记录
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+###MybatisPlus
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+  type-aliases-package: com.kexun.entity
+  type-handlers-package: com.kexun.typehandler
+
+##日志配置
+logging:
+  config: classpath:log4j.properties
+  level:
+    com.baomidou.mybatisplus.core.mapper: info
+
+config:
+  fileupload:
+    path: "/home/credit/file/"
+    warpath: "/home/credit/file/"
+
+report:
+  file:
+    # xml文件来源路径
+    xmlSourcePath: "/home/credit/file/zxjx/"
+    #xmlSourcePath: "/Users/lgs/work/xml/"
+    # xml文件的备份路径
+    xmlBackPath: "/home/credit/file/back/"
+    #xmlBackPath: "/Users/lgs/work/back/"
+    # 解析出来的json文件
+    jsonTargetPath: "/home/credit/file/json/"
+    #jsonTargetPath: "/Users/lgs/work/json/"
+    # 存放的model文件
+    modelTargetPath: "/home/credit/file/model/"
+    #modelTargetPath: "/Users/lgs/work/model/"
+
+xxl:
+  job:
+    admin:
+      addresses: http://39.101.189.130:8080/xxl-job-admin/
+      ### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
+    executor:
+      appname: admin-api
+      ### 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
+      address:
+      ### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
+      ip:
+      ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口;
+      port: 9999
+      ### 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
+      logpath: /home/credit/logs/xxl-job/
+      ### 执行器日志保存天数 [选填] :值大于3时生效,启用执行器Log文件定期清理功能,否则不生效;
+      logretentiondays: 7
+      ### 执行器通讯TOKEN [选填]:非空时启用;
+    accessToken: default_token
+
+
+
+

+ 102 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,102 @@
+#生产环境
+server:
+  port: 8888
+spring:
+  ####redis
+  redis:
+    database: 0
+    host: 127.0.0.1
+    jedis:
+      pool:
+        max-active: 8
+        max-idle: 8
+        max-wait: -1ms
+        min-idle: 0
+    #    password: 123456
+    port: 6379
+    timeout: 15000ms
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://39.101.189.130:33306/cr_loan?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: credit
+    password: 1q2w3e4r
+    # 初始化大小,最小,最大
+    initialSize: 5
+    minIdle: 5
+    maxActive: 20
+    # 配置获取连接等待超时的时间(毫秒)
+    maxWait: 60000
+    # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+    timeBetweenEvictionRunsMillis: 60000
+    # 配置有一个连接在连接池中的最小生存时间,单位是毫秒
+    minEvictableIdleTimeMillis: 300000
+    validationQuery: SELECT 1 FROM DUAL
+    testWhileIdle: true
+    testOnBorrow: false
+    testOnReturn: false
+    # 打开PSCache,指定每个连接上PSCache的大小
+    poolPreparedStatements: true
+    maxPoolPreparedStatementPerConnectionSize: 20
+    # 配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙
+    filters: stat, wall, log4j
+    # 通过connectProperties属性来打开mergeSql功能,慢SQL记录
+    connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
+###MybatisPlus
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  configuration:
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+  type-aliases-package: com.kexun.entity
+  type-handlers-package: com.kexun.typehandler
+
+##日志配置
+logging:
+  config: classpath:log4j.properties
+  level:
+    com.baomidou.mybatisplus.core.mapper: info
+
+config:
+  fileupload:
+    path: "/home/credit/file/"
+    warpath: "/home/credit/file/"
+
+report:
+  file:
+    # xml文件来源路径
+    xmlSourcePath: "/home/credit/file/zxjx/"
+    #xmlSourcePath: "/Users/lgs/work/xml/"
+    # xml文件的备份路径
+    xmlBackPath: "/home/credit/file/back/"
+    #xmlBackPath: "/Users/lgs/work/back/"
+    # 解析出来的json文件
+    jsonTargetPath: "/home/credit/file/json/"
+    #jsonTargetPath: "/Users/lgs/work/json/"
+    # 存放的model文件
+    modelTargetPath: "/home/credit/file/model/"
+    #modelTargetPath: "/Users/lgs/work/model/"
+
+xxl:
+  job:
+    admin:
+      addresses: http://39.101.189.130:8080/xxl-job-admin/
+      ### 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
+    executor:
+      appname: admin-api
+      ### 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
+      address:
+      ### 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
+      ip:
+      ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口;
+      port: 9999
+      ### 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
+      logpath: /home/credit/logs/xxl-job/
+      ### 执行器日志保存天数 [选填] :值大于3时生效,启用执行器Log文件定期清理功能,否则不生效;
+      logretentiondays: 7
+      ### 执行器通讯TOKEN [选填]:非空时启用;
+    accessToken: default_token
+
+
+
+

+ 5 - 2
src/main/resources/application.yml

@@ -1,9 +1,11 @@
-
 #生产环境
 server:
   port: 8888
 
 spring:
+  profiles:
+    #dev:开发环境、test:测试环境、prod:生产环境
+    active: dev
   servlet:
     multipart:
       max-file-size: 50MB
@@ -82,9 +84,10 @@ report:
   file:
     # xml文件来源路径
     xmlSourcePath: "/home/credit/file/zxjx/"
+    #xmlSourcePath: "/Users/lgs/work/xml/"
     # xml文件的备份路径
     xmlBackPath: "/home/credit/file/back/"
-    #xmlSourcePath: "/Users/lgs/work/xml/"
+    #xmlBackPath: "/Users/lgs/work/back/"
     # 解析出来的json文件
     jsonTargetPath: "/home/credit/file/json/"
     #jsonTargetPath: "/Users/lgs/work/json/"