|
@@ -6,10 +6,16 @@ import com.bz.smart_city.commom.model.Pagination;
|
|
import com.bz.smart_city.commom.util.ExcelUtil;
|
|
import com.bz.smart_city.commom.util.ExcelUtil;
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
import com.bz.smart_city.dao.DeviceCommandTaskMapper;
|
|
import com.bz.smart_city.dao.DeviceCommandTaskMapper;
|
|
|
|
+import com.bz.smart_city.dao.ImportMapper;
|
|
import com.bz.smart_city.dto.*;
|
|
import com.bz.smart_city.dto.*;
|
|
import com.bz.smart_city.entity.Device;
|
|
import com.bz.smart_city.entity.Device;
|
|
import com.bz.smart_city.entity.DeviceValveRecord;
|
|
import com.bz.smart_city.entity.DeviceValveRecord;
|
|
|
|
+import com.bz.smart_city.entity.Import;
|
|
|
|
+import com.bz.smart_city.excel.HandleExcelService;
|
|
|
|
+import com.bz.smart_city.excel.ResolverExcelTemplate;
|
|
import com.bz.smart_city.excel.download.template.CommandDownloadExcelTemplate;
|
|
import com.bz.smart_city.excel.download.template.CommandDownloadExcelTemplate;
|
|
|
|
+import com.bz.smart_city.excel.resolver.CommandResolverExcelService;
|
|
|
|
+import com.bz.smart_city.rabbitmq.model.RabbitCommandParamData;
|
|
import com.bz.smart_city.service.DeviceCommandService;
|
|
import com.bz.smart_city.service.DeviceCommandService;
|
|
import com.bz.smart_city.service.DeviceValveRecordService;
|
|
import com.bz.smart_city.service.DeviceValveRecordService;
|
|
import com.bz.smart_city.service.udip.EasylinkinUtils;
|
|
import com.bz.smart_city.service.udip.EasylinkinUtils;
|
|
@@ -45,6 +51,8 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
private DeviceCommandMapper deviceCommandMapper;
|
|
private DeviceCommandMapper deviceCommandMapper;
|
|
@Resource
|
|
@Resource
|
|
private DeviceCommandTaskMapper deviceCommandTaskMapper;
|
|
private DeviceCommandTaskMapper deviceCommandTaskMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ImportMapper importMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private GdAgentUtils gdAgentUtils;
|
|
private GdAgentUtils gdAgentUtils;
|
|
@@ -59,6 +67,11 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
@Autowired
|
|
@Autowired
|
|
private DeviceValveRecordService deviceValveRecordService;
|
|
private DeviceValveRecordService deviceValveRecordService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommandResolverExcelService commandResolverExcelService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private HandleExcelService handleExcelService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public int insertSelective(DeviceCommand record) {
|
|
public int insertSelective(DeviceCommand record) {
|
|
return deviceCommandMapper.insertSelective(record);
|
|
return deviceCommandMapper.insertSelective(record);
|
|
@@ -78,22 +91,27 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
public Pagination<DeviceCommandDto> getTaskPage(String deviceNo, String name, Integer commandType, Integer commandStatus, int pageNum, int pageSize) {
|
|
public Pagination<DeviceCommandDto> getTaskPage(String deviceNo, String name, Integer commandType, Integer commandStatus, int pageNum, int pageSize) {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
- List<DeviceCommandDto> list = deviceCommandTaskMapper.getList(loginUser.getSiteId(),deviceNo,name,commandType,commandStatus);
|
|
|
|
|
|
+ List<DeviceCommandDto> list = deviceCommandTaskMapper.getList(loginUser.getSiteId(),UserUtil.getCustomerIds(),deviceNo,name,commandType,commandStatus);
|
|
return new Pagination<>(list);
|
|
return new Pagination<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Pagination<DeviceCommandDto> getPage(Long deviceId, Integer startDate, Integer endDate, int pageNum, int pageSize) {
|
|
public Pagination<DeviceCommandDto> getPage(Long deviceId, Integer startDate, Integer endDate, int pageNum, int pageSize) {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
|
+
|
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
|
+ LocalDateTime startLocalDate = LocalDateTime.parse(startDate+"000000",df);
|
|
|
|
+ LocalDateTime endLocalDate = LocalDateTime.parse(endDate+"235959",df);
|
|
|
|
+
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
- List<DeviceCommandDto> list = deviceCommandMapper.getList(loginUser.getSiteId(),deviceId);
|
|
|
|
|
|
+ List<DeviceCommandDto> list = deviceCommandMapper.getList(loginUser.getSiteId(),startLocalDate,endLocalDate,deviceId);
|
|
return new Pagination<>(list);
|
|
return new Pagination<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void getExcel(String deviceNo, String name, Integer commandType, Integer commandStatus, HttpServletResponse httpServletResponse) {
|
|
public void getExcel(String deviceNo, String name, Integer commandType, Integer commandStatus, HttpServletResponse httpServletResponse) {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
- List<DeviceCommandDto> list = deviceCommandTaskMapper.getList(loginUser.getSiteId(),deviceNo,name,commandType,commandStatus);
|
|
|
|
|
|
+ List<DeviceCommandDto> list = deviceCommandTaskMapper.getList(loginUser.getSiteId(), UserUtil.getCustomerIds(), deviceNo,name,commandType,commandStatus);
|
|
|
|
|
|
String title = "批量指令下发";
|
|
String title = "批量指令下发";
|
|
String[] rowsName = new String[]{"序号", "设备编号", "设备型号", "任务名称", "指令类型", "指令状态", "下发时间", "完成时间"};
|
|
String[] rowsName = new String[]{"序号", "设备编号", "设备型号", "任务名称", "指令类型", "指令状态", "下发时间", "完成时间"};
|
|
@@ -123,10 +141,9 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
|
|
|
|
private String getCommandStatusName(Integer commandStatus) {
|
|
private String getCommandStatusName(Integer commandStatus) {
|
|
if(commandStatus==0) return "发送";
|
|
if(commandStatus==0) return "发送";
|
|
- if(commandStatus==1) return "已送达";
|
|
|
|
- if(commandStatus==2) return "超时";
|
|
|
|
- if(commandStatus==3) return "执行成功";
|
|
|
|
- if(commandStatus==4) return "执行失败";
|
|
|
|
|
|
+ if(commandStatus==1) return "超时";
|
|
|
|
+ if(commandStatus==2) return "执行成功";
|
|
|
|
+ if(commandStatus==3) return "执行失败";
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,7 +154,12 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Integer executeValveCommand(Device device, DeviceTypeDto deviceTypeDto, ValveCommandRequestDTO valveCommandRequest){
|
|
|
|
|
|
+ public Integer countByDeviceId(Long deviceId) {
|
|
|
|
+ return deviceCommandMapper.countByDeviceId(deviceId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Integer executeValveCommand(Device device, DeviceTypeDto deviceTypeDto, ValveCommandRequestDTO valveCommandRequest,String username){
|
|
log.info("begin executeValveCommand");
|
|
log.info("begin executeValveCommand");
|
|
String commandId = null;
|
|
String commandId = null;
|
|
Integer sendValveStatus = Integer.valueOf(valveCommandRequest.getValveStatus());
|
|
Integer sendValveStatus = Integer.valueOf(valveCommandRequest.getValveStatus());
|
|
@@ -198,23 +220,28 @@ public class DeviceCommandServiceImpl implements DeviceCommandService {
|
|
DeviceCommand deviceCommand = new DeviceCommand();
|
|
DeviceCommand deviceCommand = new DeviceCommand();
|
|
deviceCommand.setSiteId(device.getSiteId());
|
|
deviceCommand.setSiteId(device.getSiteId());
|
|
deviceCommand.setDeviceId(device.getId());
|
|
deviceCommand.setDeviceId(device.getId());
|
|
- deviceCommand.setCommandType(sendValveStatus);
|
|
|
|
- deviceCommand.setCommandStatus(executeResult?0:4);
|
|
|
|
- deviceCommand.setOperationType(1);
|
|
|
|
|
|
+ deviceCommand.setCommandType(Integer.valueOf(valveCommandRequest.getValveStatus()));
|
|
|
|
+ deviceCommand.setCommandStatus(executeResult?0:3);
|
|
|
|
+ deviceCommand.setOperationType(valveCommandRequest.getOperationType());
|
|
deviceCommand.setCommandId(commandId);
|
|
deviceCommand.setCommandId(commandId);
|
|
deviceCommand.setIssueDate(LocalDateTime.now());
|
|
deviceCommand.setIssueDate(LocalDateTime.now());
|
|
- deviceCommand.setPlatform(1);
|
|
|
|
|
|
+ deviceCommand.setPlatform(valveCommandRequest.getPlatform());
|
|
deviceCommand.setStatus(1);
|
|
deviceCommand.setStatus(1);
|
|
deviceCommand.setDateCreate(LocalDateTime.now());
|
|
deviceCommand.setDateCreate(LocalDateTime.now());
|
|
deviceCommand.setDateUpdate(LocalDateTime.now());
|
|
deviceCommand.setDateUpdate(LocalDateTime.now());
|
|
- deviceCommand.setCreateBy("");
|
|
|
|
- deviceCommand.setUpdateBy("");
|
|
|
|
|
|
+ deviceCommand.setCreateBy(username);
|
|
|
|
+ deviceCommand.setUpdateBy(username);
|
|
deviceCommandMapper.insertSelective(deviceCommand);
|
|
deviceCommandMapper.insertSelective(deviceCommand);
|
|
|
|
|
|
log.info("end executeValveCommand");
|
|
log.info("end executeValveCommand");
|
|
return deviceCommand.getId();
|
|
return deviceCommand.getId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void executeRabbitCommand(RabbitCommandParamData data) {
|
|
|
|
|
|
-
|
|
|
|
|
|
+ Import record = importMapper.findByObjId(data.getRecordId());
|
|
|
|
+ ResolverExcelTemplate template = new ResolverExcelTemplate(commandResolverExcelService,handleExcelService);
|
|
|
|
+ template.resolver(null,null,record,data,"批量指令下发-指令导入");
|
|
|
|
+ }
|
|
}
|
|
}
|