|
@ -16,6 +16,8 @@ import org.nl.acs.log.LokiLogType; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
|
|
|
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.common.utils.CodeUtil; |
|
|
import org.nl.common.utils.CodeUtil; |
|
|
import org.nl.config.SpringContextHolder; |
|
|
import org.nl.config.SpringContextHolder; |
|
@ -23,6 +25,7 @@ import org.springframework.context.annotation.Lazy; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
@ -34,7 +37,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
private final DeviceAppService deviceAppService; |
|
|
private final DeviceAppService deviceAppService; |
|
|
private final ISysParamService paramService; |
|
|
private final ISysParamService paramService; |
|
|
private final AcsToWmsService acsToWmsService; |
|
|
private final AcsToWmsService acsToWmsService; |
|
|
|
|
|
private final ISysDictService dictService; |
|
|
private final DeviceExecuteLogService logServer; |
|
|
private final DeviceExecuteLogService logServer; |
|
|
|
|
|
|
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
|
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); |
|
@ -193,6 +196,73 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
return b; |
|
|
return b; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void charge(String carno) { |
|
|
|
|
|
//检查数据字典station为0的参数
|
|
|
|
|
|
//分配车辆
|
|
|
|
|
|
List<Dict> dictList= dictService.getDictByName("station"); |
|
|
|
|
|
int satation=0; |
|
|
|
|
|
Dict temp=new Dict(); |
|
|
|
|
|
for(Dict dict : dictList){ |
|
|
|
|
|
if ("1".equals(dict.getValue())&&carno.equals(dict.getPara2())){ |
|
|
|
|
|
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1()); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for(Dict dict : dictList){ |
|
|
|
|
|
if ("0".equals(dict.getValue())){ |
|
|
|
|
|
satation = Integer.parseInt(dict.getPara1()); |
|
|
|
|
|
temp=dict; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(satation!=0){ |
|
|
|
|
|
String instcode =CodeUtil.getNewCode("INSTRUCT_NO"); |
|
|
|
|
|
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); |
|
|
|
|
|
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); |
|
|
|
|
|
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); |
|
|
|
|
|
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno)); |
|
|
|
|
|
byte satationhigh = (byte) IntToHexHigh(satation); |
|
|
|
|
|
byte satationlow = (byte) IntToHexLow(satation); |
|
|
|
|
|
String str = "十进制下发:"; |
|
|
|
|
|
String str1 = "十六进制下发:"; |
|
|
|
|
|
str += "ikey:" + (Integer.parseInt(instcode)); |
|
|
|
|
|
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); |
|
|
|
|
|
str += "carno:" + (Integer.parseInt(carno)); |
|
|
|
|
|
str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF); |
|
|
|
|
|
str += "/satation:" + (satation); |
|
|
|
|
|
str1 += "/satation:" + hexToString(satationhigh & 0xFF) + hexToString(satationlow & 0xFF); |
|
|
|
|
|
|
|
|
|
|
|
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0E, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
|
|
(byte) 0X00, (byte) 0X0A, |
|
|
|
|
|
(byte) 0X64, (byte) 0X80, |
|
|
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
|
|
(byte) carhigh, (byte) carlow, |
|
|
|
|
|
(byte) satationhigh, (byte) satationlow |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
log.info("下发AGV充电任务--{}", str1); |
|
|
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
OneNDCSocketConnectionAutoRun.write(b); |
|
|
|
|
|
} catch (Exception e){ |
|
|
|
|
|
log.error("下发充电任务失败{}{}",e,e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
temp.setValue("1"); |
|
|
|
|
|
temp.setPara2(String.valueOf(carno)); |
|
|
|
|
|
dictService.updateDetail(temp); |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean createChargingTaskToNDC(String carno) { |
|
|
public boolean createChargingTaskToNDC(String carno) { |
|
|
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); |
|
|
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno)); |
|
|