package com.zy.asrs.task.newWay.handler;
|
|
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.zy.asrs.entity.WrkMast;
|
import com.zy.asrs.entity.param.RCSParam;
|
import com.zy.asrs.service.*;
|
import com.zy.asrs.task.AbstractHandler;
|
import com.zy.asrs.task.core.ReturnT;
|
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.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
|
@Slf4j
|
@Service
|
@Transactional
|
public class AssignTasksToRCSHandler extends AbstractHandler<String> {
|
@Autowired
|
private WrkMastService wrkMastService;
|
@Autowired
|
private ApiLogService apiLogService;
|
@Value("${rcs.address.url}")
|
private String url;
|
@Value("${rcs.address.attrcs}")
|
private String attrcs;
|
|
public ReturnT<String> start(WrkMast wrkMast) {
|
LocalDateTime now = LocalDateTime.now();
|
String noww="bb" + new Date().getTime();
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
String formattedDate = now.format(formatter); // 格式化日期时间
|
|
LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>();
|
rcsParam.put("task_id",noww);
|
rcsParam.put("start_location","102");
|
rcsParam.put("start_site_level",1);
|
rcsParam.put("start_command",1);
|
rcsParam.put("target_location",wrkMast.getMemo());
|
rcsParam.put("target_site_level",1);
|
rcsParam.put("target_command",2);
|
rcsParam.put("priority",1);
|
rcsParam.put("robot_type",3);//车 辆 类 型 0:XC 1:XCD 2:XP_T 3:XP_L
|
rcsParam.put("MoverID","XS1");
|
|
LinkedHashMap<String,Object> map=new LinkedHashMap<>();
|
map.put("data",rcsParam);
|
String response ="";
|
Boolean bool =false;
|
String msg = "";
|
|
wrkMast.setPauseMk(noww);
|
try {
|
log.info("wms派发搬运任务给AGV搬运={}", rcsParam);
|
response = new HttpHandler.Builder()
|
// .setHeaders(headParam)
|
.setUri(url)
|
.setPath(attrcs)
|
.setJson(JSON.toJSONString(map))
|
.build()
|
.doPost();
|
JSONObject jsonObject = JSON.parseObject(response);
|
JSONObject data = jsonObject.getJSONObject("data");
|
JSONObject errInfo = jsonObject.getJSONObject("err_info");
|
if(data.getInteger("result")==0){
|
if(wrkMast.getIoType()==103||wrkMast.getIoType()==107){
|
wrkMast.setWrkSts(16L);//待回库
|
}else{
|
wrkMast.setWrkSts(15L);//下发RCS-成功
|
}
|
|
wrkMast.setErrorMemo(noww);
|
wrkMastService.updateById(wrkMast);
|
bool = true;
|
}else{
|
msg=errInfo.getString("err_msg");
|
}
|
} catch (Exception e) {
|
log.error("wms派发搬运任务给AGV搬运失败返回值={}", response);
|
} finally {
|
apiLogService.save("wms派发搬运任务给AGV搬运"
|
, url + attrcs
|
, null
|
, "127.0.0.1"
|
, JSON.toJSONString(map)
|
, response
|
, bool
|
);
|
}
|
return SUCCESS;
|
}
|
}
|