|
|
|
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.camera.dal.dataobject.order.OrderDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.sensorgun.SensorGunDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.stock.StockDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.dataobject.street.StreetDO;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.entity.echarts.*;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.mysql.order.OrderMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.dal.mysql.sensorgun.SensorGunMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.checklog.CheckLogService;
|
|
|
|
|
@ -19,12 +20,19 @@ import cn.iocoder.yudao.module.camera.service.street.StreetService;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.threeInOneCode.ScanningGun;
|
|
|
|
|
import cn.iocoder.yudao.module.camera.service.threeInOneCode.SpecificationsAndOCR;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import de.danielbechler.util.Strings;
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.ORDER_NOT_EXISTS;
|
|
|
|
|
@ -149,4 +157,122 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
return orderMapper.selectPage(pageReqVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long count(String startTime, String endTime) {
|
|
|
|
|
return orderMapper.selectCount(new QueryWrapper<OrderDO>()
|
|
|
|
|
.ge(Strings.hasText(startTime),"create_time",startTime)
|
|
|
|
|
.le(Strings.hasText(endTime),"create_time",endTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EChartsOption laneInventoryStatistics() {
|
|
|
|
|
// 创建ECharts图表的配置对象
|
|
|
|
|
EChartsOption eChartsOption = new EChartsOption();
|
|
|
|
|
|
|
|
|
|
// 创建X轴对象并设置其类型为"category",表示类别轴
|
|
|
|
|
Axis xAxis = new Axis();
|
|
|
|
|
xAxis.setType("category");
|
|
|
|
|
// 将X轴配置添加到图表配置中
|
|
|
|
|
eChartsOption.setXAxis(xAxis);
|
|
|
|
|
|
|
|
|
|
// 初始化系列列表,用于存放多个数据系列
|
|
|
|
|
List<Series> seriesList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 获取街道列表
|
|
|
|
|
List<StreetDO> streets = streetService.list();
|
|
|
|
|
|
|
|
|
|
// 初始化数据序列对象,并设置其类型为"bar",表示柱状图
|
|
|
|
|
Series series = new Series();
|
|
|
|
|
series.setName("bar");
|
|
|
|
|
series.setType("bar");
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
// 获取本月1号
|
|
|
|
|
LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
|
|
// 设置时间为0点0分0秒
|
|
|
|
|
LocalDateTime firstDayOfMonthStart = firstDayOfMonth.atStartOfDay();
|
|
|
|
|
// 设置当前时间为23点59分59秒
|
|
|
|
|
LocalDateTime nowEnd = today.atTime(23, 59, 59);
|
|
|
|
|
|
|
|
|
|
// 获取订单列表
|
|
|
|
|
List<OrderDO> orderDOS = orderMapper.selectList(new QueryWrapper<OrderDO>()
|
|
|
|
|
.ge("create_time", firstDayOfMonthStart)
|
|
|
|
|
.le("create_time", nowEnd));
|
|
|
|
|
// 使用流处理,按srmNumber分组并计算每个组的数量,存储到Map中
|
|
|
|
|
Map<String,Long> stocksMap = orderDOS.stream().collect(Collectors.groupingBy(OrderDO::getSrmNumber,Collectors.counting()));
|
|
|
|
|
List<Long> data = new ArrayList<>();
|
|
|
|
|
xAxis.setData(new ArrayList<>());
|
|
|
|
|
// 遍历街道列表,为X轴添加类别数据,并收集对应的数据到数据序列中
|
|
|
|
|
for (StreetDO street : streets) {
|
|
|
|
|
xAxis.getData().add(street.getName());
|
|
|
|
|
data.add(stocksMap.get(street.getPlcId()));
|
|
|
|
|
}
|
|
|
|
|
series.setData(data);
|
|
|
|
|
seriesList.add(series);
|
|
|
|
|
// 创建Y轴对象并设置其类型为"value",表示数值轴
|
|
|
|
|
Axis yAxis = new Axis();
|
|
|
|
|
yAxis.setType("value");
|
|
|
|
|
// 将Y轴配置添加到图表配置中
|
|
|
|
|
eChartsOption.setYAxis(yAxis);
|
|
|
|
|
|
|
|
|
|
// 将数据序列添加到系列列表中
|
|
|
|
|
eChartsOption.setSeries(seriesList);
|
|
|
|
|
return eChartsOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EChartsOption laneInventoryLine() {
|
|
|
|
|
EChartsOption eChartsOption = new EChartsOption();
|
|
|
|
|
Axis xAxis = new Axis();
|
|
|
|
|
xAxis.setType("category");
|
|
|
|
|
xAxis.setBoundaryGap(false);
|
|
|
|
|
// 创建一个包含从今天开始前7天日期的列表
|
|
|
|
|
List<String> data = new ArrayList<>();
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
LocalDate date = today.minusDays(i);
|
|
|
|
|
data.add(date.format(formatter));
|
|
|
|
|
}
|
|
|
|
|
xAxis.setData(data);
|
|
|
|
|
Axis yAxis = new Axis();
|
|
|
|
|
yAxis.setType("value");
|
|
|
|
|
eChartsOption.setYAxis(yAxis);
|
|
|
|
|
eChartsOption.setXAxis(xAxis);
|
|
|
|
|
List<OrderDO> orderDOS = orderMapper.selectList(new QueryWrapper<OrderDO>()
|
|
|
|
|
.ge("create_time",LocalDate.now().minusDays(7)));
|
|
|
|
|
|
|
|
|
|
// 填充数据
|
|
|
|
|
|
|
|
|
|
// 根据srmNumber分组,然后根据create_time的日期字符串计算当天的订单数量
|
|
|
|
|
Map<String, Map<String, Long>> map = orderDOS.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(OrderDO::getSrmNumber,
|
|
|
|
|
Collectors.groupingBy(order -> order.getCreateTime().toLocalDate().format(formatter),
|
|
|
|
|
Collectors.counting())));
|
|
|
|
|
Legend legend = new Legend();
|
|
|
|
|
List<String> legendDate = new ArrayList<>();
|
|
|
|
|
List<StreetDO> streets = streetService.list();
|
|
|
|
|
// 相关值
|
|
|
|
|
List<Series> seriesList = new ArrayList<>();
|
|
|
|
|
for (StreetDO street : streets) {
|
|
|
|
|
Series series = new Series();
|
|
|
|
|
legendDate.add(street.getName());
|
|
|
|
|
series.setName(street.getName());
|
|
|
|
|
series.setType("line");
|
|
|
|
|
series.setData(new ArrayList<>());
|
|
|
|
|
seriesList.add(series);
|
|
|
|
|
for (String date : data) {
|
|
|
|
|
Map<String, Long> countMap = map.get(street.getPlcId());
|
|
|
|
|
Long count = countMap != null ? countMap.get(date) : 0L;
|
|
|
|
|
series.getData().add(count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
legend.setData(legendDate);
|
|
|
|
|
eChartsOption.setLegend(legend);
|
|
|
|
|
eChartsOption.setSeries(seriesList);
|
|
|
|
|
|
|
|
|
|
return eChartsOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|