bug修改,日志文件配置

This commit is contained in:
李广豪 2022-03-20 21:41:49 +08:00
parent c8119c5bd0
commit 186a28bffc
11 changed files with 602 additions and 171 deletions

View File

@ -45,11 +45,11 @@
<spring.rabbitmq.username>guest</spring.rabbitmq.username>
<spring.rabbitmq.password>guest</spring.rabbitmq.password>
<!-- redis -->
<spring.redis.cluster.nodes>redis.picaiba.com:6380</spring.redis.cluster.nodes>
<!-- <spring.redis.cluster.nodes>redis.picaiba.com:6380</spring.redis.cluster.nodes>
<spring.redis.host>redis.picaiba.com</spring.redis.host>
<spring.redis.port>6380</spring.redis.port>
<spring.redis.password><![CDATA["@WSXcde3"]]></spring.redis.password>
<spring.redis.database>5</spring.redis.database>
<spring.redis.database>5</spring.redis.database>-->
<!-- database -->
<spring.datasource.url>jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false
</spring.datasource.url>
@ -98,11 +98,11 @@
<spring.rabbitmq.username>wms</spring.rabbitmq.username>
<spring.rabbitmq.password>wms</spring.rabbitmq.password>
<!-- redis -->
<spring.redis.cluster.nodes>redis.picaiba.com:6380</spring.redis.cluster.nodes>
<!-- <spring.redis.cluster.nodes>redis.picaiba.com:6380</spring.redis.cluster.nodes>
<spring.redis.host>redis.picaiba.com</spring.redis.host>
<spring.redis.port>6380</spring.redis.port>
<spring.redis.password><![CDATA["@WSXcde3"]]></spring.redis.password>
<spring.redis.database>10</spring.redis.database>
<spring.redis.database>10</spring.redis.database>-->
<!-- database -->
<spring.datasource.url>jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false
</spring.datasource.url>
@ -149,11 +149,11 @@
<spring.rabbitmq.username>wms</spring.rabbitmq.username>
<spring.rabbitmq.password>wms</spring.rabbitmq.password>
<!-- redis -->
<spring.redis.cluster.nodes>127.0.0.1:6379</spring.redis.cluster.nodes>
<!-- <spring.redis.cluster.nodes>127.0.0.1:6379</spring.redis.cluster.nodes>
<spring.redis.host>127.0.0.1</spring.redis.host>
<spring.redis.port>6379</spring.redis.port>
<spring.redis.password>2018</spring.redis.password>
<spring.redis.database>10</spring.redis.database>
<spring.redis.database>10</spring.redis.database>-->
<!-- database -->
<spring.datasource.url>jdbc:p6spy:mysql://localhost:3306/wms?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false
</spring.datasource.url>

View File

