Browse Source

2023-12-1 参数采集任务方式,自动参数采集的计算到参数底稿表,修正部分表结构及字段

develop
zhousq 1 year ago
parent
commit
e41714e622
  1. 2
      lzbi-admin/src/main/resources/application-dev.yml
  2. 6
      lzbi-admin/src/main/resources/mybatis/mybatis-config.xml
  3. 77
      lzbi-module/src/main/java/com/lzbi/asset/controller/DcBusiWorkReadConfigController.java
  4. 2
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillMasterDao.java
  5. 75
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillSub.java
  6. 48
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillSubDao.java
  7. 157
      lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamDraftDay.java
  8. 23
      lzbi-module/src/main/java/com/lzbi/draft/domain/ParamDraftQueryVo.java
  9. 4
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamBillMasterMapper.java
  10. 17
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamBillSubMapper.java
  11. 21
      lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamDraftDayMapper.java
  12. 8
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamBillMasterService.java
  13. 25
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamBillSubService.java
  14. 29
      lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamDraftDayService.java
  15. 159
      lzbi-module/src/main/java/com/lzbi/task/TaskParamDfratProcess.java
  16. 130
      lzbi-module/src/main/java/com/lzbi/task/TaskWorkParamRead.java
  17. 136
      lzbi-module/src/main/java/com/lzbi/task/domain/DcBusiWorkReadLog.java
  18. 168
      lzbi-module/src/main/java/com/lzbi/task/domain/WorkReadVo.java
  19. 21
      lzbi-module/src/main/java/com/lzbi/task/mapper/DcBusiWorkReadLogMapper.java
  20. 7
      lzbi-module/src/main/java/com/lzbi/task/mapper/WorkParamReadMapper.java
  21. 29
      lzbi-module/src/main/java/com/lzbi/task/service/DcBusiWorkReadLogService.java
  22. 14
      lzbi-module/src/main/java/com/lzbi/task/service/WorkParamReadService.java
  23. 11
      lzbi-module/src/main/resources/mapper/asset/DcBusiParamBillMasterMapper.xml
  24. 141
      lzbi-module/src/main/resources/mapper/asset/DcBusiParamBillSubMapper.xml
  25. 340
      lzbi-module/src/main/resources/mapper/asset/DcBusiParamDraftDayMapper.xml
  26. 132
      lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadLogMapper.xml
  27. 6
      lzbi-module/src/main/resources/mapper/asset/WorkParamReadMapper.xml

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

@ -76,7 +76,7 @@ spring:
datasource:
# 主库数据源
master:
url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://10.10.10.56:13306/lzdc_bi_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: luenmei
password: 123456
# # 计费数据库

6
lzbi-admin/src/main/resources/mybatis/mybatis-config.xml

@ -3,18 +3,22 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties>
<property name="id-type" value="auto"/>
</properties>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<setting name="useGeneratedKeys" value="false" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>

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

@ -1,9 +1,6 @@
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;
@ -12,13 +9,10 @@ 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.TaskParamDfratProcess;
import com.lzbi.task.TaskWorkParamRead;
import com.lzbi.task.service.WorkParamReadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,10 +21,8 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.*;
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;
@ -144,63 +136,16 @@ public class DcBusiWorkReadConfigController extends BaseController{
ExcelUtil<DcBusiWorkReadConfig> util = new ExcelUtil<>(DcBusiWorkReadConfig.class);
util.exportExcel(response, list, "导出的互联参数读取数据对照表数据");
}
@Autowired
WorkParamReadService workParamReadService;
@Autowired
CodeNoGenerater codeNoGenerater;
@Autowired
DcBusiParamBillMasterService dcBusiParamBillMasterService;
@Autowired
DcBaseCoderuleDefineService dcBaseCoderuleDefineService;
@GetMapping("/getWork")
public AjaxResult getWorkParamValue(){
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));
TaskWorkParamRead taskWorkParamRead=new TaskWorkParamRead();
taskWorkParamRead.runTask(false);
return success();
}
@GetMapping("/getDraft")
public AjaxResult getDraftValue(){
TaskParamDfratProcess taskParamDfratProcess=new TaskParamDfratProcess();
taskParamDfratProcess.doBills(null);
return success();
}
}

2
lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillMasterDao.java

@ -67,7 +67,7 @@ public class DcBusiParamBillMasterDao extends BaseModuleEntity
private String checkStatus;
/** 参数数据采集(录入)明细信息 */
private List<DcBusiParamBillSubDao> dcBusiParamBillSubDaoList;
private List<DcBusiParamBillSub> dcBusiParamBillSubDaoList;

75
lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamBillSub.java

@ -0,0 +1,75 @@
package com.lzbi.draft.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Date;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.lzbi.module.base.BaseModuleEntity;
/**
* 参数数据采集录入明细表;
* @author : zhousq
* @date : 2023-12-1
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ApiModel(value = "参数数据采集(录入)明细表",description = "")
@TableName("dc_busi_param_bill_sub")
public class DcBusiParamBillSub extends BaseModuleEntity{
/** 主键 */
@ApiModelProperty(name = "主键",notes = "")
@TableId
private Integer id ;
/** 单据编码 */
@ApiModelProperty(name = "单据编码",notes = "")
private String billNo ;
/** 统计单元编码 */
@ApiModelProperty(name = "统计单元编码",notes = "")
private String assetCode ;
/** 统计单元名称 */
@ApiModelProperty(name = "统计单元名称",notes = "")
private String assetName ;
/** 所属专业 */
@ApiModelProperty(name = "所属专业",notes = "")
private String fieldType ;
/** 指标名称 */
@ApiModelProperty(name = "指标名称",notes = "")
private String paramName ;
/** 指标编码 */
@ApiModelProperty(name = "指标编码",notes = "")
private String paramCode ;
/** 指标单位 */
@ApiModelProperty(name = "指标单位",notes = "")
private String paramUint ;
/** 参数值 */
@ApiModelProperty(name = "参数值",notes = "")
private Double paramValue ;
/** 统计日期 */
@ApiModelProperty(name = "统计日期",notes = "yyyy-MM-dd")
private String countDate ;
@ApiModelProperty(name = "统计小时",notes = "24小时")
private Integer countHour ;
public String getAssetCode(){
return Optional.ofNullable(this.assetCode).orElse("");
}
public String getParamCode(){
return Optional.ofNullable(this.paramCode).orElse("");
}
public String getCountDate(){
return Optional.ofNullable(this.countDate).orElse("");
}
public String getFieldType(){
return Optional.ofNullable(this.fieldType).orElse("");
}
}

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

@ -1,48 +0,0 @@
package com.lzbi.draft.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.lzbi.common.annotation.Excel;
import com.lzbi.module.base.BaseModuleEntity;
/**
* 参数数据采集录入明细对象 dc_busi_param_bill_sub
*
* @author win
* @date 2023-11-28
*/
@Data
public class DcBusiParamBillSubDao extends BaseModuleEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
private String counDate;
/** 单据编码 */
@Excel(name = "单据编码")
private String billNo;
/** 统计单元编码 */
@Excel(name = "统计单元编码")
private String assetCode;
/** 所属专业 */
@Excel(name = "所属专业")
private String fieldType;
/** 指标编码 */
@Excel(name = "指标编码")
private String paramCode;
/** 指标单位 */
@Excel(name = "指标单位")
private String paramUint;
/** 参数值 */
@Excel(name = "参数值")
private Double paramValue;
}

157
lzbi-module/src/main/java/com/lzbi/draft/domain/DcBusiParamDraftDay.java

