Compare commits

14 Commits

Author SHA1 Message Date
lgh
d14d142472 update: 2023-02-22 08:40:56 +08:00
lgh
571cee49a0 update: 2023-01-05 16:57:24 +08:00
lgh
f1878910e3 Merge branch 'master' of http://git.picaiba.com/mt-ck/mt-qj-wms-hd 2022-12-29 11:53:34 +08:00
lgh
f5aa87d7e9 update: 2022-12-29 11:53:23 +08:00
LGH
fa189331b8 update:
2号油搅拌速度;
1,2外区温度;
2022-12-29 11:52:22 +08:00
lgh
0616844403 update: 2022-12-27 20:08:59 +08:00
LGH
ac476e936e Merge branch 'master' of http://git.picaiba.com/mt-ck/mt-qj-wms-hd 2022-12-27 18:04:03 +08:00
LGH
6259a0237e update: 2022-12-27 18:03:59 +08:00
LGH
b0540ce4dc update: 2022-12-27 18:02:13 +08:00
lgh
395817f10e update: 2022-12-27 18:01:05 +08:00
lgh
21a4cfab23 update:
监听到加工炉完成加工后就结束当前工艺,防止开始新的工艺时上报出错
2022-12-02 15:42:02 +08:00
lgh
63d251325f update:
安全距离3.8米;
停止接收任务启用;
订单作废;
修改任务状态提交apms;
2022-11-28 17:02:29 +08:00
LGH
a002354d49 update:
出库液压台在线且高位则选为出库台
2022-11-24 09:09:38 +08:00
lgh
7e9d8f5e64 update:
任务明细非空判定,
手动进炉的任务生成炉号
2022-11-24 08:41:38 +08:00
15 changed files with 1240 additions and 126 deletions

View File

