diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index e25014d..5574465 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -475,6 +475,12 @@ ${fastjson.version} + + com.alibaba.fastjson2 + fastjson2 + 2.0.43 + + com.google.guava guava diff --git a/yudao-module-camera/yudao-module-camera-biz/pom.xml b/yudao-module-camera/yudao-module-camera-biz/pom.xml index 91368d9..7843631 100644 --- a/yudao-module-camera/yudao-module-camera-biz/pom.xml +++ b/yudao-module-camera/yudao-module-camera-biz/pom.xml @@ -40,14 +40,6 @@ 5.13.0 - - com.sun.jna.examples - test - 1.0 - system - ${project.basedir}/src/main/resources/libs/examples.jar - - cn.iocoder.boot diff --git a/yudao-module-logistics/yudao-module-logistics-biz/pom.xml b/yudao-module-logistics/yudao-module-logistics-biz/pom.xml index f39a2de..2b2f4b1 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/pom.xml +++ b/yudao-module-logistics/yudao-module-logistics-biz/pom.xml @@ -56,13 +56,13 @@ 5.13.0 - - com.sun.jna.examples - test - 1.0 - system - ${project.basedir}/src/main/resources/libs/examples.jar - + + + + + + + gnu.io SerialPort @@ -192,6 +192,11 @@ compile + + com.alibaba.fastjson2 + fastjson2 + + diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/controller/admin/kesc/StockControlController.java b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/controller/admin/kesc/StockControlController.java index d0525e5..92f66a6 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/controller/admin/kesc/StockControlController.java +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/controller/admin/kesc/StockControlController.java @@ -47,7 +47,7 @@ public class StockControlController { plcService.checkStart(kescEntity); } - return CommonResult.success("","OK"); + return CommonResult.success("OK"); } @@ -70,7 +70,7 @@ public class StockControlController { plcService.orderStop(kescEntity.getTaskId()); } - return CommonResult.success("","OK"); + return CommonResult.success("OK"); } @@ -95,7 +95,7 @@ public class StockControlController { } }); - return CommonResult.success("","OK"); + return CommonResult.success("OK"); } @PostMapping("/inventoryEndReport") @@ -104,7 +104,7 @@ public class StockControlController { @PermitAll public CommonResult updateResult( KsecDataInfo kescEntity){ log.info("模拟随行盘点结果返回状态:{}",kescEntity); - return CommonResult.success(kescEntity,"OK"); + return CommonResult.success(kescEntity); } @@ -114,7 +114,7 @@ public class StockControlController { @PermitAll public CommonResult setUpdateStatus(KsecDataInfo kescEntity){ log.info("随行盘点更新状态:{}",kescEntity); - return CommonResult.success(kescEntity,"OK"); + return CommonResult.success(kescEntity); } @PostMapping("/updateStatus") @Operation(summary = "随行盘点更新状态") @@ -134,7 +134,7 @@ public class StockControlController { plcService.action(kescEntity.getTaskId(),kescEntity.getCmdName()); } - return CommonResult.success("","OK"); + return CommonResult.success("OK"); } diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/dal/mysql/order/OrderMapper.java b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/dal/mysql/order/OrderMapper.java index bae5968..1c00a53 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/dal/mysql/order/OrderMapper.java +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/dal/mysql/order/OrderMapper.java @@ -6,6 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.camera.controller.admin.order.vo.OrderPageReqVO; import cn.iocoder.yudao.module.camera.dal.dataobject.order.OrderDO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; /** * 随行记录 Mapper @@ -34,4 +39,8 @@ public interface OrderMapper extends BaseMapperX { .orderByDesc(OrderDO::getId)); } + List> selectGroupCountBySrmNumber(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); + + List> selectGroupCountBySrmNumberAndDate(@Param("startTime") LocalDateTime startTime); + } \ No newline at end of file diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/order/OrderServiceImpl.java b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/order/OrderServiceImpl.java index 585d3c6..c05c410 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/order/OrderServiceImpl.java +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/order/OrderServiceImpl.java @@ -140,19 +140,22 @@ public class OrderServiceImpl implements OrderService { // 设置当前时间为23点59分59秒 LocalDateTime nowEnd = today.atTime(23, 59, 59); - // 获取订单列表 - List orderDOS = orderMapper.selectList(new QueryWrapper() - .ge("create_time", firstDayOfMonthStart) - .le("create_time", nowEnd)); - // 使用流处理,按srmNumber分组并计算每个组的数量,存储到Map中 - Map stocksMap = orderDOS.stream().collect(Collectors.groupingBy(OrderDO::getSrmNumber,Collectors.counting())); + // 使用SQL聚合查询,直接在数据库层面进行分组统计,避免查询大量数据到内存 + List> resultList = orderMapper.selectGroupCountBySrmNumber(firstDayOfMonthStart, nowEnd); + + // 将结果转换为Map格式 + Map stocksMap = new java.util.HashMap<>(); + for (Map row : resultList) { + String srmNumber = (String) row.get("srm_number"); + Long count = ((Number) row.get("count")).longValue(); + stocksMap.put(srmNumber, count); + } List data = new ArrayList<>(); xAxis.setData(new ArrayList<>()); - int max = 0; // 遍历街道列表,为X轴添加类别数据,并收集对应的数据到数据序列中 for (StreetDO street : streets) { xAxis.getData().add(street.getName()); - data.add(stocksMap.get(street.getPlcId())); + data.add(stocksMap.getOrDefault(street.getPlcId(), 0L)); } series.setData(data); @@ -189,16 +192,21 @@ public class OrderServiceImpl implements OrderService { yAxis.setType("value"); eChartsOption.setYAxis(yAxis); eChartsOption.setXAxis(xAxis); - List orderDOS = orderMapper.selectList(new QueryWrapper() - .ge("create_time",LocalDate.now().minusDays(7))); - // 填充数据 + // 使用SQL聚合查询,直接在数据库层面进行分组统计 + LocalDateTime sevenDaysAgo = LocalDate.now().minusDays(7).atStartOfDay(); + List> resultList = orderMapper.selectGroupCountBySrmNumberAndDate(sevenDaysAgo); + + // 将结果转换为Map>格式 + Map> map = new java.util.HashMap<>(); + for (Map row : resultList) { + String srmNumber = (String) row.get("srm_number"); + String date = row.get("date").toString(); + Long count = ((Number) row.get("count")).longValue(); + + map.computeIfAbsent(srmNumber, k -> new java.util.HashMap<>()).put(date, count); + } - // 根据srmNumber分组,然后根据create_time的日期字符串计算当天的订单数量 - Map> map = orderDOS.stream() - .collect(Collectors.groupingBy(OrderDO::getSrmNumber, - Collectors.groupingBy(order -> order.getCreateTime().toLocalDate().format(formatter), - Collectors.counting()))); Legend legend = new Legend(); List legendDate = new ArrayList<>(); List streets = streetService.list(); diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/specificationConf/SpecificationConfServiceImpl.java b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/specificationConf/SpecificationConfServiceImpl.java index fbbcaf1..ece4983 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/specificationConf/SpecificationConfServiceImpl.java +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/specificationConf/SpecificationConfServiceImpl.java @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.camera.dal.dataobject.street.StreetDO; import cn.iocoder.yudao.module.camera.dal.mysql.specificationConf.SpecificationConfMapper; import cn.iocoder.yudao.module.camera.dal.mysql.street.StreetMapper; import cn.iocoder.yudao.module.camera.service.Hik3D.HikFlaskApiService; -import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -17,8 +16,6 @@ import org.springframework.validation.annotation.Validated; import java.io.IOException; import java.util.List; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; - /** * 品规配置 Service 实现类 * @@ -86,7 +83,7 @@ public class SpecificationConfServiceImpl implements SpecificationConfService { private void validateSpecificationConfExists(Integer id) { if (specificationConfMapper.selectById(id) == null) { - throw exception(ErrorCodeConstants.SPECIFICATION_CONF_NOT_EXISTS); +// throw exception(ErrorCodeConstants.SPECIFICATION_CONF_NOT_EXISTS); } } diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/warn/WarnServiceImpl.java b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/warn/WarnServiceImpl.java index dfe9df8..78427ba 100644 --- a/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/warn/WarnServiceImpl.java +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/java/cn/iocoder/yudao/module/camera/service/warn/WarnServiceImpl.java @@ -10,9 +10,6 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.WARN_NOT_EXISTS; - /** * 报警信息 Service 实现类 @@ -50,7 +47,7 @@ public class WarnServiceImpl implements WarnService { private void validateWarnExists(Long id) { if (warnMapper.selectById(id) == null) { - throw exception(WARN_NOT_EXISTS); +// throw exception(WARN_NOT_EXISTS); } } diff --git a/yudao-module-logistics/yudao-module-logistics-biz/src/main/resources/mapper/OrderMapper.xml b/yudao-module-logistics/yudao-module-logistics-biz/src/main/resources/mapper/OrderMapper.xml new file mode 100644 index 0000000..3bb89cd --- /dev/null +++ b/yudao-module-logistics/yudao-module-logistics-biz/src/main/resources/mapper/OrderMapper.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 22f5ec2..7d4f7de 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -47,10 +47,11 @@ spring: datasource: master: name: sy - url: jdbc:mysql://192.168.1.21:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + url: jdbc:mysql://121.43.244.209:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 username: root - password: upright + password: Sy+1234567 + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 data: redis: