This commit is contained in:
李广豪 2022-07-09 22:03:37 +08:00
commit 0c026853ef
8 changed files with 366 additions and 183 deletions

View File

@ -119,6 +119,7 @@ public class CurrTaskController extends BaseController {
if (processSheet.getData().getSuccess())
{
//apms创建成功后写入数据库
param.setAutoTaskType(0);
R<IdVo> mainTask = currTaskService.createProcessTask(param);
currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId());
String sheetNo = processSheet.getData().getSheetNo();
@ -127,7 +128,7 @@ public class CurrTaskController extends BaseController {
currTaskById.setSheetNo(sheetNo);
currTaskService.updateCurrTaskById(currTaskById);
//生成详细任务中的检验结果数据在apms推送生产单结果时创建
return successful("创建成功,任务添加至等待执行队列。");
return successful(0,"创建成功,任务添加至等待执行队列。","");
}
else
{
@ -237,6 +238,7 @@ public class CurrTaskController extends BaseController {
//将返回的生产单号写入到主任务中
CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId());
currTaskById.setSheetNo(sheetNo);
currTaskById.setAutoExeTaskId(autoExeTask.getId());
currTaskService.updateCurrTaskById(currTaskById);
//生成详细任务中的检验结果数据在apms推送生产单结果时创建
//return successful("创建成功,任务添加至等待执行队列。");
@ -248,7 +250,7 @@ public class CurrTaskController extends BaseController {
}
i++;
}
return null;
return successful(0,"操作成功,任务加入待执行队列","");
}
@PostMapping(value = "mainCurrentTaskNow")

View File

@ -78,6 +78,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
AutoExeTaskServiceBiz autoExeTaskServiceBiz;
@Autowired
KilnInfoServiceBiz kilnInfoServiceBiz;
@Autowired
LocationServiceBiz locationServiceBiz;
@Override
public CurrTaskVo getCurrTask(IdParam idParam) {
@ -104,6 +106,9 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
BeanUtils.copyProperties(param, currTask);
currTask.setTaskType(TaskTypeEnum.WTK.getValue());
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId());
if (param.getAutoTaskType()!=0){
currTask.setIsAuto(1);
}
//根据工艺号查询工艺id以及工艺plc值
CraftInfo one = craftInfoServiceBiz.getOne(new QueryWrapper<CraftInfo>().eq(CraftInfo.CRAFT_CODE, param.getCraftCode()));
@ -151,34 +156,76 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
@Override
public R<String> deleteBySheetNo(String sheetNo) {
CurrTask byId = currTaskServiceBiz.getOne(new QueryWrapper<CurrTask>().eq(CurrTask.SHEET_NO, sheetNo));
//如果尚未执行状态 0
if (byId.getStatus() == 0)
{
//一个生产单可能对应多个currTask,删除的时候查询是否对应多个如果对应多个自动循环删除所有currTask,当删除最后一条currTask时上报apms
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.SHEET_NO, sheetNo));
if (currTaskList.size()>1){
int i=0;
for (CurrTask currTask:currTaskList
) {
i++;
if(currTask.getStatus()==0){
if (i==currTaskList.size()){
R<ApmsEndProcessVo> apmsStartProcessR = apmsControl.deleteBySheetNo(sheetNo);
if (!apmsStartProcessR.getData().getSuccess()){
return failed(apmsStartProcessR.getData().getMsg());
}
}
Long currTaskId = currTask.getId();
if (currTask.getIsAuto()==1){
List<CurrTask> currTaskList2 = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId()));
if (currTaskList2.size()==1){
autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId());
}
}
currTaskServiceBiz.removeById(currTaskId);
currTaskDetService.deleteByCurrTaskId(currTaskId);
R<ApmsEndProcessVo> apmsStartProcessR = apmsControl.deleteBySheetNo(sheetNo);
if (apmsStartProcessR.getData().getSuccess())
{
Long currTaskId = byId.getId();
currTaskServiceBiz.removeById(currTaskId);
currTaskDetService.deleteByCurrTaskId(currTaskId);
if (byId.getIsAuto()==1){
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.AUTO_EXE_TASK_ID, byId.getAutoExeTaskId()));
if (currTaskList.size()==0){
autoExeTaskServiceBiz.removeById(byId.getAutoExeTaskId());
}
if (currTask.getStatus()==2){
return failed("无法删除,任务已加工完成。");
}if (currTask.getStatus()==1){
return failed("无法删除,任务正在执行中。");
}
}
return successful(0,"APMS生产单删除成功。","");
}else {
for (CurrTask currTask:currTaskList
) {
if (currTask.getStatus()==0){
R<ApmsEndProcessVo> apmsStartProcessR = apmsControl.deleteBySheetNo(sheetNo);
if (apmsStartProcessR.getData().getSuccess())
{
Long currTaskId = currTask.getId();
if (currTask.getIsAuto()==1){
List<CurrTask> currTaskList2 = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId()));
if (currTaskList2.size()==1){
autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId());
}
}
currTaskServiceBiz.removeById(currTaskId);
currTaskDetService.deleteByCurrTaskId(currTaskId);
if (currTask.getIsAuto()==1){
List<CurrTask> currTaskList2 = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId()));
if (currTaskList2.size()==0){
autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId());
}
}
return successful(0,"APMS生产单删除成功。","");
}
else
{
return failed(apmsStartProcessR.getData().getMsg());
}
}
return successful("APMS生产单删除成功。");
}
else
{
return failed(apmsStartProcessR.getData().getMsg());
if (currTask.getStatus()==2){
return failed("无法删除,任务已加工完成。");
}if (currTask.getStatus()==1){
return failed("无法删除,任务正在执行中。");
}
}
}
if (byId.getStatus()==2){
return failed("无法删除,任务已加工完成。");
}
return failed("无法删除,任务正在执行中。");
return failed("根据生产单号删除任务失败!");
}
@ -211,6 +258,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
}
);
e.setCustomers(customers);
e.setKilnName(e.getTargetPosition());
e.setLocationName(locationServiceBiz.getById(e.getLocationId()).getLocationName());
});
return successful(pageVo);
}

