|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
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.text.StrBuilder;
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
@@ -26,7 +27,6 @@ import com.xy.error.CommRuntimeException;
|
|
|
import com.xy.mapper.DeviceInfoMapper;
|
|
|
import com.xy.mapper.entity.DeviceInfoQueryPage;
|
|
|
import com.xy.util.ExcelUtils;
|
|
|
-import com.xy.util.FileUtils;
|
|
|
import com.xy.utils.*;
|
|
|
import com.xy.utils.enums.DeviceActiveStateEnum;
|
|
|
import com.xy.utils.enums.DeviceNetSateType;
|
|
@@ -87,9 +87,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
private final GoodsService goodsService;
|
|
|
|
|
|
+ private final OrderRefundService refundService;
|
|
|
+
|
|
|
private final String keyPrefix = "device:history:";
|
|
|
|
|
|
- private final FileUtils fileUtils;
|
|
|
|
|
|
@Override
|
|
|
@ApiOperation("对象查询")
|
|
@@ -600,8 +601,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
if (CollUtil.isNotEmpty(deviceStatusList)) {
|
|
|
datdeviceStatusMap = deviceStatusList.stream().collect(Collectors.toMap(DeviceStatusDto.Vo::getDeviceId, d -> d));
|
|
|
}
|
|
|
- List<GoodsDeviceDto.Vo> goodsDeviceList = R.feignCheckData(goodsService.queryGoodsDeviceInfo(new GoodsDto.QueryGoodsDeviceInfo().setDeviceIds(deviceIds)));
|
|
|
- Map<Long, GoodsDeviceDto.Vo> deviceIdGoodsMap = goodsDeviceList.stream().collect(Collectors.toMap(GoodsDeviceDto.Vo::getDeviceId, d -> d));
|
|
|
+ List<GoodsDeviceDto.Vo> goodsDeviceList = R.feignCheckData(goodsService.queryGoodsDeviceInfo(new GoodsDto.QueryGoodsDeviceInfo().setMercId(mercId).setDeviceIds(deviceIds)));
|
|
|
+ Map<Long, List<GoodsDeviceDto.Vo>> deviceIdGoodsMap = goodsDeviceList.stream()
|
|
|
+ .collect(Collectors.groupingBy(GoodsDeviceDto.Vo::getDeviceId));
|
|
|
+
|
|
|
for (DeviceInfoDto.MercHomeDeviceVo device : deviceInfos) {
|
|
|
Long dId = device.getDeviceId();
|
|
|
//设备类型 反显
|
|
@@ -616,9 +619,14 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
device.setDayOrderNum(deviceData != null ? deviceData.getSalesCount() : zero);
|
|
|
device.setDaySalesPrice(deviceData != null ? deviceData.getSalesMoney() : zero);
|
|
|
DeviceStatusDto.Vo deviceStatus = datdeviceStatusMap.get(device.getDeviceId());
|
|
|
- GoodsDeviceDto.Vo goodsDevice = deviceIdGoodsMap.get(dId);
|
|
|
- device.setOnSaleNum(goodsDevice == null ? zero : goodsDevice.getStock());
|
|
|
- device.setFillNum(goodsDevice == null ? zero : goodsDevice.getFillCount());
|
|
|
+ if (CollUtil.isNotEmpty(deviceIdGoodsMap)) {
|
|
|
+ List<GoodsDeviceDto.Vo> goodsDevice = deviceIdGoodsMap.get(dId);
|
|
|
+ if (CollUtil.isNotEmpty(goodsDevice)) {
|
|
|
+ device.setOnSaleNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum());
|
|
|
+ device.setFillNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//联网状态
|
|
|
Integer netState = deviceStatus == null ? DeviceNetSateType.DISCONNECT.getCode() : deviceStatus.getNetState();
|
|
|
device.setNetState(netState);
|
|
@@ -765,8 +773,39 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
//当天
|
|
|
DeviceDataDto.Vo dayData = deviceDataService.getByDay(deviceId, mercId, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN));
|
|
|
+ if (dayData != null) {
|
|
|
+ //今日退款成功订单金额
|
|
|
+ OrderRefundDto.CountByDateVO countByDateVO = R.feignCheckData(
|
|
|
+ refundService.countByDate(new OrderRefundDto.CountByDateDTO()
|
|
|
+ .setDate(DateTime.now())
|
|
|
+ .setMercId(mercId).setDeviceId(deviceId)));
|
|
|
+ Integer hisRefundMoney = countByDateVO.getHisRefundMoney();
|
|
|
+ Integer todayRefundMoney = countByDateVO.getTodayRefundMoney();
|
|
|
+ //今日销售额 (扣除今日的订单的退款金额)
|
|
|
+ if (dayData.getSalesMoney() == null) {
|
|
|
+ dayData.setSalesMoney(0);
|
|
|
+ } else {
|
|
|
+ dayData.setSalesMoney(dayData.getSalesMoney() - todayRefundMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+ dayData.setRefundMoney(hisRefundMoney + todayRefundMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//当月
|
|
|
DeviceDataDto.Vo monthData = deviceDataService.getByMonth(deviceId, mercId, DateUtil.format(new Date(), DatePattern.SIMPLE_MONTH_PATTERN));
|
|
|
+ if (monthData != null) {
|
|
|
+ OrderRefundDto.CountByMonthVO countByMonthVO = R.feignCheckData(refundService.countByMonth(new OrderRefundDto.CountByMonthDTO().setCurMonthDate(DateTime.now()).setMercId(mercId).setDeviceId(deviceId)));
|
|
|
+ Integer hisMonthRefundMoney = countByMonthVO.getHisMonthRefundMoney();
|
|
|
+ Integer monthRefundMoney = countByMonthVO.getMonthRefundMoney();
|
|
|
+ monthData.setRefundMoney(hisMonthRefundMoney + monthRefundMoney);
|
|
|
+ if (monthData.getSalesMoney() == null) {
|
|
|
+ monthData.setSalesMoney(0);
|
|
|
+ } else {
|
|
|
+ monthData.setSalesMoney(monthData.getSalesMoney() - monthRefundMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
vo.setDayBusinessData(copy(DeviceInfoDto.BusinessData.class, dayData));
|
|
|
vo.setMonthBusinessData(copy(DeviceInfoDto.BusinessData.class, monthData));
|
|
|
return vo;
|
|
@@ -977,8 +1016,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
private DeviceInfoDto.DeviceDataCountVO dataCount5(DeviceInfoDto.DeviceDataCountDTO dto) {
|
|
|
Long deviceId = dto.getDeviceId();
|
|
|
DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
|
|
|
- DeviceStatus deviceStatus = deviceStatusService.getById(dto.getDeviceId());
|
|
|
- DeviceInfoDto.GoodsData goodsData = copy(DeviceInfoDto.GoodsData.class, deviceStatus);
|
|
|
+ DeviceInfoDto.GoodsData goodsData = new DeviceInfoDto.GoodsData();
|
|
|
//在售商品种类
|
|
|
//根据设备ID查商品id
|
|
|
GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
|
|
@@ -986,7 +1024,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
selectList.setMercId(dto.getMercId());
|
|
|
R<List<GoodsDeviceDto.Vo>> r = R.feignCheck(goodsDeviceService.list(selectList));
|
|
|
List<GoodsDeviceDto.Vo> goodsDeviceList = r.getData();
|
|
|
- goodsData.setCategoryNum(CollUtil.isNotEmpty(goodsDeviceList) ? goodsDeviceList.size() : 0);
|
|
|
+ Integer stock = 0;
|
|
|
+ Integer afterFillStock = 0;
|
|
|
+ if (CollUtil.isNotEmpty(goodsDeviceList)) {
|
|
|
+ stock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum();
|
|
|
+ afterFillStock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum();
|
|
|
+ }
|
|
|
+ goodsData.setAfterFillStock(afterFillStock);
|
|
|
+ goodsData.setStock(stock);
|
|
|
+ goodsData.setCategoryNum(CollUtil.isNotEmpty(goodsDeviceList) ? goodsDeviceList.size() : new Integer(0));
|
|
|
vo.setGoodsData(goodsData);
|
|
|
return vo;
|
|
|
}
|