@@ -139,9 +139,6 @@ public class CurrTaskController extends BaseController {
@ApiOperation(value = "订单加工-创建多个个分步骤加工任务至任务队列")
public R<String> createAutoTask(@Validated @RequestBody AutoCurrTaskParam autoCurrTaskParam) {
List<TaskCreateParam> detParams = autoCurrTaskParam.getTaskCreateParamList();
if (detParams.size() == 0) {
return failed("请添加至少一个标识卡!");
}
Boolean apmsCreateProcessSheet = false;
String sheetNo = null;
int i = 1;
@@ -150,6 +147,9 @@ public class CurrTaskController extends BaseController {
AutoExeTask autoExeTask = new AutoExeTask();
for (TaskCreateParam param : detParams
) {
if(param.getDetParams().size()==0){
return failed("请添加至少一个标识卡!");
}
//验证标识卡号正确无误。
orderInfoService.verifyTaskInfoByIdenCardNum(param.getDetParams());
//验证炉子编码信息在apms正确无误

View File

@@ -614,6 +614,7 @@ public class EnergyController extends BaseController {
carbonActVo.setValue(parGasValue.getActualNitPotValue());
carbonActVo.setUnit("%");
carbonActVo.setName("碳/氮势");
carbonActVo.setTime(parGasValue.getCreateTime());
carbonActVo.setCode(currTask.getStoveCode());
carbon.add(carbonActVo);
@@ -677,9 +678,11 @@ public class EnergyController extends BaseController {
carbonSetVo.setValue(parGasValue.getSetNitPotValue());
carbonSet.add(carbonSetVo);
EnergyVo carbonActVo = EnergyVo.builder().build();
carbonActVo.setTime(parGasValue.getCreateTime());
carbonActVo.setValue(parGasValue.getActualNitPotValue());
carbonActVo.setUnit("%");
carbonActVo.setName("碳/氮势");
carbonActVo.setTime(parGasValue.getCreateTime());
carbonActVo.setCode(currTask.getStoveCode());
carbon.add(carbonActVo);

View File

@@ -0,0 +1,693 @@
package com.mt.wms.empty.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mt.wms.core.base.BaseController;
import com.mt.wms.core.constants.CommonConstant;
import com.mt.wms.core.dal.entity.*;
import com.mt.wms.core.dal.service.*;
import com.mt.wms.core.params.IdParam;
import com.mt.wms.core.utils.BeanUtils;
import com.mt.wms.core.utils.HttpClient;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.params.ElectricQueryParam;
import com.mt.wms.empty.service.EleService;
import com.mt.wms.empty.task.ScheduledTask;
import com.mt.wms.empty.vo.ApmsCheckResultVo;
import com.mt.wms.empty.vo.CurrTaskDetVo;
import com.mt.wms.empty.vo.EnergyVo;
import com.mt.wms.empty.vo.NowCurrTaskDetVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.groups.Default;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: LGH
* @Date: 2022/12/27
*/
@RestController
@RequestMapping(CommonConstant.API_MODULE_BASE + "screenInfo")
@Slf4j
@Api(value = "大屏信息相关接口", tags = "大屏信息相关接口", hidden = false)
public class ScreenController extends BaseController {
private final static Logger logger = LoggerFactory.getLogger(ScreenController.class);
@Autowired
private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz;
@Autowired
private CurrTaskDetServiceBiz currTaskDetServiceBiz;
@Autowired
private OrderInfoServiceBiz orderInfoServiceBiz;
@Autowired
private CurrTaskServiceBiz currTaskServiceBiz;
@Autowired
private KilnInfoServiceBiz kilnInfoServiceBiz;
@Autowired
private ParEleValueServiceBiz parEleValueServiceBiz;
@Autowired
private ParGasValueServiceBiz parGasValueServiceBiz;
@Autowired
private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz;
@Autowired
private ParTemValueServiceBiz parTemValueServiceBiz;
@Autowired
private EleService eleService;
@PostMapping(value = "getKilnList")
@ApiOperation(value = "获取加工炉信息")
public R<List<KilnInfo>> getKilnList() {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo : kilnInfoList
) {
Boolean kilnWorking = kilnWorking(kilnInfo.getId());
if (kilnWorking) {
kilnInfo.setStatus(2);
}
Boolean kilnOnline = kilnOnline(kilnInfo.getId());
if (!kilnOnline) {
//不在线视为损坏
kilnInfo.setStatus(1);
}
}
return successful(kilnInfoList);
}
@PostMapping(value = "getEleList")
@ApiOperation(value = "获取加工炉最近十条加工任务电能消耗信息")
public R countEleByKiln(@Validated @RequestBody IdParam idParam) {
return eleService.list(idParam.getId());
}
@PostMapping(value = "CurrTaskInfo")
@ApiOperation(value = "获取当前加工任务基础信息")
public R<List<NowCurrTaskDetVo>> CurrTaskInfo() {
//查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
.eq(CurrTask.IS_IN, 1)
.eq(CurrTask.STATUS, 1));
if (currTaskList.size() == 0) {
return failed("");
}
List<NowCurrTaskDetVo> nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class);
for (NowCurrTaskDetVo nowCurrTask : nowCurrTaskDetVoList
) {
Long kilnId = nowCurrTask.getKilnId();
Boolean kilnWorking = kilnWorking(kilnId);
//查询对应炉号是否Working
if (kilnWorking) {
String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)).getName();
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
nowCurrTask.setTaskCode(nowCurrTask.getSheetNo());
nowCurrTask.setKilnCode(kilnInfo.getCode());
nowCurrTask.setTaskId(nowCurrTask.getId());
//设定时间
Integer setupTime = 1;
//剩余时间
Integer remainingTime = 0;
if (kilnInfo.getType() != 4) {
if (kilnInfo.getType() == 3) {
remainingTime = readPlc(nameSpace, "ProgramTimeRemaining").intValue();
} else {
remainingTime = readPlc(nameSpace, "ProgramTimeRemain").intValue();
}
}
if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) {
//运行时间
Integer runTime = readPlc(nameSpace, "ProgramRunTime").intValue();
setupTime = runTime + remainingTime;
}
if (kilnInfo.getType() == 2) {
setupTime = readPlc(nameSpace, "SetTime").intValue();
}
nowCurrTask.setSetupTime(setupTime);
nowCurrTask.setRemainingTime(remainingTime);
int completeness = (int) (((float) remainingTime / (float) setupTime) * 100);
nowCurrTask.setCompleteness(completeness);
nowCurrTask.setKilnCode(kilnInfo.getCode());
//标识卡详情
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>()
.eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId()));
List<CurrTaskDetVo> currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
for (CurrTaskDetVo currTaskDetVo : currTaskDetVoList
) {
String customerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName();
currTaskDetVo.setCustomer(customerName);
}
nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList);
}
}
return successful(nowCurrTaskDetVoList);
}
@PostMapping(value = "energyInfo")
@ApiOperation(value = "获取当前加工任务能源消耗信息")
public R<JSONObject> list(@Validated @RequestBody IdParam idParam) {
Long taskId = idParam.getId();
Map<String, Object> map = new HashMap<>();
//电度值
List<List<EnergyVo>> eleConsumeList = new ArrayList<>();
//A向电压
List<List<EnergyVo>> aVolConsumeList = new ArrayList<>();
//B向电压
List<List<EnergyVo>> bVolConsumeList = new ArrayList<>();
//C向电压
List<List<EnergyVo>> cVolConsumeList = new ArrayList<>();
//A向电流
List<List<EnergyVo>> aCurrentList = new ArrayList<>();
//B向电流
List<List<EnergyVo>> bCurrentList = new ArrayList<>();
//C向电流
List<List<EnergyVo>> cCurrentList = new ArrayList<>();
//氮气
List<List<EnergyVo>> nitConsumeList = new ArrayList<>();
//甲醇
List<List<EnergyVo>> metConsumeList = new ArrayList<>();
//丙烷
List<List<EnergyVo>> propaneConsumeList = new ArrayList<>();
//氨气
List<List<EnergyVo>> ammoniaConsumeList = new ArrayList<>();
//二氧化碳
List<List<EnergyVo>> carbonConsumeList = new ArrayList<>();
//1号油搅拌转速
List<List<EnergyVo>> rot1ConsumeList = new ArrayList<>();
//2号油搅拌转速
List<List<EnergyVo>> rot2ConsumeList = new ArrayList<>();
//温度
List<List<EnergyVo>> tempConsumeList = new ArrayList<>();
//油槽温度
List<List<EnergyVo>> oilTempConsumeList = new ArrayList<>();
//外一区温度
List<List<EnergyVo>> outerZone1TempConsumeList = new ArrayList<>();
//外二区温度
List<List<EnergyVo>> outerZone2TempConsumeList = new ArrayList<>();
//碳/氮势
List<List<EnergyVo>> carbonList = new ArrayList<>();
List<List<ApmsCheckResultVo>> checkResultList = new ArrayList<>();
CurrTask currTask = currTaskServiceBiz.getById(taskId);
//防止早期没有炉号的报错
if (currTask.getStoveCode() == null) {
currTask.setStoveCode(currTask.getSheetNo());
}
Long kilnId = currTask.getKilnId();
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
Integer kilnType = kilnInfo.getType();
//电能消耗
List<ParEleValue> parEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
.eq(ParEleValue.KILN_ID, kilnId)
.eq(ParEleValue.TASK_ID, taskId));
if (parEleValueList.size() > 0) {
List<Object> eleList = new ArrayList<>();
//电能消耗
List<EnergyVo> eleConsume = new ArrayList<>();
//A向电压
List<EnergyVo> aVolConsume = new ArrayList<>();
//B向电压
List<EnergyVo> bVolConsume = new ArrayList<>();
//C向电压
List<EnergyVo> cVolConsume = new ArrayList<>();
//A向电流
List<EnergyVo> aCurrentConsume = new ArrayList<>();
//B向电流
List<EnergyVo> bCurrentConsume = new ArrayList<>();
//C向电流
List<EnergyVo> cCurrentConsume = new ArrayList<>();
Float talBat = 0F;
int i = 0;
for (ParEleValue parEleValue : parEleValueList
) {
//首位置为0
if (i == 0) {
talBat = parEleValue.getTotalBat();
}
i++;
EnergyVo eleVo = EnergyVo.builder().build();
eleVo.setCode(currTask.getStoveCode());
eleVo.setName("耗电量");
eleVo.setUnit("KW");
eleVo.setTime(parEleValue.getCreateTime());
eleVo.setValue(floatSubtract(parEleValue.getTotalBat(), talBat));
eleConsume.add(eleVo);
EnergyVo aVolVo = EnergyVo.builder().build();
aVolVo.setCode(currTask.getStoveCode());
aVolVo.setName("A向电压");
aVolVo.setUnit("V");
aVolVo.setTime(parEleValue.getCreateTime());
aVolVo.setValue(parEleValue.getAVoltagevValue());
aVolConsume.add(aVolVo);
EnergyVo bVolVo = EnergyVo.builder().build();
bVolVo.setCode(currTask.getStoveCode());
bVolVo.setName("B向电压");
bVolVo.setUnit("V");
bVolVo.setTime(parEleValue.getCreateTime());
bVolVo.setValue(parEleValue.getBVoltagevValue());
bVolConsume.add(bVolVo);
EnergyVo cVolVo = EnergyVo.builder().build();
cVolVo.setCode(currTask.getStoveCode());
cVolVo.setName("C向电压");
cVolVo.setUnit("V");
cVolVo.setTime(parEleValue.getCreateTime());
cVolVo.setValue(parEleValue.getCVoltagevValue());
cVolConsume.add(cVolVo);
EnergyVo aCurrVo = EnergyVo.builder().build();
aCurrVo.setCode(currTask.getStoveCode());
aCurrVo.setName("A向电流");
aCurrVo.setUnit("A");
aCurrVo.setTime(parEleValue.getCreateTime());
aCurrVo.setValue(parEleValue.getACurrentValue());
aCurrentConsume.add(aCurrVo);
EnergyVo bCurrVo = EnergyVo.builder().build();
bCurrVo.setCode(currTask.getStoveCode());
bCurrVo.setName("B向电流");
bCurrVo.setUnit("A");
bCurrVo.setTime(parEleValue.getCreateTime());
bCurrVo.setValue(parEleValue.getBCurrentValue());
bCurrentConsume.add(bCurrVo);
EnergyVo cCurrVo = EnergyVo.builder().build();
cCurrVo.setCode(currTask.getStoveCode());
cCurrVo.setName("C向电流");
cCurrVo.setUnit("A");
cCurrVo.setTime(parEleValue.getCreateTime());
cCurrVo.setValue(parEleValue.getCCurrentValue());
cCurrentConsume.add(cCurrVo);
}
eleConsumeList.add(eleConsume);
aVolConsumeList.add(aVolConsume);
bVolConsumeList.add(bVolConsume);
cVolConsumeList.add(cVolConsume);
aCurrentList.add(aCurrentConsume);
bCurrentList.add(bCurrentConsume);
cCurrentList.add(cCurrentConsume);
}
//氮气、甲醇、丙烷、氨气二氧化碳消耗量碳势
List<ParGasValue> parGasValueList = parGasValueServiceBiz.list(new QueryWrapper<ParGasValue>()
.eq(ParEleValue.KILN_ID, kilnId)
.eq(ParEleValue.TASK_ID, taskId));
if (parGasValueList.size() > 0) {
if (kilnType == 1) {
//碳/氮势
List<EnergyVo> carbon = new ArrayList<>();
//碳/氮势-设定
List<EnergyVo> carbonSet = new ArrayList<>();
//氮气
List<EnergyVo> nitConsume = new ArrayList<>();
//甲醇
List<EnergyVo> metConsume = new ArrayList<>();
//丙烷
List<EnergyVo> propaneConsume = new ArrayList<>();
//氨气
List<EnergyVo> ammoniaConsume = new ArrayList<>();
for (ParGasValue parGasValue : parGasValueList
) {
EnergyVo carbonSetVo = EnergyVo.builder().build();
carbonSetVo.setTime(parGasValue.getCreateTime());
carbonSetVo.setCode(currTask.getStoveCode().concat("-设定"));
carbonSetVo.setUnit("%");
carbonSetVo.setName("碳/氮势");
carbonSetVo.setValue(parGasValue.getSetNitPotValue());
carbonSet.add(carbonSetVo);
EnergyVo carbonActVo = EnergyVo.builder().build();
carbonActVo.setValue(parGasValue.getActualNitPotValue());
carbonActVo.setUnit("%");
carbonActVo.setName("碳/氮势");
carbonActVo.setCode(currTask.getStoveCode());
carbon.add(carbonActVo);
EnergyVo nitVo = EnergyVo.builder().build();
nitVo.setTime(parGasValue.getCreateTime());
nitVo.setUnit("m³/h");
nitVo.setValue(parGasValue.getNitFlowValue());
nitVo.setName("氮气");
nitVo.setCode(currTask.getStoveCode());
nitConsume.add(nitVo);
EnergyVo metVo = EnergyVo.builder().build();
metVo.setCode(currTask.getStoveCode());
metVo.setValue(parGasValue.getMethanolFlow());
metVo.setName("甲醇");
metVo.setUnit("m³/h");
metVo.setTime(parGasValue.getCreateTime());
metConsume.add(metVo);
EnergyVo propaneVo = EnergyVo.builder().build();
propaneVo.setTime(parGasValue.getCreateTime());
propaneVo.setCode(currTask.getStoveCode());
propaneVo.setUnit("m³/h");
propaneVo.setValue(parGasValue.getPropaneFlow());
propaneVo.setName("丙烷");
propaneConsume.add(propaneVo);
EnergyVo ammoniaVo = EnergyVo.builder().build();
ammoniaVo.setName("氨气");
ammoniaVo.setCode(currTask.getStoveCode());
ammoniaVo.setValue(parGasValue.getAmmoniaFlowValue());
ammoniaVo.setUnit("m³/h");
ammoniaVo.setTime(parGasValue.getCreateTime());
ammoniaConsume.add(ammoniaVo);
}
carbonList.add(carbon);
carbonList.add(carbonSet);
nitConsumeList.add(nitConsume);
metConsumeList.add(metConsume);
propaneConsumeList.add(propaneConsume);
ammoniaConsumeList.add(ammoniaConsume);
}
if (kilnType == 3) {
//碳/氮势
List<EnergyVo> carbon = new ArrayList<>();
//碳/氮势-设定
List<EnergyVo> carbonSet = new ArrayList<>();
//氮气
List<EnergyVo> nitConsume = new ArrayList<>();
//二氧化碳
List<EnergyVo> carbonConsume = new ArrayList<>();
//氨气
List<EnergyVo> ammoniaConsume = new ArrayList<>();
for (ParGasValue parGasValue : parGasValueList
) {
EnergyVo carbonSetVo = EnergyVo.builder().build();
carbonSetVo.setTime(parGasValue.getCreateTime());
carbonSetVo.setCode(currTask.getStoveCode().concat("-设定"));
carbonSetVo.setUnit("%");
carbonSetVo.setName("碳/氮势");
carbonSetVo.setValue(parGasValue.getSetNitPotValue());
carbonSet.add(carbonSetVo);
EnergyVo carbonActVo = EnergyVo.builder().build();
carbonActVo.setTime(parGasValue.getCreateTime());
carbonActVo.setValue(parGasValue.getActualNitPotValue());
carbonActVo.setUnit("%");
carbonActVo.setName("碳/氮势");
carbonActVo.setCode(currTask.getStoveCode());
carbon.add(carbonActVo);
EnergyVo nitVo = EnergyVo.builder().build();
nitVo.setTime(parGasValue.getCreateTime());
nitVo.setUnit("m³/h");
nitVo.setValue(parGasValue.getNitFlowValue());
nitVo.setName("氮气");
nitVo.setCode(currTask.getStoveCode());
nitConsume.add(nitVo);
EnergyVo carbonVo = EnergyVo.builder().build();
carbonVo.setTime(parGasValue.getCreateTime());
carbonVo.setCode(currTask.getStoveCode());
carbonVo.setUnit("m³/h");
carbonVo.setValue(parGasValue.getCarDioxideFlowValue());
carbonVo.setName("二氧化碳");
carbonConsume.add(carbonVo);
EnergyVo ammoniaVo = EnergyVo.builder().build();
ammoniaVo.setName("氨气");
ammoniaVo.setCode(currTask.getStoveCode());
ammoniaVo.setValue(parGasValue.getAmmoniaFlowValue());
ammoniaVo.setUnit("m³/h");
ammoniaVo.setTime(parGasValue.getCreateTime());
ammoniaConsume.add(ammoniaVo);
}
carbonList.add(carbon);
carbonList.add(carbonSet);
carbonConsumeList.add(carbonConsume);
nitConsumeList.add(nitConsume);
ammoniaConsumeList.add(ammoniaConsume);
}
}
//油搅拌转速趋势
List<ParRotSpeedValue> parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper<ParRotSpeedValue>()
.eq(ParEleValue.KILN_ID, kilnId)
.eq(ParEleValue.TASK_ID, taskId));
if (parRotSpeedValueList.size() > 0) {
if (kilnType == 1) {
List<EnergyVo> rot1Consume = new ArrayList<>();
List<EnergyVo> rot2Consume = new ArrayList<>();
for (ParRotSpeedValue parRotSpeedValue : parRotSpeedValueList
) {
EnergyVo rot1Vo = EnergyVo.builder().build();
rot1Vo.setCode(currTask.getStoveCode());
rot1Vo.setUnit("转/min");
rot1Vo.setName("1号油搅拌转速");
rot1Vo.setValue(parRotSpeedValue.getOilStiSpeedAValue());
rot1Vo.setTime(parRotSpeedValue.getCreateTime());
rot1Consume.add(rot1Vo);
EnergyVo rot2Vo = EnergyVo.builder().build();
rot2Vo.setCode(currTask.getStoveCode());
rot2Vo.setUnit("转/min");
rot2Vo.setName("2号油搅拌转速");
rot2Vo.setValue(parRotSpeedValue.getOilStiSpeedBValue());
rot2Vo.setTime(parRotSpeedValue.getCreateTime());
rot2Consume.add(rot2Vo);
}
rot1ConsumeList.add(rot1Consume);
rot2ConsumeList.add(rot2Consume);
}
}
//温度趋势(实际温度、设定温度)油槽温度外区温度
List<ParTemValue> parTemValueList = parTemValueServiceBiz.list(new QueryWrapper<ParTemValue>()
.eq(ParEleValue.KILN_ID, kilnId)
.eq(ParEleValue.TASK_ID, taskId));
if (parTemValueList.size() > 0) {
if (kilnType == 1) {
List<EnergyVo> actualTempConsume = new ArrayList<>();
List<EnergyVo> setupTempConsume = new ArrayList<>();
List<EnergyVo> actualOilTempConsume = new ArrayList<>();
List<EnergyVo> setupOilTempConsume = new ArrayList<>();
for (ParTemValue parTemValue : parTemValueList
) {
EnergyVo actTempVo = EnergyVo.builder().build();
actTempVo.setTime(parTemValue.getCreateTime());
actTempVo.setCode(currTask.getStoveCode());
actTempVo.setUnit("");
actTempVo.setValue(parTemValue.getActTemValue());
actTempVo.setName("实际温度");
actualTempConsume.add(actTempVo);
EnergyVo setTempVo = EnergyVo.builder().build();
setTempVo.setTime(parTemValue.getCreateTime());
setTempVo.setCode(currTask.getStoveCode().concat("-设定"));
setTempVo.setUnit("");
setTempVo.setValue(parTemValue.getSetTemValue());
setTempVo.setName("设定温度");
setupTempConsume.add(setTempVo);
EnergyVo oilSetTempVo = EnergyVo.builder().build();
oilSetTempVo.setTime(parTemValue.getCreateTime());
oilSetTempVo.setCode(currTask.getStoveCode().concat("-设定"));
oilSetTempVo.setUnit("");
oilSetTempVo.setValue(parTemValue.getOilTankSetTemValue());
oilSetTempVo.setName("油槽设定温度");
setupOilTempConsume.add(oilSetTempVo);
EnergyVo oilActTempVo = EnergyVo.builder().build();
oilActTempVo.setTime(parTemValue.getCreateTime());
oilActTempVo.setCode(currTask.getStoveCode());
oilActTempVo.setUnit("");
oilActTempVo.setValue(parTemValue.getOilTankActTemValue());
oilActTempVo.setName("油槽实际温度");
actualOilTempConsume.add(oilActTempVo);
}
tempConsumeList.add(actualTempConsume);
tempConsumeList.add(setupTempConsume);
oilTempConsumeList.add(actualOilTempConsume);
oilTempConsumeList.add(setupOilTempConsume);
}
if (kilnType == 2) {
List<EnergyVo> actualTempConsume = new ArrayList<>();
List<EnergyVo> setupTempConsume = new ArrayList<>();
for (ParTemValue parTemValue : parTemValueList
) {
EnergyVo actTempVo = EnergyVo.builder().build();
actTempVo.setTime(parTemValue.getCreateTime());
actTempVo.setCode(currTask.getStoveCode());
actTempVo.setUnit("");
actTempVo.setValue(parTemValue.getActTemValue());
actTempVo.setName("实际温度");
actualTempConsume.add(actTempVo);
EnergyVo setTempVo = EnergyVo.builder().build();
setTempVo.setTime(parTemValue.getCreateTime());
setTempVo.setCode(currTask.getStoveCode().concat("-设定"));
setTempVo.setUnit("");
setTempVo.setValue(parTemValue.getSetTemValue());
setTempVo.setName("设定温度");
setupTempConsume.add(setTempVo);
}
tempConsumeList.add(actualTempConsume);
tempConsumeList.add(setupTempConsume);
;
}
if (kilnType == 3) {
List<EnergyVo> actualTempConsume = new ArrayList<>();
List<EnergyVo> setupTempConsume = new ArrayList<>();
List<EnergyVo> outerZone1TempConsume = new ArrayList<>();
List<EnergyVo> outerZone2TempConsume = new ArrayList<>();
for (ParTemValue parTemValue : parTemValueList
) {
EnergyVo actTempVo = EnergyVo.builder().build();
actTempVo.setTime(parTemValue.getCreateTime());
actTempVo.setCode(currTask.getStoveCode());
actTempVo.setUnit("");
actTempVo.setValue(parTemValue.getActTemValue());
actTempVo.setName("实际温度");
actualTempConsume.add(actTempVo);
EnergyVo setTempVo = EnergyVo.builder().build();
setTempVo.setTime(parTemValue.getCreateTime());
setTempVo.setCode(currTask.getStoveCode().concat("-设定"));
setTempVo.setUnit("");
setTempVo.setValue(parTemValue.getSetTemValue());
setTempVo.setName("设定温度");
setupTempConsume.add(setTempVo);
EnergyVo outer1TempVo = EnergyVo.builder().build();
outer1TempVo.setTime(parTemValue.getCreateTime());
outer1TempVo.setCode(currTask.getStoveCode());
outer1TempVo.setUnit("");
outer1TempVo.setValue(parTemValue.getOuterZone1Temp());
outer1TempVo.setName("外一区温度");
outerZone1TempConsume.add(outer1TempVo);
EnergyVo outer2TempVo = EnergyVo.builder().build();
outer2TempVo.setTime(parTemValue.getCreateTime());
outer2TempVo.setCode(currTask.getStoveCode());
outer2TempVo.setUnit("");
outer2TempVo.setValue(parTemValue.getOuterZone2Temp());
outer2TempVo.setName("外二区温度");
outerZone2TempConsume.add(outer2TempVo);
}
tempConsumeList.add(actualTempConsume);
tempConsumeList.add(setupTempConsume);
outerZone1TempConsumeList.add(outerZone1TempConsume);
outerZone2TempConsumeList.add(outerZone2TempConsume);
}
}
map.put("checkResult", checkResultList);
map.put("ele", eleConsumeList);
map.put("aVol", aVolConsumeList);
map.put("bVol", bVolConsumeList);
map.put("cVol", cVolConsumeList);
map.put("aCurr", aCurrentList);
map.put("bCurr", bCurrentList);
map.put("cCurr", cCurrentList);
map.put("carbon", carbonList);
map.put("nit", nitConsumeList);
map.put("met", metConsumeList);
map.put("propane", propaneConsumeList);
map.put("ammon", ammoniaConsumeList);
map.put("car", carbonConsumeList);
map.put("rot1", rot1ConsumeList);
map.put("rot2", rot2ConsumeList);
map.put("temp", tempConsumeList);
map.put("oilTemp", oilTempConsumeList);
map.put("outerZone1Temp",outerZone1TempConsumeList);
map.put("outerZone2Temp",outerZone2TempConsumeList);
return successful(JSONObject.parseObject(JSON.toJSONString(map)));
}
private Boolean kilnWorking(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
private Boolean kilnOnline(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "ManualAutomatic");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
/**
* 获取变量值
*
* @param nameSpace nameSpace前缀
* @param variableName 变量名称
* @return 变量值
*/
private Double readPlc(String nameSpace, String variableName) {
String identifier = nameSpace.concat(variableName);
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier", identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("能源消耗统计:获取 " + identifier + " 的值失败");
}
return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
}
/**
* 获取变量值
*
* @param nameSpace nameSpace前缀
* @param variableName 变量名称
* @return result字符串
*/
private String readPlcToString(String nameSpace, String variableName) {
String identifier = nameSpace.concat(variableName);
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier", identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("readPLC " + identifier + " 的值失败");
}
return result;
}
private Float floatSubtract(Float a, Float b) {
BigDecimal a1 = new BigDecimal(Float.toString(a));
BigDecimal b1 = new BigDecimal(Float.toString(b));
return a1.subtract(b1).floatValue();
}
}

