Compare commits

...

5 Commits

Author SHA1 Message Date
LGH
59921c28ca update:
上报apms炉号
2022-11-18 10:15:35 +08:00
LGH
5eed777f0a update:
上报apms炉号
2022-11-18 10:12:54 +08:00
LGH
592d27b858 update:
上报apms炉号
2022-11-18 10:09:47 +08:00
LGH
59f008f19e Merge branch 'master' of http://git.picaiba.com/mt-ck/mt-qj-wms-hd 2022-11-18 09:06:34 +08:00
LGH
3ecf06ae6a update:
能源消耗结构修改
2022-11-18 09:05:14 +08:00
6 changed files with 1211 additions and 593 deletions

View File

@ -157,6 +157,7 @@ public class IDGenerator {
int second = (int)(tomorrowDate.getTimeInMillis() - curDate.getTimeInMillis()) / 1000; int second = (int)(tomorrowDate.getTimeInMillis() - curDate.getTimeInMillis()) / 1000;
idGenerator.redisTemplate.opsForValue().set(KEY_PREFIX_SEQUENCE + sequenceName, sequence, second, TimeUnit.SECONDS); idGenerator.redisTemplate.opsForValue().set(KEY_PREFIX_SEQUENCE + sequenceName, sequence, second, TimeUnit.SECONDS);
idGenerator.redisTemplate.opsForValue().getOperations(); idGenerator.redisTemplate.opsForValue().getOperations();
if (sequenceLength > 0) { if (sequenceLength > 0) {
if (sequenceLength > MAX_SEQUENCE_LENGTH) { if (sequenceLength > MAX_SEQUENCE_LENGTH) {
sequenceLength = MAX_SEQUENCE_LENGTH; sequenceLength = MAX_SEQUENCE_LENGTH;

View File

@ -91,7 +91,7 @@ public class AsynRunTaskService extends BaseService {
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask)); List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask));
//检查车辆是否冲突冲突则避让 //检查车辆是否冲突冲突则避让
rgvStatus(vehicleId, currTask,currTask.getStartPosition(),currTask.getTargetPosition()); rgvStatus(vehicleId, currTask, currTask.getStartPosition(), currTask.getTargetPosition());
//新建一条执行任务的关系表存放任务执行信息 //新建一条执行任务的关系表存放任务执行信息
RunTask runTask = new RunTask(); RunTask runTask = new RunTask();
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
@ -105,7 +105,7 @@ public class AsynRunTaskService extends BaseService {
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
PointInfo pointInfo = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getEndPosition())); PointInfo pointInfo = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getEndPosition()));
Long endPoint = pointInfo.getCode(); Long endPoint = pointInfo.getCode();
logger.info("加工炉: "+pointInfo.getName()+"可用未满,调用车辆: "+vehicleId+" 起点为提升台终点为工业炉"); logger.info("加工炉: " + pointInfo.getName() + "可用未满,调用车辆: " + vehicleId + " 起点为提升台终点为工业炉");
Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue());
logger.info(String.valueOf(status)); logger.info(String.valueOf(status));
//执行成功,托盘进炉 //执行成功,托盘进炉
@ -136,7 +136,7 @@ public class AsynRunTaskService extends BaseService {
apmsCreateProcess(currTask); apmsCreateProcess(currTask);
} else { } else {
int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
if (secondSetp>0){ if (secondSetp > 0) {
//当前任务为自动任务里的第二步先上报第一步的apms-endProcess //当前任务为自动任务里的第二步先上报第一步的apms-endProcess
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
CurrTask firstCurrTask = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); CurrTask firstCurrTask = currTaskServiceBiz.getById(autoExeTask.getFTaskId());
@ -148,7 +148,7 @@ public class AsynRunTaskService extends BaseService {
apmsStartProcess(currTask); apmsStartProcess(currTask);
} }
int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
if (threeSetp>0){ if (threeSetp > 0) {
//当前任务为自动任务里的第三步先上报第二步的apms处理endProcess //当前任务为自动任务里的第三步先上报第二步的apms处理endProcess
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId());
@ -171,8 +171,8 @@ public class AsynRunTaskService extends BaseService {
vehicleInfoServiceBiz.updateById(vehicle); vehicleInfoServiceBiz.updateById(vehicle);
logger.info(String.valueOf(status)); logger.info(String.valueOf(status));
logger.info("===执行任务:" + currTaskId + " ,车辆搬运任务,车辆:" + vehicleId + " ,起点:" + startPoint + " ,终点:" + endPoint + "任务执行失败==="); logger.info("===执行任务:" + currTaskId + " ,车辆搬运任务,车辆:" + vehicleId + " ,起点:" + startPoint + " ,终点:" + endPoint + "任务执行失败===");
logger.info("任务 " + currTask.getTaskCode() + " 车辆从起点"+startPoint+"台到加工炉过程中失败。"); logger.info("任务 " + currTask.getTaskCode() + " 车辆从起点" + startPoint + "台到加工炉过程中失败。");
webSocketServer.sendtoAll("任务 " + currTask.getTaskCode() + " 车辆从起点"+startPoint+"台到加工炉过程中失败。"); webSocketServer.sendtoAll("任务 " + currTask.getTaskCode() + " 车辆从起点" + startPoint + "台到加工炉过程中失败。");
} }
} }
@ -185,7 +185,7 @@ public class AsynRunTaskService extends BaseService {
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask)); List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask));
//检查车辆是否冲突冲突则避让 //检查车辆是否冲突冲突则避让
rgvStatus(vehicleId, currTask,location.getCode(),currTask.getTargetPosition()); rgvStatus(vehicleId, currTask, location.getCode(), currTask.getTargetPosition());
//新建一条执行任务的关系表存放任务执行信息 //新建一条执行任务的关系表存放任务执行信息
RunTask runTask = new RunTask(); RunTask runTask = new RunTask();
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
@ -240,7 +240,7 @@ public class AsynRunTaskService extends BaseService {
apmsCreateProcess(currTask); apmsCreateProcess(currTask);
} else { } else {
int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
if (secondSetp>0){ if (secondSetp > 0) {
//从缓存区到加工炉的任务,其上一步已经报告了apmsend //从缓存区到加工炉的任务,其上一步已经报告了apmsend
//当前任务为自动任务里的第二步先上报第一步的apms-endProcess //当前任务为自动任务里的第二步先上报第一步的apms-endProcess
//AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); //AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
@ -252,7 +252,7 @@ public class AsynRunTaskService extends BaseService {
apmsStartProcess(currTask); apmsStartProcess(currTask);
} }
int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
if (threeSetp>0){ if (threeSetp > 0) {
//当前任务为自动任务里的第三步先上报第二步的apms处理endProcess //当前任务为自动任务里的第三步先上报第二步的apms处理endProcess
//AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); //AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
//CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); //CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId());
@ -286,13 +286,13 @@ public class AsynRunTaskService extends BaseService {
//工业炉已满调用车辆起点为提升台终点为缓存区 //工业炉已满调用车辆起点为提升台终点为缓存区
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void asynRunTaskToWarehouse(Long currTaskId, Long vehicleId,Location location) throws IOException { public void asynRunTaskToWarehouse(Long currTaskId, Long vehicleId, Location location) throws IOException {
CurrTask currTask = currTaskServiceBiz.getById(currTaskId); CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
//Location location = locationServiceBiz.getById(currTask.getLocationId()); //Location location = locationServiceBiz.getById(currTask.getLocationId());
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId()); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId());
//检查车辆是否冲突冲突则避让 //检查车辆是否冲突冲突则避让
rgvStatus(vehicleId, currTask,currTask.getStartPosition(),location.getCode()); rgvStatus(vehicleId, currTask, currTask.getStartPosition(), location.getCode());
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask = new RunTask(); RunTask runTask = new RunTask();
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
@ -343,17 +343,17 @@ public class AsynRunTaskService extends BaseService {
vehicle.setStatus(0); vehicle.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicle); vehicleInfoServiceBiz.updateById(vehicle);
//如果任务为多步骤任务的非第一步置前置任务isIn为2 //如果任务为多步骤任务的非第一步置前置任务isIn为2
if (currTask.getIsAuto()==1){ if (currTask.getIsAuto() == 1) {
int count = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTaskId)); int count = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTaskId));
if (count==0){ if (count == 0) {
int secondCount = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); int secondCount = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
if (secondCount==1){ if (secondCount == 1) {
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
CurrTask firstCurrTask = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); CurrTask firstCurrTask = currTaskServiceBiz.getById(autoExeTask.getFTaskId());
firstCurrTask.setIsIn(2); firstCurrTask.setIsIn(2);
firstCurrTask.setStatus(2); firstCurrTask.setStatus(2);
currTaskServiceBiz.updateById(firstCurrTask); currTaskServiceBiz.updateById(firstCurrTask);
}else { } else {
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId());
secondCurrTask.setIsIn(2); secondCurrTask.setIsIn(2);
@ -387,7 +387,7 @@ public class AsynRunTaskService extends BaseService {
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
Location location = locationServiceBiz.getOne(new QueryWrapper<Location>().eq(Location.CODE, currTask.getOutTargetPosition())); Location location = locationServiceBiz.getOne(new QueryWrapper<Location>().eq(Location.CODE, currTask.getOutTargetPosition()));
//检查车辆是否冲突冲突则避让 //检查车辆是否冲突冲突则避让
rgvStatus(vehicleId, currTask,currTask.getStartPosition(),location.getCode()); rgvStatus(vehicleId, currTask, currTask.getStartPosition(), location.getCode());
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask = new RunTask(); RunTask runTask = new RunTask();
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
@ -444,33 +444,33 @@ public class AsynRunTaskService extends BaseService {
vehicle.setStatus(0); vehicle.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicle); vehicleInfoServiceBiz.updateById(vehicle);
//任务为非自动任务上报apms-end-finish //任务为非自动任务上报apms-end-finish
if (currTask.getIsAuto()==0) { if (currTask.getIsAuto() == 0) {
//上报apms完成处理 //上报apms完成处理
logger.info("此任务为单步骤任务任务结束上报apms-end-finish"); logger.info("此任务为单步骤任务任务结束上报apms-end-finish");
apmsEndProcess(currTask); apmsEndProcess(currTask);
apmsFinishProcess(currTask); apmsFinishProcess(currTask);
} else { } else {
int firstSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTaskId)); int firstSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTaskId));
if (firstSetp>0){ if (firstSetp > 0) {
//当前任务为自动任务的第一步 //当前任务为自动任务的第一步
apmsEndProcess(currTask); apmsEndProcess(currTask);
} }
int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); int secondSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
if (secondSetp>0){ if (secondSetp > 0) {
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId)); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.T_TASK_ID, currTaskId));
if (autoExeTask.getProcessFlowType()==1){ if (autoExeTask.getProcessFlowType() == 1) {
logger.info("此任务为为自动任务里的第二步且一共只有两步任务结束上报apms-end-finish"); logger.info("此任务为为自动任务里的第二步且一共只有两步任务结束上报apms-end-finish");
//当前任务为自动任务里的第三步且一共只有两步先上报apms处理endProcess //当前任务为自动任务里的第三步且一共只有两步先上报apms处理endProcess
apmsEndProcess(currTask); apmsEndProcess(currTask);
//再上报apms-finishProcess //再上报apms-finishProcess
apmsFinishProcess(currTask); apmsFinishProcess(currTask);
}else { } else {
//当前任务为三步中的第二步 //当前任务为三步中的第二步
apmsEndProcess(currTask); apmsEndProcess(currTask);
} }
} }
int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId)); int threeSetp = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.TH_TASK_ID, currTaskId));
if (threeSetp>0){ if (threeSetp > 0) {
logger.info("此任务为为自动任务里的第三步任务结束上报apms-end-finish"); logger.info("此任务为为自动任务里的第三步任务结束上报apms-end-finish");
//当前任务为自动任务里的第三步先上报apms处理endProcess //当前任务为自动任务里的第三步先上报apms处理endProcess
apmsEndProcess(currTask); apmsEndProcess(currTask);
@ -491,6 +491,7 @@ public class AsynRunTaskService extends BaseService {
webSocketServer.sendtoAll("任务 " + currTask.getTaskCode() + " 车辆从工业炉到缓存区过程中失败。"); webSocketServer.sendtoAll("任务 " + currTask.getTaskCode() + " 车辆从工业炉到缓存区过程中失败。");
} }
} }
//出库起点为加工炉终点为提升台 //出库起点为加工炉终点为提升台
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void asynRunOutStockForKilnToYYT(Long currTaskId, String yeyaTaiCode, Long vehicleId) throws IOException { public void asynRunOutStockForKilnToYYT(Long currTaskId, String yeyaTaiCode, Long vehicleId) throws IOException {
@ -512,7 +513,7 @@ public class AsynRunTaskService extends BaseService {
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败==="); logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败===");
// 2022/3/6 websocket通知页面 // 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败"); webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败");
}else { } else {
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行成功==="); logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行成功===");
} }
@ -535,7 +536,7 @@ public class AsynRunTaskService extends BaseService {
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行失败==="); logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行失败===");
// 2022/3/6 websocket通知页面 // 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行失败"); webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行失败");
}else { } else {
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行成功==="); logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + 1 + "移动到点位12执行成功===");
} }
} }
@ -589,6 +590,7 @@ public class AsynRunTaskService extends BaseService {
webSocketServer.sendtoAll("出库任务车辆从加工炉到提升平台过程中失败。"); webSocketServer.sendtoAll("出库任务车辆从加工炉到提升平台过程中失败。");
} }
} }
//出库起点为缓存区库位终点为提升台 //出库起点为缓存区库位终点为提升台
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void asynRunOutStock(Long locationId, String yeyaTaiCode, Long vehicleId) throws IOException { public void asynRunOutStock(Long locationId, String yeyaTaiCode, Long vehicleId) throws IOException {
@ -1215,16 +1217,17 @@ public class AsynRunTaskService extends BaseService {
* 多步骤任务除了第一步为清洗炉外,每步都生成炉号 * 多步骤任务除了第一步为清洗炉外,每步都生成炉号
* 单步骤任务都生成炉号 * 单步骤任务都生成炉号
*/ */
private void createStoveCode(CurrTask currTask){ private void createStoveCode(CurrTask currTask) {
if (!(isFirstTask(currTask)&&currTask.getKilnId()==3)) { if (!(isFirstTask(currTask) && currTask.getKilnId() == 3)) {
//String stoveCode = CodeGeneratorHelper.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue().toString()); //String stoveCode = CodeGeneratorHelper.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue().toString());
String stoveCode =StoveCodeUtils.getStoveCode(currTask.getTargetPosition(),currTask.getPlcValue()); String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue());
currTask.setStoveCode(stoveCode); currTask.setStoveCode(stoveCode);
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
}else { } else {
logger.info(currTask.getId()+"任务为多步骤任务且第一步为清洗,不生成洗炉炉号."); logger.info(currTask.getId() + "任务为多步骤任务且第一步为清洗,不生成洗炉炉号.");
} }
} }
/** /**
* 上报apms创建生产单并开始处理 * 上报apms创建生产单并开始处理
* *
@ -1250,7 +1253,10 @@ public class AsynRunTaskService extends BaseService {
createItem.setWeight(e.getWeight().doubleValue()); createItem.setWeight(e.getWeight().doubleValue());
createItems.add(createItem); createItems.add(createItem);
}); });
apmsCreateSheet.setStoveCode(code); //apmsCreateSheet.setStoveCode(code);
if (currTask.getStoveCode() != null) {
apmsCreateSheet.setStoveCode(currTask.getStoveCode());
}
apmsCreateSheet.setItems(createItems); apmsCreateSheet.setItems(createItems);
logger.info(currTask.getId() + "开始创建apms生产单号"); logger.info(currTask.getId() + "开始创建apms生产单号");
R<ApmsCreateProcessSheetVo> processSheet = apmsController.createProcessSheet(apmsCreateSheet); R<ApmsCreateProcessSheetVo> processSheet = apmsController.createProcessSheet(apmsCreateSheet);
@ -1263,13 +1269,13 @@ public class AsynRunTaskService extends BaseService {
currTask.setSheetNo(processSheet.getData().getSheetNo()); currTask.setSheetNo(processSheet.getData().getSheetNo());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
//多步骤任务除了第一步写入sheetNo //多步骤任务除了第一步写入sheetNo
if (currTask.getIsAuto()==1){ if (currTask.getIsAuto() == 1) {
AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId());
CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId());
secondCurrTask.setSheetNo(currTask.getSheetNo()); secondCurrTask.setSheetNo(currTask.getSheetNo());
currTaskServiceBiz.updateById(secondCurrTask); currTaskServiceBiz.updateById(secondCurrTask);
//三步任务 //三步任务
if (autoExeTask.getProcessFlowType()==2){ if (autoExeTask.getProcessFlowType() == 2) {
CurrTask threeCurrTask = currTaskServiceBiz.getById(autoExeTask.getThTaskId()); CurrTask threeCurrTask = currTaskServiceBiz.getById(autoExeTask.getThTaskId());
threeCurrTask.setSheetNo(currTask.getSheetNo()); threeCurrTask.setSheetNo(currTask.getSheetNo());
currTaskServiceBiz.updateById(threeCurrTask); currTaskServiceBiz.updateById(threeCurrTask);
@ -1281,17 +1287,21 @@ public class AsynRunTaskService extends BaseService {
/** /**
* 上报apms开始加工 * 上报apms开始加工
*
* @param currTask * @param currTask
* @return * @return
*/ */
private Boolean apmsStartProcess(CurrTask currTask) { private Boolean apmsStartProcess(CurrTask currTask) {
String code = kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode(); String code = kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode();
ApmsStartProcess apmsStartProcess=new ApmsStartProcess(); ApmsStartProcess apmsStartProcess = new ApmsStartProcess();
apmsStartProcess.setStartUser("QJJP03"); apmsStartProcess.setStartUser("QJJP03");
apmsStartProcess.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); apmsStartProcess.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsStartProcess.setTechName(currTask.getCraftCodeId().toString()); apmsStartProcess.setTechName(currTask.getCraftCodeId().toString());
apmsStartProcess.setSheetNo(currTask.getSheetNo()); apmsStartProcess.setSheetNo(currTask.getSheetNo());
apmsStartProcess.setStoveCode(code); if (currTask.getStoveCode() != null) {
apmsStartProcess.setStoveCode(currTask.getStoveCode());
}
R<ApmsStartProcess> apmsStartProcessR = apmsController.startProcess(apmsStartProcess); R<ApmsStartProcess> apmsStartProcessR = apmsController.startProcess(apmsStartProcess);
if (apmsStartProcessR.getCode() != 0) { if (apmsStartProcessR.getCode() != 0) {
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败"); logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败");
@ -1303,10 +1313,11 @@ public class AsynRunTaskService extends BaseService {
/** /**
* 上报apms-end * 上报apms-end
*
* @param currTask * @param currTask
* @return * @return
*/ */
private Boolean apmsEndProcess(CurrTask currTask){ private Boolean apmsEndProcess(CurrTask currTask) {
ApmsEndProcess apmsEndProcess = new ApmsEndProcess(); ApmsEndProcess apmsEndProcess = new ApmsEndProcess();
apmsEndProcess.setEndTime(currTask.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); apmsEndProcess.setEndTime(currTask.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsEndProcess.setEndUser("QJJP03"); apmsEndProcess.setEndUser("QJJP03");
@ -1322,10 +1333,11 @@ public class AsynRunTaskService extends BaseService {
/** /**
* 上报apms-finish * 上报apms-finish
*
* @param currTask * @param currTask
* @return * @return
*/ */
private Boolean apmsFinishProcess(CurrTask currTask){ private Boolean apmsFinishProcess(CurrTask currTask) {
logger.info("任务:" + currTask.getTaskCode() + "开始上报apms完成生产单"); logger.info("任务:" + currTask.getTaskCode() + "开始上报apms完成生产单");
ApmsFinishProcessSheet apmsFinishProcessSheet = new ApmsFinishProcessSheet(); ApmsFinishProcessSheet apmsFinishProcessSheet = new ApmsFinishProcessSheet();
apmsFinishProcessSheet.setSheetNo(currTask.getSheetNo()); apmsFinishProcessSheet.setSheetNo(currTask.getSheetNo());
@ -1350,30 +1362,32 @@ public class AsynRunTaskService extends BaseService {
} }
return true; return true;
} }
/** /**
* 车辆是否在线 * 车辆是否在线
*
* @param vehicleId 车辆id * @param vehicleId 车辆id
* @return true/false * @return true/false
* @throws IOException plc访问失败 * @throws IOException plc访问失败
*/ */
private Boolean rgvOnline(Long vehicleId) throws IOException { private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null; String identifier = null;
if (vehicleId==1){ if (vehicleId == 1) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
} }
if (vehicleId==2){ if (vehicleId == 2) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
} }
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",identifier); json.put("identifier", identifier);
String result = null; String result = null;
try { try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败"); logger.info("获取车辆" + vehicleId + "当前是否在线失败");
} }
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online; return online;
@ -1381,55 +1395,56 @@ public class AsynRunTaskService extends BaseService {
/** /**
* 传入车辆ID,检查另一辆车是否在线如果在线检查是否位置冲突冲突则避让若另一辆车不在线则不检查是否冲突 * 传入车辆ID,检查另一辆车是否在线如果在线检查是否位置冲突冲突则避让若另一辆车不在线则不检查是否冲突
*
* @param vehicleId * @param vehicleId
* @param currTask * @param currTask
* @throws IOException * @throws IOException
*/ */
private void rgvStatus(Long vehicleId,CurrTask currTask,String startPosition,String targetPosition) throws IOException { private void rgvStatus(Long vehicleId, CurrTask currTask, String startPosition, String targetPosition) throws IOException {
Long currTaskId = currTask.getId(); Long currTaskId = currTask.getId();
if (vehicleId==1){ if (vehicleId == 1) {
Long anotherVehicleId=2L; Long anotherVehicleId = 2L;
Boolean rgv2Online = rgvOnline(anotherVehicleId); Boolean rgv2Online = rgvOnline(anotherVehicleId);
if (rgv2Online){ if (rgv2Online) {
//获取RGV2当前位置 //获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2); Double rgv2CurrPosition = RGVCurrPosition(2);
//两辆小车是否冲突 //两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv2CurrPosition); Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv2CurrPosition);
if (conflictBoolean){ if (conflictBoolean) {
Integer status = moveRgv(2, currTaskId, 2,0); Integer status = moveRgv(2, currTaskId, 2, 0);
logger.info(status.toString()); logger.info(status.toString());
if (status!=1){ if (status != 1) {
logger.info("===执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位2执行失败==="); logger.info("===执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位2执行失败"); webSocketServer.sendtoAll(LocalDateTime.now() + "执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败");
}else { } else {
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位2执行成功==="); logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行成功===");
} }
} }
}else { } else {
logger.info("RGV2不在线跳过检测是否避让。"); logger.info("RGV2不在线跳过检测是否避让。");
} }
}else { } else {
Long anotherVehicleId=1L; Long anotherVehicleId = 1L;
Boolean rgv1Online = rgvOnline(anotherVehicleId); Boolean rgv1Online = rgvOnline(anotherVehicleId);
if (rgv1Online){ if (rgv1Online) {
//获取RGV1当前位置 //获取RGV1当前位置
Double rgv1CurrPosition = RGVCurrPosition(1); Double rgv1CurrPosition = RGVCurrPosition(1);
//两辆小车是否冲突 //两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv1CurrPosition); Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv1CurrPosition);
if (conflictBoolean){ if (conflictBoolean) {
Integer status = moveRgv(1, currTaskId, 12,0); Integer status = moveRgv(1, currTaskId, 12, 0);
logger.info(status.toString()); logger.info(status.toString());
if (status!=1){ if (status != 1) {
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位12执行失败==="); logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位12执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位12执行失败"); webSocketServer.sendtoAll(LocalDateTime.now() + "执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位12执行失败");
}else { } else {
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+anotherVehicleId+"移动到点位12执行成功==="); logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位12执行成功===");
} }
} }
}else { } else {
logger.info("RGV1不在线跳过检测是否避让。"); logger.info("RGV1不在线跳过检测是否避让。");
} }
} }
@ -1437,14 +1452,15 @@ public class AsynRunTaskService extends BaseService {
/** /**
* 判断任务是否为单步骤任务多步骤任务第一步 * 判断任务是否为单步骤任务多步骤任务第一步
*
* @param currTask 任务 * @param currTask 任务
* @return 单步骤任务true多步骤任务第一步true,其他false * @return 单步骤任务true多步骤任务第一步true,其他false
*/ */
public Boolean isFirstTask(CurrTask currTask){ public Boolean isFirstTask(CurrTask currTask) {
if (currTask.getIsAuto()==1){ if (currTask.getIsAuto() == 1) {
int count = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTask.getId())); int count = autoExeTaskServiceBiz.count(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, currTask.getId()));
return count>0; return count > 0;
}else { } else {
return true; return true;
} }
} }

View File

@ -88,20 +88,21 @@ public class ScheduledTask extends BaseService {
public void test() throws IOException { public void test() throws IOException {
} }
//@Scheduled(fixedDelay = 1000*60) //@Scheduled(fixedDelay = 1000*60)
public void testWebsocket() throws IOException { public void testWebsocket() throws IOException {
//查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情 //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.IS_IN, 1)); List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.IS_IN, 1));
if (currTaskList.size()==0){ if (currTaskList.size() == 0) {
return; return;
} }
List<NowCurrTaskDetVo> nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); List<NowCurrTaskDetVo> nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class);
for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList for (NowCurrTaskDetVo nowCurrTask : nowCurrTaskDetVoList
) { ) {
Long kilnId = nowCurrTask.getKilnId(); Long kilnId = nowCurrTask.getKilnId();
Boolean kilnWorking = true; Boolean kilnWorking = true;
//查询对应炉号是否Working //查询对应炉号是否Working
if (kilnWorking){ if (kilnWorking) {
String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.TYPE, 0) .eq(PlcNameSpace.TYPE, 0)
@ -113,13 +114,13 @@ public class ScheduledTask extends BaseService {
Integer remainingTime = 122; Integer remainingTime = 122;
nowCurrTask.setSetupTime(setupTime); nowCurrTask.setSetupTime(setupTime);
nowCurrTask.setRemainingTime(remainingTime); nowCurrTask.setRemainingTime(remainingTime);
int completeness =(int) (((float)remainingTime/(float)setupTime )*100); int completeness = (int) (((float) remainingTime / (float) setupTime) * 100);
nowCurrTask.setCompleteness(completeness); nowCurrTask.setCompleteness(completeness);
nowCurrTask.setKilnCode("BMA1"); nowCurrTask.setKilnCode("BMA1");
//标识卡详情 //标识卡详情
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId()));
List<CurrTaskDetVo> currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); List<CurrTaskDetVo> currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList for (CurrTaskDetVo currTaskDetVo : currTaskDetVoList
) { ) {
String customerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName(); String customerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName();
currTaskDetVo.setCustomer(customerName); currTaskDetVo.setCustomer(customerName);
@ -128,28 +129,28 @@ public class ScheduledTask extends BaseService {
} }
} }
System.out.println(JSON.toJSONString(nowCurrTaskDetVoList)); System.out.println(JSON.toJSONString(nowCurrTaskDetVoList));
webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2"); webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList), "2");
} }
/** /**
* 正在加工的加工任务详情 * 正在加工的加工任务详情
*/ */
@Scheduled(fixedDelay = 1000*60) @Scheduled(fixedDelay = 1000 * 60)
public void screen() throws IOException { public void screen() throws IOException {
//查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情 //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>() List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
.eq(CurrTask.IS_IN, 1) .eq(CurrTask.IS_IN, 1)
.eq(CurrTask.STATUS,1)); .eq(CurrTask.STATUS, 1));
if (currTaskList.size()==0){ if (currTaskList.size() == 0) {
return; return;
} }
List<NowCurrTaskDetVo> nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); List<NowCurrTaskDetVo> nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class);
for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList for (NowCurrTaskDetVo nowCurrTask : nowCurrTaskDetVoList
) { ) {
Long kilnId = nowCurrTask.getKilnId(); Long kilnId = nowCurrTask.getKilnId();
Boolean kilnWorking = kilnWorking(kilnId); Boolean kilnWorking = kilnWorking(kilnId);
//查询对应炉号是否Working //查询对应炉号是否Working
if (kilnWorking){ if (kilnWorking) {
String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.TYPE, 0) .eq(PlcNameSpace.TYPE, 0)
@ -158,35 +159,35 @@ public class ScheduledTask extends BaseService {
nowCurrTask.setTaskCode(nowCurrTask.getSheetNo()); nowCurrTask.setTaskCode(nowCurrTask.getSheetNo());
nowCurrTask.setKilnCode(kilnInfo.getCode()); nowCurrTask.setKilnCode(kilnInfo.getCode());
//设定时间 //设定时间
Integer setupTime =1; Integer setupTime = 1;
//剩余时间 //剩余时间
Integer remainingTime=0; Integer remainingTime = 0;
if (kilnInfo.getType()!=4){ if (kilnInfo.getType() != 4) {
if (kilnInfo.getType()==3){ if (kilnInfo.getType() == 3) {
remainingTime = readPlc(nameSpace, "ProgramTimeRemaining").intValue(); remainingTime = readPlc(nameSpace, "ProgramTimeRemaining").intValue();
}else { } else {
remainingTime = readPlc(nameSpace, "ProgramTimeRemain").intValue(); remainingTime = readPlc(nameSpace, "ProgramTimeRemain").intValue();
} }
} }
if(kilnInfo.getType()==1||kilnInfo.getType()==3){ if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) {
//运行时间 //运行时间
Integer runTime = readPlc(nameSpace, "ProgramRunTime").intValue(); Integer runTime = readPlc(nameSpace, "ProgramRunTime").intValue();
setupTime=runTime+remainingTime; setupTime = runTime + remainingTime;
} }
if (kilnInfo.getType()==2){ if (kilnInfo.getType() == 2) {
setupTime=readPlc(nameSpace, "SetTime").intValue(); setupTime = readPlc(nameSpace, "SetTime").intValue();
} }
nowCurrTask.setSetupTime(setupTime); nowCurrTask.setSetupTime(setupTime);
nowCurrTask.setRemainingTime(remainingTime); nowCurrTask.setRemainingTime(remainingTime);
int completeness =(int) (((float)remainingTime/(float)setupTime )*100); int completeness = (int) (((float) remainingTime / (float) setupTime) * 100);
nowCurrTask.setCompleteness(completeness); nowCurrTask.setCompleteness(completeness);
nowCurrTask.setKilnCode(kilnInfo.getCode()); nowCurrTask.setKilnCode(kilnInfo.getCode());
//标识卡详情 //标识卡详情
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>() List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>()
.eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); .eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId()));
List<CurrTaskDetVo> currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); List<CurrTaskDetVo> currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList for (CurrTaskDetVo currTaskDetVo : currTaskDetVoList
) { ) {
String customerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName(); String customerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName();
currTaskDetVo.setCustomer(customerName); currTaskDetVo.setCustomer(customerName);
@ -194,43 +195,44 @@ public class ScheduledTask extends BaseService {
nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList);
} }
} }
webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2"); webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList), "2");
} }
/** /**
* 查询加工完成的工业炉 * 查询加工完成的工业炉
*/ */
@Scheduled(fixedDelay = 1000*30) @Scheduled(fixedDelay = 1000 * 30)
public void taskForStockToKiln() throws IOException { public void taskForStockToKiln() 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, 0));
if (vehicleInfoList.size()==2){ if (vehicleInfoList.size() == 2) {
//遍历currTask为进行中且is_in为正在加工的工业炉状态若加工完毕调用runTaskForOutKiln //遍历currTask为进行中且is_in为正在加工的工业炉状态若加工完毕调用runTaskForOutKiln
// 2022/3/6 有两托的判定哪一托好了(通过开始加工时间顺序排列) // 2022/3/6 有两托的判定哪一托好了(通过开始加工时间顺序排列)
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>() List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
.eq(CurrTask.STATUS, 1) .eq(CurrTask.STATUS, 1)
.eq(CurrTask.IS_IN, 1) .eq(CurrTask.IS_IN, 1)
.orderByAsc(CurrTask.BEGIN_TIME)); .orderByAsc(CurrTask.BEGIN_TIME));
for (CurrTask currTask :currTaskList for (CurrTask currTask : currTaskList
) { ) {
Long kilnId = currTask.getKilnId(); Long kilnId = currTask.getKilnId();
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
PlcNameSpace plcNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace plcNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.TYPE, 0) .eq(PlcNameSpace.TYPE, 0)
.eq(PlcNameSpace.EQ_ID,kilnId)); .eq(PlcNameSpace.EQ_ID, kilnId));
//通过允许出炉信号来判定是否加工完成 //通过允许出炉信号来判定是否加工完成
String result = readPlcToString(plcNameSpace.getName(), "AllowOut"); String result = readPlcToString(plcNameSpace.getName(), "AllowOut");
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (resultBoolean){ if (resultBoolean) {
//调用RunTaskUtils.runTaskForOutKiln //调用RunTaskUtils.runTaskForOutKiln
logger.info(kilnInfo.getCode()+kilnInfo.getKilnAlias()+"识别到允许出炉信号,进入出库程序!"); logger.info(kilnInfo.getCode() + kilnInfo.getKilnAlias() + "识别到允许出炉信号,进入出库程序!");
//更新加工单工艺结束时间,只更新一次因为可能因为不满住出炉条件而进入到下一次定时任务 //更新加工单工艺结束时间,只更新一次因为可能因为不满住出炉条件而进入到下一次定时任务
if ("null".equals(String.valueOf(currTask.getEndTime()))){ if ("null".equals(String.valueOf(currTask.getEndTime()))) {
currTask.setEndTime(LocalDateTime.now()); currTask.setEndTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
//存入历史任务表以便查询能源消耗 //存入历史任务表以便查询能源消耗
TaskHis taskHis=new TaskHis(); TaskHis taskHis = new TaskHis();
org.springframework.beans.BeanUtils.copyProperties(currTask,taskHis); org.springframework.beans.BeanUtils.copyProperties(currTask, taskHis);
taskHis.setStatus(2); taskHis.setStatus(2);
taskHis.setIsIn(2); taskHis.setIsIn(2);
taskHis.setTaskId(currTask.getId()); taskHis.setTaskId(currTask.getId());
@ -239,8 +241,8 @@ public class ScheduledTask extends BaseService {
List<TaskDetHis> taskDetHisList = BeanUtils.copyList(currTaskDets, TaskDetHis.class); List<TaskDetHis> taskDetHisList = BeanUtils.copyList(currTaskDets, TaskDetHis.class);
taskDetHisServiceBiz.saveBatch(taskDetHisList); taskDetHisServiceBiz.saveBatch(taskDetHisList);
//加工结束而没有立马出炉加工结束记录能源消耗值只记录一次 //加工结束而没有立马出炉加工结束记录能源消耗值只记录一次
asynRunTaskService.asynEndRecordConsume(currTask.getId(),kilnId); asynRunTaskService.asynEndRecordConsume(currTask.getId(), kilnId);
logger.info(kilnInfo.getCode()+"炉子中的任务:"+currTask.getId()+"已加工结束,记录加工结束能源消耗值"); logger.info(kilnInfo.getCode() + "炉子中的任务:" + currTask.getId() + "已加工结束,记录加工结束能源消耗值");
} }
runTaskUtils.runTaskForOutKiln(kilnId); runTaskUtils.runTaskForOutKiln(kilnId);
break; break;
@ -250,58 +252,58 @@ public class ScheduledTask extends BaseService {
} }
//查询出正在加工的工业炉遍历根据采集频率的不同采集高频数据能源消耗暂定30秒 //查询出正在加工的工业炉遍历根据采集频率的不同采集高频数据能源消耗暂定30秒
@Scheduled(fixedDelay = 1000*30) @Scheduled(fixedDelay = 1000 * 30)
public void getFastValue(){ public void getFastValue() {
//加工炉列表 //加工炉列表
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>().in(KilnInfo.TYPE,1,3)); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>().in(KilnInfo.TYPE, 1, 3));
for (KilnInfo kilnInfo:kilnInfoList for (KilnInfo kilnInfo : kilnInfoList
) { ) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())
.eq(PlcNameSpace.TYPE,0)); .eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName(); String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working"); String result = readPlcToString(nameSpaceNote, "Working");
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
//该炉子在工作中 //该炉子在工作中
if (resultBoolean){ if (resultBoolean) {
Long kilnId = kilnInfo.getId(); Long kilnId = kilnInfo.getId();
Long currTaskId =0L; Long currTaskId = 0L;
//多用炉因为存在多个识别号且炉子给的DischargeIdentNumber为下油槽后的识别号,所以使用表里记录的任务id根据状态和进炉时间查出正在炉里且先进去的那个 //多用炉因为存在多个识别号且炉子给的DischargeIdentNumber为下油槽后的识别号,所以使用表里记录的任务id根据状态和进炉时间查出正在炉里且先进去的那个
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.STATUS, 1) List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.STATUS, 1)
.eq(CurrTask.KILN_ID, kilnId).eq(CurrTask.IS_IN, 1)); .eq(CurrTask.KILN_ID, kilnId).eq(CurrTask.IS_IN, 1));
if (currTaskList.size()!=0){ if (currTaskList.size() != 0) {
currTaskId=currTaskList.get(0).getId(); currTaskId = currTaskList.get(0).getId();
} }
}else { } else {
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
currTaskId=Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
} }
if (currTaskId==0){ if (currTaskId == 0) {
continue; continue;
} }
CurrTask currTask = currTaskServiceBiz.getById(currTaskId); CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
//任务为null说明是已删除的任务不记录 //任务为null说明是已删除的任务不记录
if (currTask==null){ if (currTask == null) {
continue; continue;
} }
//任务结束时间不为null说明是已结束的任务不记录 //任务结束时间不为null说明是已结束的任务不记录
if (currTask.getEndTime()!=null){ if (currTask.getEndTime() != null) {
continue; continue;
} }
//任务不在加工状态不记录 //任务不在加工状态不记录
if (currTask.getIsIn()!=1){ if (currTask.getIsIn() != 1) {
continue; continue;
} }
//加工炉 //加工炉
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
//一号油搅拌转速 //一号油搅拌转速
Double oilStirringSpeed1 = readPlc(nameSpaceNote, "OilStirringSpeed1"); Double oilStirringSpeed1 = readPlc(nameSpaceNote, "OilStirringSpeed1");
//二号油搅拌转速 //二号油搅拌转速
Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2"); Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2");
ParRotSpeedValue parRotSpeedValue=new ParRotSpeedValue(); ParRotSpeedValue parRotSpeedValue = new ParRotSpeedValue();
parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue()); parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue());
parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue()); parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue());
parRotSpeedValue.setKilnId(kilnId); parRotSpeedValue.setKilnId(kilnId);
@ -320,7 +322,7 @@ public class ScheduledTask extends BaseService {
Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon");
//设定碳势 //设定碳势
Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon");
ParGasValue parGasValue=new ParGasValue(); ParGasValue parGasValue = new ParGasValue();
parGasValue.setNitFlowValue(nitrogenFlow.floatValue()); parGasValue.setNitFlowValue(nitrogenFlow.floatValue());
parGasValue.setAmmoniaFlowValue(ammoniaFlow.floatValue()); parGasValue.setAmmoniaFlowValue(ammoniaFlow.floatValue());
parGasValue.setMethanolFlow(methanolFlow.floatValue()); parGasValue.setMethanolFlow(methanolFlow.floatValue());
@ -333,7 +335,7 @@ public class ScheduledTask extends BaseService {
parGasValueServiceBiz.save(parGasValue); parGasValueServiceBiz.save(parGasValue);
} }
//氮化炉 //氮化炉
if (kilnInfo.getType()==3){ if (kilnInfo.getType() == 3) {
//实际氮势 //实际氮势
Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon");
//设定氮势 //设定氮势
@ -343,12 +345,12 @@ public class ScheduledTask extends BaseService {
//分解率 //分解率
Double decompositionRate = readPlc(nameSpaceNote, "DecompositionRate"); Double decompositionRate = readPlc(nameSpaceNote, "DecompositionRate");
//氨气量 //氨气量
Double ammoniaFlow=readPlc(nameSpaceNote,"AmmoniaFlow"); Double ammoniaFlow = readPlc(nameSpaceNote, "AmmoniaFlow");
//氮气量 //氮气量
Double nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow"); Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow");
//二氧化碳量 //二氧化碳量
Double carbonDioxideFlow = readPlc(nameSpaceNote, "CO2Flow"); Double carbonDioxideFlow = readPlc(nameSpaceNote, "CO2Flow");
ParGasValue parGasValue3=new ParGasValue(); ParGasValue parGasValue3 = new ParGasValue();
parGasValue3.setNitFlowValue(nitrogenFlow.floatValue()); parGasValue3.setNitFlowValue(nitrogenFlow.floatValue());
parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue()); parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue());
parGasValue3.setActualNitPotValue(actualCarbon.floatValue()); parGasValue3.setActualNitPotValue(actualCarbon.floatValue());
@ -366,63 +368,63 @@ public class ScheduledTask extends BaseService {
} }
//查询出正在加工的工业炉遍历根据采集频率的不同采集低频数据能源消耗暂定3分钟一次 //查询出正在加工的工业炉遍历根据采集频率的不同采集低频数据能源消耗暂定3分钟一次
@Scheduled(fixedDelay = 1000*60*3) @Scheduled(fixedDelay = 1000 * 60 * 3)
public void getSlowValue(){ public void getSlowValue() {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList for (KilnInfo kilnInfo : kilnInfoList
) { ) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())
.eq(PlcNameSpace.TYPE,0)); .eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName(); String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working"); String result = readPlcToString(nameSpaceNote, "Working");
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (resultBoolean){ if (resultBoolean) {
Long kilnId = kilnInfo.getId(); Long kilnId = kilnInfo.getId();
Long currTaskId =0L; Long currTaskId = 0L;
//多用炉因为存在多个识别号且炉子给的DischargeIdentNumber为下油槽后的识别号,所以使用表里记录的任务id根据状态和进炉时间查出正在炉里且先进去的那个 //多用炉因为存在多个识别号且炉子给的DischargeIdentNumber为下油槽后的识别号,所以使用表里记录的任务id根据状态和进炉时间查出正在炉里且先进去的那个
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.STATUS, 1) List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>().eq(CurrTask.STATUS, 1)
.eq(CurrTask.KILN_ID, kilnId).eq(CurrTask.IS_IN, 1)); .eq(CurrTask.KILN_ID, kilnId).eq(CurrTask.IS_IN, 1));
if (currTaskList.size()!=0){ if (currTaskList.size() != 0) {
currTaskId=currTaskList.get(0).getId(); currTaskId = currTaskList.get(0).getId();
} }
}else { } else {
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
currTaskId=Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
} }
/* Long kilnId = kilnInfo.getId(); /* Long kilnId = kilnInfo.getId();
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());*/ Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());*/
//任务id为0说明不是自动任务不记录 //任务id为0说明不是自动任务不记录
if (currTaskId==0){ if (currTaskId == 0) {
continue; continue;
} }
CurrTask currTask = currTaskServiceBiz.getById(currTaskId); CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
//任务为null说明是已删除的任务不记录 //任务为null说明是已删除的任务不记录
if (currTask==null){ if (currTask == null) {
continue; continue;
} }
//任务结束时间不为null说明是已结束的任务不记录 //任务结束时间不为null说明是已结束的任务不记录
if (currTask.getEndTime()!=null){ if (currTask.getEndTime() != null) {
continue; continue;
} }
//任务不在加工状态不记录 //任务不在加工状态不记录
if (currTask.getIsIn()!=1){ if (currTask.getIsIn() != 1) {
continue; continue;
} }
//加工炉 //加工炉
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
//实际温度 //实际温度
Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); Double actualTemp = readPlc(nameSpaceNote, "ActualTemp");
//设定温度 //设定温度
Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); Double setUpTemp = readPlc(nameSpaceNote, "SetUpTemp");
//油槽实际温度 //油槽实际温度
Double actualOilTemp = readPlc(nameSpaceNote, "ActualOilTemp"); Double actualOilTemp = readPlc(nameSpaceNote, "ActualOilTemp");
//油槽设定温度 //油槽设定温度
Double setUpOilTemp = readPlc(nameSpaceNote,"SetUpOilTemp"); Double setUpOilTemp = readPlc(nameSpaceNote, "SetUpOilTemp");
ParTemValue parTemValue=new ParTemValue(); ParTemValue parTemValue = new ParTemValue();
parTemValue.setSetTemValue(setUpTemp.floatValue()); parTemValue.setSetTemValue(setUpTemp.floatValue());
parTemValue.setActTemValue(actualTemp.floatValue()); parTemValue.setActTemValue(actualTemp.floatValue());
parTemValue.setOilTankSetTemValue(setUpOilTemp.floatValue()); parTemValue.setOilTankSetTemValue(setUpOilTemp.floatValue());
@ -432,15 +434,24 @@ public class ScheduledTask extends BaseService {
parTemValue.setCreateTime(LocalDateTime.now()); parTemValue.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue); parTemValueServiceBiz.save(parTemValue);
//电度值 //电度值
Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); Double electricalValue = readPlc(nameSpaceNote, "ElectricalValue");
//A向电压 //A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); Double phaseAVoltage = readPlc(nameSpaceNote, "PhaseAVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage");
ParEleValue parEleValue=new ParEleValue(); //ABC向电流
Double phaseACurrent = readPlc(nameSpaceNote, "PhaseACurrent");
Double phaseBCurrent = readPlc(nameSpaceNote, "PhaseBCurrent");
Double phaseDCurrent = readPlc(nameSpaceNote, "PhaseDCurrent");
ParEleValue parEleValue = new ParEleValue();
parEleValue.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue.setAVoltagevValue(phaseBVoltage.floatValue()); parEleValue.setBVoltagevValue(phaseBVoltage.floatValue());
parEleValue.setAVoltagevValue(phaseCVoltage.floatValue()); parEleValue.setCVoltagevValue(phaseCVoltage.floatValue());
parEleValue.setACurrentValue(phaseACurrent.floatValue());
parEleValue.setBCurrentValue(phaseBCurrent.floatValue());
parEleValue.setCCurrentValue(phaseDCurrent.floatValue());
parEleValue.setTotalBat(electricalValue.floatValue()); parEleValue.setTotalBat(electricalValue.floatValue());
parEleValue.setKilnId(kilnId); parEleValue.setKilnId(kilnId);
parEleValue.setTaskId(currTaskId); parEleValue.setTaskId(currTaskId);
@ -448,12 +459,12 @@ public class ScheduledTask extends BaseService {
parEleValueServiceBiz.save(parEleValue); parEleValueServiceBiz.save(parEleValue);
} }
//回火炉 //回火炉
if (kilnInfo.getType()==2){ if (kilnInfo.getType() == 2) {
//实际温度 //实际温度
Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); Double actualTemp = readPlc(nameSpaceNote, "ActualTemp");
//设定温度 //设定温度
Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); Double setUpTemp = readPlc(nameSpaceNote, "SetUpTemp");
ParTemValue parTemValue2=new ParTemValue(); ParTemValue parTemValue2 = new ParTemValue();
parTemValue2.setSetTemValue(setUpTemp.floatValue()); parTemValue2.setSetTemValue(setUpTemp.floatValue());
parTemValue2.setActTemValue(actualTemp.floatValue()); parTemValue2.setActTemValue(actualTemp.floatValue());
parTemValue2.setKilnId(kilnId); parTemValue2.setKilnId(kilnId);
@ -461,15 +472,22 @@ public class ScheduledTask extends BaseService {
parTemValue2.setCreateTime(LocalDateTime.now()); parTemValue2.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue2); parTemValueServiceBiz.save(parTemValue2);
//电度值 //电度值
Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); Double electricalValue = readPlc(nameSpaceNote, "TotalElectricity");
//A向电压 //A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage"); Double phaseAVoltage = readPlc(nameSpaceNote, "AVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage"); Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage"); Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage");
ParEleValue parEleValue2=new ParEleValue(); //ABC三相电流
Double aCurrent = readPlc(nameSpaceNote, "ACurrent");
Double bCurrent = readPlc(nameSpaceNote, "BCurrent");
Double cCurrent = readPlc(nameSpaceNote, "CCurrent");
ParEleValue parEleValue2 = new ParEleValue();
parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue()); parEleValue2.setBVoltagevValue(phaseBVoltage.floatValue());
parEleValue2.setAVoltagevValue(phaseCVoltage.floatValue()); parEleValue2.setCVoltagevValue(phaseCVoltage.floatValue());
parEleValue2.setACurrentValue(aCurrent.floatValue());
parEleValue2.setBCurrentValue(bCurrent.floatValue());
parEleValue2.setCCurrentValue(cCurrent.floatValue());
parEleValue2.setTotalBat(electricalValue.floatValue()); parEleValue2.setTotalBat(electricalValue.floatValue());
parEleValue2.setKilnId(kilnId); parEleValue2.setKilnId(kilnId);
parEleValue2.setTaskId(currTaskId); parEleValue2.setTaskId(currTaskId);
@ -477,18 +495,18 @@ public class ScheduledTask extends BaseService {
parEleValueServiceBiz.save(parEleValue2); parEleValueServiceBiz.save(parEleValue2);
} }
//氮化炉 //氮化炉
if (kilnInfo.getType()==3){ if (kilnInfo.getType() == 3) {
//实际温度 //实际温度
Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); Double actualTemp = readPlc(nameSpaceNote, "ActualTemp");
//设定温度 //设定温度
Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); Double setUpTemp = readPlc(nameSpaceNote, "SetUpTemp");
//炉压 //炉压
Double furnacePressure = readPlc(nameSpaceNote, "FurnacePressure"); Double furnacePressure = readPlc(nameSpaceNote, "FurnacePressure");
//外一区温度 //外一区温度
Double outerZoneITemperature = readPlc(nameSpaceNote, "OuterZoneITemperature"); Double outerZoneITemperature = readPlc(nameSpaceNote, "OuterZoneITemperature");
//外二区温度 //外二区温度
Double outerZone2Temperature = readPlc(nameSpaceNote, "OuterZone2Temperature"); Double outerZone2Temperature = readPlc(nameSpaceNote, "OuterZone2Temperature");
ParTemValue parTemValue3=new ParTemValue(); ParTemValue parTemValue3 = new ParTemValue();
parTemValue3.setSetTemValue(setUpTemp.floatValue()); parTemValue3.setSetTemValue(setUpTemp.floatValue());
parTemValue3.setActTemValue(actualTemp.floatValue()); parTemValue3.setActTemValue(actualTemp.floatValue());
parTemValue3.setOuterZone1Temp(outerZoneITemperature.floatValue()); parTemValue3.setOuterZone1Temp(outerZoneITemperature.floatValue());
@ -499,15 +517,22 @@ public class ScheduledTask extends BaseService {
parTemValue3.setCreateTime(LocalDateTime.now()); parTemValue3.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue3); parTemValueServiceBiz.save(parTemValue3);
//电度值 //电度值
Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); Double electricalValue = readPlc(nameSpaceNote, "ElectricalValue");
//A向电压 //A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); Double phaseAVoltage = readPlc(nameSpaceNote, "PhaseAVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage");
ParEleValue parEleValue3=new ParEleValue(); //ABC三向电流
Double phaseACurrent = readPlc(nameSpaceNote, "PhaseACurrent");
Double phaseBCurrent = readPlc(nameSpaceNote, "PhaseBCurrent");
Double phaseCCurrent = readPlc(nameSpaceNote, "PhaseCCurrent");
ParEleValue parEleValue3 = new ParEleValue();
parEleValue3.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue3.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue3.setAVoltagevValue(phaseBVoltage.floatValue()); parEleValue3.setBVoltagevValue(phaseBVoltage.floatValue());
parEleValue3.setAVoltagevValue(phaseCVoltage.floatValue()); parEleValue3.setCVoltagevValue(phaseCVoltage.floatValue());
parEleValue3.setACurrentValue(phaseACurrent.floatValue());
parEleValue3.setBCurrentValue(phaseBCurrent.floatValue());
parEleValue3.setCCurrentValue(phaseCVoltage.floatValue());
parEleValue3.setTotalBat(electricalValue.floatValue()); parEleValue3.setTotalBat(electricalValue.floatValue());
parEleValue3.setKilnId(kilnId); parEleValue3.setKilnId(kilnId);
parEleValue3.setTaskId(currTaskId); parEleValue3.setTaskId(currTaskId);
@ -515,17 +540,24 @@ public class ScheduledTask extends BaseService {
parEleValueServiceBiz.save(parEleValue3); parEleValueServiceBiz.save(parEleValue3);
} }
//清洗炉 //清洗炉
if (kilnInfo.getType()==4){ if (kilnInfo.getType() == 4) {
//电度值 //电度值
Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); Double electricalValue = readPlc(nameSpaceNote, "TotalElectricity");
//A向电压 //A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage"); Double phaseAVoltage = readPlc(nameSpaceNote, "AVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage"); Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage"); Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage");
ParEleValue parEleValue4=new ParEleValue(); //ABC三向电流
Double aCurrent = readPlc(nameSpaceNote, "ACurrent");
Double bCurrent = readPlc(nameSpaceNote, "BCurrent");
Double cCurrent = readPlc(nameSpaceNote, "CCurrent");
ParEleValue parEleValue4 = new ParEleValue();
parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue()); parEleValue4.setBVoltagevValue(phaseBVoltage.floatValue());
parEleValue4.setAVoltagevValue(phaseCVoltage.floatValue()); parEleValue4.setCVoltagevValue(phaseCVoltage.floatValue());
parEleValue4.setACurrentValue(aCurrent.floatValue());
parEleValue4.setBCurrentValue(bCurrent.floatValue());
parEleValue4.setCCurrentValue(cCurrent.floatValue());
parEleValue4.setTotalBat(electricalValue.floatValue()); parEleValue4.setTotalBat(electricalValue.floatValue());
parEleValue4.setKilnId(kilnId); parEleValue4.setKilnId(kilnId);
parEleValue4.setTaskId(currTaskId); parEleValue4.setTaskId(currTaskId);
@ -538,36 +570,36 @@ public class ScheduledTask extends BaseService {
//遍历工业炉空工业炉查询缓存区是否有等待加工的任务 //遍历工业炉空工业炉查询缓存区是否有等待加工的任务
//待加工任务存在且没有状态为正在进炉的情况下按照先进先出的规则选择待加工任务呼叫车辆进炉 //待加工任务存在且没有状态为正在进炉的情况下按照先进先出的规则选择待加工任务呼叫车辆进炉
@Scheduled(fixedDelay = 1000*60) @Scheduled(fixedDelay = 1000 * 60)
public void runTaskForEmptyKiln() throws IOException { public void runTaskForEmptyKiln() throws IOException {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>() List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>()
.eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0).orderByAsc(KilnInfo.TYPE)); .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0).orderByAsc(KilnInfo.TYPE));
// 呼叫车辆运送货物给炉子 // 呼叫车辆运送货物给炉子
//存在空闲工业炉 //存在空闲工业炉
if (kilnInfoList.size()!=0) { if (kilnInfoList.size() != 0) {
for (KilnInfo kilnInfo:kilnInfoList for (KilnInfo kilnInfo : kilnInfoList
) { ) {
//查询是否有车辆正在执行任务如果有根据车辆是否正在运行可以避免出现前一个任务获取还没进去炉子炉子状态依然为allowIn从而继续发送任务的情况 //查询是否有车辆正在执行任务如果有根据车辆是否正在运行可以避免出现前一个任务获取还没进去炉子炉子状态依然为allowIn从而继续发送任务的情况
List<VehicleInfo> vehicleInfos = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1)); List<VehicleInfo> vehicleInfos = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
if (vehicleInfos.size()>0){ if (vehicleInfos.size() > 0) {
return; return;
} }
Boolean kilnReadyIn=false; Boolean kilnReadyIn = false;
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
kilnReadyIn=kilnReadyIn(kilnInfo.getId()); kilnReadyIn = kilnReadyIn(kilnInfo.getId());
} }
//查询炉子是否allowIn //查询炉子是否allowIn
Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId()); Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId());
if (kilnReadyIn||kilnAllowIn){ if (kilnReadyIn || kilnAllowIn) {
//因为readyIn在多用炉第一托盘下油后一直存在,到出炉为止.所以查询当前炉子在加工的任务,大于一条,则不再根据readyIn发起任务 //因为readyIn在多用炉第一托盘下油后一直存在,到出炉为止.所以查询当前炉子在加工的任务,大于一条,则不再根据readyIn发起任务
List<CurrTask> currTaskList = currTaskServiceBiz.list(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)); .eq(CurrTask.KILN_ID, kilnInfo.getId()).eq(CurrTask.IS_IN, 1).eq(CurrTask.STATUS, 1));
if (kilnInfo.getType()==1){ if (kilnInfo.getType() == 1) {
if (currTaskList.size()>1){ if (currTaskList.size() > 1) {
continue; continue;
} }
}else { } else {
if (currTaskList.size()>0){ if (currTaskList.size() > 0) {
continue; continue;
} }
} }
@ -579,12 +611,12 @@ public class ScheduledTask extends BaseService {
.orderByAsc(InStockInfo.IN_TIME)); .orderByAsc(InStockInfo.IN_TIME));
if (inStockInfoList.size() > 0) { if (inStockInfoList.size() > 0) {
InStockInfo inStockInfo = inStockInfoList.get(0); InStockInfo inStockInfo = inStockInfoList.get(0);
logger.info("加工炉"+kilnInfo.getCode()+"readyIn为"+kilnReadyIn.toString()+" allowIn为"+kilnAllowIn.toString()); logger.info("加工炉" + kilnInfo.getCode() + "readyIn为" + kilnReadyIn.toString() + " allowIn为" + kilnAllowIn.toString());
logger.info("缓存区等待队列第一位:"+inStockInfo.toString()); logger.info("缓存区等待队列第一位:" + inStockInfo.toString());
CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId()); CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId());
if (currTask.getStatus()!=0){ if (currTask.getStatus() != 0) {
logger.info(inStockInfo.toString()+"该缓存对应的任务状态为:"+currTask.getStatus()+"不能发起任务。"); logger.info(inStockInfo.toString() + "该缓存对应的任务状态为:" + currTask.getStatus() + "不能发起任务。");
webSocketServer.sendtoUser(inStockInfo.getLocationName()+"对应的缓存加工任务状态不为未加工,不能发起任务,请先确认任务状态!","1"); webSocketServer.sendtoUser(inStockInfo.getLocationName() + "对应的缓存加工任务状态不为未加工,不能发起任务,请先确认任务状态!", "1");
} }
Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); Location location = locationServiceBiz.getById(inStockInfo.getLocationId());
//是否有小车在运行 //是否有小车在运行
@ -594,13 +626,13 @@ public class ScheduledTask extends BaseService {
//计算出路径最短的车辆id //计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode()); Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode());
//占用车辆 //占用车辆
if (vehicleId!=0){ if (vehicleId != 0) {
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1); vehicleInfo.setStatus(1);
vehicleInfo.setUpdateTime(LocalDateTime.now()); vehicleInfo.setUpdateTime(LocalDateTime.now());
vehicleInfoServiceBiz.updateById(vehicleInfo); vehicleInfoServiceBiz.updateById(vehicleInfo);
asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(), vehicleId); asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(), vehicleId);
}else { } else {
logger.info("当前两辆车都不在线.无法发起任务!"); logger.info("当前两辆车都不在线.无法发起任务!");
} }
} }
@ -612,10 +644,10 @@ public class ScheduledTask extends BaseService {
} }
//遍历正在工作炉子的报警变量记录报警 //遍历正在工作炉子的报警变量记录报警
@Scheduled(fixedDelay = 1000*60) @Scheduled(fixedDelay = 1000 * 60)
public void listenKilnAlarm(){ public void listenKilnAlarm() {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList for (KilnInfo kilnInfo : kilnInfoList
) { ) {
PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
@ -624,53 +656,53 @@ public class ScheduledTask extends BaseService {
String working = readPlcToString(kilnNameSpace.getName(), "Working"); String working = readPlcToString(kilnNameSpace.getName(), "Working");
JSONObject jsonObject = JSON.parseObject(working); JSONObject jsonObject = JSON.parseObject(working);
Boolean aBoolean = Boolean.valueOf(String.valueOf(jsonObject.get("result"))); Boolean aBoolean = Boolean.valueOf(String.valueOf(jsonObject.get("result")));
if (aBoolean){ if (aBoolean) {
//命名空间前缀 //命名空间前缀
String nameSpace = kilnNameSpace.getName(); String nameSpace = kilnNameSpace.getName();
//炉子的报警变量 //炉子的报警变量
List<PlcNameSpace> alarmNameList = plcNameSpaceServiceBiz.list(new QueryWrapper<PlcNameSpace>() List<PlcNameSpace> alarmNameList = plcNameSpaceServiceBiz.list(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 1) .eq(PlcNameSpace.EQ_TYPE, 1)
.eq(PlcNameSpace.TYPE, 1) .eq(PlcNameSpace.TYPE, 1)
.eq(PlcNameSpace.EQ_ID,kilnInfo.getId()));; .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()));
for (PlcNameSpace plcNameSpace:alarmNameList ;
for (PlcNameSpace plcNameSpace : alarmNameList
) { ) {
String name = plcNameSpace.getName(); String name = plcNameSpace.getName();
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",nameSpace+name); json.put("identifier", nameSpace + name);
String jsonString = JSON.toJSONString(json); String jsonString = JSON.toJSONString(json);
try { try {
String result = HttpClient.httpPost("http://localhost:8009/opcua/read", jsonString); String result = HttpClient.httpPost("http://localhost:8009/opcua/read", jsonString);
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
//报警状态为true //报警状态为true
if (resultBoolean){ if (resultBoolean) {
//任务状态为执行中且正在炉子中加工的任务 //任务状态为执行中且正在炉子中加工的任务
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>() List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
.eq(CurrTask.KILN_ID, kilnInfo.getId()) .eq(CurrTask.KILN_ID, kilnInfo.getId())
.eq(CurrTask.IS_IN, 1) .eq(CurrTask.IS_IN, 1)
.eq(CurrTask.STATUS, 1)); .eq(CurrTask.STATUS, 1));
if (currTaskList.size()!=0){ if (currTaskList.size() != 0) {
for (CurrTask currTask:currTaskList for (CurrTask currTask : currTaskList
) { ) {
AlarmInfo alarmInfo=new AlarmInfo(); AlarmInfo alarmInfo = new AlarmInfo();
alarmInfo.setEquipmentId(currTask.getKilnId()); alarmInfo.setEquipmentId(currTask.getKilnId());
alarmInfo.setEquipmentName(currTask.getKilnName()); alarmInfo.setEquipmentName(currTask.getKilnName());
alarmInfo.setType(0); alarmInfo.setType(0);
alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode()); alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode());
alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+""+plcNameSpace.getNote()); alarmInfo.setAlarmInfo(plcNameSpace.getEqName() + "" + plcNameSpace.getNote());
alarmInfo.setTaskCode(currTask.getTaskCode()); alarmInfo.setTaskCode(currTask.getTaskCode());
alarmInfo.setCreateTime(LocalDateTime.now()); alarmInfo.setCreateTime(LocalDateTime.now());
alarmInfoServiceBiz.save(alarmInfo); alarmInfoServiceBiz.save(alarmInfo);
} }
} } else {
else { AlarmInfo alarmInfo = new AlarmInfo();
AlarmInfo alarmInfo=new AlarmInfo();
alarmInfo.setEquipmentId(kilnInfo.getId()); alarmInfo.setEquipmentId(kilnInfo.getId());
alarmInfo.setEquipmentName(kilnInfo.getKilnName()); alarmInfo.setEquipmentName(kilnInfo.getKilnName());
alarmInfo.setType(0); alarmInfo.setType(0);
alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode()); alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode());
alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+""+plcNameSpace.getNote()); alarmInfo.setAlarmInfo(plcNameSpace.getEqName() + "" + plcNameSpace.getNote());
alarmInfo.setTaskCode("0"); alarmInfo.setTaskCode("0");
alarmInfo.setCreateTime(LocalDateTime.now()); alarmInfo.setCreateTime(LocalDateTime.now());
alarmInfoServiceBiz.save(alarmInfo); alarmInfoServiceBiz.save(alarmInfo);
@ -686,88 +718,94 @@ public class ScheduledTask extends BaseService {
//监听车辆是否在线,定时恢复车辆状态会导致避让时等待时间过久,再次发起任务,造成重复发起废弃 //监听车辆是否在线,定时恢复车辆状态会导致避让时等待时间过久,再次发起任务,造成重复发起废弃
public void listenVehicleOnline() throws IOException { public void listenVehicleOnline() throws IOException {
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS,1)); List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
for (VehicleInfo vehicleInfo:vehicleInfoList for (VehicleInfo vehicleInfo : vehicleInfoList
) { ) {
Boolean rgvOnline = rgvOnline(vehicleInfo.getId()); Boolean rgvOnline = rgvOnline(vehicleInfo.getId());
Boolean rgvFree = rgvFree(vehicleInfo.getId()); Boolean rgvFree = rgvFree(vehicleInfo.getId());
if (!rgvOnline){ if (!rgvOnline) {
webSocketServer.sendtoUser("当前存在车辆不在线,请移动停用的车辆到轨道尽头处或者改车辆为线上模式,如果已经车辆停用,请忽略本提示消息。","1"); webSocketServer.sendtoUser("当前存在车辆不在线,请移动停用的车辆到轨道尽头处或者改车辆为线上模式,如果已经车辆停用,请忽略本提示消息。", "1");
} }
if (rgvOnline&&rgvFree){ if (rgvOnline && rgvFree) {
vehicleInfo.setStatus(0); vehicleInfo.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicleInfo); vehicleInfoServiceBiz.updateById(vehicleInfo);
logger.info("检测到车辆:"+vehicleInfo.getId()+" 显示状态为占用,实际状态为空闲。自动置车辆状态为空闲。"); logger.info("检测到车辆:" + vehicleInfo.getId() + " 显示状态为占用,实际状态为空闲。自动置车辆状态为空闲。");
} }
} }
} }
/** /**
* 获取变量值 * 获取变量值
*
* @param nameSpace nameSpace前缀 * @param nameSpace nameSpace前缀
* @param variableName 变量名称 * @param variableName 变量名称
* @return result字符串 * @return result字符串
*/ */
private String readPlcToString(String nameSpace, String variableName){ private String readPlcToString(String nameSpace, String variableName) {
String identifier=nameSpace.concat(variableName); String identifier = nameSpace.concat(variableName);
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",identifier); json.put("identifier", identifier);
String result = null; String result = null;
try { try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.info("readPLC "+identifier+" 的值失败"); logger.info("readPLC " + identifier + " 的值失败");
} }
return result; return result;
} }
/** /**
* 获取变量值 * 获取变量值
*
* @param nameSpace nameSpace前缀 * @param nameSpace nameSpace前缀
* @param variableName 变量名称 * @param variableName 变量名称
* @return 变量值 * @return 变量值
*/ */
private Double readPlc(String nameSpace, String variableName){ private Double readPlc(String nameSpace, String variableName) {
String identifier=nameSpace.concat(variableName); String identifier = nameSpace.concat(variableName);
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",identifier); json.put("identifier", identifier);
String result = null; String result = null;
try { try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.info("能源消耗统计:获取 "+identifier+" 的值失败"); logger.info("能源消耗统计:获取 " + identifier + " 的值失败");
} }
return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
} }
private Boolean kilnAllowIn(Long kilnId){ private Boolean kilnAllowIn(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId) .eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE,0)); .eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName(); String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "AllowIn"); String result = readPlcToString(nameSpaceNote, "AllowIn");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
} }
private Boolean kilnReadyIn(Long kilnId){
private Boolean kilnReadyIn(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId) .eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE,0)); .eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName(); String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "ReadyIn"); String result = readPlcToString(nameSpaceNote, "ReadyIn");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
} }
private Boolean kilnWorking(Long kilnId){
private Boolean kilnWorking(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>() PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId) .eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE,0)); .eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName(); String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working"); String result = readPlcToString(nameSpaceNote, "Working");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
@ -775,28 +813,29 @@ public class ScheduledTask extends BaseService {
/** /**
* 车辆是否在线 * 车辆是否在线
*
* @param vehicleId 车辆id * @param vehicleId 车辆id
* @return true/false * @return true/false
* @throws IOException plc访问失败 * @throws IOException plc访问失败
*/ */
private Boolean rgvOnline(Long vehicleId) throws IOException { private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null; String identifier = null;
if (vehicleId==1){ if (vehicleId == 1) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
} }
if (vehicleId==2){ if (vehicleId == 2) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
} }
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",identifier); json.put("identifier", identifier);
String result = null; String result = null;
try { try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败"); logger.info("获取车辆" + vehicleId + "当前是否在线失败");
} }
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online; return online;
@ -804,28 +843,29 @@ public class ScheduledTask extends BaseService {
/** /**
* 车辆是否空闲 * 车辆是否空闲
*
* @param vehicleId 车辆id * @param vehicleId 车辆id
* @return true/false * @return true/false
* @throws IOException plc访问失败 * @throws IOException plc访问失败
*/ */
private Boolean rgvFree(Long vehicleId) throws IOException { private Boolean rgvFree(Long vehicleId) throws IOException {
String identifier=null; String identifier = null;
if (vehicleId==1){ if (vehicleId == 1) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
} }
if (vehicleId==2){ if (vehicleId == 2) {
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free"; identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
} }
Map<String, Object> json = new HashMap(); Map<String, Object> json = new HashMap();
json.put("nameSpace", 6); json.put("nameSpace", 6);
json.put("plcName", "plc1"); json.put("plcName", "plc1");
json.put("identifier",identifier); json.put("identifier", identifier);
String result = null; String result = null;
try { try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否空闲失败"); logger.info("获取车辆" + vehicleId + "当前是否空闲失败");
} }
Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return free; return free;

View File

@ -0,0 +1,174 @@
package com.mt.wms.empty.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.Version;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* @Author: LGH
* @Date: 2022/11/17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS检验结果视图对象", description = "用于查询APMS检验结果视图对象")
public class ApmsCheckResultVo {
/**
* 添加时间入库时间
*/
@ApiModelProperty(value = "创建时间", example = "1")
private LocalDateTime createTime;
/**
* 生产单号
*/
@ApiModelProperty(value = "生产单号", example = "1")
private String sheetNo;
/**
* 炉号
*/
@ApiModelProperty(value = "炉号", example = "1")
private String stoveCode;
/**
* 标识卡号
*/
@ApiModelProperty(value = "标识卡号", example = "1")
private String idenCardNum;
/**
* 硬度检验结果待检验合格不合格返工作废
*/
@ApiModelProperty(value = "硬度检验结果(待检验、合格、不合格、返工、作废)", example = "1")
private String hardness;
/**
* 金相检验结果合格不合格
*/
@ApiModelProperty(value = "金相检验结果(合格、不合格)", example = "1")
private String metallography;
/**
* 心部硬度检验值
*/
@ApiModelProperty(value = "心部硬度检验值", example = "1")
private String heartHardness;
/**
* 备注特殊注释等
*/
@ApiModelProperty(value = "备注", example = "1")
private String remake;
/**
* 硬度检验结果1
*/
@ApiModelProperty(value = "硬度检验结果1", example = "1")
private String hardnessValueOne;
/**
* 硬度检验结果2
*/
@ApiModelProperty(value = "硬度检验结果2", example = "1")
private String hardnessValueTwo;
/**
* 硬度检验结果3
*/
@ApiModelProperty(value = "硬度检验结果3", example = "1")
private String hardnessValueThree;
/**
* 金相检验渗碳淬火 渗碳层深度
*/
@ApiModelProperty(value = "金相检验渗碳淬火 渗碳层深度", example = "1")
private Float metallographyStchStccsd;
/**
* 金相检验渗碳淬火 表面为马氏体残余奥氏体
*/
@ApiModelProperty(value = "金相检验渗碳淬火 表面为马氏体、残余奥氏体(级)", example = "1")
private String metallographyStchMstost;
/**
* 金相检验渗碳淬火 细小颗粒状碳化物
*/
@ApiModelProperty(value = "金相检验渗碳淬火 细小颗粒状碳化物", example = "1")
private String metallographyStchXxklzthw;
/**
* 金相检验渗碳淬火 心部为低碳马氏体加游离铁素体
*/
@ApiModelProperty(value = "金相检验渗碳淬火 心部为低碳马氏体加游离铁素体(级)", example = "1")
private String metallographyStchDtmstyltst;
/**
* 金相检验整体淬火 基体为回火马氏体
*/
@ApiModelProperty(value = "金相检验整体淬火 基体为回火马氏体(级)", example = "1")
private String metallographyZtchHhmst;
/**
* 金相检验整体淬火 基体为回火托式体
*/
@ApiModelProperty(value = "金相检验整体淬火 基体为回火托式体(级)", example = "1")
private String metallographyZtchHhtst;
/**
* 金相检验整体淬火 基体为回火素式体
*/
@ApiModelProperty(value = "金相检验整体淬火 基体为回火素式体(级)", example = "1")
private String metallographyZtchHhsst;
/**
* 金相检验氮化 表面亮白色的为氮化合物层深
*/
@ApiModelProperty(value = "金相检验氮化 表面亮白色的为氮化合物层深", example = "1")
private Float metallographyDhDhhwcs;
/**
* 金相检验氮化 向内为扩散层深
*/
@ApiModelProperty(value = "金相检验氮化 向内为扩散层深", example = "1")
private Float metallographyDhKscs;
/**
* 金相检验氮化 心部
*/
@ApiModelProperty(value = "金相检验氮化 心部", example = "1")
private String metallographyDhXb;
/**
* 金相检验表面淬火 表面为板条马氏体
*/
@ApiModelProperty(value = "金相检验表面淬火 表面为板条马氏体(级)", example = "1")
private String metallographyBmchBtmst;
/**
* 金相检验表面淬火 心部
*/
@ApiModelProperty(value = "金相检验表面淬火 心部", example = "1")
private String metallographyBmchXb;
/**
* 金相检验 备注
*/
@ApiModelProperty(value = "金相检验 备注", example = "1")
private String metallographyBz;
/**
* 金相检验心部硬度 心部硬度检验结果
*/
@ApiModelProperty(value = "金相检验心部硬度 心部硬度检验结果", example = "1")
private Float metallographyXbydXbydjyjg;
}

View File

@ -0,0 +1,50 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import com.mt.wms.core.vo.PageVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* @Author: LGH
* @Date: 2022/11/16
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "能源消耗视图对象", description = "用于查询能源消耗视图对象")
public class EnergyVo extends BaseVo implements PageVo.ConvertVo{
/**
* 名称
*/
@ApiModelProperty(value = "名称",example = "0")
private String name;
/**
*
*/
@ApiModelProperty(value = "名称",example = "0")
private Object value;
/**
* 单位
*/
@ApiModelProperty(value = "单位",example = "0")
private String unit;
/**
* 时间
*/
@ApiModelProperty(value = "时间",example = "0")
private LocalDateTime time;
/**
* code
*/
@ApiModelProperty(value = "编码",example = "0")
private String code;
}