中科接口修改

main
Comair 7 months ago
parent 7ffb706ac6
commit efdef5a6fd
  1. 74
      shkj-wms/src/main/java/com/shkj/wcs/controller/busin/WcsTaskController.java
  2. 7
      shkj-wms/src/main/java/com/shkj/wcs/service/IBusinDataTaskService.java
  3. 89
      shkj-wms/src/main/java/com/shkj/wcs/service/impl/BusinDataTaskServiceImpl.java
  4. 41
      shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/WCSUtil.java
  5. 1
      shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/dto/WcsIncomingTaskRequestBody.java

@ -49,77 +49,7 @@ public class WcsTaskController {
@PostMapping("/toKjWcs/commonApi") @PostMapping("/toKjWcs/commonApi")
@RepeatSubmit @RepeatSubmit
public WcsResponseVo commonApi(@RequestBody WcsCreateTaskDto bo) { public WcsResponseVo commonApi(@RequestBody WcsCreateTaskDto bo) {
if (bo != null) { return iBusinDataTaskService.doTaskGeneratePickTask(bo);
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::getContainerCode, trayCode)
.in(BusinDataTask::getTaskStatus, TaskStatusEnum.wait_put.getValue(),TaskStatusEnum.wait_callback.getValue() );
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.setContainerCode(trayCode);
businDataTask.setFromSide(fromBinCode);
businDataTask.setToSide(toBinCode);
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue());
businDataTask.setCreateTime(DateUtils.getNowDate());
if (!priority.isEmpty()){
businDataTask.setPriority(priority);
}
boolean save = iBusinDataTaskService.save(businDataTask);
if (save) {
//调用下游接口下任务
log.info("任务储存成功!");
RcsCreateTaskDto rcsCreateTaskDto = new RcsCreateTaskDto();
rcsCreateTaskDto.setTaskType(RCSTaskTypeEnum.PF_LMR_COMMON.getValue());
rcsCreateTaskDto.setRobotTaskCode(businDataTask.getTaskCode());
if(!businDataTask.getPriority().isEmpty()){
rcsCreateTaskDto.setInitPriority(Integer.parseInt(businDataTask.getPriority()));
}
List<RcsIdList> rcsIdLists =new ArrayList<>();
for (int i = 1;i<=2;i++){
RcsIdList rcsIdList =new RcsIdList();
if(i==1){
rcsIdList.setType("ZONE");
rcsIdList.setCode(businDataTask.getFromSide());
rcsIdList.setOperation(RCSOperation.OT_COLLECT.getValue());
}
rcsIdList.setType("ZONE");
rcsIdList.setCode(businDataTask.getToSide());
rcsIdList.setOperation(RCSOperation.OT_DELIVERY.getValue());
rcsIdLists.add(rcsIdList);
}
//Result result = rcsUtil.rcsCreateTask(rcsCreateTaskDto);
}
} else if (dataChange.equals("2")) {
if (one == null) {
return WcsResponseVo.error(500, "未查询到该托盘" + trayCode + "存在未完成的任务");
}
one.setTaskStatus("6");
iBusinDataTaskService.updateById(one);
//推送给下游
}
}
}
}
return WcsResponseVo.success();
} }
@ -168,7 +98,7 @@ public class WcsTaskController {
@Log(title = "扫码处入库申请测试接口", businessType = BusinessType.UPDATE) @Log(title = "扫码处入库申请测试接口", businessType = BusinessType.UPDATE)
@PostMapping("/toWzWcs/wcsIncomingTaskRequest") @PostMapping("/toWzWcs/wcsIncomingTaskRequest")
@RepeatSubmit @RepeatSubmit
public WcsResponseVo wcsIncomingTaskRequest(@RequestBody WcsIncomingTaskRequestDto dto) { public WcsResponseVo wcsIncomingTaskRequest(@RequestBody WcsIncomingTaskRequestBody dto) {
//调用plc接口 暂时不用 //调用plc接口 暂时不用
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(dto); WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(dto);
return vo; return vo;

@ -2,6 +2,8 @@ package com.shkj.wcs.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.shkj.wcs.domain.BusinDataTask; import com.shkj.wcs.domain.BusinDataTask;
import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskDto;
import com.shkj.wcs.vo.WcsResponseVo;
/** /**
* @author Comair * @author Comair
@ -9,6 +11,11 @@ import com.shkj.wcs.domain.BusinDataTask;
*/ */
public interface IBusinDataTaskService extends IService<BusinDataTask> { public interface IBusinDataTaskService extends IService<BusinDataTask> {
/**
* 下发任务
*/
WcsResponseVo doTaskGeneratePickTask(WcsCreateTaskDto bo);
} }

@ -1,6 +1,8 @@
package com.shkj.wcs.service.impl; package com.shkj.wcs.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shkj.common.utils.DateUtils;
import com.shkj.wcs.bo.WcsPlcPropertyQueryBo; import com.shkj.wcs.bo.WcsPlcPropertyQueryBo;
import com.shkj.wcs.domain.BusinDataTask; import com.shkj.wcs.domain.BusinDataTask;
import com.shkj.wcs.domain.WcsPlcProperty; import com.shkj.wcs.domain.WcsPlcProperty;
@ -8,10 +10,20 @@ import com.shkj.wcs.mapper.BusinDataTaskMapper;
import com.shkj.wcs.mapper.WcsPlcPropertyMapper; import com.shkj.wcs.mapper.WcsPlcPropertyMapper;
import com.shkj.wcs.service.IBusinDataTaskService; import com.shkj.wcs.service.IBusinDataTaskService;
import com.shkj.wcs.service.IWcsPlcPropertyService; import com.shkj.wcs.service.IWcsPlcPropertyService;
import com.shkj.wcs.third.rcs.dto.RcsCreateTaskDto;
import com.shkj.wcs.third.rcs.dto.RcsIdList;
import com.shkj.wcs.third.rcs.enums.RCSOperation;
import com.shkj.wcs.third.rcs.enums.RCSTaskTypeEnum;
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.wms.enums.TaskStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -21,6 +33,83 @@ import java.util.List;
* @date 2023-04-21 * @date 2023-04-21
*/ */
@Service @Service
@Slf4j
public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, BusinDataTask> implements IBusinDataTaskService { public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, BusinDataTask> implements IBusinDataTaskService {
@Override
public WcsResponseVo doTaskGeneratePickTask(WcsCreateTaskDto bo) {
log.info("中科下发任务请求数据:"+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::getContainerCode, trayCode)
.in(BusinDataTask::getTaskStatus, TaskStatusEnum.wait_put.getValue(),TaskStatusEnum.wait_callback.getValue() );
BusinDataTask one = this.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.setContainerCode(trayCode);
businDataTask.setFromSide(fromBinCode);
businDataTask.setToSide(toBinCode);
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue());
businDataTask.setCreateTime(DateUtils.getNowDate());
if (!priority.isEmpty()){
businDataTask.setPriority(priority);
}
boolean save = this.save(businDataTask);
if (save) {
//调用下游接口下任务
log.info("任务储存成功!");
RcsCreateTaskDto rcsCreateTaskDto = new RcsCreateTaskDto();
rcsCreateTaskDto.setTaskType(RCSTaskTypeEnum.PF_LMR_COMMON.getValue());
rcsCreateTaskDto.setRobotTaskCode(businDataTask.getTaskCode());
if(!businDataTask.getPriority().isEmpty()){
rcsCreateTaskDto.setInitPriority(Integer.parseInt(businDataTask.getPriority()));
}
List<RcsIdList> rcsIdLists =new ArrayList<>();
for (int i = 1;i<=2;i++){
RcsIdList rcsIdList =new RcsIdList();
if(i==1){
rcsIdList.setType("ZONE");
rcsIdList.setCode(businDataTask.getFromSide());
rcsIdList.setOperation(RCSOperation.OT_COLLECT.getValue());
}
rcsIdList.setType("ZONE");
rcsIdList.setCode(businDataTask.getToSide());
rcsIdList.setOperation(RCSOperation.OT_DELIVERY.getValue());
rcsIdLists.add(rcsIdList);
}
//Result result = rcsUtil.rcsCreateTask(rcsCreateTaskDto);
}
} else if (dataChange.equals("2")) {
if (one == null) {
return WcsResponseVo.error(500, "未查询到该托盘" + trayCode + "存在未完成的任务");
}
one.setTaskStatus("6");
this.updateById(one);
//推送给下游
}
return WcsResponseVo.success();
}
}
}
return WcsResponseVo.error(500,"请求失败请检查参数");
}
} }

