From 9c303e635402975dfd6c11b76edec912aa6605a9 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Fri, 7 Jun 2024 15:22:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81=E6=9E=9A=E4=B8=BE=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E9=AD=94=E6=B3=95=E5=80=BC=202=E3=80=81=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=A0=81=E8=A7=84=E8=8C=83=203=E3=80=81=E9=83=A8?= =?UTF-8?q?=E5=88=86sql=E8=AF=AD=E5=8F=A5=E5=A2=9E=E5=8A=A0=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E8=B5=B0=E7=B4=A2=E5=BC=95=EF=BC=8Cmycat=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/enums/ErrorCodeConstants.java | 2 ++ .../module/executor/enums/OrderItemType.java | 33 +++++++++++++++++++ .../executor/enums/OrderPlanStatusEnum.java | 32 ++++++++++++++++++ .../enums/OrderPlateFilterTypeEnum.java | 32 ++++++++++++++++++ .../optimizeplan/OptimizePlanServiceImpl.java | 31 ++++------------- .../service/plan/PlanServiceImpl.java | 23 ++++++------- .../resources/mapper/plate/PlateMapper.xml | 17 ++++++---- 7 files changed, 129 insertions(+), 41 deletions(-) create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderItemType.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlanStatusEnum.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlateFilterTypeEnum.java diff --git a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java index c851cba16..cc7c5375f 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java +++ b/cf-module-prod-executor/cf-module-prod-executor-api/src/main/java/com/cf/imes/module/executor/enums/ErrorCodeConstants.java @@ -60,4 +60,6 @@ public interface ErrorCodeConstants { ErrorCode FILE_READ_ERR = new ErrorCode(1_002_029_012, "文件读取错误"); ErrorCode FILE_ADD_ERR = new ErrorCode(1_002_029_012, "文件已经存在是否强制保存"); ErrorCode FILE_UPLOAD_ERR = new ErrorCode(1_002_029_012, "文件内容为空"); + + ErrorCode SOURCE_NOT_EXITS_ERROR = new ErrorCode(1_002_029_013, "源数据查询失败"); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderItemType.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderItemType.java new file mode 100644 index 000000000..68cb9db86 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderItemType.java @@ -0,0 +1,33 @@ +package com.cf.imes.module.executor.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * 生产单明细类型 + * + * @author Gqr + * @since 2024/6/7 14:50 + */ +@RequiredArgsConstructor +@Getter +public enum OrderItemType { + + BOARD(1, "板材"), + + PARTS(2, "五金/配件"), + + OTHER(3, "其他"), + + QUOTE_PARTS(4, "报价配件"); + + /** + * 类型编码 + */ + private final Integer code; + + /** + * 描述 + */ + private final String desc; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlanStatusEnum.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlanStatusEnum.java new file mode 100644 index 000000000..4f993f5a8 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlanStatusEnum.java @@ -0,0 +1,32 @@ +package com.cf.imes.module.executor.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * 排单状态 + * + * @author Gqr + * @since 2024/6/7 14:25 + */ +@RequiredArgsConstructor +@Getter +public enum OrderPlanStatusEnum { + NEW(0, "新单"), + + APPLY(1, "板材已申请"), + + OPENING(2, "开料中"), + + OPENED(3, "已开料"); + + /** + * 类型编码 + */ + private final Integer code; + + /** + * 描述 + */ + private final String desc; +} \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlateFilterTypeEnum.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlateFilterTypeEnum.java new file mode 100644 index 000000000..26bda1b9a --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/enums/OrderPlateFilterTypeEnum.java @@ -0,0 +1,32 @@ +package com.cf.imes.module.executor.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * 生产单板件排单过滤类型 + * + * @author Gqr + * @since 2024/6/7 14:31 + */ +@RequiredArgsConstructor +@Getter +public enum OrderPlateFilterTypeEnum { + HAS_CUT_THROUGH_SHAPE(1, "有挖穿造型"), + + HAS_CUT_PUNCH(2, "有挖穿孔"), + + HAS_2D_KNIFE_PATHS(4, "有二维刀路"), + + STACKABLE(8, "可叠"); + + /** + * 类型编码 + */ + private final Integer code; + + /** + * 描述 + */ + private final String desc; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java index 115446e50..071f30054 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java @@ -1,9 +1,9 @@ package com.cf.imes.module.executor.service.optimizeplan; -import cn.hutool.Hutool; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch._types.FieldValue; @@ -11,7 +11,6 @@ import co.elastic.clients.elasticsearch.core.*; import co.elastic.clients.elasticsearch.core.search.Hit; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.util.json.JsonUtils; -import com.cf.imes.framework.common.util.object.BeanUtils; import com.cf.imes.framework.es.core.service.ESDocumentService; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; @@ -35,30 +34,21 @@ import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper; import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper; import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper; +import com.cf.imes.module.executor.enums.ErrorCodeConstants; +import com.cf.imes.module.executor.enums.OrderPlanStatusEnum; import com.cf.imes.module.executor.util.RandomUtils; import com.cf.imes.module.executor.util.RectangleChecker; import com.cf.imes.module.infra.api.file.FileApi; import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO; import com.cf.imes.module.system.api.dataSource.DataSourceApi; import com.cf.imes.module.system.api.machine.MachineApi; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.handler.codec.http2.DefaultHttp2Headers; -import io.netty.handler.codec.http2.DefaultHttp2HeadersDecoder; -import io.netty.handler.codec.http2.DefaultHttp2HeadersEncoder; -import io.netty.handler.codec.http2.Http2Headers; -import io.swagger.v3.core.util.Json; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; @@ -68,9 +58,6 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NOT_EXISTS; import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLAN_NOT_EXISTS; -import io.netty.handler.codec.http2.Http2HeadersEncoder; -import io.netty.handler.codec.http2.Http2HeadersDecoder; - /** * @author there */ @@ -182,7 +169,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { } planMapper.updateById(PlanDO.builder() .id(planId) - .status(2) + .status(OrderPlanStatusEnum.OPENING.getCode()) .build()); return Boolean.TRUE; } @@ -290,22 +277,18 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { @Override public OrderSource getOrderSource(Long orderId, Long planId, Long machineId) { - if(!Objects.isNull(orderId) && !Objects.isNull(planId)) { - throw exception(154112,"生产单id与排单id只能传一个"); - } OrderSource orderSource; - if(!Objects.isNull(orderId)) { + if (ObjectUtil.isNotNull(orderId)) { orderSource = getOrderSourceByOrderId(orderId); orderSource.setMachineDTO(machineApi.getMachineDetail(machineId).getCheckedData()); return orderSource; } - if(!Objects.isNull(planId)) { + if (ObjectUtil.isNotNull(planId)) { orderSource = getOrderSourceByPlanId(planId); orderSource.setMachineDTO(machineApi.getMachineDetail(machineId).getCheckedData()); return orderSource; } - throw exception(154112,"生产单id或排单id不能都空"); - + throw exception(ErrorCodeConstants.SOURCE_NOT_EXITS_ERROR); } @Override diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java index 56cf8b5c5..a2dead928 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; @@ -23,6 +22,9 @@ import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper; import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper; import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper; import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; +import com.cf.imes.module.executor.enums.OrderItemType; +import com.cf.imes.module.executor.enums.OrderPlanStatusEnum; +import com.cf.imes.module.executor.enums.OrderPlateFilterTypeEnum; import com.cf.imes.module.system.api.machine.MachineApi; import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO; import com.github.yulichang.wrapper.MPJLambdaWrapper; @@ -35,7 +37,6 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -179,7 +180,7 @@ public class PlanServiceImpl implements PlanService { if (planDO == null) { throw exception(PLAN_NOT_EXISTS); } - if (planDO.getStatus().equals(2) || planDO.getStatus().equals(3)) { + if (OrderPlanStatusEnum.OPENING.getCode().equals(planDO.getStatus()) || OrderPlanStatusEnum.OPENED.getCode().equals(planDO.getStatus())) { throw exception(PLAN_NOT_ALLOW_DELETE); } // 删除 @@ -303,13 +304,13 @@ public class PlanServiceImpl implements PlanService { .orderByDesc("a.create_time"); List filterTypes = new ArrayList<>(); if (Objects.nonNull(pageReqVO.getHoleThrough()) && pageReqVO.getHoleThrough()) { - filterTypes.add(1); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_CUT_THROUGH_SHAPE.getCode()); } if (Objects.nonNull(pageReqVO.getBurrow()) && pageReqVO.getBurrow()) { - filterTypes.add(2); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_CUT_PUNCH.getCode()); } if (Objects.nonNull(pageReqVO.getTwoDimensionalToolPath()) && pageReqVO.getTwoDimensionalToolPath()) { - filterTypes.add(4); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_2D_KNIFE_PATHS.getCode()); } queryWrapperX.inIfPresent("op.filter_type", filterTypes); @@ -350,7 +351,7 @@ public class PlanServiceImpl implements PlanService { .planId(req.getPlanId()) .orderId(obj.getOrderId()) .plateId(obj.getPlateId()) - .type(1) + .type(OrderItemType.BOARD.getCode()) .build()); planItemDOS.add(PlanItemDO.builder() @@ -370,7 +371,7 @@ public class PlanServiceImpl implements PlanService { if (planDO == null) { throw exception(PLAN_NOT_EXISTS); } - if (planDO.getStatus().equals(0) || planDO.getStatus().equals(1)) { + if (OrderPlanStatusEnum.NEW.getCode().equals(planDO.getStatus()) || OrderPlanStatusEnum.APPLY.getCode().equals(planDO.getStatus())) { throw exception(PLAN_NOT_ALLOW_CANCEL); } Set itemIds = planItemMapper.selectList(new LambdaQueryWrapperX().eq(PlanItemDO::getPlanId, id)) @@ -386,13 +387,13 @@ public class PlanServiceImpl implements PlanService { QueryWrapperX queryWrapperX = new QueryWrapperX<>(); List filterTypes = new ArrayList<>(); if (Objects.nonNull(vo.getHoleThrough()) && vo.getHoleThrough()) { - filterTypes.add(1); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_CUT_THROUGH_SHAPE.getCode()); } if (Objects.nonNull(vo.getBurrow()) && vo.getBurrow()) { - filterTypes.add(2); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_CUT_PUNCH.getCode()); } if (Objects.nonNull(vo.getTwoDimensionalToolPath()) && vo.getTwoDimensionalToolPath()) { - filterTypes.add(4); + filterTypes.add(OrderPlateFilterTypeEnum.HAS_2D_KNIFE_PATHS.getCode()); } queryWrapperX.eq("p.plan_id", vo.getPlanId()) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml index 756544005..79b3affa8 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml @@ -25,9 +25,9 @@ b.custom_order_no, b.customer, b.address, b.remark, b.id as orderId, c.goods_name, c.material, c.color, c.goods_id,oi.num, CASE WHEN a.unregular_point_count = 0 THEN '否' ELSE '是' END AS specialShaped, - CASE WHEN front_model_count = 0 or a.back_hole_count or a.side_hole_count THEN '否' ELSE '是' END AS profiling + CASE WHEN front_model_count = 0 or a.back_hole_count = 0 or a.side_hole_count = 0 THEN '否' ELSE '是' END AS profiling from order_plate a - LEFT JOIN order_item oi on a.id = oi.plate_id + LEFT JOIN order_item oi on a.id = oi.plate_id and a.order_id = oi.order_id LEFT JOIN `order` b on a.order_id = b.id LEFT JOIN order_goods c on a.goods_id = c.id @@ -47,7 +47,7 @@ resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlateResList"> select a.order_id, a.plate_no , a.name as plateName,a.is_special_shaped,a.is_sculpt, e.material, e.color, e.width, e.height, e.thickness, b.room_id, b.body_id from order_plate a - LEFT JOIN order_item b ON a.id = b.plate_id + LEFT JOIN order_item b ON a.id = b.plate_id AND a.order_id = b.order_id LEFT JOIN order_goods e ON e.id = a.goods_id AND e.order_id = a.order_id LEFT JOIN order_plan_item p ON b.id = p.item_id ${ew.customSqlSegment} @@ -80,10 +80,15 @@ From 6d5b232d7ab37b883ac06e0b0074be712a80d3e4 Mon Sep 17 00:00:00 2001 From: liuzhaotian Date: Fri, 7 Jun 2024 18:18:57 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3-=E8=8E=B7=E5=BE=97?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=8D=95=E6=95=B0=E6=8D=AE=E6=BA=90=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9-=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8E=92=E5=8D=95=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/PlanFilterTypeEnum.java | 28 ++ .../common/enums/PlanStatusEnum.java | 29 ++ .../enums/ProcessProcessingTypeEnum.java | 25 ++ .../common/enums/RemainTypeEnum.java | 20 ++ .../es/core/service/ESDocumentService.java | 9 + .../core/service/ESDocumentServiceImpl.java | 34 ++ .../admin/plan/OptimizePlanController.java | 17 +- .../controller/admin/plan/PlanController.java | 2 +- .../controller/admin/plan/bo/OrderSource.java | 17 +- .../saveOptimize/OptimizeRemainPlate.java | 100 ++++++ .../plan/saveOptimize/SaveOrderReqVO.java | 66 ++++ .../SavePlanPlateResultReqVO.java | 48 +++ .../controller/admin/plan/vo/GoodsReqVO.java | 92 +++++ .../plan/vo/OptimizePlateDetialRespVO.java | 49 --- .../admin/plan/vo/OrderRespVOCopy.java | 16 +- .../admin/plan/vo/PlateDetialRespVO.java | 13 +- .../admin/plan/vo/PlateReqPageVO.java | 4 +- .../goods/OptimizeBoardModelDO.java | 128 +++++++ .../remainplaten/RemainPlateDO.java | 25 +- .../executor/dal/mysql/goods/GoodsMapper.java | 8 + .../executor/dal/mysql/order/OrderMapper.java | 2 +- .../dal/mysql/orderItem/OrderItemMapper.java | 8 + .../executor/dal/mysql/plate/PlateMapper.java | 5 +- .../mysql/remainplaten/RemainPlateMapper.java | 16 +- .../optimizeplan/OptimizePlanService.java | 8 + .../optimizeplan/OptimizePlanServiceImpl.java | 330 +++++++++++++++--- .../executor/service/plan/PlanService.java | 3 +- .../service/plan/PlanServiceImpl.java | 51 +-- .../service/plate/PlateServiceImpl.java | 25 +- .../module/executor/util/OrganIdUtils.java | 18 + .../resources/mapper/goods/GoodsMapper.xml | 32 ++ .../resources/mapper/order/OrderMapper.xml | 10 +- .../mapper/orderItem/OrderItemMapper.xml | 16 + .../resources/mapper/plate/PlateMapper.xml | 103 +----- .../process/ProductionProcessServiceImpl.java | 5 +- script/es/imes_order_remain_plate_model.index | 118 +++++++ 36 files changed, 1218 insertions(+), 262 deletions(-) create mode 100644 cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanFilterTypeEnum.java create mode 100644 cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanStatusEnum.java create mode 100644 cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/ProcessProcessingTypeEnum.java create mode 100644 cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/RemainTypeEnum.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/OptimizeRemainPlate.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SaveOrderReqVO.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SavePlanPlateResultReqVO.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/GoodsReqVO.java delete mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OptimizePlateDetialRespVO.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/goods/OptimizeBoardModelDO.java create mode 100644 cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/OrganIdUtils.java create mode 100644 script/es/imes_order_remain_plate_model.index diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanFilterTypeEnum.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanFilterTypeEnum.java new file mode 100644 index 000000000..7a715bf72 --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanFilterTypeEnum.java @@ -0,0 +1,28 @@ +package com.cf.imes.framework.common.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum PlanFilterTypeEnum { + + + DIGGINGTHROUGHTHESHAPE(1,"有挖穿造型"), + THEREAREPERFORATEDHOLES(2,"有挖穿孔"), + TWODIMENSIONALCUTTINGPATH(4,"有二维刀路"), + STACKABLE(8,"可叠"); + + private Integer type; + private String filterNames; + + public boolean equals(Integer type) { + return this.type .equals(type) ; + } + + public boolean equals(PlanFilterTypeEnum enableStatusEnum) { + return enableStatusEnum != null && enableStatusEnum.type .equals(this.getType()) ; + } + +} diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanStatusEnum.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanStatusEnum.java new file mode 100644 index 000000000..8d591adce --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/PlanStatusEnum.java @@ -0,0 +1,29 @@ +package com.cf.imes.framework.common.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum PlanStatusEnum { + + + NEWORDER(0,"新单"), + BOARDHASBEENAPPLIEDFOR(1,"板材已申请"), + DURINGCUTTING(2,"开料中"), + OPENEDMATERIAL(3,"已开料"); + + private Integer status; + private String scheduling; + + + public boolean equals(Integer status) { + return this.status .equals(status) ; + } + + public boolean equals(PlanStatusEnum enableStatusEnum) { + return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ; + } + +} diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/ProcessProcessingTypeEnum.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/ProcessProcessingTypeEnum.java new file mode 100644 index 000000000..d72fd3a3a --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/ProcessProcessingTypeEnum.java @@ -0,0 +1,25 @@ +package com.cf.imes.framework.common.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum ProcessProcessingTypeEnum { + + + COMPONENTPROCESSING(7L,"组件加工"); + + private Long number; + private String fabricatedItem; + + public boolean equals(Integer number) { + return this.number .equals(number) ; + } + + public boolean equals(ProcessProcessingTypeEnum enableStatusEnum) { + return enableStatusEnum != null && enableStatusEnum.number .equals(this.getNumber()) ; + } + +} diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/RemainTypeEnum.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/RemainTypeEnum.java new file mode 100644 index 000000000..a7854b133 --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/RemainTypeEnum.java @@ -0,0 +1,20 @@ +package com.cf.imes.framework.common.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum RemainTypeEnum { + + WRITEOFF(0,"核销"), + SCHEDULING(1,"排单"), + PATCHINGPLATE(2,"补板"); + + + private Integer type; + private String useType; + + +} diff --git a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentService.java b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentService.java index b9e9dabd9..e426032ca 100644 --- a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentService.java +++ b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentService.java @@ -59,6 +59,15 @@ public interface ESDocumentService { BulkResponse bulkCreate(String idxName, List documents) throws Exception; + /** + * 批量更新文档 + * @param idxName 索引名 + * @param documents 要更新的对象集合 + * @return 批量更新的结果 + */ + BulkResponse bulkUpdate(String idxName, List documents) throws Exception; + + /** * 根据文档id查找文档 * @param idxName 索引名 diff --git a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentServiceImpl.java b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentServiceImpl.java index 514ad55ee..45b275461 100644 --- a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentServiceImpl.java +++ b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/core/service/ESDocumentServiceImpl.java @@ -156,6 +156,40 @@ public class ESDocumentServiceImpl implements ESDocumentService { return elasticsearchClient.bulk(br.build()); } + + + + /** + * 批量方式更新文档 + * + * @param idxName 索引名 + * @param documents 要更新的对象集合 + */ + @Override + public BulkResponse bulkUpdate(String idxName, List documents) throws Exception { + BulkRequest.Builder br = new BulkRequest.Builder(); + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + Date date = new Date(); + documents.forEach(esDocument -> { + // 假设esDocument有一个ID集。如果没有,则应该抛出异常或进行相应的处理。 + if (StrUtil.isBlank(esDocument.getId())) { + throw new IllegalArgumentException("更新操作的文档ID不能为空"); + } + esDocument.setUpdater(loginUser.getNickname()); + esDocument.setUpdateTime(simpleDateFormat.format(date)); + + br.operations(op -> op.update(u -> u + .index(idxName) + .id(esDocument.getId()) + .action(a -> a + .doc(esDocument)))); + }); + return elasticsearchClient.bulk(br.build()); + } + + + + /** * @param idxName 索引名称 * @param docId 文档id diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/OptimizePlanController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/OptimizePlanController.java index f6bf3ceb6..6d128e0db 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/OptimizePlanController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/OptimizePlanController.java @@ -3,12 +3,10 @@ package com.cf.imes.module.executor.controller.admin.plan; import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.operatelog.core.annotations.OperateLog; import com.cf.imes.module.executor.controller.admin.plan.bo.OrderSource; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.SavePlanPlateResultReqVO; import com.cf.imes.module.executor.controller.admin.plan.vo.*; import com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService; -import com.cf.imes.module.executor.util.RandomUtils; -import com.cf.imes.module.system.api.dataSource.DataSourceApi; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; @@ -109,4 +107,17 @@ public class OptimizePlanController { return CommonResult.success( optimizePlanService.getLabelDataSourceValue(req)); } + + + @PostMapping("/saveOptimizationResults") + @Operation(summary = "保存优化后的数据") + @PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')") + public CommonResult saveOptimizationResults(@Valid @RequestBody SavePlanPlateResultReqVO req ) { + + optimizePlanService.saveOptimizationResults(req); + + return CommonResult.success(true); + + } + } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java index e89f3d5a4..23175db65 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java @@ -108,7 +108,7 @@ public class PlanController { @GetMapping("getNotPlanOrderListPage") @Operation(summary = "获取未排单的板材生产单板材分页列表") @PreAuthorize("@ss.hasPermission('executor:plan:query')") - public CommonResult> getOrderPage(@Valid OrderPageReqVOCopy pageReqVO) { + public CommonResult> getOrderPage(@Valid OrderPageReqVOCopy pageReqVO) { return success(planService.getOrderPage(pageReqVO)); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/bo/OrderSource.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/bo/OrderSource.java index 0fd63cc98..fef96dc55 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/bo/OrderSource.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/bo/OrderSource.java @@ -1,14 +1,12 @@ package com.cf.imes.module.executor.controller.admin.plan.bo; -import com.cf.imes.module.executor.controller.admin.plan.vo.OptimizeParamRespVO; -import com.cf.imes.module.executor.controller.admin.plan.vo.OptimizePlateDetialRespVO; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.OptimizeRemainPlate; +import com.cf.imes.module.executor.controller.admin.plan.vo.GoodsReqVO; import com.cf.imes.module.executor.controller.admin.plan.vo.PlateDetialRespVO; -import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailVO; -import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; +import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO; import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO; -import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO; import com.cf.imes.module.system.api.machine.dto.MachineDTO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; @@ -28,8 +26,11 @@ import java.util.List; @NoArgsConstructor public class OrderSource { - @Schema(description = "优化时数据") - private List optimizePlateDetialRespVO; + @Schema(description = "优化后的大板数据") + private List optimizeBoardModelDOS; + + @Schema(description = "优化后的余料板数据", requiredMode = Schema.RequiredMode.REQUIRED) + private List optimizeRemainPlates; @Schema(description = "机台数据") private MachineDTO machineDTO; @@ -41,7 +42,7 @@ public class OrderSource { private List orderList; @Schema(description = "板材-大板列表") - private List goodsList; + private List goodsList; @Schema(description = "小板列表") private List plateList; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/OptimizeRemainPlate.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/OptimizeRemainPlate.java new file mode 100644 index 000000000..0540cd89e --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/OptimizeRemainPlate.java @@ -0,0 +1,100 @@ +package com.cf.imes.module.executor.controller.admin.plan.saveOptimize; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Schema(description = "优化后的余料板数据") +public class OptimizeRemainPlate { + + + @Schema(description = "余料板ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long id; + + + @Schema(description = "源排单ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long initPlanId; + + + @Schema(description = "排单ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long planId; + + + + @Schema(description = "状态(未使用 = 0, 已使用 = 1)", requiredMode = Schema.RequiredMode.REQUIRED) + private Integer status; + + + + @Schema(description = "商品ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long goodsId; + + + + @Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED) + private String goodsName; + + + @Schema(description = "材质", requiredMode = Schema.RequiredMode.REQUIRED) + private String material; + + + + @Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED) + private String color; + + + @Schema(description = "宽", requiredMode = Schema.RequiredMode.REQUIRED) + private BigDecimal width; + + + + @Schema(description = "长", requiredMode = Schema.RequiredMode.REQUIRED) + private BigDecimal length; + + + @Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED) + private String brand; + + + + @Schema(description = "排单号", requiredMode = Schema.RequiredMode.REQUIRED) + private String planCode; + + + + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED) + private Integer count; + + + + @Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED) + private BigDecimal thickness; + + + + @Schema(description = "轮廓", requiredMode = Schema.RequiredMode.REQUIRED) + private String outLineJson; + + + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED) + private String remark; + + + @Schema(description = "排版样式", requiredMode = Schema.RequiredMode.REQUIRED) + private Integer placeStyle; + + + + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SaveOrderReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SaveOrderReqVO.java new file mode 100644 index 000000000..2654bc9af --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SaveOrderReqVO.java @@ -0,0 +1,66 @@ +package com.cf.imes.module.executor.controller.admin.plan.saveOptimize; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +import static com.cf.imes.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; + +@Data +@Schema(description = "优化后的生产单数据") +public class SaveOrderReqVO { + + @Schema(description = "生产单id") + private Long orderId; + + @Schema(description = "父id") + private Long parentNo; + + @Schema(description = "自定义单号") + private String customOrderNo; + + @Schema(description = "客户") + private String customer; + + @Schema(description = "地址") + private String address; + + @Schema(description = "客户电话") + private String phoneNumber; + + @Schema(description = "经销商") + private String dealer; + + @Schema(description = "经销商电话") + private String dealerPhoneNumber; + + @Schema(description = "业务员") + private String salesman; + + @Schema(description = "拆单员") + private String splitter; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "交付日期") + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) + private Date deliveryDate; + + @Schema(description = "生产单类型,1主单 2子单") + private Integer type; + + @Schema(description = "生产单排序号") + private Integer sort; + + @Schema(description = "CAD数据类型,1CAD 2WebCAD 3Excel") + private Integer dataType; + + @Schema(description = "订单状态,0未排单1已排单2生产中3加工完成4打包完成5入库完成6出库完成") + private Integer status; + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SavePlanPlateResultReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SavePlanPlateResultReqVO.java new file mode 100644 index 000000000..17bbc5ef3 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/saveOptimize/SavePlanPlateResultReqVO.java @@ -0,0 +1,48 @@ +package com.cf.imes.module.executor.controller.admin.plan.saveOptimize; + + +import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsSaveReqVO; +import com.cf.imes.module.executor.controller.admin.plan.vo.PlateDetialRespVO; +import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; +import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO; +import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import java.util.List; + +@Data +public class SavePlanPlateResultReqVO { + + +// @Schema(description = "优化后的生产单数据", requiredMode = Schema.RequiredMode.REQUIRED) +// private List orderList; + + + + @Schema(description = "优化后的大板列表数据", requiredMode = Schema.RequiredMode.REQUIRED) + private List optimizeBoardModelDOS; + + + + @Schema(description = "优化后的余料板数据", requiredMode = Schema.RequiredMode.REQUIRED) + private List optimizeRemainPlates; + + + + @Schema(description = "优化后的小板列表数据", requiredMode = Schema.RequiredMode.REQUIRED) + private List plateList; + + + + @Schema(description = "优化后新增的小板ID") + private List addPlateIds; + + + + @Schema(description = "优化后删除的小板ID") + private List deletePlateIds; + + + + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/GoodsReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/GoodsReqVO.java new file mode 100644 index 000000000..17cc7e4f0 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/GoodsReqVO.java @@ -0,0 +1,92 @@ +package com.cf.imes.module.executor.controller.admin.plan.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 生产单商品表") +@Data +public class GoodsReqVO { + + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4109") + private Long id; + + + @Schema(description = "余料板ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4109") + private Long remainId; + + + @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 = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) + private String creator; + + + + @Schema(description = "更新人", requiredMode = Schema.RequiredMode.REQUIRED) + private String updater; + + + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + + + @Schema(description = "更新时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] updateTime; + + + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OptimizePlateDetialRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OptimizePlateDetialRespVO.java deleted file mode 100644 index 29aab6115..000000000 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OptimizePlateDetialRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.cf.imes.module.executor.controller.admin.plan.vo; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 优化时对应的数据") -@Data -public class OptimizePlateDetialRespVO { - - @Schema(description = "大板ID", requiredMode = Schema.RequiredMode.REQUIRED) - private Long boardId; - - @Schema(description = "大板名称", requiredMode = Schema.RequiredMode.REQUIRED) - private String plateName; - - @Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED) - private String material; - - @Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED) - private String color; - - @Schema(description = "是否有纹路", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean hasTexture; - - @Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED) - private Double thickness; - - @Schema(description = "小板数量", requiredMode = Schema.RequiredMode.REQUIRED) - private Long plateNum; - - @Schema(description = "大板数量", requiredMode = Schema.RequiredMode.REQUIRED) - private Long boardNum; - - @Schema(description = "余料板数量", requiredMode = Schema.RequiredMode.REQUIRED) - private String remainPlateNum; - - @Schema(description = "前N", requiredMode = Schema.RequiredMode.REQUIRED) - private Double topN; - - @Schema(description = "最后", requiredMode = Schema.RequiredMode.REQUIRED) - private Double eventually; - - @Schema(description = "开料刀", requiredMode = Schema.RequiredMode.REQUIRED) - private String knifeName; - - @Schema(description = "尺寸规格", requiredMode = Schema.RequiredMode.REQUIRED) - private String spec; -} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVOCopy.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVOCopy.java index a8c91b2bc..71f266f51 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVOCopy.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVOCopy.java @@ -41,16 +41,16 @@ public class OrderRespVOCopy { private int num; @Schema(description = "平方") private BigDecimal area = new BigDecimal("0"); - @Schema(description = "商品id") - private String goodsId; - @Schema(description = "商品名称") - private String goodsName; +// @Schema(description = "商品id") +// private String goodsId; +// @Schema(description = "商品名称") +// private String goodsName; @Schema(description = "订单对应的板件的信息") private List platePages; - @Schema(description = "颜色") - private String color; - @Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板") - private String material; +// @Schema(description = "颜色") +// private String color; +// @Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板") +// private String material; } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateDetialRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateDetialRespVO.java index b7ce08c37..bbb97857d 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateDetialRespVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateDetialRespVO.java @@ -14,16 +14,23 @@ public class PlateDetialRespVO { private Long id; + @Schema(description = "房间ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long roomId; + @Schema(description = "房间名称", requiredMode = Schema.RequiredMode.REQUIRED) private String roomName; + @Schema(description = "柜体ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long bodyId; + + @Schema(description = "柜体名称", requiredMode = Schema.RequiredMode.REQUIRED) private String bodyName; @Schema(description = "生产单号", requiredMode = Schema.RequiredMode.REQUIRED) - private String orderId; + private Long orderId; @Schema(description = "商品ID", requiredMode = Schema.RequiredMode.REQUIRED) @@ -166,6 +173,10 @@ public class PlateDetialRespVO { private Integer type; + @Schema(description = "加工组ID", requiredMode = Schema.RequiredMode.REQUIRED) + private Long processGroupId; + + @Schema(description = "加工组名称", requiredMode = Schema.RequiredMode.REQUIRED) private String processGroupName; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateReqPageVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateReqPageVO.java index a0ac8dc78..2eda878c0 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateReqPageVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlateReqPageVO.java @@ -11,6 +11,6 @@ import lombok.Data; public class PlateReqPageVO extends PageParam { @Schema(description = "生产单id") private Long orderId; - @Schema(description = "商品id") - private String goodsId; +// @Schema(description = "商品id") +// private String goodsId; } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/goods/OptimizeBoardModelDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/goods/OptimizeBoardModelDO.java new file mode 100644 index 000000000..8b98331c1 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/goods/OptimizeBoardModelDO.java @@ -0,0 +1,128 @@ +package com.cf.imes.module.executor.dal.dataobject.goods; + + +import com.cf.imes.framework.es.core.dal.ESDocument; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Schema(description = "优化后的大板信息") +public class OptimizeBoardModelDO extends ESDocument { + + @Schema(description = "排单ID") + private Long planId; + + + @Schema(description = "生产单id") + private Long orderId; + + + @Schema(description = "大板原长") + private BigDecimal orgLength; + @Schema(description = "大板原宽") + private BigDecimal orgWidth; + + + @Schema(description = "大板开料长") + private BigDecimal length; + @Schema(description = "大板开料宽") + private BigDecimal width; + @Schema(description = "大板厚度") + private BigDecimal thickness; + + @Schema(description = "修边值") + private BigDecimal cutBorder; + + + @Schema(description = "开料刀直径") + private BigDecimal diameter; + + + @Schema(description = "开料刀路间隙") + private BigDecimal cutKnifeGap; + + + @Schema(description = "预铣值") + private BigDecimal preMillingSize; + + + @Schema(description = "是否辅助开料") + private Boolean isHelpCut; + + + @Schema(description = "同刀辅助开料偏移") + private BigDecimal helpCutGap; + + + @Schema(description = "开料刀ID") + private Integer cutKnifeId; + + + + @Schema(description = "辅助刀ID") + private Integer helpKnifeId; + + + + @Schema(description = "是否已优化") + private Boolean isOptimized; + + + @Schema(description = "大板数") + private Integer boardCount; + + + @Schema(description = "余料板数") + private Integer remainBoardCount; + + + @Schema(description = "最小板号") + private Integer minBoardId; + + + @Schema(description = "最大板号") + private Integer maxBoardId; + + + @Schema(description = "总平均利用率") + private BigDecimal avgUsageRateAll; + + + @Schema(description = "前N块板(不包含最后一块板)的平均利用率") + private BigDecimal avgUsageRateExcludeLastBoard; + + + + @Schema(description = "最后一块板的利用率") + private BigDecimal usageRateLastBoard; + + + + @Schema(description = "使用大板情况--大板优化数据") + private String usedBoardInfo; + + + + @Schema(description = "小板排版情况--小板优化数据") + private String blockPlaceInfo; + + + + @Schema(description = "余料板排版情况--余料板优化数据") + private String remainBoardInfo; + + + + + + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/remainplaten/RemainPlateDO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/remainplaten/RemainPlateDO.java index c7bbf87dc..1c07fd590 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/remainplaten/RemainPlateDO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/dataobject/remainplaten/RemainPlateDO.java @@ -1,8 +1,6 @@ package com.cf.imes.module.executor.dal.dataobject.remainplaten; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import com.cf.imes.framework.mybatis.core.dataobject.BaseDO; import lombok.*; @@ -91,6 +89,25 @@ public class RemainPlateDO extends BaseDO { /** * 轮廊数据,Json 串 */ - private String outline; + private String outLineJson; + + /** + * 组织ID + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long organId; + + + /** + * 是否为开料添加,0否,1是 + */ + private Boolean isCutting; + + + /** + * 是否为开料添加,0否,1是 + */ + private Integer useType; + } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java index 378667b1a..6ddeef763 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/goods/GoodsMapper.java @@ -5,9 +5,11 @@ import java.util.*; 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.plan.vo.GoodsReqVO; import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; import org.apache.ibatis.annotations.Mapper; import com.cf.imes.module.executor.controller.admin.goods.vo.*; +import org.apache.ibatis.annotations.Param; /** * 生产单商品 Mapper @@ -36,4 +38,10 @@ public interface GoodsMapper extends BaseMapperX { .orderByDesc(GoodsDO::getId)); } + + List selectGoodsList(@Param("orderId") Long orderId); + + + List selectGoodsListByOrderIds(@Param("orderIds") List orderIds); + } \ No newline at end of file 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 e2b6eea0e..27adf53cd 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 @@ -53,7 +53,7 @@ public interface OrderMapper extends BaseMapperX { } - List selectOrderPage(/*@Param("page") IPage page,*/ @Param(Constants.WRAPPER) Wrapper wrapper); + IPage selectOrderPage(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); default List selectOrderCheck(OrderPageReqVO reqVO) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java index 77ce9df8b..d9f8e6a88 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java @@ -5,13 +5,16 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderModuleRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPlatesDetailRespVO; import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.OptimizeRemainPlate; import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailReqVO; import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailRespVO; import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO; import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO; import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleExtraDO; +import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -35,4 +38,9 @@ public interface OrderItemMapper extends BaseMapperX { PlateDetailRespVO selectPlateNumList(@Param("orderId") Long orderId); + + + void deleteByPlateId(@Param("deletePlateIds") List deletePlateIds); + + } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java index 5c99eb60f..d55bc9eab 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java @@ -63,7 +63,7 @@ public interface PlateMapper extends BaseMapperX { } // IPage selectPlatePage(@Param("page") IPage page, @Param("orderId")Long organId, @Param("goodsId") String goodsId); - List selectPlatePage(/*@Param("page") IPage page,*/ @Param("orderId")Long organId, @Param("goodsId") String goodsId); + List selectPlatePage(/*@Param("page") IPage page,*/ @Param("orderId")Long organId/*, @Param("goodsId") String goodsId*/); IPage selectPlateByPlanId(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); @@ -98,9 +98,6 @@ public interface PlateMapper extends BaseMapperX { List selectPlateDetialListByIds(@Param("orderIds") List orderIds); - List selectPlate(@Param("orderId") Long orderId); - - List selectPlateListByOrderIds(@Param("orderIds") List orderIds); List selectPlateGoodsList(@Param("orderId") Long orderId, @Param("organId") Long organId); } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/remainplaten/RemainPlateMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/remainplaten/RemainPlateMapper.java index cde9ee9f2..89592a2d0 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/remainplaten/RemainPlateMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/remainplaten/RemainPlateMapper.java @@ -3,10 +3,13 @@ package com.cf.imes.module.executor.dal.mysql.remainplaten; 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.module.executor.controller.admin.plan.saveOptimize.OptimizeRemainPlate; import com.cf.imes.module.executor.controller.admin.remainplate.vo.RemainPlatePageReqVO; import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface RemainPlateMapper extends BaseMapperX { @@ -27,9 +30,20 @@ public interface RemainPlateMapper extends BaseMapperX { .eqIfPresent(RemainPlateDO::getStore, reqVO.getStore()) .eqIfPresent(RemainPlateDO::getCount, reqVO.getCount()) .eqIfPresent(RemainPlateDO::getRemark, reqVO.getRemark()) - .eqIfPresent(RemainPlateDO::getOutline, reqVO.getOutline()) + .eqIfPresent(RemainPlateDO::getOutLineJson, reqVO.getOutline()) .betweenIfPresent(RemainPlateDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(RemainPlateDO::getId)); } + + + + + default List selectByPlanId(Long planId, Long userOrganId) { + return selectList( new LambdaQueryWrapperX() + .eq(RemainPlateDO::getPlanId, planId) + .eq(RemainPlateDO::getOrganId, userOrganId)); + + + } } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanService.java index de336dd8c..ce8e65e7f 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanService.java @@ -1,6 +1,7 @@ package com.cf.imes.module.executor.service.optimizeplan; import com.cf.imes.module.executor.controller.admin.plan.bo.OrderSource; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.SavePlanPlateResultReqVO; import com.cf.imes.module.executor.controller.admin.plan.vo.*; import java.util.List; @@ -10,6 +11,8 @@ public interface OptimizePlanService { String ORDER_PLATE_MODEL = "imes_order_plate_model"; + String ORDER_REMAIN_PLATE_MODEL = "imes_order_remain_plate_model"; + List getPlateListByPlanId(Long planId); Boolean addRemain(AddRemainReqVO vo); @@ -29,4 +32,9 @@ public interface OptimizePlanService { OrderSource getOrderSourceByOrderId(Long orderId); OrderSource getOrderSourceByPlanId(Long planId); + + + void saveOptimizationResults(SavePlanPlateResultReqVO req); + + } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java index 115446e50..4b2435179 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/optimizeplan/OptimizePlanServiceImpl.java @@ -1,6 +1,5 @@ package com.cf.imes.module.executor.service.optimizeplan; -import cn.hutool.Hutool; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.util.IdUtil; @@ -9,17 +8,27 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch.core.*; import co.elastic.clients.elasticsearch.core.search.Hit; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.cf.imes.framework.common.enums.PlanStatusEnum; +import com.cf.imes.framework.common.enums.RemainTypeEnum; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.util.json.JsonUtils; import com.cf.imes.framework.common.util.object.BeanUtils; import com.cf.imes.framework.es.core.service.ESDocumentService; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; +import com.cf.imes.framework.mybatis.core.query.QueryWrapperX; +import com.cf.imes.framework.organ.core.context.OrganContextHolder; +import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; import com.cf.imes.module.executor.controller.admin.plan.bo.OrderSource; import com.cf.imes.module.executor.controller.admin.plan.dto.Material; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.OptimizeRemainPlate; +import com.cf.imes.module.executor.controller.admin.plan.saveOptimize.SavePlanPlateResultReqVO; import com.cf.imes.module.executor.controller.admin.plan.vo.*; import com.cf.imes.module.executor.controller.admin.plate.vo.PlateDetailVO; import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; +import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO; import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO; @@ -41,35 +50,25 @@ import com.cf.imes.module.infra.api.file.FileApi; import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO; import com.cf.imes.module.system.api.dataSource.DataSourceApi; import com.cf.imes.module.system.api.machine.MachineApi; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.handler.codec.http2.DefaultHttp2Headers; -import io.netty.handler.codec.http2.DefaultHttp2HeadersDecoder; -import io.netty.handler.codec.http2.DefaultHttp2HeadersEncoder; -import io.netty.handler.codec.http2.Http2Headers; -import io.swagger.v3.core.util.Json; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.UNKNOWN; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.cf.imes.framework.organ.core.context.OrganContextHolder.getOrganId; import static com.cf.imes.module.executor.enums.ErrorCodeConstants.ORDER_NOT_EXISTS; import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLAN_NOT_EXISTS; +import static com.cf.imes.module.executor.util.OrganIdUtils.getUserOrganId; -import io.netty.handler.codec.http2.Http2HeadersEncoder; -import io.netty.handler.codec.http2.Http2HeadersDecoder; +import org.springframework.transaction.annotation.Transactional; /** * @author there @@ -110,6 +109,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { @Resource private ESDocumentService esDocumentService; + @Resource + private OrderItemMapper orderItemMapper; + @Override public List getPlateListByPlanId(Long planId) { return planMapper.selectPlateListByPlanId(planId); @@ -182,7 +184,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { } planMapper.updateById(PlanDO.builder() .id(planId) - .status(2) + .status(PlanStatusEnum.DURINGCUTTING.getStatus()) .build()); return Boolean.TRUE; } @@ -196,27 +198,27 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { //余料板规格 List rawSizes = new ArrayList<>(); List remainPlateCount = new ArrayList<>(); - if(CollectionUtil.isNotEmpty(remainPlateDOS)) { + if (CollectionUtil.isNotEmpty(remainPlateDOS)) { Map> map = remainPlateDOS.stream() .map(e -> OutlineDTO.builder() - .list(JsonUtils.parseArray(e.getOutline(), PointDTO.class)) + .list(JsonUtils.parseArray(e.getOutLineJson(), PointDTO.class)) .length(e.getLength()) .width(e.getWidth()) .build() ) .filter(e -> e.getList().size() == 4 && RectangleChecker.checkRectangle(e.getList())) .collect(Collectors.groupingBy(e -> e.getLength() + "," + e.getWidth())); - map.entrySet().forEach(e-> { + map.entrySet().forEach(e -> { String[] split = e.getKey().split(","); BigDecimal length = new BigDecimal(split[0]); BigDecimal width = new BigDecimal(split[1]); List outlines = e.getValue(); rawSizes.add(OptimizeParamResVO.RawSize.builder() - .length(length) - .width(width) - .x(new BigDecimal(outlines.get(0).getList().get(0).getX())) - .y(new BigDecimal(outlines.get(0).getList().get(0).getY())) - .build()); + .length(length) + .width(width) + .x(new BigDecimal(outlines.get(0).getList().get(0).getX())) + .y(new BigDecimal(outlines.get(0).getList().get(0).getY())) + .build()); remainPlateCount.add(outlines.size()); }); } @@ -231,7 +233,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { */ MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() .distinct() - .select(GoodsDO::getId ,GoodsDO::getWidth, GoodsDO::getHeight) + .select(GoodsDO::getId, GoodsDO::getWidth, GoodsDO::getHeight) .leftJoin(PlateDO.class, PlateDO::getGoodsId, GoodsDO::getGoodsId) .leftJoin(OrderItemDO.class, OrderItemDO::getPlanId, PlateDO::getPlateNo) .leftJoin(PlanItemDO.class, PlanItemDO::getItemId, OrderItemDO::getId) @@ -239,10 +241,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { GoodsDO goodsDO = goodsMapper.selectJoinOne(GoodsDO.class, wrapper); rawSizes.add(OptimizeParamResVO.RawSize.builder() - .width(goodsDO.getWidth()) - .length(goodsDO.getHeight()) - .x(new BigDecimal("0")) - .y(new BigDecimal("0")) + .width(goodsDO.getWidth()) + .length(goodsDO.getHeight()) + .x(new BigDecimal("0")) + .y(new BigDecimal("0")) .build()); return OptimizeParamResVO.builder() .plates(plates) @@ -257,7 +259,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { OptimizeParamRespVO optimizePlanParam = planMapper.getOptimizePlanParam(planId); - if(Objects.isNull(optimizePlanParam)) { + if (Objects.isNull(optimizePlanParam)) { return RandomUtils.randomPojo(OptimizeParamRespVO.class); } //暂时先mock @@ -268,7 +270,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { plateDetailVOS.add(RandomUtils.randomPojo(PlateDetailVO.class)); plateDetailVOS.add(RandomUtils.randomPojo(PlateDetailVO.class)); plateDetailVOS.add(RandomUtils.randomPojo(PlateDetailVO.class)); - if( CollectionUtil.isNotEmpty(optimizePlanParam.getPlateList())) { + if (CollectionUtil.isNotEmpty(optimizePlanParam.getPlateList())) { optimizePlanParam.getPlateList().get(0).setPlateDetailList(plateDetailVOS); } optimizePlanParam.setMaterialList(list); @@ -279,10 +281,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { public Map getLabelDataSourceValue(GetSourceDataReq req) { String sqlStr = dataSourceApi.getSqlById(req.getDataSourceId()).getCheckedData(); String sql = sqlStr.replace("#{orderId}", req.getOrderId() + ""); - if(!Objects.isNull(req.getPackageId())) { + if (!Objects.isNull(req.getPackageId())) { sql = sql.replace("#{packageId}", req.getPackageId() + ""); } - if(!Objects.isNull(req.getPlanId())) { + if (!Objects.isNull(req.getPlanId())) { sql = sql.replace("#{planId}", req.getPlanId() + ""); } return orderMapper.selectDynamicSqlString(sql); @@ -290,62 +292,74 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { @Override public OrderSource getOrderSource(Long orderId, Long planId, Long machineId) { - if(!Objects.isNull(orderId) && !Objects.isNull(planId)) { - throw exception(154112,"生产单id与排单id只能传一个"); + if (!Objects.isNull(orderId) && !Objects.isNull(planId)) { + throw exception(154112, "生产单id与排单id只能传一个"); } OrderSource orderSource; - if(!Objects.isNull(orderId)) { + if (!Objects.isNull(orderId)) { orderSource = getOrderSourceByOrderId(orderId); orderSource.setMachineDTO(machineApi.getMachineDetail(machineId).getCheckedData()); return orderSource; } - if(!Objects.isNull(planId)) { + if (!Objects.isNull(planId)) { orderSource = getOrderSourceByPlanId(planId); orderSource.setMachineDTO(machineApi.getMachineDetail(machineId).getCheckedData()); return orderSource; } - throw exception(154112,"生产单id或排单id不能都空"); + throw exception(154112, "生产单id或排单id不能都空"); } @Override public OrderSource getOrderSourceByOrderId(Long orderId) { OrderDO orderDO = orderMapper.selectById(orderId); - if(Objects.isNull(orderDO)) { + if (Objects.isNull(orderDO)) { throw exception(ORDER_NOT_EXISTS); } OrderSource orderSource = new OrderSource(); - List optimizePlateDetialRespVO = plateMapper.selectPlate(orderId); - List goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX() - .eq(GoodsDO::getOrderId, orderId) - ); +// List goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX() +// .eq(GoodsDO::getOrderId, orderId) +// ); + + List goodsDOS = goodsMapper.selectGoodsList(orderId); // PlanDO planDO = planMapper.selectByOrderId(orderId); List plateDOS = plateMapper.selectPlateDetialList(orderId); - Integer size = plateDOS.size(); - List orderModelDOS = buildRespByOrderId(orderId, ORDER_PLATE_MODEL,size); + // 造型数据的尺寸长度 + Integer orderModelSize = plateDOS.size(); + + + List orderModelDOS = buildRespByOrderId(orderId, ORDER_PLATE_MODEL, orderModelSize); + + + // 大板数据的尺寸长度 + Integer boardSize = goodsDOS.stream().map(m -> m.getId()).collect(Collectors.toList()).size(); + + + List optimizeBoardModelDOS = buildBoardByOrderId(orderId, ORDER_REMAIN_PLATE_MODEL, boardSize); + + - orderSource.setOptimizePlateDetialRespVO(optimizePlateDetialRespVO); // orderSource.setPlan(planDO); orderSource.setOrderList(Collections.singletonList(orderDO)); orderSource.setPlateList(plateDOS); orderSource.setGoodsList(goodsDOS); orderSource.setPlateModels(orderModelDOS); + orderSource.setOptimizeBoardModelDOS(optimizeBoardModelDOS); return orderSource; } - @Resource - private OrderItemMapper orderItemMapper; + @Override public OrderSource getOrderSourceByPlanId(Long planId) { PlanDO planDO = planMapper.selectById(planId); - if(Objects.isNull(planDO)) { + if (Objects.isNull(planDO)) { throw exception(PLAN_NOT_EXISTS); } MPJLambdaWrapper wrapper = new MPJLambdaWrapperX() @@ -356,35 +370,179 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { List orderItemDOS = orderItemMapper.selectJoinList(OrderItemDO.class, wrapper); List orderIds = orderItemDOS.stream().map(OrderItemDO::getOrderId).collect(Collectors.toList()); - List optimizePlateDetialRespVOS = plateMapper.selectPlateListByOrderIds(orderIds); List orderDOS = orderMapper.selectBatchIds(orderIds); - List goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX().in(GoodsDO::getOrderId, orderIds)); +// List goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX().in(GoodsDO::getOrderId, orderIds)); + + List goodsDOS = goodsMapper.selectGoodsListByOrderIds(orderIds); List plateDOS = plateMapper.selectPlateDetialListByIds(orderIds); - Integer size = plateDOS.size(); + // 造型数据的尺寸长度 + Integer orderModelSize = plateDOS.size(); + + List orderModelDOS = buildRespByOrderIds(orderIds, ORDER_PLATE_MODEL, orderModelSize); + + + // 大板数据的尺寸长度 + Integer boardSize = goodsDOS.stream().map(m -> m.getId()).collect(Collectors.toList()).size(); + + List optimizeBoardModelDOS = buildBoardByOrderIds(orderIds, ORDER_REMAIN_PLATE_MODEL, boardSize); + + + List remainPlateDOS = remainPlateMapper.selectByPlanId(planId,getUserOrganId()); + + List optimizeRemainPlates = BeanUtils.toBean(remainPlateDOS, OptimizeRemainPlate.class); + - List orderModelDOS = buildRespByOrderIds(orderIds, ORDER_PLATE_MODEL,size); return OrderSource.builder() - .optimizePlateDetialRespVO(optimizePlateDetialRespVOS) .orderList(orderDOS) .plan(planDO) .goodsList(goodsDOS) .plateList(plateDOS) .plateModels(orderModelDOS) + .optimizeBoardModelDOS(optimizeBoardModelDOS) + .optimizeRemainPlates(optimizeRemainPlates) .build(); } + // 保存优化后的数据 + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOptimizationResults(SavePlanPlateResultReqVO req) { - private List buildRespByOrderIds(Collection orderIds, String index,Integer size) { + + // 判断当前的大板数据是否已经优化,有优化,更新,没有,新增 + if (req.getOptimizeBoardModelDOS().get(0).getIsOptimized().equals(true)) { + try { + // 更新大板的优化数据 + BulkResponse bulkResponse = esDocumentService.bulkUpdate(ORDER_REMAIN_PLATE_MODEL, req.getOptimizeBoardModelDOS()); + boolean errors = bulkResponse.errors(); + if (errors) { + log.error(bulkResponse.items().toString()); + throw new ServiceException(500, "未知异常"); + } + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage()); + throw new RuntimeException(e); + } + } + else { + + // 保存优化后的大板数据 + batchSaveBoardModel(req.getOptimizeBoardModelDOS()); + + } + + + if (CollectionUtil.isNotEmpty(req.getOptimizeRemainPlates())) { + ArrayList remainPlateDOS = new ArrayList(); + + for (OptimizeRemainPlate optimizeRemainPlate : req.getOptimizeRemainPlates()) { + remainPlateDOS.add(RemainPlateDO.builder() + .id(optimizeRemainPlate.getId()) + .planId(optimizeRemainPlate.getPlanId()) + .initPlanId(optimizeRemainPlate.getInitPlanId()) + .organId(getUserOrganId()) + .status(optimizeRemainPlate.getStatus()) + .isCutting(true) + .useType(RemainTypeEnum.PATCHINGPLATE.getType()) + .goodsId(optimizeRemainPlate.getGoodsId().toString()) + .name(optimizeRemainPlate.getGoodsName()) + .material(optimizeRemainPlate.getMaterial()) + .color(optimizeRemainPlate.getColor()) + .width(optimizeRemainPlate.getWidth()) + .length(optimizeRemainPlate.getLength()) + .thickness(optimizeRemainPlate.getThickness()) + .brand(optimizeRemainPlate.getBrand()) + .placeStyle(optimizeRemainPlate.getPlaceStyle()) + .store("") + .count(optimizeRemainPlate.getCount()) + .remark(optimizeRemainPlate.getRemark()) + .outLineJson(optimizeRemainPlate.getOutLineJson()) + .build()); + } + + remainPlateMapper.updateBatch(remainPlateDOS); +// for (RemainPlateDO remainPlateDO : remainPlateDOS) { +// +//// if(remainPlateDO.getId() != null){ +//// remainPlateMapper.insert(remainPlateDO); +//// +//// } +// +// remainPlateMapper.updateById(remainPlateDO); +// +// } + + + } + + + // 有新增小板,往数据库新增小板 + if (CollectionUtil.isNotEmpty(req.getAddPlateIds())) { + + List addPlates = req.getPlateList().stream() + .filter(m -> req.getAddPlateIds().contains(m.getId())) + .map(m -> m.setId(null)) + .collect(Collectors.toList()); + + +// List collect = req.getPlateList().stream().map(m -> m.getId()).collect(Collectors.toList()); +// List addPlateIds = req.getAddPlateIds().stream().filter(m -> !collect.contains(m)).collect(Collectors.toList()); +// List addPlates = req.getPlateList().stream() +// .filter(m -> addPlateIds.contains(m.getId())) +// .map(m->m.setId(null)) +// .collect(Collectors.toList()); + // 批量新增小板信息 + List plateDOS = BeanUtils.toBean(addPlates, PlateDO.class); + + plateMapper.insertBatch(plateDOS); + + // 批量新增生产单明细表信息 + ArrayList orderItemDOS = new ArrayList(); + + for (PlateDetialRespVO plateDetialRespVO : req.getPlateList()) { + orderItemDOS.add(OrderItemDO.builder() + .id(plateDetialRespVO.getItemId()) + .bodyId(plateDetialRespVO.getBodyId()) + .groupId(plateDetialRespVO.getProcessGroupId()) + .orderId(plateDetialRespVO.getOrderId()) + .type(1) + .plateId(plateDetialRespVO.getId()) + .build()); + } + + + orderItemMapper.insertBatch(orderItemDOS); + + } + + // 有删除的小板ID,删除小板 + if (CollectionUtil.isNotEmpty(req.getDeletePlateIds())) { + + // 删除生产单板件表的小板 + plateMapper.deleteBatchIds(req.getDeletePlateIds()); + + // 删除生产单明细表中对应的小板数据 + orderItemMapper.deleteByPlateId(req.getDeletePlateIds()); + + + } + + + } + + + private List buildRespByOrderIds(Collection orderIds, String index, Integer size) { List fieldValues = orderIds.stream().map(FieldValue::of).toList(); SearchRequest.Builder builder = new SearchRequest.Builder(); builder.index(index); builder.size(size); - builder.query(q -> q.terms(b -> b.field("orderId").terms(e->e.value(fieldValues)))); + builder.query(q -> q.terms(b -> b.field("orderId").terms(e -> e.value(fieldValues)))); try { SearchResponse search = elasticsearchClient.search(builder.build(), OrderModelDO.class); List> hits = search.hits().hits(); @@ -417,6 +575,68 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { } + /** + * 保存优化后的大板的数据 + * + * @param optimizeBoardModelDOS + */ + @Transactional(rollbackFor = Exception.class) + public void batchSaveBoardModel(List optimizeBoardModelDOS) { + try { + BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_REMAIN_PLATE_MODEL, optimizeBoardModelDOS); + boolean errors = bulkResponse.errors(); + if (errors) { + log.error(bulkResponse.items().toString()); + throw new ServiceException(500, "未知异常"); + } + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage()); + throw new RuntimeException(e); + } + + } + + + private List buildBoardByOrderId(Long orderId, String index,Integer size) { + SearchRequest.Builder builder = new SearchRequest.Builder(); + builder.index(index); + builder.size(size); + builder.query(q -> q.term(b -> b.field("orderId").value(orderId))); + try { + SearchResponse search = elasticsearchClient.search(builder.build(), OptimizeBoardModelDO.class); + List> hits = search.hits().hits(); + if (CollectionUtil.isNotEmpty(hits)) { + return hits.stream().map(Hit::source).collect(Collectors.toList()); + } + return new ArrayList<>(); + } catch (IOException e) { + log.error(e.getMessage()); + throw new ServiceException(INTERNAL_SERVER_ERROR); + } + } + + + + private List buildBoardByOrderIds(Collection orderIds, String index, Integer size) { + List fieldValues = orderIds.stream().map(FieldValue::of).toList(); + SearchRequest.Builder builder = new SearchRequest.Builder(); + builder.index(index); + builder.size(size); + builder.query(q -> q.terms(b -> b.field("orderId").terms(e -> e.value(fieldValues)))); + try { + SearchResponse search = elasticsearchClient.search(builder.build(), OptimizeBoardModelDO.class); + List> hits = search.hits().hits(); + if (CollectionUtil.isNotEmpty(hits)) { + return hits.stream().map(Hit::source).collect(Collectors.toList()); + } + return new ArrayList<>(); + } catch (IOException e) { + log.error(e.getMessage()); + throw new ServiceException(INTERNAL_SERVER_ERROR); + } + } + } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanService.java index 956bc8b7a..00a3cc43b 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanService.java @@ -53,7 +53,8 @@ public interface PlanService { */ PageResult getPlanPage(PlanPageReqVO pageReqVO); - List getOrderPage(OrderPageReqVOCopy pageReqVO); + + PageResult getOrderPage(OrderPageReqVOCopy pageReqVO); List getNotPlanPlateListPage(PlateReqPageVO pageVO); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java index 56cf8b5c5..91748bf05 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java @@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import com.cf.imes.framework.common.enums.PlanFilterTypeEnum; +import com.cf.imes.framework.common.enums.PlanStatusEnum; +import com.cf.imes.framework.common.util.json.JsonUtils; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; import com.cf.imes.framework.mybatis.core.query.QueryWrapperX; @@ -120,10 +123,10 @@ public class PlanServiceImpl implements PlanService { if (CollectionUtil.isNotEmpty(itemIds)) { ArrayList planItemDOS = new ArrayList<>(); - for (Long plateId : itemIds) { + for (Long itemId : itemIds) { planItemDOS.add(PlanItemDO.builder() .planId(planId) - .itemId(plateId) + .itemId(itemId) .build()); } planItemMapper.insertBatch(planItemDOS); @@ -179,7 +182,7 @@ public class PlanServiceImpl implements PlanService { if (planDO == null) { throw exception(PLAN_NOT_EXISTS); } - if (planDO.getStatus().equals(2) || planDO.getStatus().equals(3)) { + if (planDO.getStatus().equals(PlanStatusEnum.DURINGCUTTING.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.OPENEDMATERIAL.getStatus())) { throw exception(PLAN_NOT_ALLOW_DELETE); } // 删除 @@ -233,7 +236,6 @@ public class PlanServiceImpl implements PlanService { List machines = machineApi.list(macheineIds).getCheckedData(); - List planIds = planDOPageResult.getList().stream().map(PlanDO::getId).collect(Collectors.toList()); // // 根据排单ID查询排单明细表对应的明细ID // List itemDOS = planItemMapper.selectList(new LambdaQueryWrapperX().in(PlanItemDO::getPlanId, ids)); @@ -283,13 +285,13 @@ public class PlanServiceImpl implements PlanService { } @Override - public List getOrderPage(OrderPageReqVOCopy pageReqVO) { -// PageDTO page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + public PageResult getOrderPage(OrderPageReqVOCopy pageReqVO) { + PageDTO page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); QueryWrapperX queryWrapperX = new QueryWrapperX<>(); queryWrapperX .eqIfPresent("a.id", pageReqVO.getOrderId()) - .isNull("opi.id") + .isNull("opi.item_id") .eqIfPresent("a.customer", pageReqVO.getConsignee()) .eqIfPresent("a.custom_order_no", pageReqVO.getDefaultId()) .eqIfPresent("a.address", pageReqVO.getConsigneeAddress()) @@ -299,30 +301,37 @@ public class PlanServiceImpl implements PlanService { .eqIfPresent("op.is_door", pageReqVO.getIsDoor()) .betweenIfPresent("op.height", new BigDecimal[]{pageReqVO.getLongMinRang(), pageReqVO.getLongMaxRang()}) .betweenIfPresent("op.width", new BigDecimal[]{pageReqVO.getWidthMinRang(), pageReqVO.getWidthMaxRang()}) - .groupBy("a.id","og.id","og.goods_name","og.color","og.material","op.goods_id") + .groupBy("a.id", " a.order_date", "a.delivery_date", "a.customer", "a.address", "a.custom_order_no") .orderByDesc("a.create_time"); List filterTypes = new ArrayList<>(); if (Objects.nonNull(pageReqVO.getHoleThrough()) && pageReqVO.getHoleThrough()) { - filterTypes.add(1); + filterTypes.add(PlanFilterTypeEnum.DIGGINGTHROUGHTHESHAPE.getType()); } if (Objects.nonNull(pageReqVO.getBurrow()) && pageReqVO.getBurrow()) { - filterTypes.add(2); + filterTypes.add(PlanFilterTypeEnum.THEREAREPERFORATEDHOLES.getType()); } if (Objects.nonNull(pageReqVO.getTwoDimensionalToolPath()) && pageReqVO.getTwoDimensionalToolPath()) { - filterTypes.add(4); + filterTypes.add(PlanFilterTypeEnum.TWODIMENSIONALCUTTINGPATH.getType()); } queryWrapperX.inIfPresent("op.filter_type", filterTypes); - List orderRespVOCopies = orderMapper.selectOrderPage(queryWrapperX); + IPage orderRespVOCopies = orderMapper.selectOrderPage(page, queryWrapperX); - for (OrderRespVOCopy orderRespVOCopy : orderRespVOCopies) { + List records = orderRespVOCopies.getRecords(); + for (OrderRespVOCopy orderRespVOCopy : records) { - List platePages = plateMapper.selectPlatePage(orderRespVOCopy.getOrderId(), orderRespVOCopy.getGoodsId()); + List platePages = plateMapper.selectPlatePage(orderRespVOCopy.getOrderId()/*, orderRespVOCopy.getGoodsId()*/); orderRespVOCopy.setPlatePages(platePages); } - return orderRespVOCopies; + + + if (CollectionUtil.isEmpty(records)) { + return new PageResult<>(); + } + + return new PageResult<>(orderRespVOCopies.getRecords(), orderRespVOCopies.getTotal()); // IPage orderDOPageResult = orderMapper.selectOrderPage(queryWrapperX); @@ -336,7 +345,7 @@ public class PlanServiceImpl implements PlanService { @Override public List getNotPlanPlateListPage(PlateReqPageVO pageVO) { // PageDTO page = new PageDTO<>(pageVO.getPageNo(), pageVO.getPageSize()); - List pageRes = plateMapper.selectPlatePage(/*page, */pageVO.getOrderId(), pageVO.getGoodsId()); + List pageRes = plateMapper.selectPlatePage(/*page, */pageVO.getOrderId()/*, pageVO.getGoodsId()*/); return pageRes; } @@ -370,7 +379,7 @@ public class PlanServiceImpl implements PlanService { if (planDO == null) { throw exception(PLAN_NOT_EXISTS); } - if (planDO.getStatus().equals(0) || planDO.getStatus().equals(1)) { + if (planDO.getStatus().equals(PlanStatusEnum.NEWORDER.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.BOARDHASBEENAPPLIEDFOR.getStatus())) { throw exception(PLAN_NOT_ALLOW_CANCEL); } Set itemIds = planItemMapper.selectList(new LambdaQueryWrapperX().eq(PlanItemDO::getPlanId, id)) @@ -386,13 +395,13 @@ public class PlanServiceImpl implements PlanService { QueryWrapperX queryWrapperX = new QueryWrapperX<>(); List filterTypes = new ArrayList<>(); if (Objects.nonNull(vo.getHoleThrough()) && vo.getHoleThrough()) { - filterTypes.add(1); + filterTypes.add(PlanFilterTypeEnum.DIGGINGTHROUGHTHESHAPE.getType()); } if (Objects.nonNull(vo.getBurrow()) && vo.getBurrow()) { - filterTypes.add(2); + filterTypes.add(PlanFilterTypeEnum.THEREAREPERFORATEDHOLES.getType()); } if (Objects.nonNull(vo.getTwoDimensionalToolPath()) && vo.getTwoDimensionalToolPath()) { - filterTypes.add(4); + filterTypes.add(PlanFilterTypeEnum.TWODIMENSIONALCUTTINGPATH.getType()); } queryWrapperX.eq("p.plan_id", vo.getPlanId()) @@ -446,7 +455,7 @@ public class PlanServiceImpl implements PlanService { @Override public Boolean setSort(List list) { ArrayList planDOS = new ArrayList<>(); - list.forEach(e->{ + list.forEach(e -> { planDOS.add(PlanDO.builder() .id(e.getPlanId()) .sort(e.getSort()) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java index 2c3794a15..02ec2cb68 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil; +import com.cf.imes.framework.common.util.json.JsonUtils; import com.cf.imes.framework.es.core.service.ESDocumentService; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; import com.cf.imes.framework.security.core.LoginUser; @@ -26,6 +27,9 @@ import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper; import com.cf.imes.module.executor.dal.mysql.processStepItem.ProcessStepItemMapper; import com.cf.imes.module.executor.util.RandomUtils; import com.cf.imes.module.system.enums.ErrorCodeConstants; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -36,6 +40,8 @@ import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.*; import java.util.stream.Collectors; @@ -48,6 +54,7 @@ import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.cf.imes.framework.common.util.json.JsonUtils.fetchData; import static com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService.ORDER_PLATE_MODEL; import static com.cf.imes.module.system.enums.ErrorCodeConstants.PLATE_NOT_EXISTS; @@ -201,7 +208,7 @@ public class PlateServiceImpl implements PlateService { @SneakyThrows @Override - public List getPlateModelByPlateId(List bodyIds) { + public List getPlateModelByPlateId(List bodyIds) { List list = plateMapper.selectJoinList(BodyPlateIdDTO.class, new MPJLambdaWrapperX() .selectAs(PlateDO::getId, "plateId") .leftJoin(OrderItemDO.class, OrderItemDO::getPlateId, PlateDO::getId) @@ -215,12 +222,15 @@ public class PlateServiceImpl implements PlateService { })); List bodyPlateDetailVOS = new ArrayList<>(); + List>> data = new ArrayList<>(); map.entrySet().forEach(e->{ - bodyPlateDetailVOS.add(BodyPlateDetailVO.builder() - .orderModelList(e.getValue()) - .bodyId(e.getKey()) - .build() - ); + bodyPlateDetailVOS.add(BodyPlateDetailVO.builder() + // 将造型的数据转换成 抽取后的数据结构 + .orderModelList(e.getValue()) +// .orderModelList(e.getValue()) + .bodyId(e.getKey()) + .build() + ); }); return bodyPlateDetailVOS; } @@ -229,6 +239,9 @@ public class PlateServiceImpl implements PlateService { + + + private List buildRespByPlateIds(Collection plateIds, String index) { // diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/OrganIdUtils.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/OrganIdUtils.java new file mode 100644 index 000000000..0e27dc3d3 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/OrganIdUtils.java @@ -0,0 +1,18 @@ +package com.cf.imes.module.executor.util; + +import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; + + +/** + * 获取当前用户的组织ID + * + * @author 晨丰科技 + */ +public class OrganIdUtils { + + public static Long getUserOrganId(){ + + return SecurityFrameworkUtils.getLoginUser().getOrganId(); + + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml index abe5643b6..209efc6ba 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/goods/GoodsMapper.xml @@ -9,4 +9,36 @@ 文档可见:https://www.cf.com/MyBatis/x-plugins/ --> + + + + + + + \ No newline at end of file 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 b9ca9a36f..665ce3c1b 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 @@ -4,12 +4,12 @@ SELECT i.order_id, p.id, p.plate_no, g.material, p.name, p.area, p.seal_left, p.seal_down, p.seal_right, p.seal_up, p.texture, p.is_special_shaped, p.is_sculpt, p.unregular_point_count, p.front_hole_count, @@ -129,4 +130,19 @@ + + + + delete from order_item where plate_id in + + #{id} + + + + + + + + + \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml index 756544005..af9678dae 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml @@ -1,43 +1,26 @@ + + - - select count(distinct og.id) as boardNum, - count(distinct op.id) as plateNum, - (case - when p.texture ='' then false - else true end ) as hasTexture, - og.id as boardId, - og.goods_name as plateName, - og.material as material, - og.color as color, - og.thickness as thickness, - og.spec as spec, - orp.count as remainPlateNum - from order_goods og - left join order_plate op on og.id = op.goods_id - left join plate p on og.goods_id = p.id - left join order_remain_plate orp on op.id = orp.plan_id - where og.order_id = #{orderId} - group by boardId,plateName,material,color,thickness,spec,remainPlateNum,hasTexture; - - - select oi.id from order_plate op - join order_item oi on op.id = oi.plate_id - where ( op.order_id, op.goods_id ) in + join order_item oi on op.id = oi.plate_id and op.order_id = oi.order_id + where op.order_id in - (#{item.orderId},#{item.goodsId}) + (#{item.orderId}) + and + op.goods_id in + + (#{item.goodsId}) + + From 5de9bff802ae07a3bb4ad973a0068b24028b4571 Mon Sep 17 00:00:00 2001 From: liuzhaotian Date: Tue, 11 Jun 2024 09:45:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9-2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cf/imes/module/executor/service/plate/PlateServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java index 02ec2cb68..5083c2a16 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plate/PlateServiceImpl.java @@ -9,7 +9,6 @@ import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.core.search.Hit; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.cf.imes.framework.common.exception.ServiceException; @@ -54,7 +53,6 @@ import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.cf.imes.framework.common.util.json.JsonUtils.fetchData; import static com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService.ORDER_PLATE_MODEL; import static com.cf.imes.module.system.enums.ErrorCodeConstants.PLATE_NOT_EXISTS;