Browse Source

2023-11-30 升级动态数据源加载,删除冲突配置,配置文件修改,依赖更新,统计参数自动录入单据生成

develop
zhousq 12 months ago
parent
commit
d8ae512ef0
  1. 3
      lzbi-admin/src/main/java/com/lzbi/RuoYiApplication.java
  2. 58
      lzbi-admin/src/main/resources/application-dev.yml
  3. 2
      lzbi-admin/src/main/resources/application-test.yml
  4. 15
      lzbi-admin/src/main/resources/application.yml
  5. 11
      lzbi-common/pom.xml
  6. 6
      lzbi-framework/src/main/java/com/lzbi/framework/aspectj/DataSourceAspect.java
  7. 230
      lzbi-framework/src/main/java/com/lzbi/framework/config/DruidConfig.java
  8. 78
      lzbi-framework/src/main/java/com/lzbi/framework/config/properties/DruidProperties.java
  9. 14
      lzbi-module/pom.xml
  10. 70
      lzbi-module/src/main/java/com/lzbi/asset/controller/DcBusiWorkReadConfigController.java
  11. 2
      lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiWorkReadConfig.java
  12. 54
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillSubDao.java
  13. 1
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamBillMasterService.java
  14. 7
      lzbi-module/src/main/java/com/lzbi/task/domain/EumValueReadType.java
  15. 27
      lzbi-module/src/main/java/com/lzbi/task/domain/WorkReadVo.java
  16. 16
      lzbi-module/src/main/resources/mapper/asset/DcBusiParamBillMasterMapper.xml
  17. 11
      lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml
  18. 8
      lzbi-module/src/main/resources/mapper/asset/WorkParamReadMapper.xml

3
lzbi-admin/src/main/java/com/lzbi/RuoYiApplication.java

