bug调整

This commit is contained in:
xy
2024-10-30 16:09:20 +08:00
parent 014370062a
commit c325301a8f
7 changed files with 74 additions and 75 deletions

View File

@@ -1,7 +1,6 @@
package com.njcn.csdevice.controller.equipment;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
@@ -81,18 +80,21 @@ public class DeviceFtpController extends BaseController {
})
public HttpResult<String> downloadFile(@RequestParam("nDid") String nDid, @RequestParam("name") String name, @RequestParam("size") Integer size, @RequestParam("fileCheck") String fileCheck){
String methodDescribe = getMethodDescribe("downloadFile");
String result = deviceFtpService.downloadFile(nDid,name,size,fileCheck);
redisUtil.delete("downloadFilePath:"+name);
redisUtil.delete("fileCheck"+name);
redisUtil.delete("fileDowning:"+nDid);
if (Objects.isNull(result)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
} else {
int step = (int) Math.ceil((double) size / 51200);
String json = "{fileName:"+name+",allStep:"+ step +",nowStep:"+ step +"}";
publisher.send("/Web/Progress/" + nDid, new Gson().toJson(json), 1, false);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
deviceFtpService.downloadFile(nDid,name,size,fileCheck);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "文件下载中,请稍等");
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDownloadFilePath")
@ApiOperation("获取文件下载路径")
@ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
@ApiImplicitParam(name = "name", value = "文件路径名", required = true)
})
public HttpResult<String> getDownloadFilePath(@RequestParam("nDid") String nDid, @RequestParam("name") String name){
String methodDescribe = getMethodDescribe("getDownloadFilePath");
String result = deviceFtpService.getDownloadFilePath(nDid,name);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)

View File

@@ -10,7 +10,9 @@ public interface DeviceFtpService {
List<MakeUpVo> askDeviceFileOrDir(String nDid, String name, String type);
String downloadFile(String nDid, String name, Integer size, String fileCheck);
void downloadFile(String nDid, String name, Integer size, String fileCheck);
String getDownloadFilePath(String nDid, String name);
boolean createFile(String nDid, String path);

View File

@@ -33,6 +33,7 @@ import com.njcn.csdevice.service.ICsLedgerService;
import com.njcn.csdevice.util.InfluxDbParamUtil;
import com.njcn.csdevice.utils.DataChangeUtil;
import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.constant.HarmonicConstant;
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
@@ -82,49 +83,24 @@ import java.util.stream.Stream;
public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> implements ICsGroupService {
private final ICsDataArrayService csDataArrayService;
private final CsGroArrMapper csGroArrMapper;
private final CsGroupMapper csGroupMapper;
private final CsDataArrayMapper csDataArrayMapper;
private final CommonService commonService;
private final EpdFeignClient epdFeignClient;
private final CsLineFeignClient csLineFeignClient;
private final ICsLedgerService iCsLedgerService;
private final DicDataFeignClient dicDataFeignClient;
private final EquipmentFeignClient equipmentFeignClient;
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
private final EvtDataService evtDataService;
private final DecimalFormat df = new DecimalFormat("#0.00");
private final EleEvtFeignClient eleEvtFeignClient;
private final OverlimitMapper overlimitMapper;
private final CsDataSetMapper csDataSetMapper;
private final EventFeignClient eventFeignClient;
private final InfluxDbParamUtil influxDbParamUtil;
private final Set<String> POWER_LIST = new HashSet<>(Arrays.asList(
"电网有功功率", "电网无功功率", "电网视在功率", "负载有功功率",
"负载无功功率", "负载视在功率", "有功功率", "无功功率",
"视在功率", "基波有功功率", "基波无功功率",
"基波视在功率", "三相总有功功率", "三相总无功功率",
"三相总视在功率","相电压总有效值","线电压总有效值","相电压基波有效值","线电压基波有效值","电压正序分量"
));
@Override
@Transactional(rollbackFor = Exception.class)
public List<CsGroupVO> getGroupData(String dataSet) {
@@ -196,6 +172,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}
if (vo.getAnotherName().contains("A相") || vo.getAnotherName().contains("B相") || vo.getAnotherName().contains("C相")) {
vo.setAnotherName(vo.getAnotherName().substring(0,2));
} else if (vo.getAnotherName().contains("AB") || vo.getAnotherName().contains("BC") || vo.getAnotherName().contains("CA")) {
vo.setAnotherName(vo.getAnotherName().substring(0,2).concat(""));
}
arrayList.add(vo);
}
@@ -349,29 +327,39 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
return commonQueryParam;
}).collect(Collectors.toList());
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
//List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
vo.setStatMethod(temp.getValueType());
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
if (ObjectUtil.isNotNull(epdPqd.getPrimaryFormula()) && !Objects.equals(csDataSet.getDataLevel(), commonStatisticalQueryParam.getDataLevel())) {
Double re;
if ("Primary".equals(csDataSet.getDataLevel())) {
re = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
double re;
if (Objects.equals("Primary",commonStatisticalQueryParam.getDataLevel())) {
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
vo.setUnit(epdPqd.getUnit());
} else {
re = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.secondaryToPrimary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct) / 1000;
vo.setStatisticalData(Double.valueOf(df.format(re)));
vo.setUnit("k" + epdPqd.getUnit());
}
}
vo.setStatisticalData(Double.valueOf(df.format(re)));
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
if (Objects.equals("Primary",csDataSet.getDataLevel())) {
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
re = DataChangeUtil.primaryToSecondary(epdPqd.getPrimaryFormula(), temp.getValue(), pt, ct);
vo.setStatisticalData(Double.valueOf(df.format(re)));
}
} else {
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
}
vo.setUnit(epdPqd.getUnit());
}
vo.setStatisticalIndex(epdPqd.getId());
vo.setUnit(epdPqd.getUnit());
vo.setStatisticalName(epdPqd.getName());
vo.setAnotherName(epdPqd.getShowName());
return vo;
@@ -413,7 +401,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -555,7 +543,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -655,7 +643,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());
@@ -821,9 +809,12 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
}
}
//判断功率是否需要转换
//判断指标是否需要转换
public boolean changePower(String name) {
return POWER_LIST.stream()
if(name.contains("相角")) {
return false;
}
return HarmonicConstant.POWER_LIST.stream()
.anyMatch(name::contains);
}

