|
@@ -30,6 +30,7 @@ import org.jdom.output.Format;
|
|
import org.jdom.output.XMLOutputter;
|
|
import org.jdom.output.XMLOutputter;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -121,6 +122,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|
private ScConfigurationService scConfigurationService;
|
|
private ScConfigurationService scConfigurationService;
|
|
@Autowired
|
|
@Autowired
|
|
private GeneralDownload generalDownload;
|
|
private GeneralDownload generalDownload;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MessageService messageService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int insert(Device device) {
|
|
public int insert(Device device) {
|
|
@@ -173,12 +176,12 @@ public class DeviceServiceImpl implements DeviceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, int pageNum, int pageSize) {
|
|
|
|
|
|
+ public Pagination<DeviceDto> getList(Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer manufacturerId, String equipmentType, String model, Integer isTag, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, String concentratorNo, String collectorNo, Integer channelNumberId, String errorType, Integer customerId, Integer days, Integer startDays, Integer endDays, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, int pageNum, int pageSize) {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
- equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
|
|
|
|
|
|
+ equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, channelNumberId, errorType, customerId,
|
|
days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus,startReading,endReading, sortColumn, sortOrder);
|
|
days, startDays, endDays,deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus,startReading,endReading, sortColumn, sortOrder);
|
|
return new Pagination<>(list);
|
|
return new Pagination<>(list);
|
|
}
|
|
}
|
|
@@ -194,7 +197,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
|
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
- equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
|
|
|
|
|
|
+ equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, null, errorType, customerId,
|
|
days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
|
|
days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
|
|
String title = "设备列表";
|
|
String title = "设备列表";
|
|
|
|
|
|
@@ -306,7 +309,7 @@ public class DeviceServiceImpl implements DeviceService {
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
|
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status, manufacturerId,
|
|
- equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, errorType, customerId,
|
|
|
|
|
|
+ equipmentType, model, isTag, floor, locDesc, province, city, region, community, concentratorNo, collectorNo, null, errorType, customerId,
|
|
days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
|
|
days, startDays, endDays, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
|
|
String title = "设备列表";
|
|
String title = "设备列表";
|
|
//判断是否是水表场景
|
|
//判断是否是水表场景
|
|
@@ -1351,14 +1354,16 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void setValve(Long deviceId, String valve) {
|
|
|
|
|
|
+ public void setValve(Long deviceId, Integer valve) {
|
|
Device device = deviceMapper.findByDeviceId(deviceId);
|
|
Device device = deviceMapper.findByDeviceId(deviceId);
|
|
DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(device.getDeviceType());
|
|
DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(device.getDeviceType());
|
|
WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceId);
|
|
WaterMeterErrorDays waterMeterErrorDays = waterMeterErrorDaysMapper.findByDeviceId(deviceId);
|
|
String sendValveStatus = "0";
|
|
String sendValveStatus = "0";
|
|
|
|
|
|
if (valve != null) {
|
|
if (valve != null) {
|
|
- sendValveStatus = valve;
|
|
|
|
|
|
+ if(valve == 1){
|
|
|
|
+ sendValveStatus = "1";
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
if(waterMeterErrorDays != null){
|
|
if(waterMeterErrorDays != null){
|
|
if (waterMeterErrorDays.getValveButtonStatus() != null) {
|
|
if (waterMeterErrorDays.getValveButtonStatus() != null) {
|
|
@@ -1367,41 +1372,66 @@ public class DeviceServiceImpl implements DeviceService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- //更新按钮阀门状态
|
|
|
|
- WaterMeterErrorDays waterMeterErrorDayUpdate = new WaterMeterErrorDays();
|
|
|
|
- waterMeterErrorDayUpdate.setDeviceId(deviceId);
|
|
|
|
- if (waterMeterErrorDays != null) {
|
|
|
|
-
|
|
|
|
- if (waterMeterErrorDays.getValveButtonStatus() != null) {
|
|
|
|
|
|
|
|
- if(waterMeterErrorDays.getValveButtonStatus()== 1){
|
|
|
|
- waterMeterErrorDayUpdate.setValveButtonStatus(0);
|
|
|
|
|
|
+ //更新按钮阀门状态
|
|
|
|
+ WaterMeterErrorDays waterMeterErrorDayUpdate = new WaterMeterErrorDays();
|
|
|
|
+ waterMeterErrorDayUpdate.setDeviceId(deviceId);
|
|
|
|
+ if (waterMeterErrorDays != null) {
|
|
|
|
+ if (waterMeterErrorDays.getValveButtonStatus() != null) {
|
|
|
|
+ if (valve != null) {
|
|
|
|
+ if(waterMeterErrorDays.getValveButtonStatus()==valve){
|
|
|
|
+ waterMeterErrorDayUpdate.setValveButtonStatus(waterMeterErrorDays.getValveButtonStatus());
|
|
}else {
|
|
}else {
|
|
- waterMeterErrorDayUpdate.setValveButtonStatus(1);
|
|
|
|
|
|
+ waterMeterErrorDayUpdate.setValveButtonStatus(valve==1?1:0);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- waterMeterErrorDayUpdate.setValveButtonStatus(0);
|
|
|
|
|
|
+ waterMeterErrorDayUpdate.setValveButtonStatus(waterMeterErrorDays.getValveButtonStatus()== 1?0:1);
|
|
}
|
|
}
|
|
- waterMeterErrorDaysMapper.updateByPrimaryKeySelective(waterMeterErrorDayUpdate);
|
|
|
|
}else {
|
|
}else {
|
|
waterMeterErrorDayUpdate.setValveButtonStatus(0);
|
|
waterMeterErrorDayUpdate.setValveButtonStatus(0);
|
|
- waterMeterErrorDayUpdate.setStatus(1);
|
|
|
|
- waterMeterErrorDaysMapper.insert(waterMeterErrorDayUpdate);
|
|
|
|
}
|
|
}
|
|
|
|
+ waterMeterErrorDaysMapper.updateByPrimaryKeySelective(waterMeterErrorDayUpdate);
|
|
|
|
+ }else {
|
|
|
|
+ if (valve != null) {
|
|
|
|
+ //waterMeterErrorDayUpdate.setValveButtonStatus(valve==0?1:0);
|
|
|
|
+ waterMeterErrorDayUpdate.setValveButtonStatus(valve==1?1:0);
|
|
|
|
+ }else {
|
|
|
|
+ waterMeterErrorDayUpdate.setValveButtonStatus(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ waterMeterErrorDayUpdate.setStatus(1);
|
|
|
|
+ waterMeterErrorDaysMapper.insert(waterMeterErrorDayUpdate);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
ValveCommandRequestDTO valveCommandRequest = new ValveCommandRequestDTO();
|
|
ValveCommandRequestDTO valveCommandRequest = new ValveCommandRequestDTO();
|
|
valveCommandRequest.setValveStatus(sendValveStatus);
|
|
valveCommandRequest.setValveStatus(sendValveStatus);
|
|
|
|
|
|
- //1、下发开关阀门
|
|
|
|
|
|
+ //1、执行开关阀门
|
|
|
|
+ executeValveCommand(device,deviceTypeDto,valveCommandRequest);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setValveV2(Long deviceId, String valve) {
|
|
|
|
+ Device device = deviceMapper.findByDeviceId(deviceId);
|
|
|
|
+ DeviceTypeDto deviceTypeDto = deviceTypeMapper.getById(device.getDeviceType());
|
|
|
|
+
|
|
|
|
+ ValveCommandRequestDTO valveCommandRequest = new ValveCommandRequestDTO();
|
|
|
|
+ valveCommandRequest.setValveStatus(valve);
|
|
|
|
+
|
|
|
|
+ //1、执行开关阀门
|
|
|
|
+ executeValveCommand(device,deviceTypeDto,valveCommandRequest);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void executeValveCommand(Device device,DeviceTypeDto deviceTypeDto,ValveCommandRequestDTO valveCommandRequest){
|
|
if(StringUtils.equals("lora188",deviceTypeDto.getEnModel())){
|
|
if(StringUtils.equals("lora188",deviceTypeDto.getEnModel())){
|
|
valveCommandRequest.setMeterCode(device.getWaterMeterNo());
|
|
valveCommandRequest.setMeterCode(device.getWaterMeterNo());
|
|
easylinkinUtils.sendDownlink(device.getDeviceNo(),valveCommandRequest);
|
|
easylinkinUtils.sendDownlink(device.getDeviceNo(),valveCommandRequest);
|
|
}else if(StringUtils.equals("hxgd",deviceTypeDto.getEnModel()))
|
|
}else if(StringUtils.equals("hxgd",deviceTypeDto.getEnModel()))
|
|
{
|
|
{
|
|
- valveCommandRequest.setMeterCode(String.valueOf(deviceId));
|
|
|
|
|
|
+ valveCommandRequest.setMeterCode(String.valueOf(device.getId()));
|
|
gdAgentUtils.setMeterValve(valveCommandRequest);
|
|
gdAgentUtils.setMeterValve(valveCommandRequest);
|
|
}
|
|
}
|
|
else if(StringUtils.equals("hengxin-nb",deviceTypeDto.getEnModel()))
|
|
else if(StringUtils.equals("hengxin-nb",deviceTypeDto.getEnModel()))
|
|
@@ -1416,8 +1446,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
|
//2、插入开关阀门记录
|
|
//2、插入开关阀门记录
|
|
DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
|
|
DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
|
|
- deviceValveRecord.setDeviceId(deviceId);
|
|
|
|
- deviceValveRecord.setSendValveStatus(Integer.valueOf(sendValveStatus));
|
|
|
|
|
|
+ deviceValveRecord.setDeviceId(device.getId());
|
|
|
|
+ deviceValveRecord.setSendValveStatus(Integer.valueOf(valveCommandRequest.getValveStatus()));
|
|
deviceValveRecord.setSendStatus(1);
|
|
deviceValveRecord.setSendStatus(1);
|
|
deviceValveRecord.setCommandId(commandResult.getString("commandId"));
|
|
deviceValveRecord.setCommandId(commandResult.getString("commandId"));
|
|
deviceValveRecord.setRemark("");
|
|
deviceValveRecord.setRemark("");
|
|
@@ -1430,8 +1460,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
|
//2、插入开关阀门记录
|
|
//2、插入开关阀门记录
|
|
DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
|
|
DeviceValveRecord deviceValveRecord = new DeviceValveRecord();
|
|
- deviceValveRecord.setDeviceId(deviceId);
|
|
|
|
- deviceValveRecord.setSendValveStatus(Integer.valueOf(sendValveStatus));
|
|
|
|
|
|
+ deviceValveRecord.setDeviceId(device.getId());
|
|
|
|
+ deviceValveRecord.setSendValveStatus(Integer.valueOf(valveCommandRequest.getValveStatus()));
|
|
deviceValveRecord.setSendStatus(1);
|
|
deviceValveRecord.setSendStatus(1);
|
|
deviceValveRecord.setCommandId(commandResult.getString("commandId"));
|
|
deviceValveRecord.setCommandId(commandResult.getString("commandId"));
|
|
deviceValveRecord.setCommandStatus(commandResult.getString("status"));
|
|
deviceValveRecord.setCommandStatus(commandResult.getString("status"));
|
|
@@ -1442,7 +1472,6 @@ public class DeviceServiceImpl implements DeviceService {
|
|
valveCommandRequest.setMeterCode(device.getWaterMeterNo());
|
|
valveCommandRequest.setMeterCode(device.getWaterMeterNo());
|
|
udipEtlDataCommandService.defaultCommandSend(device.getUdipId(),valveCommandRequest);
|
|
udipEtlDataCommandService.defaultCommandSend(device.getUdipId(),valveCommandRequest);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1545,4 +1574,42 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
|
log.info("end valveUpdate");
|
|
log.info("end valveUpdate");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Async
|
|
|
|
+ @Override
|
|
|
|
+ public void batchSetValve(LoginUser loginUser, Integer valveStatus, InputDeviceDto inputDeviceDto) {
|
|
|
|
+ log.info("begin batchSetValve size = {},inputDeviceDto = {}",inputDeviceDto.getDeviceIds().size(),JSON.toJSON(inputDeviceDto));
|
|
|
|
+
|
|
|
|
+ String valveStatusName = "关阀";
|
|
|
|
+ if(valveStatus == 1){
|
|
|
|
+ valveStatusName = "开阀";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AtomicInteger success = new AtomicInteger(0);
|
|
|
|
+ AtomicInteger fail = new AtomicInteger(0);
|
|
|
|
+ if (inputDeviceDto.getDeviceIds() != null && inputDeviceDto.getDeviceIds().size() > 0) {
|
|
|
|
+ for (Long deviceId : inputDeviceDto.getDeviceIds()) {
|
|
|
|
+ try {
|
|
|
|
+ setValve(deviceId,valveStatus);
|
|
|
|
+ success.incrementAndGet();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ fail.incrementAndGet();
|
|
|
|
+ log.error("batchReleaseFiles error {}",e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //waterRelatedDeviceMapper.updateIssueStatus(inputDeviceDto.getDeviceIds(),1);
|
|
|
|
+
|
|
|
|
+ Message message = new Message();
|
|
|
|
+ message.setSiteId(loginUser.getSiteId());
|
|
|
|
+ message.setUserId(loginUser.getId());
|
|
|
|
+ message.setMessageType(5);
|
|
|
|
+ message.setMessageTitle("远传水表-设备列表-批量"+valveStatusName);
|
|
|
|
+ message.setMessageContent("远传水表批量"+valveStatusName+"完成,成功"+success.get()+"条,失败"+fail.get()+"条。");
|
|
|
|
+ message.setRead(0);
|
|
|
|
+ messageService.insertSelective(message);
|
|
|
|
+ log.info("end batchSetValve");
|
|
|
|
+ }
|
|
}
|
|
}
|