diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatusEnum.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatusEnum.java index 9579d7ef7..219b46a9d 100644 --- a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatusEnum.java +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatusEnum.java @@ -8,7 +8,7 @@ import lombok.Getter; @Getter public enum OrderStatusEnum { - EMPTY(0, "默认"), + EMPTY(0, "空单"), NEW_ORDER(1, "新单"), NO_SORT(2, "未排单"), IN_PRODUCTION(3, "生产中"), diff --git a/cf-framework/cf-spring-boot-starter-security/src/main/java/com/cf/imes/framework/security/core/util/SecurityFrameworkUtils.java b/cf-framework/cf-spring-boot-starter-security/src/main/java/com/cf/imes/framework/security/core/util/SecurityFrameworkUtils.java index 625cab2e9..930d975dd 100644 --- a/cf-framework/cf-spring-boot-starter-security/src/main/java/com/cf/imes/framework/security/core/util/SecurityFrameworkUtils.java +++ b/cf-framework/cf-spring-boot-starter-security/src/main/java/com/cf/imes/framework/security/core/util/SecurityFrameworkUtils.java @@ -1,6 +1,8 @@ package com.cf.imes.framework.security.core.util; import cn.hutool.core.util.StrUtil; +import com.cf.imes.framework.common.exception.ServiceException; +import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants; import com.cf.imes.framework.security.core.LoginUser; import com.cf.imes.framework.web.core.util.WebFrameworkUtils; import org.springframework.lang.Nullable; @@ -123,9 +125,12 @@ public class SecurityFrameworkUtils { * 获取当前用户的组织ID * */ - public static Long getUserOrganId(){ - - return SecurityFrameworkUtils.getLoginUser().getOrganId(); + public static Long getUserOrganId() { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if (loginUser == null) { + throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED); + } + return loginUser.getOrganId(); } } diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/OrderStatisticsUnit.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/OrderStatisticsUnit.java new file mode 100644 index 000000000..f02c40c1d --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/OrderStatisticsUnit.java @@ -0,0 +1,34 @@ +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; + } +} 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 b45b0b236..7fd8f4963 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,19 +455,6 @@ public class OrderController { return success(orderService.getOrderWarn()); } - // 生产单状态分组统计返回 - @GetMapping("/getOrderStatusCount") - @Operation(summary = "生产单状态分组统计返回") - @Parameters({ - @Parameter(name = "startTime", description = "开始时间", example = "2024-07-15"), - @Parameter(name = "endTime", description = "结束时间", example = "2024-07-16") - }) - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult> getOrderStatusCount(@RequestParam(value = "startTime") String startTime, - @RequestParam(value = "endTime") String endTime) { - return success(orderService.getOrderStatusCount(startTime + " 00:00:00", endTime + " 23:59:59")); - } - // 小板数量 <集合> @GetMapping("/getPlateCount") @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 index f189df5d3..60209b131 100644 --- 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 @@ -5,13 +5,15 @@ import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisti 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 javax.validation.Valid; + +import java.util.Map; import static com.cf.imes.framework.common.pojo.CommonResult.success; @@ -56,4 +58,10 @@ public class OrderStatisticsController { public CommonResult getOrderSquareProduce(OrderStatisticsReqVO reqVO) { return success(orderStatisticsService.orderSquareProduce(reqVO)); } + + @GetMapping("/orderStatus/group") + @Operation(summary = "生产单状态分组统计") + public CommonResult> getOrderStatusCount(@Valid OrderStatisticsReqVO reqVO) { + return success(orderStatisticsService.getOrderStatusCount(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 index 4990426ae..dbf1d18ec 100644 --- 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 @@ -1,7 +1,11 @@ package com.cf.imes.module.executor.controller.admin.order.vo.order; +import com.cf.imes.module.executor.validation.order.OrderStatisticsUnitInEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; /** * @author Gqr @@ -12,4 +16,15 @@ import lombok.Data; public class OrderStatisticsReqVO { @Schema(description = "组织id") private Long organId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate[] createTime; + + /** + * 统计维度单位 + */ + @Schema(description = "统计维度单位", example = "0", allowableValues = {"0", "1", "2", "3"}, type = "integer") + @OrderStatisticsUnitInEnum + private Integer unit; } 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/OrderStatusRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatusRespVO.java index 547dc76ca..7b7961b15 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatusRespVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatusRespVO.java @@ -2,8 +2,7 @@ package com.cf.imes.module.executor.controller.admin.order.vo.order; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; - -import java.time.LocalDateTime; +import org.jetbrains.annotations.NotNull; @Schema(description = "管理后台 - 生产单状态统计") @Data @@ -11,7 +10,7 @@ import java.time.LocalDateTime; @AllArgsConstructor @NoArgsConstructor @ToString(callSuper = true) -public class OrderStatusRespVO { +public class OrderStatusRespVO implements Comparable { @Schema(description = "订单状态") private Integer orderState; @@ -19,5 +18,37 @@ public class OrderStatusRespVO { private Integer orderCount; @Schema(description = "生产单时间") - private LocalDateTime orderDate; + private String orderDate; + + @Override + public int compareTo(@NotNull OrderStatusRespVO other) { + // 解析 orderDate 字符串为年、月、周 + String[] partsThis = orderDate.split("-"); + String[] partsOther = other.orderDate.split("-"); + + // 比较年份 + int yearComparison = Integer.compare(Integer.parseInt(partsThis[0]), Integer.parseInt(partsOther[0])); + if (yearComparison != 0) { + return yearComparison; + } + + // 比较月份 + if (partsThis.length > 1 && partsOther.length > 1) { + int monthComparison = Integer.compare(Integer.parseInt(partsThis[1]), Integer.parseInt(partsOther[1])); + if (monthComparison != 0) { + return monthComparison; + } + } + + // 比较周数 + if (partsThis.length > 2 && partsOther.length > 2) { + int weekComparison = Integer.compare(Integer.parseInt(partsThis[2]), Integer.parseInt(partsOther[2])); + if (weekComparison != 0) { + return weekComparison; + } + } + + // 如果所有部分都相同,则按状态排序 + return this.orderState.compareTo(other.orderState); + } } 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 089e786b1..e4a423dc0 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 @@ -10,6 +10,7 @@ import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; 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.OrderStatisticsReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatusRespVO; import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds; import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy; @@ -138,8 +139,13 @@ public interface OrderMapper extends BaseMapperX { List selectOrderIds(@Param(Constants.WRAPPER) Wrapper wrapper); -// 生产单状态统计 - List selectOrderStatusCount(@Param("organId")Long organId, @Param("startTime")String startTime, @Param("endTime")String endTime); + /** + * 生产单状态按时间分组统计 + * + * @param reqVO + * @return + */ + List selectOrderStatusCount(@Param("req") OrderStatisticsReqVO reqVO); // 生产单预警统计 List selectOrderNear(@Param("today") LocalDateTime today, @Param("orderDate") LocalDateTime orderDate, @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 e5577d3d3..a71bfb299 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 @@ -173,10 +173,6 @@ public interface OrderService { */ List getApiOrderList(JSONObject orderList); - /** - * 生产单状态统计 - */ - List getOrderStatusCount(String startTime, String endTime); /** * 生产单超期告警分析统计 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 2dd65a52d..e56b0c7ac 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 @@ -620,13 +620,6 @@ public class OrderServiceImpl implements OrderService { return apiOrderRespVOS; } - @Override - public List getOrderStatusCount(String startTime, String endTime) { - List orderStatusRespVOS = orderMapper.selectOrderStatusCount(OrganContextHolder.getOrganId(), startTime, endTime); - orderStatusRespVOS.removeIf(obj -> obj.getOrderState() == OrderStatusEnum.EMPTY.getStatus()); - return orderStatusRespVOS; - } - @Override public Map> getOrderWarn() { Map> map = new HashMap<>(); 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 index c9d6dc225..bb88d0c7d 100644 --- 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 @@ -2,6 +2,8 @@ package com.cf.imes.module.executor.service.order; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; +import java.util.Map; + /** * 生产单统计 order_{N} Service 接口 * @author Gqr @@ -32,4 +34,9 @@ public interface OrderStatisticsService { * 今日生产单完成总数 */ Integer orderSquareProduce(OrderStatisticsReqVO reqVO); + + /** + * 生产单状态统计 + */ + Map getOrderStatusCount(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 index 39e0ee83a..b8dde7fd3 100644 --- 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 @@ -1,13 +1,28 @@ package com.cf.imes.module.executor.service.order; +import cn.hutool.core.util.ObjectUtil; +import com.cf.imes.framework.common.enums.OrderStatusEnum; 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.controller.admin.order.vo.order.OrderStatusRespVO; import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; +import com.cf.imes.module.executor.enums.OrderStatisticsUnit; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; /** * @author Gqr @@ -49,6 +64,92 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService { return orderMapper.selectOrderSquareProduce(getOrganIdParam(reqVO)); } + @Override + @OrganIgnore + public Map getOrderStatusCount(OrderStatisticsReqVO reqVO) { + Map resultMap = new HashMap<>(); + + // 计算时间跨度 + getTimeSpan(reqVO); + + // 查询订单状态统计数据 + List orderStatusRespVOS = orderMapper.selectOrderStatusCount(reqVO); + + // 基于相同的orderDate分组 + Map> orderDateMap = orderStatusRespVOS.stream() + .sorted(Comparator.naturalOrder()) + .collect(Collectors.groupingBy(OrderStatusRespVO::getOrderDate, LinkedHashMap::new, Collectors.toList())); + + // 所有的日期集合 + Set dateList = orderDateMap.keySet(); + resultMap.put("dateList", dateList); + + // 初始化结果集 + List> series = new ArrayList<>(); + for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) { + Map seriesItem = new HashMap<>(); + int[] sumArr = new int[orderDateMap.size()]; + + // 遍历日期map + int index = 0; + for (Map.Entry> entry : orderDateMap.entrySet()) { + // 查找匹配的订单状态 + Optional matchingStatus = entry.getValue().stream() + .filter(respVO -> Objects.equals(orderStatusEnum.getStatus(), respVO.getOrderState())) + .findFirst(); + + // 设置计数值 + sumArr[index++] = matchingStatus.map(OrderStatusRespVO::getOrderCount).orElse(0); + } + + seriesItem.put("data", sumArr); + seriesItem.put("name", orderStatusEnum.getDescription()); + series.add(seriesItem); + } + + resultMap.put("series", series); + + return resultMap; + } + + /** + * 获取统计的时间跨度 + * 计算起止时间:前端不传入时间就根据维度单位从当前日期计算 + * + * @param reqVO + */ + private void getTimeSpan(OrderStatisticsReqVO reqVO) { + LocalDate[] createTime = reqVO.getCreateTime(); + LocalDate startTime = null; + LocalDate endTime; + LocalDate now = LocalDate.now(); + if (ObjectUtil.isNull(createTime) || ObjectUtil.isNull(createTime[0]) || ObjectUtil.isNull(createTime[1])) { + endTime = now; + switch (OrderStatisticsUnit.fromValue(reqVO.getUnit())) { + case QUARTER: + // 从now往前的2年 + startTime = now.minusYears(2); + break; + case MONTH: + // 从now往前的12个月 + startTime = now.minusMonths(12); + break; + case WEEK: + // 从now往前的12周 + startTime = now.minusWeeks(12); + break; + case DAY: + // 从now往前的15天 + startTime = now.minusDays(15); + break; + default: + break; + } + // 声明一个LocalDateTime的数组,把startTime和endTime放进去 + reqVO.setCreateTime(new LocalDate[]{startTime, endTime}); + } + } + /** * 前端传组织否则查当前用户所在的组织 * diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnum.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnum.java new file mode 100644 index 000000000..b151c2a1a --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnum.java @@ -0,0 +1,36 @@ +package com.cf.imes.module.executor.validation.order; + +import javax.validation.Constraint; +import javax.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[] payload() default {}; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnumValidator.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnumValidator.java new file mode 100644 index 000000000..6fe1288dc --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/validation/order/OrderStatisticsUnitInEnumValidator.java @@ -0,0 +1,36 @@ +package com.cf.imes.module.executor.validation.order; + +import cn.hutool.core.util.ObjectUtil; +import com.cf.imes.module.executor.enums.OrderStatisticsUnit; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +/** + * 生产单统计维度单位入参校验器 + * + * @author Gqr + * @since 2024/7/17 9:33 + */ +public class OrderStatisticsUnitInEnumValidator implements ConstraintValidator { + + @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; + } + } + +} + 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 79015c525..7cc75754c 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 @@ -81,16 +81,28 @@ - + select o.status as orderState, + count(o.id) as orderCount + + ,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as orderDate + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as orderDate + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS + orderDate + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as orderDate + from orders o where o.organ_id = #{organId} - and DATE(o.order_date) between #{startTime} and #{endTime} - and o.deleted = 0 - group by o.status, o.order_date + and o.order_date between #{req.createTime[0]} and #{req.createTime[1]} + and o.deleted = 0 + group by o.status, orderDate;