|
|
|
|
@ -485,11 +485,38 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<DeviceLedgerDO> getDeviceLedgerPage(DeviceLedgerPageReqVO pageReqVO) {
|
|
|
|
|
|
|
|
|
|
if (!prepareDeviceLedgerQuery(pageReqVO)) {
|
|
|
|
|
return new PageResult<>(Collections.emptyList(), 0L);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DeviceLineDO> deviceLineList = deviceLineService.getDeviceLineList(new DeviceLineListReqVO());
|
|
|
|
|
Map<Long, List<DeviceLineDO>> collect = deviceLineList.stream().collect(Collectors.groupingBy(DeviceLineDO::getId));
|
|
|
|
|
Map<Long, DeviceLineDO> deviceLineMap = deviceLineList.stream()
|
|
|
|
|
.collect(Collectors.toMap(DeviceLineDO::getId, Function.identity(), (a, b) -> a));
|
|
|
|
|
PageResult<DeviceLedgerDO> deviceLedgerDOPageResult = deviceLedgerMapper.selectPage(pageReqVO);
|
|
|
|
|
for (DeviceLedgerDO deviceLedgerDO : deviceLedgerDOPageResult.getList()) {
|
|
|
|
|
if (deviceLedgerDO.getDeviceType()!=null){
|
|
|
|
|
DeviceTypeDO deviceTypeDO = deviceTypeMapper.selectById(deviceLedgerDO.getDeviceType());
|
|
|
|
|
deviceLedgerDO.setTypeName(deviceTypeDO.getName());
|
|
|
|
|
}
|
|
|
|
|
if(deviceLedgerDO.getDeviceLine()!=null&&CollUtil.isNotEmpty(collect.get(deviceLedgerDO.getDeviceLine().longValue()))){
|
|
|
|
|
deviceLedgerDO.setWorkshopName(collect.get(deviceLedgerDO.getDeviceLine().longValue()).get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
fillTopCategoryInfo(deviceLedgerDO, deviceLineMap);
|
|
|
|
|
}
|
|
|
|
|
fillIotDeviceInfo(deviceLedgerDOPageResult.getList());
|
|
|
|
|
return deviceLedgerDOPageResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean prepareDeviceLedgerQuery(DeviceLedgerPageReqVO pageReqVO) {
|
|
|
|
|
if (pageReqVO == null) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (pageReqVO.getDeviceLine() != null) {
|
|
|
|
|
Set<Integer> deviceLineIds = new LinkedHashSet<>();
|
|
|
|
|
collectDeviceLineIds(Long.valueOf(pageReqVO.getDeviceLine()), deviceLineIds);
|
|
|
|
|
if (deviceLineIds.isEmpty()) {
|
|
|
|
|
return new PageResult<>(Collections.emptyList(), 0L);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
pageReqVO.setDeviceLineIds(new ArrayList<>(deviceLineIds));
|
|
|
|
|
}
|
|
|
|
|
@ -507,25 +534,13 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
|
|
|
|
|
.map(String::valueOf)
|
|
|
|
|
.collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
|
|
pageReqVO.setIds(ids);
|
|
|
|
|
}
|
|
|
|
|
List<DeviceLineDO> deviceLineList = deviceLineService.getDeviceLineList(new DeviceLineListReqVO());
|
|
|
|
|
Map<Long, List<DeviceLineDO>> collect = deviceLineList.stream().collect(Collectors.groupingBy(DeviceLineDO::getId));
|
|
|
|
|
Map<Long, DeviceLineDO> deviceLineMap = deviceLineList.stream()
|
|
|
|
|
.collect(Collectors.toMap(DeviceLineDO::getId, Function.identity(), (a, b) -> a));
|
|
|
|
|
PageResult<DeviceLedgerDO> deviceLedgerDOPageResult = deviceLedgerMapper.selectPage(pageReqVO);
|
|
|
|
|
for (DeviceLedgerDO deviceLedgerDO : deviceLedgerDOPageResult.getList()) {
|
|
|
|
|
if (deviceLedgerDO.getDeviceType()!=null){
|
|
|
|
|
DeviceTypeDO deviceTypeDO = deviceTypeMapper.selectById(deviceLedgerDO.getDeviceType());
|
|
|
|
|
deviceLedgerDO.setTypeName(deviceTypeDO.getName());
|
|
|
|
|
}
|
|
|
|
|
if(deviceLedgerDO.getDeviceLine()!=null&&CollUtil.isNotEmpty(collect.get(deviceLedgerDO.getDeviceLine().longValue()))){
|
|
|
|
|
deviceLedgerDO.setWorkshopName(collect.get(deviceLedgerDO.getDeviceLine().longValue()).get(0).getName());
|
|
|
|
|
if (StringUtils.isBlank(ids)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
fillTopCategoryInfo(deviceLedgerDO, deviceLineMap);
|
|
|
|
|
|
|
|
|
|
pageReqVO.setIds(ids);
|
|
|
|
|
}
|
|
|
|
|
fillIotDeviceInfo(deviceLedgerDOPageResult.getList());
|
|
|
|
|
return deviceLedgerDOPageResult;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void collectDeviceLineIds(Long deviceLineId, Set<Integer> results) {
|
|
|
|
|
@ -715,6 +730,21 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
|
|
|
|
|
public List<DeviceLedgerDO> getDeviceLedgerList() {
|
|
|
|
|
List<DeviceLedgerDO> list = deviceLedgerMapper.selectList();
|
|
|
|
|
fillTopCategoryInfo(list);
|
|
|
|
|
fillIotDeviceInfo(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DeviceLedgerDO> getDeviceLedgerList(DeviceLedgerPageReqVO pageReqVO) {
|
|
|
|
|
if (pageReqVO == null) {
|
|
|
|
|
return getDeviceLedgerList();
|
|
|
|
|
}
|
|
|
|
|
if (!prepareDeviceLedgerQuery(pageReqVO)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
List<DeviceLedgerDO> list = deviceLedgerMapper.selectList(pageReqVO);
|
|
|
|
|
fillTopCategoryInfo(list);
|
|
|
|
|
fillIotDeviceInfo(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|