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-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/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/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/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 c9e79cedb..19d82dd47 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..662bb6ecf 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,25 +1,35 @@ 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; 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; @@ -35,41 +45,32 @@ 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.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; 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 +111,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 +186,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService { } planMapper.updateById(PlanDO.builder() .id(planId) - .status(2) + .status(PlanStatusEnum.DURINGCUTTING.getStatus()) .build()); return Boolean.TRUE; } @@ -196,27 +200,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 +235,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 +243,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 +261,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 +272,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 +283,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 +294,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 (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 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 +372,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 +577,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..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,11 +9,11 @@ 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; 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 +26,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 +39,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; @@ -201,7 +206,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 +220,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 +237,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/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..959ca57a3 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 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}) + + @@ -127,9 +116,12 @@ + + + @@ -141,8 +133,11 @@ select distinct op.*, oi.id as itemId, ogs.goods_name as goodsName, + ob.id as bodyId, + ob.room_id as roomId, ob.name as bodyName, ob.room_name as roomName, + og.id as processGroupId, og.name as processGroupName, CASE WHEN op.unregular_point_count = 0 and op.front_hole_count = 0 and op.back_hole_count = 0 and op.side_hole_count = 0 THEN false ELSE true END AS hasHole from order_plate op @@ -184,75 +179,9 @@ - - - - - - - - - - - - - - - -