@ -0,0 +1,157 @@
package com.lzbi.draft.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.lzbi.module.base.BaseModuleEntity;
/**
* 参数数据底稿表;
* @author : zhousq
* @date : 2023-12-1
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ApiModel(value = "参数数据底稿表(日)",description = "")
@TableName("dc_busi_param_draft_day")
public class DcBusiParamDraftDay extends BaseModuleEntity{
/** 主键 */
@ApiModelProperty(name = "主键",notes = "")
@TableId(type = IdType.AUTO)
private Integer id ;
/** 公司编码 */
@ApiModelProperty(name = "公司编码",notes = "")
private String companyCode ;
/** 生产组织机构名称 */
@ApiModelProperty(name = "生产组织机构名称",notes = "")
private String organizeName ;
/** 生产组织机构编号 */
@ApiModelProperty(name = "生产组织机构编号",notes = "")
private String organizeCode ;
/** 公司名称 */
@ApiModelProperty(name = "公司名称",notes = "")
private String companyName ;
/** 统计单元 */
@ApiModelProperty(name = "统计单元",notes = "")
private String assetCode ;
@ApiModelProperty(name = "统计单元",notes = "")
private String assetName ;
/** 参数编码 */
@ApiModelProperty(name = "参数编码",notes = "")
private String paramCode ;
/** 参数名称 */
@ApiModelProperty(name = "参数名称",notes = "")
private String paramName ;
/** 生产专业 */
@ApiModelProperty(name = "生产专业",notes = "")
private String paramField ;
/** 指标单位 */
@ApiModelProperty(name = "指标单位",notes = "")
private String targetUint ;
/** 统计日期[yyyy-mm-dd] */
@ApiModelProperty(name = "统计日期[yyyy-mm-dd]",notes = "")
private String countDate ;
/** 均值 */
@ApiModelProperty(name = "均值",notes = "")
private Double valAvg ;
/** 当日最大值 */
@ApiModelProperty(name = "当日最大值",notes = "")
private Double valMax ;
/** 和值 */
@ApiModelProperty(name = "和值",notes = "")
private String valSum ;
/** 当日最小值 */
@ApiModelProperty(name = "当日最小值",notes = "")
private Double valMin ;
/** 积算值 */
@ApiModelProperty(name = "积算值",notes = "")
private Double valIntegrating ;
/** 上限 */
@ApiModelProperty(name = "上限",notes = "")
private Double valLimitUp ;
/** 下限 */
@ApiModelProperty(name = "下限",notes = "")
private Double valLimitDown ;
/** 1时;[00:00:00,00:59:59] */
@ApiModelProperty(name = "1时",notes = "[00:00:00,00:59:59]")
private Double val01 ;
/** 2时;[01:00:00,01:59:59] */
@ApiModelProperty(name = "2时",notes = "[01:00:00,01:59:59]")
private Double val02 ;
/** 3时;[02:00:00,02:59:59] */
@ApiModelProperty(name = "3时",notes = "[02:00:00,02:59:59]")
private Double val03 ;
/** 4时 */
@ApiModelProperty(name = "4时",notes = "")
private Double val04 ;
/** 5时 */
@ApiModelProperty(name = "5时",notes = "")
private Double val05 ;
/** 6时 */
@ApiModelProperty(name = "6时",notes = "")
private Double val06 ;
/** 7时 */
@ApiModelProperty(name = "7时",notes = "")
private Double val07 ;
/** 8时 */
@ApiModelProperty(name = "8时",notes = "")
private Double val08 ;
/** 9时 */
@ApiModelProperty(name = "9时",notes = "")
private Double val09 ;
/** 10时 */
@ApiModelProperty(name = "10时",notes = "")
private Double val10 ;
/** 11时 */
@ApiModelProperty(name = "11时",notes = "")
private Double val11 ;
/** 12时 */
@ApiModelProperty(name = "12时",notes = "")
private Double val12 ;
/** 13时 */
@ApiModelProperty(name = "13时",notes = "")
private Double val13 ;
/** 14时 */
@ApiModelProperty(name = "14时",notes = "")
private Double val14 ;
/** 15时 */
@ApiModelProperty(name = "15时",notes = "")
private Double val15 ;
/** 16时 */
@ApiModelProperty(name = "16时",notes = "")
private Double val16 ;
/** 17时 */
@ApiModelProperty(name = "17时",notes = "")
private Double val17 ;
/** 18时 */
@ApiModelProperty(name = "18时",notes = "")
private Double val18 ;
/** 18时 */
@ApiModelProperty(name = "18时",notes = "")
private Double val19 ;
/** 20时 */
@ApiModelProperty(name = "20时",notes = "")
private Double val20 ;
/** 21时 */
@ApiModelProperty(name = "21时",notes = "")
private Double val21 ;
/** 22时 */
@ApiModelProperty(name = "22时",notes = "")
private Double val22 ;
/** 23时 */
@ApiModelProperty(name = "23时",notes = "")
private Double val23 ;
/** 24时 */
@ApiModelProperty(name = "24时",notes = "")
private Double val24 ;
}

23
lzbi-module/src/main/java/com/lzbi/draft/domain/ParamDraftQueryVo.java

@ -0,0 +1,23 @@
package com.lzbi.draft.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @auth create by Administrator
* @date 2023/12/1
* ParamDraftQueryVo
* 参数底稿表基础查询参数
*
*/
@Data
public class ParamDraftQueryVo {
@ApiModelProperty("统计单元编码")
private String assetCode;
@ApiModelProperty("生产专业编码")
private String specialCode;
@ApiModelProperty("统计单元参数编码")
private String assetParamCode;
@ApiModelProperty("查询日期 yyyu-MM-dd")
private String countDate;
}

4
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamBillMasterMapper.java

@ -3,7 +3,7 @@ package com.lzbi.draft.mapper;
import java.util.List;
import com.lzbi.draft.domain.DcBusiParamBillMasterDao;
import com.lzbi.draft.domain.DcBusiParamBillSubDao;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
@ -77,7 +77,7 @@ public interface DcBusiParamBillMasterMapper extends BaseMapper<DcBusiParamBillM
* @param dcBusiParamBillSubDaoList 参数数据采集录入明细列表
* @return 结果
*/
public int batchDcBusiParamBillSubDao(List<DcBusiParamBillSubDao> dcBusiParamBillSubDaoList);
public int batchDcBusiParamBillSubDao(List<DcBusiParamBillSub> dcBusiParamBillSubDaoList);
/**

17
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamBillSubMapper.java

@ -0,0 +1,17 @@
package com.lzbi.draft.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import java.util.List;
/**
* 参数数据采集录入明细表;(dc_busi_param_bill_sub)表数据库访问层
* @author : zhousq
* @date : 2023-12-1
*/
@InterceptorIgnore(tenantLine = "true")
public interface DcBusiParamBillSubMapper extends BaseMapper<DcBusiParamBillSub>{
List<DcBusiParamBillSub> selectByVo( DcBusiParamBillSub beanVo);
int insertByVo( DcBusiParamBillSub beanVo);
}

21
lzbi-module/src/main/java/com/lzbi/draft/mapper/DcBusiParamDraftDayMapper.java

@ -0,0 +1,21 @@
package com.lzbi.draft.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.draft.domain.DcBusiParamDraftDay;
import com.lzbi.draft.domain.ParamDraftQueryVo;
import java.util.List;
/**
* 参数数据底稿表;(dc_busi_param_draft_day)表数据库访问层
* @author : zhousq
* @date : 2023-12-1
*/
@InterceptorIgnore(tenantLine = "true")
public interface DcBusiParamDraftDayMapper extends BaseMapper<DcBusiParamDraftDay>{
List<DcBusiParamDraftDay> selectByVo( DcBusiParamDraftDay beanVo);
int insertByVo( DcBusiParamDraftDay beanVo);
DcBusiParamDraftDay selectOneByParam( ParamDraftQueryVo beanVo);
}

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

