Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
zhousq 11 months ago
parent
commit
152801abbc
  1. 9
      lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java
  2. 10
      lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseParamModelController.java
  3. 3
      lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseParamModel.java
  4. 1
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java
  5. 42
      lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java
  6. 9
      lzbi-module/src/main/java/com/lzbi/targetFolder/controller/DcBaseAssetTargetController.java
  7. 17
      lzbi-module/src/main/java/com/lzbi/targetFolder/controller/DcBaseTargetModelController.java
  8. 88
      lzbi-module/src/main/java/com/lzbi/task/domain/DaTangGuanJingDataVO.java
  9. 88
      lzbi-module/src/main/java/com/lzbi/task/domain/MultipleDeviceDataVO.java
  10. 13
      lzbi-module/src/main/java/com/lzbi/task/domain/ReadQueryParams.java
  11. 26
      lzbi-module/src/main/java/com/lzbi/task/domain/ThourWeatherVO.java
  12. 40
      lzbi-module/src/main/java/com/lzbi/task/domain/WorkDataDTO.java
  13. 8
      lzbi-module/src/main/java/com/lzbi/task/mapper/WorkParamReadMapper.java
  14. 142
      lzbi-module/src/main/java/com/lzbi/task/service/WorkParamReadService.java
  15. 7
      lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml
  16. 1
      lzbi-module/src/main/resources/mapper/asset/DcBaseParamModelMapper.xml
  17. 76
      lzbi-module/src/main/resources/mapper/asset/WorkParamReadMapper.xml
  18. 1
      lzbi-module/src/main/resources/mapper/targetFolder/DcBaseAssetTargetMapper.xml
  19. 1
      lzbi-module/src/main/resources/mapper/targetFolder/DcBaseTargetModelMapper.xml

9
lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java

