Explorar o código

新增自定义订单功能模块

oyq28 hai 7 meses
pai
achega
6b29c7ce93

+ 9 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/OrderTaskMapper.java

@@ -0,0 +1,9 @@
+package com.github.zuihou.business.operationManagementCenter.dao;
+
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.OrderTask;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface OrderTaskMapper extends SuperMapper<OrderTask> {
+}

+ 11 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/OrderTaskService.java

@@ -0,0 +1,11 @@
+package com.github.zuihou.business.operationManagementCenter.service;
+
+import com.github.zuihou.base.service.SuperService;
+import com.github.zuihou.business.operationManagementCenter.entity.OrderTask;
+
+public interface OrderTaskService extends SuperService<OrderTask> {
+
+    boolean prodNode(OrderTask orderTask, String planId);
+
+    boolean isOneLine(String startName, String goalName);
+}

+ 224 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/OrderTaskServiceImpl.java

@@ -0,0 +1,224 @@
+package com.github.zuihou.business.operationManagementCenter.service.impl;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.zuihou.base.service.SuperServiceImpl;
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
+import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
+import com.github.zuihou.business.operationManagementCenter.dao.OrderTaskMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.*;
+import com.github.zuihou.business.operationManagementCenter.service.*;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureProductionresourceService;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionResourceCenter.dao.ResourceBusinessMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceBusiness;
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourceBizService;
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.util.DynamicRabbitMq;
+import com.github.zuihou.business.util.MsgUtil;
+import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.tenant.service.CodeRuleService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+@Slf4j
+@Service
+public class OrderTaskServiceImpl extends SuperServiceImpl<OrderTaskMapper, OrderTask> implements OrderTaskService {
+
+    @Autowired
+    private OrderService orderService;
+
+    @Autowired
+    private PlanService planService;
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Autowired
+    private StorgeService storgeService;
+
+    @Autowired
+    private ProductionresourceBizService productionresourceService;
+
+    @Autowired
+    private ProductionresourcePositionService productionresourcePositionService;
+
+    @Autowired
+    private MsgUtil msgUtil;
+
+    @Autowired
+    private DynamicRabbitMq dynamicRabbitMq;
+
+    @Autowired
+    private ResourceBusinessMapper resourceBusinessMapper;
+
+    @Autowired
+    private WorkpieceService tWorkpieceService;
+
+    @Autowired
+    private BomProcedureProductionresourceService bomProcedureProductionresourceService;
+
+    @Autowired
+    private CodeRuleService codeRuleService;
+
+    @Autowired
+    private OrderProductService orderProductService;
+
+    @Autowired
+    private BomProcedureService bomProcedureService;
+
+    @Autowired
+    private StockInfoService stockInfoService;
+
+    @Override
+    public boolean prodNode(OrderTask orderTask, String planId) {
+
+        //依据配置动态更新节点
+        String[] startNameCondition = orderTask.getStart().split("_");
+        String[] goalNameCondition = orderTask.getGoal().split("_");
+        if(startNameCondition.length != 2 || goalNameCondition.length != 2) return false;
+        Storge startStorge = storgeService.getOne(new LbqWrapper<Storge>().likeLeft(Storge::getNo, startNameCondition[1]).eq(Storge::getPointId, startNameCondition[1]));
+        if(null == startStorge) return false;
+        Storge goalStorge = storgeService.getOne(new LbqWrapper<Storge>().likeLeft(Storge::getNo, goalNameCondition[1]).eq(Storge::getPointId, goalNameCondition[1]));
+
+        Long startResourceId = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getStorgeId, startStorge.getId()).last("limit 1")).getResourceId();
+        Long endResourceId = (null==goalStorge) ? null : productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getStorgeId, goalStorge.getId()).last("limit 1")).getResourceId();
+
+        if(startNameCondition[0].equals(goalNameCondition[0])){
+            //同产线内简易搬运处理
+            this.inLineHandle(orderTask, startStorge, goalStorge, startNameCondition[0], startResourceId, endResourceId);
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isOneLine(String startName, String goalName) {
+        String[] startNameCondition = startName.split("_");
+        String[] goalNameCondition = goalName.split("_");
+        if(startNameCondition.length != 2 || goalNameCondition.length != 2) return false;
+        return startNameCondition[0].equals(goalNameCondition[0]);
+    }
+
+    /**
+     * 初始化简易订单任务
+     *
+     * @param currentSort
+     * @param order
+     * @param resourceBusinessId
+     * @return
+     */
+
+    public TTask getSimpleTask(int currentSort, Order order, Long resourceBusinessId, Long endResourceId){
+        TTask simpleTask = taskService.getOne(new LambdaQueryWrapper<TTask>().eq(TTask::getResourceBusinessId, resourceBusinessId).eq(TTask::getProcedureSort, currentSort).orderByDesc(TTask::getCreateTime).last("limit 1"));
+        Plan plan = planService.getOne(new LambdaQueryWrapper<Plan>().eq(Plan::getProduceStatus, "4").orderByDesc(Plan::getCreateTime).last("limit 1"));
+        TTask initTask = TTask.builder().build();
+        //OrderProduct initProduct = OrderProduct.builder().build();
+        Plan initPlan = Plan.builder().build();
+        if(simpleTask == null){
+            //初始化默认简易任务
+            //默认目的位置作为搬运任务的主设备
+            Long resourceId = endResourceId;
+            BomProcedure bomProcedure = bomProcedureService.getById(1L);
+            Long procedureId = bomProcedure!=null? bomProcedure.getId() : bomProcedureService.getOne(new LbqWrapper<BomProcedure>().eq(BomProcedure::getNo, "OP10").orderByDesc(BomProcedure::getCreateTime).last("limit 1")).getId();
+            Long bomId = 1L;
+            initTask.setCompleteBatchNo(UUID.randomUUID().toString().replace("-", ""));
+            initTask.setOrderNo(order.getOrderNo()).setProcedureNo("OP05").setProcedureName(bomProcedure.getName()).setResourceId(resourceId).setProcedureId(procedureId).setTaskNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK)).
+                    setOrderId(order.getId()).setProcedureSort(0).setFirstProcedureFlag("1").setLastProcedureFlag("1").setDraftFlag("0").setResourceBusinessId(resourceBusinessId).setBomId(bomId);
+        }else{
+            initTask = TTask.builder().build();
+            BeanUtil.copyProperties(simpleTask, initTask, "id");
+            initTask.setOrderId(order.getId()).setOrderNo(order.getOrderNo()).setPlanId(order.getPlanId()).setCompleteBatchNo(UUID.randomUUID().toString().replace("-", "")).setTaskNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK));
+        }
+
+        BeanUtil.copyProperties(plan, initPlan, "id");
+        initPlan.setOrderId(order.getId()).setOrderNo(order.getOrderNo()).setPlanNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_PLAN));
+        //orderProductService.save(initProduct);
+        planService.save(initPlan);
+        initTask.setPlanId(initPlan.getId());
+        return initTask;
+    }
+
+    /**
+     *  同产线内简易搬运处理
+     *
+     * @param orderTask
+     * @param startStorge
+     * @param goalStorge
+     * @param conditionName
+     */
+    public void inLineHandle(OrderTask orderTask, Storge startStorge, Storge goalStorge, String conditionName, Long startResourceId, Long endResourceId){
+        //线内提出多余的task任务
+        List<StockInfo> stockInfoList = stockInfoService.getStockInfoByType(startStorge.getId(), "1");
+        if(stockInfoList.size() == 0){
+            msgUtil.createWarnLog("当前库位工装信息不存在,请检查数据", "DataException");
+            return;
+        }
+
+        int currentSort = conditionName.equals("BZ")? 0:1;
+        Order order = orderService.getById(orderTask.getOrderId());
+
+        String businessName = DemoLineConstant.DEMOLINE_CT_LINE_MOVE;
+
+        ResourceBusiness resourceBusiness = resourceBusinessMapper.selectOne(new LbqWrapper<ResourceBusiness>().eq(ResourceBusiness::getName, businessName));
+        //初始化任务
+        TTask simpleTask = this.getSimpleTask(currentSort, order, resourceBusiness.getId(), endResourceId);
+        taskService.save(simpleTask);
+        //初始化任务节点
+        List<TaskNode> switchNodes = taskNodeService.getCreateTaskNode(resourceBusiness.getId(), simpleTask);
+        List<TaskNode> taskNodes = new ArrayList<TaskNode>();
+        switchNodes.stream().forEach(node -> {
+            TaskNode taskNode = new TaskNode();
+            BeanUtil.copyProperties(node, taskNode, "id");
+            taskNode.setProcedureId(simpleTask.getProcedureId()).setTaskId(simpleTask.getId()).setExeStatus("1").setExeResult(null).setStartTime(null).setEndTime(null).setFeedback("").setNodeType("0").setCreateTime(simpleTask.getCreateTime());
+            taskNode.setCompleteBatchSort(taskNode.getCompleteBatchSort()+1);
+            if(taskNode.getPrority().equals(2)){
+                //线边库区分处理
+                taskNode.setTargetResourceId(endResourceId);
+            }
+            if(taskNode.getInterfaceType().equals("04") && taskNode.getResourceId()==null){
+                taskNode.setResourceId(endResourceId);
+            }
+            taskNodes.add(taskNode);
+        });
+        taskNodeService.saveBatch(taskNodes);
+
+        StockInfo stockInfo = stockInfoList.get(0);
+
+        //更新零件信息
+        TWorkpiece tWorkpiece = TWorkpiece.builder().build();
+        tWorkpiece.setOrderId(orderTask.getOrderId()).setOrderNo(order.getOrderNo()).setOrderName(order.getOrderName()).setCompleteBatchNo(simpleTask.getCompleteBatchNo()).setSerialNo(1).setIsEnd("0").setPlanId(simpleTask.getPlanId());
+        tWorkpiece.setPointId(startStorge.getPointId()).setStorgeId(startStorge.getId()).setCompleteBatchSort(0).setUniqueCode("").setTrayNo(stockInfo.getTrayNo());
+        tWorkpieceService.save(tWorkpiece);
+
+        //更新订单状态
+        order.setOrderStatus("2");
+        orderService.updateById(order);
+
+        TaskNode firstNode = taskNodes.get(0);
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("taskNodeId",firstNode.getId().toString());
+        jsonObject.put("bizType", BizConstant.MQ_TASK_NODE_TYPE_COMMON);
+        jsonObject.put("handMode",0);
+        log.info("推送mq队列{}消息{}",firstNode.getResourceId().toString(),jsonObject.toString());
+        dynamicRabbitMq.sendMsg(firstNode.getResourceId().toString(),jsonObject.toString());
+    }
+}

