上报apms炉号
This commit is contained in:
李广豪 2022-11-18 10:12:54 +08:00
parent 592d27b858
commit 5eed777f0a

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,79 +159,80 @@ 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);
} }
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,11 +644,11 @@ 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)
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId())); .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()));
@ -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;