@ -87,6 +87,8 @@ public class VehicleController extends BaseController {
return successful(IDGenerator.gen("CL", "yyyyMMddHHmm", 2, "VEHICLE_CODE"));
}
@PostMapping(value = "resetStatus")
@ApiOperation(value = "重置车辆状态")
private R<String> reset(){
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
for (VehicleInfo vehicleInfo:vehicleInfoList

View File

@ -49,8 +49,8 @@ public class HttpClient {
public static String httpPost(String url, String json) throws IOException {
//OkHttpClient httpClient = new OkHttpClient();
OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(300L, TimeUnit.SECONDS)
.writeTimeout(300, TimeUnit.SECONDS)
.readTimeout(300, TimeUnit.SECONDS)
.writeTimeout(60*30, TimeUnit.SECONDS)
.readTimeout(60*30, TimeUnit.SECONDS)
.build();
RequestBody requestBody = RequestBody.create(JSON, json);
Request request = new Request.Builder()

View File

@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.validation.groups.Default;
import java.math.BigDecimal;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -79,6 +80,8 @@ public class EnergyController extends BaseController {
private KilnInfoServiceBiz kilnInfoServiceBiz;
@Autowired
private CurrTaskServiceBiz currTaskServiceBiz;
@Autowired
private TaskHisServiceBiz taskHisServiceBiz;
@PostMapping(value = "eletric")
@ApiOperation(value = "根据窑炉id获取消耗情况")
@ -215,8 +218,7 @@ public class EnergyController extends BaseController {
@PostMapping(value = "energyList")
@ApiOperation(value = "根据加工炉id获取能源消耗情况")
public R<String> energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){
electricQueryParam.getTaskId();
CurrTask currTask = currTaskServiceBiz.getById(electricQueryParam.getTaskId());
TaskHis currTask = taskHisServiceBiz.getById(electricQueryParam.getTaskId());
Long kilnId = currTask.getKilnId();
KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
Integer kilnType = kilnInfo.getType();
@ -224,25 +226,33 @@ public class EnergyController extends BaseController {
JSONObject jsonObject=new JSONObject();
ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build();
Map map=new HashMap();
Map<String,Object> map=new HashMap<>();
//电能消耗
List<ParEleValue> parEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
.eq(ParEleValue.KILN_ID, kilnId)
.eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId()));
if (parEleValueList.size()>0){
List eleList=new ArrayList();
List<Object> eleList=new ArrayList<>();
//电能消耗
List eleConsume=new ArrayList<>();
List<Object> eleConsume=new ArrayList<>();
//A向电压
List aVolConsume=new ArrayList<>();
List<Object> aVolConsume=new ArrayList<>();
//B向电压
List bVolConsume=new ArrayList<>();
List<Object> bVolConsume=new ArrayList<>();
//C向电压
List cVolConsume=new ArrayList<>();
List<Object> cVolConsume=new ArrayList<>();
Float talBat=0F;
int i=0;
for (ParEleValue parEleValue:parEleValueList
) {
//首位置为0
if (i==0){
talBat=parEleValue.getTotalBat();
}
i++;
map.put("time",parEleValue.getCreateTime());
map.put("value",parEleValue.getTotalBat());
map.put("value",floatSubtract(parEleValue.getTotalBat(),talBat));
map.put("name","耗电量");
map.put("unit","KW");
eleConsume.add(JSONObject.toJSON(map));
@ -278,37 +288,50 @@ public class EnergyController extends BaseController {
.eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId()));
if (parGasValueList.size()>0){
if (kilnType==1){
List gasList=new ArrayList();
List<Object> gasList=new ArrayList<>();
//氮气
List nitConsume=new ArrayList<>();
List<Object> nitConsume=new ArrayList<>();
Float nit=0F;
//甲醇
List metConsume=new ArrayList<>();
List<Object> metConsume=new ArrayList<>();
Float met=0F;
//丙烷
List propaneConsume=new ArrayList<>();
List<Object> propaneConsume=new ArrayList<>();
Float propane=0F;
//氨气
List ammoniaConsume=new ArrayList<>();
List<Object> ammoniaConsume=new ArrayList<>();
Float ammonia=0F;
int i=0;
for (ParGasValue parGasValue:parGasValueList
) {
//累计值的量首位置为0
if (i==0){
nit=parGasValue.getNitFlowValue();
met=parGasValue.getMethanolFlow();
propane=parGasValue.getPropaneFlow();
ammonia=parGasValue.getAmmoniaFlowValue();
}
i++;
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getNitFlowValue());
map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit));
map.put("name","氮气");
map.put("unit","");
nitConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getMethanolFlow());
map.put("value",floatSubtract(parGasValue.getMethanolFlow(),met));
map.put("name","甲醇");
map.put("unit","");
metConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getPropaneFlow());
map.put("value",floatSubtract(parGasValue.getPropaneFlow(),propane));
map.put("name","丙烷");
map.put("unit","");
propaneConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getAmmoniaFlowValue());
map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia));
map.put("name","氨气");
map.put("unit","");
ammoniaConsume.add(JSONObject.toJSON(map));
@ -321,29 +344,40 @@ public class EnergyController extends BaseController {
jsonObject.put("gas",gasList);
}
if (kilnType==3){
List gasList=new ArrayList();
List<Object> gasList=new ArrayList<>();
//氮气
List nitConsume=new ArrayList<>();
List<Object> nitConsume=new ArrayList<>();
Float nit=0F;
//二氧化碳
List carbonConsume=new ArrayList<>();
List<Object> carbonConsume=new ArrayList<>();
Float carbon=0F;
//氨气
List ammoniaConsume=new ArrayList<>();
List<Object> ammoniaConsume=new ArrayList<>();
Float ammonia=0F;
int i=0;
for (ParGasValue parGasValue:parGasValueList
) {
//累计值的量首位置为0
if (i==0){
nit=parGasValue.getNitFlowValue();
carbon=parGasValue.getCarDioxideFlowValue();
ammonia=parGasValue.getAmmoniaFlowValue();
}
i++;
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getNitFlowValue());
map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit));
map.put("name","氮气");
map.put("unit","");
nitConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getCarDioxideFlowValue());
map.put("value",floatSubtract(parGasValue.getCarDioxideFlowValue(),carbon));
map.put("name","二氧化碳");
map.put("unit","");
carbonConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parGasValue.getCreateTime());
map.put("value",parGasValue.getAmmoniaFlowValue());
map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia));
map.put("name","氨气");
map.put("unit","");
ammoniaConsume.add(JSONObject.toJSON(map));
@ -361,9 +395,9 @@ public class EnergyController extends BaseController {
.eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId()));
if (parRotSpeedValueList.size()>0){
if (kilnType==1){
List rotList=new ArrayList();
List rot1Consume=new ArrayList<>();
List rot2Consume=new ArrayList<>();
List<Object> rotList=new ArrayList<>();
List<Object> rot1Consume=new ArrayList<>();
List<Object> rot2Consume=new ArrayList<>();
for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList
) {
map.put("time",parRotSpeedValue.getCreateTime());
@ -390,11 +424,11 @@ public class EnergyController extends BaseController {
.eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId()));
if (parTemValueList.size()>0){
if (kilnType==1){
List tempList=new ArrayList();
List actualTempConsume=new ArrayList<>();
List setupTempConsume=new ArrayList<>();
List actualOilTempConsume=new ArrayList<>();
List setupOilTempConsume=new ArrayList<>();
List<Object> tempList=new ArrayList<>();
List<Object> actualTempConsume=new ArrayList<>();
List<Object> setupTempConsume=new ArrayList<>();
List<Object> actualOilTempConsume=new ArrayList<>();
List<Object> setupOilTempConsume=new ArrayList<>();
for (ParTemValue parTemValue:parTemValueList
) {
map.put("time",parTemValue.getCreateTime());
@ -429,9 +463,9 @@ public class EnergyController extends BaseController {
jsonObject.put("temp",tempList);
}
if (kilnType==2){
List tempList=new ArrayList();
List actualTempConsume=new ArrayList<>();
List setupTempConsume=new ArrayList<>();
List<Object> tempList=new ArrayList<>();
List<Object> actualTempConsume=new ArrayList<>();
List<Object> setupTempConsume=new ArrayList<>();
for (ParTemValue parTemValue:parTemValueList
) {
map.put("time",parTemValue.getCreateTime());
@ -453,11 +487,11 @@ public class EnergyController extends BaseController {
}
if (kilnType==3){
List tempList=new ArrayList();
List actualTempConsume=new ArrayList<>();
List setupTempConsume=new ArrayList<>();
List outerZone1TempConsume=new ArrayList<>();
List outerZone2TempConsume=new ArrayList<>();
List<Object> tempList=new ArrayList<>();
List<Object> actualTempConsume=new ArrayList<>();
List<Object> setupTempConsume=new ArrayList<>();
List<Object> outerZone1TempConsume=new ArrayList<>();
List<Object> outerZone2TempConsume=new ArrayList<>();
for (ParTemValue parTemValue:parTemValueList
) {
map.put("time",parTemValue.getCreateTime());
@ -479,6 +513,7 @@ public class EnergyController extends BaseController {
outerZone1TempConsume.add(JSONObject.toJSON(map));
map.clear();
map.put("time",parTemValue.getCreateTime());
map.put("value",parTemValue.getOuterZone2Temp());
map.put("name","外二区温度");
map.put("unit","");
@ -494,5 +529,10 @@ public class EnergyController extends BaseController {
}
return R.ok(jsonObject.toJSONString());
}
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

@ -42,7 +42,7 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic
private OrderInfoServiceBiz orderInfoServiceBiz;
@Override
public R<List<CurrTaskDetVo>> get(IdParam idParam) {
Long taskId = inStockInfoServiceBiz.getById(idParam).getTaskId();
Long taskId = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>().eq(InStockInfo.LOCATION_ID,idParam.getId())).getTaskId();
List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq("curr_task_id", taskId));
List<CurrTaskDetVo> currTaskDetVoList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList

View File

@ -109,7 +109,6 @@ public class AsynRunTaskService extends BaseService {
runTask.setVehicleId(vehicleId);
runTask.setStartPosition(currTask.getStartPosition());
runTask.setEndPosition(currTask.getTargetPosition());
setCommonField(runTask);
runTask.setBeginTime(LocalDateTime.now());
runTaskServiceBiz.save(runTask);
//调用车辆填入起终点,得到车辆执行结果
@ -149,6 +148,7 @@ public class AsynRunTaskService extends BaseService {
Location location = locationServiceBiz.getById(inStockInfo.getLocationId());
Long currTaskId = inStockInfo.getTaskId();
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);
if (vehicleId==1){
//获取RGV2当前位置
Double rgv2CurrPosition = RGVCurrPosition(2);
@ -186,7 +186,6 @@ public class AsynRunTaskService extends BaseService {
// 起点为库位
runTask.setStartPosition(location.getCode());
runTask.setEndPosition(currTask.getTargetPosition());
setCommonField(runTask);
runTask.setBeginTime(LocalDateTime.now());
runTaskServiceBiz.save(runTask);
//修改缓存区存储情况表状态
@ -216,6 +215,9 @@ public class AsynRunTaskService extends BaseService {
currTask.setRunTaskId(runTask.getId());
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//更新小车状态
vehicle.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicle);
}else {
runTask.setStatus(3);
runTask.setUpdateTime(LocalDateTime.now());
@ -264,7 +266,6 @@ public class AsynRunTaskService extends BaseService {
}
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask=new RunTask();
setCommonField(runTask);
runTask.setTaskId(currTask.getId());
runTask.setTaskCode(currTask.getTaskCode());
runTask.setVehicleId(vehicleId);
@ -284,7 +285,7 @@ public class AsynRunTaskService extends BaseService {
inStockInfo.setLocationId(location.getId());
inStockInfo.setLocationName(location.getLocationNameAlias());
inStockInfo.setType(1);
setCommonField(inStockInfo);
inStockInfo.setCreateTime(LocalDateTime.now());
inStockInfoServiceBiz.save(inStockInfo);
// 调用车辆填入起终点,得到车辆执行结果,填入任务号待确认
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
@ -299,6 +300,7 @@ public class AsynRunTaskService extends BaseService {
runTaskServiceBiz.updateById(runTask);
//更新currTask表
currTask.setCacheSatatus(2);
currTask.setStatus(3);
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//更新in_stock_info表
@ -355,7 +357,6 @@ public class AsynRunTaskService extends BaseService {
}
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask=new RunTask();
setCommonField(runTask);
runTask.setTaskId(currTask.getId());
runTask.setTaskCode(currTask.getTaskCode());
runTask.setVehicleId(vehicleId);
@ -380,8 +381,7 @@ public class AsynRunTaskService extends BaseService {
inStockInfo.setKilnName(currTask.getKilnName());
inStockInfo.setLocationId(location.getId());
inStockInfo.setLocationName(location.getLocationNameAlias());
inStockInfo.setType(0);
setCommonField(inStockInfo);
inStockInfo.setCreateTime(LocalDateTime.now());
inStockInfoServiceBiz.save(inStockInfo);
// 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号
Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode();
@ -426,7 +426,7 @@ public class AsynRunTaskService extends BaseService {
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(2, 1L, 39);
Integer status = moveRgv(2, 1L, 1);
if (status!=1){
logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39执行失败===");
// 2022/3/6 websocket通知页面
@ -441,7 +441,7 @@ public class AsynRunTaskService extends BaseService {
//两辆小车是否冲突
Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition);
if (conflictBoolean){
Integer status = moveRgv(1, 1L, 1);
Integer status = moveRgv(1, 1L, 12);
if (status!=1){
logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1执行失败===");
// 2022/3/6 websocket通知页面
@ -452,7 +452,7 @@ public class AsynRunTaskService extends BaseService {
}
}
RunTask runTask=new RunTask();
setCommonField(runTask);
// setCommonField(runTask);
runTask.setVehicleId(vehicleId);
runTask.setBeginTime(LocalDateTime.now());
runTask.setStartPosition(location.getCode());
@ -470,7 +470,7 @@ public class AsynRunTaskService extends BaseService {
Integer status = sendTaskToRgv(vehicleId, 0L, startPoint, endPoint, 0);
if (status==1){
logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功===");
//更新关系表状态为完成
//更新调度任务表状态为完成
runTask.setUpdateTime(LocalDateTime.now());
runTask.setStatus(2);
runTask.setEndTime(LocalDateTime.now());
@ -487,13 +487,17 @@ public class AsynRunTaskService extends BaseService {
//更新库位状态
location.setStatus(0);
locationServiceBiz.updateById(location);
//更新车辆状态
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(0);
vehicleInfoServiceBiz.updateById(vehicleInfo);
}else {
runTask.setStatus(3);
runTask.setUpdateTime(LocalDateTime.now());
runTaskServiceBiz.updateById(runTask);
logger.info("任务 "+runTask.getTaskCode()+" 车辆从缓存区到提升平台过程中失败。");
logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败===");
System.out.println("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败===");
// 2021/12/14 websocket推送到前端
webSocketServer.sendtoAll("出库任务车辆从缓存区到提升平台过程中失败。");
}
@ -896,7 +900,7 @@ public class AsynRunTaskService extends BaseService {
json.put("identifier",identifier);
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("能源消耗统计:获取 "+identifier+" 的值失败");
@ -921,12 +925,13 @@ public class AsynRunTaskService extends BaseService {
}
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取RGV1的当前位置失败");
}
return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
Double value = Double.valueOf(JSONObject.parseObject(result).get("result").toString());
return value*0.0001;
}
/**
@ -942,16 +947,21 @@ public class AsynRunTaskService extends BaseService {
Map<String, Integer> json = new HashMap();
//type=1为
// taskType 4 单移动
json.put("taskType", 4);
json.put("sendRow", sendRow);
json.put("pickRow",0);
json.put("taskNo",1);
json.put("ideNumber",1);
json.put("processNumber",1);
String taskJson = JSON.toJSONString(json);
logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,即将执行车辆位移任务,车辆"+vehicleId+"移动到点位"+sendRow+"===");
String result =null;
try {
if (vehicleId==1){
result=HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson);
result=HttpClient.httpPost("http://192.168.6.51:8009/rgv1/sendTask",taskJson);
}else {
result=HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson);
result=HttpClient.httpPost("http://192.168.6.51:8009/rgv2/sendTask",taskJson);
}
JSONObject jsonObject = JSON.parseObject(result);
@ -987,10 +997,10 @@ public class AsynRunTaskService extends BaseService {
logger.info("===执行任务:"+currTaskId+" ,即将执行车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"===");
try {
if (vehicleId==1){
result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson);
result = HttpClient.httpPost("http://192.168.6.51:8009/rgv1/sendTask", taskJson);
}
if (vehicleId==2){
result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson);
result = HttpClient.httpPost("http://192.168.6.51:8009/rgv2/sendTask", taskJson);
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -66,18 +66,23 @@ public class RunTaskUtils {
//起点,起点和终点是液压台code窑炉code缓存区code
String startPosition = currTask.getStartPosition();
PointInfo startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, startPosition));
// 可以根据点位类型判断起点是否为液压台
// 可以根据点位类型判断起点是否为液压台(2是液压台)
Integer startPointType = startPoint.getType();
if (startPointType==3){
if (startPointType==2){
Map<String, Object> yeya = new HashMap();
//type=1为
yeya.put("type", 1);
yeya.put("number", startPoint.getCode());
if ("YYT003".equals(startPoint.getNote())){
yeya.put("number", 2);
}
if ("YYT004".equals(startPoint.getNote())){
yeya.put("number", 1);
}
String yeyaJudgeStatus = JSON.toJSONString(yeya);
//判断起点液压台是否已放货且提升到位
String yeyaStatus=null;
try {
yeyaStatus = HttpClient.httpPost("http://localhost:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
} catch (IOException e) {
e.printStackTrace();
logger.error(new Date() + "WCS接口超时未响应");
@ -108,6 +113,9 @@ public class RunTaskUtils {
if (resultBoolean){
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
if (vehicleId==0){
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
@ -130,7 +138,7 @@ public class RunTaskUtils {
if (count >0) {
//分配一个缓存区库位
Location location = locationServiceBiz.list(new QueryWrapper<Location>()
.eq(Location.STATUS, 1)
.eq(Location.STATUS, 0)
.eq(Location.VALID, 1)).get(0);
//更新 location 表对应库位状态为占用
location.setStatus(1);
@ -140,6 +148,9 @@ public class RunTaskUtils {
PointInfo pointInfo = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, location.getCode()));
//计算出路径最短的车辆id,起点液压台终点缓存区库位点
Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), location.getCode());
if (vehicleId==0){
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
@ -233,6 +244,9 @@ public class RunTaskUtils {
//窑炉为起点,缓存区为终点
Location location = locationList.get(0);
Long vehicleId = taskDistanceUtils.chooseVehicle(kilnInfo.getCode(), location.getCode());
if (vehicleId==0){
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
@ -267,8 +281,17 @@ public class RunTaskUtils {
//有小车在运行提示当前有车辆在运行请稍后
return R.failed("当前轨道有RGV车辆在运动请等待当前RGV车辆执行完毕再执行任务");
}
Boolean platFormStatus = platFormStatus(yeyaTaiCode);
if (!platFormStatus){
// TODO: 2022/3/19 delete
System.out.println("当前选定的液压台为在线或未提升到位,请检查后重试!");
return R.failed("当前选定的液压台为在线或未提升到位,请检查后重试!");
}
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), yeyaTaiCode);
if (vehicleId==0){
return R.failed("两辆车都不在线,请检查后重试!");
}
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
@ -276,6 +299,8 @@ public class RunTaskUtils {
vehicleInfoServiceBiz.updateById(vehicleInfo);
//异步调用车辆
asynRunTaskService.asynRunOutStock(locationId,yeyaTaiCode,vehicleInfo.getId());
// TODO: 2022/3/19
System.out.println("操作成功,任务已开始执行。");
return R.ok("操作成功,任务已开始执行。");
}
@ -293,7 +318,7 @@ public class RunTaskUtils {
json.put("identifier",identifier);
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("readPLC "+identifier+" 的值失败");
@ -301,4 +326,86 @@ public class RunTaskUtils {
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.";
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();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier+"TaskState");
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==1){
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+"TaskState");
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==1){
return true;
}else {
return false;
}
}else {
return false;
}
}
return false;
}
}

View File

@ -15,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
@ -28,6 +29,7 @@ import java.util.Map;
* @Date: 2021/12/13 19:54
* @Version 1.0
*/
@Component
public class ScheduledTask extends BaseService {
private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class);
@ -65,7 +67,6 @@ public class ScheduledTask extends BaseService {
@Resource
private WebSocketServer webSocketServer;
@Scheduled(fixedDelay = 5000)
public void testWebsocket() throws IOException {
webSocketServer.sendtoAll(LocalDateTime.now()+"测试");
}
@ -73,7 +74,6 @@ public class ScheduledTask extends BaseService {
/**
* 查询加工完成的窑炉
*/
@Scheduled
public void taskForStockToKiln() throws IOException {
//两辆车是否都空闲只有两辆车都空闲才被允许做任务
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 0));
@ -105,23 +105,24 @@ public class ScheduledTask extends BaseService {
}
//查询出正在加工的窑炉遍历根据采集频率的不同采集高频数据能源消耗
//查询出正在加工的窑炉遍历根据采集频率的不同采集高频数据能源消耗暂定30秒
//@Scheduled(fixedDelay = 1000*30)
public void getFastValue(){
//加工炉列表
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>().in(KilnInfo.TYPE,1,3));
for (KilnInfo kilnInfo:kilnInfoList
) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 1)
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId())
.eq(PlcNameSpace.TYPE,1));
.eq(PlcNameSpace.TYPE,0));
String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working");
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
//该炉子在工作中
if (resultBoolean){
Long kilnId = kilnInfo.getId();
String identificationNumber = readPlcToString(nameSpaceNote, "Identification number");
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
//加工炉
if (kilnInfo.getType()==1){
@ -134,7 +135,7 @@ public class ScheduledTask extends BaseService {
parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue());
parRotSpeedValue.setKilnId(kilnId);
parRotSpeedValue.setTaskId(currTaskId);
setCommonField(parRotSpeedValue);
parRotSpeedValue.setCreateTime(LocalDateTime.now());
parRotSpeedValueServiceBiz.save(parRotSpeedValue);
//氮气
Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow");
@ -157,7 +158,7 @@ public class ScheduledTask extends BaseService {
parGasValue.setSetNitPotValue(setupCarbon.floatValue());
parGasValue.setKilnId(kilnId);
parGasValue.setTaskId(currTaskId);
setCommonField(parGasValue);
parGasValue.setCreateTime(LocalDateTime.now());
parGasValueServiceBiz.save(parGasValue);
}
//氮化炉
@ -175,7 +176,7 @@ public class ScheduledTask extends BaseService {
//氮气量
Double nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow");
//二氧化碳量
Double carbonDioxideFlow = readPlc(nameSpaceNote, "CarbonDioxideFlow");
Double carbonDioxideFlow = readPlc(nameSpaceNote, "CO2Flow");
ParGasValue parGasValue3=new ParGasValue();
parGasValue3.setNitFlowValue(nitrogenFlow.floatValue());
parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue());
@ -185,27 +186,29 @@ public class ScheduledTask extends BaseService {
parGasValue3.setDecompositionRate(decompositionRate.floatValue());
parGasValue3.setKilnId(kilnId);
parGasValue3.setTaskId(currTaskId);
setCommonField(parGasValue3);
parGasValue3.setCreateTime(LocalDateTime.now());
parGasValueServiceBiz.save(parGasValue3);
}
}
}
}
//查询出正在加工的窑炉遍历根据采集频率的不同采集低频数据能源消耗
//查询出正在加工的窑炉遍历根据采集频率的不同采集低频数据能源消耗暂定3分钟一次
//@Scheduled(fixedDelay = 1000*60*3)
public void getSlowValue(){
System.out.println("开始采集数据");
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList
) {
PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 1)
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnInfo.getId())
.eq(PlcNameSpace.TYPE,1));
.eq(PlcNameSpace.TYPE,0));
String nameSpaceNote = nameSpace.getName();
String result = readPlcToString(nameSpaceNote, "Working");
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (resultBoolean){
Long kilnId = kilnInfo.getId();
String identificationNumber = readPlcToString(nameSpaceNote, "Identification number");
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
//加工炉
if (kilnInfo.getType()==1){
@ -224,7 +227,7 @@ public class ScheduledTask extends BaseService {
parTemValue.setOilTankActTemValue(actualOilTemp.floatValue());
parTemValue.setKilnId(kilnId);
parTemValue.setTaskId(currTaskId);
setCommonField(parTemValue);
parTemValue.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue);
//电度值
Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue");
@ -239,7 +242,7 @@ public class ScheduledTask extends BaseService {
parEleValue.setTotalBat(electricalValue.floatValue());
parEleValue.setKilnId(kilnId);
parEleValue.setTaskId(currTaskId);
setCommonField(parEleValue);
parEleValue.setCreateTime(LocalDateTime.now());
parEleValueServiceBiz.save(parEleValue);
}
//回火炉
@ -253,14 +256,14 @@ public class ScheduledTask extends BaseService {
parTemValue2.setActTemValue(actualTemp.floatValue());
parTemValue2.setKilnId(kilnId);
parTemValue2.setTaskId(currTaskId);
setCommonField(parTemValue2);
parTemValue2.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue2);
//电度值
Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity");
//A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage");
Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage");
ParEleValue parEleValue2=new ParEleValue();
parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue());
@ -268,7 +271,7 @@ public class ScheduledTask extends BaseService {
parEleValue2.setTotalBat(electricalValue.floatValue());
parEleValue2.setKilnId(kilnId);
parEleValue2.setTaskId(currTaskId);
setCommonField(parEleValue2);
parEleValue2.setCreateTime(LocalDateTime.now());
parEleValueServiceBiz.save(parEleValue2);
}
//氮化炉
@ -291,7 +294,7 @@ public class ScheduledTask extends BaseService {
parTemValue3.setFurnacePressure(furnacePressure.floatValue());
parTemValue3.setKilnId(kilnId);
parTemValue3.setTaskId(currTaskId);
setCommonField(parTemValue3);
parTemValue3.setCreateTime(LocalDateTime.now());
parTemValueServiceBiz.save(parTemValue3);
//电度值
Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue");
@ -306,7 +309,7 @@ public class ScheduledTask extends BaseService {
parEleValue3.setTotalBat(electricalValue.floatValue());
parEleValue3.setKilnId(kilnId);
parEleValue3.setTaskId(currTaskId);
setCommonField(parEleValue3);
parEleValue3.setCreateTime(LocalDateTime.now());
parEleValueServiceBiz.save(parEleValue3);
}
//清洗炉
@ -314,9 +317,9 @@ public class ScheduledTask extends BaseService {
//电度值
Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity");
//A向电压
Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage");
Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage");
Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage");
Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage");
ParEleValue parEleValue4=new ParEleValue();
parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue());
parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue());
@ -324,42 +327,56 @@ public class ScheduledTask extends BaseService {
parEleValue4.setTotalBat(electricalValue.floatValue());
parEleValue4.setKilnId(kilnId);
parEleValue4.setTaskId(currTaskId);
setCommonField(parEleValue4);
parEleValue4.setCreateTime(LocalDateTime.now());
parEleValueServiceBiz.save(parEleValue4);
}
}
}
System.out.println("采集完成");
}
//遍历窑炉空窑炉查询缓存区是否有等待加工的任务
//待加工任务存在且没有状态为正在进炉的情况下按照先进先出的规则选择待加工任务呼叫车辆进炉
//@Scheduled(fixedDelay = 1000*10)
public void runTaskForEmptyKiln() throws IOException {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>()
.eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0));
// 呼叫车辆运送货物给炉子
//存在空闲窑炉
if (kilnInfoList.size()!=0){
//缓存去是否有目标位置为窑炉的待加工任务
KilnInfo kilnInfo = kilnInfoList.get(0);
List<InStockInfo> inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper<InStockInfo>()
.eq(InStockInfo.TYPE, 1)
.eq(InStockInfo.KILN_ID, kilnInfo.getId())
.orderByAsc(InStockInfo.IN_TIME));
if (inStockInfoList.size()>0){
InStockInfo inStockInfo = inStockInfoList.get(0);
CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId());
Location location = locationServiceBiz.getById(inStockInfo.getLocationId());
//是否有小车在运行
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
//两辆车同时空闲其中一辆车在运行时不能调度另一辆车防止运行中路线冲突
if (vehicleInfoList.size()==0){
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode());
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
vehicleInfo.setUpdateTime(LocalDateTime.now());
vehicleInfoServiceBiz.updateById(vehicleInfo);
asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(),vehicleId);
if (kilnInfoList.size()!=0) {
for (KilnInfo kilnInfo:kilnInfoList
) {
//查询是否有车辆正在执行任务如果有根据车辆是否正在运行可以避免出现前一个任务获取还没进去炉子炉子状态依然为allowIn从而继续发送任务的情况
List<VehicleInfo> vehicleInfos = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
if (vehicleInfos.size()>0){
return;
}
//查询炉子是否allowIn
Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId());
if (kilnAllowIn){
//缓存去是否有目标位置为窑炉的待加工任务
List<InStockInfo> inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper<InStockInfo>()
.eq(InStockInfo.TYPE, 1)
.eq(InStockInfo.KILN_ID, kilnInfo.getId())
.orderByAsc(InStockInfo.IN_TIME));
if (inStockInfoList.size() > 0) {
InStockInfo inStockInfo = inStockInfoList.get(0);
CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId());
Location location = locationServiceBiz.getById(inStockInfo.getLocationId());
//是否有小车在运行
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
//两辆车同时空闲其中一辆车在运行时不能调度另一辆车防止运行中路线冲突
if (vehicleInfoList.size() == 0) {
//计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode());
//占用车辆
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1);
vehicleInfo.setUpdateTime(LocalDateTime.now());
vehicleInfoServiceBiz.updateById(vehicleInfo);
asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(), vehicleId);
}
}
}
}
@ -446,11 +463,12 @@ public class ScheduledTask extends BaseService {
json.put("identifier",identifier);
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
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;
}
/**
@ -467,7 +485,7 @@ public class ScheduledTask extends BaseService {
json.put("identifier",identifier);
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("能源消耗统计:获取 "+identifier+" 的值失败");
@ -475,32 +493,14 @@ public class ScheduledTask extends BaseService {
return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
}
private Boolean rgvOnline(Long vehicleId) throws IOException {
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
// TODO: 2022/3/19 小车的命名空间
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
}
if (vehicleId==2){
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){
webSocketServer.sendtoAll(vehicleInfo.getVehicleName()+"当前不在线,请人工确认车辆状态,如不能恢复未在线状态,请尽快手动移动车辆到轨道尽头,以避免车辆阻碍任务执行!");
return false;
}
return true;
private Boolean kilnAllowIn(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, "AllowIn");
return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
}
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mt.wms.core.dal.entity.PointInfo;
import com.mt.wms.core.dal.entity.VehicleInfo;
import com.mt.wms.core.dal.service.PointInfoServiceBiz;
import com.mt.wms.core.utils.HttpClient;
import org.slf4j.Logger;
@ -35,15 +36,47 @@ public class TaskDistanceUtils {
* @param endPoint 终点
* @return 路径最短的小车id
*/
public Long chooseVehicle(String startPoint,String endPoint){
Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, startPoint)).getDistance();
public Long chooseVehicle(String startPoint,String endPoint) throws IOException {
//车辆是否在线若不在线返回在线的那一辆都不在线返回0
if (!rgvOnline(1L)){
//液压台4 1号回火炉只能调用车辆1
if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){
return 0L;
}
if (!rgvOnline(2L)){
return 0L;
}
return 2L;
}
if (!rgvOnline(2L)){
//3-4号回火炉只能调用车辆2
if ("BMC3".equals(startPoint)||"BMC3".equals(endPoint)||"BMC4".equals(startPoint)||"BMC4".equals(endPoint)){
return 0L;
}
if (!rgvOnline(1L)){
return 0L;
}
return 1L;
}
//3-4号回火炉只能调用车辆2
if ("BMC3".equals(startPoint)||"BMC3".equals(endPoint)||"BMC4".equals(startPoint)||"BMC4".equals(endPoint)){
return 2L;
}
//液压台4 1号回火炉只能调用车辆1
if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){
return 1L;
}
Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, startPoint)).getDistance();
// 2022/2/19 两辆小车都空闲获取出当前位置
Double rgv1CurrPosition = RGVCurrPosition(1L);
Double rgv2CurrPosition = RGVCurrPosition(2L);
//计算空闲小车当前位置到起点的距离
Double vehicle1Distance = Math.abs(startDistance - rgv1CurrPosition);
Double vehicle2Distance = Math.abs(startDistance - rgv2CurrPosition);
return (vehicle1Distance< vehicle2Distance)?1L:2L;
return (vehicle1Distance < vehicle2Distance) ? 1L : 2L;
}
/**
* 计算执行任务的小车本次任务的剩余路径经过的点位集合
@ -67,9 +100,12 @@ public class TaskDistanceUtils {
}
//判断小车是否冲突,传入选定小车的id,任务起终点,另一小车位置
public Boolean conflictForVehicle(Long vehicleId,String startPoint,String endPoint,Double otherNowPosition){
Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, startPoint)).getDistance();
Double endDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.CODE, endPoint)).getDistance();
public Boolean conflictForVehicle(Long vehicleId,String startPoint,String endPoint,Double otherNowPosition) throws IOException {
if (!rgvOnline(1L)||!rgvOnline(2L)){
return false;
}
Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, startPoint)).getDistance();
Double endDistance = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, endPoint)).getDistance();
//获取点位list
List<PointInfo> pointInfoList = pointInfoServiceBiz.list(new QueryWrapper<PointInfo>().orderByAsc(PointInfo.ID));
// 2022/2/19 获取小车当前位置
@ -108,11 +144,41 @@ public class TaskDistanceUtils {
}
String result = null;
try {
result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json));
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取RGV的当前位置失败");
}
return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
Double value = Double.valueOf(JSONObject.parseObject(result).get("result").toString());
return value*0.0001;
}
/**
* 车辆是否在线
* @param vehicleId 车辆id
* @return true/false
* @throws IOException plc访问失败
*/
private Boolean rgvOnline(Long vehicleId) throws IOException {
String identifier=null;
if (vehicleId==1){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
}
if (vehicleId==2){
identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
}
Map<String, Object> json = new HashMap();
json.put("nameSpace", 6);
json.put("plcName", "plc1");
json.put("identifier",identifier);
String result = null;
try {
result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
} catch (IOException e) {
e.printStackTrace();
logger.info("获取车辆"+vehicleId+"当前是否在线失败");
}
Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
return online;
}
}

