parent
6653b0e8b3
commit
cf34501387
@ -0,0 +1,23 @@ |
||||
package com.shkj.wcs.bo; |
||||
|
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@Accessors(chain = true) |
||||
public class WcsRequestBo implements Serializable { |
||||
|
||||
private Header header; |
||||
private List<Object> body; |
||||
|
||||
@Data |
||||
public static class Header { |
||||
private String businessType; |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,35 @@ |
||||
package com.shkj.wcs.controller.busin; |
||||
|
||||
import com.shkj.common.annotation.Log; |
||||
import com.shkj.common.annotation.RepeatSubmit; |
||||
import com.shkj.common.enums.BusinessType; |
||||
import com.shkj.wcs.bo.WcsRequestBo; |
||||
import com.shkj.wcs.vo.QueryAreaStatusVo; |
||||
import com.shkj.wcs.vo.WcsResponseVo; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RequiredArgsConstructor(onConstructor_ =@Autowired) |
||||
@RestController |
||||
@RequestMapping("/api") |
||||
public class AgvTaskContorller { |
||||
|
||||
|
||||
/** |
||||
* 执行task |
||||
*/ |
||||
@Log(title = "查询每个库区状态",businessType = BusinessType.UPDATE) |
||||
@PostMapping("/toKjWcs/queryAreaStatus") |
||||
@RepeatSubmit |
||||
public WcsResponseVo queryAreaStatus(WcsRequestBo wcsRequestBo){ |
||||
// 请求agv接口...
|
||||
List<QueryAreaStatusVo> areaStatusVos = new ArrayList<>(); |
||||
return WcsResponseVo.success(areaStatusVos); |
||||
} |
||||
} |
||||
@ -0,0 +1,85 @@ |
||||
package com.shkj.wcs.controller.busin; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.shkj.common.annotation.Log; |
||||
import com.shkj.common.annotation.RepeatSubmit; |
||||
import com.shkj.common.enums.BusinessType; |
||||
import com.shkj.common.utils.DateUtils; |
||||
import com.shkj.wcs.service.IBusinDataTaskService; |
||||
import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskBody; |
||||
import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskDto; |
||||
import com.shkj.wcs.vo.WcsResponseVo; |
||||
import com.shkj.wcs.domain.BusinDataTask; |
||||
import com.shkj.wms.service.IBusinTaskService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RequiredArgsConstructor(onConstructor_ =@Autowired) |
||||
@RestController |
||||
@RequestMapping("/api") |
||||
public class WcsTaskController { |
||||
|
||||
@Autowired |
||||
private IBusinDataTaskService iBusinDataTaskService; |
||||
|
||||
|
||||
/** |
||||
* wz-wcs任务下发 |
||||
*/ |
||||
@Log(title = "wz-wcs任务下发",businessType = BusinessType.UPDATE) |
||||
@PostMapping("/toKjWcs/commonApi") |
||||
@RepeatSubmit |
||||
public WcsResponseVo commonApi(WcsCreateTaskDto bo){ |
||||
if(bo != null){ |
||||
List<WcsCreateTaskBody> body = bo.getBody(); |
||||
if(!body.isEmpty()){ |
||||
for(WcsCreateTaskBody by : body){ |
||||
String taskId = by.getTaskId(); |
||||
String trayCode = by.getTrayCode(); |
||||
String taskType = by.getTaskType(); |
||||
String fromBinCode = by.getFromBinCode(); |
||||
String toBinCode = by.getToBinCode(); |
||||
String dataChange = by.getDataChange(); |
||||
String priority = by.getPriority(); |
||||
LambdaQueryWrapper<BusinDataTask> lqwDataTask = new LambdaQueryWrapper<BusinDataTask>() |
||||
.eq(BusinDataTask::getContainerId,trayCode) |
||||
.in(BusinDataTask::getTaskStatus,"1","2"); |
||||
BusinDataTask one = iBusinDataTaskService.getOne(lqwDataTask); |
||||
if(dataChange.equals("1")){ |
||||
if (one != null){ |
||||
return WcsResponseVo.error(500,"该托盘"+trayCode+"存在未完成的任务"); |
||||
} |
||||
BusinDataTask businDataTask = new BusinDataTask(); |
||||
businDataTask.setTaskCode(taskId); |
||||
businDataTask.setTaskType(taskType); |
||||
businDataTask.setContainerId(Long.valueOf(trayCode)); |
||||
businDataTask.setFromSide(fromBinCode); |
||||
businDataTask.setToSide(toBinCode); |
||||
businDataTask.setCreateTime(DateUtils.getNowDate()); |
||||
businDataTask.setPriority(priority); |
||||
boolean save = iBusinDataTaskService.save(businDataTask); |
||||
if(save){ |
||||
//调用下游接口下任务
|
||||
|
||||
} |
||||
}else if(dataChange.equals("2")){ |
||||
if (one == null){ |
||||
return WcsResponseVo.error(500,"未查询到该托盘"+trayCode+"存在未完成的任务"); |
||||
} |
||||
one.setTaskStatus("6"); |
||||
iBusinDataTaskService.updateById(one); |
||||
//推送给下游
|
||||
|
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
return WcsResponseVo.success(); |
||||
} |
||||
} |
||||
@ -1,8 +1,8 @@ |
||||
package com.shkj.wms.mapper; |
||||
package com.shkj.wcs.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.shkj.wms.bo.BusinTaskQueryBo; |
||||
import com.shkj.wms.domain.BusinDataTask; |
||||
import com.shkj.wcs.domain.BusinDataTask; |
||||
import com.shkj.wms.vo.BusinDataTaskVo; |
||||
|
||||
import java.util.Date; |
||||
@ -0,0 +1,12 @@ |
||||
package com.shkj.wcs.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.shkj.wcs.domain.BusinDataTask; |
||||
|
||||
/** |
||||
* @author Comair |
||||
* @date 2025年04月18日 9:11 |
||||
*/ |
||||
public interface IBusinDataTaskService extends IService<BusinDataTask> { |
||||
|
||||
} |
||||
@ -0,0 +1,10 @@ |
||||
package com.shkj.wcs.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.shkj.wcs.domain.BusinDataTask; |
||||
import com.shkj.wcs.mapper.BusinDataTaskMapper; |
||||
import com.shkj.wcs.service.IBusinDataTaskService; |
||||
import com.shkj.wms.service.IBusinTaskService; |
||||
|
||||
public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper,BusinDataTask> implements IBusinDataTaskService { |
||||
} |
||||
@ -0,0 +1,63 @@ |
||||
package com.shkj.wcs.third.workbinWcs.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@Accessors(chain = true) |
||||
public class WcsCreateTaskBody implements Serializable { |
||||
/** |
||||
* 任务号(唯一编号) |
||||
*/ |
||||
@NotBlank(message = "任务id不得为空") |
||||
private String taskId; |
||||
|
||||
/** |
||||
* 托盘码 |
||||
*/ |
||||
@NotBlank(message = "托盘码不得为空") |
||||
private String trayCode; |
||||
|
||||
|
||||
/** |
||||
* 任务类型 |
||||
* 出库:1 |
||||
* 入库:2 |
||||
* 同层同巷道移库:3 |
||||
*/ |
||||
@NotBlank(message = "任务类型不得为空") |
||||
private String taskType; |
||||
|
||||
/** |
||||
* 任务起点(线体站台,立库终点) |
||||
*/ |
||||
@NotBlank(message = "任务起点不得为空") |
||||
private String fromBinCode; |
||||
|
||||
/** |
||||
* 任务终点 |
||||
*/ |
||||
@NotBlank(message = "任务终点不得为空") |
||||
private String toBinCode; |
||||
|
||||
/** |
||||
* 任务下发时间 包括毫秒 |
||||
*/ |
||||
private String createDt; |
||||
|
||||
/** |
||||
* 新增:1 |
||||
*/ |
||||
@NotBlank(message = "数据类型不得为空") |
||||
private String dataChange; |
||||
|
||||
/** |
||||
* 优先级 |
||||
*/ |
||||
private String priority; |
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
package com.shkj.wcs.third.workbinWcs.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 任务下发实体类 |
||||
*/ |
||||
@Data |
||||
@NoArgsConstructor |
||||
@Accessors(chain = true) |
||||
public class WcsCreateTaskDto implements Serializable { |
||||
|
||||
private WcsCreateTaskHeader header; |
||||
private List<WcsCreateTaskBody> body; |
||||
} |
||||
|
||||
@ -0,0 +1,14 @@ |
||||
package com.shkj.wcs.third.workbinWcs.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@Accessors(chain = true) |
||||
public class WcsCreateTaskHeader implements Serializable { |
||||
private String businessType = "commonTask"; |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
package com.shkj.wcs.third.workbinWcs.enums; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* 任务状态枚举 |
||||
* |
||||
* @author zjx |
||||
* @date 2024/09/05 |
||||
*/ |
||||
@Getter |
||||
@AllArgsConstructor |
||||
public enum WcsCallbackTaskEnum { |
||||
|
||||
wait("1", "等待"), |
||||
exec("2", "进行中"), |
||||
finish("3", "完成"), |
||||
fail("4", "失败"), |
||||
; |
||||
|
||||
private String value; |
||||
private String desc; |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
package com.shkj.wcs.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
public class QueryAreaStatusVo implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
//库区标识
|
||||
private String areaInLocation; |
||||
|
||||
//状态
|
||||
private Integer status; |
||||
} |
||||
@ -0,0 +1,60 @@ |
||||
package com.shkj.wcs.vo; |
||||
|
||||
import lombok.Data; |
||||
import org.apache.poi.ss.formula.functions.T; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class WcsResponseVo<T> { |
||||
private ResponseHeader header; |
||||
private List<T> body; |
||||
|
||||
@Data |
||||
public static class ResponseHeader { |
||||
private Integer msgCode; |
||||
private String message; |
||||
} |
||||
|
||||
// 成功
|
||||
public static <T> WcsResponseVo<T> success(List<T> data) { |
||||
WcsResponseVo<T> response = new WcsResponseVo<>(); |
||||
response.setHeader(createSuccessHeader()); |
||||
response.setBody(data != null ? data : Collections.emptyList()); |
||||
return response; |
||||
} |
||||
|
||||
// 无数据的成功响应
|
||||
public static <T> WcsResponseVo<T> success() { |
||||
return success(null); |
||||
} |
||||
|
||||
// 单对象成功响应(非List场景)
|
||||
public static <T> WcsResponseVo<T> success(T item) { |
||||
WcsResponseVo<T> response = new WcsResponseVo<>(); |
||||
response.setHeader(createSuccessHeader()); |
||||
response.setBody(item != null ? |
||||
Collections.singletonList(item) : |
||||
Collections.emptyList()); |
||||
return response; |
||||
} |
||||
|
||||
// 错误响应
|
||||
public static <T> WcsResponseVo<T> error(int code, String msg) { |
||||
WcsResponseVo<T> response = new WcsResponseVo<>(); |
||||
ResponseHeader header = new ResponseHeader(); |
||||
header.setMsgCode(code); |
||||
header.setMessage(msg); |
||||
response.setHeader(header); |
||||
response.setBody(Collections.emptyList()); // 错误时body默认为空数组
|
||||
return response; |
||||
} |
||||
|
||||
private static ResponseHeader createSuccessHeader() { |
||||
ResponseHeader header = new ResponseHeader(); |
||||
header.setMsgCode(200); |
||||
header.setMessage("调用成功"); |
||||
return header; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue