1、统计枚举、校验统一使用common模块;2、旧超管统计相关代码移除;

This commit is contained in:
gaoqr
2025-09-30 17:54:47 +08:00
parent b2f004df00
commit fe5e14002f
24 changed files with 61 additions and 464 deletions
@@ -1,34 +0,0 @@
package com.cf.imes.module.executor.enums;
/**
* 生产单统计维度单位
* @author Gqr
* @since 2024/8/6 10:04
*/
public enum OrderStatisticsUnit {
//季度、月、周、日
QUARTER(0),
MONTH(1),
WEEK(2),
DAY(3);
OrderStatisticsUnit(Integer value) {
this.value = value;
}
private Integer value;
public Integer getValue() {
return value;
}
// from value
public static OrderStatisticsUnit fromValue(Integer value) {
for (OrderStatisticsUnit unit : OrderStatisticsUnit.values()) {
if (unit.getValue().equals(value)) {
return unit;
}
}
return null;
}
}
@@ -1,41 +0,0 @@
package com.cf.imes.module.executor.controller.admin.order;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.executor.service.order.OrderSupStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
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 jakarta.annotation.Resource;
import java.util.Map;
import static com.cf.imes.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 超管-生产单统计管理")
@RestController
@RequestMapping("/executor/order/supStatistics")
@Validated
@Slf4j
public class OrderSupStatisticsController {
@Resource
private OrderSupStatisticsService orderSupStatisticsService;
@GetMapping("/total/order")
@Operation(summary = "生产单总数")
@PreAuthorize("@ss.hasPermission('homePage:analysis:org-statistic')")
public CommonResult<Map<String, Integer>> getOrderTotal() {
return success(orderSupStatisticsService.orderTotal());
}
@GetMapping("/total/plateArea")
@Operation(summary = "拆单板件平方数")
public CommonResult<Map<String, Double>> getPlateAreaTotal() {
return success(orderSupStatisticsService.plateAreaTotal());
}
}
@@ -1,30 +0,0 @@
package com.cf.imes.module.executor.dal.mysql.order;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
@Mapper
public interface OrderSupStatisticsMapper extends BaseMapperX<OrderDO> {
/**
* 当日生产单板件平方数
*/
Double selectOrderSquareProduceToday(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
/**
* 生产单按时间统计失效数量
*/
List<OrderStatisticsIsLapseRespVO> selectOrderCountLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
/**
* 生产单按时间分组统计未失效数量
*/
List<OrderStatisticsIsLapseRespVO> selectOrderCountNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
}
@@ -12,6 +12,7 @@ import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.util.NamedValue;
import com.cf.imes.framework.common.enums.OrderStatusEnum;
import com.cf.imes.framework.common.enums.StatisticsUnit;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO;
@@ -25,7 +26,6 @@ import com.cf.imes.module.executor.dal.mysql.order.OrderStatisticsMapper;
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
import com.cf.imes.module.executor.dal.mysql.plate.OrderPlateStatisticsMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
import com.cf.imes.module.executor.enums.OrderStatisticsUnit;
import com.cf.imes.module.system.api.dict.DictDataApi;
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
import com.cf.imes.module.system.enums.DictTypeConstants;
@@ -593,7 +593,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
* @return
*/
private DateHistogramAggregation.Builder getDateHistogram(Integer unit, DateHistogramAggregation.Builder builder) {
switch (OrderStatisticsUnit.fromValue(unit)) {
switch (StatisticsUnit.fromValue(unit)) {
case QUARTER:
return builder.calendarInterval(CalendarInterval.Quarter).format("yyyy-Q");
case MONTH:
@@ -612,7 +612,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
* @return
*/
private String dateToWeekMonth(String dateStr, Integer unit) {
if (OrderStatisticsUnit.WEEK.getValue().equals(unit)) {
if (StatisticsUnit.WEEK.getValue().equals(unit)) {
LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(DATE_TIME_FORMATTER_PATTERN_YEAR_MONTH_DAY));
// 年月
String outDateStr = date.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMATTER_PATTERN_YEAR_MONTH));
@@ -1,19 +0,0 @@
package com.cf.imes.module.executor.service.order;
import java.util.Map;
/**
* 生产单统计 —— 超管
*/
public interface OrderSupStatisticsService {
/**
* 生产单总数统计
*/
Map<String, Integer> orderTotal();
/**
* 拆单板件平方数统计
*/
Map<String, Double> plateAreaTotal();
}
@@ -1,56 +0,0 @@
package com.cf.imes.module.executor.service.order;
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
import com.cf.imes.module.executor.dal.mysql.order.OrderStatisticsMapper;
import com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
@Service
@Validated
public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
@Resource
private OrderStatisticsMapper orderStatisticsMapper;
@Resource
private OrderSupStatisticsMapper orderSupStatisticsMapper;
@Override
@OrganIgnore
public Map<String, Integer> orderTotal() {
Map<String, Integer> resultMap = new LinkedHashMap<>();
// 生产单总数
Integer total = orderStatisticsMapper.selectOrderCount();
resultMap.put("total", total);
// 日增长量
Integer today = orderStatisticsMapper.selectOrderCountToday();
resultMap.put("today", today);
return resultMap;
}
@Override
public Map<String, Double> plateAreaTotal() {
Map<String, Double> resultMap = new LinkedHashMap<>();
// 生产单板件平方数
Double total = orderStatisticsMapper.selectOrderSquareProduce();
resultMap.put("total", total);
// 当日生产单板件平方数
LocalDate date = LocalDate.now();
LocalDateTime startTime = LocalDateTime.of(date, LocalTime.MIDNIGHT);
LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX);
Double today = orderSupStatisticsMapper.selectOrderSquareProduceToday(startTime, endTime);
resultMap.put("today", today);
return resultMap;
}
}
@@ -1,36 +0,0 @@
package com.cf.imes.module.executor.validation.order;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 生产单统计维度单位入参校验注解
*
* @author Gqr
* @since 2024/7/17 9:33
*/
@Target({
ElementType.METHOD,
ElementType.FIELD,
ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR,
ElementType.PARAMETER,
ElementType.TYPE_USE
})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(
validatedBy = {OrderStatisticsUnitInEnumValidator.class}
)
public @interface OrderStatisticsUnitInEnum {
String message() default "生产单统计维度单位[unit]错误,请检查";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -1,36 +0,0 @@
package com.cf.imes.module.executor.validation.order;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.executor.enums.OrderStatisticsUnit;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
/**
* 生产单统计维度单位入参校验器
*
* @author Gqr
* @since 2024/7/17 9:33
*/
public class OrderStatisticsUnitInEnumValidator implements ConstraintValidator<OrderStatisticsUnitInEnum, Integer> {
@Override
public void initialize(OrderStatisticsUnitInEnum constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
if (ObjectUtil.isNull(value)) {
return true;
}
OrderStatisticsUnit unit = OrderStatisticsUnit.fromValue(value);
if (ObjectUtil.isNotNull(unit)) {
return true;
} else {
return false;
}
}
}
@@ -8,16 +8,16 @@
</select>
<sql id="dateFormat">
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', WEEK(o.order_date, 1)) AS date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as date
</if>
</sql>
@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper">
<sql id="dateFormat">
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as date
</if>
</sql>
<select id="selectOrderSquareProduceToday" resultType="java.lang.Double">
SELECT SUM(op.area) as area
FROM orders o
LEFT JOIN order_plate op on op.order_id = o.id
WHERE o.deleted = 0 AND o.create_time BETWEEN #{startTime} AND #{endTime}
</select>
<select id="selectOrderCountLapseByOrderDate"
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO">
select count(o.id) as orderCount
<include refid="dateFormat"/>
from orders o
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
and (o.deleted = 1 or o.status = 0)
group by date;
</select>
<select id="selectOrderCountNotLapseByOrderDate"
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO">
select count(o.id) as orderCount
<include refid="dateFormat"/>
from orders o
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
and o.deleted = 0 and o.status != 0
group by date;
</select>
</mapper>
@@ -45,16 +45,16 @@
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsCountRespVO">
select
count(p.id) as count
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(p.create_time), '-', QUARTER(p.create_time)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', FLOOR((DayOfMonth(p.create_time)-1)/7)+1) AS date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', DAY(p.create_time)) as date
</if>
from order_plan p
@@ -66,16 +66,16 @@
<select id="selectPlanAreaGroupByCreateTime"
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsAreaRespVO">
select sum(op.area) areaSum
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(p.create_time), '-', QUARTER(p.create_time)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', FLOOR((DayOfMonth(p.create_time)-1)/7)+1) AS date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(p.create_time), '-', MONTH(p.create_time), '-', DAY(p.create_time)) as date
</if>
from order_plan p
@@ -26,16 +26,16 @@
MIN(g.thickness) AS thickness,
MIN(g.width) AS width,
COUNT(a.id) AS orderCount
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as orderDate
</if>
FROM order_goods g
@@ -77,16 +77,16 @@
MIN(g.thickness) AS thickness,
MIN(g.width) AS width,
SUM(a.area) AS orderArea
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS orderDate
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.StatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as orderDate
</if>
FROM order_goods g