This commit is contained in:
2023-08-30 20:14:53 +08:00
parent 71c46b7bd9
commit 56e7cd37fd
4 changed files with 107 additions and 106 deletions

View File

@@ -15,23 +15,23 @@ import lombok.Data;
public class AskDataDto {
@ParamName("Cldid")
private Integer clDid;
private Integer Cldid;
@ParamName("DataType")
private Integer dataType;
private Integer DataType;
@ParamName("DataAttr")
private Integer dataAttr;
private Integer DataAttr;
@ParamName("Operate")
private Integer operate;
private Integer Operate;
@ParamName("StartTime")
private Integer startTime;
private Integer StartTime;
@ParamName("EndTime")
private Integer endTime;
private Integer EndTime;
@ParamName("DataArray")
private DataArrayDto dataArray;
private DataArrayDto DataArray;
}

View File

@@ -1,47 +1,47 @@
package com.njcn.access.runner;
import com.njcn.access.service.ICsEquipmentDeliveryService;
import com.njcn.access.service.ICsTopicService;
import com.njcn.access.service.impl.CsDeviceServiceImpl;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/8/28 13:57
*/
@Component
@Slf4j
public class AccessApplicationRunner implements ApplicationRunner {
@Resource
private CsDeviceServiceImpl csDeviceService;
@Resource
private ICsTopicService csTopicService;
@Resource
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
@Override
public void run(ApplicationArguments args){
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
list.forEach(item->{
String version = csTopicService.getVersion(item.getNdid());
if (!Objects.isNull(version)){
csDeviceService.devAccess(item.getNdid(),version);
}
});
}
}
//package com.njcn.access.runner;
//
//import com.njcn.access.service.ICsEquipmentDeliveryService;
//import com.njcn.access.service.ICsTopicService;
//import com.njcn.access.service.impl.CsDeviceServiceImpl;
//import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入
// *
// * @author xuyang
// * @version 1.0.0
// * @createTime 2023/8/28 13:57
// */
//@Component
//@Slf4j
//public class AccessApplicationRunner implements ApplicationRunner {
//
// @Resource
// private CsDeviceServiceImpl csDeviceService;
//
// @Resource
// private ICsTopicService csTopicService;
//
// @Resource
// private ICsEquipmentDeliveryService csEquipmentDeliveryService;
//
// @Override
// public void run(ApplicationArguments args){
// List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
// list.forEach(item->{
// String version = csTopicService.getVersion(item.getNdid());
// if (!Objects.isNull(version)){
// csDeviceService.devAccess(item.getNdid(),version);
// }
// });
// }
//
//}

View File

@@ -1,50 +1,50 @@
package com.njcn.access.runner;
import com.njcn.access.service.ICsEquipmentDeliveryService;
import com.njcn.access.service.ICsTopicService;
import com.njcn.access.service.impl.CsDeviceServiceImpl;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* 类的介绍:防止设备掉线 系统未能调整,做一个定时任务,每天凌晨将所有设备重新接入
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/8/28 14:21
*/
@Component
@Slf4j
public class AccessScheduledTask {
@Resource
private CsDeviceServiceImpl csDeviceService;
@Resource
private ICsTopicService csTopicService;
@Resource
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
/**
* {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
*/
@Scheduled(cron = "0 0 0 * * ?")
public void executeTask() {
log.info("每日凌晨定时任务执行");
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
list.forEach(item->{
String version = csTopicService.getVersion(item.getNdid());
if (!Objects.isNull(version)){
csDeviceService.devAccess(item.getNdid(),version);
}
});
}
}
//package com.njcn.access.runner;
//
//import com.njcn.access.service.ICsEquipmentDeliveryService;
//import com.njcn.access.service.ICsTopicService;
//import com.njcn.access.service.impl.CsDeviceServiceImpl;
//import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * 类的介绍:防止设备掉线 系统未能调整,做一个定时任务,每天凌晨将所有设备重新接入
// *
// * @author xuyang
// * @version 1.0.0
// * @createTime 2023/8/28 14:21
// */
//@Component
//@Slf4j
//public class AccessScheduledTask {
//
// @Resource
// private CsDeviceServiceImpl csDeviceService;
//
// @Resource
// private ICsTopicService csTopicService;
//
// @Resource
// private ICsEquipmentDeliveryService csEquipmentDeliveryService;
//
// /**
// * {秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
// */
// @Scheduled(cron = "0 0 0 * * ?")
// public void executeTask() {
// log.info("每日凌晨定时任务执行");
// List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
// list.forEach(item->{
// String version = csTopicService.getVersion(item.getNdid());
// if (!Objects.isNull(version)){
// csDeviceService.devAccess(item.getNdid(),version);
// }
// });
// }
//
//}

View File

@@ -413,15 +413,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_6.getCode()));
reqAndResParam.setExpire(-1);
AskDataDto askDataDto = new AskDataDto();
askDataDto.setClDid(-1);
askDataDto.setDataAttr(0);
askDataDto.setOperate(1);
askDataDto.setStartTime(-1);
askDataDto.setEndTime(-1);
if (Objects.equals(dataType,AccessEnum.SOFT_INFO.getCode())){
reqAndResParam.setDid(did);
askDataDto.setCldid(0);
reqAndResParam.setDid(2);
askDataDto.setDataType(1);
} else if (Objects.equals(dataType,AccessEnum.L_DEV_INFO.getCode())){
askDataDto.setCldid(0);
reqAndResParam.setDid(did);
askDataDto.setDataType(2);
}