@ -79,6 +79,10 @@ public class DcBaseAssetInfoController extends BaseController {
@Log(title = "资产信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcBaseAssetInfo dcBaseAssetInfo) {
dcBaseAssetInfo.setCreatedTime(DateUtils.getNowDate());
dcBaseAssetInfo.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetInfo.setDeptId(getDeptId());
dcBaseAssetInfo.setUserId(getUserId());
return toAjax(dcBaseAssetInfoService.insertDcBaseAssetInfo(dcBaseAssetInfo));
}
@ -89,6 +93,8 @@ public class DcBaseAssetInfoController extends BaseController {
@Log(title = "资产信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcBaseAssetInfo dcBaseAssetInfo) {
dcBaseAssetInfo.setUpdatedBy(getUsername());
dcBaseAssetInfo.setUpdatedTime(DateUtils.getNowDate());
return toAjax(dcBaseAssetInfoService.updateDcBaseAssetInfo(dcBaseAssetInfo));
}
@ -122,10 +128,9 @@ public class DcBaseAssetInfoController extends BaseController {
beanObject.remove("id");
DcBaseAssetInfo dcBaseAssetInfo = JSON.toJavaObject(beanObject, DcBaseAssetInfo.class);
dcBaseAssetInfo.setCreatedTime(DateUtils.getNowDate());
dcBaseAssetInfo.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetInfo.setDeptId(getDeptId());
dcBaseAssetInfo.setUserId(getUserId());
dcBaseAssetInfo.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetInfo.setCreatedTime(DateUtils.getNowDate());
beanList.add(dcBaseAssetInfo);
}
} catch (Exception e) {

10
lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseParamModelController.java

@ -72,11 +72,10 @@ public class DcBaseParamModelController extends BaseController
@PostMapping
public AjaxResult add(@Valid @RequestBody DcBaseParamModel dcBaseParamModel) {
//BeanValidators.validateWithException(validator, dcBaseParamModel);
dcBaseParamModel.setCreatedBy(getUsername());
dcBaseParamModel.setCreatedTime(DateUtils.getNowDate());
dcBaseParamModel.setTenantId("0");
dcBaseParamModel.setUpdatedBy(getUsername());
dcBaseParamModel.setUpdatedTime(DateUtils.getNowDate());
dcBaseParamModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseParamModel.setDeptId(getDeptId());
dcBaseParamModel.setUserId(getUserId());
return toAjax(dcBaseParamModelService.insertByVo(dcBaseParamModel));
}
/**
@ -154,10 +153,9 @@ public class DcBaseParamModelController extends BaseController
beanObject.remove("id");
DcBaseParamModel dcBaseParamModel = JSON.toJavaObject(beanObject, DcBaseParamModel.class);
dcBaseParamModel.setCreatedTime(DateUtils.getNowDate());
dcBaseParamModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseParamModel.setDeptId(getDeptId());
dcBaseParamModel.setUserId(getUserId());
dcBaseParamModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseParamModel.setCreatedTime(DateUtils.getNowDate());
dcBaseParamModelList.add(dcBaseParamModel);
}
} catch (Exception e) {

3
lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseParamModel.java

@ -22,9 +22,6 @@ import com.lzbi.module.base.BaseModuleEntity;
@TableName("dc_base_param_model")
public class DcBaseParamModel extends BaseModuleEntity{
/** 主键 */
@ApiModelProperty(name = "主键",notes = "")
private Long id ;
/** 参数模型编码 */
@ApiModelProperty(name = "参数模型编码",notes = "")
private String paramModelCode ;

1
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenNewController.java

@ -93,4 +93,5 @@ public class DcBusiDataScreenNewController extends BaseController {
public AjaxResult corporateStatistics(@Validated DcBusDataScreenNewReq dcBusDataScreenNewReq) {
return success(dcBusiDataScreenNewService.getCorporateStatistics(dcBusDataScreenNewReq));
}
}

42
lzbi-module/src/main/java/com/lzbi/draft/controller/ReportController.java

@ -1,10 +1,17 @@
package com.lzbi.draft.controller;
import com.lzbi.common.core.controller.BaseController;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.draft.entity.req.TargetDraftMonthReportReq;
import com.lzbi.draft.entity.vo.TargetDraftMonthReportVO;
import com.lzbi.draft.service.ReportService;
import com.lzbi.task.domain.DaTangGuanJingDataVO;
import com.lzbi.task.domain.MultipleDeviceDataVO;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.ThourWeatherVO;
import com.lzbi.task.service.WorkParamReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,13 +26,46 @@ import java.util.List;
*/
@RestController
@RequestMapping("/report")
public class ReportController {
public class ReportController extends BaseController {
@Autowired
private ReportService reportService;
@Autowired
private WorkParamReadService workParamReadService;
@GetMapping("/targetDraftMonthReport")
public List<TargetDraftMonthReportVO> targetDraftMonthReport(TargetDraftMonthReportReq targetDraftMonthReportReq) {
return reportService.getTargetDraftMonthReport(targetDraftMonthReportReq);
}
/**
* 获取数据
* @param readQueryParams
* @return
*/
@GetMapping("/multipleDeviceData")
public List<MultipleDeviceDataVO> getMultipleDeviceData(@Validated ReadQueryParams readQueryParams) {
return workParamReadService.getMultipleDeviceData(readQueryParams);
}
/**
* 获取数据
* @param readQueryParams
* @return
*/
@GetMapping("/daTangGuanJingData")
public List<DaTangGuanJingDataVO> getDaTangGuanJingDataVO(@Validated ReadQueryParams readQueryParams) {
return workParamReadService.getDaTangGuanJingDataVO(readQueryParams);
}
/**
* 获取小时天气
* @param readQueryParams
* @return
*/
@GetMapping("/thourWeather")
public List<ThourWeatherVO> getThourWeather(@Validated ReadQueryParams readQueryParams) {
return workParamReadService.getThourWeather(readQueryParams);
}
}

9
lzbi-module/src/main/java/com/lzbi/targetFolder/controller/DcBaseAssetTargetController.java

@ -83,6 +83,10 @@ public class DcBaseAssetTargetController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody DcBaseAssetTarget dcBaseAssetTarget)
{
dcBaseAssetTarget.setCreatedTime(DateUtils.getNowDate());
dcBaseAssetTarget.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetTarget.setDeptId(getDeptId());
dcBaseAssetTarget.setUserId(getUserId());
return toAjax(dcBaseAssetTargetService.insertDcBaseAssetTarget(dcBaseAssetTarget));
}
@ -94,6 +98,8 @@ public class DcBaseAssetTargetController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody DcBaseAssetTarget dcBaseAssetTarget)
{
dcBaseAssetTarget.setUpdatedTime(DateUtils.getNowDate());
dcBaseAssetTarget.setUpdatedBy(String.valueOf(getUserId()));
return toAjax(dcBaseAssetTargetService.updateDcBaseAssetTarget(dcBaseAssetTarget));
}
@ -140,10 +146,9 @@ public class DcBaseAssetTargetController extends BaseController
beanObject.remove("id");
DcBaseAssetTarget dcBaseAssetTarget = JSON.toJavaObject(beanObject, DcBaseAssetTarget.class);
dcBaseAssetTarget.setCreatedTime(DateUtils.getNowDate());
dcBaseAssetTarget.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetTarget.setDeptId(getDeptId());
dcBaseAssetTarget.setUserId(getUserId());
dcBaseAssetTarget.setCreatedBy(String.valueOf(getUserId()));
dcBaseAssetTarget.setCreatedTime(DateUtils.getNowDate());
beanList.add(dcBaseAssetTarget);
}
} catch (Exception e) {

17
lzbi-module/src/main/java/com/lzbi/targetFolder/controller/DcBaseTargetModelController.java

@ -101,9 +101,13 @@ public class DcBaseTargetModelController extends BaseController
@PreAuthorize("@ss.hasPermi('target:targetModel:add')")
@Log(title = "指标模版配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcBaseTargetModel DcBaseTargetModel)
public AjaxResult add(@RequestBody DcBaseTargetModel dcBaseTargetModel)
{
return toAjax(dcBaseTargetModelService.insertDcBaseTargetModel(DcBaseTargetModel));
dcBaseTargetModel.setCreatedTime(DateUtils.getNowDate());
dcBaseTargetModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseTargetModel.setDeptId(getDeptId());
dcBaseTargetModel.setUserId(getUserId());
return toAjax(dcBaseTargetModelService.insertDcBaseTargetModel(dcBaseTargetModel));
}
/**
@ -117,9 +121,11 @@ public class DcBaseTargetModelController extends BaseController
@PreAuthorize("@ss.hasPermi('target:targetModel:edit')")
@Log(title = "指标模版配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcBaseTargetModel DcBaseTargetModel)
public AjaxResult edit(@RequestBody DcBaseTargetModel dcBaseTargetModel)
{
return toAjax(dcBaseTargetModelService.updateDcBaseTargetModel(DcBaseTargetModel));
dcBaseTargetModel.setUpdatedTime(DateUtils.getNowDate());
dcBaseTargetModel.setUpdatedBy(String.valueOf(getUserId()));
return toAjax(dcBaseTargetModelService.updateDcBaseTargetModel(dcBaseTargetModel));
}
/**
@ -157,10 +163,9 @@ public class DcBaseTargetModelController extends BaseController
beanObject.remove("id");
DcBaseTargetModel dcBaseTargetModel = JSON.toJavaObject(beanObject, DcBaseTargetModel.class);
dcBaseTargetModel.setCreatedTime(DateUtils.getNowDate());
dcBaseTargetModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseTargetModel.setDeptId(getDeptId());
dcBaseTargetModel.setUserId(getUserId());
dcBaseTargetModel.setCreatedBy(String.valueOf(getUserId()));
dcBaseTargetModel.setCreatedTime(DateUtils.getNowDate());
beanList.add(dcBaseTargetModel);
}
} catch (Exception e) {

88
lzbi-module/src/main/java/com/lzbi/task/domain/DaTangGuanJingDataVO.java

@ -0,0 +1,88 @@
package com.lzbi.task.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class DaTangGuanJingDataVO {
/**
* 瞬时流量
*/
private Double ssll;
/**
* 累计热量
*/
private Double ssrl;
/**
* 一网供温
*/
private Double ywgw;
/**
* 一网回温
*/
private Double ywhw;
/**
* 一网供压
*/
private Double ywgy;
/**
* 一网回压
*/
private Double ywhy;
/**
* 供水流量
*/
private Double gsll;
/**
* 回水流量
*/
private Double hsll;
/**
* 瞬时补水
*/
private Double ssbs;
/**
* 累计补水
*/
private Double ljbs;
/**
* 阀门给定
*/
private Double fmgd;
/**
* 阀门反馈
*/
private Double fmfk;
/**
* 设备编码
*/
private String deviceName;
/**
* 分区
*/
private String partion;
/**
* 统计时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH")
private Date thour;
public DaTangGuanJingDataVO() {
this.ssll = 0D;
this.ssrl = 0D;
this.ywgw = 0D;
this.ywhw = 0D;
this.ywgy = 0D;
this.ywhy = 0D;
this.gsll = 0D;
this.hsll = 0D;
this.ssbs = 0D;
this.ljbs = 0D;
this.fmgd = 0D;
this.fmfk = 0D;
}
}

88
lzbi-module/src/main/java/com/lzbi/task/domain/MultipleDeviceDataVO.java

@ -0,0 +1,88 @@
package com.lzbi.task.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class MultipleDeviceDataVO {
/**
* 瞬时流量
*/
private Double ssll;
/**
* 累计热量
*/
private Double ssrl;
/**
* 一网供温
*/
private Double ywgw;
/**
* 一网回温
*/
private Double ywhw;
/**
* 一网供压
*/
private Double ywgy;
/**
* 一网回压
*/
private Double ywhy;
/**
* 二网供温
*/
private Double ewgw;
/**
* 二网回温
*/
private Double ewhw;
/**
* 二网供压
*/
private Double ewgy;
/**
* 二网回压
*/
private Double ewhy;
/**
* 阀门给定
*/
private Double fmgd;
/**
* 阀门反馈
*/
private Double fmfk;
/**
* 设备编码
*/
private String deviceName;
/**
* 分区
*/
private String partion;
/**
* 统计时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH")
private Date thour;
public MultipleDeviceDataVO() {
this.ssll = 0D;
this.ssrl = 0D;
this.ywgw = 0D;
this.ywhw = 0D;
this.ywgy = 0D;
this.ywhy = 0D;
this.ewgw = 0D;
this.ewhw = 0D;
this.ewgy = 0D;
this.ewhy = 0D;
this.fmgd = 0D;
this.fmfk = 0D;
}
}

13
lzbi-module/src/main/java/com/lzbi/task/domain/ReadQueryParams.java

@ -1,7 +1,10 @@
package com.lzbi.task.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -11,8 +14,18 @@ import java.util.List;
*/
@Data
public class ReadQueryParams {
@NotNull(message = "请输入起始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH")
@DateTimeFormat(pattern = "yyyy-MM-dd HH")
private String beginTime;
@NotNull(message = "请输入结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH")
@DateTimeFormat(pattern = "yyyy-MM-dd HH")
private String endTime;
private List<String> deviceCodes;
private List<String> paramCodes;
}

26
lzbi-module/src/main/java/com/lzbi/task/domain/ThourWeatherVO.java

@ -0,0 +1,26 @@
package com.lzbi.task.domain;
import lombok.Data;
import java.util.Date;
@Data
public class ThourWeatherVO {
/**
* 城市
*/
private String city;
/**
* 天气
*/
private String weather;
/**
* 温度
*/
private Double temperature;
/**
* 时间
*/
private String thour;
}

40
lzbi-module/src/main/java/com/lzbi/task/domain/WorkDataDTO.java

@ -0,0 +1,40 @@
package com.lzbi.task.domain;
import lombok.Data;
import java.util.Date;
@Data
public class WorkDataDTO {
/** 参数编码 */
private String paramModelId ;
/** 参数编码名称 */
private String paramModeName ;
/** 设备编码 */
private String deviceCode ;
/** 设备编码 */
private String deviceName ;
/** 分区 */
private String partion;
/** 统计时间 */
private Date thour ;
/** 和值 */
private Double total ;
/** 总条数 */
private Double countsAll ;
/** 除零总数 */
private Double countsZero ;
/** 最大值 */
private Double maxVal ;
/** 最小值 */
private Double minVal ;
/** 开始值 */
private Double firstVal ;
/** 结束值 */
private Double lastVal ;
/** 统计日 */
private String dateCount ;
/** 小时 */
private Integer hourCount ;
}

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

@ -1,9 +1,7 @@
package com.lzbi.task.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzbi.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.WorkParamInfo;
import com.lzbi.task.domain.*;
import java.util.List;
@ -17,4 +15,8 @@ import java.util.List;
public interface WorkParamReadMapper extends BaseMapper<WorkParamInfo>
{
public List<DcBusiWorkReadLog> readWorkValue(ReadQueryParams readQueryParams);
List<WorkDataDTO> readWorkData (ReadQueryParams readQueryParams);
List<ThourWeatherVO> getThourWeather(ReadQueryParams readQueryParams);
}

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

@ -1,14 +1,19 @@
package com.lzbi.task.service;
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.task.domain.DcBusiWorkReadLog;
import com.lzbi.task.domain.ReadQueryParams;
import com.lzbi.task.domain.WorkParamInfo;
import com.lzbi.task.domain.*;
import com.lzbi.task.mapper.WorkParamReadMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -17,14 +22,137 @@ import java.util.List;
* @author win
* @date 2023-11-29
*/
//@DS("workDB")
@DS("workDB")
@Service
public class WorkParamReadService extends ServiceImpl<WorkParamReadMapper, WorkParamInfo> implements IService<WorkParamInfo>
@Slf4j
public class WorkParamReadService extends ServiceImpl<WorkParamReadMapper, WorkParamInfo> implements IService<WorkParamInfo> {
{
/*获取生产单元的参数读取配置
* */
public List<DcBusiWorkReadLog> readWorkValue(ReadQueryParams readQueryParams) {
return baseMapper.readWorkValue(readQueryParams);
}
public List<MultipleDeviceDataVO> getMultipleDeviceData(ReadQueryParams readQueryParams) {
String[] DEVICE_CODE_ARR = new String[]{"00011","00053","00054","00050","00055","00051","00052","00059","00056","00057","00022","00023","00024","00009","00058","00026","00029","00030","00031","00032","00044","00013","00007","00017","00046","00042","00019","00016","00001","00028","00045","00021","00010","00041","00015","00014","00005","00006","00002","00003","00004","00008","00018","00027","00043","00020","00040"};
String[] PARAM_CODE_ARR = new String[]{"007", "009", "011", "012", "013", "014", "045", "046", "047", "048", "028", "029"};
readQueryParams.setParamCodes(Arrays.asList(PARAM_CODE_ARR));
readQueryParams.setDeviceCodes(Arrays.asList(DEVICE_CODE_ARR));
Class<MultipleDeviceDataVO> clazz = MultipleDeviceDataVO.class;
Field[] fields = clazz.getDeclaredFields();
List<MultipleDeviceDataVO> list = new ArrayList<>();
List<WorkDataDTO> workDataDTOS = baseMapper.readWorkData(readQueryParams);
if (!CollectionUtils.isEmpty(workDataDTOS)) {
Map<Date, List<WorkDataDTO>> timeMap = workDataDTOS.stream().collect(Collectors.groupingBy(WorkDataDTO::getThour));
timeMap.forEach((key, value) -> {
Map<String, List<WorkDataDTO>> deviceMap = value.stream().collect(Collectors.groupingBy(WorkDataDTO::getDeviceCode));
for (String deviceCode : DEVICE_CODE_ARR) {
if (deviceMap.containsKey(deviceCode)) {
List<WorkDataDTO> workDataDTOList = deviceMap.get(deviceCode);
Map<String, List<WorkDataDTO>> partionMap = workDataDTOList.stream().collect(Collectors.groupingBy(WorkDataDTO::getPartion));
partionMap.forEach((p, l) -> {
Map<String, List<WorkDataDTO>> paramModelMap = l.stream().collect(Collectors.groupingBy(WorkDataDTO::getParamModelId));
MultipleDeviceDataVO multipleDeviceDataVO = new MultipleDeviceDataVO();
multipleDeviceDataVO.setThour(key);
multipleDeviceDataVO.setDeviceName(deviceMap.get(deviceCode).get(0).getDeviceName());
multipleDeviceDataVO.setPartion(p);
for (int i = 0, len = PARAM_CODE_ARR.length; i < len; i++) {
try {
if (!fields[i].isAccessible()) {
fields[i].setAccessible(true);
}
List<WorkDataDTO> workDataDTOList1 = paramModelMap.get(PARAM_CODE_ARR[i]);
if (!CollectionUtils.isEmpty(workDataDTOList1)) {
WorkDataDTO workDataDTO1 = workDataDTOList1.get(0);
Double v = 0D;
if (i == 1) {
if (null != workDataDTO1.getLastVal()) {
v = workDataDTO1.getLastVal();
}
} else {
if (null != workDataDTO1.getTotal() && null != workDataDTO1.getCountsZero()) {
v = workDataDTO1.getTotal() / workDataDTO1.getCountsZero();
}
}
if (null != v && !Double.isNaN(v)) {
v = BigDecimal.valueOf(v).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
fields[i].set(multipleDeviceDataVO, v);
}
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
list.add(multipleDeviceDataVO);
});
}
}
});
}
return list;
}
public List<DaTangGuanJingDataVO> getDaTangGuanJingDataVO(ReadQueryParams readQueryParams) {
String[] DEVICE_CODE_ARR = new String[]{"00033"};
String[] PARAM_CODE_ARR = new String[]{"007", "009", "011", "012", "013", "014", "049", "054", "030", "031", "028", "029"};
readQueryParams.setParamCodes(Arrays.asList(PARAM_CODE_ARR));
readQueryParams.setDeviceCodes(Arrays.asList(DEVICE_CODE_ARR));
Class<DaTangGuanJingDataVO> clazz = DaTangGuanJingDataVO.class;
Field[] fields = clazz.getDeclaredFields();
List<DaTangGuanJingDataVO> list = new ArrayList<>();
List<WorkDataDTO> workDataDTOS = baseMapper.readWorkData(readQueryParams);
if (!CollectionUtils.isEmpty(workDataDTOS)) {
Map<Date, List<WorkDataDTO>> timeMap = workDataDTOS.stream().collect(Collectors.groupingBy(WorkDataDTO::getThour));
timeMap.forEach((key, value) -> {
Map<String, List<WorkDataDTO>> deviceMap = value.stream().collect(Collectors.groupingBy(WorkDataDTO::getDeviceCode));
for (String deviceCode : DEVICE_CODE_ARR) {
if (deviceMap.containsKey(deviceCode)) {
List<WorkDataDTO> workDataDTOList = deviceMap.get(deviceCode);
Map<String, List<WorkDataDTO>> partionMap = workDataDTOList.stream().collect(Collectors.groupingBy(WorkDataDTO::getPartion));
partionMap.forEach((p, l) -> {
Map<String, List<WorkDataDTO>> paramModelMap = l.stream().collect(Collectors.groupingBy(WorkDataDTO::getParamModelId));
DaTangGuanJingDataVO daTangGuanJingDataVO = new DaTangGuanJingDataVO();
daTangGuanJingDataVO.setThour(key);
daTangGuanJingDataVO.setDeviceName(deviceMap.get(deviceCode).get(0).getDeviceName());
daTangGuanJingDataVO.setPartion(p);
for (int i = 0, len = PARAM_CODE_ARR.length; i < len; i++) {
try {
if (!fields[i].isAccessible()) {
fields[i].setAccessible(true);
}
List<WorkDataDTO> workDataDTOList1 = paramModelMap.get(PARAM_CODE_ARR[i]);
if (!CollectionUtils.isEmpty(workDataDTOList1)) {
WorkDataDTO workDataDTO1 = workDataDTOList1.get(0);
Double v = 0D;
if (i == 1) {
if (null != workDataDTO1.getLastVal()) {
v = workDataDTO1.getLastVal();
}
} else {
if (null != workDataDTO1.getTotal() && null != workDataDTO1.getCountsZero()) {
v = workDataDTO1.getTotal() / workDataDTO1.getCountsZero();
}
}
if (null != v && !Double.isNaN(v)) {
v = BigDecimal.valueOf(v).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
fields[i].set(daTangGuanJingDataVO, v);
}
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
list.add(daTangGuanJingDataVO);
});
}
}
});
}
return list;
}
public List<ThourWeatherVO> getThourWeather(ReadQueryParams readQueryParams) {
return baseMapper.getThourWeather(readQueryParams);
}
}

7
lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml

@ -65,6 +65,7 @@
<if test="comanyId != null ">and comany_id = #{comanyId}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
</where>
ORDER BY COALESCE(updated_time, created_time) DESC
</select>
<select id="selectDcBaseAssetInfoById" parameterType="Long" resultMap="DcBaseAssetInfoResult">
<include refid="selectDcBaseAssetInfoVo"/>
@ -85,7 +86,7 @@
insert into dc_base_asset_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID,</if>
<if test="REVISION != null">REVISION,</if>
<if test="revision != null">REVISION,</if>
<if test="createdBy != null">CREATED_BY,</if>
<if test="createdTime != null">CREATED_TIME,</if>
<if test="updatedBy != null">UPDATED_BY,</if>
@ -104,7 +105,7 @@
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
<if test="REVISION != null">#{REVISION},</if>
<if test="revision != null">#{revision},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
@ -127,7 +128,7 @@
update dc_base_asset_info
<trim prefix="SET" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID = #{tenantId},</if>
<if test="REVISION != null">REVISION = #{REVISION},</if>
<if test="revision != null">REVISION = #{revision},</if>
<if test="createdBy != null">CREATED_BY = #{createdBy},</if>
<if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
<if test="updatedBy != null">UPDATED_BY = #{updatedBy},</if>

1
lzbi-module/src/main/resources/mapper/asset/DcBaseParamModelMapper.xml

@ -74,6 +74,7 @@
<if test="flagStatus != null and flagStatus != ''"> and flag_status = #{flagStatus}</if>
</where>
ORDER BY COALESCE(updated_time, created_time) DESC
</select>
<insert id="insertByVo" parameterType="com.lzbi.asset.domain.DcBaseParamModel">
insert into dc_base_param_model

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

@ -39,4 +39,80 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY thour, param_code,device_uuid
ORDER BY thour asc
</select>
<resultMap type="com.lzbi.task.domain.WorkDataDTO" id="WorkDataVoResult">
<result property="paramModelId" column="param_model_id" />
<result property="paramModeName" column="param_class_name" />
<result property="deviceCode" column="device_uuid" />
<result property="deviceName" column="device_name" />
<result property="partion" column="partion" />
<result property="thour" column="thour" />
<result property="total" column="total" />
<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" />
<result property="lastVal" column="lastVal" />
</resultMap>
<select id="readWorkData" resultMap="WorkDataVoResult" parameterType="com.lzbi.task.domain.ReadQueryParams">
SELECT
t2.param_model_id,
t3.param_class_name,
t1.device_uuid,
t5.device_name,
t4.partion,
time_bucket ( '1 HOUR', t1.timestamp_key ) AS thour,
SUM ( CASE WHEN t1.param_value_num > 0.00 THEN t1.param_value_num ELSE 0 END ) AS total,
COUNT ( * ) AS countsall,
SUM ( CASE WHEN t1.param_value_num > 0.00 THEN 1 ELSE 0 END ) AS countsz,
MAX ( t1.param_value_num ) AS maxVal,
FIRST ( t1.param_value_num, timestamp_key ) AS firstVal,
LAST ( t1.param_value_num, timestamp_key ) AS lastVal,
MIN ( t1.param_value_num ) AS minVal
FROM
dc_base_log_history_level1 t1
INNER JOIN dc_base_device_param t2 ON t1.param_code = t2.param_code
AND t2.param_model_id IN
<foreach item="item" index="index" collection="paramCodes" open="(" close=")" separator=",">
#{item}
</foreach>
LEFT JOIN dc_model_paramclass t3 ON t2.param_model_id = t3.param_class_code
LEFT JOIN dc_base_device_param t4 ON t4.param_code = t1.param_code
AND t4.device_uuid = t4.device_uuid
LEFT JOIN dc_base_deviceinfo t5 ON t5.center_device_code = t1.device_uuid
WHERE
t1.timestamp_key BETWEEN to_timestamp( #{beginTime}, 'yyyy-MM-dd hh24:mi:ss' )
AND to_timestamp( #{endTime}, 'yyyy-MM-dd hh24:mi:ss' )
AND t1.device_uuid in
<foreach item="item" index="index" collection="deviceCodes" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY
thour,
t1.device_uuid,
t2.param_model_id,
t3.param_class_name,
t4.partion,
t5.device_name
</select>
<select id="getThourWeather" parameterType="com.lzbi.task.domain.ReadQueryParams" resultType="com.lzbi.task.domain.ThourWeatherVO">
SELECT
city,
max(weather) AS weather,
min(temperature) AS temperature,
to_char( reporttime, 'yyyy-MM-dd hh24' ) as thour
FROM
"dc_busi_real_weather_hours"
WHERE
city = '浑南区'
AND reporttime BETWEEN to_timestamp( #{beginTime}, 'yyyy-MM-dd hh24:mi:ss' )
AND to_timestamp( #{endTime}, 'yyyy-MM-dd hh24:mi:ss' )
GROUP BY
city, thour
ORDER BY
thour ASC
</select>
</mapper>

1
lzbi-module/src/main/resources/mapper/targetFolder/DcBaseAssetTargetMapper.xml

@ -62,6 +62,7 @@
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
ORDER BY COALESCE(updated_time, created_time) DESC
</select>
<select id="selectDcBaseAssetTargetById" parameterType="Long" resultMap="DcBaseAssetTargetResult">

1
lzbi-module/src/main/resources/mapper/targetFolder/DcBaseTargetModelMapper.xml

@ -36,6 +36,7 @@
<if test="targetModelField != null and targetModelField != ''"> and target_model_field = #{targetModelField}</if>
<if test="targetModelLevel != null "> and target_model_level = #{targetModelLevel}</if>
</where>
ORDER BY COALESCE(updated_time, created_time) DESC
</select>
<select id="selectDcBaseTargetModelById" parameterType="Long" resultMap="DcBaseTargetModelResult">

Loading…
Cancel
Save