自动任务
This commit is contained in:
parent
274fdd6a35
commit
211c017278
@ -6,18 +6,24 @@ import com.mt.wms.core.api.Assert;
|
|||||||
import com.mt.wms.core.base.BaseService;
|
import com.mt.wms.core.base.BaseService;
|
||||||
import com.mt.wms.core.dal.entity.AutoExeTask;
|
import com.mt.wms.core.dal.entity.AutoExeTask;
|
||||||
import com.mt.wms.core.dal.entity.AutoExeTaskHis;
|
import com.mt.wms.core.dal.entity.AutoExeTaskHis;
|
||||||
|
import com.mt.wms.core.dal.entity.CurrTask;
|
||||||
import com.mt.wms.core.dal.service.AutoExeTaskHisServiceBiz;
|
import com.mt.wms.core.dal.service.AutoExeTaskHisServiceBiz;
|
||||||
import com.mt.wms.core.dal.service.AutoExeTaskServiceBiz;
|
import com.mt.wms.core.dal.service.AutoExeTaskServiceBiz;
|
||||||
|
import com.mt.wms.core.dal.service.CurrTaskServiceBiz;
|
||||||
import com.mt.wms.core.errorcode.ApiErrorCode;
|
import com.mt.wms.core.errorcode.ApiErrorCode;
|
||||||
import com.mt.wms.core.params.IdParam;
|
import com.mt.wms.core.params.IdParam;
|
||||||
import com.mt.wms.core.vo.IdVo;
|
import com.mt.wms.core.vo.IdVo;
|
||||||
import com.mt.wms.core.vo.PageVo;
|
import com.mt.wms.core.vo.PageVo;
|
||||||
import com.mt.wms.core.vo.R;
|
import com.mt.wms.core.vo.R;
|
||||||
|
import com.mt.wms.empty.controller.ApmsController;
|
||||||
import com.mt.wms.empty.params.AutoTaskParam;
|
import com.mt.wms.empty.params.AutoTaskParam;
|
||||||
import com.mt.wms.empty.params.AutoTaskQueryParam;
|
import com.mt.wms.empty.params.AutoTaskQueryParam;
|
||||||
import com.mt.wms.empty.service.AutoTaskService;
|
import com.mt.wms.empty.service.AutoTaskService;
|
||||||
|
import com.mt.wms.empty.vo.ApmsEndProcessVo;
|
||||||
import com.mt.wms.empty.vo.AutoTaskVo;
|
import com.mt.wms.empty.vo.AutoTaskVo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -33,10 +39,16 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class AutoTaskServiceImpl extends BaseService implements AutoTaskService {
|
public class AutoTaskServiceImpl extends BaseService implements AutoTaskService {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(AutoTaskServiceImpl.class);
|
||||||
@Resource
|
@Resource
|
||||||
private AutoExeTaskServiceBiz autoExeTaskServiceBiz;
|
private AutoExeTaskServiceBiz autoExeTaskServiceBiz;
|
||||||
@Resource
|
@Resource
|
||||||
private AutoExeTaskHisServiceBiz autoExeTaskHisServiceBiz;
|
private AutoExeTaskHisServiceBiz autoExeTaskHisServiceBiz;
|
||||||
|
@Resource
|
||||||
|
private CurrTaskServiceBiz currTaskServiceBiz;
|
||||||
|
@Resource
|
||||||
|
private ApmsController apmsController;
|
||||||
@Override
|
@Override
|
||||||
public R<AutoTaskVo> get(IdParam idParam) {
|
public R<AutoTaskVo> get(IdParam idParam) {
|
||||||
Assert.notNull(ApiErrorCode.INVALID_PARAMETER,idParam.getId());
|
Assert.notNull(ApiErrorCode.INVALID_PARAMETER,idParam.getId());
|
||||||
@ -55,12 +67,14 @@ public class AutoTaskServiceImpl extends BaseService implements AutoTaskService
|
|||||||
public R<PageVo<AutoTaskVo>> page(AutoTaskQueryParam autoTaskQueryParam) {
|
public R<PageVo<AutoTaskVo>> page(AutoTaskQueryParam autoTaskQueryParam) {
|
||||||
QueryWrapper<AutoExeTask> wrapper=new QueryWrapper<>();
|
QueryWrapper<AutoExeTask> wrapper=new QueryWrapper<>();
|
||||||
wrapper.eq((autoTaskQueryParam.getStatus()!=null&&("").equals(autoTaskQueryParam.getStatus())),AutoExeTask.STATUS,autoTaskQueryParam.getStatus());
|
wrapper.eq((autoTaskQueryParam.getStatus()!=null&&("").equals(autoTaskQueryParam.getStatus())),AutoExeTask.STATUS,autoTaskQueryParam.getStatus());
|
||||||
|
wrapper.in(AutoExeTask.STATUS,0,1);
|
||||||
Page<AutoExeTask> page = autoExeTaskServiceBiz.page(new Page<>(autoTaskQueryParam.getCurrent(), autoTaskQueryParam.getSize()), wrapper);
|
Page<AutoExeTask> page = autoExeTaskServiceBiz.page(new Page<>(autoTaskQueryParam.getCurrent(), autoTaskQueryParam.getSize()), wrapper);
|
||||||
return successful(new PageVo<>(page,AutoTaskVo.class));
|
return successful(new PageVo<>(page,AutoTaskVo.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<IdVo> stop(IdParam idParam) {
|
public R<IdVo> stop(IdParam idParam) {
|
||||||
|
|
||||||
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(idParam.getId());
|
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(idParam.getId());
|
||||||
//状态置为终止
|
//状态置为终止
|
||||||
autoExeTask.setStatus(3);
|
autoExeTask.setStatus(3);
|
||||||
@ -71,7 +85,19 @@ public class AutoTaskServiceImpl extends BaseService implements AutoTaskService
|
|||||||
autoExeTaskHisServiceBiz.save(autoExeTaskHis);
|
autoExeTaskHisServiceBiz.save(autoExeTaskHis);
|
||||||
//释放后续步骤
|
//释放后续步骤
|
||||||
// TODO: 2022/3/3
|
// TODO: 2022/3/3
|
||||||
|
//删除对应的几条currtask(未执行的),通知apms生产单作废
|
||||||
|
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
|
||||||
|
.eq(CurrTask.AUTO_EXE_TASK_ID, autoExeTask.getId()).eq(CurrTask.STATUS,0));
|
||||||
|
for (CurrTask currTask:currTaskList
|
||||||
|
) {
|
||||||
|
R<ApmsEndProcessVo> apmsEndProcessVoR = apmsController.deleteBySheetNo(currTask.getSheetNo());
|
||||||
|
if (!apmsEndProcessVoR.getData().getSuccess()){
|
||||||
|
logger.info("Apms作废生产单接口错误");
|
||||||
|
return R.failed("Apms作废生产单接口错误");
|
||||||
|
}
|
||||||
|
currTaskServiceBiz.removeById(currTask);
|
||||||
|
}
|
||||||
autoExeTaskServiceBiz.removeById(autoExeTask);
|
autoExeTaskServiceBiz.removeById(autoExeTask);
|
||||||
return null;
|
return successful(IdVo.builder().id(idParam.getId()).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
otherNowPoint=1;
|
otherNowPoint=1;
|
||||||
//两辆小车是否冲突
|
//两辆小车是否冲突
|
||||||
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
while (conflictBoolean){
|
if (conflictBoolean){
|
||||||
//若冲突
|
//若冲突
|
||||||
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
Map<String, Integer> json = new HashMap();
|
Map<String, Integer> json = new HashMap();
|
||||||
@ -87,6 +87,8 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error(new Date() + "WCS接口超时未响应!");
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
@ -94,7 +96,7 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
otherNowPoint=2;
|
otherNowPoint=2;
|
||||||
//两辆小车是否冲突
|
//两辆小车是否冲突
|
||||||
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
while (conflictBoolean){
|
if (conflictBoolean){
|
||||||
//若冲突
|
//若冲突
|
||||||
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
Map<String, Integer> json = new HashMap();
|
Map<String, Integer> json = new HashMap();
|
||||||
@ -107,6 +109,8 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error(new Date() + "WCS接口超时未响应!");
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,16 +186,55 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
if (vehicleId==1){
|
if (vehicleId==1){
|
||||||
// TODO: 2022/2/26 获取RGV2当前位置
|
// TODO: 2022/2/26 获取RGV2当前位置
|
||||||
otherNowPoint=1;
|
otherNowPoint=1;
|
||||||
|
//两辆小车是否冲突
|
||||||
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
|
if (conflictBoolean){
|
||||||
|
//若冲突
|
||||||
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
//type=1为 入
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 39);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
//获取RGV1当前位置
|
//获取RGV1当前位置
|
||||||
otherNowPoint=2;
|
otherNowPoint=2;
|
||||||
}
|
|
||||||
//两辆小车是否冲突
|
//两辆小车是否冲突
|
||||||
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), currTask.getTargetPosition(), otherNowPoint);
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
while (conflictBoolean){
|
if (conflictBoolean){
|
||||||
//若冲突
|
//若冲突
|
||||||
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 1);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* //两辆小车是否冲突
|
||||||
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
|
if (conflictBoolean){
|
||||||
|
//若冲突
|
||||||
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
}*/
|
||||||
|
|
||||||
//新建一条执行任务的关系表存放任务执行信息
|
//新建一条执行任务的关系表存放任务执行信息
|
||||||
RunTask runTask=new RunTask();
|
RunTask runTask=new RunTask();
|
||||||
@ -208,9 +251,33 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
inStockInfo.setStatus(1);
|
inStockInfo.setStatus(1);
|
||||||
inStockInfoServiceBiz.updateById(inStockInfo);
|
inStockInfoServiceBiz.updateById(inStockInfo);
|
||||||
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
|
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
|
||||||
|
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
|
||||||
|
Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode();
|
||||||
|
Map<String, Object> json = new HashMap();
|
||||||
|
// taskType 1 搬运
|
||||||
|
json.put("taskType", 1);
|
||||||
|
json.put("sendRow", endPoint);
|
||||||
|
json.put("pickRow",startPoint);
|
||||||
|
json.put("taskNo",currTaskId);
|
||||||
|
json.put("ideNumber",1);
|
||||||
|
json.put("processNumber",currTask.getPlcValue());
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
String result =null;
|
||||||
|
try {
|
||||||
|
if (vehicleId==1){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
if (vehicleId==2){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
int status = Integer.parseInt(String.valueOf(jsonObject.get("msg")));
|
||||||
//执行成功,托盘进炉
|
//执行成功,托盘进炉
|
||||||
if (true){
|
if (status==1){
|
||||||
//更新调度表状态为完成
|
//更新调度表状态为完成
|
||||||
runTask.setUpdateTime(LocalDateTime.now());
|
runTask.setUpdateTime(LocalDateTime.now());
|
||||||
runTask.setEndTime(LocalDateTime.now());
|
runTask.setEndTime(LocalDateTime.now());
|
||||||
@ -246,15 +313,48 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
if (vehicleId==1){
|
if (vehicleId==1){
|
||||||
// TODO: 2022/2/26 获取RGV2当前位置
|
// TODO: 2022/2/26 获取RGV2当前位置
|
||||||
otherNowPoint=1;
|
otherNowPoint=1;
|
||||||
|
//两辆小车是否冲突
|
||||||
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
|
if (conflictBoolean){
|
||||||
|
//若冲突
|
||||||
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
//type=1为 入
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 39);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
//获取RGV1当前位置
|
//获取RGV1当前位置
|
||||||
otherNowPoint=2;
|
otherNowPoint=2;
|
||||||
}
|
|
||||||
//两辆小车是否冲突
|
//两辆小车是否冲突
|
||||||
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
while (conflictBoolean){
|
if (conflictBoolean){
|
||||||
//若冲突
|
//若冲突
|
||||||
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 1);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PointInfo pointOfLocation = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, location.getCode()));
|
PointInfo pointOfLocation = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, location.getCode()));
|
||||||
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
|
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
|
||||||
@ -282,8 +382,32 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
setCommonField(inStockInfo);
|
setCommonField(inStockInfo);
|
||||||
inStockInfoServiceBiz.save(inStockInfo);
|
inStockInfoServiceBiz.save(inStockInfo);
|
||||||
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
|
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
|
||||||
|
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
|
||||||
if (true){
|
Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode();
|
||||||
|
Map<String, Object> json = new HashMap();
|
||||||
|
// taskType 1 搬运
|
||||||
|
json.put("taskType", 1);
|
||||||
|
json.put("sendRow", endPoint);
|
||||||
|
json.put("pickRow",startPoint);
|
||||||
|
json.put("taskNo",currTaskId);
|
||||||
|
json.put("ideNumber",1);
|
||||||
|
json.put("processNumber",currTask.getPlcValue());
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
String result =null;
|
||||||
|
try {
|
||||||
|
if (vehicleId==1){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
if (vehicleId==2){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
int status = Integer.parseInt(String.valueOf(jsonObject.get("msg")));
|
||||||
|
if (status==1){
|
||||||
//更新关系表状态为完成
|
//更新关系表状态为完成
|
||||||
runTask.setUpdateTime(LocalDateTime.now());
|
runTask.setUpdateTime(LocalDateTime.now());
|
||||||
runTask.setStatus(2);
|
runTask.setStatus(2);
|
||||||
@ -317,15 +441,48 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
if (vehicleId==1){
|
if (vehicleId==1){
|
||||||
// TODO: 2022/2/26 获取RGV2当前位置
|
// TODO: 2022/2/26 获取RGV2当前位置
|
||||||
otherNowPoint=1;
|
otherNowPoint=1;
|
||||||
|
//两辆小车是否冲突
|
||||||
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
|
if (conflictBoolean){
|
||||||
|
//若冲突
|
||||||
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
//type=1为 入
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 39);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
//获取RGV1当前位置
|
//获取RGV1当前位置
|
||||||
otherNowPoint=2;
|
otherNowPoint=2;
|
||||||
}
|
|
||||||
//两辆小车是否冲突
|
//两辆小车是否冲突
|
||||||
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint);
|
||||||
while (conflictBoolean){
|
if (conflictBoolean){
|
||||||
//若冲突
|
//若冲突
|
||||||
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
// TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端
|
||||||
|
Map<String, Integer> json = new HashMap();
|
||||||
|
// taskType 4 单移动
|
||||||
|
json.put("taskType", 4);
|
||||||
|
json.put("sendRow", 1);
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
try {
|
||||||
|
HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
//wocket推送到页面
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: 2021/12/28 location排序
|
// TODO: 2021/12/28 location排序
|
||||||
Location location = locationServiceBiz.list(new QueryWrapper<Location>()
|
Location location = locationServiceBiz.list(new QueryWrapper<Location>()
|
||||||
@ -366,7 +523,32 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
setCommonField(inStockInfo);
|
setCommonField(inStockInfo);
|
||||||
inStockInfoServiceBiz.save(inStockInfo);
|
inStockInfoServiceBiz.save(inStockInfo);
|
||||||
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
|
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
|
||||||
if (true){
|
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
|
||||||
|
Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode();
|
||||||
|
Map<String, Object> json = new HashMap();
|
||||||
|
// taskType 1 搬运
|
||||||
|
json.put("taskType", 1);
|
||||||
|
json.put("sendRow", endPoint);
|
||||||
|
json.put("pickRow",startPoint);
|
||||||
|
json.put("taskNo",currTaskId);
|
||||||
|
json.put("ideNumber",1);
|
||||||
|
json.put("processNumber",currTask.getPlcValue());
|
||||||
|
String taskJson = JSON.toJSONString(json);
|
||||||
|
String result =null;
|
||||||
|
try {
|
||||||
|
if (vehicleId==1){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
if (vehicleId==2){
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(new Date() + "WCS接口超时未响应!");
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
int status = Integer.parseInt(String.valueOf(jsonObject.get("msg")));
|
||||||
|
if (status==1){
|
||||||
//更新关系表状态为完成
|
//更新关系表状态为完成
|
||||||
runTask.setUpdateTime(LocalDateTime.now());
|
runTask.setUpdateTime(LocalDateTime.now());
|
||||||
runTask.setStatus(2);
|
runTask.setStatus(2);
|
||||||
@ -394,9 +576,14 @@ public class AsynRunTaskService extends BaseService {
|
|||||||
}
|
}
|
||||||
//出库。起点为缓存区库位,终点为提升台
|
//出库。起点为缓存区库位,终点为提升台
|
||||||
@Async("asyncServiceExecutor")
|
@Async("asyncServiceExecutor")
|
||||||
public void asynRunOutStock(Long runTaskId,Long locationId){
|
public void asynRunOutStock(Long locationId){
|
||||||
//修改调度任务状态
|
RunTask runTask=new RunTask();
|
||||||
RunTask runTask = runTaskServiceBiz.getById(runTaskId);
|
setCommonField(runTask);
|
||||||
|
//runTask.setVehicleId(vehicleId);
|
||||||
|
runTask.setBeginTime(LocalDateTime.now());
|
||||||
|
//runTask.setStartPosition(currTask.getOutStartPosition());
|
||||||
|
//runTask.setEndPosition(currTask.getOutTargetPosition());
|
||||||
|
runTaskServiceBiz.save(runTask);
|
||||||
//修改缓存区状态
|
//修改缓存区状态
|
||||||
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>()
|
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>()
|
||||||
.eq("location_id", locationId));
|
.eq("location_id", locationId));
|
||||||
|
@ -51,6 +51,8 @@ public class RunTaskUtils {
|
|||||||
private AutoExeTaskServiceBiz autoExeTaskServiceBiz;
|
private AutoExeTaskServiceBiz autoExeTaskServiceBiz;
|
||||||
@Resource
|
@Resource
|
||||||
private KilnInfoServiceBiz kilnInfoServiceBiz;
|
private KilnInfoServiceBiz kilnInfoServiceBiz;
|
||||||
|
@Resource
|
||||||
|
private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进炉加工
|
* 进炉加工
|
||||||
@ -58,7 +60,7 @@ public class RunTaskUtils {
|
|||||||
* @return
|
* @return
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public R runTaskForInKiln(Long currTaskId) throws InterruptedException {
|
public R runTaskForInKiln(Long currTaskId) throws InterruptedException{
|
||||||
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
||||||
//起点,起点和终点是液压台code、窑炉code、缓存区code
|
//起点,起点和终点是液压台code、窑炉code、缓存区code
|
||||||
String startPosition = currTask.getStartPosition();
|
String startPosition = currTask.getStartPosition();
|
||||||
@ -90,15 +92,19 @@ public class RunTaskUtils {
|
|||||||
//有小车在运行,提示当前有车辆在运行,请稍后
|
//有小车在运行,提示当前有车辆在运行,请稍后
|
||||||
return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!");
|
return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!");
|
||||||
}
|
}
|
||||||
// TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态
|
// TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态,能放两坨货的窑炉怎么判定状态?
|
||||||
int kilnStatus = 1;
|
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId());
|
||||||
|
String kilnNamePlace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
|
||||||
|
.eq(PlcNameSpace.EQ_TYPE, 0)
|
||||||
|
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId())).getName();
|
||||||
|
String result = readPlcToString(kilnNamePlace, "AllowIn");
|
||||||
|
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
|
||||||
//窑炉状态为不可用
|
//窑炉状态为不可用
|
||||||
if (kilnStatus == 0) {
|
if (kilnInfo.getStatus() == 1) {
|
||||||
return R.failed("目标窑炉不可用!");
|
return R.failed("目标窑炉不可用!");
|
||||||
}
|
}
|
||||||
//窑炉可用未满
|
//窑炉可用未满
|
||||||
if (kilnStatus==1){
|
if (resultBoolean){
|
||||||
//计算出路径最短的车辆id
|
//计算出路径最短的车辆id
|
||||||
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
|
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
|
||||||
//占用车辆
|
//占用车辆
|
||||||
@ -115,7 +121,7 @@ public class RunTaskUtils {
|
|||||||
return R.ok("操作成功,任务已开始执行。");
|
return R.ok("操作成功,任务已开始执行。");
|
||||||
}
|
}
|
||||||
//窑炉已满
|
//窑炉已满
|
||||||
if (kilnStatus==2){
|
if (resultBoolean){
|
||||||
//查询缓存区库位是否已满
|
//查询缓存区库位是否已满
|
||||||
int count = locationServiceBiz.count(new QueryWrapper<Location>()
|
int count = locationServiceBiz.count(new QueryWrapper<Location>()
|
||||||
.eq(Location.STATUS, 0)
|
.eq(Location.STATUS, 0)
|
||||||
@ -249,4 +255,26 @@ public class RunTaskUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取变量值
|
||||||
|
* @param nameSpace nameSpace前缀
|
||||||
|
* @param variableName 变量名称
|
||||||
|
* @return result字符串
|
||||||
|
*/
|
||||||
|
private String readPlcToString(String nameSpace, String variableName){
|
||||||
|
String identifier=nameSpace.concat(variableName);
|
||||||
|
Map<String, Object> json = new HashMap();
|
||||||
|
json.put("nameSpace", 6);
|
||||||
|
json.put("plcName", "plc1");
|
||||||
|
json.put("identifier",identifier);
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.info("readPLC: "+identifier+" 的值失败");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,19 @@ public class TaskDistanceUtils {
|
|||||||
//小车当前位置、起点、终点,找出最大最小值
|
//小车当前位置、起点、终点,找出最大最小值
|
||||||
int min=(((nowPoint<start)?nowPoint:start)<end)?((nowPoint<start)?nowPoint:start):end;
|
int min=(((nowPoint<start)?nowPoint:start)<end)?((nowPoint<start)?nowPoint:start):end;
|
||||||
int max=(((nowPoint>start)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end;
|
int max=(((nowPoint>start)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end;
|
||||||
|
//另一辆小车在在小车路径上比如冲突,不在小车路径上时判定一下安全距离(4米)
|
||||||
if (otherNowPoint>=min&&otherNowPoint<=max){
|
if (otherNowPoint>=min&&otherNowPoint<=max){
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
|
Double maxDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, max)).getDistance();
|
||||||
|
Double minDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, min)).getDistance();
|
||||||
|
Double otherVehicleDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, otherNowPoint)).getDistance();
|
||||||
|
if (Math.abs(otherVehicleDistance-maxDistance)<4){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Math.abs(otherVehicleDistance-minDistance)<4){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,12 @@ public class CurrTaskMainQueryVo extends BaseVo implements PageVo.ConvertVo {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("任务类型")
|
@ApiModelProperty("任务类型")
|
||||||
private Integer taskType;
|
private Integer taskType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自动执行: 0手动,1自动,如果是自动任务这里要监控进出和到缓存区的调度任务
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("是否自动执行:手动,1自动")
|
||||||
|
private Integer is_auto;
|
||||||
/**
|
/**
|
||||||
* 开始位置
|
* 开始位置
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user