分析页统计:小板数量、小板面积统计接口实现

This commit is contained in:
gaoqr
2024-08-07 18:35:27 +08:00
parent adc2e8806a
commit 2a7f19d69f
11 changed files with 326 additions and 179 deletions
@@ -454,38 +454,4 @@ public class OrderController {
public CommonResult<Map<String, List<OrderOverdueRespVO>>> getOrderOverdue() {
return success(orderService.getOrderWarn());
}
// 小板数量 <集合>
@GetMapping("/getPlateCount")
@Operation(summary = "小板数量")
@Parameters({
@Parameter(name = "startTime", description = "开始时间", example = "2024-07-15"),
@Parameter(name = "endTime", description = "结束时间", example = "2024-07-16"),
@Parameter(name = "pageNo", description = "第几页", example = "1"),
@Parameter(name = "pageSize", description = "每页条数", example = "10")
})
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<PageResult<OrderGoodsPlateRespVO>> getPlateCount(@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime,
@RequestParam(value = "pageNo") Integer pageNo,
@RequestParam(value = "pageSize") Integer pageSize) {
return success(orderService.plateCount(startTime + " 00:00:00", endTime + " 23:59:59", pageNo, pageSize));
}
// 小板面积 <集合>
@GetMapping("/getPlateArea")
@Operation(summary = "小板面积")
@Parameters({
@Parameter(name = "startTime", description = "开始时间", example = "2024-07-15"),
@Parameter(name = "endTime", description = "结束时间", example = "2024-07-16"),
@Parameter(name = "pageNo", description = "第几页", example = "1"),
@Parameter(name = "pageSize", description = "每页条数", example = "10")
})
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<PageResult<OrderGoodsPlateRespVO>> getPlateArea(@RequestParam(value = "startTime") String startTime,
@RequestParam(value = "endTime") String endTime,
@RequestParam(value = "pageNo") Integer pageNo,
@RequestParam(value = "pageSize") Integer pageSize) {
return success(orderService.plateArea(startTime + " 00:00:00", endTime + " 23:59:59", pageNo, pageSize));
}
}
@@ -76,4 +76,16 @@ public class OrderStatisticsController {
public CommonResult<Map<String, Object>> getOrderAndPlanAreaGroup(@Valid OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.getOrderAndPlanAreaSumGroup(reqVO));
}
@GetMapping("/plateCount/group")
@Operation(summary = "小板数量分组统计")
public CommonResult<Map<String,Object>> getPlateCount(@Valid OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.getOrderPlateCountGroup(reqVO));
}
@GetMapping("/plateArea/group")
@Operation(summary = "小板面积分组统计")
public CommonResult<Map<String,Object>> getPlateArea(@Valid OrderStatisticsReqVO reqVO) {
return success(orderStatisticsService.getOrderPlateAreaGroup(reqVO));
}
}
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.controller.admin.order.vo.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
@@ -11,7 +12,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
public class OrderGoodsPlateRespVO {
public class OrderGoodsPlateRespVO implements Comparable<OrderGoodsPlateRespVO> {
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
private Long goodsId;
@@ -54,4 +55,47 @@ public class OrderGoodsPlateRespVO {
@Schema(description = "面积")
private BigDecimal orderArea;
@Schema(description = "生产单日期")
private String orderDate;
@Override
public int compareTo(@NotNull OrderGoodsPlateRespVO other) {
// 解析 date 字符串为年、月、周
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;
}
}
// 比较数量
if (orderCount != null && other.orderCount != null) {
return orderCount.compareTo(other.orderCount);
}
// 比较面积
if (orderArea != null && other.orderArea != null) {
return orderArea.compareTo(other.orderArea);
}
return 0;
}
}
@@ -0,0 +1,36 @@
package com.cf.imes.module.executor.dal.mysql.plate;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 生产单板件统计Mapper
*
* @author Gqr
* @since 2024/8/7 17:06
*/
@Mapper
public interface OrderPlateStatisticsMapper extends BaseMapperX<PlateDO> {
/**
* 基于生产单时间分组统计小板数量
*
* @param reqVO
* @return
*/
List<OrderGoodsPlateRespVO> selectPlateAnalysisListByCount(@Param("req") OrderStatisticsReqVO reqVO);
/**
* 基于生产单时间分组统计小板面积
*
* @param reqVO
* @return
*/
List<OrderGoodsPlateRespVO> selectPlateAnalysisListByArea(@Param("req") OrderStatisticsReqVO reqVO);
}
@@ -1,8 +1,6 @@
package com.cf.imes.module.executor.dal.mysql.plate;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
@@ -12,7 +10,6 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO;
import com.cf.imes.module.executor.controller.admin.plan.bo.GoodsNum;
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderIds;
import com.cf.imes.module.executor.controller.admin.plan.vo.*;
@@ -136,13 +133,6 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
List<GoodsNum> selectGoodsNum(@Param("orderIds") List<Long> orderIds,@Param("organId") Long organId);
// 小板数据分析
// List<OrderGoodsPlateRespVO> selectPlateAnalysisListByCount(@Param("organId") Long organId, @Param("startTime") String startTime, @Param("endTime") String endTime); // 数量
IPage<OrderGoodsPlateRespVO> selectPlateAnalysisListByCount(@Param("page") IPage<OrderGoodsPlateRespVO> page, @Param("organId") Long organId, @Param("startTime") String startTime, @Param("endTime") String endTime); // 数量
// List<OrderGoodsPlateRespVO> selectPlateAnalysisListByArea(@Param("organId") Long organId, @Param("startTime") String startTime, @Param("endTime") String endTime); // 面积
IPage<OrderGoodsPlateRespVO> selectPlateAnalysisListByArea(@Param("page") IPage<OrderGoodsPlateRespVO> page, @Param("organId") Long organId, @Param("startTime") String startTime, @Param("endTime") String endTime); // 面积
default List<PlateDO> selectPlateNum(Long orderId, Long organId) {
return selectList(new LambdaQueryWrapperX<PlateDO>()
.eq(PlateDO::getOrganId,organId)
@@ -178,14 +178,4 @@ public interface OrderService {
* 生产单超期告警分析统计
*/
Map<String,List<OrderOverdueRespVO>> getOrderWarn();
/**
* 小板数量
*/
PageResult<OrderGoodsPlateRespVO> plateCount(String startTime, String endTime, Integer pageNo, Integer pageSize);
/**
* 小板面积
*/
PageResult<OrderGoodsPlateRespVO> plateArea(String startTime, String endTime, Integer pageNo, Integer pageSize);
}
@@ -294,38 +294,6 @@ public class OrderServiceImpl implements OrderService {
return JsonUtils.zipString(orderBodyToString);
}
@Override
public PageResult<OrderGoodsPlateRespVO> plateCount(String startTime, String endTime, Integer pageNo, Integer pageSize) {
// 角色判断
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 数据查询
PageDTO<OrderGoodsPlateRespVO> page = new PageDTO<>(pageNo, pageSize);
IPage<OrderGoodsPlateRespVO> orderDetail;
if (loginUser.getIsSupAdmin()){
orderDetail = plateMapper.selectPlateAnalysisListByCount(page,null, startTime, endTime);
}else {
orderDetail = plateMapper.selectPlateAnalysisListByCount(page,OrganContextHolder.getOrganId(), startTime, endTime);
}
PageResult<OrderGoodsPlateRespVO> pageResult = new PageResult(orderDetail.getRecords(), orderDetail.getTotal());
return pageResult;
}
@Override
public PageResult<OrderGoodsPlateRespVO> plateArea(String startTime, String endTime, Integer pageNo, Integer pageSize) {
// 角色判断
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 数据查询
PageDTO<OrderGoodsPlateRespVO> page = new PageDTO<>(pageNo, pageSize);
IPage<OrderGoodsPlateRespVO> orderDetail;
if (loginUser.getIsSupAdmin()){
orderDetail = plateMapper.selectPlateAnalysisListByArea(page,null, startTime, endTime);
}else {
orderDetail = plateMapper.selectPlateAnalysisListByArea(page,OrganContextHolder.getOrganId(), startTime, endTime);
}
PageResult<OrderGoodsPlateRespVO> pageResult = new PageResult(orderDetail.getRecords(), orderDetail.getTotal());
return pageResult;
}
@Override
public List<OrderRoomBodyRespVO> getRoomAndBody(Long planId) {
@@ -50,10 +50,26 @@ public interface OrderStatisticsService {
Map<String, Object> getOrderAndPlanCountGroup(OrderStatisticsReqVO reqVO);
/**
* 生产单、排单平方数统计
* 生产单、排单平方数分组统计
*
* @param reqVO
* @return
*/
Map<String,Object> getOrderAndPlanAreaSumGroup(OrderStatisticsReqVO reqVO);
/**
* 小板数量分组统计
*
* @param reqVO
* @return
*/
Map<String, Object> getOrderPlateCountGroup(OrderStatisticsReqVO reqVO);
/**
* 小板面积分组统计
*
* @param reqVO
* @return
*/
Map<String, Object> getOrderPlateAreaGroup(OrderStatisticsReqVO reqVO);
}
@@ -4,6 +4,7 @@ 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.OrderGoodsPlateRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsAreaRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsStatusRespVO;
@@ -11,6 +12,7 @@ import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsA
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsCountRespVO;
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.enums.OrderStatisticsUnit;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -44,6 +46,9 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
@Resource
private PlanMapper planMapper;
@Resource
private OrderPlateStatisticsMapper orderPlateStatisticsMapper;
@Override
@OrganIgnore
public Integer orderCount(OrderStatisticsReqVO reqVO) {
@@ -79,11 +84,9 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
public Map<String, Object> getOrderStatusCount(OrderStatisticsReqVO reqVO) {
Map<String, Object> resultMap = new HashMap<>();
// 获取机构id
reqVO.setOrganId(getOrganIdParam(reqVO));
// 计算时间跨度
getTimeSpan(reqVO);
// 所有的日期集合
List<String> dateList = getDateList(reqVO);
resultMap.put("dateList", dateList);
// 查询订单状态统计数据
List<OrderStatisticsStatusRespVO> orderStatusRespVOS = orderStatisticsMapper.selectOrderStatusCountGroupBy(reqVO);
@@ -93,10 +96,6 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
.sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrderStatisticsStatusRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
// 所有的日期集合
List<String> dateList = generateDateRange(reqVO);
resultMap.put("dateList", dateList);
// 遍历订单状态所有枚举值
List<Map<String, Object>> series = new ArrayList<>();
for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
@@ -134,14 +133,8 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
public Map<String, Object> getOrderAndPlanCountGroup(OrderStatisticsReqVO reqVO) {
Map<String, Object> resultMap = new LinkedHashMap<>();
// 获取机构id
reqVO.setOrganId(getOrganIdParam(reqVO));
// 计算时间跨度
getTimeSpan(reqVO);
// 所有的日期集合
List<String> dateList = generateDateRange(reqVO);
List<String> dateList = getDateList(reqVO);
Map<String, List<OrderStatisticsStatusRespVO>> orderRespMap = orderStatisticsMapper.selectOrderCountGroupByOrderDate(reqVO).stream()
.sorted(Comparator.naturalOrder())
@@ -179,14 +172,8 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
public Map<String, Object> getOrderAndPlanAreaSumGroup(OrderStatisticsReqVO reqVO) {
Map<String, Object> resultMap = new LinkedHashMap<>();
// 获取机构id
reqVO.setOrganId(getOrganIdParam(reqVO));
// 计算时间跨度
getTimeSpan(reqVO);
// 所有的日期集合
List<String> dateList = generateDateRange(reqVO);
List<String> dateList = getDateList(reqVO);
Map<String, List<OrderStatisticsAreaRespVO>> orderRespMap = orderStatisticsMapper.selectOrderAreaGroupByOrderDate(reqVO).stream()
.sorted(Comparator.naturalOrder())
@@ -213,6 +200,132 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
return resultMap;
}
@Override
public Map<String, Object> getOrderPlateCountGroup(OrderStatisticsReqVO reqVO) {
Map<String, Object> resultMap = new LinkedHashMap<>();
// 所有的日期集合
List<String> dateList = getDateList(reqVO);
resultMap.put("dateList", dateList);
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOList = orderPlateStatisticsMapper.selectPlateAnalysisListByCount(reqVO);
// 基于相同的orderDate分组
Map<String, List<OrderGoodsPlateRespVO>> orderGoodsPlateRespMap = orderGoodsPlateRespVOList.stream()
.sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrderGoodsPlateRespVO::getOrderDate, LinkedHashMap::new, Collectors.toList()));
// 获取所有商品map
Map<Long, String> goodsMap = orderGoodsPlateRespMap.values().stream()
.flatMap(List::stream)
.collect(Collectors.toMap(
OrderGoodsPlateRespVO::getGoodsId,
OrderGoodsPlateRespVO::getMaterial,
(oldValue, newValue) -> newValue
));
// 遍历订单状态所有枚举值
List<Map<String, Object>> series = new ArrayList<>();
for (Map.Entry<Long, String> entry : goodsMap.entrySet()) {
Map<String, Object> seriesItem = new HashMap<>();
int[] sumArr = new int[dateList.size()];
// 遍历完整的日期范围
int index = 0;
for (String dateStr : dateList) {
// 查找匹配的goodsId
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOS = orderGoodsPlateRespMap.get(dateStr);
int count = 0;
if (orderGoodsPlateRespVOS != null) {
count = orderGoodsPlateRespVOS.stream()
.filter(respVO -> Objects.equals(entry.getKey(), respVO.getGoodsId()))
.map(OrderGoodsPlateRespVO::getOrderCount)
.findFirst().orElse(0);
}
sumArr[index++] = count;
}
seriesItem.put("data", sumArr);
seriesItem.put("id", entry.getKey());
seriesItem.put("name", entry.getValue());
series.add(seriesItem);
}
resultMap.put("series", series);
return resultMap;
}
@Override
public Map<String, Object> getOrderPlateAreaGroup(OrderStatisticsReqVO reqVO) {
Map<String, Object> resultMap = new LinkedHashMap<>();
// 所有的日期集合
List<String> dateList = getDateList(reqVO);
resultMap.put("dateList", dateList);
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOList = orderPlateStatisticsMapper.selectPlateAnalysisListByArea(reqVO);
// 基于相同的orderDate分组
Map<String, List<OrderGoodsPlateRespVO>> orderGoodsPlateRespMap = orderGoodsPlateRespVOList.stream()
.sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrderGoodsPlateRespVO::getOrderDate, LinkedHashMap::new, Collectors.toList()));
// 获取所有商品map
Map<Long, String> goodsMap = orderGoodsPlateRespMap.values().stream()
.flatMap(List::stream)
.collect(Collectors.toMap(
OrderGoodsPlateRespVO::getGoodsId,
OrderGoodsPlateRespVO::getMaterial,
(oldValue, newValue) -> newValue
));
// 遍历订单状态所有枚举值
List<Map<String, Object>> series = new ArrayList<>();
for (Map.Entry<Long, String> entry : goodsMap.entrySet()) {
Map<String, Object> seriesItem = new HashMap<>();
BigDecimal[] areaArr = new BigDecimal[dateList.size()];
// 遍历完整的日期范围
int index = 0;
for (String dateStr : dateList) {
// 查找匹配的goodsId
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOS = orderGoodsPlateRespMap.get(dateStr);
BigDecimal area = new BigDecimal(0);
if (orderGoodsPlateRespVOS != null) {
area = orderGoodsPlateRespVOS.stream()
.filter(respVO -> Objects.equals(entry.getKey(), respVO.getGoodsId()))
.map(OrderGoodsPlateRespVO::getOrderArea)
.findFirst().orElse(new BigDecimal(0));
}
areaArr[index++] = area;
}
seriesItem.put("data", areaArr);
seriesItem.put("id", entry.getKey());
seriesItem.put("name", entry.getValue());
series.add(seriesItem);
}
resultMap.put("series", series);
return resultMap;
}
/**
* 获取日期区间格式下的所有日期字符串
* 1、reqVO设置机构id
* 2、计算时间跨度设置到reqVO
* 3、返回所有日期的集合
* @param reqVO
* @return
*/
private List<String> getDateList(OrderStatisticsReqVO reqVO) {
// 获取机构id
reqVO.setOrganId(getOrganIdParam(reqVO));
// 计算时间跨度
getTimeSpan(reqVO);
// 所有的日期集合
return generateDateRange(reqVO);
}
/**
* 获取统计的时间跨度
* 计算起止时间:前端不传入时间就根据维度单位从当前日期计算
@@ -0,0 +1,80 @@
<?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.plate.OrderPlateStatisticsMapper">
<select id="selectPlateAnalysisListByCount" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO">
SELECT g.goods_id,
MIN(g.material) AS material,
MIN(g.brand) AS brand,
MIN(g.color) AS color,
MIN(g.goods_name) AS goods_name,
MIN(g.height) AS height,
MIN(g.spec) AS spec,
MIN(g.texture) AS texture,
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()">
,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()">
,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()">
,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()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as orderDate
</if>
FROM order_goods g
LEFT JOIN order_plate a ON g.id = a.goods_id AND g.organ_id = #{req.organId}
LEFT JOIN orders o ON o.id = a.order_id AND o.organ_id = #{req.organId}
WHERE a.deleted = 0
AND o.order_date BETWEEN #{req.createTime[0]} AND #{req.createTime[1]}
AND g.organ_id = #{req.organId}
GROUP BY
g.goods_id,orderDate
HAVING
SUM (a.area) > 0
ORDER BY
orderCount DESC;
</select>
<select id="selectPlateAnalysisListByArea"
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO">
SELECT g.goods_id,
MIN(g.material) AS material,
MIN(g.brand) AS brand,
MIN(g.color) AS color,
MIN(g.goods_name) AS goods_name,
MIN(g.height) AS height,
MIN(g.spec) AS spec,
MIN(g.texture) AS texture,
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()">
,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()">
,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()">
,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()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as orderDate
</if>
FROM order_goods g
LEFT JOIN order_plate a ON g.id = a.goods_id AND g.organ_id = #{req.organId}
LEFT JOIN orders o ON o.id = a.order_id AND o.organ_id = #{req.organId}
WHERE a.deleted = 0
AND o.order_date BETWEEN #{req.createTime[0]} AND #{req.createTime[1]}
AND g.organ_id = #{req.organId}
GROUP BY
g.goods_id,orderDate
HAVING
SUM (a.area) > 0
ORDER BY
orderArea DESC;
</select>
</mapper>
@@ -601,73 +601,5 @@
</select>
<select id="selectPlateAnalysisListByCount" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO">
SELECT
MIN(g.brand) AS brand,
MIN(g.color) AS color,
g.goods_id,
MIN(g.goods_name) AS goods_name,
MIN(g.height) AS height,
MIN(g.material) AS material,
MIN(g.spec) AS spec,
MIN(g.texture) AS texture,
MIN(g.thickness) AS thickness,
MIN(g.width) AS width,
MIN(o.order_date) AS orderDate,
SUM(a.area) AS orderArea,
COUNT(a.id) AS orderCount
FROM
order_goods g
LEFT JOIN order_plate a ON g.id = a.goods_id AND g.organ_id = a.organ_id
LEFT JOIN orders o ON o.id = a.order_id
WHERE
a.deleted = 0
AND DATE(o.order_date) BETWEEN #{startTime} AND #{endTime}
<if test="organId != null">
AND o.organ_id = #{organId}
</if>
GROUP BY
g.goods_id
HAVING
SUM(a.area) > 0
ORDER BY
orderCount DESC;
</select>
<select id="selectPlateAnalysisListByArea" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderGoodsPlateRespVO">
SELECT
MIN(g.brand) AS brand,
MIN(g.color) AS color,
g.goods_id,
MIN(g.goods_name) AS goods_name,
MIN(g.height) AS height,
MIN(g.material) AS material,
MIN(g.spec) AS spec,
MIN(g.texture) AS texture,
MIN(g.thickness) AS thickness,
MIN(g.width) AS width,
MIN(o.order_date) AS orderDate,
SUM(a.area) AS orderArea,
COUNT(a.id) AS orderCount
FROM
order_goods g
LEFT JOIN order_plate a ON g.id = a.goods_id AND g.organ_id = a.organ_id
LEFT JOIN orders o ON o.id = a.order_id
WHERE
a.deleted = 0
AND DATE(o.order_date) BETWEEN #{startTime} AND #{endTime}
<if test="organId != null">
AND o.organ_id = #{organId}
</if>
GROUP BY
g.goods_id
HAVING
SUM(a.area) > 0
ORDER BY
orderArea DESC;
</select>
</mapper>