生产单管理-列表时间修改

This commit is contained in:
lym
2024-07-11 09:31:15 +08:00
parent 4bd39e579a
commit 044bdb3163
13 changed files with 207 additions and 15 deletions
@@ -26,7 +26,6 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.io.File;
import java.time.LocalDateTime;
import java.util.*;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -365,4 +364,29 @@ public class OrderController {
JSONObject orderList = apiDataAchieve.getApiOrderList(token,shopId,startTime,endTime,orderNo,customOrderNo).get();
return success(orderService.getApiOrderList(orderList));
}
// 生产单状态分组统计返回
@GetMapping("/getOrderStatusCount")
@Operation(summary = "生产单状态分组统计返回")
@Parameter(name = "startTerm", description = "按周,按月,按年", required = false, example = "1,2,3")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<List<OrderStatusRespVO>> getOrderStatusCount(@RequestParam(value = "startTerm", required = false) Integer startTerm) {
return success(orderService.getOrderStatusCount(startTerm));
}
// 小板数据分析
@GetMapping("/getOrderPlateAnalysisCount")
@Operation(summary = "小板数据分析统计(小板数量、小班面积)")
@PreAuthorize("@ss.hasPermission('productManager:List')")
public CommonResult<List<OrderGoodsPlateRespVO>> getOrderPlateAnalysisCount() {
return success(orderService.getOrderPlateAnalysisCount());
}
// 生产单超期告警
// @GetMapping("/getOrderOverdue")
// @Operation(summary = "生产单超期告警")
// @PreAuthorize("@ss.hasPermission('productManager:List')")
// public CommonResult<List<OrderOverdueRespVO>> getOrderOverdue() {
// return success(orderService.getOrderOverdue());
// }
}
@@ -0,0 +1,65 @@
package com.cf.imes.module.executor.controller.admin.order.vo.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 按材料统计小板数量")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
public class OrderGoodsPlateRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4109")
private Long id;
@Schema(description = "生产单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12114")
private Long orderId;
@Schema(description = "设计端商品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "832")
private Long rawGoodsId;
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
private Long goodsId;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
private String goodsName;
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板", requiredMode = Schema.RequiredMode.REQUIRED)
private String material;
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
private String color;
@Schema(description = "纹路")
private Integer texture;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal width;
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal height;
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal thickness;
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "7305")
private BigDecimal price;
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
private String brand;
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
private String spec;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
private String remark;
@Schema(description = "数量")
private Integer orderCount;
@Schema(description = "面积")
private BigDecimal orderArea;
}
@@ -0,0 +1,18 @@
package com.cf.imes.module.executor.controller.admin.order.vo.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Schema(description = "管理后台 - 生产单状态统计")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
public class OrderStatusRespVO {
@Schema(description = "订单状态")
private Integer orderState;
@Schema(description = "订单数量")
private Integer orderCount;
}
@@ -10,12 +10,15 @@ 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.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
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;
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.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -132,4 +135,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
List<OrderRespVOCopy> selectOrderListByIds(@Param("orderIds") List<OrderIds> orderIds, @Param("organId")Long organId);
List<Long> selectOrderIds(@Param(Constants.WRAPPER) Wrapper<OrderDO> wrapper);
// 生产单状态统计
List<OrderStatusRespVO> selectOrderStatusCount(@Param("organId")Long organId, @Param("orderDate") LocalDateTime orderDate);
}
@@ -1,23 +1,21 @@
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;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
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.*;
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import org.apache.ibatis.annotations.Mapper;
import com.cf.imes.module.executor.controller.admin.plate.vo.*;
@@ -138,4 +136,6 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
List<GoodsNum> selectGoodsNum(@Param("orderIds") List<Long> orderIds,@Param("organId") Long organId);
// 小板数据分析
List<OrderGoodsPlateRespVO> selectPlateAnalysisList(@Param("organId") Long organId, @Param("orderDate") LocalDateTime orderDate);
}
@@ -16,7 +16,6 @@ import org.springframework.boot.system.ApplicationHome;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -172,4 +171,14 @@ public interface OrderService {
/**查找api单号列表
*/
List<ApiOrderRespVO> getApiOrderList(JSONObject orderList);
/**
* 生产单状态统计
*/
List<OrderStatusRespVO> getOrderStatusCount(Integer startTerm);
/**
* 小板数据分析统计
*/
List<OrderGoodsPlateRespVO> getOrderPlateAnalysisCount();
}
@@ -62,10 +62,9 @@ import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.*;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -417,7 +416,9 @@ public class OrderServiceImpl implements OrderService {
List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) map.get("plateGoodDOLists");
validateCustomOrderNoExists(order.get(0).getCustomOrderNo());
orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, null, itemDO, order.get(0), goodsDO, plateGoodDOS);
String nickName = SecurityFrameworkUtils.getLoginUser().getNickname();
OrderDO orderDO = order.get(0).setSalesman(nickName).setSplitter(nickName);
orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, null, itemDO, orderDO, goodsDO, plateGoodDOS);
List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);
if (orderModelDOs.size() > 0) {
@@ -570,7 +571,35 @@ public class OrderServiceImpl implements OrderService {
return apiOrderRespVOS;
}
// 判断是否已经导入
@Override
public List<OrderStatusRespVO> getOrderStatusCount(Integer startTerm) {
// 根据开始条件选择
LocalDateTime orderDate = null;
LocalTime endOfDay = LocalTime.of(00, 00, 00);
switch (startTerm) {
case 1:
orderDate = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay();
break;
case 2:
orderDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
break;
case 3:
orderDate = LocalDate.now().withMonth(1).withDayOfMonth(1).atStartOfDay();
break;
}
List<OrderStatusRespVO> orderStatusRespVOS = orderMapper.selectOrderStatusCount(OrganContextHolder.getOrganId(), orderDate);
orderStatusRespVOS.removeIf(obj -> obj.getOrderState() == OrderStatusEnum.EMPTY.getStatus());
return orderStatusRespVOS;
}
@Override
public List<OrderGoodsPlateRespVO> getOrderPlateAnalysisCount() {
LocalDateTime orderDate = LocalDate.now().withDayOfMonth(1).atStartOfDay();
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOS = plateMapper.selectPlateAnalysisList(OrganContextHolder.getOrganId(), orderDate);
return orderGoodsPlateRespVOS;
}
// 判断是否已经导入
private Boolean validateOrderNoExists(String orderNo, Long organId) {
if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
.eq(OrderDO::getApiOrderId, orderNo)
@@ -171,10 +171,10 @@ public class ApiDataAchieve {
public Future<JSONObject> getApiOrderList(String token,String shopId,String createDateMin, String createDateMax, String orderNo, String customOrderNo) {
JSONObject jsonOrders = new JSONObject();
if (createDateMin != null){
jsonOrders.put("create_date_min", createDateMin);
jsonOrders.put("create_date_min", createDateMin + " 00:00:00");
}
if (createDateMax != null) {
jsonOrders.put("create_date_max", createDateMax);
jsonOrders.put("create_date_max", createDateMax + " 23:59:59");
}
jsonOrders.put("curr_page", 1);
@@ -278,6 +278,7 @@ public class ApiTypeRealize {
OrderDO orderDO = OrderDO.builder()
.id(orderId)
.apiOrderId(orderNo)
.parentNo(0L)
.orderDate(orderDate.atStartOfDay())
.deliveryDate(deliveryDate.atStartOfDay())
@@ -81,6 +81,16 @@
</select>
<select id="selectOrderStatusCount" resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatusRespVO">
select
o.status as orderState,
count(o.id) as orderCount
from orders o
where o.organ_id = #{organId}
and DATE(o.order_date) >= #{orderDate}
and o.deleted = false
group by o.status
</select>
</mapper>
@@ -481,5 +481,33 @@
</select>
<select id="selectPlateAnalysisList" 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
o.organ_id = #{organId}
AND a.deleted = false
AND DATE(o.order_date) >= #{orderDate}
GROUP BY
g.goods_id
</select>
</mapper>