@ -1,5 +1,6 @@
package com.lzbi;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -11,7 +12,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi
*/
@EnableKnife4j
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class })
public class RuoYiApplication
{
public static void main(String[] args)

58
lzbi-admin/src/main/resources/application-dev.yml

@ -27,33 +27,9 @@ spring:
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
dynamic:
strict: true
druid:
# 主库数据源
master:
url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: luenmei
password: 123456
# 计费数据库
charge:
url: jdbc:oracle:thin:@//10.10.10.60:1521/HX?CONNECT_TIMEOUT=10000&Read_Timeout=120000
username: lmjt_sys
password: lmjt_sys
# 计费数据库
workDB:
driverClassName: org.postgresql.Driver
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:postgresql://10.10.10.56:5432/dctestdb?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: postgres
password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
@ -73,7 +49,7 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
@ -85,7 +61,7 @@ spring:
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-username: luenmeilz
login-password: 123456
filter:
stat:
@ -97,6 +73,32 @@ spring:
wall:
config:
multi-statement-allow: true
datasource:
# 主库数据源
master:
url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: luenmei
password: 123456
# # 计费数据库
# charge:
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//10.10.10.60:1521/HX?CONNECT_TIMEOUT=10000&Read_Timeout=120000
# username: lmjt_sys
# password: lmjt_sys
# 从库数据源
slave:
# 从数据源开关/默认关闭
url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: luenmei
password: 123456
workDB:
driverClassName: org.postgresql.Driver
#type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:postgresql://10.10.10.56:5432/dctestdb?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai
username: postgres
password: 123456
primary: master
# 日志配置
logging:
file:

2
lzbi-admin/src/main/resources/application-test.yml

@ -73,7 +73,7 @@ spring:
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-username: luenmeilz
login-password: 123456
filter:
stat:

15
lzbi-admin/src/main/resources/application.yml

@ -1,17 +1,17 @@
# 项目相关配置
luenmeilz:
# 名称
name: RuoYi
name: luenmeilz
# 版本
version: 3.8.6
version: 1.0.1
# 版权年份
copyrightYear: 2023
# 实例演示开关
demoEnabled: true
demoEnabled: false
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
addressEnabled: true
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 高德天气服务ip地址
@ -41,12 +41,9 @@ server:
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
max: 1000
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
# 用户配置
user:
password:
@ -83,7 +80,7 @@ token:
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
expireTime: 1440
# MyBatis Plus配置
mybatis-plus:

11
lzbi-common/pom.xml

@ -60,11 +60,11 @@
</dependency>
<!-- &lt;!&ndash; 动态数据源 &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
<!-- <version>3.5.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
@ -141,7 +141,6 @@
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
<type>pom</type>
</dependency>
<!-- -->
<dependency>

6
lzbi-framework/src/main/java/com/lzbi/framework/aspectj/DataSourceAspect.java

@ -20,9 +20,9 @@ import com.lzbi.framework.datasource.DynamicDataSourceContextHolder;
*
* @author ruoyi
*/
@Aspect
@Order(1)
@Component
//@Aspect
//@Order(1)
//@Component
public class DataSourceAspect
{
protected Logger logger = LoggerFactory.getLogger(getClass());

230
lzbi-framework/src/main/java/com/lzbi/framework/config/DruidConfig.java

@ -1,126 +1,126 @@
package com.lzbi.framework.config;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.sql.DataSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.alibaba.druid.util.Utils;
import com.lzbi.common.enums.DataSourceType;
import com.lzbi.common.utils.spring.SpringUtils;
import com.lzbi.framework.config.properties.DruidProperties;
import com.lzbi.framework.datasource.DynamicDataSource;
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;
//import javax.servlet.Filter;
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.sql.DataSource;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.web.servlet.FilterRegistrationBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
//import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
//import com.alibaba.druid.util.Utils;
//import com.lzbi.common.enums.DataSourceType;
//import com.lzbi.common.utils.spring.SpringUtils;
//import com.lzbi.framework.config.properties.DruidProperties;
//import com.lzbi.framework.datasource.DynamicDataSource;
/**
* druid 配置多数据源
*
* @author ruoyi
*/
@Configuration
//@Configuration
public class DruidConfig
{
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean(name = "dynamicDataSource")
@Primary
public DynamicDataSource dataSource(DataSource masterDataSource)
{
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources);
}
/**
* 设置数据源
*
* @param targetDataSources 备选数据源集合
* @param sourceName 数据源名称
* @param beanName bean名称
*/
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName)
{
try
{
DataSource dataSource = SpringUtils.getBean(beanName);
targetDataSources.put(sourceName, dataSource);
}
catch (Exception e)
{
}
}
/**
* 去除监控页面底部的广告
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
{
// 获取web监控页面的参数
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// 提取common.js的配置路径
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
final String filePath = "support/http/resources/js/common.js";
// 创建filter进行过滤
Filter filter = new Filter()
{
@Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
{
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
chain.doFilter(request, response);
// 重置缓冲区,响应头不会被重置
response.resetBuffer();
// 获取common.js
String text = Utils.readFromResource(filePath);
// 正则替换banner, 除去底部的广告信息
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text);
}
@Override
public void destroy()
{
}
};
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(filter);
registrationBean.addUrlPatterns(commonJsPattern);
return registrationBean;
}
// @Bean
// @ConfigurationProperties("spring.datasource.druid.master")
// public DataSource masterDataSource(DruidProperties druidProperties)
// {
// DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
// return druidProperties.dataSource(dataSource);
// }
//
// @Bean
// @ConfigurationProperties("spring.datasource.druid.slave")
// @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
// public DataSource slaveDataSource(DruidProperties druidProperties)
// {
// DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
// return druidProperties.dataSource(dataSource);
// }
//
// @Bean(name = "dynamicDataSource")
// @Primary
// public DynamicDataSource dataSource(DataSource masterDataSource)
// {
// Map<Object, Object> targetDataSources = new HashMap<>();
// targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
// setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
// return new DynamicDataSource(masterDataSource, targetDataSources);
// }
//
// /**
// * 设置数据源
// *
// * @param targetDataSources 备选数据源集合
// * @param sourceName 数据源名称
// * @param beanName bean名称
// */
// public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName)
// {
// try
// {
// DataSource dataSource = SpringUtils.getBean(beanName);
// targetDataSources.put(sourceName, dataSource);
// }
// catch (Exception e)
// {
// }
// }
//
// /**
// * 去除监控页面底部的广告
// */
// @SuppressWarnings({ "rawtypes", "unchecked" })
// @Bean
// @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
// public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
// {
// // 获取web监控页面的参数
// DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// // 提取common.js的配置路径
// String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
// String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
// final String filePath = "support/http/resources/js/common.js";
// // 创建filter进行过滤
// Filter filter = new Filter()
// {
// @Override
// public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
// {
// }
// @Override
// public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
// throws IOException, ServletException
// {
// chain.doFilter(request, response);
// // 重置缓冲区,响应头不会被重置
// response.resetBuffer();
// // 获取common.js
// String text = Utils.readFromResource(filePath);
// // 正则替换banner, 除去底部的广告信息
// text = text.replaceAll("<a.*?banner\"></a><br/>", "");
// text = text.replaceAll("powered.*?shrek.wang</a>", "");
// response.getWriter().write(text);
// }
// @Override
// public void destroy()
// {
// }
// };
// FilterRegistrationBean registrationBean = new FilterRegistrationBean();
// registrationBean.setFilter(filter);
// registrationBean.addUrlPatterns(commonJsPattern);
// return registrationBean;
// }
}