View File

@ -47,7 +47,7 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic
List<CurrTaskDetVo> currTaskDetVoList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList
) {
String costomerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq("order_no", currTaskDetVo.getOrderNo())).getCustomerName();
String costomerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName();
currTaskDetVo.setCustomer(costomerName);
}
return successful(currTaskDetVoList);

View File

@ -86,35 +86,8 @@ public class AsynRunTaskService extends BaseService {
public void asynRunTask(Long currTaskId,Long vehicleId) throws IOException {
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, currTaskId, 2,0);
if (status!=1){
logger.info("===执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}
}else {
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, currTaskId, 12,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}
}
//检查车辆是否冲突冲突则避让
rgvStatus(vehicleId,currTask);
//新建一条执行任务的关系表存放任务执行信息
RunTask runTask=new RunTask();
runTask.setTaskId(currTask.getId());
@ -168,35 +141,8 @@ public class AsynRunTaskService extends BaseService {
Long currTaskId = inStockInfo.getTaskId();
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(),currTask.getTargetPosition(), rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, currTaskId, 2,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}
}else {
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId,location.getCode(),currTask.getTargetPosition(), rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, currTaskId, 12,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}
}
//检查车辆是否冲突冲突则避让
rgvStatus(vehicleId,currTask);
//新建一条执行任务的关系表存放任务执行信息
RunTask runTask=new RunTask();
runTask.setTaskId(currTask.getId());
@ -262,35 +208,8 @@ public class AsynRunTaskService extends BaseService {
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
Location location = locationServiceBiz.getById(currTask.getLocationId());
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, currTaskId, 2,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}
}else {
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, currTaskId, 12,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}
}
//检查车辆是否冲突冲突则避让
rgvStatus(vehicleId,currTask);
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask=new RunTask();
runTask.setTaskId(currTask.getId());
@ -327,7 +246,6 @@ public class AsynRunTaskService extends BaseService {
runTaskServiceBiz.updateById(runTask);
//更新currTask表
currTask.setCacheSatatus(2);
currTask.setStatus(3);
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//更新in_stock_info表
@ -351,37 +269,8 @@ public class AsynRunTaskService extends BaseService {
public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId) throws IOException {
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, currTaskId, 2,currTask.getPlcValue());
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}
}else {
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, currTaskId, 12,currTask.getPlcValue());
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}
}
//检查车辆是否冲突冲突则避让
rgvStatus(vehicleId,currTask);
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask=new RunTask();
runTask.setTaskId(currTask.getId());
@ -495,34 +384,46 @@ public class AsynRunTaskService extends BaseService {
public void asynRunOutStock(Long locationId,String yeyaTaiCode,Long vehicleId) throws IOException {
Location location = locationServiceBiz.getById(locationId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, 1L, 2,0);
if (status!=1){
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
Long anotherVehicleId=2L;
Boolean rgv2Online = rgvOnline(anotherVehicleId);
if (rgv2Online){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, 1L, 2,0);
if (status!=1){
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行成功===");
}else {
logger.info("RGV2不在线跳过检测是否避让。");
}
}else {
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, 1L, 12,0);
if (status!=1){
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
Boolean rgv1Online = rgvOnline(1L);
if (rgv1Online){
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, 1L, 12,0);
if (status!=1){
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行成功===");
}else {
logger.info("RGV1不在线跳过检测是否避让。");
}
}
RunTask runTask=new RunTask();
@ -1097,4 +998,86 @@ public class AsynRunTaskService extends BaseService {
}
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms成功");
}
/**
* 车辆是否在线
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
}
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://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败");
}
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online;
}
/**
* 传入车辆ID,检查另一辆车是否在线如果在线检查是否位置冲突冲突则避让若另一辆车不在线则不检查是否冲突
* @param vehicleId
* @param currTask
* @throws IOException
*/
private void rgvStatus(Long vehicleId,CurrTask currTask) throws IOException {
Long currTaskId = currTask.getId();
if (vehicleId==1){
Long anotherVehicleId=2L;
Boolean rgv2Online = rgvOnline(anotherVehicleId);
if (rgv2Online){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, currTaskId, 2,0);
if (status!=1){
logger.info("===执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位39执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位39执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位39执行成功===");
}
}else {
logger.info("RGV2不在线跳过检测是否避让。");
}
}else {
Long anotherVehicleId=1L;
Boolean rgv1Online = rgvOnline(anotherVehicleId);
if (rgv1Online){
//获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, currTaskId, 12,0);
if (status!=1){
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位1执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位1执行失败");
return;
}
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位1执行成功===");
}
}else {
logger.info("RGV1不在线跳过检测是否避让。");
}
}
}
}

