Commit 91ae5cbf authored by 周毅's avatar 周毅

添加日志输出

parent 69251cfa
package com.gavel.qzsa.agv.process;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.utils.DateUtils;
import com.gavel.common.utils.SpringUtils;
import com.gavel.qzsa.agv.service.HcMsglogService;
......@@ -11,7 +15,7 @@ import com.gavel.qzsa.rabbitmq.model.TaskFeedback;
public class AgvTaskHandler implements Runnable {
private Logger logger = LoggerFactory.getLogger(this.getClass());
//任务单号
private AgvTask agvTask;
......@@ -52,6 +56,7 @@ public class AgvTaskHandler implements Runnable {
if("任务下发".equals(agvTask.getMsgtype())){
needWriteQueue = true;
feedback.setMsgtype("接收任务反馈");
logger.debug("处理任务下发!{} ", JSONObject.toJSONString(agvTask));
rcmsService().genHcTask(agvTask);
feedback.setMsgcode("1");
feedback.setMessage("任务下发成功,agvCode:"+agvTask.getTask().getAgvCode());
......
......@@ -159,32 +159,34 @@ public class AgvServiceImpl extends BaseEditServiceImpl implements AgvService {
//充电状态,阈值比较
if(StringUtils.equals(isEnable,"Y")){
if(StringUtils.equals("7",agvStatus.getStatus())) {
String agvdl = commonService.getStringOptionValue(JcsjParamEnum.AgvBatterySetting.id());
Integer yz = Integer.valueOf(agvdl);//设置值
Integer yz = commonService.getIntOptionValue(JcsjParamEnum.AgvBatterySetting.id());//设置值
Integer curValue = Integer.valueOf(agvStatus.getBattery());//获取小车值
if(NumberUtils.less(curValue , yz)){
logger.error("小车{}正在充电,且当前电量{}低于设定阈值{}!", agvStatus.getRobotCode(), curValue, yz);
continue;
}
}
}
//查询Eptask中是否已存在小车,如果存在,返回空,生成任务失败
if (eptaskDao.countExecutingHcTask(agvStatus.getRobotCode()) > 0) {
logger.error("小车"+agvStatus.getRobotCode()+"已存在执行任务,生成任务失败!");
logger.error("小车"+agvStatus.getRobotCode()+"已存在执行任务!");
continue;
}
if(StringUtils.isNotEmpty(template.getAgv())){
if(StringUtils.contains(template.getAgv(),agvStatus.getRobotCode())){
String lockKey = "AgvTask";
String lockKey = "AgvTask-"+agvStatus.getRobotCode();
if(!LockUtils.lock(lockKey,agvStatus.getRobotCode())) {
logger.error("小车{}已被别的任务占用,继续寻找小车!", agvStatus.getRobotCode());
continue;
}
LockUtils.releaseLock(lockKey,agvStatus.getRobotCode());
return agvStatus.getRobotCode();
}
}else {
String lockKey = "AgvTask";
String lockKey = "AgvTask-"+agvStatus.getRobotCode();
if(!LockUtils.lock(lockKey,agvStatus.getRobotCode())) {
logger.error("小车{}已被别的任务占用,继续寻找小车!", agvStatus.getRobotCode());
continue;
}
LockUtils.releaseLock(lockKey,agvStatus.getRobotCode());
......
package com.gavel.qzsa.agv.service.impl;
import java.util.Calendar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.business.service.CommonService;
import com.gavel.common.lock.LockUtils;
import com.gavel.common.utils.StringUtils;
import com.gavel.common.utils.UserInfoUtil;
import com.gavel.persistence.sql.RecordSet;
import com.gavel.qzsa.agv.dao.EptaskDao;
import com.gavel.qzsa.agv.persistent.Agvtaskqueue;
import com.gavel.qzsa.agv.persistent.Eptask;
......@@ -24,21 +31,13 @@ import com.gavel.qzsa.mcs.utils.EpTask2Enum;
import com.gavel.qzsa.mcs.utils.EpTaskEnum;
import com.gavel.qzsa.rabbitmq.handler.MessageHandler;
import com.gavel.qzsa.rabbitmq.model.AgvTask;
import com.gavel.persistence.sql.RecordSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
@Service("eptaskService")
@Transactional
public class EptaskServiceImpl extends BaseEditServiceImpl implements EptaskService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
// private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private EptaskDao eptaskDao;
......@@ -156,7 +155,7 @@ public class EptaskServiceImpl extends BaseEditServiceImpl implements EptaskServ
}
String cancelTemplate = ","+commonService.getStringOptionValue(JcsjParamEnum.AGVBACK_TEMPLATE.id())+",";
boolean isCancel = cancelTemplate.indexOf(","+agvTask.getTasktype()+",") >= 0;
String lockKey = "AgvTask";
String lockKey = "AgvTask-"+agvTask.getAgvcode();
String agvCode = agvTask.getAgvcode();
//查询空闲小车
if (!isCancel){
......@@ -164,7 +163,7 @@ public class EptaskServiceImpl extends BaseEditServiceImpl implements EptaskServ
if(StringUtils.isEmpty(agvCode) ){
throwReturnMessage("未找到小车,生成任务失败!");
}
//agvCode="1143";
// agvCode="1143";
}
if (LockUtils.lock(lockKey, agvCode)){
try{
......@@ -202,6 +201,7 @@ public class EptaskServiceImpl extends BaseEditServiceImpl implements EptaskServ
throwReturnMessage("货架"+pod.getPodCode()+"PLC连接状态不正确, 生成任务失败!");
}
eptask.setPodCode(pod.getPodCode());
// eptask.setPodCode("1001");
}
eptask.setCreateDate(Calendar.getInstance().getTime());
eptask.setPriority("1");//优先级
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.converter.DataConvert;
import com.gavel.common.utils.DateUtils;
import com.gavel.common.utils.StringUtils;
import com.gavel.qzsa.agv.persistent.Agvtaskqueue;
import com.gavel.qzsa.agv.utils.MsgCodeEnum;
import com.gavel.qzsa.rabbitmq.model.AgvTask;
......@@ -43,6 +44,7 @@ public class HcMsglogServiceImpl extends BaseEditServiceImpl implements HcMsglog
HcMsglog hcMsglog = new HcMsglog();
hcMsglog.setGuid(agvTask.getGuid());
hcMsglog.setTasktype(agvTask.getTasktype());
if (StringUtils.isNotEmpty(feedback.getTime()))
hcMsglog.setRevtime(DateUtils.parseDate(feedback.getTime()));
hcMsglog.setDesttask(DataConvert.list2JSONString(agvTask.getDesttask()));
hcMsglog.setMsgcode(feedback.getMsgcode());
......
package com.gavel.qzsa.config;
import com.gavel.qzsa.rabbitmq.handler.MessageHandler;
import com.gavel.timer.scheduler.TimerJobFactory;
import com.gavel.timer.scheduler.TimerJobInit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
......@@ -11,9 +10,15 @@ import org.springframework.core.annotation.Order;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;
import com.gavel.qzsa.rabbitmq.handler.MessageHandler;
import com.gavel.timer.scheduler.TimerJobFactory;
import com.gavel.timer.scheduler.TimerJobInit;
@Configuration
public class InitConfig {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private TimerJobFactory timerJobFactory;
......@@ -27,14 +32,43 @@ public class InitConfig {
@Autowired
private MessageHandler messageHandler;
// @Autowired
// private AgvtaskqueueService agvtaskqueueService;
@Override
public void run(String... args) throws Exception {
messageHandler.init();
timerJobInit.init();
// test();
}
/*private void test() {
String value = "{\"msgtype\":\"任务下发\",\"guid\":\"202210230930490000T\",\"tasktype\":\"S31\",\"desttask\":[{\"device\":101,\"desc\":\"上盘\"},{\"device\":101,\"desc\":\"上盘\"},{\"device\":0,\"desc\":\"下盘\"},{\"device\":0,\"desc\":\"下盘\"}],\"EquipID\":201,\"time\":\"2022-10-23 09:30:49.590\"}";
AgvTask agvTask = JSONObject.parseObject(value, AgvTask.class);
if (StringUtils.equals(agvTask.getMsgtype(), MessageHandler.TASK_START)
|| StringUtils.equals(agvTask.getMsgtype(), MessageHandler.TASK_CANCEL)
|| StringUtils.equals(agvTask.getMsgtype(), MessageHandler.TASK_PAUSE)
|| StringUtils.equals(agvTask.getMsgtype(), MessageHandler.TASK_RECORVER)){
TaskFeedback feedback = null;
try {
agvtaskqueueService.writeMessage(value);
}catch (Exception e){
feedback = new TaskFeedback();
feedback.setGuid(agvTask.getGuid());
feedback.setMessage(e.getMessage());
feedback.setMsgtype("接收任务反馈");
feedback.setTime(DateUtils.formatDate(DateUtils.getDateTime(),DateUtils.MillISECONDS_DATE_FORMAT));
feedback.setMsgcode("2");
}finally {
SpringUtils.getBean(HcMsglogService.class).addMsgLog(feedback,agvTask);
SpringUtils.getBean(RabbitMqSendMessage.class).sendMessageAgvTask(feedback);
}
}else
MessageHandler.executorSerivce.execute(new AgvTaskHandler(agvTask));
}*/
public void askForLeave(){
System.out.println("项目启动了,执行了方法");
logger.debug("项目启动了,执行了方法");
}
}
......
......@@ -3,12 +3,16 @@ package com.gavel.qzsa.jcsj.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.utils.StringUtils;
import com.gavel.persistence.sql.RecordSet;
import com.gavel.qzsa.jcsj.dao.GwDao;
import com.gavel.qzsa.jcsj.dao.PodDao;
import com.gavel.qzsa.jcsj.dao.TemplateDao;
......@@ -24,13 +28,14 @@ import com.gavel.qzsa.jcsj.vo.TemplateVO;
import com.gavel.qzsa.jcsj.vo.TemplatedetailVO;
import com.gavel.qzsa.mcs.model.Position;
import com.gavel.qzsa.rabbitmq.model.Device;
import com.gavel.persistence.sql.RecordSet;
@Service
@Transactional
public class TemplateServiceImpl extends BaseEditServiceImpl implements TemplateService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private TemplateDao templateDao;
......@@ -173,6 +178,8 @@ public class TemplateServiceImpl extends BaseEditServiceImpl implements Template
if (StringUtils.isEmpty(code)) {
throwReturnMessage("编码不允许为空!");
}
logger.debug("解析路线模板调用参数!agvCode【{}】, templateCode【{}】, deviceList【{}】, equipID【{}】",
agvCode, code, JSONObject.toJSONString(deviceList), equipID);
List<Position> list = new ArrayList<>();
//查询模板
Template param = new Template();
......@@ -253,9 +260,10 @@ public class TemplateServiceImpl extends BaseEditServiceImpl implements Template
deviceIndex++;
} else if (StringUtils.equals(templatedetail.getGwlx(), GwlxEnum.S.getId())) {
//设备单元工位位置点
logger.debug("设备起止点解析!equipID【{}】,gwlx【{}】", equipID, templatedetail.getGwlx());
Gw gw = gwDao.findByDevice(equipID, templatedetail.getGwlx());
if (gw == null) {
throwReturnMessage("无法获取设备单元%s的%s!", equipID, GwlxEnum.findNameById(templatedetail.getGwlx()));
throwReturnMessage("无法获取起止设备%s的%s!", equipID, GwlxEnum.findNameById(templatedetail.getGwlx()));
}
position.setPositionCode(gw.getMapdatacode());
list.add(position);
......
......@@ -18,7 +18,7 @@ public enum GwlxEnum {
F("货架摆放点", "6"),
G("取消点内", "7"),
H("取消点外", "8"),
S("设备单元", "10"),
S("起止设备", "10"),
Z("切换设备◎", "99");
private String id;
......
......@@ -468,9 +468,9 @@ public class RcmsServiceImpl extends BaseEditServiceImpl implements RcmsService
// RCS 提交任务
List<Device> deviceList = agvTask.getDesttask().stream().filter(device -> !"0".equals(device.getDevice())).collect(Collectors.toList()); //过滤设备号为零
String equipID = agvTask.getEquipID();
//获取位置集合
List<Position> positionCodePath = templateService.parseTemplate(eptask.getAgvCode(),agvTask.getTasktype(),deviceList,equipID);
LOG.debug("解析路线模板调用前的参数传入!{}", JSONObject.toJSONString(agvTask));
List<Position> positionCodePath = templateService.parseTemplate(eptask.getAgvCode(),agvTask.getTasktype(),deviceList,agvTask.getEquipID());
GenAgvTaskResp genAgvTaskResp = genAgvSchedulingTask(eptask.getTaskTyp(),
positionCodePath, eptask.getPriority(), eptask.getTaskCode(),eptask.getPodCode(),eptask.getAgvCode());
......
......@@ -55,6 +55,7 @@ public class AgvTaskQueueHandler implements Runnable {
logger.error(e.getMessage());
}
} else {
logger.debug("process AgvTaskQueue!{}", JSONObject.toJSONString(agvtaskQueue));
AgvTask agvTask = new AgvTask();
agvTask.setTasktype(agvtaskQueue.getTasktype());
agvTask.setGuid(agvtaskQueue.getGuid());
......
package com.gavel.qzsa.rabbitmq.handler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.codec.binary.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.utils.DateUtils;
import com.gavel.common.utils.SpringUtils;
......@@ -13,13 +23,6 @@ import com.gavel.qzsa.jcsj.redisplcqueue.RedisQueuePlcTask;
import com.gavel.qzsa.rabbitmq.model.AgvStatusModel;
import com.gavel.qzsa.rabbitmq.model.AgvTask;
import com.gavel.qzsa.rabbitmq.model.TaskFeedback;
import org.apache.commons.codec.binary.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Service
@RabbitListener
......@@ -38,7 +41,7 @@ public class MessageHandler{
public static ExecutorService parseExecutor = Executors.newSingleThreadExecutor();
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private AgvtaskqueueService agvtaskqueueService;
......@@ -66,7 +69,7 @@ public class MessageHandler{
value = new String((byte[])message);
}else
value = message.toString();
//LOGGER.info("process AgvTask {}", value);
logger.debug("process AgvTask {}", value);
AgvTask agvTask = JSONObject.parseObject(value, AgvTask.class);
if (StringUtils.equals(agvTask.getMsgtype(), TASK_START)
......
......@@ -84,6 +84,7 @@ $(function () {
columns: [[
{title: "工位编码", field: "usercallcode", fieldType: "ftString",width:150},
{title: "工位名称", field: "name", fieldType: "ftString",width:150},
{title: "工位别名", field: "alias", fieldType: "ftString",width:150},
{title: "工位类型", field: "type", fieldType: "combobox", width:120, props:{data:$typeArray}},
{title: "工位状态", field: "status", fieldType: "ftString",width: 100, align:'center', formatter: function (value, index, row) {
return $statusMap[value] || value;
......
......@@ -7,7 +7,7 @@
<div class="gui-col-sm12">
<label class="gui-form-label">地图编号:</label>
<div class="gui-input-block">
<input type="text" name="code" data-toggle="gui-textbox" data-options="" >
<input type="text" name="code" data-toggle="gui-textbox" data-options="" readonly>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment