1.下载文件优化
2.设备接入调整
This commit is contained in:
@@ -14,6 +14,7 @@ import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.AppUserFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
@@ -112,6 +113,7 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String version = csTopicService.getVersion(item.getNdid());
|
||||
if (!Objects.isNull(version)){
|
||||
csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -131,6 +133,7 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
//这边可能存在装置已经掉线,但是客户端仍然在线的情况
|
||||
if (mqttClient) {
|
||||
csDeviceService.devAccessAskTemplate(nDid,version,1);
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
Object object = redisUtil.getObjectByKey("online" + nDid);
|
||||
@@ -169,11 +172,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
//判断客户端
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (mqttClient) {
|
||||
csDeviceService.devAccessAskTemplate(nDid,version,attemptCount++);
|
||||
csDeviceService.devAccessAskTemplate(nDid,version,1);
|
||||
Integer status = csEquipmentDeliveryService.queryEquipmentBynDid(nDid).getRunStatus();
|
||||
if (Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
||||
logDto.setResult(1);
|
||||
scheduler.shutdown();
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||
return;
|
||||
} else {
|
||||
logDto.setResult(0);
|
||||
@@ -203,7 +207,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
//掉线通知
|
||||
private NoticeUserDto sendOffLine(String nDid) {
|
||||
NoticeUserDto dto = new NoticeUserDto();
|
||||
// NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
dto.setTitle("设备离线");
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||
@@ -213,16 +216,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "离线");
|
||||
dto.setContent(content);
|
||||
dto.setPushClientId(getEventUser(po.getId(),true));
|
||||
// payload.setType(3);
|
||||
// payload.setPath("/pages/message/message?type="+payload.getType());
|
||||
// dto.setPayload(payload);
|
||||
return dto;
|
||||
}
|
||||
|
||||
//重连失败通知
|
||||
private NoticeUserDto sendConnectFail(String nDid) {
|
||||
NoticeUserDto dto = new NoticeUserDto();
|
||||
// NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
dto.setTitle("设备接入失败");
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||
@@ -232,9 +231,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "多次接入失败");
|
||||
dto.setContent(content);
|
||||
dto.setPushClientId(getEventUser(po.getId(),false));
|
||||
// payload.setType(3);
|
||||
// payload.setPath("/pages/message/message?type="+payload.getType());
|
||||
// dto.setPayload(payload);
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
||||
Object object3 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(name));
|
||||
if (!Objects.isNull(object3)) {
|
||||
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object3), FileStreamDto.class);
|
||||
String json = "{allStep:"+dto.getTotal()+",nowStep:"+ (CollectionUtil.isEmpty(dto.getList())?0:dto.getList().size())+"}";
|
||||
String json = "{fileName:"+name+",allStep:"+dto.getTotal()+",nowStep:"+ (CollectionUtil.isEmpty(dto.getList())?0:dto.getList().size())+"}";
|
||||
publisher.send("/Web/Progress/" + nDid, new Gson().toJson(json), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
int times = bytes.length / cap + 1;
|
||||
for (int i = 1; i <= times; i++) {
|
||||
//发送数据给前端
|
||||
String json = "{allStep:"+times+",nowStep:"+i+"}";
|
||||
String json = "{fileName:"+file.getOriginalFilename()+",allStep:"+times+",nowStep:"+i+"}";
|
||||
publisher.send("/Web/Progress/" + id, new Gson().toJson(json), 1, false);
|
||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||
byte[] lsBytes;
|
||||
@@ -200,7 +200,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
}
|
||||
} else {
|
||||
String json = "{allStep:\""+1+"\",nowStep:"+1+"}";
|
||||
String json = "{fileName:"+file.getOriginalFilename()+",allStep:\""+1+"\",nowStep:"+1+"}";
|
||||
publisher.send("/Web/Progress", new Gson().toJson(json), 1, false);
|
||||
ReqAndResDto.Req req = getPojo(1,path,file,length,bytes,0,hexString);
|
||||
publisher.send("/Pfm/DevFileCmd/" + version + "/" + id, new Gson().toJson(req), 1, false);
|
||||
|
||||
@@ -222,16 +222,34 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setClDid(0);
|
||||
if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){
|
||||
po.setLineId(devAccessParam.getNDid() + "1");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 2)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 1)&&Objects.equals(it.getType(), 2)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "1");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "1");
|
||||
po.setClDid(1);
|
||||
} else if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){
|
||||
po.setLineId(devAccessParam.getNDid() + "2");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 2)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 2)&&Objects.equals(it.getType(), 2)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "2");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "2");
|
||||
po.setClDid(2);
|
||||
} else {
|
||||
po.setLineId(devAccessParam.getNDid() + "0");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 1)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 0)&&Objects.equals(it.getType(), 0)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "0");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "0");
|
||||
}
|
||||
@@ -538,6 +556,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setUpdateTime(LocalDateTime.now());
|
||||
csDevModelRelationService.addRelation(po);
|
||||
}
|
||||
//fixme 修改监测点使用的模板和数据集
|
||||
|
||||
//发起接入
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_5.getCode()));
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false);
|
||||
|
||||
Reference in New Issue
Block a user