+ 69 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/OrderTaskPageDTO.java

@@ -0,0 +1,69 @@
+package com.github.zuihou.business.operationManagementCenter.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "OrderTaskPageDTO", description = "自定义订单表")
+public class OrderTaskPageDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 订单ID
+     */
+    @ApiModelProperty(value = "订单编号")
+    @TableField(value = "order_id", condition = LIKE)
+    private Long orderId;
+
+    @ApiModelProperty(value = "起点位置")
+    @Length(max = 128, message = "起点位置长度不能超过128")
+    private String start;
+
+    @ApiModelProperty(value = "目标位置")
+    @Length(max = 128, message = "目标位置长度不能超过128")
+    private String goal;
+
+    @ApiModelProperty(value = "是否加工")
+    @NotEmpty(message = "是否加工不能为空")
+    @Length(max = 1, message = "是否加工长度不能超过1")
+    private String isMachine;
+
+    @ApiModelProperty(value = "是否线边库管理")
+    @NotEmpty(message = "是否线边库管理不能为空")
+    @Length(max = 1, message = "是否线边库管理长度不能超过1")
+    private String isXbk;
+
+    @ApiModelProperty(value = "是否包含零件")
+    @Length(max = 1, message = "是否包含零件长度不能超过1")
+    private String hasMaterial;
+
+    @ApiModelProperty(value = "历史零件批次号")
+    @Length(max = 255, message = "历史零件批次号长度不能超过255")
+    private String confBatchNo;
+
+    @ApiModelProperty(value = "零件名称")
+    @TableField(exist = false)
+    private String orderName;
+
+    @ApiModelProperty(value = "零件状态")
+    @TableField(exist = false)
+    private String orderStatus;
+
+}

