package com.zy.asrs.task;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.exception.CoolException;
|
import com.zy.asrs.entity.TaskWrk;
|
import com.zy.asrs.entity.TaskWrkLog;
|
import com.zy.asrs.service.ApiLogService;
|
import com.zy.asrs.service.TaskWrkService;
|
import com.zy.common.utils.HttpHandler;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.io.IOException;
|
import java.util.HashMap;
|
import java.util.List;
|
|
@Slf4j
|
@Component
|
public class AssignTasksRCSScheduler {
|
@Autowired
|
private TaskWrkService taskWrkService;
|
@Autowired
|
private ApiLogService apiLogService;
|
@Value("${wcs.urlWcs}")
|
private String wcsUrl;
|
@Value("${wcs.movePathWcs}")
|
private String wcsmovePath;
|
@Value("${wcs.outboundTaskRequest}")
|
private String wcsoutboundTaskRequest;
|
@Value("${wms.TaskExecCallback}")
|
private String TaskExecCallback;
|
@Value("${wms.taskStatusFeedbackPath}")
|
private String taskStatusFeedbackPath;
|
|
/**
|
* 自动派发出库任务给RCS
|
*
|
* @throws IOException
|
*/
|
@Scheduled(cron = "0/3 * * * * ? ")
|
public void execute() throws IOException {
|
if(true){
|
List<TaskWrk> taskWrks=taskWrkService.selectList(new EntityWrapper<TaskWrk>()
|
.eq("wrk_sts",1).eq("io_type",3));
|
for(TaskWrk taskWrk:taskWrks){
|
HashMap<String, Object> headParam = new HashMap<>();
|
String response = "";
|
Boolean bool = false;
|
String dz="";
|
if(taskWrk.getIoType()==2){
|
dz=wcsoutboundTaskRequest;
|
}else{
|
dz=wcsmovePath;
|
}
|
try {
|
headParam.put("taskNo", taskWrk.getTaskNo());
|
headParam.put("sourceLocNo",taskWrk.getStartPoint());//源库位
|
headParam.put("locNo",taskWrk.getTargetPoint());//目标库位
|
log.info("wcs派发任务给RCS出库={}", taskWrk);
|
response = new HttpHandler.Builder()
|
// .setHeaders(headParam)
|
.setUri(wcsUrl)
|
.setPath(dz)
|
.setJson(JSON.toJSONString(headParam))
|
.build()
|
.doPost();
|
JSONObject jsonObject = JSON.parseObject(response);
|
if(jsonObject.get("code").equals(200)){
|
//派发出库任务给RCS==>成功下发出库任务
|
taskWrk.setWrkSts(2);
|
taskWrkService.updateById(taskWrk);
|
bool = true;
|
}
|
} catch (Exception e) {
|
log.error("wcs派发任务给RCS出库失败{},返回值={}", taskWrk, response);
|
} finally {
|
apiLogService.save("wcs派发任务给RCS出库"
|
, wcsUrl + dz
|
, null
|
, "127.0.0.1"
|
, JSON.toJSONString(headParam)
|
, response
|
, bool
|
);
|
}
|
}
|
}
|
}
|
}
|