78
lzbi-framework/src/main/java/com/lzbi/framework/config/properties/DruidProperties.java

@ -1,15 +1,15 @@
package com.lzbi.framework.config.properties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import com.alibaba.druid.pool.DruidDataSource;
//import org.springframework.context.annotation.Configuration;
//import com.alibaba.druid.pool.DruidDataSource;
/**
* druid 配置属性
*
* @author ruoyi
*/
@Configuration
//@Configuration
public class DruidProperties
{
@Value("${spring.datasource.druid.initialSize}")
@ -50,40 +50,40 @@ public class DruidProperties
@Value("${spring.datasource.druid.testOnReturn}")
private boolean testOnReturn;
public DruidDataSource dataSource(DruidDataSource datasource)
{
/** 配置初始化大小、最小、最大 */
datasource.setInitialSize(initialSize);
datasource.setMaxActive(maxActive);
datasource.setMinIdle(minIdle);
/** 配置获取连接等待超时的时间 */
datasource.setMaxWait(maxWait);
/** 配置驱动连接超时时间,检测数据库建立连接的超时时间,单位是毫秒 */
datasource.setConnectTimeout(connectTimeout);
/** 配置网络超时时间,等待数据库操作完成的网络超时时间,单位是毫秒 */
datasource.setSocketTimeout(socketTimeout);
/** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
/** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis);
/**
* 用来检测连接是否有效的sql要求是一个查询语句常用select 'x'如果validationQuery为nulltestOnBorrowtestOnReturntestWhileIdle都不会起作用
*/
datasource.setValidationQuery(validationQuery);
/** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */
datasource.setTestWhileIdle(testWhileIdle);
/** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
datasource.setTestOnBorrow(testOnBorrow);
/** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
datasource.setTestOnReturn(testOnReturn);
return datasource;
}
//
// public DruidDataSource dataSource(DruidDataSource datasource)
// {
// /** 配置初始化大小、最小、最大 */
// datasource.setInitialSize(initialSize);
// datasource.setMaxActive(maxActive);
// datasource.setMinIdle(minIdle);
//
// /** 配置获取连接等待超时的时间 */
// datasource.setMaxWait(maxWait);
//
// /** 配置驱动连接超时时间,检测数据库建立连接的超时时间,单位是毫秒 */
// datasource.setConnectTimeout(connectTimeout);
//
// /** 配置网络超时时间,等待数据库操作完成的网络超时时间,单位是毫秒 */
// datasource.setSocketTimeout(socketTimeout);
//
// /** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */
// datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//
// /** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */
// datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
// datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis);
//
// /**
// * 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。
// */
// datasource.setValidationQuery(validationQuery);
// /** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */
// datasource.setTestWhileIdle(testWhileIdle);
// /** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
// datasource.setTestOnBorrow(testOnBorrow);
// /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */
// datasource.setTestOnReturn(testOnReturn);
// return datasource;
// }
}

14
lzbi-module/pom.xml

@ -42,15 +42,11 @@
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.6.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- </dependency>-->
</dependencies>
</project>

70
lzbi-module/src/main/java/com/lzbi/asset/controller/DcBusiWorkReadConfigController.java

@ -1,14 +1,24 @@
package com.lzbi.asset.controller;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzbi.code.domain.DcBaseCoderuleDefineDao;
import com.lzbi.code.domain.DcBusiCoderuleConfigDao;
import com.lzbi.code.service.CodeNoGenerater;
import com.lzbi.code.service.DcBaseCoderuleDefineService;
import com.lzbi.common.annotation.Log;
import com.lzbi.common.core.controller.BaseController;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.core.page.TableDataInfo;
import com.lzbi.common.enums.BusinessType;
import com.lzbi.common.utils.DateUtils;
import com.lzbi.common.utils.StringUtils;
import com.lzbi.common.utils.poi.ExcelUtil;
import com.lzbi.draft.domain.DcBusiParamBillMasterDao;
import com.lzbi.draft.domain.DcBusiParamBillSubDao;
import com.lzbi.draft.service.DcBusiParamBillMasterService;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.WorkReadVo;
import com.lzbi.task.service.WorkParamReadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -16,9 +26,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.awt.geom.Arc2D;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.lzbi.asset.domain.DcBusiWorkReadConfig;
import com.lzbi.asset.service.DcBusiWorkReadConfigService;
@ -135,8 +148,59 @@ public class DcBusiWorkReadConfigController extends BaseController{
WorkParamReadService workParamReadService;
@Autowired
CodeNoGenerater codeNoGenerater;
@Autowired
DcBusiParamBillMasterService dcBusiParamBillMasterService;
@Autowired
DcBaseCoderuleDefineService dcBaseCoderuleDefineService;
@GetMapping("/getWork")
public AjaxResult getWorkParamValue(){
return success();
String inComeDate="2023-11-29";
DcBusiCoderuleConfigDao ruleIdByBusicode = dcBaseCoderuleDefineService.getRuleIdByBusicode("param_bill_adjust");
DcBaseCoderuleDefineDao ruleDao = dcBaseCoderuleDefineService.selectDcBaseCoderuleDefineDaoById(ruleIdByBusicode.getRuleId());
DcBusiParamBillMasterDao billm=new DcBusiParamBillMasterDao();
String billNo=codeNoGenerater.getCode(ruleDao);
if(StringUtils.isNull(billNo)){
billNo= "AD_"+String.valueOf(System.currentTimeMillis());
}
billm.setBillNo(billNo);
billm.setCreatedBy("robot");
billm.setCreatedTime(DateUtil.date());
billm.setBillIncomeDate(inComeDate);
billm.setBillType("auto");
billm.setCheckType("1");
billm.setCheckStatus("0");
List<DcBusiParamBillSubDao> billSub=new ArrayList<>();
ReadQueryParams readQueryParams=new ReadQueryParams();
readQueryParams.setBeginTime(inComeDate+" 00:00:00");
readQueryParams.setEndTime(inComeDate+" 23:59:59");
DcBusiWorkReadConfig dwrc=new DcBusiWorkReadConfig();
dwrc.setAssetCode("SP00001");
dwrc.setGoalSource("work");
List<DcBusiWorkReadConfig> dcBusiWorkReadConfigs = dcBusiWorkReadConfigService.selectByVo(dwrc);
List<String> pcl=dcBusiWorkReadConfigs.parallelStream().map(DcBusiWorkReadConfig::getGoalParamCode).collect(Collectors.toList());
List<String> dcl=dcBusiWorkReadConfigs.parallelStream().map(DcBusiWorkReadConfig::getGoalParamExt1).collect(Collectors.toList());
readQueryParams.setParamCodes(pcl);
readQueryParams.setDeviceCodes(dcl);
List<WorkReadVo> workReadVos = workParamReadService.readWorkValue(readQueryParams);
final String billNo_c=billNo;
workReadVos.parallelStream().forEach(item->{
Optional<DcBusiWorkReadConfig> find = dcBusiWorkReadConfigs.parallelStream().filter(info -> info.getGoalParamCode().equals(item.getParamCode()) && info.getGoalParamExt1().equals(item.getDeviceCode())).findFirst();
if(find.isPresent()){
DcBusiParamBillSubDao subDao=new DcBusiParamBillSubDao();
subDao.setCreatedBy("robot");
subDao.setAssetCode(find.get().getAssetCode());
subDao.setBillNo(billNo_c);
Double va=item.getValueByType(find.get().getGoalParamType());
subDao.setParamValue(va);
subDao.setParamCode(find.get().getAssetParamCode());
subDao.setFieldType(find.get().getAssetFieldCode());
subDao.setCounDate(item.getDateCount());
billSub.add(subDao);
}
});
billm.setDcBusiParamBillSubDaoList(billSub);
//dcBusiParamBillMasterService.insertDcBusiParamBillMasterDao(billm);
//dcBusiParamBillMasterService.saveBatch()
return success(dcBusiParamBillMasterService.insertDcBusiParamBillMasterDao(billm));
}
}

2
lzbi-module/src/main/java/com/lzbi/asset/domain/DcBusiWorkReadConfig.java

@ -48,5 +48,7 @@ public class DcBusiWorkReadConfig extends BaseModuleEntity{
/** 数据来源;生产IOT:work;计费:charge;Erp:erp */
@ApiModelProperty(name = "数据来源",notes = "生产IOT:work;计费:charge;Erp:erp")
private String goalSource ;
@ApiModelProperty(name = "所属专业")
private String assetFieldCode ;
}

54
lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillSubDao.java

@ -19,70 +19,20 @@ import com.lzbi.module.base.BaseModuleEntity;
public class DcBusiParamBillSubDao extends BaseModuleEntity
{
private static final long serialVersionUID = 1L;
/** 租户号 */
private String tenantId;
/** 乐观锁 */
private Long REVISION;
/** 创建人 */
private String createdBy;
/** 创建时间 */
private Date createdTime;
/** 更新人 */
private String updatedBy;
/** 更新时间 */
private Date updatedTime;
/** 删除人 */
private String deleteBy;
/** 删除时间 */
private Date deleteTime;
/** 主键 */
private Long id;
private String counDate;
/** 单据编码 */
@Excel(name = "单据编码")
private String billNo;
/** 公司名称 */
@Excel(name = "公司名称")
private String companyName;
/** 公司编码 */
@Excel(name = "公司编码")
private String companyCode;
/** 组织机构代码 */
@Excel(name = "组织机构代码")
private String orgCode;
/** 组织机构名称 */
@Excel(name = "组织机构名称")
private String orgName;
/** 统计单元编码 */
@Excel(name = "统计单元编码")
private String assetCode;
/** 统计单元名称 */
@Excel(name = "统计单元名称")
private String assetName;
/** 所属专业 */
@Excel(name = "所属专业")
private String fieldType;
/** 指标名称 */
@Excel(name = "指标名称")
private String paramName;
/** 指标编码 */
@Excel(name = "指标编码")
private String paramCode;
@ -93,6 +43,6 @@ public class DcBusiParamBillSubDao extends BaseModuleEntity
/** 参数值 */
@Excel(name = "参数值")
private BigDecimal paramValue;
private Double paramValue;
}

1
lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamBillMasterService.java

@ -56,6 +56,7 @@ public class DcBusiParamBillMasterService extends ServiceImpl<DcBusiParamBillMas
{
dcBusiParamBillMasterDao.setCreatedTime(DateUtils.getNowDate());
int rows = baseMapper.insertDcBusiParamBillMasterDao(dcBusiParamBillMasterDao);
insertDcBusiParamBillSubDao(dcBusiParamBillMasterDao);
return rows;
}

7
lzbi-module/src/main/java/com/lzbi/task/domain/EumValueReadType.java

@ -25,11 +25,14 @@ public enum EumValueReadType
/**
* 开始时间点值
*/
PVBEGIN("pvbegin"),
PVBEGIN("pvb"),
/**
* 结束时间点值
*/
PVEND("pvend"),
PVEND("pve"),
MAXV("max"),
MINV("min"),
;
private final String type;
EumValueReadType(String type){

27
lzbi-module/src/main/java/com/lzbi/task/domain/WorkReadVo.java

@ -15,7 +15,7 @@ import java.util.Optional;
* WorkReadVo
* 从生产数据库读取的参数统计值
*/
@Data
public class WorkReadVo {
/***/
@ApiModelProperty("参数编码")
@ -140,4 +140,29 @@ public class WorkReadVo {
public Integer getHourCount() {
return DateUtil.hour(this.thour, true);
}
public Double getValueByType(String type){
if(type.equals(EumValueReadType.AVG.toString())){
return getAvgAll();
}
if(type.equals(EumValueReadType.SUM.toString())){
return getTotal();
}
if(type.equals(EumValueReadType.AVGNOZERO.toString())){
return getAvgNoZero();
}
if(type.equals(EumValueReadType.PVBEGIN.toString())){
return getFirstVal();
}
if(type.equals(EumValueReadType.PVEND.toString())){
return getLastVal();
}
if(type.equals(EumValueReadType.MAXV.toString())){
return getMaxVal();
}
if(type.equals(EumValueReadType.MINV.toString())){
return getMinVal();
}
return 0.00;
}
}

16
lzbi-module/src/main/resources/mapper/asset/DcBusiParamBillMasterMapper.xml

@ -27,7 +27,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="DcBusiParamBillSubDao" id="DcBusiParamBillSubDaoResult">
<result property="tenantId" column="sub_TENANT_ID" />
<result property="REVISION" column="sub_REVISION" />
<result property="createdBy" column="sub_CREATED_BY" />
<result property="createdTime" column="sub_CREATED_TIME" />
<result property="updatedBy" column="sub_UPDATED_BY" />
@ -36,14 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deleteTime" column="sub_DELETE_TIME" />
<result property="id" column="sub_id" />
<result property="billNo" column="sub_bill_no" />
<result property="companyName" column="sub_company_name" />
<result property="companyCode" column="sub_company_code" />
<result property="orgCode" column="sub_org_code" />
<result property="orgName" column="sub_org_name" />
<result property="assetCode" column="sub_asset_code" />
<result property="assetName" column="sub_asset_name" />
<result property="fieldType" column="sub_field_type" />
<result property="paramName" column="sub_param_name" />
<result property="counDate" column="count_date" />
<result property="paramCode" column="sub_param_code" />
<result property="paramUint" column="sub_param_uint" />
<result property="paramValue" column="sub_param_value" />
@ -66,9 +60,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcBusiParamBillMasterDaoById" parameterType="Long" resultMap="DcBusiParamBillMasterDaoDcBusiParamBillSubDaoResult">
select a.TENANT_ID, a.REVISION, a.CREATED_BY, a.CREATED_TIME, a.UPDATED_BY, a.UPDATED_TIME, a.DELETE_BY, a.DELETE_TIME, a.id, a.bill_no, a.bill_income_date, a.bill_type, a.check_type, a.check_status,
b.TENANT_ID as sub_TENANT_ID, b.REVISION as sub_REVISION, b.CREATED_BY as sub_CREATED_BY, b.CREATED_TIME as sub_CREATED_TIME, b.UPDATED_BY as sub_UPDATED_BY, b.UPDATED_TIME as sub_UPDATED_TIME, b.DELETE_BY as sub_DELETE_BY, b.DELETE_TIME as sub_DELETE_TIME, b.id as sub_id, b.bill_no as sub_bill_no, b.company_name as sub_company_name, b.company_code as sub_company_code, b.org_code as sub_org_code, b.org_name as sub_org_name, b.asset_code as sub_asset_code, b.asset_name as sub_asset_name, b.field_type as sub_field_type, b.param_name as sub_param_name, b.param_code as sub_param_code, b.param_uint as sub_param_uint, b.param_value as sub_param_value
b.TENANT_ID as sub_TENANT_ID, b.CREATED_BY as sub_CREATED_BY, b.CREATED_TIME as sub_CREATED_TIME, b.UPDATED_BY as sub_UPDATED_BY, b.UPDATED_TIME as sub_UPDATED_TIME, b.DELETE_BY as sub_DELETE_BY, b.DELETE_TIME as sub_DELETE_TIME, b.id as sub_id, b.bill_no as sub_bill_no,b.asset_code as sub_asset_code, b.field_type as sub_field_type, b.param_code as sub_param_code, b.param_value as sub_param_value
from dc_busi_param_bill_master a
left join dc_busi_param_bill_sub b on b.bill_no = a.id
left join dc_busi_param_bill_sub b on b.bill_no = a.bill_no
where a.id = #{id}
</select>
@ -149,9 +143,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchDcBusiParamBillSubDao">
insert into dc_busi_param_bill_sub( TENANT_ID, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, DELETE_BY, DELETE_TIME, id, bill_no, company_name, company_code, org_code, org_name, asset_code, asset_name, field_type, param_name, param_code, param_uint, param_value) values
insert into dc_busi_param_bill_sub( TENANT_ID, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, DELETE_BY, DELETE_TIME, id, bill_no, asset_code, field_type, param_code, param_value) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.tenantId}, #{item.REVISION}, #{item.createdBy}, #{item.createdTime}, #{item.updatedBy}, #{item.updatedTime}, #{item.deleteBy}, #{item.deleteTime}, #{item.id}, #{item.billNo}, #{item.companyName}, #{item.companyCode}, #{item.orgCode}, #{item.orgName}, #{item.assetCode}, #{item.assetName}, #{item.fieldType}, #{item.paramName}, #{item.paramCode}, #{item.paramUint}, #{item.paramValue})
( #{item.tenantId}, #{item.createdBy}, #{item.createdTime}, #{item.updatedBy}, #{item.updatedTime}, #{item.deleteBy}, #{item.deleteTime}, #{item.id}, #{item.billNo}, #{item.assetCode}, #{item.fieldType}, #{item.paramCode}, #{item.paramValue})
</foreach>
</insert>
</mapper>

11
lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadConfigMapper.xml

@ -37,6 +37,9 @@
<result property="goalParamType" column="goal_param_type"/>
<!-- 数据来源 -->
<result property="goalSource" column="goal_source"/>
<!-- 数据来源 -->
<result property="assetFieldCode" column="asset_field_code"/>
</resultMap>
<sql id="baseQuerySql">
select
@ -56,6 +59,7 @@
goal_param_ext2,
goal_param_type,
goal_source,
asset_field_code
from dc_busi_work_read_config
</sql>
<select id="selectByVo" resultMap="rmDcBusiWorkReadConfig" parameterType="com.lzbi.asset.domain.DcBusiWorkReadConfig">
@ -66,7 +70,7 @@
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="updatedTime != null a"> and updated_time = #{updatedTime}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
<if test="deleteBy != null and deleteBy != ''"> and delete_by = #{deleteBy}</if>
<if test="deleteTime != null "> and delete_time = #{deleteTime}</if>
<if test="id != null "> and id = #{id}</if>
@ -77,7 +81,7 @@
<if test="goalParamExt2 != null and goalParamExt2 != ''"> and goal_param_ext2 = #{goalParamExt2}</if>
<if test="goalParamType != null and goalParamType != ''"> and goal_param_type = #{goalParamType}</if>
<if test="goalSource != null and goalSource != ''"> and goal_source = #{goalSource}</if>
<if test="assetFieldCode != null and assetFieldCode != ''"> and asset_field_code = #{assetFieldCode}</if>
</where>
</select>
<insert id="insertByVo" parameterType="com.lzbi.asset.domain.DcBusiWorkReadConfig">
@ -99,6 +103,7 @@
<if test="goalParamExt2 != null and goalParamExt2 != ''">goal_param_ext2,</if>
<if test="goalParamType != null and goalParamType != ''">goal_param_type,</if>
<if test="goalSource != null and goalSource != ''">goal_source,</if>
<if test="assetFieldCode != null and assetFieldCode != ''">asset_field_code</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
@ -117,7 +122,7 @@
<if test="goalParamExt2 != null and goalParamExt2 != ''">#{goalParamExt2},</if>
<if test="goalParamType != null and goalParamType != ''">#{goalParamType},</if>
<if test="goalSource != null and goalSource != ''">#{goalSource},</if>
<if test="assetFieldCode != null and assetFieldCode != ''">#{assetFieldCode},</if>
</trim>
</insert>
</mapper>

8
lzbi-module/src/main/resources/mapper/asset/WorkParamReadMapper.xml

@ -29,12 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM dc_base_log_history_level1 AS his
where timestamp_key BETWEEN to_timestamp(#{beginTime},'yyyy-MM-dd hh24:mi:ss') and to_timestamp(#{endTime},'yyyy-MM-dd hh24:mi:ss')
and device_uuid in
<foreach item="item" index="index" collection="deviceCodes" separator=",">
( #{item})
<foreach item="item" index="index" collection="deviceCodes" open="(" close=")" separator=",">
#{item}
</foreach>
and param_code in
<foreach item="item" index="index" collection="paramCodes" separator=",">
( #{item})
<foreach item="item" index="index" collection="paramCodes" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY thour, param_code,device_uuid
ORDER BY thour asc

Loading…
Cancel
Save