add:主分支合并完成
This commit is contained in:
@@ -2,8 +2,12 @@ package cn.code.nl.module.task.api;
|
||||
|
||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||
import cn.code.nl.module.task.dto.TaskInfoDTO;
|
||||
import cn.code.nl.module.task.dto.TransportTaskDestinationAssignReq;
|
||||
import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO;
|
||||
import cn.code.nl.module.task.dto.TransportTaskQueryReq;
|
||||
import cn.code.nl.module.task.dto.UnfinishedTaskPointReqDTO;
|
||||
import cn.code.nl.module.task.dto.TaskCallbackResultReqDTO;
|
||||
import cn.code.nl.module.task.dto.TransportTaskUpdateReqDTO;
|
||||
import cn.code.nl.module.task.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -51,6 +55,25 @@ public interface TransportTaskApi {
|
||||
@Operation(summary = "根据 taskCode 查询任务")
|
||||
CommonResult<TaskInfoDTO> getTaskByCode(@RequestParam("taskCode") String taskCode);
|
||||
|
||||
/**
|
||||
* 根据点位编码查询第一条未完成任务
|
||||
*
|
||||
* @param pointCode 点位编码
|
||||
* @return 未完成任务
|
||||
*/
|
||||
@GetMapping(PREFIX + "/getFirstUnfinishedTaskByPointCode")
|
||||
CommonResult<TaskInfoDTO> getFirstUnfinishedTaskByPointCode(@RequestParam("pointCode") String pointCode);
|
||||
|
||||
@GetMapping(PREFIX + "/getUnfinishedTaskByBiz")
|
||||
@Operation(summary = "根据业务标识查询未完成任务")
|
||||
CommonResult<TaskInfoDTO> getUnfinishedTaskByBiz(@RequestParam("ownerService") String ownerService,
|
||||
@RequestParam("bizType") String bizType,
|
||||
@RequestParam("bizId") String bizId);
|
||||
|
||||
@GetMapping(PREFIX + "/hasUnfinishedTaskByVehicleCode")
|
||||
@Operation(summary = "判断载具是否存在未完成任务")
|
||||
CommonResult<Boolean> hasUnfinishedTaskByVehicleCode(@RequestParam("vehicleCode") String vehicleCode);
|
||||
|
||||
@GetMapping(PREFIX + "/getRunningTaskByMaterialId")
|
||||
@Operation(summary = "根据 materialId 和 ownerService 查询运行中任务")
|
||||
CommonResult<List<TaskInfoDTO>> getRunningTaskByMaterialId(@RequestParam("materialId") Long materialId,
|
||||
@@ -65,4 +88,47 @@ public interface TransportTaskApi {
|
||||
@Operation(summary = "统计指定目的点的未完成任务数")
|
||||
CommonResult<Long> countUnfinishedByDestination(@RequestParam("pointCode") String pointCode,
|
||||
@RequestParam("ownerService") String ownerService);
|
||||
|
||||
@GetMapping(PREFIX + "/updateTransportTask")
|
||||
@Operation(summary = "更新搬运任务")
|
||||
CommonResult<Boolean> updateTransportTask(@RequestBody TransportTaskUpdateReqDTO transportTaskUpdateReqDTO);
|
||||
|
||||
/**
|
||||
* 根据任务类型和结果参数中的区块统计未完成任务数
|
||||
*
|
||||
* @param taskType 任务类型
|
||||
* @param block 区块
|
||||
* @return 未完成任务数
|
||||
*/
|
||||
@GetMapping(PREFIX + "/countUnfinishedByTaskTypeAndResultBlock")
|
||||
CommonResult<Long> countUnfinishedByTaskTypeAndResultBlock(
|
||||
@RequestParam("taskType") String taskType, @RequestParam("block") String block);
|
||||
|
||||
/**
|
||||
* 检查指定点位是否存在未完成任务
|
||||
*
|
||||
* @param reqDTO 点位查询请求
|
||||
* @return 是否存在未完成任务
|
||||
*/
|
||||
@PostMapping(PREFIX + "/hasUnfinishedByPointCodes")
|
||||
CommonResult<Boolean> hasUnfinishedByPointCodes(@Valid @RequestBody UnfinishedTaskPointReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 根据任务类型和状态查询搬运任务
|
||||
*
|
||||
* @param req 查询请求
|
||||
* @return 搬运任务列表
|
||||
*/
|
||||
@PostMapping(PREFIX + "/queryTransportTasks")
|
||||
CommonResult<List<TaskInfoDTO>> queryTransportTasks(@Valid @RequestBody TransportTaskQueryReq req);
|
||||
|
||||
/**
|
||||
* 条件分配搬运任务目的点并推进任务状态
|
||||
*
|
||||
* @param req 目的点分配请求
|
||||
* @return 是否分配成功
|
||||
*/
|
||||
@PostMapping(PREFIX + "/assignDestination")
|
||||
CommonResult<Boolean> assignDestination(@Valid @RequestBody TransportTaskDestinationAssignReq req);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ public class TransportTaskCreateReqDTO {
|
||||
@NotEmpty(message = "业务归属服务不能为空")
|
||||
private String ownerService;
|
||||
|
||||
@Schema(description = "任务状态:设置以这个为准")
|
||||
private String taskStatus;
|
||||
|
||||
@Schema(description = "业务类型")
|
||||
private String bizType;
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.code.nl.module.task.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 搬运任务目的点分配请求
|
||||
*/
|
||||
@Data
|
||||
public class TransportTaskDestinationAssignReq implements Serializable {
|
||||
|
||||
/**
|
||||
* 任务标识
|
||||
*/
|
||||
@NotNull(message = "任务标识不能为空")
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 目的点编码
|
||||
*/
|
||||
@NotEmpty(message = "目的点编码不能为空")
|
||||
private String pointCode2;
|
||||
|
||||
/**
|
||||
* 期望任务状态
|
||||
*/
|
||||
@NotEmpty(message = "期望任务状态不能为空")
|
||||
private String expectedTaskStatus;
|
||||
|
||||
/**
|
||||
* 目标任务状态
|
||||
*/
|
||||
@NotEmpty(message = "目标任务状态不能为空")
|
||||
private String targetTaskStatus;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.code.nl.module.task.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 搬运任务查询请求
|
||||
*/
|
||||
@Data
|
||||
public class TransportTaskQueryReq implements Serializable {
|
||||
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
@NotEmpty(message = "任务类型不能为空")
|
||||
private String taskType;
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*/
|
||||
@NotEmpty(message = "任务状态不能为空")
|
||||
private String taskStatus;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package cn.code.nl.module.task.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* LMS/WMS 更新搬运任务请求 DTO
|
||||
*
|
||||
* @author dsh
|
||||
* 2026/8/11
|
||||
*/
|
||||
@Schema(description = "RPC - 搬运任务更新 Request DTO")
|
||||
@Data
|
||||
public class TransportTaskUpdateReqDTO {
|
||||
|
||||
private Long taskId;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "业务归属服务:LMS/WMS", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String ownerService;
|
||||
|
||||
@Schema(description = "业务类型")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "业务侧标识")
|
||||
private String bizId;
|
||||
|
||||
@Schema(description = "业务回调处理器编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String handleCode;
|
||||
|
||||
@Schema(description = "ACS任务类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String acsTaskType;
|
||||
|
||||
@Schema(description = "AGV系统类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String agvSystemType;
|
||||
|
||||
@Schema(description = "取货点1")
|
||||
private String pointCode1;
|
||||
|
||||
@Schema(description = "放货点1")
|
||||
private String pointCode2;
|
||||
|
||||
@Schema(description = "取货点2")
|
||||
private String pointCode3;
|
||||
|
||||
@Schema(description = "放货点2")
|
||||
private String pointCode4;
|
||||
|
||||
@Schema(description = "载具编码")
|
||||
private String vehicleCode;
|
||||
|
||||
@Schema(description = "载具编码2")
|
||||
private String vehicleCode2;
|
||||
|
||||
@Schema(description = "物料id")
|
||||
private Long materialId;
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
private String materialCode;
|
||||
|
||||
@Schema(description = "优先级")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "生产区域")
|
||||
private String productArea;
|
||||
|
||||
@Schema(description = "是否自动下发")
|
||||
private String isAutoIssue;
|
||||
|
||||
@Schema(description = "是否创建完成")
|
||||
private Boolean isCreateFinish;
|
||||
|
||||
@Schema(description = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
@Schema(description = "载具类型")
|
||||
private String vehicleType;
|
||||
|
||||
@Schema(description = "载具数量")
|
||||
private Long vehicleQty;
|
||||
|
||||
@Schema(description = "车号")
|
||||
private String carNo;
|
||||
|
||||
@Schema(description = "任务组标识")
|
||||
private Long taskGroupId;
|
||||
|
||||
@Schema(description = "任务组顺序号")
|
||||
private Long sortSeq;
|
||||
|
||||
@Schema(description = "扩展参数(JSON)")
|
||||
private String requestParam;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.code.nl.module.task.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 未完成任务点位查询请求
|
||||
*/
|
||||
@Data
|
||||
public class UnfinishedTaskPointReqDTO {
|
||||
|
||||
/**
|
||||
* 点位编码列表
|
||||
*/
|
||||
@NotEmpty(message = "点位编码列表不能为空")
|
||||
private List<@NotBlank(message = "点位编码不能为空") String> pointCodes;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.code.nl.module.task.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 任务业务回调方式
|
||||
*/
|
||||
@Getter
|
||||
public enum TaskCallbackTypeEnum {
|
||||
|
||||
MQ("mq"),
|
||||
|
||||
FEIGN("feign");
|
||||
|
||||
private final String code;
|
||||
|
||||
TaskCallbackTypeEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编码获取任务业务回调方式
|
||||
*
|
||||
* @param code 回调方式编码
|
||||
* @return 任务业务回调方式
|
||||
*/
|
||||
public static TaskCallbackTypeEnum getByCode(String code) {
|
||||
for (TaskCallbackTypeEnum value : values()) {
|
||||
if (value.getCode().equals(code)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,52 @@
|
||||
package cn.code.nl.module.task.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 任务业务归属服务枚举
|
||||
* @author dsh
|
||||
* 2026/7/29
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TaskOwnerServiceEnum {
|
||||
|
||||
LMS("LMS","生产业务"),
|
||||
WMS("WMS","仓储业务");
|
||||
LMS("lms", "LMS"),
|
||||
WMS("wms", "WMS");
|
||||
|
||||
private String code;
|
||||
/**
|
||||
* MQ Topic 前缀
|
||||
*/
|
||||
private final String code;
|
||||
|
||||
private String name;
|
||||
/**
|
||||
* 服务注册名称
|
||||
*/
|
||||
private final String serviceName;
|
||||
|
||||
TaskOwnerServiceEnum(String code,String name){
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
/**
|
||||
* 根据业务归属编码获取枚举
|
||||
*
|
||||
* @param code 业务归属编码
|
||||
* @return 业务归属服务枚举
|
||||
*/
|
||||
public static TaskOwnerServiceEnum getByCode(String code) {
|
||||
for (TaskOwnerServiceEnum value : values()) {
|
||||
if (value.name().equalsIgnoreCase(code) || value.serviceName.equalsIgnoreCase(code)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建业务服务消费的 Topic
|
||||
*
|
||||
* @param topic 基础 Topic
|
||||
* @return 完整 Topic
|
||||
*/
|
||||
public String buildTopic(String topic) {
|
||||
return code + "_" + topic;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,19 +9,30 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum TaskTypeEnum {
|
||||
|
||||
RAW_FOIL_STANDARD_TASK("010101","生箔标准任务"),
|
||||
SLI_UP_QZZ_TASK("010101","分切送轴任务"),
|
||||
RAW_FOIL_INSTORAGE_TASK("010102","称重入库任务"),
|
||||
AUTO_AIR_SHAFT_TASK("010103", "自动子卷桁架搬运任务"),
|
||||
AUTO_SLEEVE_TASK("010104", "自动套轴桁架搬运任务");
|
||||
SLI_UP_QZZ_TASK("010101","分切送轴任务", "1"),
|
||||
RAW_FOIL_STANDARD_TASK("010101","生箔标准任务","1"),
|
||||
RAW_FOIL_SINGLE_FULL_ROLL_TASK("010102","生箔单下满卷任务","1"),
|
||||
RAW_FOIL_SINGLE_EMPTY_ROLL_LOWER_TASK("010103","生箔单下空辊任务","5"),
|
||||
RAW_FOIL_SINGLE_EMPTY_ROLL_UP_TASK("010104","生箔单上空辊任务","5"),
|
||||
RAW_FOIL_INSTORAGE_TASK("010105","称重入库任务","5"),
|
||||
RAW_FOIL_WEIGHING_TASK("010106","母卷称重任务","5"),
|
||||
RAW_FOIL_IN_HOTBOX_TASK("010107","入烘箱任务","5"),
|
||||
RAW_FOIL_OUT_HOTBOX_TASK("010108","出烘箱任务","5"),
|
||||
RAW_FOIL_QC_TRANSFER_TASK("010109","质检转运任务","5"),
|
||||
RAW_FOIL_CACHE_TO_QC_TASK("010110","缓存到质检任务","5"),
|
||||
AUTO_AIR_SHAFT_TASK("010103", "自动子卷桁架搬运任务","5"),
|
||||
AUTO_SLEEVE_TASK("010104", "自动套轴桁架搬运任务","5");
|
||||
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
TaskTypeEnum(String code,String name){
|
||||
private String defaultPriority;
|
||||
|
||||
TaskTypeEnum(String code,String name,String defaultPriority){
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.defaultPriority = defaultPriority;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,20 @@ public class TaskEventMessage {
|
||||
/** 业务回调处理器编码 */
|
||||
private String handleCode;
|
||||
|
||||
/** 触发任务状态完成时的登录用户 */
|
||||
private Long operatorId;
|
||||
|
||||
/** 扩展数据 */
|
||||
private Map<String, Object> payload;
|
||||
|
||||
/**
|
||||
* 构建任务事件唯一标识
|
||||
*
|
||||
* @param taskId 任务标识
|
||||
* @param eventType 事件类型
|
||||
* @return 任务事件唯一标识
|
||||
*/
|
||||
public static String buildEventId(Long taskId, String eventType) {
|
||||
return taskId + "_" + eventType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.code.nl.module.task.enums;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 任务业务归属服务本地 Spring 集成测试
|
||||
*/
|
||||
@SpringBootTest(classes = TaskOwnerServiceEnumLocalSpringTest.TestConfiguration.class)
|
||||
class TaskOwnerServiceEnumLocalSpringTest {
|
||||
|
||||
/**
|
||||
* 验证 LMS 业务归属编码生成消费者 Topic
|
||||
*/
|
||||
@Test
|
||||
void buildTopicShouldSupportLmsOwnerService() {
|
||||
TaskOwnerServiceEnum ownerService = TaskOwnerServiceEnum.getByCode("LMS");
|
||||
|
||||
Assertions.assertNotNull(ownerService);
|
||||
Assertions.assertEquals("lms_task_status_change_dev_topic",
|
||||
ownerService.buildTopic("task_status_change_dev_topic"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 WMS 业务归属编码生成消费者 Topic
|
||||
*/
|
||||
@Test
|
||||
void buildTopicShouldSupportWmsOwnerService() {
|
||||
TaskOwnerServiceEnum ownerService = TaskOwnerServiceEnum.getByCode("WMS");
|
||||
|
||||
Assertions.assertNotNull(ownerService);
|
||||
Assertions.assertEquals("wms_task_status_change_dev_topic",
|
||||
ownerService.buildTopic("task_status_change_dev_topic"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证兼容服务注册名称并拒绝非法业务归属
|
||||
*/
|
||||
@Test
|
||||
void getByCodeShouldSupportServiceNameAndRejectInvalidCode() {
|
||||
Assertions.assertEquals(TaskOwnerServiceEnum.LMS,
|
||||
TaskOwnerServiceEnum.getByCode("lms-server"));
|
||||
Assertions.assertEquals(TaskOwnerServiceEnum.WMS,
|
||||
TaskOwnerServiceEnum.getByCode("wms-server"));
|
||||
Assertions.assertNull(TaskOwnerServiceEnum.getByCode("invalid-server"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 Spring 配置
|
||||
*/
|
||||
@Configuration
|
||||
static class TestConfiguration {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user