opt:修复NDC断联消息通知;
This commit is contained in:
@@ -19,10 +19,12 @@ import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.task.enums.NoticeTypeEnum;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -69,6 +71,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
LuceneExecuteLogService luceneExecuteLogService;
|
||||
@Autowired
|
||||
ISysDictService dictService;
|
||||
@Autowired
|
||||
ISysNoticeService iSysNoticeService;
|
||||
|
||||
public OneNDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
@@ -94,8 +98,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
|
||||
|
||||
|
||||
int instCode = 0;
|
||||
try {
|
||||
byte[] b = new byte[1024];
|
||||
s = new Socket(ip, port);
|
||||
@@ -152,6 +155,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
instCode =ikey;
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
@@ -354,12 +358,12 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Agv链接异常");
|
||||
log.info("Agv链接异常");
|
||||
iSysNoticeService.createNotice("指令号"+instCode+",异常信息:"+e.getMessage(), "警告:NDC断联", NoticeTypeEnum.EXCEPTION.getCode());
|
||||
log.error("agv连接出现异常:{}", e);
|
||||
if (ObjectUtil.isNotEmpty(s)) {
|
||||
s.close();
|
||||
}
|
||||
System.out.println(e.getMessage());
|
||||
//System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
@@ -183,10 +183,15 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
//到达取货点
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x03) {
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
//添加车号
|
||||
if (StringUtils.isBlank(task.getCar_no())) {
|
||||
task.setCar_no(String.valueOf(carno));
|
||||
}
|
||||
taskserver.update(task);
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
} else if (phase == 0x04) {
|
||||
data = getData(data, index, inst, task);
|
||||
//取货完毕
|
||||
|
||||
@@ -707,7 +707,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(String id) {
|
||||
public synchronized void finish(String id) {
|
||||
InstructionDto entity = this.findById(id);
|
||||
// if (entity == null) throw new BadRequestException(LangProcess.msg("error_sysAuth"));
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
@@ -731,12 +731,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
device = appService.findDeviceByCode(entity.getNext_point_code());
|
||||
if (device == null) {
|
||||
log.error("地址对应设备未找到");
|
||||
throw new BadRequestException(LangProcess.msg("error_isNull", instnextdevice));
|
||||
} else {
|
||||
instnextdevice = entity.getNext_point_code();
|
||||
}
|
||||
// if (device == null) {
|
||||
// log.error("地址对应设备未找到");
|
||||
// throw new BadRequestException(LangProcess.msg("error_isNull", instnextdevice));
|
||||
// } else {
|
||||
instnextdevice = entity.getNext_point_code();
|
||||
// }
|
||||
}
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
|
||||
@@ -745,13 +745,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
|
||||
String start_device_code = entity.getStart_device_code();
|
||||
|
||||
Device deviceByCode = deviceAppService.findDeviceByCode(start_device_code);
|
||||
if (deviceByCode == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
throw new BadRequestException(LangProcess.msg("error_isNull", start_device_code));
|
||||
|
||||
}
|
||||
|
||||
// Device deviceByCode = deviceAppService.findDeviceByCode(start_device_code);
|
||||
// if (deviceByCode == null) {
|
||||
// log.debug("地址对应设备未找到");
|
||||
// throw new BadRequestException(LangProcess.msg("error_isNull", start_device_code));
|
||||
//
|
||||
// }
|
||||
jo1.put("hasGoodStatus", CommonFinalParam.ONE);
|
||||
jo1.put("material_type", startdevice.getMaterial_type());
|
||||
|
||||
@@ -775,12 +774,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
jo.put("batch", "");
|
||||
jo.put("islock", "0");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
|
||||
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
|
||||
|
||||
Task task = new LambdaQueryChainWrapper<>(taskMapper)
|
||||
.eq(Task::getTask_id, insttaskid)
|
||||
.one();
|
||||
@@ -790,7 +785,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
//多路由任务
|
||||
finishAndCreateNextInst((Instruction) entity);
|
||||
Instruction instruction = ConvertUtil.convert(entity, Instruction.class);
|
||||
finishAndCreateNextInst(instruction);
|
||||
}
|
||||
}
|
||||
updateTaskPriority(task);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.acs.task.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum NoticeTypeEnum {
|
||||
|
||||
EXCEPTION("1", "异常"),
|
||||
WARN("2", "警告"),
|
||||
NOTIFICATION("3", "通知");
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public enum TaskStatusEnum {
|
||||
FINISHED("2", "FINISHED", "完成"),
|
||||
FINISHEDMOVE("4", "FINISHEDMOVE", "取货完成"),
|
||||
CANCEL("3", "CANCEL", "取消"),
|
||||
REQUEST("10", "REQUEST", "二次分配请求"),
|
||||
ERROR("99", "ERROR", "异常");
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TaskController {
|
||||
/** 完成任务 */
|
||||
@PostMapping(value = "/finish/{id}")
|
||||
public ResponseEntity<Object> finish(@RequestBody String id) {
|
||||
taskService.finish(id);
|
||||
taskService.finishByHand(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -301,6 +301,9 @@ public interface TaskService extends CommonService<Task> {
|
||||
*/
|
||||
void finish(String ids);
|
||||
|
||||
|
||||
void finishByHand(String id);
|
||||
|
||||
/**
|
||||
* 取货完成
|
||||
*
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -33,7 +32,6 @@ import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device.service.dto.DeviceAssignedDto;
|
||||
import org.nl.acs.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
@@ -63,7 +61,6 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -75,7 +72,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -856,19 +852,29 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishByHand(String id) {
|
||||
id =id+"-";
|
||||
this.finish(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(String id) {
|
||||
boolean isByhand = false;
|
||||
if (id.contains("-")) {
|
||||
id = id.substring(0, id.indexOf("-"));
|
||||
isByhand = true;
|
||||
}
|
||||
TaskDto entity = this.findById(id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException(LangProcess.msg("error_sysAuth"));
|
||||
}
|
||||
|
||||
InstructionDto instdto = instructionService.findByTaskid(id, "instruction_status <2 ");
|
||||
if (instdto != null) {
|
||||
throw new BadRequestException(LangProcess.msg("task_insHas"));
|
||||
}
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
@@ -876,6 +882,9 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
entity.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
//车辆执行任务完成计时字段
|
||||
entity.setTo_y(now);
|
||||
if (isByhand) {
|
||||
entity.setRemark("该任务由人工手动强制完成");
|
||||
}
|
||||
Task task = ConvertUtil.convert(entity, Task.class);
|
||||
if (StringUtils.isNotBlank(entity.getTo_x())) {
|
||||
DateTime toXTime = DateUtil.parse(entity.getTo_x());
|
||||
|
||||
@@ -57,9 +57,13 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
LambdaQueryWrapper<SysLog> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(ObjectUtil.isNotEmpty(log_type), SysLog::getLog_type, log_type)
|
||||
.eq(ObjectUtil.isNotEmpty(username), SysLog::getUsername, username)
|
||||
.like(ObjectUtil.isNotEmpty(blurry), SysLog::getDescription, blurry)
|
||||
.le(ObjectUtil.isNotEmpty(end_time), SysLog::getCreate_time, end_time)
|
||||
.ge(ObjectUtil.isNotEmpty(begin_time), SysLog::getCreate_time, begin_time)
|
||||
.and(ObjectUtil.isNotEmpty(blurry), wrapper ->
|
||||
wrapper.like(SysLog::getDescription, blurry)
|
||||
.or()
|
||||
.like(SysLog::getParams, blurry)
|
||||
)
|
||||
.orderByDesc(SysLog::getCreate_time);
|
||||
IPage<SysLog> page = new Page<>(pageable.getPage()+1, pageable.getSize());
|
||||
logMapper.selectPage(page, lam);
|
||||
|
||||
@@ -161,32 +161,20 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||
|
||||
@Override
|
||||
public void createNotice(String msg, String title, String type) {
|
||||
// 获取标题相同的信息
|
||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
||||
.eq(SysNotice::getNotice_title, title)
|
||||
.eq(SysNotice::getHave_read, NoticeEnum.HAVE_READ_OFF.getValue()));
|
||||
String dealStatus = NoticeEnum.DEAL_STATUS_NO.getValue();
|
||||
String haveRead = NoticeEnum.HAVE_READ_OFF.getValue();
|
||||
SysNotice noticeDto = SysNotice.builder()
|
||||
.notice_id(IdUtil.getSnowflake(1, 1).nextIdStr())
|
||||
.notice_type(type)
|
||||
.notice_title(title)
|
||||
.notice_content(msg)
|
||||
.deal_status(NoticeEnum.DEAL_STATUS_NO.getValue())
|
||||
.have_read(NoticeEnum.HAVE_READ_OFF.getValue())
|
||||
.deal_status(dealStatus)
|
||||
.have_read(haveRead)
|
||||
.create_time(DateUtil.now())
|
||||
.build();
|
||||
if (ObjectUtil.isNotEmpty(sysNotices)) {
|
||||
noticeDto.setNotice_id(sysNotices.get(0).getNotice_id());
|
||||
}
|
||||
// 插入/修改
|
||||
this.saveOrUpdate(noticeDto);
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("data", "notice_message_update");
|
||||
SocketMsg messageInfo = new SocketMsg(res, MsgType.INFO);
|
||||
try {
|
||||
webSocketServer.sendInfo(messageInfo, "messageInfo");
|
||||
} catch (IOException e) {
|
||||
throw new BadRequestException(LangProcess.msg("error_Send"));
|
||||
}
|
||||
sysNoticeMapper.insert(noticeDto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.quartz.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.tlog.task.quartz.TLogQuartzJobBean;
|
||||
@@ -96,6 +97,7 @@ public class ExecutionJob extends TLogQuartzJobBean {
|
||||
// 任务状态 0:成功 1:失败
|
||||
logDto.setIs_success(false);
|
||||
logDto.setException_detail(ThrowableUtil.getStackTrace(e));
|
||||
logDto.setCreate_time(DateUtil.now());
|
||||
// 任务如果失败了则暂停
|
||||
if (quartzJob.getPause_after_failure() != null && quartzJob.getPause_after_failure()) {
|
||||
quartzJob.setIs_pause(false);
|
||||
@@ -103,8 +105,8 @@ public class ExecutionJob extends TLogQuartzJobBean {
|
||||
quartzJobService.updateIsPause(quartzJob);
|
||||
}
|
||||
//异常时候打印日志
|
||||
log.info(logDto.toString());
|
||||
quartzLogMapper.insert(logDto);
|
||||
log.error(logDto.toString());
|
||||
//quartzLogMapper.insert(logDto);
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
# active: dev
|
||||
# active: prod
|
||||
jackson:
|
||||
|
||||
Reference in New Issue
Block a user