@ -64,13 +64,18 @@ public class WCSUtil {
* @return * @return
*/ */
public WcsResponseVo queryTaskStatus(WCSQueryTaskStatusBody dto) { public WcsResponseVo queryTaskStatus(WCSQueryTaskStatusBody dto) {
Map<String, String> headerMap = new HashMap<>(1); JSONObject jsonObject = new JSONObject();
headerMap.put("businessType", "trayCheck"); JSONObject header = new JSONObject();
String json = JSONObject.toJSONString(dto); header.put("businessType","queryTaskStatus");
jsonObject.put("header",header);
List<WCSQueryTaskStatusBody> queryTaskStatusBodyList = new ArrayList<>();
queryTaskStatusBodyList.add(dto);
jsonObject.put("body",queryTaskStatusBodyList);
String json = JSONObject.toJSONString(jsonObject);
log.info("KJ向WZ请求是否存在生产区空托出库任务参数"+json); log.info("KJ向WZ请求是否存在生产区空托出库任务参数"+json);
try { try {
String res = HttpRequest.post(queryTaskStatusUrl) String res = HttpRequest.post(queryTaskStatusUrl)
.addHeaders(headerMap)
.body(json) .body(json)
.execute().body(); .execute().body();
log.info("KJ向WZ请求是否存在生产区空托出库任务返回:" + res); log.info("KJ向WZ请求是否存在生产区空托出库任务返回:" + res);
@ -90,13 +95,18 @@ public class WCSUtil {
* @return * @return
*/ */
public WcsResponseVo wcsIncomingTrayCheck(WcsIncomingTrayCheckBody dto) { public WcsResponseVo wcsIncomingTrayCheck(WcsIncomingTrayCheckBody dto) {
Map<String, String> headerMap = new HashMap<>(1); JSONObject jsonObject = new JSONObject();
headerMap.put("businessType", "trayCheck"); JSONObject header = new JSONObject();
String json = JSONObject.toJSONString(dto); header.put("businessType","trayCheck");
jsonObject.put("header",header);
List<WcsIncomingTrayCheckBody> incomingTrayCheckBodies = new ArrayList<>();
incomingTrayCheckBodies.add(dto);
jsonObject.put("body",incomingTrayCheckBodies);
String json = JSONObject.toJSONString(jsonObject);
log.info("KJ向WZ请求生产区入库托盘码校验参数"+json); log.info("KJ向WZ请求生产区入库托盘码校验参数"+json);
try { try {
String res = HttpRequest.post(wcsIncomingTrayCheckUrl) String res = HttpRequest.post(wcsIncomingTrayCheckUrl)
.addHeaders(headerMap)
.body(json) .body(json)
.execute().body(); .execute().body();
log.info("KJ向WZ请求生产区入库托盘码校验返回:" + res); log.info("KJ向WZ请求生产区入库托盘码校验返回:" + res);
@ -116,14 +126,19 @@ public class WCSUtil {
* @param dto * @param dto
* @return * @return
*/ */
public WcsResponseVo wcsIncomingTaskRequest(WcsIncomingTaskRequestDto dto) { public WcsResponseVo wcsIncomingTaskRequest(WcsIncomingTaskRequestBody dto) {
Map<String, String> headerMap = new HashMap<>(1); JSONObject jsonObject = new JSONObject();
headerMap.put("businessType", dto.getHeader().getBusinessType()); JSONObject header = new JSONObject();
String json = JSONObject.toJSONString(dto); header.put("businessType","stockIn");
jsonObject.put("header",header);
List<WcsIncomingTaskRequestBody> incomingTaskRequestBodies = new ArrayList<>();
incomingTaskRequestBodies.add(dto);
jsonObject.put("body",incomingTaskRequestBodies);
String json = JSONObject.toJSONString(jsonObject);
log.info("KJ向WZ入库申请参数"+json); log.info("KJ向WZ入库申请参数"+json);
try { try {
String res = HttpRequest.post(wcsIncomingTaskRequestUrl) String res = HttpRequest.post(wcsIncomingTaskRequestUrl)
.addHeaders(headerMap)
.body(json) .body(json)
.execute().body(); .execute().body();
log.info("KJ向WZ入库申请返回:" + res); log.info("KJ向WZ入库申请返回:" + res);

@ -21,7 +21,6 @@ public class WcsIncomingTaskRequestBody implements Serializable {
/** /**
* 托盘码 * 托盘码
*/ */
@NotBlank(message = "托盘码不得为空")
private String trayCode; private String trayCode;

Loading…
Cancel
Save