@ -3,7 +3,7 @@ package com.lzbi.draft.service;
import java.util.List;
import com.lzbi.draft.domain.DcBusiParamBillMasterDao;
import com.lzbi.draft.domain.DcBusiParamBillSubDao;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import com.lzbi.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -112,12 +112,12 @@ public class DcBusiParamBillMasterService extends ServiceImpl<DcBusiParamBillMas
*/
public void insertDcBusiParamBillSubDao(DcBusiParamBillMasterDao dcBusiParamBillMasterDao)
{
List<DcBusiParamBillSubDao> dcBusiParamBillSubDaoList = dcBusiParamBillMasterDao.getDcBusiParamBillSubDaoList();
List<DcBusiParamBillSub> dcBusiParamBillSubDaoList = dcBusiParamBillMasterDao.getDcBusiParamBillSubDaoList();
String billNo = dcBusiParamBillMasterDao.getBillNo();
if (StringUtils.isNotNull(dcBusiParamBillSubDaoList))
{
List<DcBusiParamBillSubDao> list = new ArrayList<DcBusiParamBillSubDao>();
for (DcBusiParamBillSubDao dcBusiParamBillSubDao : dcBusiParamBillSubDaoList)
List<DcBusiParamBillSub> list = new ArrayList<DcBusiParamBillSub>();
for (DcBusiParamBillSub dcBusiParamBillSubDao : dcBusiParamBillSubDaoList)
{
dcBusiParamBillSubDao.setBillNo(billNo);
list.add(dcBusiParamBillSubDao);

25
lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamBillSubService.java

@ -0,0 +1,25 @@
package com.lzbi.draft.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.draft.mapper.DcBusiParamBillSubMapper;
import org.springframework.stereotype.Service;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import java.util.List;
/**
* 参数数据采集录入明细表;(dc_busi_param_bill_sub)表服务接口
* @author : zhousq
* @date : 2023-12-1
*/
@Service
public class DcBusiParamBillSubService extends ServiceImpl<DcBusiParamBillSubMapper, DcBusiParamBillSub> implements IService<DcBusiParamBillSub> {
public List<DcBusiParamBillSub> selectByVo( DcBusiParamBillSub dcBusiParamBillSub){
return baseMapper.selectByVo(dcBusiParamBillSub);
}
public int insertByVo( DcBusiParamBillSub dcBusiParamBillSub){
return baseMapper.insertByVo(dcBusiParamBillSub);
}
}

29
lzbi-module/src/main/java/com/lzbi/draft/service/DcBusiParamDraftDayService.java

@ -0,0 +1,29 @@
package com.lzbi.draft.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.draft.domain.ParamDraftQueryVo;
import com.lzbi.draft.mapper.DcBusiParamDraftDayMapper;
import org.springframework.stereotype.Service;
import com.lzbi.draft.domain.DcBusiParamDraftDay;
import java.util.List;
/**
* 参数数据底稿表;(dc_busi_param_draft_day)表服务接口
* @author : zhousq
* @date : 2023-12-1
*/
@Service
public class DcBusiParamDraftDayService extends ServiceImpl<DcBusiParamDraftDayMapper, DcBusiParamDraftDay> implements IService<DcBusiParamDraftDay> {
public List<DcBusiParamDraftDay> selectByVo( DcBusiParamDraftDay dcBusiParamDraftDay){
return baseMapper.selectByVo(dcBusiParamDraftDay);
}
public int insertByVo( DcBusiParamDraftDay dcBusiParamDraftDay){
return baseMapper.insertByVo(dcBusiParamDraftDay);
}
public DcBusiParamDraftDay selectOneByParam(ParamDraftQueryVo queryVo){
return baseMapper.selectOneByParam(queryVo);
}
}

159
lzbi-module/src/main/java/com/lzbi/task/TaskParamDfratProcess.java

@ -0,0 +1,159 @@
package com.lzbi.task;
import cn.hutool.core.date.DateUtil;
import com.lzbi.common.utils.StringUtils;
import com.lzbi.common.utils.spring.SpringUtils;
import com.lzbi.draft.domain.DcBusiParamBillMasterDao;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import com.lzbi.draft.domain.DcBusiParamDraftDay;
import com.lzbi.draft.domain.ParamDraftQueryVo;
import com.lzbi.draft.service.DcBusiParamBillMasterService;
import com.lzbi.draft.service.DcBusiParamBillSubService;
import com.lzbi.draft.service.DcBusiParamDraftDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @auth create by Administrator
* @date 2023/12/1
* TaskParamDfratProcess
* 处理参数底稿表数据
*/
@Component
public class TaskParamDfratProcess {
DcBusiParamBillMasterService dcBusiParamBillMasterService=SpringUtils.getBean(DcBusiParamBillMasterService.class);
DcBusiParamBillSubService dcBusiParamBillSubService= SpringUtils.getBean(DcBusiParamBillSubService.class);
DcBusiParamDraftDayService dBusiParamDraftDayService=SpringUtils.getBean(DcBusiParamDraftDayService.class);
public void doBill(DcBusiParamBillMasterDao billMasterDao){
DcBusiParamBillSub billSub=new DcBusiParamBillSub();
billSub.setBillNo(billMasterDao.getBillNo());
List<DcBusiParamBillSub> dcBusiParamBillSubs = dcBusiParamBillSubService.selectByVo(billSub);
Map<String, List<DcBusiParamBillSub>> collect = dcBusiParamBillSubs.stream().collect(Collectors.groupingBy(gp -> gp.getAssetCode() + ":" + gp.getParamCode() + ":" + gp.getFieldType() + ":" + gp.getCountDate()));
collect.forEach((key,value)->{
String[] s=key.split(":");
ParamDraftQueryVo queryVo=new ParamDraftQueryVo();
queryVo.setAssetCode(s[0]);
queryVo.setAssetParamCode(s[1]);
queryVo.setSpecialCode(s[2]);
queryVo.setCountDate(s[3]);
DcBusiParamDraftDay dcBusiParamDraftDay = Optional.ofNullable(dBusiParamDraftDayService.selectOneByParam(queryVo)).orElse(new DcBusiParamDraftDay());
List<DcBusiParamBillSub> subs = value.stream().sorted(Comparator.comparing(DcBusiParamBillSub::getCountHour)).collect(Collectors.toList());
subs.forEach(val->{
if(StringUtils.isNull(dcBusiParamDraftDay.getId())){
dcBusiParamDraftDay.setCreatedTime(DateUtil.date());
dcBusiParamDraftDay.setCreatedBy("task");
dcBusiParamDraftDay.setParamField(val.getFieldType());
dcBusiParamDraftDay.setParamCode(val.getParamCode());
dcBusiParamDraftDay.setCountDate(val.getCountDate());
dcBusiParamDraftDay.setAssetCode(val.getAssetCode());
//------------设置 统计单元的其他信息
// dcBusiParamDraftDay.setOrganizeCode();
// dcBusiParamDraftDay.setOrganizeName();
// dcBusiParamDraftDay.setParamName();
// dcBusiParamDraftDay.setTargetUint();
// dcBusiParamDraftDay.setAssetName();
// dcBusiParamDraftDay.setCompanyCode();
// dcBusiParamDraftDay.setCompanyName();
}
dcBusiParamDraftDay.setUpdatedBy("task");
dcBusiParamDraftDay.setUpdatedTime(DateUtil.date());
switch (val.getCountHour()){
case 0:
dcBusiParamDraftDay.setVal01(val.getParamValue());
break;
case 1:
dcBusiParamDraftDay.setVal02(val.getParamValue());
break;
case 2:
dcBusiParamDraftDay.setVal03(val.getParamValue());
break;
case 3:
dcBusiParamDraftDay.setVal04(val.getParamValue());
break;
case 4:
dcBusiParamDraftDay.setVal05(val.getParamValue());
break;
case 5:
dcBusiParamDraftDay.setVal06(val.getParamValue());
break;
case 6:
dcBusiParamDraftDay.setVal07(val.getParamValue());
break;
case 7:
dcBusiParamDraftDay.setVal08(val.getParamValue());
break;
case 8:
dcBusiParamDraftDay.setVal09(val.getParamValue());
break;
case 9:
dcBusiParamDraftDay.setVal10(val.getParamValue());
break;
case 10:
dcBusiParamDraftDay.setVal11(val.getParamValue());
break;
case 11:
dcBusiParamDraftDay.setVal12(val.getParamValue());
break;
case 12:
dcBusiParamDraftDay.setVal13(val.getParamValue());
break;
case 13:
dcBusiParamDraftDay.setVal14(val.getParamValue());
break;
case 14:
dcBusiParamDraftDay.setVal15(val.getParamValue());
break;
case 15:
dcBusiParamDraftDay.setVal16(val.getParamValue());
break;
case 16:
dcBusiParamDraftDay.setVal17(val.getParamValue());
break;
case 17:
dcBusiParamDraftDay.setVal18(val.getParamValue());
break;
case 18:
dcBusiParamDraftDay.setVal19(val.getParamValue());
break;
case 19:
dcBusiParamDraftDay.setVal20(val.getParamValue());
break;
case 20:
dcBusiParamDraftDay.setVal21(val.getParamValue());
break;
case 21:
dcBusiParamDraftDay.setVal22(val.getParamValue());
break;
case 22:
dcBusiParamDraftDay.setVal23(val.getParamValue());
break;
case 23:
dcBusiParamDraftDay.setVal24(val.getParamValue());
break;
}
});
dBusiParamDraftDayService.saveOrUpdate(dcBusiParamDraftDay);
});
}
public void doBills(String billNo){
DcBusiParamBillMasterDao dcBusiParamBillMasterDao=new DcBusiParamBillMasterDao();
dcBusiParamBillMasterDao.setCheckStatus("1");
dcBusiParamBillMasterDao.setBillNo(billNo);
List<DcBusiParamBillMasterDao> dcBusiParamBillMasterDaos = dcBusiParamBillMasterService.selectDcBusiParamBillMasterDaoList(dcBusiParamBillMasterDao);
dcBusiParamBillMasterDaos.forEach(item->{
doBill(item);
});
}
}

130
lzbi-module/src/main/java/com/lzbi/task/TaskWorkParamRead.java

@ -0,0 +1,130 @@
package com.lzbi.task;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.lzbi.asset.domain.DcBusiWorkReadConfig;
import com.lzbi.asset.service.DcBusiWorkReadConfigService;
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.utils.StringUtils;
import com.lzbi.common.utils.spring.SpringUtils;
import com.lzbi.draft.domain.DcBusiParamBillMasterDao;
import com.lzbi.draft.domain.DcBusiParamBillSub;
import com.lzbi.draft.service.DcBusiParamBillMasterService;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.service.DcBusiWorkReadLogService;
import com.lzbi.task.service.WorkParamReadService;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @auth create by Administrator
* @date 2023/12/1
* TaskWorkParamRead
* quartz的定时任务 每天0点读取前一天的数据
* 处理过程
* 1从dc_busi_work_read_config 中读取 统计单元参数配置与生产参数的对照配置
* 2根据时间和找到的IOT参数设备编码进行 分区查询 从生产IOT数据库中查询
* 3把查询的结果存入dc_busi_work_read_log 日志存入前如果存在则删除日志
* 4生成任务参数任务单据
*/
@Component
public class TaskWorkParamRead {
DcBaseCoderuleDefineService dcBaseCoderuleDefineService = SpringUtils.getBean(DcBaseCoderuleDefineService.class);
CodeNoGenerater codeNoGenerater = SpringUtils.getBean(CodeNoGenerater.class);
DcBusiWorkReadConfigService dcBusiWorkReadConfigService= SpringUtils.getBean(DcBusiWorkReadConfigService.class);
WorkParamReadService workParamReadService=SpringUtils.getBean(WorkParamReadService.class);
DcBusiWorkReadLogService dcBusiWorkReadLogService=SpringUtils.getBean(DcBusiWorkReadLogService.class);
DcBusiParamBillMasterService dcBusiParamBillMasterService=SpringUtils.getBean(DcBusiParamBillMasterService.class);
boolean ifLog=false;
public void runTask(Boolean ifLog){
this.ifLog=ifLog;
String inDate=DateUtil.format(DateUtil.offsetDay(DateUtil.date(),-1), DatePattern.NORM_DATE_PATTERN);
createParamBill(inDate);
}
public void runTask(){
String inDate=DateUtil.format(DateUtil.offsetDay(DateUtil.date(),-1), DatePattern.NORM_DATE_PATTERN);
createParamBill(inDate);
}
/**从生产数据库获取配置的参数的值
* 按小时及性能分区统计"work"
* */
public List<DcBusiWorkReadLog> getWorkReadVo(String inComeDate,List<String> pcl,List<String> dcl){
ReadQueryParams readQueryParams=new ReadQueryParams();
readQueryParams.setBeginTime(inComeDate+" 00:00:00");
readQueryParams.setEndTime(inComeDate+" 23:59:59");
readQueryParams.setParamCodes(pcl);
readQueryParams.setDeviceCodes(dcl);
List<DcBusiWorkReadLog> dcBusiWorkReadLogs = workParamReadService.readWorkValue(readQueryParams);
if(ifLog){
readQueryParams.setBeginTime(inComeDate);
saveRealLog(dcBusiWorkReadLogs,readQueryParams);
}
return dcBusiWorkReadLogs;
}
/*存入日志*/
public boolean saveRealLog(List<DcBusiWorkReadLog> listlog,ReadQueryParams readQueryParams){
dcBusiWorkReadLogService.deleteByParams(readQueryParams);
return dcBusiWorkReadLogService.saveBatch(listlog);
//return true;
}
/**
* 创建参数采集但
* inComeDate 采集的目标时间 格式为yyyy-MM-dd
* */
private final String BUSICODE="param_bill_adjust";
private final String SOURCE="work";
public int createParamBill(String inComeDate){
//String inComeDate="2023-11-29";
DcBusiCoderuleConfigDao ruleIdByBusicode = dcBaseCoderuleDefineService.getRuleIdByBusicode(BUSICODE);
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("1");
List<DcBusiParamBillSub> billSub=new ArrayList<>();
DcBusiWorkReadConfig dwrc=new DcBusiWorkReadConfig();
//dwrc.setAssetCode(assetCode);
dwrc.setGoalSource(SOURCE);
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());
List<DcBusiWorkReadLog> listRow=getWorkReadVo(inComeDate,pcl,dcl);
final String billNo_c=billNo;
listRow.parallelStream().forEach(item->{
Optional<DcBusiWorkReadConfig> find = dcBusiWorkReadConfigs.parallelStream().filter(info -> info.getGoalParamCode().equals(item.getParamCode()) && info.getGoalParamExt1().equals(item.getDeviceCode())).findFirst();
if(find.isPresent()){
DcBusiParamBillSub subDao=new DcBusiParamBillSub();
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.setCountDate(item.getDateCount());
subDao.setCountHour(item.getHourCount());
billSub.add(subDao);
}
});
billm.setDcBusiParamBillSubDaoList(billSub);
return dcBusiParamBillMasterService.insertDcBusiParamBillMasterDao(billm);
}
}

136
lzbi-module/src/main/java/com/lzbi/task/domain/DcBusiWorkReadLog.java

@ -0,0 +1,136 @@
package com.lzbi.task.domain;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Date;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* 生产IOT系统读取的日志表;
* @author : zhousq
* @date : 2023-12-1
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ApiModel(value = "生产IOT系统读取的日志表",description = "")
@TableName("dc_busi_work_read_log")
public class DcBusiWorkReadLog {
/** 参数编码 */
@ApiModelProperty(name = "参数编码",notes = "")
private String paramCode ;
/** 设备编码 */
@ApiModelProperty(name = "设备编码",notes = "")
private String deviceCode ;
/** 统计时间 */
@ApiModelProperty(name = "统计时间",notes = "")
private Date thour ;
/** 生成时间 */
@ApiModelProperty(name = "生成时间",notes = "")
private Date createTime ;
/** 和值 */
@ApiModelProperty(name = "和值",notes = "")
private Double total ;
/** 总条数 */
@ApiModelProperty(name = "总条数",notes = "")
private Double countsAll ;
/** 除零总数 */
@ApiModelProperty(name = "除零总数",notes = "")
private Double countsZero ;
/** 最大值 */
@ApiModelProperty(name = "最大值",notes = "")
private Double maxVal ;
/** 最小值 */
@ApiModelProperty(name = "最小值",notes = "")
private Double minVal ;
/** 开始值 */
@ApiModelProperty(name = "开始值",notes = "")
private Double firstVal ;
/** 结束值 */
@ApiModelProperty(name = "结束值",notes = "")
private Double lastVal ;
/** 均值 */
@ApiModelProperty(name = "均值",notes = "")
private Double avgAll ;
/** 除零均值 */
@ApiModelProperty(name = "除零均值",notes = "")
private Double avgNoZero ;
/** 统计日 */
@ApiModelProperty(name = "统计日",notes = "")
private String dateCount ;
/** 小时 */
@ApiModelProperty(name = "小时",notes = "")
private Integer hourCount ;
public void setTotal(Double total) {
this.total = Optional.ofNullable(total).orElse(0.00);
}
public void setCountsAll(Double countsall) {
this.countsAll = Optional.ofNullable(countsall).orElse(1.00);
}
public void setCountsZero(Double countsz) {
this.countsZero = Optional.ofNullable(countsz).orElse(1.00);
}
public void setMaxVal(Double maxVal) {
this.maxVal =Optional.ofNullable(maxVal).orElse(0.00);
}
public void setMinVal(Double minVal) {
this.minVal =Optional.ofNullable(minVal).orElse(0.00);
}
public void setFirstVal(Double firstVal) {
this.firstVal = Optional.ofNullable(firstVal).orElse(0.00);
}
public void setLastVal(Double lastVal) {
this.lastVal = Optional.ofNullable(lastVal).orElse(0.00);
}
public Double getAvgAll(){
return this.total/(this.countsAll>0.0?this.countsAll:1);
}
public Double getAvgNoZero(){
return this.total/(this.countsZero>0.0?this.countsZero:1);
}
public String getDateCount() {
return DateUtil.format(this.thour, DatePattern.NORM_DATE_PATTERN);
}
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;
}
}

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

@ -1,168 +0,0 @@
package com.lzbi.task.domain;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NonNull;
import java.util.Date;
import java.util.Optional;
/**
* @auth create by Administrator
* @date 2023/11/30
* WorkReadVo
* 从生产数据库读取的参数统计值
*/
@Data
public class WorkReadVo {
/***/
@ApiModelProperty("参数编码")
private String paramCode;
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("统计时间")
private Date thour;
@ApiModelProperty("和值")
private Double total;
@ApiModelProperty("总数")
private Double countsall;
@ApiModelProperty("除零总数")
private Double countsz;
@ApiModelProperty("最大值")
private Double maxVal;
@ApiModelProperty("最小值")
private Double minVal;
@ApiModelProperty("首值")
private Double firstVal;
@ApiModelProperty("末值")
private Double lastVal;
@ApiModelProperty("均值")
private Double avgAll;
@ApiModelProperty("不计算0值的均值")
private Double avgNoZero;
@ApiModelProperty("日期-天")
private String dateCount;
@ApiModelProperty("时间-小时")
private Integer hourCount;
public String getParamCode() {
return paramCode;
}
public void setParamCode(String paramCode) {
this.paramCode = paramCode;
}
public String getDeviceCode() {
return deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public Date getThour() {
return thour;
}
public void setThour(Date thour) {
this.thour = thour;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = Optional.ofNullable(total).orElse(0.00);
}
public Double getCountsall() {
return countsall;
}
public void setCountsall(Double countsall) {
this.countsall = Optional.ofNullable(countsall).orElse(1.00);
}
public Double getCountsz() {
return countsz;
}
public void setCountsz(Double countsz) {
this.countsz = Optional.ofNullable(countsz).orElse(1.00);
}
public Double getMaxVal() {
return maxVal;
}
public void setMaxVal(Double maxVal) {
this.maxVal =Optional.ofNullable(maxVal).orElse(0.00);
}
public Double getMinVal() {
return minVal;
}
public void setMinVal(Double minVal) {
this.minVal =Optional.ofNullable(minVal).orElse(0.00);
}
public Double getFirstVal() {
return firstVal;
}
public void setFirstVal(Double firstVal) {
this.firstVal = Optional.ofNullable(firstVal).orElse(0.00);
}
public Double getLastVal() {
return lastVal;
}
public void setLastVal(Double lastVal) {
this.lastVal = Optional.ofNullable(lastVal).orElse(0.00);
}
public Double getAvgAll(){
return this.total/(this.countsall>0.0?this.countsall:1);
}
public Double getAvgNoZero(){
return this.total/(this.countsz>0.0?this.countsz:1);
}
public String getDateCount() {
return DateUtil.format(this.thour, DatePattern.NORM_DATE_PATTERN);
}
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;
}
}

21
lzbi-module/src/main/java/com/lzbi/task/mapper/DcBusiWorkReadLogMapper.java

@ -0,0 +1,21 @@
package com.lzbi.task.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import java.util.List;
/**
* 生产IOT系统读取的日志表;(dc_busi_work_read_log)表数据库访问层
* @author : zhousq
* @date : 2023-12-1
*/
@InterceptorIgnore(tenantLine = "true")
public interface DcBusiWorkReadLogMapper extends BaseMapper<DcBusiWorkReadLog>{
List<DcBusiWorkReadLog> selectByVo( DcBusiWorkReadLog beanVo);
int insertByVo( DcBusiWorkReadLog beanVo);
int deleteByParams(ReadQueryParams queryParams );
}

7
lzbi-module/src/main/java/com/lzbi/task/mapper/WorkParamReadMapper.java

@ -1,12 +1,9 @@
package com.lzbi.task.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.code.domain.DcBaseCoderuleDefineDao;
import com.lzbi.code.domain.DcBaseCoderuleSerialDao;
import com.lzbi.code.domain.DcBusiCoderuleConfigDao;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.WorkParamInfo;
import com.lzbi.task.domain.WorkReadVo;
import java.util.List;
@ -19,5 +16,5 @@ import java.util.List;
public interface WorkParamReadMapper extends BaseMapper<WorkParamInfo>
{
public List<WorkReadVo> readWorkValue(ReadQueryParams readQueryParams);
public List<DcBusiWorkReadLog> readWorkValue(ReadQueryParams readQueryParams);
}

29
lzbi-module/src/main/java/com/lzbi/task/service/DcBusiWorkReadLogService.java

@ -0,0 +1,29 @@
package com.lzbi.task.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.mapper.DcBusiWorkReadLogMapper;
import org.springframework.stereotype.Service;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import java.util.List;
/**
* 生产IOT系统读取的日志表;(dc_busi_work_read_log)表服务接口
* @author : zhousq
* @date : 2023-12-1
*/
@Service
public class DcBusiWorkReadLogService extends ServiceImpl<DcBusiWorkReadLogMapper, DcBusiWorkReadLog> implements IService<DcBusiWorkReadLog> {
public List<DcBusiWorkReadLog> selectByVo( DcBusiWorkReadLog dcBusiWorkReadLog){
return baseMapper.selectByVo(dcBusiWorkReadLog);
}
public int insertByVo( DcBusiWorkReadLog dcBusiWorkReadLog){
return baseMapper.insertByVo(dcBusiWorkReadLog);
}
public int deleteByParams(ReadQueryParams queryParams){
return baseMapper.deleteByParams(queryParams);
}
}

14
lzbi-module/src/main/java/com/lzbi/task/service/WorkParamReadService.java

@ -1,25 +1,15 @@
package com.lzbi.task.service;
import cn.hutool.core.date.DateUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzbi.asset.service.DcBusiWorkReadConfigService;
import com.lzbi.code.domain.DcBaseCoderuleDefineDao;
import com.lzbi.code.domain.DcBaseCoderuleSerialDao;
import com.lzbi.code.domain.DcBusiCoderuleConfigDao;
import com.lzbi.code.domain.codeBodyType;
import com.lzbi.common.utils.DateUtils;
import com.lzbi.common.utils.StringUtils;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.WorkParamInfo;
import com.lzbi.task.domain.WorkReadVo;
import com.lzbi.task.mapper.WorkParamReadMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
* 编码规则定义Service业务层处理
@ -34,7 +24,7 @@ public class WorkParamReadService extends ServiceImpl<WorkParamReadMapper, WorkP
{
/*获取生产单元的参数读取配置
* */
public List<WorkReadVo> readWorkValue(ReadQueryParams readQueryParams){
public List<DcBusiWorkReadLog> readWorkValue(ReadQueryParams readQueryParams){
return baseMapper.readWorkValue(readQueryParams);
}
}

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

@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<collection property="dcBusiParamBillSubDaoList" notNullColumn="sub_id" javaType="java.util.List" resultMap="DcBusiParamBillSubDaoResult" />
</resultMap>
<resultMap type="DcBusiParamBillSubDao" id="DcBusiParamBillSubDaoResult">
<resultMap type="DcBusiParamBillSub" id="DcBusiParamBillSubDaoResult">
<result property="tenantId" column="sub_TENANT_ID" />
<result property="createdBy" column="sub_CREATED_BY" />
<result property="createdTime" column="sub_CREATED_TIME" />
@ -37,7 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="billNo" column="sub_bill_no" />
<result property="assetCode" column="sub_asset_code" />
<result property="fieldType" column="sub_field_type" />
<result property="counDate" column="count_date" />
<result property="countDate" column="sub_count_date" />
<result property="countHour" column="sub_count_hour" />
<result property="paramCode" column="sub_param_code" />
<result property="paramUint" column="sub_param_uint" />
<result property="paramValue" column="sub_param_value" />
@ -60,7 +61,7 @@ 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.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
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, b.count_date as sub_count_date, b.count_hour as sub_count_hour
from dc_busi_param_bill_master a
left join dc_busi_param_bill_sub b on b.bill_no = a.bill_no
where a.id = #{id}
@ -143,9 +144,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchDcBusiParamBillSubDao">
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
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,count_date,count_hour) values
<foreach item="item" index="index" collection="list" separator=",">
( #{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})
( #{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}, #{item.countDate}, #{item.countHour})
</foreach>
</insert>
</mapper>

141
lzbi-module/src/main/resources/mapper/asset/DcBusiParamBillSubMapper.xml

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lzbi.draft.mapper.DcBusiParamBillSubMapper">
<resultMap type="com.lzbi.draft.domain.DcBusiParamBillSub" id="rmDcBusiParamBillSub">
<!-- 主键 -->
<result property="id" column="id"/>
<!-- 单据编码 -->
<result property="billNo" column="bill_no"/>
<!-- 统计单元编码 -->
<result property="assetCode" column="asset_code"/>
<!-- 统计单元名称 -->
<result property="assetName" column="asset_name"/>
<!-- 所属专业 -->
<result property="fieldType" column="field_type"/>
<!-- 指标名称 -->
<result property="paramName" column="param_name"/>
<!-- 指标编码 -->
<result property="paramCode" column="param_code"/>
<!-- 指标单位 -->
<result property="paramUint" column="param_uint"/>
<!-- 参数值 -->
<result property="paramValue" column="param_value"/>
<!-- 统计日期 -->
<result property="countDate" column="count_date"/>
<!-- 小时 -->
<result property="countHour" column="count_hour"/>
<!-- 租户号 -->
<result property="tenantId" column="tenant_id"/>
<!-- 乐观锁 -->
<result property="revision" column="revision"/>
<!-- 创建人 -->
<result property="createdBy" column="created_by"/>
<!-- 创建时间 -->
<result property="createdTime" column="created_time"/>
<!-- 更新人 -->
<result property="updatedBy" column="updated_by"/>
<!-- 更新时间 -->
<result property="updatedTime" column="updated_time"/>
<!-- 删除人 -->
<result property="deleteBy" column="delete_by"/>
<!-- 删除时间 -->
<result property="deleteTime" column="delete_time"/>
</resultMap>
<sql id="baseQuerySql">
select
id,
bill_no,
asset_code,
asset_name,
field_type,
param_name,
param_code,
param_uint,
param_value,
count_date,
count_hour,
tenant_id,
revision,
created_by,
created_time,
updated_by,
updated_time,
delete_by,
delete_time
from dc_busi_param_bill_sub
</sql>
<select id="selectByVo" resultMap="rmDcBusiParamBillSub" parameterType="com.lzbi.draft.domain.DcBusiParamBillSub">
<include refid="baseQuerySql"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="billNo != null and billNo != ''"> and bill_no = #{billNo}</if>
<if test="assetCode != null and assetCode != ''"> and asset_code = #{assetCode}</if>
<if test="assetName != null and assetName != ''"> and asset_name = #{assetName}</if>
<if test="fieldType != null and fieldType != ''"> and field_type = #{fieldType}</if>
<if test="paramName != null and paramName != ''"> and param_name = #{paramName}</if>
<if test="paramCode != null and paramCode != ''"> and param_code = #{paramCode}</if>
<if test="paramUint != null and paramUint != ''"> and param_uint = #{paramUint}</if>
<if test="paramValue != null and paramValue != ''"> and param_value = #{paramValue}</if>
<if test="countDate != null and countDate != ''"> and count_date = #{countDate}</if>
<if test="countHour != null "> and count_hour = #{countHour}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="revision != null "> and revision = #{revision}</if>
<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 "> 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>
</where>
</select>
<insert id="insertByVo" parameterType="com.lzbi.draft.domain.DcBusiParamBillSub">
insert into dc_busi_param_bill_sub
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="billNo != null and billNo != ''">bill_no,</if>
<if test="assetCode != null and assetCode != ''">asset_code,</if>
<if test="assetName != null and assetName != ''">asset_name,</if>
<if test="fieldType != null and fieldType != ''">field_type,</if>
<if test="paramName != null and paramName != ''">param_name,</if>
<if test="paramCode != null and paramCode != ''">param_code,</if>
<if test="paramUint != null and paramUint != ''">param_uint,</if>
<if test="paramValue != null and paramValue != ''">param_value,</if>
<if test="countDate != null and countDate != ''">count_date,</if>
<if test="countHour != null ">count_hour,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="revision != null ">revision,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="createdTime != null ">created_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="deleteBy != null and deleteBy != ''">delete_by,</if>
<if test="deleteTime != null">delete_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="billNo != null and billNo != ''">#{billNo},</if>
<if test="assetCode != null and assetCode != ''">#{assetCode},</if>
<if test="assetName != null and assetName != ''">#{assetName},</if>
<if test="fieldType != null and fieldType != ''">#{fieldType},</if>
<if test="paramName != null and paramName != ''">#{paramName},</if>
<if test="paramCode != null and paramCode != ''">#{paramCode},</if>
<if test="paramUint != null and paramUint != ''">#{paramUint},</if>
<if test="paramValue != null and paramValue != ''">#{paramValue},</if>
<if test="countDate != null and countDate != ''">#{countDate},</if>
<if test="countHour != null ">#{countHour},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="revision != null ">#{revision},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="deleteBy != null and deleteBy != ''">#{deleteBy},</if>
<if test="deleteTime != null">#{deleteTime},</if>
</trim>
</insert>
</mapper>

340
lzbi-module/src/main/resources/mapper/asset/DcBusiParamDraftDayMapper.xml

@ -0,0 +1,340 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lzbi.draft.mapper.DcBusiParamDraftDayMapper">
<resultMap type="com.lzbi.draft.domain.DcBusiParamDraftDay" id="rmDcBusiParamDraftDay">
<!-- 租户号 -->
<result property="tenantId" column="tenant_id"/>
<!-- 乐观锁 -->
<result property="revision" column="revision"/>
<!-- 创建人 -->
<result property="createdBy" column="created_by"/>
<!-- 创建时间 -->
<result property="createdTime" column="created_time"/>
<!-- 更新人 -->
<result property="updatedBy" column="updated_by"/>
<!-- 更新时间 -->
<result property="updatedTime" column="updated_time"/>
<!-- 删除人 -->
<result property="deleteBy" column="delete_by"/>
<!-- 删除时间 -->
<result property="deleteTime" column="delete_time"/>
<!-- 主键 -->
<result property="id" column="id"/>
<!-- 公司编码 -->
<result property="companyCode" column="company_code"/>
<!-- 生产组织机构名称 -->
<result property="organizeName" column="organize_name"/>
<!-- 生产组织机构编号 -->
<result property="organizeCode" column="organize_code"/>
<!-- 公司名称 -->
<result property="companyName" column="company_name"/>
<!-- 统计单元 -->
<result property="assetCode" column="asset_code"/>
<!-- 统计单元 -->
<result property="assetName" column="asset_name"/>
<!-- 参数编码 -->
<result property="paramCode" column="param_code"/>
<!-- 参数名称 -->
<result property="paramName" column="param_name"/>
<!-- 生产专业 -->
<result property="paramField" column="param_field"/>
<!-- 指标单位 -->
<result property="targetUint" column="target_uint"/>
<!-- 统计日期[yyyy-mm-dd] -->
<result property="countDate" column="count_date"/>
<!-- 均值 -->
<result property="valAvg" column="val_avg"/>
<!-- 当日最大值 -->
<result property="valMax" column="val_max"/>
<!-- 和值 -->
<result property="valSum" column="val_sum"/>
<!-- 当日最小值 -->
<result property="valMin" column="val_min"/>
<!-- 积算值 -->
<result property="valIntegrating" column="val_integrating"/>
<!-- 上限 -->
<result property="valLimitUp" column="val_limit_up"/>
<!-- 下限 -->
<result property="valLimitDown" column="val_limit_down"/>
<!-- 1时 -->
<result property="val01" column="val01"/>
<!-- 2时 -->
<result property="val02" column="val02"/>
<!-- 3时 -->
<result property="val03" column="val03"/>
<!-- 4时 -->
<result property="val04" column="val04"/>
<!-- 5时 -->
<result property="val05" column="val05"/>
<!-- 6时 -->
<result property="val06" column="val06"/>
<!-- 7时 -->
<result property="val07" column="val07"/>
<!-- 8时 -->
<result property="val08" column="val08"/>
<!-- 9时 -->
<result property="val09" column="val09"/>
<!-- 10时 -->
<result property="val10" column="val10"/>
<!-- 11时 -->
<result property="val11" column="val11"/>
<!-- 12时 -->
<result property="val12" column="val12"/>
<!-- 13时 -->
<result property="val13" column="val13"/>
<!-- 14时 -->
<result property="val14" column="val14"/>
<!-- 15时 -->
<result property="val15" column="val15"/>
<!-- 16时 -->
<result property="val16" column="val16"/>
<!-- 17时 -->
<result property="val17" column="val17"/>
<!-- 18时 -->
<result property="val18" column="val18"/>
<!-- 18时 -->
<result property="val19" column="val19"/>
<!-- 20时 -->
<result property="val20" column="val20"/>
<!-- 21时 -->
<result property="val21" column="val21"/>
<!-- 22时 -->
<result property="val22" column="val22"/>
<!-- 23时 -->
<result property="val23" column="val23"/>
<!-- 24时 -->
<result property="val24" column="val24"/>
</resultMap>
<sql id="baseQuerySql">
select
tenant_id,
revision,
created_by,
created_time,
updated_by,
updated_time,
delete_by,
delete_time,
id,
company_code,
organize_name,
organize_code,
company_name,
asset_code,
asset_name,
param_code,
param_name,
param_field,
target_uint,
count_date,
val_avg,
val_max,
val_sum,
val_min,
val_integrating,
val_limit_up,
val_limit_down,
val01,
val02,
val03,
val04,
val05,
val06,
val07,
val08,
val09,
val10,
val11,
val12,
val13,
val14,
val15,
val16,
val17,
val18,
val19,
val20,
val21,
val22,
val23,
val24
from dc_busi_param_draft_day
</sql>
<select id="selectByVo" resultMap="rmDcBusiParamDraftDay" parameterType="com.lzbi.draft.domain.DcBusiParamDraftDay">
<include refid="baseQuerySql"/>
<where>
<if test="tenantId != null"> and tenant_id = #{tenantId}</if>
<if test="revision != null "> and revision = #{revision}</if>
<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 "> 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 != ''"> and id = #{id}</if>
<if test="companyCode != null and companyCode != ''"> and company_code = #{companyCode}</if>
<if test="organizeName != null and organizeName != ''"> and organize_name = #{organizeName}</if>
<if test="organizeCode != null and organizeCode != ''"> and organize_code = #{organizeCode}</if>
<if test="companyName != null and companyName != ''"> and company_name = #{companyName}</if>
<if test="assetCode != null and assetCode != ''"> and asset_code = #{assetCode}</if>
<if test="assetName != null and assetCode != ''"> and asset_name = #{assetName}</if>
<if test="paramCode != null and paramCode != ''"> and param_code = #{paramCode}</if>
<if test="paramName != null and paramName != ''"> and param_name = #{paramName}</if>
<if test="paramField != null and paramField != ''"> and param_field = #{paramField}</if>
<if test="targetUint != null and targetUint != ''"> and target_uint = #{targetUint}</if>
<if test="countDate != null and countDate != ''"> and count_date = #{countDate}</if>
<if test="valAvg != null"> and val_avg = #{valAvg}</if>
<if test="valMax != null"> and val_max = #{valMax}</if>
<if test="valSum != null"> and val_sum = #{valSum}</if>
<if test="valMin != null"> and val_min = #{valMin}</if>
<if test="valIntegrating != null "> and val_integrating = #{valIntegrating}</if>
<if test="valLimitUp != null "> and val_limit_up = #{valLimitUp}</if>
<if test="valLimitDown != null"> and val_limit_down = #{valLimitDown}</if>
<if test="val01 != null "> and val01 = #{val01}</if>
<if test="val02 != null "> and val02 = #{val02}</if>
<if test="val03 != null"> and val03 = #{val03}</if>
<if test="val04 != null "> and val04 = #{val04}</if>
<if test="val05 != null "> and val05 = #{val05}</if>
<if test="val06 != null "> and val06 = #{val06}</if>
<if test="val07 != null "> and val07 = #{val07}</if>
<if test="val08 != null "> and val08 = #{val08}</if>
<if test="val09 != null "> and val09 = #{val09}</if>
<if test="val10 != null "> and val10 = #{val10}</if>
<if test="val11 != null "> and val11 = #{val11}</if>
<if test="val12 != null "> and val12 = #{val12}</if>
<if test="val13 != null "> and val13 = #{val13}</if>
<if test="val14 != null "> and val14 = #{val14}</if>
<if test="val15 != null "> and val15 = #{val15}</if>
<if test="val16 != null "> and val16 = #{val16}</if>
<if test="val17 != null "> and val17 = #{val17}</if>
<if test="val18 != null "> and val18 = #{val18}</if>
<if test="val19 != null "> and val19 = #{val19}</if>
<if test="val20 != null "> and val20 = #{val20}</if>
<if test="val21 != null "> and val21 = #{val21}</if>
<if test="val22 != null "> and val22 = #{val22}</if>
<if test="val23 != null "> and val23 = #{val23}</if>
<if test="val24 != null "> and val24 = #{val24}</if>
</where>
</select>
<insert id="insertByVo" parameterType="com.lzbi.draft.domain.DcBusiParamDraftDay">
insert into dc_busi_param_draft_day
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null ">tenant_id,</if>
<if test="revision != null ">revision,</if>
<if test="createdBy != null and createdBy != ''">created_by,</if>
<if test="createdTime != null ">created_time,</if>
<if test="updatedBy != null and updatedBy != ''">updated_by,</if>
<if test="updatedTime != null ">updated_time,</if>
<if test="deleteBy != null and deleteBy != ''">delete_by,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="companyCode != null and companyCode != ''">company_code,</if>
<if test="organizeName != null and organizeName != ''">organize_name,</if>
<if test="organizeCode != null and organizeCode != ''">organize_code,</if>
<if test="companyName != null and companyName != ''">company_name,</if>
<if test="assetCode != null and assetCode != ''">asset_code,</if>
<if test="assetName != null and assetName != ''">asset_name,</if>
<if test="paramCode != null and paramCode != ''">param_code,</if>
<if test="paramName != null and paramName != ''">param_name,</if>
<if test="paramField != null and paramField != ''">param_field,</if>
<if test="targetUint != null and targetUint != ''">target_uint,</if>
<if test="countDate != null and countDate != ''">count_date,</if>
<if test="valAvg != null ">val_avg,</if>
<if test="valMax != null ">val_max,</if>
<if test="valSum != null ">val_sum,</if>
<if test="valMin != null ">val_min,</if>
<if test="valIntegrating != null">val_integrating,</if>
<if test="valLimitUp != null ">val_limit_up,</if>
<if test="valLimitDown != null ">val_limit_down,</if>
<if test="val01 != null">val01,</if>
<if test="val02 != null">val02,</if>
<if test="val03 != null">val03,</if>
<if test="val04 != null">val04,</if>
<if test="val05 != null">val05,</if>
<if test="val06 != null">val06,</if>
<if test="val07 != null">val07,</if>
<if test="val08 != null">val08,</if>
<if test="val09 != null">val09,</if>
<if test="val10 != null">val10,</if>
<if test="val11 != null">val11,</if>
<if test="val12 != null">val12,</if>
<if test="val13 != null">val13,</if>
<if test="val14 != null">val14,</if>
<if test="val15 != null">val15,</if>
<if test="val16 != null">val16,</if>
<if test="val17 != null">val17,</if>
<if test="val18 != null">val18,</if>
<if test="val19 != null">val19,</if>
<if test="val20 != null">val20,</if>
<if test="val21 != null">val21,</if>
<if test="val22 != null">val22,</if>
<if test="val23 != null">val23,</if>
<if test="val24 != null">val24,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null ">#{tenantId},</if>
<if test="revision != null ">#{revision},</if>
<if test="createdBy != null and createdBy != ''">#{createdBy},</if>
<if test="createdTime != null ">#{createdTime},</if>
<if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
<if test="updatedTime != null ">#{updatedTime},</if>
<if test="deleteBy != null and deleteBy != ''">#{deleteBy},</if>
<if test="deleteTime != null ">#{deleteTime},</if>
<if test="companyCode != null and companyCode != ''">#{companyCode},</if>
<if test="organizeName != null and organizeName != ''">#{organizeName},</if>
<if test="organizeCode != null and organizeCode != ''">#{organizeCode},</if>
<if test="companyName != null and companyName != ''">#{companyName},</if>
<if test="assetCode != null and assetCode != ''">#{assetCode},</if>
<if test="assetName != null and assetName != ''">#{assetName},</if>
<if test="paramCode != null and paramCode != ''">#{paramCode},</if>
<if test="paramName != null and paramName != ''">#{paramName},</if>
<if test="paramField != null and paramField != ''">#{paramField},</if>
<if test="targetUint != null and targetUint != ''">#{targetUint},</if>
<if test="countDate != null and countDate != ''">#{countDate},</if>
<if test="valAvg != null ">#{valAvg},</if>
<if test="valMax != null ">#{valMax},</if>
<if test="valSum != null ">#{valSum},</if>
<if test="valMin != null ">#{valMin},</if>
<if test="valIntegrating != null ">#{valIntegrating},</if>
<if test="valLimitUp != null ">#{valLimitUp},</if>
<if test="valLimitDown != null">#{valLimitDown},</if>
<if test="val01 != null ">#{val01},</if>
<if test="val02 != null">#{val02},</if>
<if test="val03 != null">#{val03},</if>
<if test="val04 != null">#{val04},</if>
<if test="val05 != null">#{val05},</if>
<if test="val06 != null">#{val06},</if>
<if test="val07 != null">#{val07},</if>
<if test="val08 != null">#{val08},</if>
<if test="val09 != null">#{val09},</if>
<if test="val10 != null">#{val10},</if>
<if test="val11 != null">#{val11},</if>
<if test="val12 != null">#{val12},</if>
<if test="val13 != null">#{val13},</if>
<if test="val14 != null">#{val14},</if>
<if test="val15 != null">#{val15},</if>
<if test="val16 != null">#{val16},</if>
<if test="val17 != null">#{val17},</if>
<if test="val18 != null">#{val18},</if>
<if test="val19 != null">#{val19},</if>
<if test="val20 != null">#{val20},</if>
<if test="val21 != null">#{val21},</if>
<if test="val22 != null">#{val22},</if>
<if test="val23 != null">#{val23},</if>
<if test="val24 != null">#{val24},</if>
</trim>
</insert>
<select id="selectOneByParam" resultMap="rmDcBusiParamDraftDay" parameterType="ParamDraftQueryVo">
<include refid="baseQuerySql"></include>
<where>
<if test="assetCode != null and assetCode != ''"> and asset_code = #{assetCode}</if>
<if test="assetParamCode != null and assetParamCode != ''"> and param_code = #{assetParamCode}</if>
<if test="specialCode != null and specialCode != ''"> and param_field = #{specialCode}</if>
<if test="countDate != null and countDate != ''"> and count_date = #{countDate}</if>
</where>
limit 1
</select>
</mapper>

132
lzbi-module/src/main/resources/mapper/asset/DcBusiWorkReadLogMapper.xml

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lzbi.task.mapper.DcBusiWorkReadLogMapper">
<resultMap type="com.lzbi.task.domain.DcBusiWorkReadLog" id="rmDcBusiWorkReadLog">
<!-- 参数编码 -->
<result property="paramCode" column="param_code"/>
<!-- 设备编码 -->
<result property="deviceCode" column="device_code"/>
<!-- 统计时间 -->
<result property="thour" column="thour"/>
<!-- 生成时间 -->
<result property="createTime" column="create_time"/>
<!-- 和值 -->
<result property="total" column="total"/>
<!-- 总条数 -->
<result property="countsAll" column="counts_all"/>
<!-- 除零总数 -->
<result property="countsZero" column="counts_zero"/>
<!-- 最大值 -->
<result property="maxVal" column="max_val"/>
<!-- 最小值 -->
<result property="minVal" column="min_val"/>
<!-- 开始值 -->
<result property="firstVal" column="first_val"/>
<!-- 结束值 -->
<result property="lastVal" column="last_val"/>
<!-- 均值 -->
<result property="avgAll" column="avg_all"/>
<!-- 除零均值 -->
<result property="avgNoZero" column="avg_no_zero"/>
<!-- 统计日 -->
<result property="dateCount" column="date_count"/>
<!-- 小时 -->
<result property="hourCount" column="hour_count"/>
</resultMap>
<sql id="baseQuerySql">
select
param_code,
device_code,
thour,
create_time,
total,
counts_all,
counts_zero,
max_val,
min_val,
first_val,
last_val,
avg_all,
avg_no_zero,
date_count,
hour_count
from dc_busi_work_read_log
</sql>
<select id="selectByVo" resultMap="rmDcBusiWorkReadLog" parameterType="com.lzbi.task.domain.DcBusiWorkReadLog">
<include refid="baseQuerySql"/>
<where>
<if test="paramCode != null and paramCode != ''"> and param_code = #{paramCode}</if>
<if test="deviceCode != null and deviceCode != ''"> and device_code = #{deviceCode}</if>
<if test="thour != null and thour != ''"> and thour = #{thour}</if>
<if test="createTime != null and createTime != ''"> and create_time = #{createTime}</if>
<if test="total != null and total != ''"> and total = #{total}</if>
<if test="countsAll != null and countsAll != ''"> and counts_all = #{countsAll}</if>
<if test="countsZero != null and countsZero != ''"> and counts_zero = #{countsZero}</if>
<if test="maxVal != null and maxVal != ''"> and max_val = #{maxVal}</if>
<if test="minVal != null and minVal != ''"> and min_val = #{minVal}</if>
<if test="firstVal != null and firstVal != ''"> and first_val = #{firstVal}</if>
<if test="lastVal != null and lastVal != ''"> and last_val = #{lastVal}</if>
<if test="avgAll != null and avgAll != ''"> and avg_all = #{avgAll}</if>
<if test="avgNoZero != null and avgNoZero != ''"> and avg_no_zero = #{avgNoZero}</if>
<if test="dateCount != null and dateCount != ''"> and date_count = #{dateCount}</if>
<if test="hourCount != null and hourCount != ''"> and hour_count = #{hourCount}</if>
</where>
</select>
<insert id="insertByVo" parameterType="com.lzbi.task.domain.DcBusiWorkReadLog">
insert into dc_busi_work_read_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="paramCode != null and paramCode != ''">param_code,</if>
<if test="deviceCode != null and deviceCode != ''">device_code,</if>
<if test="thour != null and thour != ''">thour,</if>
<if test="createTime != null and createTime != ''">create_time,</if>
<if test="total != null and total != ''">total,</if>
<if test="countsAll != null and countsAll != ''">counts_all,</if>
<if test="countsZero != null and countsZero != ''">counts_zero,</if>
<if test="maxVal != null and maxVal != ''">max_val,</if>
<if test="minVal != null and minVal != ''">min_val,</if>
<if test="firstVal != null and firstVal != ''">first_val,</if>
<if test="lastVal != null and lastVal != ''">last_val,</if>
<if test="avgAll != null and avgAll != ''">avg_all,</if>
<if test="avgNoZero != null and avgNoZero != ''">avg_no_zero,</if>
<if test="dateCount != null and dateCount != ''">date_count,</if>
<if test="hourCount != null and hourCount != ''">hour_count,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="paramCode != null and paramCode != ''">#{paramCode},</if>
<if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
<if test="thour != null and thour != ''">#{thour},</if>
<if test="createTime != null and createTime != ''">#{createTime},</if>
<if test="total != null and total != ''">#{total},</if>
<if test="countsAll != null and countsAll != ''">#{countsAll},</if>
<if test="countsZero != null and countsZero != ''">#{countsZero},</if>
<if test="maxVal != null and maxVal != ''">#{maxVal},</if>
<if test="minVal != null and minVal != ''">#{minVal},</if>
<if test="firstVal != null and firstVal != ''">#{firstVal},</if>
<if test="lastVal != null and lastVal != ''">#{lastVal},</if>
<if test="avgAll != null and avgAll != ''">#{avgAll},</if>
<if test="avgNoZero != null and avgNoZero != ''">#{avgNoZero},</if>
<if test="dateCount != null and dateCount != ''">#{dateCount},</if>
<if test="hourCount != null and hourCount != ''">#{hourCount},</if>
</trim>
</insert>
<delete id="deleteByParams" parameterType="com.lzbi.task.domain.ReadQueryParams">
delete from dc_busi_work_read_log where date_count=#{beginTime}
and device_code in
<foreach item="item" index="index" collection="deviceCodes" open="(" close=")" separator=",">
#{item}
</foreach>
and param_code in
<foreach item="item" index="index" collection="paramCodes" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
</mapper>

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

@ -3,13 +3,13 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lzbi.task.mapper.WorkParamReadMapper">
<resultMap type="com.lzbi.task.domain.WorkReadVo" id="WorkReadVoResult">
<resultMap type="com.lzbi.task.domain.DcBusiWorkReadLog" id="WorkReadVoResult">
<result property="deviceCode" column="device_uuid" />
<result property="paramCode" column="param_code" />
<result property="thour" column="thour" />
<result property="total" column="total" />
<result property="countsall" column="countsall" />
<result property="countsz" column="countsz" />
<result property="countsAll" column="countsall" />
<result property="countsZero" column="countsz" />
<result property="maxVal" column="maxVal" />
<result property="minVal" column="minVal" />
<result property="firstVal" column="firstVal" />

Loading…
Cancel
Save