View File

@@ -14,6 +14,7 @@ import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.time.Instant;
@@ -86,8 +87,8 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
}
@Override
public String downloadFile(String nDid, String name, Integer size, String fileCheck) {
String result = null;
@Async
public void downloadFile(String nDid, String name, Integer size, String fileCheck) {
judgeClientOnline(nDid);
Object task = redisUtil.getObjectByKey("fileDowning:"+nDid);
if (Objects.nonNull(task)) {
@@ -98,25 +99,26 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
throw new BusinessException(AlgorithmResponseEnum.FILE_BUSY);
}
try {
redisUtil.delete("downloadFilePath:"+name);
boolean file = askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
if (!file) {
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete("fileCheck"+name);
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
}
Object object = redisUtil.getObjectByKey("downloadFilePath:"+name);
if (Objects.nonNull(object)) {
result = (String) object;
redisUtil.delete("downloadFilePath:"+name);
redisUtil.delete("fileCheck"+name);
redisUtil.delete("fileDowning:"+nDid);
}
redisUtil.delete("downloadFilePath:"+ nDid + name);
askDeviceDataFeignClient.downloadFile(nDid,name,size,fileCheck).getData();
} catch (Exception e) {
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete("fileCheck"+name);
redisUtil.delete("fileCheck"+nDid+name);
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOADING);
}
}
@Override
public String getDownloadFilePath(String nDid, String name) {
String result = null;
Object object = redisUtil.getObjectByKey("downloadFilePath:" + nDid + name);
if (Objects.nonNull(object)) {
result = (String) object;
redisUtil.delete("downloadFilePath:" + nDid + name);
}
redisUtil.delete("fileCheck"+nDid+name);
redisUtil.delete("fileDowning:"+nDid);
redisUtil.delete(AppRedisKey.FILE_PART.concat(name));
return result;
}

View File

@@ -448,7 +448,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
ThdDataVO vo = new ThdDataVO();
vo.setLineId(temp.getLineId());
vo.setPhase(temp.getPhaseType());
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
vo.setPosition(position);
vo.setTime(temp.getTime());