|
@@ -28,13 +28,14 @@ import com.xy.device.*;
|
|
|
import com.xy.dto.*;
|
|
|
import com.xy.dto.api.biz.ContainerAddDTO;
|
|
|
import com.xy.dto.be.MercDto;
|
|
|
-import com.xy.dto.common.MercRegionDto;
|
|
|
+import com.xy.dto.common.MercPlaceDto;
|
|
|
import com.xy.entity.*;
|
|
|
import com.xy.enums.FileExportType;
|
|
|
import com.xy.error.CommRuntimeException;
|
|
|
import com.xy.mapper.DeviceInfoMapper;
|
|
|
import com.xy.mapper.entity.DeviceInfoQueryPage;
|
|
|
import com.xy.service.be.MercFeignService;
|
|
|
+import com.xy.service.common.MercPlaceService;
|
|
|
import com.xy.service.common.MercRegionService;
|
|
|
import com.xy.sys.EnumDataClearSize;
|
|
|
import com.xy.util.ExcelUtils;
|
|
@@ -105,6 +106,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
private final DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
|
|
|
|
|
|
+ private final MercPlaceService mercPlaceService;
|
|
|
+
|
|
|
@PostMapping("eventList")
|
|
|
@ApiOperation("根据事件编码查询设备")
|
|
|
public R<PageBean<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
|
|
@@ -147,7 +150,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Long strategyId = dto.getStrategyId();
|
|
|
|
|
|
GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
|
|
|
- selectList.setMercId(mercId).setPriceStrategyId(strategyId);
|
|
|
+ //selectList.setMercId(mercId).setPriceStrategyId(strategyId);
|
|
|
List<GoodsDeviceDto.Vo> goodsDevices = R.feignCheckData(goodsDeviceService.list(selectList));
|
|
|
if (type == 2 && CollUtil.isEmpty(goodsDevices)) {
|
|
|
//右侧已选的
|
|
@@ -774,6 +777,19 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Long mercId = dto.getMercId();
|
|
|
String deviceName = dto.getDeviceName();
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
+ List<Long> searchPlaceIdList = new ArrayList<>();
|
|
|
+ //根据管理员名字查询点位ID列表
|
|
|
+ if (Emptys.check(dto.getAdminName())) {
|
|
|
+ MercPlaceDto.ListDto placeDto = new MercPlaceDto.ListDto();
|
|
|
+ placeDto.setMercId(mercId).setAdminName(dto.getAdminName());
|
|
|
+ List<MercPlaceDto.Vo> searchPlaceList = mercPlaceService.list(placeDto).getData();
|
|
|
+ if (Emptys.check(searchPlaceList)) {
|
|
|
+ searchPlaceIdList = searchPlaceList.stream().map(MercPlaceDto.Vo::getId).distinct().collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
boolean isQa = false;
|
|
|
if ("393010594508869".equals(String.valueOf(mercId))) {
|
|
|
isQa = true;
|
|
@@ -781,16 +797,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
dto.setActiveState("1");
|
|
|
}
|
|
|
List<Long> searchDeviceIds = new ArrayList<>();
|
|
|
- if (StrUtil.isNotEmpty(searchKey)) {
|
|
|
+ if (StrUtil.isNotEmpty(searchKey) || StrUtil.isNotEmpty(dto.getAdminName())) {
|
|
|
//名称或者编号搜索设备
|
|
|
- List<DeviceInfo> list = list(Wrappers.<DeviceInfo>lambdaQuery()
|
|
|
+ LambdaQueryWrapper<DeviceInfo> deviceLqw = Wrappers.<DeviceInfo>lambdaQuery()
|
|
|
.eq(DeviceInfo::getMercId, mercId)
|
|
|
- .and(wrapper -> wrapper
|
|
|
- .eq(DeviceInfo::getDeviceId, searchKey)
|
|
|
- .or()
|
|
|
- .likeRight(DeviceInfo::getDeviceName, searchKey)
|
|
|
- )
|
|
|
- );
|
|
|
+ .in(Emptys.check(searchPlaceIdList), DeviceInfo::getPlaceId, searchPlaceIdList);
|
|
|
+ if (Emptys.check(searchKey)) {
|
|
|
+ deviceLqw.and(wrapper -> wrapper
|
|
|
+ .eq(Emptys.check(searchKey), DeviceInfo::getDeviceId, searchKey)
|
|
|
+ .or()
|
|
|
+ .likeRight(Emptys.check(searchKey), DeviceInfo::getDeviceName, searchKey)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DeviceInfo> list = list(deviceLqw);
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
return R.ok(new ArrayList<>());
|
|
|
}
|
|
@@ -820,7 +840,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
if (CollUtil.isNotEmpty(searchDeviceIds)) {
|
|
|
for (Long id : searchDeviceIds) {
|
|
|
int index = deviceIdList.indexOf(id);
|
|
|
- if (index > 0) {
|
|
|
+ if (index >= 0) {
|
|
|
queryDeviceIds.add(id);
|
|
|
}
|
|
|
}
|
|
@@ -865,25 +885,31 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
lqw.eq(deviceType != null, DeviceInfo::getDeviceType, deviceType);
|
|
|
lqw.in(CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
|
|
|
lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName).orderByAsc(true, DeviceInfo::getDeviceName, DeviceInfo::getDeviceId);
|
|
|
- List<DeviceInfo> deviceInfoList = this.list(lqw);
|
|
|
- //未分区域的设置默认值
|
|
|
- deviceInfoList.stream().filter(s -> s.getDistrictId() == null).forEach(s -> s.setDistrictId(-1L));
|
|
|
- Map<Long, String> districtMap = new HashMap<>();
|
|
|
- List<Long> districtIdList = list.stream().map(DeviceInfoDto.MercHomeCountVO::getDistrictId).filter(i -> i != -1).collect(Collectors.toList());
|
|
|
- districtMap = mercRegionService.getNameList(new MercRegionDto.GetNameListDto().setIds(districtIdList)).getData();
|
|
|
- //根据区域id分组
|
|
|
- Map<Long, List<DeviceInfo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfo::getDistrictId));
|
|
|
+ List<DeviceInfoDto.Vo> deviceInfoList = copy(DeviceInfoDto.Vo.class, this.list(lqw));
|
|
|
+ //根据点位ID查询管理员名字
|
|
|
+ List<Long> placeIdList = deviceInfoList.stream().map(DeviceInfoDto.Vo::getPlaceId).distinct().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<MercPlaceDto.Vo> mercPlaceList = mercPlaceService.list(new MercPlaceDto.ListDto().setIds(placeIdList)).getData();
|
|
|
+ Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
|
|
|
+ deviceInfoList.forEach(i -> i.setAdminName(mercPlaceMap.get(i.getPlaceId())));
|
|
|
+
|
|
|
+ //没有管理员的的设置默认值
|
|
|
+ deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName("未分配管理员"));
|
|
|
+ List<String> adminNameList = deviceInfoList.stream().map(DeviceInfoDto.Vo::getAdminName).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ //根据管理员名字分组
|
|
|
+ Map<String, List<DeviceInfoDto.Vo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.Vo::getAdminName));
|
|
|
+
|
|
|
+
|
|
|
DateTime date = DateTime.now();
|
|
|
DateTime start = DateUtil.beginOfDay(date);
|
|
|
DateTime end = DateUtil.endOfDay(date);
|
|
|
- for (DeviceInfoDto.MercHomeCountVO v : list) {
|
|
|
+ for (String adminName : adminNameList) {
|
|
|
DeviceInfoDto.MercHomeListVO vo = new DeviceInfoDto.MercHomeListVO();
|
|
|
- Long districtId = v.getDistrictId();
|
|
|
- vo.setDeviceNum(v.getDeviceNum());
|
|
|
- vo.setDistrictId(v.getDistrictId());
|
|
|
- vo.setDistrictName(v.getDistrictId() == -1L ? "未分配区域" : districtMap.get(v.getDistrictId()));
|
|
|
+ vo.setAdminName(adminName);
|
|
|
//区域下的设备列表
|
|
|
- List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = BeanUtil.copyToList(deviceMap.get(districtId), DeviceInfoDto.MercHomeDeviceVo.class);
|
|
|
+ List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = BeanUtil.copyToList(deviceMap.get(adminName), DeviceInfoDto.MercHomeDeviceVo.class);
|
|
|
+ vo.setDeviceNum(deviceInfos.size());
|
|
|
if (CollUtil.isEmpty(deviceInfos)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -982,7 +1008,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
dataList.add(vo);
|
|
|
}
|
|
|
-
|
|
|
+ DeviceInfoDto.MercHomeListVO orderTemp = null;
|
|
|
+ for (int i=0; i<dataList.size(); i++){
|
|
|
+ if ("未分配管理员".equals(dataList.get(i).getAdminName())) {
|
|
|
+ orderTemp = dataList.get(i);
|
|
|
+ dataList.remove(i);
|
|
|
+ dataList.add(orderTemp);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.ok(dataList);
|
|
|
}
|
|
|
|