Browse Source

根据事件数据查询可用设备

develop
wangsixiang 3 months ago
parent
commit
9f14872822
  1. 10
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  2. 6
      zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java
  3. 47
      zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

10
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -15,6 +15,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcEvent;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.interfaces.OperationLog;
import com.zc.business.request.DeviceGetPropertiesOperateRequest;
@ -103,6 +104,15 @@ public class DcDeviceController extends BaseController {
return AjaxResult.success(dcDeviceService.listDevice(dcDevice));
}
/**
* 根据事件数据查询可用设备
*/
@ApiOperation("根据事件数据查询可用设备")
@PostMapping("/deviceList/{deviceType}")
public AjaxResult deviceListByEvent(@RequestBody DcEvent dcEvent,@PathVariable String deviceType) {
return AjaxResult.success(dcDeviceService.deviceListByEvent(dcEvent, deviceType));
}
/**
* 无分页根据设备桩号查询设备列表
*

6
zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java

@ -4,6 +4,7 @@ package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcStakeMark;
import com.zc.common.core.httpclient.exception.HttpException;
@ -59,6 +60,11 @@ public interface IDcDeviceService extends IService<DcDevice> {
*/
List<DcDevice> listDevice(DcDevice dcDevice);
/**
* 根据事件数据查询可用设备
*/
List<DcDevice> deviceListByEvent(DcEvent dcEvent, String deviceType);
/**
* 批量修改设备
*

47
zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java

@ -11,6 +11,7 @@ import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StakeMarkUtils;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcProduct;
import com.zc.business.domain.DcStakeMark;
import com.zc.business.domain.MdDevice;
@ -365,6 +366,52 @@ public class DcDeviceServiceImpl extends ServiceImpl<DcDeviceMapper, DcDevice> i
return dcDeviceMapper.selectDcDeviceList(dcDevice);
}
/**
* 根据事件数据查询可用设备
*/
@Override
public List<DcDevice> deviceListByEvent(DcEvent dcEvent, String deviceType) {
// 事件方向 1
String direction = dcEvent.getDirection();
// 事件桩号 K086+285
dcEvent.setStakeMark(dcEvent.getStakeMark().replace(UniversalEnum.CAPITAL_K.getValue(), UniversalEnum.EMPTY_STRING.getValue()));
String[] markArray = dcEvent.getStakeMark().split(UniversalEnum.BARRE_PLUS.getValue());
if (markArray[UniversalEnum.ONE.getNumber()].length() < UniversalEnum.THREE.getNumber()) {
// 不足三位 补零
markArray[UniversalEnum.ONE.getNumber()] = String.format("%0" + UniversalEnum.THREE.getNumber() + "d", markArray[UniversalEnum.ONE.getNumber()]);
}
List<String> start = new ArrayList<>();
List<String> end = new ArrayList<>();
Map<String, Object> parameter = new HashMap<>();
parameter.put("deviceType", deviceType);
// 根据桩号和方向确定设备的范围
if (direction.equals("1") || direction.equals("菏泽方向")) {
// 菏泽方向
start.add(UniversalEnum.FIFTY_FIVE.getValue());
start.add(UniversalEnum.THREE_HUNDRED_SEVENTY_NINE.getValue());
end.add(markArray[UniversalEnum.ZERO.getNumber()]);
end.add(markArray[UniversalEnum.ONE.getNumber()]);
}else {
// 济南方向
start.add(markArray[UniversalEnum.ZERO.getNumber()]);
start.add(markArray[UniversalEnum.ONE.getNumber()]);
end.add(UniversalEnum.TWO_HUNDRED_AND_EIGHT.getValue());
end.add(UniversalEnum.ONE_HUNDRED_AND_FIFTY_FOUR.getValue());
}
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
parameter.put("useState",UniversalEnum.ONE.getNumber());
parameter.put("deviceState", UniversalEnum.ONE.getValue());
List<DcDevice> dcDeviceList = devicePileNumberQueryDevice(parameter);
Collections.sort(dcDeviceList, new Comparator<DcDevice>() {
@Override
public int compare(DcDevice o1, DcDevice o2) {
return o1.getStakeMark().compareTo(o2.getStakeMark());
}
});
return dcDeviceList;
}
/**
* 批量修改设备
*

Loading…
Cancel
Save