|
|
@ -14,10 +14,11 @@ import lombok.extern.log4j.Log4j2; |
|
|
|
import org.springframework.context.annotation.Primary; |
|
|
|
import org.springframework.context.annotation.Primary; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Service("张三") |
|
|
|
@Service |
|
|
|
@Log4j2 |
|
|
|
@Log4j2 |
|
|
|
@AllArgsConstructor |
|
|
|
@AllArgsConstructor |
|
|
|
@Primary |
|
|
|
@Primary |
|
|
@ -30,24 +31,24 @@ public class BillingDataServiceImpl implements IBillingDataService { |
|
|
|
public BillingDataVO getBillingData() { |
|
|
|
public BillingDataVO getBillingData() { |
|
|
|
// 今天的数据
|
|
|
|
// 今天的数据
|
|
|
|
BillingDataInfoVO today = billingDataMapper.getBillingData( |
|
|
|
BillingDataInfoVO today = billingDataMapper.getBillingData( |
|
|
|
DateUtil.format(new Date(), "2024-MM-dd 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "2024-MM-dd 23:59:59") |
|
|
|
DateUtil.format(new Date(), "yyyy-MM-dd 23:59:59") |
|
|
|
); |
|
|
|
); |
|
|
|
// 当月的数据
|
|
|
|
// 当月的数据
|
|
|
|
BillingDataInfoVO month = billingDataMapper.getBillingData( |
|
|
|
BillingDataInfoVO month = billingDataMapper.getBillingData( |
|
|
|
DateUtil.format(new Date(), "2024-MM-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "yyyy-MM-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "2024-MM-31 23:59:59") |
|
|
|
DateUtil.format(new Date(), "yyyy-MM-31 23:59:59") |
|
|
|
); |
|
|
|
); |
|
|
|
// 年的数据
|
|
|
|
// 年的数据
|
|
|
|
BillingDataInfoVO year = billingDataMapper.getBillingData( |
|
|
|
BillingDataInfoVO year = billingDataMapper.getBillingData( |
|
|
|
DateUtil.format(new Date(), "2024-01-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "yyyy-01-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "2024-12-31 23:59:59") |
|
|
|
DateUtil.format(new Date(), "yyyy-12-31 23:59:59") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
BillingDataVO billingDataVO = new BillingDataVO(); |
|
|
|
BillingDataVO billingDataVO = new BillingDataVO(); |
|
|
|
billingDataVO.setToday(today); |
|
|
|
billingDataVO.setToday(today == null ? new BillingDataInfoVO() : today); |
|
|
|
billingDataVO.setMonth(month); |
|
|
|
billingDataVO.setMonth(month == null ? new BillingDataInfoVO() : month); |
|
|
|
billingDataVO.setYear(year); |
|
|
|
billingDataVO.setYear(year == null ? new BillingDataInfoVO() : year); |
|
|
|
|
|
|
|
|
|
|
|
return billingDataVO; |
|
|
|
return billingDataVO; |
|
|
|
} |
|
|
|
} |
|
|
@ -55,44 +56,56 @@ public class BillingDataServiceImpl implements IBillingDataService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<WarehouseBillingDataVO> getWarehouseBillingData() { |
|
|
|
public List<WarehouseBillingDataVO> getWarehouseBillingData() { |
|
|
|
List<WarehouseInfoVO> warehouselist = mapWarehouseMapper.warehouselist(); |
|
|
|
List<WarehouseInfoVO> warehouselist = mapWarehouseMapper.warehouselist(); |
|
|
|
// List<WarehouseBillingDataVO> warehouseBillingData = billingDataMapper.getWarehouseBillingData(
|
|
|
|
|
|
|
|
// DateUtil.format(new Date(), "yyyy-01-01 00:00:00"),
|
|
|
|
|
|
|
|
// DateUtil.format(new Date(), "yyyy-12-31 23:59:59")
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<WarehouseBillingDataVO> warehouseBillingData = billingDataMapper.getWarehouseBillingData( |
|
|
|
List<WarehouseBillingDataVO> warehouseBillingData = billingDataMapper.getWarehouseBillingData( |
|
|
|
DateUtil.format(new Date(), "2024-01-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "yyyy-01-01 00:00:00"), |
|
|
|
DateUtil.format(new Date(), "2024-12-31 23:59:59") |
|
|
|
DateUtil.format(new Date(), "yyyy-12-31 23:59:59") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Map<Long, WarehouseInfoVO> warehouseBillingDataMap = warehouselist.stream().collect(Collectors.toMap(WarehouseInfoVO::getWarehouseId, v -> v)); |
|
|
|
Map<Long, WarehouseBillingDataVO> warehouseBillingMapData = warehouseBillingData.stream().collect(Collectors.toMap(WarehouseBillingDataVO::getWarehouseId, v -> v)); |
|
|
|
List<WarehouseBillingDataVO> res = null; |
|
|
|
|
|
|
|
try { |
|
|
|
List<WarehouseBillingDataVO> res = new ArrayList<>(); |
|
|
|
res = warehouseBillingData.stream() |
|
|
|
warehouselist.forEach(warehouseInfoVO -> { |
|
|
|
.peek(WarehouseBillingDataVO -> { |
|
|
|
WarehouseBillingDataVO warehouseBillingDataVO = warehouseBillingMapData.get(warehouseInfoVO.getWarehouseId()); |
|
|
|
if (warehouseBillingDataMap.get(WarehouseBillingDataVO.getWarehouseId()) != null) { |
|
|
|
|
|
|
|
WarehouseBillingDataVO.setWarehouseName(warehouseBillingDataMap.get(WarehouseBillingDataVO.getWarehouseId()).getWarehouseName()); |
|
|
|
if (warehouseBillingDataVO == null) { |
|
|
|
} |
|
|
|
warehouseBillingDataVO = new WarehouseBillingDataVO(); |
|
|
|
}) |
|
|
|
warehouseBillingDataVO.setWarehouseId(warehouseInfoVO.getWarehouseId()); |
|
|
|
.sorted((WarehouseBillingDataVO o1, WarehouseBillingDataVO o2) -> o2.getTotal() - o1.getTotal()) |
|
|
|
warehouseBillingDataVO.setTotal(0); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
warehouseBillingDataVO.setValue(0); |
|
|
|
}catch (Exception e){ |
|
|
|
|
|
|
|
log.error("数据异常", e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
warehouseBillingDataVO.setWarehouseName(warehouseInfoVO.getWarehouseName()); |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
res.add(warehouseBillingDataVO); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res.stream().sorted((o1, o2) -> o2.getTotal() - o1.getTotal()).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<MonthBillingDataVO> getMonthBillingData() { |
|
|
|
public List<MonthBillingDataVO> getMonthBillingData() { |
|
|
|
// return billingDataMapper.getMonthBillingData(
|
|
|
|
List<MonthBillingDataVO> monthBillingData = billingDataMapper.getMonthBillingData( |
|
|
|
// DateUtil.format(new Date(), "yyyy-01-01 00:00:00"),
|
|
|
|
DateUtil.format(new Date(), "yyyy-01-01 00:00:00"), |
|
|
|
// DateUtil.format(new Date(), "yyyy-12-31 23:59:59")
|
|
|
|
DateUtil.format(new Date(), "yyyy-12-31 23:59:59") |
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return billingDataMapper.getMonthBillingData( |
|
|
|
|
|
|
|
DateUtil.format(new Date(), "2024-01-01 00:00:00"), |
|
|
|
|
|
|
|
DateUtil.format(new Date(), "2024-12-31 23:59:59") |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<MonthBillingDataVO> res = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String, MonthBillingDataVO> monthKeyData = monthBillingData.stream().collect(Collectors.toMap(MonthBillingDataVO::getMonth, v -> v)); |
|
|
|
|
|
|
|
List<String> monthList = Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monthList.forEach(month -> { |
|
|
|
|
|
|
|
month = LocalDate.now().getYear() + "-" + month; |
|
|
|
|
|
|
|
MonthBillingDataVO monthBillingDataVO = monthKeyData.get(month); |
|
|
|
|
|
|
|
if (monthBillingDataVO == null) { |
|
|
|
|
|
|
|
monthBillingDataVO = new MonthBillingDataVO(); |
|
|
|
|
|
|
|
monthBillingDataVO.setMonth(month); |
|
|
|
|
|
|
|
monthBillingDataVO.setTotal(0); |
|
|
|
|
|
|
|
monthBillingDataVO.setValue(0); |
|
|
|
|
|
|
|
monthBillingDataVO.setVolume("0"); |
|
|
|
|
|
|
|
monthBillingDataVO.setWeight("0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
res.add(monthBillingDataVO); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|