View File

@@ -0,0 +1,17 @@
package com.mt.wms.empty.mapper;
import com.mt.wms.empty.vo.CountEleVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author: LGH
* @Date: 2022/12/27
*/
public interface EleMapper {
/**
* 获取最近十条电能统计值
*/
List<CountEleVo> list(@Param("kilnId") Long kilnId);
}

View File

@@ -0,0 +1,11 @@
package com.mt.wms.empty.service;
import com.mt.wms.core.vo.R;
/**
* @Author: LGH
* @Date: 2022/12/27
*/
public interface EleService {
R list(Long kilnId);
}

View File

@@ -17,6 +17,7 @@ import com.mt.wms.empty.enums.TaskTypeEnum;
import com.mt.wms.empty.params.*;
import com.mt.wms.empty.service.*;
import com.mt.wms.empty.task.RunTaskUtils;
import com.mt.wms.empty.task.StoveCodeUtils;
import com.mt.wms.empty.task.TaskDistanceUtils;
import com.mt.wms.empty.vo.*;
import com.mt.wms.empty.websocket.WebSocketServer;
@@ -78,6 +79,10 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
CurrTaskDetServiceBiz currTaskDetServiceBiz;
@Autowired
InStockInfoServiceBiz inStockInfoServiceBiz;
@Autowired
TaskDetHisServiceBiz taskDetHisServiceBiz;
@Autowired
TaskHisServiceBiz taskHisServiceBiz;
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
@@ -389,6 +394,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
if (!status.equals(currTask.getStatus())) {
//修改为加工中,多步骤任务修改为加工中,查询缓存区,查询前置任务状态,并修改
if (status == 1) {
currTask.setStatus(1);
currTask.setIsIn(1);
currTask.setUpdaterId(99);
currTask.setUpdateTime(LocalDateTime.now());
currTask.setBeginTime(LocalDateTime.now());
//生产炉号
createStoveCode(currTask);
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>().eq(InStockInfo.TASK_ID, currTask.getId()));
if (inStockInfo != null) {
//更新库位状态为未占用
@@ -419,6 +431,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
currTask1.setUpdaterId(99);
currTask1.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask1);
apmsEndProcess(currTask1);
apmsStartProcess(currTask);
} else if (currTask.getId().equals(autoExeTask.getThTaskId())) {
//该任务为自动任务第三条,修改自动任务第二条的状态
CurrTask currTask2 = currTaskServiceBiz.getById(autoExeTask.getFTaskId());
@@ -428,13 +442,11 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
currTask2.setUpdaterId(99);
currTask2.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask2);
apmsEndProcess(currTask2);
apmsStartProcess(currTask);
}
}
currTask.setStatus(1);
currTask.setIsIn(1);
currTask.setUpdaterId(99);
currTask.setUpdateTime(LocalDateTime.now());
currTask.setBeginTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
logger.info("修改任务" + currTask.getId() + "状态为加工中成功");
}
@@ -448,12 +460,23 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
locationServiceBiz.updateById(location);
//删除库位缓存
inStockInfoServiceBiz.removeById(inStockInfo);
}
currTask.setStatus(1);
currTask.setCreatorId(99);
currTask.setBeginTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
logger.info("修改任务" + currTask.getId() + "状态为加工完成成功");
//存入历史任务表以便查询能源消耗
TaskHis taskHis = new TaskHis();
org.springframework.beans.BeanUtils.copyProperties(currTask, taskHis);
taskHis.setStatus(2);
taskHis.setIsIn(2);
taskHis.setTaskId(currTask.getId());
taskHisServiceBiz.save(taskHis);
List<CurrTaskDet> currTaskDets = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId()));
List<TaskDetHis> taskDetHisList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDets, TaskDetHis.class);
taskDetHisServiceBiz.saveBatch(taskDetHisList);
}
currTask.setStatus(status);
currTask.setCreatorId(99);
@@ -679,6 +702,9 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
if (currTask.getStatus() != 0) {
return R.failed("该任务状态不为未执行,无法执行!");
}
if (currTask.getCacheSatatus()==2&&currTask.getIsCache()==1){
return R.failed("该任务已在缓存队列,状态不为未执行,无法执行!");
}
//是否为自动任务
if (currTask.getIsAuto() == 1) {
List<AutoExeTask> exeTaskList = autoExeTaskServiceBiz.list(new QueryWrapper<AutoExeTask>().eq(AutoExeTask.F_TASK_ID, taskId));
@@ -778,4 +804,80 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
return true;
}
}
/**
* 上报apms开始加工
*
* @param currTask
* @return
*/
private Boolean apmsStartProcess(CurrTask currTask) {
String code = kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode();
ApmsStartProcess apmsStartProcess = new ApmsStartProcess();
apmsStartProcess.setStartUser("QJJP03");
apmsStartProcess.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsStartProcess.setTechName(currTask.getCraftCodeId().toString());
apmsStartProcess.setSheetNo(currTask.getSheetNo());
if (currTask.getStoveCode() != null) {
apmsStartProcess.setStoveCode(currTask.getStoveCode());
}
R<ApmsStartProcess> apmsStartProcessR = apmsControl.startProcess(apmsStartProcess);
if (apmsStartProcessR.getCode() != 0) {
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败");
return false;
}
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms成功");
return true;
}
/**
* 上报apms-end
*
* @param currTask
* @return
*/
private Boolean apmsEndProcess(CurrTask currTask) {
ApmsEndProcess apmsEndProcess = new ApmsEndProcess();
LocalDateTime date=LocalDateTime.now();
if (currTask.getEndTime()!=null){
date=currTask.getEndTime();
}
apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsEndProcess.setEndUser("QJJP03");
apmsEndProcess.setSheetNo(currTask.getSheetNo());
R<ApmsEndProcessVo> apmsEndProcessVoR = apmsControl.endProcess(apmsEndProcess);
if (apmsEndProcessVoR.getCode() != 0) {
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms失败");
return false;
}
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms成功");
return true;
}
/**
* 生成炉号
* 多步骤任务除了第一步为清洗炉外,每步都生成炉号
* 单步骤任务都生成炉号
*/
private void createStoveCode(CurrTask currTask) {
//单步骤任务,直接生成炉号
if (currTask.getIsAuto() == 0) {
String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue());
currTask.setStoveCode(stoveCode);
currTaskServiceBiz.updateById(currTask);
return;
}
//多步骤任务,只有BMA,BMB步骤生成炉号
else {
//获取加工炉
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId());
//只有BMA,BMB生成炉号
if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) {
String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue());
currTask.setStoveCode(stoveCode);
currTaskServiceBiz.updateById(currTask);
} else {
logger.info(currTask.getId() + "任务为多步骤任务但该步骤不生成洗炉炉号.");
}
}
}
}

