分析页统计:五个数量统计接口完善

This commit is contained in:
gaoqr
2024-08-06 09:25:33 +08:00
parent 85c0cdc3ef
commit 483e2dcb99
9 changed files with 213 additions and 172 deletions
@@ -455,46 +455,6 @@ public class OrderController {
return success(orderService.getOrderWarn());
}
// 生产单总数
@GetMapping("/orderCount")
@Operation(summary = "生产单总数")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<Integer> getOrderCount() {
return success(orderService.orderCount());
}
// 今日新增生产单总数
@GetMapping("/orderCountToday")
@Operation(summary = "今日新增生产单总数")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<Integer> getOrderCountToday() {
return success(orderService.orderCountToday());
}
// 今日生产单完成总数
@GetMapping("/orderCountTodayFinish")
@Operation(summary = "今日生产单完成总数")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<Integer> getOrderCountTodayFinish() {
return success(orderService.orderCountTodayFinish());
}
// 生产中生产单总数
@GetMapping("/orderCountProduce")
@Operation(summary = "生产中生产单总数")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<Integer> getOrderCountProduce() {
return success(orderService.orderCountProduce());
}
// 生产中生产平方数
@GetMapping("/orderSquareProduce")
@Operation(summary = "生产中生产平方数")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<Integer> getOrderSquareProduce() {
return success(orderService.orderSquareProduce());
}
// 生产单状态分组统计返回
@GetMapping("/getOrderStatusCount")
@Operation(summary = "生产单状态分组统计返回")
@@ -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<Integer> getOrderCount(OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.orderCount(reqVO));
}
@GetMapping("/today/increase")
@Operation(summary = "今日新增生产单总数")
public CommonResult<Integer> getOrderCountToday(OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.orderCountToday(reqVO));
}
@GetMapping("/today/finish")
@Operation(summary = "今日生产单完成总数")
public CommonResult<Integer> getOrderCountTodayFinish(OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.orderCountTodayFinish(reqVO));
}
@GetMapping("/producing/total")
@Operation(summary = "生产中生产单总数")
public CommonResult<Integer> getOrderCountProduce(OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.orderCountProduce(reqVO));
}
@GetMapping("/producing/square")
@Operation(summary = "生产中生产平方数")
public CommonResult<Integer> getOrderSquareProduce(OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.orderSquareProduce(reqVO));
}
}
@@ -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;
}
@@ -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<OrderDO> {
// 生产单逾期统计
List<OrderOverdueRespVO> selectOrderOverdue(@Param("today") LocalDateTime today, @Param("organId") Long organId);
// 生产单数量统计
default Integer selectOrderCount(Long organId){
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
.eq(OrderDO::getOrganId, organId)
.eq(OrderDO::getDeleted, 0)));
}
@OrganIgnore
default Integer selectOrderCount(){
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
/**
* 生产单数量统计
*/
default Integer selectOrderCount(Long organId) {
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrderDO>()
.eqIfPresent(OrderDO::getOrganId, organId)
.eq(OrderDO::getDeleted, 0)));
}
// 今日新增生产单总数统计
default Integer selectOrderCountToday(Long organId){
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
.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<OrderDO>()
.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<OrderDO>()
.eqIfPresent(OrderDO::getOrganId, organId)
.eq(OrderDO::getOrderDate, LocalDate.now())));
}
// 今日新增生产单总数统计
default Integer selectOrderCountTodayFinish(Long organId){
return Math.toIntExact(selectCount(new LambdaQueryWrapper<OrderDO>()
.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<OrderDO>()
.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<OrderDO>()
.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<OrderDO>()
.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<OrderDO>()
.eq(OrderDO::getDeleted, 0)
/**
* 生产中生产单总数
*
*/
default Integer selectOrderCountProduce(Long organId) {
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrderDO>()
.eqIfPresent(OrderDO::getOrganId, organId)
.eq(OrderDO::getStatus, OrderStatusEnum.IN_PRODUCTION.getStatus())));
}
// 生产中生产平方数
@OrganIgnore
/**
* 生产中生产平方数
*
* @param organId
* @return
*/
Integer selectOrderSquareProduce(@Param("organId") Long organId);
}
@@ -183,31 +183,6 @@ public interface OrderService {
*/
Map<String,List<OrderOverdueRespVO>> getOrderWarn();
/**
* 生产单总数统计
*/
Integer orderCount();
/**
* 今日新增生产单总数统计
*/
Integer orderCountToday();
/**
* 今日生产单完成总数
*/
Integer orderCountTodayFinish();
/**
* 今日生产单完成总数
*/
Integer orderCountProduce();
/**
* 今日生产单完成总数
*/
Integer orderSquareProduce();
/**
* 小板数量
*/
@@ -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<OrderGoodsPlateRespVO> plateCount(String startTime, String endTime, Integer pageNo, Integer pageSize) {
// 角色判断
@@ -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);
}
@@ -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();
}
}
}
@@ -163,8 +163,8 @@
<select id="selectOrderSquareProduce" resultType="java.lang.Integer">
SELECT SUM(op.area) as area FROM orders o
LEFT JOIN order_plate op on op.order_id = o.id
SELECT SUM(op.area) as area FROM orders o
LEFT JOIN order_plate op on op.order_id = o.id
WHERE o.deleted = 0
<if test="organId != null">
AND o.organ_id = #{organId}