View File

@ -114,6 +114,7 @@ public class RunTaskUtils {
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
if (vehicleId==0){
logger.info("两辆车都不在线,请检查后重试!");
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
@ -407,5 +408,61 @@ public class RunTaskUtils {
}
return false;
}
/**
* 车辆是否在线
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
}
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://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败");
}
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online;
}
/**
* 车辆是否空闲
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvFree(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
}
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://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否空闲失败");
}
Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return free;
}
}

View File

@ -142,6 +142,7 @@ public class ScheduledTask extends BaseService {
.eq(PlcNameSpace.TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)).getName();
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
nowCurrTask.setTaskCode(nowCurrTask.getSheetNo());
nowCurrTask.setKilnCode(kilnInfo.getCode());
//设定时间
Integer setupTime =1;
@ -541,19 +542,35 @@ public class ScheduledTask extends BaseService {
//报警状态为true
if (resultBoolean){
//任务状态为执行中且正在炉子中加工的任务
CurrTask currTask = currTaskServiceBiz.getOne(new QueryWrapper<CurrTask>()
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
.eq(CurrTask.KILN_ID, kilnInfo.getId())
.eq(CurrTask.IS_IN, 1)
.eq(CurrTask.STATUS, 1));
AlarmInfo alarmInfo=new AlarmInfo();
alarmInfo.setEquipmentId(currTask.getKilnId());
alarmInfo.setEquipmentName(currTask.getKilnName());
alarmInfo.setType(0);
alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode());
alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+""+plcNameSpace.getNote());
alarmInfo.setTaskCode(currTask.getTaskCode());
alarmInfo.setCreateTime(LocalDateTime.now());
alarmInfoServiceBiz.save(alarmInfo);
if (currTaskList.size()!=0){
for (CurrTask currTask:currTaskList
) {
AlarmInfo alarmInfo=new AlarmInfo();
alarmInfo.setEquipmentId(currTask.getKilnId());
alarmInfo.setEquipmentName(currTask.getKilnName());
alarmInfo.setType(0);
alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode());
alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+""+plcNameSpace.getNote());
alarmInfo.setTaskCode(currTask.getTaskCode());
alarmInfo.setCreateTime(LocalDateTime.now());
alarmInfoServiceBiz.save(alarmInfo);
}
}
else {
AlarmInfo alarmInfo=new AlarmInfo();
alarmInfo.setEquipmentId(kilnInfo.getId());
alarmInfo.setEquipmentName(kilnInfo.getKilnName());
alarmInfo.setType(0);
alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode());
alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+""+plcNameSpace.getNote());
alarmInfo.setTaskCode("0");
alarmInfo.setCreateTime(LocalDateTime.now());
alarmInfoServiceBiz.save(alarmInfo);
}
}
} catch (IOException e) {
e.printStackTrace();
@ -564,13 +581,22 @@ public class ScheduledTask extends BaseService {
logger.info("==结束查询炉子是否有报警==");
}
//监听车辆是否在线暂时不用
//监听车辆是否在线
@Scheduled(fixedDelay = 1000*60)
public void listenVehicleOnline() throws IOException {
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>()
.eq(VehicleInfo.STATUS, 0));
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS,1));
for (VehicleInfo vehicleInfo:vehicleInfoList
) {
Boolean rgvOnline = rgvOnline(vehicleInfo.getId());
Boolean rgvFree = rgvFree(vehicleInfo.getId());
if (!rgvOnline){
webSocketServer.sendtoUser("当前存在车辆不在线,请移动停用的车辆到轨道尽头处或者改车辆为线上模式,如果已经车辆停用,请忽略本提示消息。","1");
}
if (rgvOnline&&rgvFree){
vehicleInfo.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicleInfo);
logger.info("检测到车辆:"+vehicleInfo.getId()+" 显示状态为占用,实际状态为空闲。自动置车辆状态为空闲。");
}
}
}
/**
@ -645,5 +671,61 @@ public class ScheduledTask extends BaseService {
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
/**
* 车辆是否在线
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
}
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://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败");
}
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online;
}
/**
* 车辆是否空闲
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvFree(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
}
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://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否空闲失败");
}
Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return free;
}
}

View File

@ -78,6 +78,11 @@ public class CurrTaskMainQueryVo extends BaseVo implements PageVo.ConvertVo {
*/
@ApiModelProperty("库位")
private String locationName;
/**
* 库位
*/
@ApiModelProperty("库位id")
private Long locationId;
/**
* 窑炉名称
*/

View File

@ -31,6 +31,11 @@ public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{
*/
@ApiModelProperty(value = "currtask任务code",example = "0")
private String taskCode;
/**
* 生产单号
*/
@ApiModelProperty(value = "生产单号",example = "0")
private String sheetNo;
/**
* 炉子id