View File

@@ -0,0 +1,46 @@
package com.mt.wms.empty.service.impl;
import com.mt.wms.core.base.BaseService;
import com.mt.wms.core.dal.entity.CurrTask;
import com.mt.wms.core.dal.service.CurrTaskServiceBiz;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.mapper.EleMapper;
import com.mt.wms.empty.service.EleService;
import com.mt.wms.empty.vo.CountEleVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: LGH
* @Date: 2022/12/27
*/
@Service
public class EleServiceImpl extends BaseService implements EleService {
@Resource
EleMapper eleMapper;
@Resource
CurrTaskServiceBiz currTaskServiceBiz;
@Override
public R list(Long kilnId) {
List<CountEleVo> list = eleMapper.list(kilnId);
for (CountEleVo countEleVo:list
) {
CurrTask currTask = currTaskServiceBiz.getById(countEleVo.getTaskId());
if (currTask.getStoveCode()==null){
if (currTask.getSheetNo()!=null){
currTask.setStoveCode(currTask.getSheetNo());
}else {
currTask.setStoveCode(currTask.getTaskCode());
}
}
countEleVo.setStoveCode(currTask.getStoveCode());
countEleVo.setCreateTime(currTask.getCreateTime());
}
return successful(list);
}
}

View File

@@ -119,6 +119,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
.like(StringUtils.isNotBlank(param.getOrderNo()), OrderInfo.ORDER_NO, param.getOrderNo())
.like(StringUtils.isNotBlank(param.getCustomerName()),OrderInfo.CUSTOMER_NAME,param.getCustomerName())
.in(OrderInfo.STATUS,0,1)
.eq(OrderInfo.ORDER_VOID,1)
.orderByDesc(OrderInfo.CREATE_TIME);
Page<OrderInfo> page = orderInfoService.page(new Page<>(param.getCurrent(), param.getSize()), wrapper);
PageVo<OrderInfoVo> orderInfoVoPageVo = new PageVo<>(page, OrderInfoVo.class);
@@ -219,7 +220,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
@Override
public R<OrderInfoVo> getTaskInfoByIdenCardNum(String idenCardNum) {
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.eq(OrderInfo.IDEN_CARD_NUM, idenCardNum).eq(OrderInfo.VALID, 1);
wrapper.eq(OrderInfo.IDEN_CARD_NUM, idenCardNum).eq(OrderInfo.VALID, 1).eq(OrderInfo.ORDER_VOID,1);
OrderInfo one = orderInfoService.getOne(wrapper);
Assert.notNull("未找到该标识卡信息!", one);
OrderInfoVo build = OrderInfoVo.builder().build();
@@ -261,7 +262,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
for (TaskCreateDetParam detParam : detParams)
{
QueryWrapper<OrderInfo> wrapper = new QueryWrapper<>();
wrapper.eq(OrderInfo.IDEN_CARD_NUM, detParam.getIdenCardNum()).eq(OrderInfo.VALID, 1);
wrapper.eq(OrderInfo.IDEN_CARD_NUM, detParam.getIdenCardNum()).eq(OrderInfo.VALID, 1).eq(OrderInfo.ORDER_VOID,1);
OrderInfo one = orderInfoService.getOne(wrapper);
Assert.notNull("错误,标识卡号" + detParam.getIdenCardNum() + "在订单中不存在!", one);
}

View File

@@ -507,15 +507,15 @@ public class AsynRunTaskService extends BaseService {
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, kilnInfo.getCode(), yeyaTaiCode, rgv2CurrPosition);
if (conflictBoolean) {
Integer status = moveRgv(2, 1L, 2, 0);
Integer status = moveRgv(2, 1L, 1, 0);
logger.info(status.toString());
if (status != 1) {
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败===");
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败");
} else {
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行成功===");
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行成功===");
}
}
} else {
@@ -606,14 +606,14 @@ public class AsynRunTaskService extends BaseService {
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition);
if (conflictBoolean) {
Integer status = moveRgv(2, 1L, 2, 0);
Integer status = moveRgv(2, 1L, 1, 0);
if (status != 1) {
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39,执行失败===");
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39执行失败");
return;
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39,执行成功===");
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行成功===");
}
} else {
logger.info("RGV2不在线跳过检测是否避让。");
@@ -629,12 +629,12 @@ public class AsynRunTaskService extends BaseService {
if (conflictBoolean) {
Integer status = moveRgv(1, 1L, 12, 0);
if (status != 1) {
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1执行失败===");
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位12,执行失败===");
// 2022/3/6 websocket通知页面
webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1执行失败");
return;
}
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1执行成功===");
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位12,执行成功===");
}
} else {
logger.info("RGV1不在线跳过检测是否避让。");
@@ -1331,8 +1331,12 @@ public class AsynRunTaskService extends BaseService {
* @return
*/
private Boolean apmsEndProcess(CurrTask currTask) {
LocalDateTime date=LocalDateTime.now();
if (currTask.getEndTime()!=null){
date=currTask.getEndTime();
}
ApmsEndProcess apmsEndProcess = new ApmsEndProcess();
apmsEndProcess.setEndTime(currTask.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsEndProcess.setEndUser("QJJP03");
apmsEndProcess.setSheetNo(currTask.getSheetNo());
R<ApmsEndProcessVo> apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess);
@@ -1424,13 +1428,13 @@ public class AsynRunTaskService extends BaseService {
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv2CurrPosition);
if (conflictBoolean) {
Integer status = moveRgv(2, currTaskId, 2, 0);
Integer status = moveRgv(2, currTaskId, 1, 0);
logger.info(status.toString());
if (status != 1) {
logger.info("===执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败===");
logger.info("===执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行失败===");
webSocketServer.sendtoAll(LocalDateTime.now() + "执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2执行失败");
} else {
logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行成功===");
logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行成功===");
}
}
} else {

View File

@@ -63,6 +63,7 @@ public class RunTaskUtils {
/**
* 进炉加工
*
* @param currTaskId 任务id
* @return R
* @throws InterruptedException
@@ -74,25 +75,25 @@ public class RunTaskUtils {
PointInfo startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, startPosition));
// 可以根据点位类型判断起点是否为液压台(2是液压台)
Integer startPointType = startPoint.getType();
if (startPointType==2){
if (startPointType == 2) {
Map<String, Object> yeya = new HashMap();
//type=1为 入
yeya.put("type", 1);
if ("YYT003".equals(currTask.getStartPosition())){
if ("YYT003".equals(currTask.getStartPosition())) {
yeya.put("number", 3);
}
if ("YYT004".equals(currTask.getStartPosition())){
if ("YYT004".equals(currTask.getStartPosition())) {
yeya.put("number", 4);
}
if ("YYT002".equals(currTask.getStartPosition())){
if ("YYT002".equals(currTask.getStartPosition())) {
yeya.put("number", 2);
}
if ("YYT001".equals(currTask.getStartPosition())){
if ("YYT001".equals(currTask.getStartPosition())) {
yeya.put("number", 1);
}
String yeyaJudgeStatus = JSON.toJSONString(yeya);
//判断起点液压台是否已放货且提升到位
String yeyaStatus=null;
String yeyaStatus = null;
try {
yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
} catch (IOException e) {
@@ -100,13 +101,13 @@ public class RunTaskUtils {
logger.error(new Date() + "WCS接口超时未响应");
}
//taskStatus==3满足条件其他状态值说明液压台不满足开始任务的条件无货物或者有货物但是没提升到位
if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1){
return R.failed(startPoint.getName()+"号液压台不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1) {
return R.failed(startPoint.getName() + "号液压台不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
}
}
//是否有小车在运行
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
if (vehicleInfoList.size()>0){
if (vehicleInfoList.size() > 0) {
//有小车在运行,提示当前有车辆在运行,请稍后
return R.failed("当前轨道有RGV车辆在运动请等待当前RGV车辆执行完毕再执行任务");
}
@@ -122,10 +123,10 @@ public class RunTaskUtils {
return R.failed("目标工业炉不可用!");
}
//工业炉可用未满
if (resultBoolean){
if (resultBoolean) {
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
if (vehicleId==0){
if (vehicleId == 0) {
logger.info("两辆车都不在线,请检查后重试!");
return R.failed("两辆车都不在线,请检查后重试!");
}
@@ -139,7 +140,7 @@ public class RunTaskUtils {
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//异步调用车辆
asynRunTaskService.asynRunTask(currTask.getId(),vehicleId);
asynRunTaskService.asynRunTask(currTask.getId(), vehicleId);
return R.ok("操作成功,任务已开始执行。");
} else {
//工业炉已满
@@ -148,14 +149,14 @@ public class RunTaskUtils {
.eq(Location.STATUS, 0)
.eq(Location.VALID, 1));
//缓存区未满
if (count >0) {
if (count > 0) {
//分配一个缓存区库位
Location location = locationServiceBiz.list(new QueryWrapper<Location>()
.eq(Location.STATUS, 0)
.eq(Location.VALID, 1)).get(0);
//计算出路径最短的车辆id,起点液压台,终点缓存区库位点
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), location.getCode());
if (vehicleId==0){
if (vehicleId == 0) {
logger.info("两辆车都不在线,请检查后重试!");
return R.failed("两辆车都不在线,请检查后重试!");
}
@@ -180,7 +181,7 @@ public class RunTaskUtils {
currTask.setLocationName(location.getLocationName());
currTaskServiceBiz.updateById(currTask);
//异步调用车辆
asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleId,location);
asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(), vehicleId, location);
return R.ok("操作成功!当前目标工业炉已满,托盘准备加入缓存区待加工队列。");
}
return R.failed("当前目标工业炉已满!缓存区已满!请稍后重试!");
@@ -191,6 +192,7 @@ public class RunTaskUtils {
* 加工完成、出炉。传入工业炉id查询正在该工业炉加工的currTask,查询是否有空闲车辆,有,
* (查询是否为自动任务,是,查询下一步的工业炉是否空闲,是,调车去下一工业炉加工,否,暂存缓存区)
* 呼叫车辆暂存缓存区车辆调度任务结束后结束后再查询缓R存区队列避免车辆路线冲突查询该工业炉的缓存区队列开始下一托盘货物调度进工业炉
*
* @return R
*/
public R runTaskForOutKiln(Long kilnId) throws IOException {
@@ -199,7 +201,7 @@ public class RunTaskUtils {
.eq("is_in", 1)
.eq("status", 1)
.eq("kiln_id", kilnId).orderByAsc(CurrTask.BEGIN_TIME));
if (currTaskList.size()==0){
if (currTaskList.size() == 0) {
return R.failed();
}
CurrTask currTask = currTaskList.get(0);
@@ -267,8 +269,17 @@ public class RunTaskUtils {
vehicleInfo.setStatus(1);
vehicleInfo.setUpdateTime(LocalDateTime.now());
vehicleInfoServiceBiz.updateById(vehicleInfo);
asynRunTaskService.asynRunOutStockForKilnToYYT(currTask.getId(),"YYT001",vehicleId);
return R.ok("操作成功!托盘即将出库到一号液压台。");
String yytCode = "YYT001";
//选择出库液压台
if (platFormPosition("YYT001")) {
yytCode = "YYT001";
} else if (platFormPosition("YYT002")) {
yytCode = "YYT002";
} else {
yytCode = "YYT001";
}
asynRunTaskService.asynRunOutStockForKilnToYYT(currTask.getId(), yytCode, vehicleId);
return R.ok("操作成功!托盘即将出库到" + yytCode + "液压台。");
} else {
//查询缓存区库位是否已满
int count = locationServiceBiz.count(new QueryWrapper<Location>()
@@ -318,49 +329,50 @@ public class RunTaskUtils {
/**
* 从缓存区出库
* @param locationId 库位id
*
* @param locationId 库位id
* @param yeyaTaiCode 液压台code
* @return R
*/
public R runTaskForOut(Long locationId,String yeyaTaiCode) throws IOException {
public R runTaskForOut(Long locationId, String yeyaTaiCode) throws IOException {
Location location = locationServiceBiz.getById(locationId);
//是否有小车在运行
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
if (vehicleInfoList.size()>0){
if (vehicleInfoList.size() > 0) {
//有小车在运行,提示当前有车辆在运行,请稍后
return R.failed("当前轨道有RGV车辆在运动请等待当前RGV车辆执行完毕再执行任务");
}
Map<String, Object> yeya = new HashMap();
//type=1随意赋值不用type了
yeya.put("type", 1);
if ("YYT003".equals(yeyaTaiCode)){
yeya.put("number", 3);
}
if ("YYT004".equals(yeyaTaiCode)){
yeya.put("number", 4);
}
if ("YYT002".equals(yeyaTaiCode)){
yeya.put("number", 2);
}
if ("YYT001".equals(yeyaTaiCode)){
yeya.put("number", 1);
}
String yeyaJudgeStatus = JSON.toJSONString(yeya);
//判断起点液压台是否在线且提升到位
String yeyaStatus=null;
try {
yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
} catch (IOException e) {
e.printStackTrace();
logger.error(new Date() + "WCS接口超时未响应");
}
//taskStatus==3满足条件其他状态值说明液压台不满足开始任务的条件无货物或者有货物但是没提升到位
if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1){
return R.failed("液压台"+yeyaTaiCode+"不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
}
Map<String, Object> yeya = new HashMap();
//type=1随意赋值不用type了
yeya.put("type", 1);
if ("YYT003".equals(yeyaTaiCode)) {
yeya.put("number", 3);
}
if ("YYT004".equals(yeyaTaiCode)) {
yeya.put("number", 4);
}
if ("YYT002".equals(yeyaTaiCode)) {
yeya.put("number", 2);
}
if ("YYT001".equals(yeyaTaiCode)) {
yeya.put("number", 1);
}
String yeyaJudgeStatus = JSON.toJSONString(yeya);
//判断起点液压台是否在线且提升到位
String yeyaStatus = null;
try {
yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
} catch (IOException e) {
e.printStackTrace();
logger.error(new Date() + "WCS接口超时未响应");
}
//taskStatus==3满足条件其他状态值说明液压台不满足开始任务的条件无货物或者有货物但是没提升到位
if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1) {
return R.failed("液压台" + yeyaTaiCode + "不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
}
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), yeyaTaiCode);
if (vehicleId==0){
if (vehicleId == 0) {
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
@@ -369,7 +381,7 @@ public class RunTaskUtils {
vehicleInfo.setUpdateTime(LocalDateTime.now());
vehicleInfoServiceBiz.updateById(vehicleInfo);
//异步调用车辆
asynRunTaskService.asynRunOutStock(locationId,yeyaTaiCode,vehicleInfo.getId());
asynRunTaskService.asynRunOutStock(locationId, yeyaTaiCode, vehicleInfo.getId());
// TODO: 2022/3/19
System.out.println("操作成功,任务已开始执行。");
return R.ok("操作成功,任务已开始执行。");
@@ -377,39 +389,41 @@ public class RunTaskUtils {
/**
* 获取变量值
* @param nameSpace nameSpace前缀
*
* @param nameSpace nameSpace前缀
* @param variableName 变量名称
* @return result字符串
*/
private String readPlcToString(String nameSpace, String variableName){
String identifier=nameSpace.concat(variableName);
private String readPlcToString(String nameSpace, String variableName) {
String identifier = nameSpace.concat(variableName);
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier);
json.put("identifier", identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("readPLC "+identifier+" 的值失败");
logger.info("readPLC " + identifier + " 的值失败");
}
return result;
}
/**
* 判断液压台是否准备好放货
*
* @param platFormCode 液压台编码
* @return 是/否
*/
private Boolean platFormStatus(String platFormCode){
String identifier=null;
if ("YYT001".equals(platFormCode)){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
private Boolean platFormStatus(String platFormCode) {
String identifier = null;
if ("YYT001".equals(platFormCode)) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier+"Online");
json.put("identifier", identifier + "Online");
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
@@ -418,11 +432,11 @@ public class RunTaskUtils {
logger.info("获取液压台1当前是否在线失败");
}
Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (aBoolean){
if (aBoolean) {
Map<String, Object> statusJson = new HashMap();
statusJson.put("nameSpace", 6);
statusJson.put("plcName", "plc1");
statusJson.put("identifier",identifier+"TaskState");
statusJson.put("identifier", identifier + "TaskState");
String statusResult = null;
try {
statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
@@ -431,21 +445,21 @@ public class RunTaskUtils {
logger.info("获取液压台1当前状态失败");
}
Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
if (status==1){
if (status == 1) {
return true;
}else {
} else {
return false;
}
}else {
} else {
return false;
}
}
if ("YYT002".equals(platFormCode)){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
if ("YYT002".equals(platFormCode)) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier+"Online");
json.put("identifier", identifier + "Online");
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
@@ -454,11 +468,11 @@ public class RunTaskUtils {
logger.info("获取液压台2当前是否在线失败");
}
Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (aBoolean){
if (aBoolean) {
Map<String, Object> statusJson = new HashMap();
statusJson.put("nameSpace", 6);
statusJson.put("plcName", "plc1");
statusJson.put("identifier",identifier+"TaskState");
statusJson.put("identifier", identifier + "TaskState");
String statusResult = null;
try {
statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
@@ -467,41 +481,124 @@ public class RunTaskUtils {
logger.info("获取液压台2当前状态失败");
}
Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
if (status==1){
if (status == 1) {
return true;
}else {
} else {
return false;
}
}else {
} else {
return false;
}
}
return false;
}
/**
* 选择出库液压台;
* 查询液压台1和液压台2是否为高位,都不为高位则选择液压台1
*/
private Boolean platFormPosition(String platFormCode) {
String identifier = null;
if ("YYT001".equals(platFormCode)) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier", identifier + "Online");
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取液压台1当前是否在线失败");
}
Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (aBoolean) {
Map<String, Object> statusJson = new HashMap();
statusJson.put("nameSpace", 6);
statusJson.put("plcName", "plc1");
statusJson.put("identifier", identifier + "LifterPosition");
String statusResult = null;
try {
statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取液压台1当前是否高位");
}
Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
if (status == 2) {
return true;
} else {
return false;
}
} else {
return false;
}
}
if ("YYT002".equals(platFormCode)) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier", identifier + "Online");
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取液压台2当前是否在线失败");
}
Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (aBoolean) {
Map<String, Object> statusJson = new HashMap();
statusJson.put("nameSpace", 6);
statusJson.put("plcName", "plc1");
statusJson.put("identifier", identifier + "LifterPosition");
String statusResult = null;
try {
statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取液压台2当前是否高位失败");
}
Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
if (status == 2) {
return true;
} else {
return false;
}
} else {
return false;
}
}
return false;
}
/**
* 车辆是否在线
*
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
* @throws IOException plc访问失败
*/
private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
String identifier = null;
if (vehicleId == 1) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
if (vehicleId == 2) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
}
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier);
json.put("identifier", identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败");
logger.info("获取车辆" + vehicleId + "当前是否在线失败");
}
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online;
@@ -509,28 +606,29 @@ public class RunTaskUtils {
/**
* 车辆是否空闲
*
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
* @throws IOException plc访问失败
*/
private Boolean rgvFree(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
String identifier = null;
if (vehicleId == 1) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
if (vehicleId == 2) {
identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
}
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier);
json.put("identifier", identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否空闲失败");
logger.info("获取车辆" + vehicleId + "当前是否空闲失败");
}
Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return free;

View File

@@ -12,6 +12,9 @@ import com.mt.wms.core.utils.CodeGeneratorHelper;
import com.mt.wms.core.utils.HttpClient;
import com.mt.wms.core.utils.StringUtils;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.controller.ApmsController;
import com.mt.wms.empty.params.ApmsEndProcess;
import com.mt.wms.empty.vo.ApmsEndProcessVo;
import com.mt.wms.empty.vo.CurrTaskDetVo;
import com.mt.wms.empty.vo.NowCurrTaskDetVo;
import com.mt.wms.empty.websocket.WebSocketServer;
@@ -25,6 +28,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -81,6 +85,8 @@ public class ScheduledTask extends BaseService {
private TaskHisServiceBiz taskHisServiceBiz;
@Resource
private TaskDetHisServiceBiz taskDetHisServiceBiz;
@Resource
private ApmsController apmsController;
//@Scheduled(fixedDelay = 1000*20)
@@ -158,6 +164,7 @@ public class ScheduledTask extends BaseService {
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
nowCurrTask.setTaskCode(nowCurrTask.getSheetNo());
nowCurrTask.setKilnCode(kilnInfo.getCode());
nowCurrTask.setTaskId(nowCurrTask.getId());
//设定时间
Integer setupTime = 1;
//剩余时间
@@ -242,6 +249,8 @@ public class ScheduledTask extends BaseService {
taskDetHisServiceBiz.saveBatch(taskDetHisList);
//加工结束而没有立马出炉,加工结束记录能源消耗值只记录一次
asynRunTaskService.asynEndRecordConsume(currTask.getId(), kilnId);
apmsEndProcess(currTask);
logger.info(currTask+"上报apms结束当前工艺加工");
logger.info(kilnInfo.getCode() + "炉子中的任务:" + currTask.getId() + "已加工结束,记录加工结束能源消耗值");
}
runTaskUtils.runTaskForOutKiln(kilnId);
@@ -305,7 +314,7 @@ public class ScheduledTask extends BaseService {
Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2");
ParRotSpeedValue parRotSpeedValue = new ParRotSpeedValue();
parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue());
parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue());
parRotSpeedValue.setOilStiSpeedBValue(oilStirringSpeed2.floatValue());
parRotSpeedValue.setKilnId(kilnId);
parRotSpeedValue.setTaskId(currTaskId);
parRotSpeedValue.setCreateTime(LocalDateTime.now());
@@ -546,7 +555,7 @@ public class ScheduledTask extends BaseService {
//A向电压
Double phaseAVoltage = readPlc(nameSpaceNote, "AVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "Cvoltage");
//ABC三向电流
Double aCurrent = readPlc(nameSpaceNote, "ACurrent");
Double bCurrent = readPlc(nameSpaceNote, "BCurrent");
@@ -584,6 +593,9 @@ public class ScheduledTask extends BaseService {
if (vehicleInfos.size() > 0) {
return;
}
if (kilnStopRecTask(kilnInfo.getId())){
continue;
}
Boolean kilnReadyIn = false;
if (kilnInfo.getType() == 1) {
kilnReadyIn = kilnReadyIn(kilnInfo.getId());
@@ -791,6 +803,15 @@ public class ScheduledTask extends BaseService {
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
private Boolean kilnStopRecTask(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)
.eq(PlcNameSpace.TYPE, 0));
String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "StopRecTask");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
private Boolean kilnReadyIn(Long kilnId) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 0)
@@ -870,4 +891,27 @@ public class ScheduledTask extends BaseService {
Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return free;
}
/**
* 上报apms-end
*
* @param currTask
* @return
*/
private Boolean apmsEndProcess(CurrTask currTask) {
LocalDateTime date=LocalDateTime.now();
if (currTask.getEndTime()!=null){
date=currTask.getEndTime();
}
ApmsEndProcess apmsEndProcess = new ApmsEndProcess();
apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
apmsEndProcess.setEndUser("QJJP03");
apmsEndProcess.setSheetNo(currTask.getSheetNo());
R<ApmsEndProcessVo> apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess);
if (apmsEndProcessVoR.getCode() != 0) {
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms失败");
return false;
}
logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms成功");
return true;
}
}

View File

@@ -121,10 +121,10 @@ public class TaskDistanceUtils {
if (otherNowPosition>=minDistance&&otherNowPosition<=maxDistance){
return true;
}else {
if (Math.abs(otherNowPosition-maxDistance)<3.5){
if (Math.abs(otherNowPosition-maxDistance)<4){
return true;
}
if (Math.abs(otherNowPosition-minDistance)<3.5){
if (Math.abs(otherNowPosition-minDistance)<4){
return true;
}
return false;

View File

@@ -0,0 +1,44 @@
package com.mt.wms.empty.vo;
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/12/27
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "消耗数据视图对象", description = "用于查询消耗数据")
public class CountEleVo {
/**
* 时间
*/
@ApiModelProperty(value = "时间", example = "0")
private LocalDateTime createTime;
/**
* 消耗值
*/
@ApiModelProperty(value = "消耗值", example = "0.0")
private Float totalBat;
/**
* 名称
*/
@ApiModelProperty(value = "任务id", example = "0.0")
private Long taskId;
/**
* 炉号
*/
@ApiModelProperty(value = "炉号", example = "0.0")
private String stoveCode;
}

View File

@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -20,59 +21,74 @@ import java.util.List;
@Accessors(chain = true)
@Builder
@ApiModel(value = "当前正在加工炉任务详情视图对象", description = "用于查询当前正在加工炉任务详情")
public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{
public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo {
/**
* 主键,自增
*/
@ApiModelProperty(value = "主键", example = "1")
private Long id;
/**
* currtask任务id
*/
@ApiModelProperty(value = "currtask任务id", example = "0")
private Long taskId;
/**
* currtask任务code
*/
@ApiModelProperty(value = "currtask任务code",example = "0")
@ApiModelProperty(value = "currtask任务code", example = "0")
private String taskCode;
/**
* 炉号
*/
@ApiModelProperty(value = "炉号", example = "0")
private String stoveCode;
/**
* 生产单号
*/
@ApiModelProperty(value = "生产单号",example = "0")
@ApiModelProperty(value = "生产单号", example = "0")
private String sheetNo;
/**
* 炉子id
*/
@ApiModelProperty(value = "炉子id",example = "0")
@ApiModelProperty(value = "炉子id", example = "0")
private Long kilnId;
/**
* 炉子code
*/
@ApiModelProperty(value = "炉子code",example = "0")
@ApiModelProperty(value = "炉子code", example = "0")
private String kilnCode;
/**
* 工艺plc值
*/
@ApiModelProperty(value = "工艺plc值",example = "0")
@ApiModelProperty(value = "工艺plc值", example = "0")
private Integer plcValue;
/**
* 工艺设定时间
*/
@ApiModelProperty(value = "工艺设定时间",example = "0")
@ApiModelProperty(value = "工艺设定时间", example = "0")
private Integer setupTime;
/**
* 工艺剩余时间
*/
@ApiModelProperty(value = "工艺剩余时间",example = "0")
@ApiModelProperty(value = "工艺剩余时间", example = "0")
private Integer remainingTime;
/**
* 工艺进度
*/
@ApiModelProperty(value = "工艺进度",example = "0")
@ApiModelProperty(value = "工艺进度", example = "0")
private Integer completeness;
/**
* 开始加工时间
*/
@ApiModelProperty(value = "开始加工时间", example = "0")
private LocalDateTime beginTime;
/**
* 标识卡list
*/
@ApiModelProperty(value = "标识卡list",example = "0")
@ApiModelProperty(value = "标识卡list", example = "0")
private List<CurrTaskDetVo> currTaskDetVoList;
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018.
~ http://www.ulabcare.com
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mt.wms.empty.mapper.EleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.mt.wms.empty.vo.CountEleVo">
<id column="task_id" property="taskId"/>
<result column="create_time" property="createTime"/>
<result column="total_bat" property="totalBat"/>
</resultMap>
<!-- 根据角色查询菜单,角色已分配的菜单标记为选中状态 -->
<select id="list"
resultType="com.mt.wms.empty.vo.CountEleVo">
select
max(total_bat) as total_bat ,
task_id
from
t_par_ele_value tpev2
where
kiln_id = #{kilnId}
group by
task_id
order by
total_bat desc
limit 11
</select>
</mapper>