|
|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
package com.shkj.wcs.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.shkj.common.utils.DateUtils; |
|
|
|
|
import com.shkj.wcs.bo.WcsPlcPropertyQueryBo; |
|
|
|
|
import com.shkj.wcs.domain.BusinDataTask; |
|
|
|
|
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.service.IBusinDataTaskService; |
|
|
|
|
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.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -21,6 +33,83 @@ import java.util.List; |
|
|
|
|
* @date 2023-04-21 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@Slf4j |
|
|
|
|
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,"请求失败请检查参数"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|