From 483e2dcb995377aab5ab7fba30b9adf69ed4e067 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Tue, 6 Aug 2024 09:25:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=9E=90=E9=A1=B5=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=EF=BC=9A=E4=BA=94=E4=B8=AA=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/order/OrderController.java | 40 --------- .../order/OrderStatisticsController.java | 59 +++++++++++++ .../order/vo/order/OrderStatisticsReqVO.java | 15 ++++ .../executor/dal/mysql/order/OrderMapper.java | 85 ++++++++----------- .../executor/service/order/OrderService.java | 25 ------ .../service/order/OrderServiceImpl.java | 57 ------------- .../service/order/OrderStatisticsService.java | 35 ++++++++ .../order/OrderStatisticsServiceImpl.java | 65 ++++++++++++++ .../resources/mapper/order/OrderMapper.xml | 4 +- 9 files changed, 213 insertions(+), 172 deletions(-) create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderStatisticsController.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsReqVO.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsService.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsServiceImpl.java diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index 8dcfe37f7..b45b0b236 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -455,46 +455,6 @@ public class OrderController { return success(orderService.getOrderWarn()); } - // 生产单总数 - @GetMapping("/orderCount") - @Operation(summary = "生产单总数") - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult getOrderCount() { - return success(orderService.orderCount()); - } - - // 今日新增生产单总数 - @GetMapping("/orderCountToday") - @Operation(summary = "今日新增生产单总数") - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult getOrderCountToday() { - return success(orderService.orderCountToday()); - } - - // 今日生产单完成总数 - @GetMapping("/orderCountTodayFinish") - @Operation(summary = "今日生产单完成总数") - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult getOrderCountTodayFinish() { - return success(orderService.orderCountTodayFinish()); - } - - // 生产中生产单总数 - @GetMapping("/orderCountProduce") - @Operation(summary = "生产中生产单总数") - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult getOrderCountProduce() { - return success(orderService.orderCountProduce()); - } - - // 生产中生产平方数 - @GetMapping("/orderSquareProduce") - @Operation(summary = "生产中生产平方数") - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult getOrderSquareProduce() { - return success(orderService.orderSquareProduce()); - } - // 生产单状态分组统计返回 @GetMapping("/getOrderStatusCount") @Operation(summary = "生产单状态分组统计返回") diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderStatisticsController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderStatisticsController.java new file mode 100644 index 000000000..f189df5d3 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderStatisticsController.java @@ -0,0 +1,59 @@ +package com.cf.imes.module.executor.controller.admin.order; + +import com.cf.imes.framework.common.pojo.CommonResult; +import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; +import com.cf.imes.module.executor.service.order.OrderStatisticsService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import static com.cf.imes.framework.common.pojo.CommonResult.success; + +/** + * @author Gqr + * @since 2024/8/5 17:00 + */ +@Tag(name = "管理后台 - 生产单统计管理") +@RestController +@RequestMapping("/executor/order/statistics") +@Validated +public class OrderStatisticsController { + @Resource + private OrderStatisticsService orderStatisticsService; + + @GetMapping("/total") + @Operation(summary = "生产单总数") + public CommonResult getOrderCount(OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.orderCount(reqVO)); + } + + @GetMapping("/today/increase") + @Operation(summary = "今日新增生产单总数") + public CommonResult getOrderCountToday(OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.orderCountToday(reqVO)); + } + + @GetMapping("/today/finish") + @Operation(summary = "今日生产单完成总数") + public CommonResult getOrderCountTodayFinish(OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.orderCountTodayFinish(reqVO)); + } + + @GetMapping("/producing/total") + @Operation(summary = "生产中生产单总数") + public CommonResult getOrderCountProduce(OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.orderCountProduce(reqVO)); + } + + @GetMapping("/producing/square") + @Operation(summary = "生产中生产平方数") + public CommonResult getOrderSquareProduce(OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.orderSquareProduce(reqVO)); + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsReqVO.java new file mode 100644 index 000000000..4990426ae --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsReqVO.java @@ -0,0 +1,15 @@ +package com.cf.imes.module.executor.controller.admin.order.vo.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @author Gqr + * @since 2024/8/5 17:10 + */ +@Schema(description = "管理后台 - 生产单统计 Request VO") +@Data +public class OrderStatisticsReqVO { + @Schema(description = "组织id") + private Long organId; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java index 55cb6bac2..089e786b1 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java @@ -8,8 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; -import com.cf.imes.framework.mybatis.core.query.QueryWrapperX; -import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderOverdueRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatusRespVO; @@ -22,6 +20,7 @@ import org.apache.ibatis.annotations.Param; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.Collection; import java.util.List; import java.util.Map; @@ -148,61 +147,51 @@ public interface OrderMapper extends BaseMapperX { // 生产单逾期统计 List selectOrderOverdue(@Param("today") LocalDateTime today, @Param("organId") Long organId); -// 生产单数量统计 - default Integer selectOrderCount(Long organId){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getOrganId, organId) - .eq(OrderDO::getDeleted, 0))); - } - @OrganIgnore - default Integer selectOrderCount(){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() + /** + * 生产单数量统计 + */ + default Integer selectOrderCount(Long organId) { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eqIfPresent(OrderDO::getOrganId, organId) .eq(OrderDO::getDeleted, 0))); } -// 今日新增生产单总数统计 - default Integer selectOrderCountToday(Long organId){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getOrganId, organId) - .eq(OrderDO::getDeleted, 0) - .between(OrderDO::getCreateTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)))); - } - @OrganIgnore - default Integer selectOrderCountToday(){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getDeleted, 0) - .between(OrderDO::getCreateTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)))); + /** + * 今日新增生产单总数统计 + * + */ + default Integer selectOrderCountToday(Long organId) { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eqIfPresent(OrderDO::getOrganId, organId) + .eq(OrderDO::getOrderDate, LocalDate.now()))); + } -// 今日新增生产单总数统计 - default Integer selectOrderCountTodayFinish(Long organId){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getOrganId, organId) - .eq(OrderDO::getDeleted, 0) - .between(OrderDO::getFinishTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)))); - } - @OrganIgnore - default Integer selectOrderCountTodayFinish(){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getDeleted, 0) - .between(OrderDO::getFinishTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)))); + /** + * 今日完成生产单总数统计 + * + */ + default Integer selectOrderCountTodayFinish(Long organId) { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eqIfPresent(OrderDO::getOrganId, organId) + .between(OrderDO::getFinishTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIN), LocalDateTime.of(LocalDate.now(), LocalTime.MAX)))); } -// 今日新增生产单总数统计 - default Integer selectOrderCountProduce(Long organId){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getOrganId, organId) - .eq(OrderDO::getDeleted, 0) - .eq(OrderDO::getStatus, OrderStatusEnum.IN_PRODUCTION.getStatus()))); - } - @OrganIgnore - default Integer selectOrderCountProduce(){ - return Math.toIntExact(selectCount(new LambdaQueryWrapper() - .eq(OrderDO::getDeleted, 0) + /** + * 生产中生产单总数 + * + */ + default Integer selectOrderCountProduce(Long organId) { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eqIfPresent(OrderDO::getOrganId, organId) .eq(OrderDO::getStatus, OrderStatusEnum.IN_PRODUCTION.getStatus()))); } -// 生产中生产平方数 - @OrganIgnore + /** + * 生产中生产平方数 + * + * @param organId + * @return + */ Integer selectOrderSquareProduce(@Param("organId") Long organId); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java index bc1f41dac..e5577d3d3 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java @@ -183,31 +183,6 @@ public interface OrderService { */ Map> getOrderWarn(); - /** - * 生产单总数统计 - */ - Integer orderCount(); - - /** - * 今日新增生产单总数统计 - */ - Integer orderCountToday(); - - /** - * 今日生产单完成总数 - */ - Integer orderCountTodayFinish(); - - /** - * 今日生产单完成总数 - */ - Integer orderCountProduce(); - - /** - * 今日生产单完成总数 - */ - Integer orderSquareProduce(); - /** * 小板数量 */ diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java index 35b10ccbb..2dd65a52d 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java @@ -1,7 +1,6 @@ package com.cf.imes.module.executor.service.order; import cn.smallbun.screw.core.util.CollectionUtils; -import co.elastic.clients.elasticsearch.nodes.Ingest; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -71,7 +70,6 @@ import java.nio.file.Paths; import java.time.*; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -296,61 +294,6 @@ public class OrderServiceImpl implements OrderService { return JsonUtils.zipString(orderBodyToString); } - @Override - public Integer orderCount() { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// 数据查询 - if (loginUser.getIsSupAdmin()){ - return orderMapper.selectOrderCount(); - } - return orderMapper.selectOrderCount(getUserOrganId()); - } - - @Override - public Integer orderCountToday() { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// 数据查询 - if (loginUser.getIsSupAdmin()){ - return orderMapper.selectOrderCountToday(); - } - return orderMapper.selectOrderCountToday(getUserOrganId()); - } - - @Override - public Integer orderCountTodayFinish() { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// 数据查询 - if (loginUser.getIsSupAdmin()){ - return orderMapper.selectOrderCountTodayFinish(); - } - return orderMapper.selectOrderCountTodayFinish(getUserOrganId()); - } - - @Override - public Integer orderCountProduce() { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// 数据查询 - if (loginUser.getIsSupAdmin()){ - return orderMapper.selectOrderCountProduce(); - } - return orderMapper.selectOrderCountProduce(getUserOrganId()); - } - - @Override - public Integer orderSquareProduce() { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); -// 数据查询 - if (loginUser.getIsSupAdmin()){ - return orderMapper.selectOrderSquareProduce(null); - } - return orderMapper.selectOrderSquareProduce(getUserOrganId()); - } - @Override public PageResult plateCount(String startTime, String endTime, Integer pageNo, Integer pageSize) { // 角色判断 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsService.java new file mode 100644 index 000000000..c9d6dc225 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsService.java @@ -0,0 +1,35 @@ +package com.cf.imes.module.executor.service.order; + +import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; + +/** + * 生产单统计 order_{N} Service 接口 + * @author Gqr + * @since 2024/8/5 16:57 + */ +public interface OrderStatisticsService { + /** + * 生产单总数统计 + */ + Integer orderCount(OrderStatisticsReqVO reqVO); + + /** + * 今日新增生产单总数统计 + */ + Integer orderCountToday(OrderStatisticsReqVO reqVO); + + /** + * 今日生产单完成总数 + */ + Integer orderCountTodayFinish(OrderStatisticsReqVO reqVO); + + /** + * 今日生产单完成总数 + */ + Integer orderCountProduce(OrderStatisticsReqVO reqVO); + + /** + * 今日生产单完成总数 + */ + Integer orderSquareProduce(OrderStatisticsReqVO reqVO); +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsServiceImpl.java new file mode 100644 index 000000000..39e0ee83a --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderStatisticsServiceImpl.java @@ -0,0 +1,65 @@ +package com.cf.imes.module.executor.service.order; + +import com.cf.imes.framework.organ.core.aop.OrganIgnore; +import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; +import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; +import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +/** + * @author Gqr + * @since 2024/8/5 16:58 + */ +@Service +@Validated +public class OrderStatisticsServiceImpl implements OrderStatisticsService { + @Resource + private OrderMapper orderMapper; + + @Override + @OrganIgnore + public Integer orderCount(OrderStatisticsReqVO reqVO) { + return orderMapper.selectOrderCount(getOrganIdParam(reqVO)); + } + + @Override + @OrganIgnore + public Integer orderCountToday(OrderStatisticsReqVO reqVO) { + return orderMapper.selectOrderCountToday(getOrganIdParam(reqVO)); + } + + @Override + @OrganIgnore + public Integer orderCountTodayFinish(OrderStatisticsReqVO reqVO) { + return orderMapper.selectOrderCountTodayFinish(getOrganIdParam(reqVO)); + } + + @Override + @OrganIgnore + public Integer orderCountProduce(OrderStatisticsReqVO reqVO) { + return orderMapper.selectOrderCountProduce(getOrganIdParam(reqVO)); + } + + @Override + @OrganIgnore + public Integer orderSquareProduce(OrderStatisticsReqVO reqVO) { + return orderMapper.selectOrderSquareProduce(getOrganIdParam(reqVO)); + } + + /** + * 前端传组织否则查当前用户所在的组织 + * + * @param reqVO + * @return + */ + private Long getOrganIdParam(OrderStatisticsReqVO reqVO) { + if (reqVO != null && reqVO.getOrganId() != null) { + return reqVO.getOrganId(); + } else { + return SecurityFrameworkUtils.getUserOrganId(); + } + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml index 873649a30..79015c525 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml @@ -163,8 +163,8 @@