View File

@ -13,14 +13,14 @@ spring:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
redis:
#redis:
# cluster:
# nodes:
# - localhost:6379
host: @spring.redis.host@
port: @spring.redis.port@
password: @spring.redis.password@
database: @spring.redis.database@
#host: @spring.redis.host@
#port: @spring.redis.port@
#password: @spring.redis.password@
#database: @spring.redis.database@
#开发工具
devtools:

View File

@ -1,6 +1,212 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="com.mt.wms.gateway" level="DEBUG"/>
<jmxConfigurator/>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL如果设置为WARN则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时配置文档如果发生改变将会被重新加载默认值为true -->
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。
当scan为true时此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时将打印出logback内部日志信息实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<contextName>logback-spring</contextName>
<!-- name的值是变量的名称value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后可以使“${}”来使用变量。 -->
<property name="logging.pathwork" value="D:/logger/qj_wms" />
<!--0. 日志格式和颜色渲染 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--1. 输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用只配置最底级别控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--2. 输出到文档-->
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${logging.pathwork}/debug/work-log-debug.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${logging.pathwork}/work-log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>999</maxHistory>
<totalSizeCap>200GB</totalSizeCap>
</rollingPolicy>
<!-- 此日志文档只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.2 level为 INFO 日志,时间滚动输出 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${logging.pathwork}/info/work-log-info.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${logging.pathwork}/work-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>999</maxHistory>
<totalSizeCap>200GB</totalSizeCap>
</rollingPolicy>
<!-- 此日志文档只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${logging.pathwork}/warn/work-log-warn.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${logging.pathwork}/work-log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
<!-- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<!-- <maxFileSize>100MB</maxFileSize>-->
<!-- </timeBasedFileNamingAndTriggeringPolicy>-->
<!-- &lt;!&ndash;日志文档保留天数&ndash;&gt;-->
<!-- <maxHistory>999</maxHistory>-->
<!-- </rollingPolicy>-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${logging.pathwork}/work-log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>999</maxHistory>
<totalSizeCap>200GB</totalSizeCap>
</rollingPolicy>
<!-- 此日志文档只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.4 level为 ERROR 日志,时间滚动输出 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${logging.pathwork}/error/work-log-error.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${logging.pathwork}/work-log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>-->
<!-- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<!-- <maxFileSize>100MB</maxFileSize>-->
<!-- </timeBasedFileNamingAndTriggeringPolicy>-->
<!-- &lt;!&ndash;日志文档保留天数&ndash;&gt;-->
<!-- <maxHistory>999</maxHistory>-->
<!-- </rollingPolicy>-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${logging.pathwork}/work-log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>999</maxHistory>
<totalSizeCap>200GB</totalSizeCap>
</rollingPolicy>
<!-- 此日志文档只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、
以及指定<appender><logger>仅有一个name属性
一个可选的level和一个可选的addtivity属性。
name:用来指定受此logger约束的某一个包或者具体的某一个类。
level:用来设置打印级别大小写无关TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF
还有一个特俗值INHERITED或者同义词NULL代表强制执行上级的级别。
如果未设置此属性那么当前logger将会继承上级的级别。
addtivity:是否向上级logger传递打印信息。默认是true。
<logger name="org.springframework.web" level="info"/>
<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>
-->
<!--
使用mybatis的时候sql语句是debug下才会打印而这里我们只配置了info所以想要查看sql语句的话有以下两种操作
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql不过这样日志那边会出现很多其他消息
第二种就是单独给dao下目录配置debug模式代码如下这样配置sql语句会打印其他还是正常info级别
【logging.level.org.mybatis=debug logging.level.dao=debug】
-->
<!--
root节点是必选节点用来指定最基础的日志输出级别只有一个level属性
level:用来设置打印级别大小写无关TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF
不能设置为INHERITED或者同义词NULL。默认是DEBUG
可以包含零个或多个元素标识这个appender将会添加到这个logger。
-->
<!-- name就是包名这个包下的 所有logger 输出就以下配置 -->
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
<!-- 4.2 生产环境:输出到文档
<springProfile name="pro">
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="ERROR_FILE" />
<appender-ref ref="WARN_FILE" />
</root>
</springProfile> -->
</configuration>