+ 60 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/OrderTaskSaveDTO.java

@@ -0,0 +1,60 @@
+package com.github.zuihou.business.operationManagementCenter.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "OrderTaskPageDTO", description = "自定义订单表")
+public class OrderTaskSaveDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 订单ID
+     */
+    @ApiModelProperty(value = "订单编号")
+    @TableField(value = "order_id", condition = LIKE)
+    private Long orderId;
+
+    @ApiModelProperty(value = "起点位置")
+    @Length(max = 128, message = "起点位置长度不能超过128")
+    private String start;
+
+    @ApiModelProperty(value = "目标位置")
+    @Length(max = 128, message = "目标位置长度不能超过128")
+    private String goal;
+
+    @ApiModelProperty(value = "是否加工")
+    @NotEmpty(message = "是否加工不能为空")
+    @Length(max = 1, message = "是否加工长度不能超过1")
+    private String isMachine;
+
+    @ApiModelProperty(value = "是否线边库管理")
+    @NotEmpty(message = "是否线边库管理不能为空")
+    @Length(max = 1, message = "是否线边库管理长度不能超过1")
+    private String isXbk;
+
+    @ApiModelProperty(value = "是否包含零件")
+    @Length(max = 1, message = "是否包含零件长度不能超过1")
+    private String hasMaterial;
+
+    @ApiModelProperty(value = "历史零件批次号")
+    @Length(max = 255, message = "历史零件批次号长度不能超过255")
+    private String confBatchNo;
+}

+ 56 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/OrderTaskUpdateDTO.java

