opt:优化充电
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.agv.server.impl;
|
package org.nl.acs.agv.server.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -23,6 +24,7 @@ import org.nl.common.utils.CodeUtil;
|
|||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -197,24 +199,19 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void charge(String carno) {
|
public void charge(String carno) {
|
||||||
//检查数据字典station为0的参数
|
//检查数据字典station为0的参数
|
||||||
//分配车辆
|
//分配车辆
|
||||||
List<Dict> dictList= dictService.getDictByName("station");
|
Dict dict = dictService.getDictByName3("station",carno,null);
|
||||||
int satation=0;
|
int satation=0;
|
||||||
Dict temp=new Dict();
|
if(ObjectUtil.isNotEmpty(dict)){
|
||||||
for(Dict dict : dictList){
|
|
||||||
if ("1".equals(dict.getValue())&&carno.equals(dict.getPara2())){
|
|
||||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
|
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
Dict temp = dictService.getDictByName2("station");
|
||||||
for(Dict dict : dictList){
|
if(ObjectUtil.isNotEmpty(temp)){
|
||||||
if ("0".equals(dict.getValue())){
|
satation = Integer.parseInt(temp.getPara1());
|
||||||
satation = Integer.parseInt(dict.getPara1());
|
|
||||||
temp=dict;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(satation!=0){
|
if(satation!=0){
|
||||||
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
||||||
@@ -238,7 +235,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
(byte) 0X00, (byte) 0X0E,
|
(byte) 0X00, (byte) 0X0E,
|
||||||
(byte) 0X00, (byte) 0X01,
|
(byte) 0X00, (byte) 0X01,
|
||||||
(byte) 0X00, (byte) 0X71,
|
(byte) 0X00, (byte) 0X71,
|
||||||
(byte) 0X00, (byte) 0X0A,
|
(byte) 0X00, (byte) 0X08,
|
||||||
(byte) 0X64, (byte) 0X80,
|
(byte) 0X64, (byte) 0X80,
|
||||||
(byte) 0X00, (byte) 0X01,
|
(byte) 0X00, (byte) 0X01,
|
||||||
(byte) ikeyhigh, (byte) ikeylow,
|
(byte) ikeyhigh, (byte) ikeylow,
|
||||||
@@ -255,7 +252,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
temp.setValue("1");
|
temp.setValue("1");
|
||||||
temp.setPara2(String.valueOf(carno));
|
temp.setPara2(carno);
|
||||||
|
temp.setPara3("下发充电");
|
||||||
dictService.updateDetail(temp);
|
dictService.updateDetail(temp);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import org.nl.acs.device.domain.Device;
|
|||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||||
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
|
||||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
|
||||||
import org.nl.acs.instruction.domain.Instruction;
|
import org.nl.acs.instruction.domain.Instruction;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||||
@@ -31,7 +29,6 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||||
|
|
||||||
@@ -81,7 +78,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
System.out.println("NDCAgv链接开始");
|
System.out.println("NDCAgv链接开始");
|
||||||
ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
|
||||||
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||||
@@ -131,16 +127,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
//车号
|
//车号
|
||||||
int carno = arr[20];
|
int carno = arr[20];
|
||||||
//充电桩站点号
|
//充电桩站点号
|
||||||
int station = arr[25];
|
int station=arr[25];
|
||||||
|
|
||||||
Instruction link_inst = null;
|
Instruction link_inst = null;
|
||||||
Instruction inst = null;
|
Instruction inst = null;
|
||||||
List<Instruction> insts = null;
|
|
||||||
boolean link_flag = false;
|
boolean link_flag = false;
|
||||||
Device agv_device = null;
|
|
||||||
if (carno != 0) {
|
|
||||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
|
||||||
}
|
|
||||||
if (ikey != 0) {
|
if (ikey != 0) {
|
||||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||||
if (ObjectUtil.isEmpty(inst)) {
|
if (ObjectUtil.isEmpty(inst)) {
|
||||||
@@ -151,7 +141,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
link_flag = true;
|
link_flag = true;
|
||||||
}
|
}
|
||||||
log.info("接收agv上报信息:" + bs);
|
log.info("接收agv上报信息:" + bs);
|
||||||
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " carno--" + carno+" station--"+station);
|
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " carno--" + carno);
|
||||||
Device device = null;
|
Device device = null;
|
||||||
String device_code = null;
|
String device_code = null;
|
||||||
String old_device_code = null;
|
String old_device_code = null;
|
||||||
@@ -244,24 +234,20 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
//(需要WCS反馈)
|
//(需要WCS反馈)
|
||||||
}else if (phase == 0xFF) {
|
}else if (phase == 0xFF) {
|
||||||
|
|
||||||
if (!ObjectUtil.isEmpty(inst)) {
|
if (ObjectUtil.isNotEmpty(inst)) {
|
||||||
if (!ObjectUtil.isEmpty(inst)) {
|
|
||||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||||
taskService.cancel(inst.getTask_id());
|
taskService.cancel(inst.getTask_id());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||||
//充电任务下发成功上报
|
//充电任务下发成功上报
|
||||||
} else if (phase == 0x64){
|
} else if (phase == 0x64){
|
||||||
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
|
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
|
||||||
List<Dict> dictList= dictService.getDictByName("station");
|
Dict dict = dictService.getDictByName3("station",null,String.valueOf(station));
|
||||||
for(Dict dict : dictList){
|
if (ObjectUtil.isNotEmpty(dict)){
|
||||||
if (Integer.parseInt(dict.getPara1())==station){
|
|
||||||
dict.setValue("1");
|
dict.setValue("1");
|
||||||
dict.setPara2(String.valueOf(agvaddr));
|
dict.setPara2(String.valueOf(agvaddr));
|
||||||
|
dict.setPara3("下发成功");
|
||||||
dictService.updateDetail(dict);
|
dictService.updateDetail(dict);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//充电成功
|
//充电成功
|
||||||
}else if (phase == 0x65){
|
}else if (phase == 0x65){
|
||||||
@@ -269,14 +255,12 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
//充电取消上报
|
//充电取消上报
|
||||||
}else if (phase == 0x66){
|
}else if (phase == 0x66){
|
||||||
log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
|
log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
|
||||||
List<Dict> dictList= dictService.getDictByName("station");
|
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),String.valueOf(station));
|
||||||
for(Dict dict : dictList){
|
if (ObjectUtil.isNotEmpty(dict)){
|
||||||
if (Integer.parseInt(dict.getPara1())==station){
|
|
||||||
dict.setValue("0");
|
dict.setValue("0");
|
||||||
dict.setPara2("");
|
dict.setPara2("");
|
||||||
|
dict.setPara3("");
|
||||||
dictService.updateDetail(dict);
|
dictService.updateDetail(dict);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +298,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("OneAgv链接异常");
|
|
||||||
log.info("OneAgv链接异常");
|
log.info("OneAgv链接异常");
|
||||||
log.error("agv连接出现异常:{}", e);
|
log.error("agv连接出现异常:{}", e);
|
||||||
logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage());
|
logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage());
|
||||||
|
|||||||
@@ -35,9 +35,12 @@ import org.nl.acs.task.domain.Task;
|
|||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
import org.nl.acs.task.service.impl.TaskServiceImpl;
|
import org.nl.acs.task.service.impl.TaskServiceImpl;
|
||||||
|
import org.nl.system.service.dict.ISysDictService;
|
||||||
|
import org.nl.system.service.dict.dao.Dict;
|
||||||
import org.nl.system.service.param.ISysParamService;
|
import org.nl.system.service.param.ISysParamService;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -57,6 +60,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||||
|
ISysDictService dictService = SpringContextHolder.getBean(ISysDictService.class);
|
||||||
int agvaddr = 0;
|
int agvaddr = 0;
|
||||||
int agvaddr_copy = 0;
|
int agvaddr_copy = 0;
|
||||||
int weight = 0;
|
int weight = 0;
|
||||||
@@ -334,10 +338,22 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
|||||||
log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric);
|
log.info("接收agv上报信息,is_atuo_electric:" + is_atuo_electric);
|
||||||
if("1".equals(is_atuo_electric)){
|
if("1".equals(is_atuo_electric)){
|
||||||
int electric = Integer.parseInt(paramService.findByCode(AcsConfig.ELECTRIC).getValue());
|
int electric = Integer.parseInt(paramService.findByCode(AcsConfig.ELECTRIC).getValue());
|
||||||
if (electric_qty>0&&electric_qty < electric) {
|
if (electric_qty>0 && electric_qty < electric) {
|
||||||
log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.device_code, electric_qty,electric);
|
log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty,electric);
|
||||||
|
//判断是否已下发充电任务
|
||||||
|
Dict dict1 = dictService.getDictByName3("station",String.valueOf(this.agvaddr),null);
|
||||||
|
if(ObjectUtil.isNotEmpty(dict1)){
|
||||||
|
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict1.getPara1());
|
||||||
|
}else{
|
||||||
|
//未下发,判断是否有空闲充电桩
|
||||||
|
Dict dict = dictService.getDictByName2("station");
|
||||||
|
if(ObjectUtil.isNotEmpty(dict)){
|
||||||
NDCAgvService.charge(String.valueOf(this.agvaddr));
|
NDCAgvService.charge(String.valueOf(this.agvaddr));
|
||||||
isCharge =true;
|
isCharge =true;
|
||||||
|
}else{
|
||||||
|
log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty,electric);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (phase == 0x74) {
|
} else if (phase == 0x74) {
|
||||||
|
|||||||
@@ -960,7 +960,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
|||||||
|
|
||||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||||
// NDC agv指令不当场取消指令,需要等agv上报
|
// NDC agv指令不当场取消指令,需要等agv上报
|
||||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
if (StrUtil.isNotEmpty(entity.getAgv_jobno())) {
|
||||||
ndcAgvService.deleteAgvInstToNDC(new Instruction(entity));
|
ndcAgvService.deleteAgvInstToNDC(new Instruction(entity));
|
||||||
}
|
}
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|||||||
@@ -62,6 +62,20 @@ public interface ISysDictService extends IService<Dict> {
|
|||||||
*/
|
*/
|
||||||
List<Dict> getDictByName(String name);
|
List<Dict> getDictByName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典明细
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Dict getDictByName2(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典明细
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Dict getDictByName3(String name,String carno,String station);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加字典明细
|
* 添加字典明细
|
||||||
* @param resources
|
* @param resources
|
||||||
|
|||||||
@@ -124,6 +124,39 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
|||||||
return dictList;
|
return dictList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dict getDictByName2(String name) {
|
||||||
|
Dict dict = null;
|
||||||
|
List<Dict> dictList = sysDictMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<Dict>()
|
||||||
|
.eq(Dict::getCode, name)
|
||||||
|
.eq(Dict::getValue, "0")
|
||||||
|
.and(slam -> slam.isNull(Dict::getPara2)
|
||||||
|
.or()
|
||||||
|
.eq(Dict::getPara2, ""))
|
||||||
|
);
|
||||||
|
if (ObjectUtil.isNotEmpty(dictList) && dictList.size()>0){
|
||||||
|
dict = dictList.get(0);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dict getDictByName3(String name,String carno,String station) {
|
||||||
|
Dict dict = null;
|
||||||
|
List<Dict> dictList = sysDictMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<Dict>()
|
||||||
|
.eq(Dict::getCode, name)
|
||||||
|
.eq(ObjectUtil.isNotEmpty(carno),Dict::getPara2, carno)
|
||||||
|
.eq(ObjectUtil.isNotEmpty(station),Dict::getPara1, station)
|
||||||
|
.eq(Dict::getValue,"1")
|
||||||
|
);
|
||||||
|
if (ObjectUtil.isNotEmpty(dictList) && dictList.size()>0){
|
||||||
|
dict = dictList.get(0);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createDetail(Dict dict) {
|
public void createDetail(Dict dict) {
|
||||||
|
|||||||
Reference in New Issue
Block a user