装置文件夹新建、删除
This commit is contained in:
@@ -24,4 +24,11 @@ public interface AskDeviceDataFeignClient {
|
|||||||
|
|
||||||
@PostMapping("/rebootDevice")
|
@PostMapping("/rebootDevice")
|
||||||
HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid);
|
HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid);
|
||||||
|
|
||||||
|
@PostMapping("/createFolder")
|
||||||
|
HttpResult<String> createFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path);
|
||||||
|
|
||||||
|
@PostMapping("/deleteFolder")
|
||||||
|
HttpResult<String> deleteFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,18 @@ public class AskDeviceDataClientFallbackFactory implements FallbackFactory<AskDe
|
|||||||
log.error("{}异常,降级处理,异常为:{}","设备重启",cause.toString());
|
log.error("{}异常,降级处理,异常为:{}","设备重启",cause.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> createFolder(String nDid, String path) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","创建文件夹",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> deleteFolder(String nDid, String path) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","删除文件夹",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,4 +82,32 @@ public class AskDeviceDataController extends BaseController {
|
|||||||
askDeviceDataService.rebootDevice(nDid);
|
askDeviceDataService.rebootDevice(nDid);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/createFolder")
|
||||||
|
@ApiOperation("创建文件")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
|
||||||
|
@ApiImplicitParam(name = "path", value = "文件路径", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<String> createFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path){
|
||||||
|
String methodDescribe = getMethodDescribe("createFolder");
|
||||||
|
askDeviceDataService.createFolder(nDid,path);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/deleteFolder")
|
||||||
|
@ApiOperation("删除文件")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
|
||||||
|
@ApiImplicitParam(name = "path", value = "文件路径", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<String> deleteFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path){
|
||||||
|
String methodDescribe = getMethodDescribe("deleteFolder");
|
||||||
|
askDeviceDataService.deleteFolder(nDid,path);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -622,6 +622,14 @@ public class MqttMessageHandler {
|
|||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.UPLOAD,fileRedisDto,10L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.UPLOAD,fileRedisDto,10L);
|
||||||
redisUtil.saveByKeyWithExpire("uploading","uploading",20L);
|
redisUtil.saveByKeyWithExpire("uploading","uploading",20L);
|
||||||
break;
|
break;
|
||||||
|
case 4660:
|
||||||
|
log.info("设备目录/文件删除应答");
|
||||||
|
redisUtil.saveByKeyWithExpire( "deleteDir"+ nDid,fileDto.getCode(),10L);
|
||||||
|
break;
|
||||||
|
case 4661:
|
||||||
|
log.info("设备目录创建应答");
|
||||||
|
redisUtil.saveByKeyWithExpire( "createDir"+ nDid,fileDto.getCode(),10L);
|
||||||
|
break;
|
||||||
case 4662:
|
case 4662:
|
||||||
log.info("装置根目录应答");
|
log.info("装置根目录应答");
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.DEVICE_ROOT_PATH + nDid,fileDto.getMsg().getName(),10L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.DEVICE_ROOT_PATH + nDid,fileDto.getMsg().getName(),10L);
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ public interface AskDeviceDataService {
|
|||||||
boolean downloadFile(String nDid, String name, Integer size, String fileCheck);
|
boolean downloadFile(String nDid, String name, Integer size, String fileCheck);
|
||||||
|
|
||||||
void rebootDevice(String nDid);
|
void rebootDevice(String nDid);
|
||||||
|
|
||||||
|
void createFolder(String nDid, String path);
|
||||||
|
|
||||||
|
void deleteFolder(String nDid, String path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,52 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
|||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createFolder(String nDid, String path) {
|
||||||
|
Object object = getDeviceMid(nDid);
|
||||||
|
if (!Objects.isNull(object)) {
|
||||||
|
mid = (Integer) object;
|
||||||
|
}
|
||||||
|
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||||
|
reqAndResParam.setMid(mid);
|
||||||
|
reqAndResParam.setDid(0);
|
||||||
|
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
|
reqAndResParam.setExpire(-1);
|
||||||
|
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_12.getCode()));
|
||||||
|
String json = String.format("{\"Name\":\"%s\"}", path);
|
||||||
|
JSONObject jsonObject = JSONObject.fromObject(json);
|
||||||
|
reqAndResParam.setMsg(jsonObject);
|
||||||
|
publisher.send("/Pfm/DevFileCmd/V1/" + nDid, new Gson().toJson(reqAndResParam), 1, false);
|
||||||
|
mid = mid + 1;
|
||||||
|
if (mid > 10000) {
|
||||||
|
mid = 1;
|
||||||
|
}
|
||||||
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFolder(String nDid, String path) {
|
||||||
|
Object object = getDeviceMid(nDid);
|
||||||
|
if (!Objects.isNull(object)) {
|
||||||
|
mid = (Integer) object;
|
||||||
|
}
|
||||||
|
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||||
|
reqAndResParam.setMid(mid);
|
||||||
|
reqAndResParam.setDid(0);
|
||||||
|
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
|
reqAndResParam.setExpire(-1);
|
||||||
|
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_11.getCode()));
|
||||||
|
String json = String.format("{\"Name\":\"%s\"}", path);
|
||||||
|
JSONObject jsonObject = JSONObject.fromObject(json);
|
||||||
|
reqAndResParam.setMsg(jsonObject);
|
||||||
|
publisher.send("/Pfm/DevFileCmd/V1/" + nDid, new Gson().toJson(reqAndResParam), 1, false);
|
||||||
|
mid = mid + 1;
|
||||||
|
if (mid > 10000) {
|
||||||
|
mid = 1;
|
||||||
|
}
|
||||||
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||||
|
}
|
||||||
|
|
||||||
public Object getDeviceMid(String nDid) {
|
public Object getDeviceMid(String nDid) {
|
||||||
return redisUtil.getObjectByKey(AppRedisKey.DEVICE_MID + nDid);
|
return redisUtil.getObjectByKey(AppRedisKey.DEVICE_MID + nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,9 +268,9 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
*/
|
*/
|
||||||
public void sendNextStep(DeviceLogDTO logDto, String path, MultipartFile file, int length, byte[] bytes, Integer offset, String version, String id, int mid, String fileCheck, boolean result) {
|
public void sendNextStep(DeviceLogDTO logDto, String path, MultipartFile file, int length, byte[] bytes, Integer offset, String version, String id, int mid, String fileCheck, boolean result) {
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
if (result) {
|
if (result) {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(10000);
|
||||||
} else {
|
} else {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.zlevent.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
@@ -56,13 +57,21 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
try {
|
try {
|
||||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
|
eventTime = eventService.timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
||||||
|
LambdaQueryWrapper<CsEventPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(CsEventPO::getDeviceId,po.getId())
|
||||||
|
.eq(CsEventPO::getProcess,po.getProcess())
|
||||||
|
.eq(CsEventPO::getCode,item.getCode())
|
||||||
|
.eq(CsEventPO::getStartTime,eventTime)
|
||||||
|
.eq(CsEventPO::getTag,item.getName());
|
||||||
|
List<CsEventPO> list = csEventService.list(wrapper);
|
||||||
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
//事件入库
|
//事件入库
|
||||||
CsEventPO csEvent = new CsEventPO();
|
CsEventPO csEvent = new CsEventPO();
|
||||||
csEvent.setId(id);
|
csEvent.setId(id);
|
||||||
csEvent.setDeviceId(po.getId());
|
csEvent.setDeviceId(po.getId());
|
||||||
csEvent.setProcess(po.getProcess());
|
csEvent.setProcess(po.getProcess());
|
||||||
csEvent.setCode(item.getCode());
|
csEvent.setCode(item.getCode());
|
||||||
eventTime = eventService.timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
|
||||||
csEvent.setStartTime(eventTime);
|
csEvent.setStartTime(eventTime);
|
||||||
tag = item.getName();
|
tag = item.getName();
|
||||||
csEvent.setTag(tag);
|
csEvent.setTag(tag);
|
||||||
@@ -72,9 +81,9 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
csEvent.setCode(item.getCode());
|
csEvent.setCode(item.getCode());
|
||||||
list1.add(csEvent);
|
list1.add(csEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (CollectionUtil.isNotEmpty(list1)){
|
if (CollectionUtil.isNotEmpty(list1)){
|
||||||
csEventService.saveBatch(list1);
|
csEventService.saveBatch(list1);
|
||||||
}
|
|
||||||
//推送事件逻辑处理 && cs_event_user入库 && 修改字典中告警事件的编码
|
//推送事件逻辑处理 && cs_event_user入库 && 修改字典中告警事件的编码
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
if (Objects.isNull(item.getCode())){
|
if (Objects.isNull(item.getCode())){
|
||||||
@@ -89,6 +98,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
epdFeignClient.update(updateParam);
|
epdFeignClient.update(updateParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CsEventLogs csEventLogs = new CsEventLogs();
|
CsEventLogs csEventLogs = new CsEventLogs();
|
||||||
csEventLogs.setDeviceId(po.getId());
|
csEventLogs.setDeviceId(po.getId());
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.zlevent.service.impl;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
@@ -92,6 +93,16 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//处理事件数据
|
//处理事件数据
|
||||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
|
eventTime = timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
||||||
|
//此处做限制,如果已有事件则不在记录通知
|
||||||
|
LambdaQueryWrapper<CsEventPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(CsEventPO::getDeviceId,po.getId())
|
||||||
|
.eq(CsEventPO::getProcess,po.getProcess())
|
||||||
|
.eq(CsEventPO::getCode,item.getCode())
|
||||||
|
.eq(CsEventPO::getStartTime,eventTime)
|
||||||
|
.eq(CsEventPO::getTag,item.getName());
|
||||||
|
List<CsEventPO> list = csEventService.list(wrapper);
|
||||||
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
id = IdUtil.fastSimpleUUID();
|
id = IdUtil.fastSimpleUUID();
|
||||||
//事件入库
|
//事件入库
|
||||||
CsEventPO csEvent = new CsEventPO();
|
CsEventPO csEvent = new CsEventPO();
|
||||||
@@ -162,18 +173,19 @@ public class EventServiceImpl implements IEventService {
|
|||||||
csEventLogs.setTime(LocalDateTime.now());
|
csEventLogs.setTime(LocalDateTime.now());
|
||||||
csEventLogsService.save(csEventLogs);
|
csEventLogsService.save(csEventLogs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//cs_event入库
|
//cs_event入库
|
||||||
if (CollectionUtil.isNotEmpty(list1)){
|
if (CollectionUtil.isNotEmpty(list1)){
|
||||||
csEventService.saveBatch(list1);
|
csEventService.saveBatch(list1);
|
||||||
|
//推送事件逻辑处理 && cs_event_user入库
|
||||||
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
|
sendEventUtils.sendUser(1,item.getType(),po.getId(),item.getName(),eventTime,id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//evt_data入库
|
//evt_data入库
|
||||||
if (CollectionUtil.isNotEmpty(records)) {
|
if (CollectionUtil.isNotEmpty(records)) {
|
||||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
||||||
}
|
}
|
||||||
//推送事件逻辑处理 && cs_event_user入库
|
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
|
||||||
sendEventUtils.sendUser(1,item.getType(),po.getId(),item.getName(),eventTime,id);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CsEventLogs csEventLogs = new CsEventLogs();
|
CsEventLogs csEventLogs = new CsEventLogs();
|
||||||
csEventLogs.setLineId(lineId);
|
csEventLogs.setLineId(lineId);
|
||||||
|
|||||||
@@ -258,11 +258,8 @@ public class FileServiceImpl implements IFileService {
|
|||||||
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
||||||
csEventLogs.setIsAll(0);
|
csEventLogs.setIsAll(0);
|
||||||
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), dto);
|
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), dto);
|
||||||
long time1 = System.currentTimeMillis();
|
|
||||||
//将数据写入临时文件
|
//将数据写入临时文件
|
||||||
appendFile(lsFileName, appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
appendFile(lsFileName, appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
||||||
long time2 = System.currentTimeMillis();
|
|
||||||
System.out.println("time==:" + (time2 - time1));
|
|
||||||
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
||||||
if (Objects.isNull(object2)) {
|
if (Objects.isNull(object2)) {
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()), null, 10L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()), null, 10L);
|
||||||
|
|||||||
@@ -40,13 +40,10 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EventFeignClient eventFeignClient;
|
private EventFeignClient eventFeignClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private WaveFeignClient waveFeignClient;
|
private WaveFeignClient waveFeignClient;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -70,7 +67,6 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
|||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
log.info("分发至便携式基础数据处理");
|
log.info("分发至便携式基础数据处理");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user