|
@@ -31,12 +31,14 @@ import com.xy.dto.be.MercDto;
|
|
|
import com.xy.dto.common.MercPlaceDto;
|
|
|
import com.xy.dto.device.DeviceQueryDTO;
|
|
|
import com.xy.dto.device.DeviceRegDTO;
|
|
|
+import com.xy.dto.mini.MiniDeviceInfoDto;
|
|
|
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.be.MercService;
|
|
|
import com.xy.service.common.MercPlaceService;
|
|
|
import com.xy.service.common.MercRegionService;
|
|
|
import com.xy.sys.EnumDataClearSize;
|
|
@@ -112,6 +114,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
private final MercUserBindDeviceService mercUserBindDeviceService;
|
|
|
|
|
|
private final DevicePartServiceImpl devicePartService;
|
|
|
+ private final MercService mercService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -127,7 +130,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- //没有管理员的的设置默认值
|
|
|
+ // 没有管理员的的设置默认值
|
|
|
deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName(noAdmin));
|
|
|
return R.ok(deviceInfoList);
|
|
|
}
|
|
@@ -147,7 +150,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- //没有管理员的的设置默认值
|
|
|
+ // 没有管理员的的设置默认值
|
|
|
deviceInfoList.getRecords().stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName(noAdmin));
|
|
|
return R.ok(toPageBean(DeviceInfoDto.ListByAdminName.class, deviceInfoList));
|
|
|
}
|
|
@@ -157,10 +160,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
public R<List<DeviceInfoDto.GroupByAdminNameVo>> groupByAdminName(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
|
|
|
String noAdmin = "未分配管理员";
|
|
|
List<DeviceInfoDto.ListByAdminName> deviceInfoList = listByAdminName(dto).getData();
|
|
|
- //根据管理员名字分组
|
|
|
+ // 根据管理员名字分组
|
|
|
Map<String, List<DeviceInfoDto.ListByAdminName>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.ListByAdminName::getAdminName));
|
|
|
List<DeviceInfoDto.GroupByAdminNameVo> list = new ArrayList<>();
|
|
|
- //不包含未分配管理员的
|
|
|
+ // 不包含未分配管理员的
|
|
|
deviceMap.forEach(
|
|
|
(k, i) -> {
|
|
|
DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
@@ -172,7 +175,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
- //包含分配管理员的
|
|
|
+ // 包含分配管理员的
|
|
|
List<DeviceInfoDto.ListByAdminName> noAdminNamesList = deviceMap.get(noAdmin);
|
|
|
if (Emptys.check(noAdminNamesList)) {
|
|
|
DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
@@ -188,10 +191,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
public R<List<DeviceInfoDto.GroupByAdminNameVo>> groupByAdminCount(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
|
|
|
String noAdmin = "未分配管理员";
|
|
|
List<DeviceInfoDto.ListByAdminName> deviceInfoList = listByAdminName(dto).getData();
|
|
|
- //根据管理员名字分组
|
|
|
+ // 根据管理员名字分组
|
|
|
Map<String, List<DeviceInfoDto.ListByAdminName>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.ListByAdminName::getAdminName));
|
|
|
List<DeviceInfoDto.GroupByAdminNameVo> list = new ArrayList<>();
|
|
|
- //不包含未分配管理员的
|
|
|
+ // 不包含未分配管理员的
|
|
|
deviceMap.forEach(
|
|
|
(k, i) -> {
|
|
|
DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
@@ -203,7 +206,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
- //包含分配管理员的
|
|
|
+ // 包含分配管理员的
|
|
|
List<DeviceInfoDto.ListByAdminName> noAdminNamesList = deviceMap.get(noAdmin);
|
|
|
if (Emptys.check(noAdminNamesList)) {
|
|
|
DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
@@ -250,7 +253,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
String searchKey = dto.getSearchKey();
|
|
|
Integer thirdStatus = dto.getThirdStatus();
|
|
|
List<String> statusList = new ArrayList<>();
|
|
|
- //1待审核,2已审核
|
|
|
+ // 1待审核,2已审核
|
|
|
if (thirdStatus != null && thirdStatus.intValue() == 1) {
|
|
|
statusList = CollUtil.newArrayList("1000", "2000", "3000", "5000");
|
|
|
}
|
|
@@ -281,8 +284,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
*/
|
|
|
String tyStatus = deviceInfo.getThirdStatus();
|
|
|
if (!"4000".equals(tyStatus)) {
|
|
|
- //未登记成功的需要实时查询
|
|
|
- //查询登记设备
|
|
|
+ // 未登记成功的需要实时查询
|
|
|
+ // 查询登记设备
|
|
|
DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
|
|
|
Integer status = deviceQueryVO.getStatus();
|
|
|
String message = deviceQueryVO.getMessage();
|
|
@@ -318,7 +321,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
List<GoodsDeviceDto.Vo> goodsDevices = R.feignCheckData(goodsDeviceService.list(selectList));
|
|
|
if (type == 2 && CollUtil.isEmpty(goodsDevices)) {
|
|
|
- //右侧已选的
|
|
|
+ // 右侧已选的
|
|
|
return R.ok(new PageBean<>());
|
|
|
}
|
|
|
List<Long> deviceIds = goodsDevices.stream().map(GoodsDeviceDto.Vo::getDeviceId).collect(Collectors.toList());
|
|
@@ -326,7 +329,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
|
|
|
.build();
|
|
|
lqw.in(type == 2 && CollUtil.isNotEmpty(deviceIds), DeviceInfo::getDeviceId, deviceIds);
|
|
|
- //左侧排除掉已关联的
|
|
|
+ // 左侧排除掉已关联的
|
|
|
lqw.notIn(type == 1 && CollUtil.isNotEmpty(deviceIds), DeviceInfo::getDeviceId, deviceIds);
|
|
|
lqw.and(StrUtil.isNotEmpty(searchKey), wrapper -> wrapper
|
|
|
.eq(DeviceInfo::getDeviceId, searchKey)
|
|
@@ -347,7 +350,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@ApiOperation("设备列表带卡包数")
|
|
|
public R<PageBean<DeviceInfoDto.AlgorithmChargingVo>> algorithmChargingDevice(@RequestBody @Validated DeviceInfoDto.AlgorithmCharging algorithmCharging) {
|
|
|
PageBean pageBean = algorithmCharging.getPage();
|
|
|
- //查询设备
|
|
|
+ // 查询设备
|
|
|
Integer value = SysDictUtils.getValue(EnumDeviceActiveStatus.Code.CODE.getCode(), EnumDeviceActiveStatus.N_1.getCode(), Integer.class);
|
|
|
LambdaUpdateWrapper<DeviceInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<DeviceInfo>()
|
|
|
.eq(DeviceInfo::getMercId, algorithmCharging.getMercId())
|
|
@@ -360,7 +363,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
if (!Emptys.check(algorithmChargingVos)) {
|
|
|
return R.ok(algorithmChargingVoPageBean);
|
|
|
}
|
|
|
- //查询卡包数量
|
|
|
+ // 查询卡包数量
|
|
|
List<DeviceAlgorithmChargingDto.CountVo> data = deviceAlgorithmChargingService.count(new DeviceAlgorithmChargingDto.Count()
|
|
|
.setDeviceIds(new JArrayList<>(algorithmChargingVos).getProperty(DeviceInfoDto.AlgorithmChargingVo::getDeviceId))
|
|
|
.setMercId(algorithmCharging.getMercId())
|
|
@@ -413,6 +416,55 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
return R.ok(toPageBean(DeviceInfoDto.Vo.class, iPage));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @ApiOperation("设备流水统计分页")
|
|
|
+ public R<PageBean<DeviceDataDto.DeviceFlowCountVO>> deviceFlowCountPage(@RequestBody @Valid DeviceDataDto.DeviceFlowCountDTO dto) {
|
|
|
+ Long curMercId = dto.getCurMercId();
|
|
|
+ PageBean pageBean = dto.getPage();
|
|
|
+ List<Long> mercIds = new ArrayList<>();
|
|
|
+ Long chooseMercId = dto.getChooseMercId();
|
|
|
+ if (chooseMercId == null) {
|
|
|
+ // 未指定商户 查下级商户含自身
|
|
|
+ mercIds = R.feignCheckData(mercService.getAllSubMercIds(new MercDto.QuerySubDTO().setParentMercID(curMercId)));
|
|
|
+ } else {
|
|
|
+ mercIds.add(chooseMercId);
|
|
|
+
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
|
|
|
+ .ge(DeviceInfo::getActiveTime, dto.getActiveStartTime())
|
|
|
+ .le(DeviceInfo::getActiveTime, dto.getActiveEndStartTime())
|
|
|
+ .build().in(DeviceInfo::getMercId, mercIds).eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
|
|
|
+ IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
|
|
|
+ PageBean<DeviceDataDto.DeviceFlowCountVO> dataPage = toPageBean(DeviceDataDto.DeviceFlowCountVO.class, iPage);
|
|
|
+
|
|
|
+ List<DeviceDataDto.DeviceFlowCountVO> records = dataPage.getRecords();
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
+
|
|
|
+ List<Long> placeIds = records.stream().filter(s -> s.getPlaceId() != null).map(DeviceDataDto.DeviceFlowCountVO::getPlaceId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<MercPlaceDto.Vo> merPlaceList = R.feignCheckData(mercPlaceService.list(new MercPlaceDto.ListDto().setIds(placeIds)));
|
|
|
+ if (Emptys.check(merPlaceList)) {
|
|
|
+ Map<Long, MercPlaceDto.Vo> placeMap = merPlaceList.stream().collect(Collectors.toMap(MercPlaceDto.Vo::getId, p -> p));
|
|
|
+
|
|
|
+ for (DeviceDataDto.DeviceFlowCountVO record : records) {
|
|
|
+ Long placeId = record.getPlaceId();
|
|
|
+ if (placeId == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 点位 区域 反显
|
|
|
+ MercPlaceDto.Vo placeVo = placeMap.get(placeId);
|
|
|
+ if (placeVo != null) {
|
|
|
+ record.setDistrictName(placeVo.getRegionName());
|
|
|
+ record.setPlaceName(placeVo.getPlaceName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataPage.setRecords(records);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok(dataPage);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 按商户分页查设备
|
|
|
*
|
|
@@ -430,7 +482,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
|
|
|
if (BooleanUtil.isFalse(choosed)) {
|
|
|
- //未选择 排除已选择
|
|
|
+ // 未选择 排除已选择
|
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
lqw.notIn(DeviceInfo::getDeviceId, deviceIds);
|
|
|
} else {
|
|
@@ -440,8 +492,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
lqw.in(DeviceInfo::getDeviceId, myDeviceIds);
|
|
|
}
|
|
|
} else {
|
|
|
- //已选择
|
|
|
- //指定设备 已选择
|
|
|
+ // 已选择
|
|
|
+ // 指定设备 已选择
|
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
lqw.in(DeviceInfo::getDeviceId, deviceIds);
|
|
|
} else {
|
|
@@ -449,7 +501,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //设备搜索
|
|
|
+ // 设备搜索
|
|
|
lqw.and(StrUtil.isNotEmpty(deviceSearch),
|
|
|
wrapper -> wrapper
|
|
|
.likeRight(DeviceInfo::getDeviceName, deviceSearch)
|
|
@@ -463,7 +515,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@Override
|
|
|
@ApiOperation("对象查询")
|
|
|
public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {
|
|
|
- //设备信息
|
|
|
+ // 设备信息
|
|
|
LambdaQueryWrapper<DeviceInfo> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(obj, DeviceInfo.class).build();
|
|
|
List<DeviceInfo> list = list(lambdaQueryWrapper);
|
|
|
if (!Emptys.check(list)) {
|
|
@@ -484,21 +536,21 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, num);
|
|
|
if (obj.getIsSysinfo()) {
|
|
|
execute.execute(() -> {
|
|
|
- //系统信息
|
|
|
+ // 系统信息
|
|
|
DeviceSysinfoDto.Vo deviceSysinfo = deviceSysinfoService.get(new DeviceSysinfoDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
|
|
|
deviceInfo.setDeviceSysinfo(deviceSysinfo);
|
|
|
});
|
|
|
}
|
|
|
if (obj.getIsStatus()) {
|
|
|
execute.execute(() -> {
|
|
|
- //状态信息
|
|
|
+ // 状态信息
|
|
|
DeviceStatusDto.Vo deviceStatus = deviceStatusService.obj(new DeviceStatusDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
|
|
|
deviceInfo.setDeviceStatus(deviceStatus);
|
|
|
});
|
|
|
}
|
|
|
if (obj.getIsRegister()) {
|
|
|
execute.execute(() -> {
|
|
|
- //注册信息
|
|
|
+ // 注册信息
|
|
|
DeviceRegisterDto.Vo deviceRegister = deviceRegisterService.obj(new DeviceRegisterDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
|
|
|
deviceInfo.setDeviceRegister(deviceRegister);
|
|
|
});
|
|
@@ -528,14 +580,14 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@Override
|
|
|
@ApiOperation("设备访问历史添加")
|
|
|
public R history(DeviceInfoDto.Obj obj) {
|
|
|
- //获取字典
|
|
|
+ // 获取字典
|
|
|
SysDictRedis sysDictRedis = SysDictUtils.get(EnumDataClearSize.Code.CODE.getCode(), EnumDataClearSize.DEVICE_HISTORY_TWIG.getCode());
|
|
|
Integer value = Integer.valueOf(sysDictRedis.getValue());
|
|
|
- //获取redis
|
|
|
+ // 获取redis
|
|
|
String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
|
|
|
List<String> list = redisService.getList(key);
|
|
|
list.add(0, String.valueOf(obj.getDeviceId()));
|
|
|
- //去重
|
|
|
+ // 去重
|
|
|
List<String> redisList = new ArrayList<>();
|
|
|
JList<String> comparing = new JArrayList<>(list).comparing();
|
|
|
if (comparing.size() > value) {
|
|
@@ -562,7 +614,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
DeviceStatusDto.Vo deviceStatus = deviceInfo.getDeviceStatus();
|
|
|
SysDictRedis qualitySets = SysDictUtils.get(EnumQualityMercSets.Code.CODE.getCode(), EnumQualityMercSets.MERC_CODE.getCode());
|
|
|
- //设备当前商户是质检时不检查
|
|
|
+ // 设备当前商户是质检时不检查
|
|
|
if (!qualitySets.getValue().equals(deviceInfo.getMercCode())) {
|
|
|
check(deviceInfo.getActiveState(), 2, "设备未激活");
|
|
|
check(deviceInfo.getFreezeStatus(), 2, "设备已冻结");
|
|
@@ -580,13 +632,13 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@PostMapping("historyList")
|
|
|
@ApiOperation("设备访问历史查询")
|
|
|
public R<List<DeviceInfoDto.Vo>> historyList() {
|
|
|
- //获取redis
|
|
|
+ // 获取redis
|
|
|
String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
|
|
|
List<String> deviceIds = redisService.getList(key);
|
|
|
if (!Emptys.check(deviceIds)) {
|
|
|
return R.ok();
|
|
|
}
|
|
|
- //查询数据库
|
|
|
+ // 查询数据库
|
|
|
List<DeviceInfo> list = list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceIds));
|
|
|
return R.ok(copy(DeviceInfoDto.Vo.class, list));
|
|
|
}
|
|
@@ -605,15 +657,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@PostMapping("update")
|
|
|
public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
|
|
|
DeviceInfo deviceInfo = getById(update.getDeviceId());
|
|
|
- //判断是否更新了点位
|
|
|
+ // 判断是否更新了点位
|
|
|
if (Emptys.check(update.getPlaceId()) && !Objects.equals(deviceInfo.getPlaceId(), update.getPlaceId())) {
|
|
|
- //把设备绑定给点位管理员
|
|
|
+ // 把设备绑定给点位管理员
|
|
|
MercUserBindDeviceDto.BindByDeviceUpdate bindByPlaceIdDTto = new MercUserBindDeviceDto.BindByDeviceUpdate();
|
|
|
bindByPlaceIdDTto.setDeviceId(update.getDeviceId())
|
|
|
.setPlaceId(update.getPlaceId())
|
|
|
.setMercId(deviceInfo.getMercId());
|
|
|
mercUserBindDeviceService.bindByDeviceUpdate(bindByPlaceIdDTto);
|
|
|
- //更新坐标为点位的坐标
|
|
|
+ // 更新坐标为点位的坐标
|
|
|
MercPlaceDto.ObjVo place = mercPlaceService.obj(new MercPlaceDto.Obj().setId(update.getPlaceId())).getData();
|
|
|
update.setLat(place.getLat()).setLon(place.getLon());
|
|
|
}
|
|
@@ -626,19 +678,19 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
DeviceInfoDto.Vo device = R.feignCheckData(this.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(true)));
|
|
|
Long algorithmId = update.getAlgorithmId();
|
|
|
if (algorithmId != null && AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
|
|
|
- //云从算法
|
|
|
+ // 云从算法
|
|
|
boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
|
|
|
if (!b) {
|
|
|
- //货柜不存在,新增
|
|
|
+ // 货柜不存在,新增
|
|
|
cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
|
|
|
}
|
|
|
} else if (algorithmId != null && AlgorithmTypeEnum.TY.getId() == algorithmId) {
|
|
|
- //拓元算法
|
|
|
- //查询登记设备
|
|
|
+ // 拓元算法
|
|
|
+ // 查询登记设备
|
|
|
DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
|
|
|
Integer status = deviceQueryVO.getStatus();
|
|
|
if (status != null && 1000 == status.intValue()) {
|
|
|
- //未知的设备CPUID,进行登记
|
|
|
+ // 未知的设备CPUID,进行登记
|
|
|
tyApiService.deviceReg(new DeviceRegDTO()
|
|
|
.setCpuId(String.valueOf(deviceId))
|
|
|
.setDeviceNumber(String.valueOf(deviceId))
|
|
@@ -688,20 +740,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@ApiOperation("更新商户线路")
|
|
|
public R updateLine(@RequestBody @Validated DeviceInfoDto.UpdateLine updateLine) {
|
|
|
LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>().eq(DeviceInfo::getMercId, updateLine.getMercId());
|
|
|
- //绑定线路,更换线路
|
|
|
+ // 绑定线路,更换线路
|
|
|
if (DeviceInfoDto.UPDATE.equals(updateLine.getType())) {
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
deviceInfo.setPlaceLineId(updateLine.getPlaceLineId());
|
|
|
luw.in(DeviceInfo::getDeviceId, updateLine.getDeviceIds());
|
|
|
baseMapper.update(deviceInfo, luw);
|
|
|
}
|
|
|
- //删除线路
|
|
|
+ // 删除线路
|
|
|
if (DeviceInfoDto.DEL.equals(updateLine.getType())) {
|
|
|
luw.eq(DeviceInfo::getPlaceLineId, updateLine.getWherePlaceLineId());
|
|
|
luw.set(DeviceInfo::getPlaceLineId, null);
|
|
|
baseMapper.update(null, luw);
|
|
|
}
|
|
|
- //解绑线路 设置线路ID为null
|
|
|
+ // 解绑线路 设置线路ID为null
|
|
|
if (DeviceInfoDto.CLEAR.equals(updateLine.getType())) {
|
|
|
luw.in(DeviceInfo::getDeviceId, updateLine.getDeviceIds());
|
|
|
luw.set(DeviceInfo::getPlaceLineId, null);
|
|
@@ -715,20 +767,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@ApiOperation("更新商户点位")
|
|
|
public R updatePlace(@RequestBody @Validated DeviceInfoDto.UpdatePlace updatePlace) {
|
|
|
LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>().eq(DeviceInfo::getMercId, updatePlace.getMercId());
|
|
|
- //绑定点位,更换点位
|
|
|
+ // 绑定点位,更换点位
|
|
|
if (DeviceInfoDto.UPDATE.equals(updatePlace.getType())) {
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
deviceInfo.setPlaceId(updatePlace.getPlaceId());
|
|
|
luw.in(DeviceInfo::getDeviceId, updatePlace.getDeviceIds());
|
|
|
baseMapper.update(deviceInfo, luw);
|
|
|
}
|
|
|
- //删除点位
|
|
|
+ // 删除点位
|
|
|
if (DeviceInfoDto.DEL.equals(updatePlace.getType())) {
|
|
|
luw.eq(DeviceInfo::getPlaceId, updatePlace.getWherePlaceId());
|
|
|
luw.set(DeviceInfo::getPlaceId, null);
|
|
|
baseMapper.update(null, luw);
|
|
|
}
|
|
|
- //解绑点位 设置点位ID为null
|
|
|
+ // 解绑点位 设置点位ID为null
|
|
|
if (DeviceInfoDto.CLEAR.equals(updatePlace.getType())) {
|
|
|
luw.in(DeviceInfo::getDeviceId, updatePlace.getDeviceIds());
|
|
|
luw.set(DeviceInfo::getPlaceId, null);
|
|
@@ -760,13 +812,13 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
|
|
|
List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
|
|
|
List<DeviceInfoDto.DeviceExcelVO> deviceExcelVOS = BeanUtil.copyToList(records, DeviceInfoDto.DeviceExcelVO.class);
|
|
|
- //异步导出参数封装
|
|
|
+ // 异步导出参数封装
|
|
|
ExcelDTO<DeviceInfoDto.DeviceExcelVO> excelDTO = new ExcelDTO<>();
|
|
|
excelDTO.setData(deviceExcelVOS);
|
|
|
excelDTO.setHead(DeviceInfoDto.DeviceExcelVO.class);
|
|
|
excelDTO.setSheetName(FileExportType.DEVICE_INFO.getDescription());
|
|
|
excelDTO.setFileExportType(FileExportType.DEVICE_INFO);
|
|
|
- //执行导出
|
|
|
+ // 执行导出
|
|
|
fileExportService.exportExcelAsync(excelDTO);
|
|
|
}
|
|
|
|
|
@@ -787,41 +839,45 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
String mercCode = auth.getMercCode();
|
|
|
Long algorithmId = auth.getAlgorithmId();
|
|
|
String mercName = auth.getMercName();
|
|
|
- //商户最终设备列表
|
|
|
+ // 商户最终设备列表
|
|
|
List<Long> deviceIds = auth.getDeviceIds();
|
|
|
List<DeviceInfo> devices = getDevicesByMercId(mercId);
|
|
|
- //取消商户设备授权
|
|
|
+ // 取消商户设备授权
|
|
|
if (CollUtil.isEmpty(deviceIds)) {
|
|
|
if (CollUtil.isEmpty(devices)) {
|
|
|
return R.ok(Boolean.TRUE);
|
|
|
}
|
|
|
}
|
|
|
- //更新商户设备授权
|
|
|
+ // 更新商户设备授权
|
|
|
List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
|
|
|
+ // 绑定前,先进行旧的用户设备关联表清理
|
|
|
+ R.feignCheckData(mercService.unBindSubMercDevice(new MiniDeviceInfoDto.MercDeviceUnBindDto().setDeviceIds(deviceIds)));
|
|
|
List<DeviceStatus> deviceStatuses = new ArrayList<>();
|
|
|
for (DeviceInfo deviceInfo : deviceInfos) {
|
|
|
Integer deviceType = deviceInfo.getDeviceType();
|
|
|
Long deviceId = deviceInfo.getDeviceId();
|
|
|
+ // 清理点位
|
|
|
+ deviceInfo.setPlaceId(-1L);
|
|
|
|
|
|
if (ObjectUtil.equals(deviceType, DeviceTypeEnum.TYPE5.getCode())) {
|
|
|
- //支付宝设备算法
|
|
|
+ // 支付宝设备算法
|
|
|
algorithmId = AlgorithmTypeEnum.ALIPAY.getId();
|
|
|
} else {
|
|
|
- //非支付宝算法
|
|
|
+ // 非支付宝算法
|
|
|
if (AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
|
|
|
- //云从算法
|
|
|
+ // 云从算法
|
|
|
boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
|
|
|
if (!b) {
|
|
|
- //货柜不存在,新增
|
|
|
+ // 货柜不存在,新增
|
|
|
cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
|
|
|
}
|
|
|
} else if (AlgorithmTypeEnum.TY.getId() == algorithmId) {
|
|
|
- //拓元算法
|
|
|
- //查询登记设备
|
|
|
+ // 拓元算法
|
|
|
+ // 查询登记设备
|
|
|
DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
|
|
|
Integer status = deviceQueryVO.getStatus();
|
|
|
if (status != null && 1000 == status.intValue()) {
|
|
|
- //未知的设备CPUID,进行登记
|
|
|
+ // 未知的设备CPUID,进行登记
|
|
|
tyApiService.deviceReg(new DeviceRegDTO()
|
|
|
.setCpuId(String.valueOf(deviceId))
|
|
|
.setDeviceNumber(String.valueOf(deviceId))
|
|
@@ -833,7 +889,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
String refMercCode = deviceInfo.getMercCode();
|
|
|
|
|
|
if (BooleanUtil.isFalse(auth.getMercOperate())) {
|
|
|
- //非商户操作
|
|
|
+ // 非商户操作
|
|
|
// 只有解绑后,才能给顶级商户授权
|
|
|
if (refMercId != -1 && refMercId != mercId.intValue()) {
|
|
|
StrBuilder sb = StrBuilder.create();
|
|
@@ -844,20 +900,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
.append(deviceInfo.getMercName())
|
|
|
.append("]绑定,请先进行解绑!")
|
|
|
.toString();
|
|
|
- //非质检商户需要进行判断,质检商户跳过
|
|
|
+ // 非质检商户需要进行判断,质检商户跳过
|
|
|
if (!QA_MERC_CODE.equals(refMercCode)) {
|
|
|
- //已关联别商户
|
|
|
+ // 已关联别商户
|
|
|
return R.fail(errMsg, Boolean.FALSE);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
- //商户操作直接转移给子商户
|
|
|
+ // 商户操作直接转移给子商户
|
|
|
}
|
|
|
|
|
|
- //绑定关系
|
|
|
+ // 绑定关系
|
|
|
deviceInfo.setMercId(mercId).setMercCode(mercCode).setAlgorithmId(algorithmId).setMercName(mercName);
|
|
|
- //标记机器可交易
|
|
|
+ // 标记机器可交易
|
|
|
DeviceStatus deviceStatus = new DeviceStatus()
|
|
|
.setDeviceId(deviceInfo.getDeviceId())
|
|
|
.setIsPay(true);
|
|
@@ -904,13 +960,19 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
private Boolean removeMerDevicesByDeviceIds(DeviceInfoDto.MercDeviceUnBindDto dto, List<DeviceInfo> deviceInfos) {
|
|
|
if (CollUtil.isNotEmpty(deviceInfos)) {
|
|
|
deviceInfos.forEach(deviceInfo -> {
|
|
|
- //回收 到当前操作商户
|
|
|
+ // 回收 到当前操作商户
|
|
|
deviceInfo.setMercId(dto.getMercId());
|
|
|
deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
|
|
|
+ // 清理点位信息
|
|
|
+ deviceInfo.setPlaceId(-1L);
|
|
|
deviceInfo.setMercName(dto.getMercName());
|
|
|
deviceInfo.setMercCode(dto.getMercCode());
|
|
|
});
|
|
|
- //批量更新
|
|
|
+
|
|
|
+ // 用户设备关联表清理
|
|
|
+ List<Long> deviceIds = deviceInfos.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
|
|
|
+ R.feignCheckData(mercService.unBindSubMercDevice(new MiniDeviceInfoDto.MercDeviceUnBindDto().setDeviceIds(deviceIds)));
|
|
|
+ // 批量更新
|
|
|
return updateBatchById(deviceInfos);
|
|
|
}
|
|
|
|
|
@@ -928,13 +990,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
MercDto.Vo mercCheck = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setMercCode(QA_MERC_CODE)));
|
|
|
if (CollUtil.isNotEmpty(deviceInfos)) {
|
|
|
deviceInfos.forEach(deviceInfo -> {
|
|
|
- //回收
|
|
|
+ // 回收
|
|
|
deviceInfo.setMercId(mercCheck.getId());
|
|
|
deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
|
|
|
deviceInfo.setMercName(mercCheck.getName());
|
|
|
deviceInfo.setMercCode(QA_MERC_CODE);
|
|
|
+ // 清理点位
|
|
|
+ deviceInfo.setPlaceId(-1L);
|
|
|
});
|
|
|
- //批量更新
|
|
|
+ // 批量更新
|
|
|
return updateBatchById(deviceInfos);
|
|
|
}
|
|
|
|
|
@@ -951,7 +1015,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
private Boolean removeMerRefDevices(List<DeviceInfo> deviceInfos, Long parentId) {
|
|
|
if (CollUtil.isNotEmpty(deviceInfos) && parentId != null) {
|
|
|
deviceInfos.forEach(deviceInfo -> {
|
|
|
- //非顶级兴元商户,解绑后,机器归父商户
|
|
|
+ // 非顶级兴元商户,解绑后,机器归父商户
|
|
|
if (parentId != 1) {
|
|
|
MercDto.Vo mercParent = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setId(parentId)));
|
|
|
if (mercParent != null) {
|
|
@@ -965,7 +1029,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- //一级商户,解绑后,直接释放
|
|
|
+ // 一级商户,解绑后,直接释放
|
|
|
if (parentId == 0) {
|
|
|
MercDto.Vo mercCheck = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setMercCode(QA_MERC_CODE)));
|
|
|
if (mercCheck != null) {
|
|
@@ -981,7 +1045,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- //批量更新
|
|
|
+ // 批量更新
|
|
|
return updateBatchById(deviceInfos);
|
|
|
}
|
|
|
|
|
@@ -1014,7 +1078,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
// queryWrapper.in(LambdaUtils.getUnderlineCaseName(DeviceInfo::getPlaceLineId), placeLineIds);
|
|
|
// }
|
|
|
|
|
|
- //fixed
|
|
|
+ // fixed
|
|
|
if (StrUtil.isNotEmpty(deviceSearch)) {
|
|
|
queryWrapper.and(wrapper -> wrapper.likeRight(LambdaUtils.getUnderlineCaseName(DeviceInfo::getDeviceName), deviceSearch).or()
|
|
|
.eq(LambdaUtils.getUnderlineCaseName(DeviceInfo::getDeviceId), deviceSearch));
|
|
@@ -1048,7 +1112,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
public R<DeviceInfoDto.MercHomeStatisticalVO> mercHomeStatistical(DeviceInfoDto.MercHomeQueryDTO dto) {
|
|
|
Long mercId = dto.getMercId();
|
|
|
List<Long> myDeviceIds = dto.getMyDeviceIds();
|
|
|
- //初始化数据
|
|
|
+ // 初始化数据
|
|
|
DeviceInfoDto.MercHomeStatisticalVO mercHomeStatisticalVO = new DeviceInfoDto.MercHomeStatisticalVO()
|
|
|
.setClosedNum(0).setOfflineNum(0)
|
|
|
.setOnlineNum(0).setOperatingNum(0).setNeedToFillNum(0);
|
|
@@ -1062,9 +1126,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
|
|
|
|
|
|
- //在线、离线
|
|
|
+ // 在线、离线
|
|
|
List<DeviceStatus> deviceStatuses = deviceStatusService.listByIds(myDeviceIds);
|
|
|
- //分组统计
|
|
|
+ // 分组统计
|
|
|
Map<Integer, Long> countNetstateMap = deviceStatuses.stream().collect(Collectors
|
|
|
.groupingBy(DeviceStatus::getNetState, Collectors.counting()));
|
|
|
Integer onlineDictValue = SysDictUtils.getValue(EnumDeviceOnlineStatus.Code.CODE.getCode(), EnumDeviceOnlineStatus.CONNECTED.getCode(), Integer.class);
|
|
@@ -1075,20 +1139,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
mercHomeStatisticalVO.setOnlineNum(onlineNum);
|
|
|
mercHomeStatisticalVO.setOfflineNum(offlineNum);
|
|
|
|
|
|
- //锁机、未锁机
|
|
|
+ // 锁机、未锁机
|
|
|
// Map<Integer, Long> countLockLstateMap = deviceStatuses.stream().collect(Collectors
|
|
|
// .groupingBy(DeviceStatus::getLockStateL, Collectors.counting()));
|
|
|
// Long lockLStateNum = countLockLstateMap.get(DeviceLockState.LOCK.getCode());
|
|
|
// Long unLockLStateNum = countLockLstateMap.get(DeviceLockState.UN_LOCK.getCode());
|
|
|
Map<Integer, Long> countLockLstateMap = mercDevices.stream().collect(Collectors
|
|
|
.groupingBy(DeviceInfo::getBusyState, Collectors.counting()));
|
|
|
- //运营
|
|
|
+ // 运营
|
|
|
Long operatingNum = countLockLstateMap.get(DeviceBusySateType.OPERATING.getCode());
|
|
|
- //停运
|
|
|
+ // 停运
|
|
|
Long suspendedNum = countLockLstateMap.get(DeviceBusySateType.SUSPENDED.getCode());
|
|
|
mercHomeStatisticalVO.setOperatingNum(operatingNum == null ? 0 : operatingNum.intValue());
|
|
|
mercHomeStatisticalVO.setClosedNum(suspendedNum == null ? 0 : suspendedNum.intValue());
|
|
|
- //待补货
|
|
|
+ // 待补货
|
|
|
Integer deviceNum = R.feignCheckData(goodsDeviceService.countOutOfStockDevice(new GoodsDeviceDto.CountOutOfStockDevice().setMercId(mercId).setDeviceIds(myDeviceIds)));
|
|
|
mercHomeStatisticalVO.setNeedToFillNum(deviceNum);
|
|
|
return R.ok(mercHomeStatisticalVO);
|
|
@@ -1102,7 +1166,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
String deviceName = dto.getDeviceName();
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
List<Long> searchPlaceIdList = new ArrayList<>();
|
|
|
- //根据管理员名字查询点位ID列表
|
|
|
+ // 根据管理员名字查询点位ID列表
|
|
|
if (Emptys.check(dto.getAdminName())) {
|
|
|
MercPlaceDto.ListDto placeDto = new MercPlaceDto.ListDto();
|
|
|
placeDto.setMercId(mercId).setAdminName(dto.getAdminName());
|
|
@@ -1122,7 +1186,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
List<Long> searchDeviceIds = new ArrayList<>();
|
|
|
if (StrUtil.isNotEmpty(searchKey) || StrUtil.isNotEmpty(dto.getAdminName())) {
|
|
|
- //名称或者编号搜索设备
|
|
|
+ // 名称或者编号搜索设备
|
|
|
LambdaQueryWrapper<DeviceInfo> deviceLqw = Wrappers.<DeviceInfo>lambdaQuery()
|
|
|
.eq(DeviceInfo::getMercId, mercId)
|
|
|
.in(Emptys.check(searchPlaceIdList), DeviceInfo::getPlaceId, searchPlaceIdList);
|
|
@@ -1147,7 +1211,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Integer busyStatus = dto.getBusyStatus();
|
|
|
Integer onlineStatus = dto.getOnlineStatus();
|
|
|
Integer deviceType = dto.getDeviceType();
|
|
|
- //条件查询 在线状态,运营状态,设备类型,
|
|
|
+ // 条件查询 在线状态,运营状态,设备类型,
|
|
|
List<Long> deviceIdList = new ArrayList<>();
|
|
|
if (deviceId != null && myDeviceIds.indexOf(deviceId) > 0) {
|
|
|
deviceIdList.add(deviceId);
|
|
@@ -1168,7 +1232,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
queryDeviceIds.add(id);
|
|
|
}
|
|
|
}
|
|
|
- //无符合权限的搜索设备,返空
|
|
|
+ // 无符合权限的搜索设备,返空
|
|
|
if (CollUtil.isEmpty(queryDeviceIds)) {
|
|
|
return R.ok(new ArrayList<>());
|
|
|
} else {
|
|
@@ -1202,7 +1266,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
|
|
|
|
|
|
LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
- //非质检商户才需要激活
|
|
|
+ // 非质检商户才需要激活
|
|
|
lqw.eq(!isQa, DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
|
|
|
lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
|
|
|
lqw.eq(busyStatus != null, DeviceInfo::getBusyState, busyStatus);
|
|
@@ -1210,15 +1274,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
lqw.in(CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
|
|
|
lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName).orderByAsc(true, DeviceInfo::getDeviceName, DeviceInfo::getDeviceId);
|
|
|
List<DeviceInfoDto.Vo> deviceInfoList = copy(DeviceInfoDto.Vo.class, this.list(lqw));
|
|
|
- //根据点位ID查询管理员名字
|
|
|
+ // 根据点位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();
|
|
|
if (Emptys.check(mercPlaceList)) {
|
|
|
- //Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
|
|
|
+ // Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
|
|
|
Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(HashMap::new, (map, item) -> map.put(item.getId(), item.getAdminName()), HashMap::putAll);
|
|
|
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());
|
|
|
List<Long> dIds = deviceInfoList.stream().map(DeviceInfoDto.Vo::getDeviceId).distinct().collect(Collectors.toList());
|
|
@@ -1228,7 +1292,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
deviceSysInfoMap = deviceSysList.stream().collect(Collectors.toMap(DeviceSysinfoDto.Vo::getDeviceId, i -> i));
|
|
|
}
|
|
|
|
|
|
- //根据管理员名字分组
|
|
|
+ // 根据管理员名字分组
|
|
|
Map<String, List<DeviceInfoDto.Vo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.Vo::getAdminName));
|
|
|
|
|
|
DateTime date = DateTime.now();
|
|
@@ -1237,18 +1301,18 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
for (String adminName : adminNameList) {
|
|
|
DeviceInfoDto.MercHomeListVO vo = new DeviceInfoDto.MercHomeListVO();
|
|
|
vo.setAdminName(adminName);
|
|
|
- //区域下的设备列表
|
|
|
+ // 区域下的设备列表
|
|
|
List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = BeanUtil.copyToList(deviceMap.get(adminName), DeviceInfoDto.MercHomeDeviceVo.class);
|
|
|
vo.setDeviceNum(deviceInfos.size());
|
|
|
if (CollUtil.isEmpty(deviceInfos)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- //设备销售统计
|
|
|
+ // 设备销售统计
|
|
|
List<Long> deviceIds = deviceInfos.stream().map(DeviceInfoDto.MercHomeDeviceVo::getDeviceId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
- //设备状态查询
|
|
|
+ // 设备状态查询
|
|
|
List<DeviceStatusDto.Vo> deviceStatusList = deviceStatusService.list(new DeviceStatusDto.SelectList().setDeviceIds(deviceIds)).getData();
|
|
|
Map<Long, DeviceStatusDto.Vo> datdeviceStatusMap = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(deviceStatusList)) {
|
|
@@ -1262,10 +1326,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
for (DeviceInfoDto.MercHomeDeviceVo device : deviceInfos) {
|
|
|
Long dId = device.getDeviceId();
|
|
|
- //设备类型 反显
|
|
|
+ // 设备类型 反显
|
|
|
SysDictRedis dictDeviceType = SysDictUtils.get(DictConsts.DEVICE_TYPE, String.valueOf(device.getDeviceType()));
|
|
|
device.setDeviceTypeName(dictDeviceType.getMsg());
|
|
|
- //运营状态 反显
|
|
|
+ // 运营状态 反显
|
|
|
SysDictRedis dictBusyState = SysDictUtils.get(DictConsts.DEVICE_BUSY_STATUS, String.valueOf(device.getBusyState()));
|
|
|
device.setBusyStateName(dictBusyState.getMsg());
|
|
|
|
|
@@ -1274,10 +1338,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
CountDto.OrderByCreateTimeAndMercId orderByCreateTimeAndMercId = new CountDto.OrderByCreateTimeAndMercId()
|
|
|
.setMerdId(mercId).setBeginTime(start).setEndTime(end).setDeviceIds(CollUtil.newArrayList(dId));
|
|
|
log.info("设备订单统计:{}", JSONUtil.toJsonPrettyStr(orderByCreateTimeAndMercId));
|
|
|
- //完成订单
|
|
|
+ // 完成订单
|
|
|
CountDto.SuccessVo successVo = R.feignCheckData(countApiService.orderBySuccess(orderByCreateTimeAndMercId));
|
|
|
|
|
|
- //今日销售、库存情况 反显
|
|
|
+ // 今日销售、库存情况 反显
|
|
|
device.setDayOrderNum(successVo != null ? successVo.getOrdersSize() : zero);
|
|
|
device.setDaySalesPrice(successVo != null ? successVo.getOrderTotalMoney() : zero);
|
|
|
DeviceStatusDto.Vo deviceStatus = datdeviceStatusMap.get(device.getDeviceId());
|
|
@@ -1288,7 +1352,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
device.setFillNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum());
|
|
|
}
|
|
|
}
|
|
|
- //温控仪 反显
|
|
|
+ // 温控仪 反显
|
|
|
DeviceSysinfoDto.Vo dSysInfo = deviceSysInfoMap.get(dId);
|
|
|
if (dSysInfo == null) {
|
|
|
device.setIsHaveTemp(false);
|
|
@@ -1296,14 +1360,14 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
device.setIsHaveTemp(BooleanUtil.isTrue(dSysInfo.getIsHaveTemp()));
|
|
|
}
|
|
|
|
|
|
- //算法類型
|
|
|
+ // 算法類型
|
|
|
Long algorithmId = device.getAlgorithmId();
|
|
|
if (algorithmId != null) {
|
|
|
String name = algorithmListMap.get(algorithmId);
|
|
|
device.setAlgorithmAlias(name);
|
|
|
}
|
|
|
|
|
|
- //联网状态
|
|
|
+ // 联网状态
|
|
|
Integer netState = deviceStatus == null ? DeviceNetSateType.DISCONNECT.getCode() : deviceStatus.getNetState();
|
|
|
device.setNetState(netState);
|
|
|
if (netState == null) {
|
|
@@ -1320,7 +1384,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
device.setDeviceStateR(deviceStateR);
|
|
|
Boolean isUseBattery = deviceStatus.getIsUseBattery();
|
|
|
if (BooleanUtil.isTrue(isUseBattery)) {
|
|
|
- //使用电池。即断电状态
|
|
|
+ // 使用电池。即断电状态
|
|
|
device.setSysPower(2);
|
|
|
} else {
|
|
|
device.setSysPower(1);
|
|
@@ -1335,7 +1399,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
}
|
|
|
|
|
|
- //名称排序
|
|
|
+ // 名称排序
|
|
|
if (CollUtil.isNotEmpty(deviceInfos)) {
|
|
|
deviceInfos = ListUtil.sortByProperty(deviceInfos, LambdaUtils.getProperty(DeviceInfoDto.MercHomeDeviceVo::getDeviceName));
|
|
|
deviceInfos = ListUtil.sortByProperty(deviceInfos, LambdaUtils.getProperty(DeviceInfoDto.MercHomeDeviceVo::getDeviceId));
|
|
@@ -1393,16 +1457,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@Override
|
|
|
public R<PageBean<DeviceInfoDto.MerHomeSearchVO>> mercDeviceSearchPage(@RequestBody DeviceInfoDto.Page page) {
|
|
|
PageBean<DeviceInfoDto.MerHomeSearchVO> pageData = new PageBean<>();
|
|
|
- //小程序独有查询字段 缺货状态:stockStatus ,是否查故障设备:fault
|
|
|
+ // 小程序独有查询字段 缺货状态:stockStatus ,是否查故障设备:fault
|
|
|
Boolean fault = page.getFault();
|
|
|
Long mercId = page.getMercId();
|
|
|
List<Long> myDeviceIds = page.getMyDeviceIds();
|
|
|
if (CollUtil.isEmpty(myDeviceIds)) {
|
|
|
- //无设备
|
|
|
+ // 无设备
|
|
|
return R.ok(pageData);
|
|
|
}
|
|
|
if (BooleanUtil.isTrue(fault)) {
|
|
|
- //查询故障设备
|
|
|
+ // 查询故障设备
|
|
|
List<DeviceEventMsg> deviceEventMsgs = deviceEventMsgService.list(Wrappers.<DeviceEventMsg>lambdaQuery()
|
|
|
.eq(mercId != null, DeviceEventMsg::getMercId, page.getMercId())
|
|
|
.in(DeviceEventMsg::getDeviceId, myDeviceIds));
|
|
@@ -1427,12 +1491,12 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
List<Long> deviceIds = records.stream().map(DeviceInfoDto.Vo2::getDeviceId).collect(Collectors.toList());
|
|
|
String type = EnumDeviceDataType.DAY.getCode();
|
|
|
String todayDate = DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN);
|
|
|
- //查询当天
|
|
|
+ // 查询当天
|
|
|
DeviceDataDto.ListDTO dto = new DeviceDataDto.ListDTO()
|
|
|
.setDeviceIds(deviceIds).setType(type).setDateValue(Integer.valueOf(todayDate)).setMercId(mercId);
|
|
|
List<DeviceDataDto.Vo> deviceDataList = deviceDataService.list(dto);
|
|
|
Map<Long, DeviceDataDto.Vo> dataMap = MapUtil.newHashMap();
|
|
|
- //统计数据反显
|
|
|
+ // 统计数据反显
|
|
|
if (CollUtil.isNotEmpty(deviceDataList)) {
|
|
|
dataMap = deviceDataList.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDeviceId, d -> d));
|
|
|
}
|
|
@@ -1441,7 +1505,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Long deviceId = v.getDeviceId();
|
|
|
DeviceDataDto.Vo vo = dataMap.get(deviceId);
|
|
|
if (vo != null) {
|
|
|
- //今日订单数
|
|
|
+ // 今日订单数
|
|
|
v.setDayOrderNum(vo != null ? vo.getSalesCount() : 0);
|
|
|
v.setDaySalesPrice(vo != null ? vo.getSalesMoney() : 0);
|
|
|
BeanUtil.copyProperties(vo, merHomeSearchVO);
|
|
@@ -1479,19 +1543,19 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Integer type = dto.getType();
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
- //经营数据
|
|
|
+ // 经营数据
|
|
|
return R.ok(dataCount1(dto));
|
|
|
case 2:
|
|
|
- //经营图表
|
|
|
+ // 经营图表
|
|
|
return R.ok(dataCount2(dto));
|
|
|
case 3:
|
|
|
- //温度图表
|
|
|
+ // 温度图表
|
|
|
return R.ok(dataCount3(dto));
|
|
|
case 4:
|
|
|
- //信号图表
|
|
|
+ // 信号图表
|
|
|
return R.ok(dataCount4(dto));
|
|
|
case 5:
|
|
|
- //商品管理
|
|
|
+ // 商品管理
|
|
|
return R.ok(dataCount5(dto));
|
|
|
default:
|
|
|
break;
|
|
@@ -1509,7 +1573,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
Long mercId = dto.getMercId();
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
- //当天
|
|
|
+ // 当天
|
|
|
|
|
|
|
|
|
DateTime date = DateTime.now();
|
|
@@ -1519,7 +1583,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
CountDto.OrderByCreateTimeAndMercId orderByCreateTimeAndMercId = new CountDto.OrderByCreateTimeAndMercId()
|
|
|
.setMerdId(mercId).setBeginTime(start).setEndTime(end).setDeviceIds(deviceIds);
|
|
|
|
|
|
- //完成订单
|
|
|
+ // 完成订单
|
|
|
CountDto.SuccessVo successVo = R.feignCheckData(countApiService.orderBySuccess(orderByCreateTimeAndMercId));
|
|
|
|
|
|
DeviceDataDto.Vo dayData = new DeviceDataDto.Vo();
|
|
@@ -1530,16 +1594,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
|
|
|
|
|
|
- //当月
|
|
|
+ // 当月
|
|
|
DeviceDataDto.Vo monthData = new DeviceDataDto.Vo();
|
|
|
|
|
|
- //月度统计
|
|
|
+ // 月度统计
|
|
|
DateTime startM = DateUtil.beginOfMonth(date);
|
|
|
DateTime endM = DateUtil.endOfMonth(date);
|
|
|
|
|
|
CountDto.OrderByCreateTimeAndMercId monthOrder = new CountDto.OrderByCreateTimeAndMercId()
|
|
|
.setMerdId(mercId).setBeginTime(startM).setEndTime(endM).setDeviceIds(deviceIds);
|
|
|
- //完成订单
|
|
|
+ // 完成订单
|
|
|
CountDto.SuccessVo successVoM = R.feignCheckData(countApiService.orderBySuccess(monthOrder));
|
|
|
|
|
|
|
|
@@ -1561,7 +1625,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
*/
|
|
|
private DeviceInfoDto.DeviceDataCountVO dataCount2(DeviceInfoDto.DeviceDataCountDTO dto) {
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
- //近一个月 (销售额,订单数,退款金额,退款数)
|
|
|
+ // 近一个月 (销售额,订单数,退款金额,退款数)
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
DeviceInfoDto.BusinessChart businessChart = new DeviceInfoDto.BusinessChart();
|
|
|
List<String> categories = DataTime.dayListByLastDay(30);
|
|
@@ -1579,7 +1643,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
- //每天的数据
|
|
|
+ // 每天的数据
|
|
|
Map<Integer, DeviceDataDto.Vo> dataDayMap = listByDay.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDateValue, i -> i));
|
|
|
|
|
|
List<DeviceInfoDto.MyChartSeries3> series = new ArrayList<>();
|
|
@@ -1587,12 +1651,12 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
String[] names = {"销售额", "订单数", "退款金额", "退款数"};
|
|
|
for (int i = 0; i < names.length; i++) {
|
|
|
DeviceInfoDto.MyChartSeries3 myChartSeries = new DeviceInfoDto.MyChartSeries3();
|
|
|
- //某个类型每天的数据
|
|
|
+ // 某个类型每天的数据
|
|
|
List<String> data = new ArrayList<>();
|
|
|
if (i == 0) {
|
|
|
- //销售额
|
|
|
+ // 销售额
|
|
|
dateList.forEach(d -> {
|
|
|
- //每日数据填充
|
|
|
+ // 每日数据填充
|
|
|
DeviceDataDto.Vo deviceData = dataDayMap.get(d);
|
|
|
|
|
|
if (deviceData == null) {
|
|
@@ -1604,9 +1668,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
});
|
|
|
} else if (i == 1) {
|
|
|
- //订单数
|
|
|
+ // 订单数
|
|
|
dateList.forEach(d -> {
|
|
|
- //每日数据填充
|
|
|
+ // 每日数据填充
|
|
|
DeviceDataDto.Vo deviceData = dataDayMap.get(d);
|
|
|
String value = "0";
|
|
|
if (deviceData == null) {
|
|
@@ -1618,9 +1682,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
});
|
|
|
} else if (i == 2) {
|
|
|
- //退款金额
|
|
|
+ // 退款金额
|
|
|
dateList.forEach(d -> {
|
|
|
- //每日数据填充
|
|
|
+ // 每日数据填充
|
|
|
DeviceDataDto.Vo deviceData = dataDayMap.get(d);
|
|
|
if (deviceData == null) {
|
|
|
data.add(String.valueOf(BigDecimal.ZERO));
|
|
@@ -1632,9 +1696,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
});
|
|
|
} else if (i == 3) {
|
|
|
- //退款数
|
|
|
+ // 退款数
|
|
|
dateList.forEach(d -> {
|
|
|
- //每日数据填充
|
|
|
+ // 每日数据填充
|
|
|
DeviceDataDto.Vo deviceData = dataDayMap.get(d);
|
|
|
if (deviceData == null) {
|
|
|
data.add("0");
|
|
@@ -1668,7 +1732,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
String startTime = choosDate + " 00:00:00";
|
|
|
String endTime = choosDate + " 23:59:59";
|
|
|
- //查询选定日期的温度数据
|
|
|
+ // 查询选定日期的温度数据
|
|
|
List<DeviceTempRecords> deviceTempRecords = deviceTempRecordsService.list(Wrappers.<DeviceTempRecords>lambdaQuery()
|
|
|
.eq(DeviceTempRecords::getDeviceId, deviceId).between(DeviceTempRecords::getCreateTime, startTime, endTime)
|
|
|
.orderBy(true, true, DeviceTempRecords::getCreateTime));
|
|
@@ -1715,7 +1779,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
String startTime = choosDate + " 00:00:00";
|
|
|
String endTime = choosDate + " 23:59:59";
|
|
|
- //查询选定日期的温度数据
|
|
|
+ // 查询选定日期的温度数据
|
|
|
List<DeviceNetRecord> deviceNetRecords = deviceNetRecordService.list(Wrappers.<DeviceNetRecord>lambdaQuery()
|
|
|
.eq(DeviceNetRecord::getDeviceId, deviceId).between(DeviceNetRecord::getCreateTime, startTime, endTime)
|
|
|
.orderBy(true, true, DeviceNetRecord::getCreateTime));
|
|
@@ -1758,8 +1822,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
DeviceInfoDto.GoodsData goodsData = new DeviceInfoDto.GoodsData();
|
|
|
- //在售商品种类
|
|
|
- //根据设备ID查商品id
|
|
|
+ // 在售商品种类
|
|
|
+ // 根据设备ID查商品id
|
|
|
GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
|
|
|
selectList.setDeviceIds(CollUtil.newArrayList(deviceId));
|
|
|
selectList.setMercId(dto.getMercId());
|