|
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.text.StrBuilder;
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
@@ -28,10 +29,7 @@ import com.xy.mapper.DeviceInfoMapper;
|
|
|
import com.xy.mapper.entity.DeviceInfoQueryPage;
|
|
|
import com.xy.util.ExcelUtils;
|
|
|
import com.xy.utils.*;
|
|
|
-import com.xy.utils.enums.DeviceActiveStateEnum;
|
|
|
-import com.xy.utils.enums.DeviceNetSateType;
|
|
|
-import com.xy.utils.enums.DictEnum;
|
|
|
-import com.xy.utils.enums.DictSonEnum;
|
|
|
+import com.xy.utils.enums.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import jodd.introspector.MapperFunction;
|
|
@@ -221,7 +219,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@ApiOperation("修改")
|
|
|
@PostMapping("update")
|
|
|
public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
|
|
|
- DeviceInfo deviceInfo = copy(DeviceInfo.class, update);
|
|
|
+ DeviceInfo deviceInfo = copy(DeviceInfo.class, update)
|
|
|
+ .setUpdateTime(LocalDateTime.now());
|
|
|
updateById(deviceInfo);
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -229,8 +228,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
@ApiOperation("批量修改")
|
|
|
@PostMapping("updateBatch")
|
|
|
public R updateBatch(@RequestBody List<DeviceInfoDto.Update> updates) {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
List<DeviceInfo> deviceInfos = new ArrayList<>(updates.size());
|
|
|
- updates.forEach(update -> deviceInfos.add(copy(DeviceInfo.class, update)));
|
|
|
+ updates.forEach(update -> deviceInfos.add(copy(DeviceInfo.class, update).setUpdateTime(now)));
|
|
|
updateBatchById(deviceInfos);
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -531,20 +531,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
mercHomeStatisticalVO.setOnlineNum(onlineNum);
|
|
|
mercHomeStatisticalVO.setOfflineNum(offlineNum);
|
|
|
|
|
|
-
|
|
|
- //运营、停业
|
|
|
- Map<Integer, Long> countBusyStateMap = mercDevices.stream().collect(Collectors
|
|
|
- .groupingBy(DeviceInfo::getBusyState, Collectors.counting()));
|
|
|
- Integer busyState1 = SysDictUtils.getValue(DictEnum.DEVICE_BUSY_STATUS.getKey(), DictSonEnum.DEVICE_BUSY_STATUS1.getKey(), Integer.class);
|
|
|
- Integer busyState2 = SysDictUtils.getValue(DictEnum.DEVICE_BUSY_STATUS.getKey(), DictSonEnum.DEVICE_BUSY_STATUS2.getKey(), Integer.class);
|
|
|
- int operatingNum = countBusyStateMap.get(busyState1) == null ? 0 : countBusyStateMap.get(busyState1).intValue();
|
|
|
- int closedNum = countBusyStateMap.get(busyState2) == null ? 0 : countBusyStateMap.get(busyState2).intValue();
|
|
|
- mercHomeStatisticalVO.setOperatingNum(operatingNum);
|
|
|
- mercHomeStatisticalVO.setClosedNum(closedNum);
|
|
|
-
|
|
|
+ //锁机、未锁机
|
|
|
+ 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());
|
|
|
+ mercHomeStatisticalVO.setOperatingNum(unLockLStateNum == null ? 0 : unLockLStateNum.intValue());
|
|
|
+ mercHomeStatisticalVO.setClosedNum(lockLStateNum == null ? 0 : lockLStateNum.intValue());
|
|
|
//待补货
|
|
|
- //TODO: 此逻辑需要确认
|
|
|
-
|
|
|
+ Integer deviceNum = R.feignCheckData(goodsDeviceService.countOutOfStockDevice(new GoodsDeviceDto.CountOutOfStockDevice().setMercId(mercId)));
|
|
|
+ mercHomeStatisticalVO.setNeedToFillNum(deviceNum);
|
|
|
return R.ok(mercHomeStatisticalVO);
|
|
|
}
|
|
|
|
|
@@ -636,6 +632,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
device.setNetStateName(DeviceNetSateType.getEnumByCode(deviceStatus.getNetState()).getDescription());
|
|
|
}
|
|
|
|
|
|
+ Integer deviceStateL = deviceStatus.getLockStateL();
|
|
|
+ Integer deviceStateR = deviceStatus.getLockStateR();
|
|
|
+ device.setDeviceStateL(deviceStateL);
|
|
|
+ device.setDeviceStateR(deviceStateR);
|
|
|
+ DeviceLockState deviceLockStateL = DeviceLockState.getEnumByCode(deviceStateL);
|
|
|
+ DeviceLockState deviceLockStateR = DeviceLockState.getEnumByCode(deviceStateR);
|
|
|
+ device.setDeviceStateRName(deviceLockStateR == null ? "未知" : deviceLockStateR.getDescription());
|
|
|
+ device.setDeviceStateLName(deviceLockStateL == null ? "未知" : deviceLockStateL.getDescription());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//在线排序
|
|
@@ -673,7 +678,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
//小程序独有查询字段 缺货状态:stockStatus ,是否查故障设备:fault
|
|
|
Boolean fault = page.getFault();
|
|
|
Long mercId = page.getMercId();
|
|
|
- List<Long> myDeviceIds = page.getDeviceIdList();
|
|
|
+ List<Long> myDeviceIds = page.getMyDeviceIds();
|
|
|
if (CollUtil.isEmpty(myDeviceIds)) {
|
|
|
//无设备
|
|
|
return R.ok(pageData);
|
|
@@ -698,32 +703,46 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
return R.ok(pageData);
|
|
|
}
|
|
|
List<DeviceInfoDto.MerHomeSearchVO> merHomeSearchRecords = new ArrayList<>();
|
|
|
- List<Long> deviceIds = records.stream().map(DeviceInfoDto.Vo2::getDeviceId).collect(Collectors.toList());
|
|
|
- String type = SysDictUtils.getValue(DictEnum.DEVICE_DATA_TYPE.getKey(), DictSonEnum.DEVICE_DATA_TYPE_DAY.getKey(), String.class);
|
|
|
- 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);
|
|
|
+
|
|
|
BeanUtil.copyProperties(pageBean, pageData);
|
|
|
- List<DeviceDataDto.Vo> deviceDataList = deviceDataService.list(dto);
|
|
|
- if (CollUtil.isNotEmpty(deviceDataList)) {
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
+ List<Long> deviceIds = records.stream().map(DeviceInfoDto.Vo2::getDeviceId).collect(Collectors.toList());
|
|
|
+ String type = SysDictUtils.getValue(DictEnum.DEVICE_DATA_TYPE.getKey(), DictSonEnum.DEVICE_DATA_TYPE_DAY.getKey(), String.class);
|
|
|
+ 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();
|
|
|
//统计数据反显
|
|
|
- Map<Long, DeviceDataDto.Vo> dataMap = deviceDataList.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDeviceId, d -> d));
|
|
|
- records.forEach(v -> {
|
|
|
+ if (CollUtil.isNotEmpty(deviceDataList)) {
|
|
|
+ dataMap = deviceDataList.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDeviceId, d -> d));
|
|
|
+ }
|
|
|
+ for (DeviceInfoDto.Vo2 v : records) {
|
|
|
DeviceInfoDto.MerHomeSearchVO merHomeSearchVO = new DeviceInfoDto.MerHomeSearchVO();
|
|
|
Long deviceId = v.getDeviceId();
|
|
|
DeviceDataDto.Vo vo = dataMap.get(deviceId);
|
|
|
- //今日订单数
|
|
|
- v.setDayOrderNum(vo != null ? vo.getSalesCount() : 0);
|
|
|
- v.setDaySalesPrice(vo != null ? vo.getSalesMoney() : 0);
|
|
|
+ if (vo != null) {
|
|
|
+ //今日订单数
|
|
|
+ v.setDayOrderNum(vo != null ? vo.getSalesCount() : 0);
|
|
|
+ v.setDaySalesPrice(vo != null ? vo.getSalesMoney() : 0);
|
|
|
+ BeanUtil.copyProperties(vo, merHomeSearchVO);
|
|
|
+ }
|
|
|
DeviceSysinfoDto.Vo deviceSysinfo = v.getDeviceSysinfo();
|
|
|
DeviceStatusDto.Vo deviceStatus = v.getDeviceStatus();
|
|
|
- BeanUtil.copyProperties(vo, merHomeSearchVO);
|
|
|
merHomeSearchVO.setAppUpmVersion(deviceSysinfo.getAppUpmVersion());
|
|
|
merHomeSearchVO.setTempValue(deviceStatus.getTempValue());
|
|
|
merHomeSearchVO.setNetDbm(deviceStatus.getNetDbm());
|
|
|
+ Integer deviceStateL = deviceStatus.getLockStateL();
|
|
|
+ Integer deviceStateR = deviceStatus.getLockStateR();
|
|
|
+ merHomeSearchVO.setDeviceStateL(deviceStateL);
|
|
|
+ merHomeSearchVO.setDeviceStateR(deviceStateR);
|
|
|
+ DeviceLockState deviceLockStateL = DeviceLockState.getEnumByCode(deviceStateL);
|
|
|
+ DeviceLockState deviceLockStateR = DeviceLockState.getEnumByCode(deviceStateR);
|
|
|
+ merHomeSearchVO.setDeviceStateRName(deviceLockStateR == null ? "未知" : deviceLockStateR.getDescription());
|
|
|
+ merHomeSearchVO.setDeviceStateLName(deviceLockStateL == null ? "未知" : deviceLockStateL.getDescription());
|
|
|
merHomeSearchRecords.add(merHomeSearchVO);
|
|
|
- });
|
|
|
+ }
|
|
|
pageData.setRecords(merHomeSearchRecords);
|
|
|
}
|
|
|
return R.ok(pageData);
|