@@ -0,0 +1,56 @@
+package com.github.zuihou.business.operationManagementCenter.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.github.zuihou.base.entity.SuperEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "OrderTaskUpdateDTO", description = "自定义订单表")
+public class OrderTaskUpdateDTO implements Serializable {
+
+    /**
+     * 订单ID
+     */
+    @ApiModelProperty(value = "主键")
+    @NotNull(message = "id不能为空", groups = SuperEntity.Update.class)
+    private Long id;
+
+    @ApiModelProperty(value = "订单编号")
+    @TableField(value = "order_id", condition = LIKE)
+    private Long orderId;
+
+    @ApiModelProperty(value = "起点位置")
+    @Length(max = 128, message = "起点位置长度不能超过128")
+    private String start;
+
+    @ApiModelProperty(value = "目标位置")
+    @Length(max = 128, message = "目标位置长度不能超过128")
+    private String goal;
+
+    @ApiModelProperty(value = "是否加工")
+    @Length(max = 1, message = "是否加工长度不能超过1")
+    private String isMachine;
+
+    @ApiModelProperty(value = "是否线边库管理")
+    @Length(max = 1, message = "是否线边库管理长度不能超过1")
+    private String isXbk;
+
+    @ApiModelProperty(value = "是否包含零件")
+    @Length(max = 1, message = "是否包含零件长度不能超过1")
+    private String hasMaterial;
+}

+ 106 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/OrderTask.java

@@ -0,0 +1,106 @@
+package com.github.zuihou.business.operationManagementCenter.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotEmpty;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_order_task_conf")
+@ApiModel(value = "OrderTask", description = "订单任务配置表")
+@AllArgsConstructor
+public class OrderTask extends Entity<Long> {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    /**
+     * 订单ID
+     */
+    @ApiModelProperty(value = "订单编号")
+    @NotEmpty(message = "订单编号不能为空")
+    @TableField(value = "order_id", condition = LIKE)
+    @Excel(name = "订单ID")
+    private Long orderId;
+
+    @ApiModelProperty(value = "起点位置")
+    @NotEmpty(message = "起点位置不能为空")
+    @Length(max = 128, message = "起点位置长度不能超过128")
+    @TableField(value = "start", condition = LIKE)
+    @Excel(name = "起点位置")
+    private String start;
+
+    @ApiModelProperty(value = "目标位置")
+    @NotEmpty(message = "起点位置不能为空")
+    @Length(max = 128, message = "目标位置长度不能超过128")
+    @TableField(value = "goal", condition = LIKE)
+    @Excel(name = "目标位置")
+    private String goal;
+
+    @ApiModelProperty(value = "是否加工")
+    @NotEmpty(message = "是否加工不能为空")
+    @Length(max = 1, message = "是否加工长度不能超过1")
+    @TableField(value = "is_machine", condition = LIKE)
+    @Excel(name = "是否加工")
+    private String isMachine;
+
+    @ApiModelProperty(value = "是否线边库管理")
+    @NotEmpty(message = "是否线边库管理不能为空")
+    @Length(max = 1, message = "是否线边库管理长度不能超过1")
+    @TableField(value = "is_xbk", condition = LIKE)
+    @Excel(name = "是否线边库管理")
+    private String isXbk;
+
+    @ApiModelProperty(value = "是否包含零件")
+    @NotEmpty(message = "是否包含零件不能为空")
+    @Length(max = 1, message = "是否包含零件长度不能超过1")
+    @TableField(value = "has_material", condition = LIKE)
+    @Excel(name = "是否包含零件")
+    private String hasMaterial;
+
+    @ApiModelProperty(value = "历史零件批次号")
+    @NotEmpty(message = "历史零件批次号")
+    @Length(max = 255, message = "历史零件批次号管理长度不能超过255")
+    @TableField(value = "conf_batch_no", condition = LIKE)
+    @Excel(name = "历史零件批次号")
+    private String confBatchNo;
+
+    @ApiModelProperty(value = "零件名称")
+    @TableField(exist = false)
+    @Excel(name = "零件名称")
+    private String orderName;
+
+    @ApiModelProperty(value = "零件状态")
+    @TableField(exist = false)
+    @Excel(name = "零件状态")
+    private String orderStatus;
+
+
+
+
+    @Builder
+    public OrderTask(Long orderId, String start, String goal,String isMachine, String hasMaterial, String isXbk, String confBatchNo){
+            this.orderId = orderId;
+            this.start = start;
+            this.goal = goal;
+            this.isMachine = isMachine;
+            this.hasMaterial = hasMaterial;
+            this.isXbk = isXbk;
+            this.confBatchNo = confBatchNo;
+    }
+
+}