暂降模块代码合并

终端运行管理接口调整
This commit is contained in:
2022-09-15 10:56:22 +08:00
parent 07775513a0
commit e3d77c23a8
92 changed files with 17262 additions and 500 deletions

View File

@@ -1,11 +1,14 @@
package com.njcn.device.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.format.DatePrinter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pojo.param.DeviceInfoParam;
import com.njcn.device.pojo.param.RunManageParam;
import com.njcn.device.pojo.param.TerminalLedgerParam;
@@ -23,6 +26,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
@@ -45,9 +51,9 @@ public class RunManageController extends BaseController {
@PostMapping("/getLineLedger")
@ApiOperation("监测点台账信息")
@ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true)
public HttpResult<Page<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) {
public HttpResult<List<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) {
String methodDescribe = getMethodDescribe("getLineLedger");
Page<RunManageVO> res = runManageService.getLineLedger(runManageParam);
List<RunManageVO> res = runManageService.getLineLedger(runManageParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}

View File

@@ -25,7 +25,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
* @author cdf
* @date 2022/5/11
*/
//TODO
List<Device> getDeviceList(@Param("list") List<String> list);
/**
@@ -35,7 +34,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
* @param runFlag 状态
* @return 结果
*/
Page<RunManageVO> getRunManageList(@Param("page") Page<RunManageVO> page, @Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag);
List<RunManageVO> getRunManageList(@Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag);
/**
* 获取监测点台账信息

View File

@@ -21,7 +21,7 @@ public interface RunManageService {
* @param runManageParam 参数
* @return 结果
*/
Page<RunManageVO> getLineLedger(RunManageParam runManageParam);
List<RunManageVO> getLineLedger(RunManageParam runManageParam);
/**
* 获取终端台账信息

View File

@@ -3,6 +3,7 @@ package com.njcn.device.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.dto.SimpleDTO;
@@ -43,6 +44,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -77,14 +79,13 @@ public class RunManageServiceImpl implements RunManageService {
private final InfluxDbUtils influxDbUtils;
@Override
public Page<RunManageVO> getLineLedger(RunManageParam runManageParam) {
public List<RunManageVO> getLineLedger(RunManageParam runManageParam) {
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
List<String> lineIndexes = generalDeviceDTOList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(lineIndexes)) {
Page<RunManageVO> page = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam));
return deviceMapper.getRunManageList(page,lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
return deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
}else {
throw new BusinessException(CommonResponseEnum.FAIL);
}
@@ -99,14 +100,16 @@ public class RunManageServiceImpl implements RunManageService {
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list->list.getDeviceIndexes().stream()).collect(Collectors.toList());
DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
runManageParam.setSearchBeginTime(DateUtil.beginOfMonth(new Date()).toString(bf));
runManageParam.setSearchEndTime(DateUtil.endOfMonth(new Date()).toString(bf));
if(CollectionUtil.isNotEmpty(devIndexes)){
runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes);
String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id";
//sql语句
String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE+")";
String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE;
QueryResult queryResult = influxDbUtils.query(sql);
InfluxDBResultMapper inCn = new InfluxDBResultMapper();
@@ -117,38 +120,11 @@ public class RunManageServiceImpl implements RunManageService {
return runManageDevList;
}
/* private Float getCondition(String startTime, String endTime, String lineId) {
final Float[] floatList = {0.0f};
QueryResult queryResult;
if (!lineId.isEmpty()) {
//组装sql语句
String stringBuilder = "time >= '" + startTime + "' and " + "time <= '" + endTime + "' and (" + DEV_INDEX + " ='" + lineId + "') ";
//sql语句
String sql = "SELECT SUM(" + ONLINE_MIN + ")/(SUM(" + OFFLINE_MIN + ")+SUM(" + ONLINE_MIN + ")) AS onlineRate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE;
queryResult = influxDbUtils.query(sql);
//处理结果集
List<org.influxdb.dto.QueryResult.Series> list = queryResult.getResults().get(0).getSeries();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(po -> {
List<List<Object>> valueList = po.getValues();
if (!CollectionUtils.isEmpty(valueList)) {
for (List<Object> value : valueList) {
//数据完整性 保留四位小数
floatList[0] = value.get(1) == null ? null : BigDecimal.valueOf(Float.parseFloat(value.get(1).toString())).setScale(4, BigDecimal.ROUND_HALF_UP).floatValue();
}
}
});
}
return floatList[0];
}
return floatList[0];
}*/
@Override
public List<TerminalLedgerVO> getTerminalLedger(DeviceInfoParam deviceInfoParam) {
//定义待返回终端信息
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfoAsDept(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
List<TerminalLedgerVO> terminalLedgerVOList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(generalDeviceDTOList)) {