装置文件夹新建、删除
This commit is contained in:
@@ -24,4 +24,11 @@ public interface AskDeviceDataFeignClient {
|
||||
|
||||
@PostMapping("/rebootDevice")
|
||||
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());
|
||||
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);
|
||||
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("uploading","uploading",20L);
|
||||
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:
|
||||
log.info("装置根目录应答");
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
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) {
|
||||
try {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 30; i++) {
|
||||
if (result) {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(10000);
|
||||
} else {
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.zlevent.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
@@ -56,13 +57,21 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
try {
|
||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||
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();
|
||||
csEvent.setId(id);
|
||||
csEvent.setDeviceId(po.getId());
|
||||
csEvent.setProcess(po.getProcess());
|
||||
csEvent.setCode(item.getCode());
|
||||
eventTime = eventService.timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
||||
csEvent.setStartTime(eventTime);
|
||||
tag = item.getName();
|
||||
csEvent.setTag(tag);
|
||||
@@ -72,9 +81,9 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
csEvent.setCode(item.getCode());
|
||||
list1.add(csEvent);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list1)){
|
||||
csEventService.saveBatch(list1);
|
||||
}
|
||||
//推送事件逻辑处理 && cs_event_user入库 && 修改字典中告警事件的编码
|
||||
for (AppEventMessage.DataArray item : dataArray) {
|
||||
if (Objects.isNull(item.getCode())){
|
||||
@@ -89,6 +98,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
epdFeignClient.update(updateParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CsEventLogs csEventLogs = new CsEventLogs();
|
||||
csEventLogs.setDeviceId(po.getId());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.zlevent.service.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
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.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
@@ -92,6 +93,16 @@ public class EventServiceImpl implements IEventService {
|
||||
//处理事件数据
|
||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||
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();
|
||||
//事件入库
|
||||
CsEventPO csEvent = new CsEventPO();
|
||||
@@ -162,18 +173,19 @@ public class EventServiceImpl implements IEventService {
|
||||
csEventLogs.setTime(LocalDateTime.now());
|
||||
csEventLogsService.save(csEventLogs);
|
||||
}
|
||||
}
|
||||
//cs_event入库
|
||||
if (CollectionUtil.isNotEmpty(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入库
|
||||
if (CollectionUtil.isNotEmpty(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) {
|
||||
CsEventLogs csEventLogs = new CsEventLogs();
|
||||
csEventLogs.setLineId(lineId);
|
||||
|
||||
@@ -258,11 +258,8 @@ public class FileServiceImpl implements IFileService {
|
||||
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
||||
csEventLogs.setIsAll(0);
|
||||
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), dto);
|
||||
long time1 = System.currentTimeMillis();
|
||||
//将数据写入临时文件
|
||||
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());
|
||||
if (Objects.isNull(object2)) {
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()), null, 10L);
|
||||
|
||||
@@ -40,13 +40,10 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||
|
||||
@Resource
|
||||
private EventFeignClient eventFeignClient;
|
||||
|
||||
@Resource
|
||||
private WaveFeignClient waveFeignClient;
|
||||
@Resource
|
||||
@@ -70,7 +67,6 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
||||
break;
|
||||
case 32:
|
||||
log.info("分发至便携式基础数据处理");
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user