Merge remote-tracking branch 'origin/master'

This commit is contained in:
yuyang 2022-03-08 10:40:18 +08:00
commit 563e09a397
4 changed files with 80 additions and 25 deletions

View File

@ -63,10 +63,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
public void handleBinary(ClientHandler handler, byte[] data) throws IOException { public void handleBinary(ClientHandler handler, byte[] data) throws IOException {
try { try {
String pileNo = ChargingPileServer.getPileNo(handler);
List<byte[]> dataList = parseDataList(data); List<byte[]> dataList = parseDataList(data);
for (byte[] d : dataList) { for (byte[] d : dataList) {
String dataStr = toHex(d); String dataStr = toHex(d);
String pileNo = ChargingPileServer.getPileNo(handler);
log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo); log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo);
if (d.length <= 2 || !dataStr.startsWith("68")) { if (d.length <= 2 || !dataStr.startsWith("68")) {
log.debug("received invalid data <<<< |{}|, len[{}]", dataStr, d.length); log.debug("received invalid data <<<< |{}|, len[{}]", dataStr, d.length);
@ -88,7 +88,8 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
} }
} }
private void process(ClientHandler handler, byte[] data) throws TxException, IOException, NacosException, InterruptedException { private void process(ClientHandler handler, byte[] data) throws TxException, IOException, NacosException,
InterruptedException {
String serviceName = toHex(data, 5, 6); String serviceName = toHex(data, 5, 6);
String version = ChargingPileServer.getVersion(handler.getName()); String version = ChargingPileServer.getVersion(handler.getName());
@ -105,8 +106,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
cachePile.put("tcfg", false); cachePile.put("tcfg", false);
REDIS.setCacheMap(pilekey, cachePile); REDIS.setCacheMap(pilekey, cachePile);
regHandler(handler, pileNo, req); regHandler(handler, pileNo, req);
} } else if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
setCachePileRM(pilekey); setCachePileRM(pilekey);
} }
if (result.getBinary() != null) { if (result.getBinary() != null) {
@ -130,6 +130,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
xhpcDeviceMessageMapper.insertByDomain(deviceMessage); xhpcDeviceMessageMapper.insertByDomain(deviceMessage);
} }
if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) { if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
pileNo = ChargingPileServer.getPileNo(handler);
if (null == pileNo) {
handler.forceClose();
} else {
Boolean tcfg = (Boolean) cachePile.get("tcfg"); Boolean tcfg = (Boolean) cachePile.get("tcfg");
if (tcfg == null || !tcfg) { if (tcfg == null || !tcfg) {
String skey = pilekey.concat(".seqhex"); String skey = pilekey.concat(".seqhex");
@ -154,6 +158,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
} }
} }
} }
}
private String getTimeBin(String seqhex, String pileNo, Date date) { private String getTimeBin(String seqhex, String pileNo, Date date) {

View File

@ -3,6 +3,7 @@ package com.xhpc.workorder.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.xhpc.common.core.exception.CustomException; import com.xhpc.common.core.exception.CustomException;
import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.workorder.domain.XhpcStationDeviceDomain; import com.xhpc.workorder.domain.XhpcStationDeviceDomain;
import com.xhpc.workorder.domain.XhpcWorkStationDomain; import com.xhpc.workorder.domain.XhpcWorkStationDomain;
import com.xhpc.workorder.mapper.XhpcStationDeviceMapper; import com.xhpc.workorder.mapper.XhpcStationDeviceMapper;
@ -26,9 +27,52 @@ public class WorkStationServiceImpl implements WorkStationService {
@Resource @Resource
XhpcWorkStationMapper stationMapper; XhpcWorkStationMapper stationMapper;
@Resource
RedisService redisService;
private int getTerminalStatus(String serialNumber) {
//0离线 1故障 2空闲 3充电 4 已插枪 5未知
// Integer status =5;
//终端状态用 redis数据
if(!"".equals(serialNumber) && serialNumber!=null){
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber);
if(cacheMap !=null && cacheMap.get("status") !=null){
if ("离线".equals(cacheMap.get("status").toString())){
return 0;
}else if("故障".equals(cacheMap.get("status").toString())){
return 1;
}else if("空闲".equals(cacheMap.get("status").toString())){
if("".equals(cacheMap.get("vehicleGunStatus").toString())){
return 4;
}else{
return 2;
}
}else{
//充电桩
return 3;
}
}
return 5;
}else{
return 5;
}
}
@Override @Override
public List<Map<String, Object>> getStationDevice(Map<String, Object> params){ public List<Map<String, Object>> getStationDevice(Map<String, Object> params){
return deviceMapper.selectStationGunDeviceListByParams(params);
List<Map<String, Object>> deviceList = deviceMapper.selectStationGunDeviceListByParams(params);
for(Map<String, Object> map : deviceList){
//状态
int pileSerialNumber = getTerminalStatus(map.get("gunSerialNumber").toString());
map.put("workStatus",pileSerialNumber);
}
return deviceList;
} }

View File

@ -45,10 +45,14 @@
d2.serial_number as 'gunSerialNumber', d2.serial_number as 'gunSerialNumber',
d2.brand_model as 'gunBrandModel', d2.brand_model as 'gunBrandModel',
d2.current_type as 'gunCurrentType', d2.current_type as 'gunCurrentType',
d2.sorted as 'gunSorted' d2.sorted as 'gunSorted',
t.status as 'status',
t.work_status as 'workStatus',
t.charging_pile_id as 'chargingPileId'
from xhpc_station_device d1 from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
LEFT JOIN xhpc_station_device d2 on d2.parent_device_id=d1.device_id LEFT JOIN xhpc_station_device d2 on d2.parent_device_id=d1.device_id
LEFT JOIN xhpc_terminal t on t.serial_number = d2.serial_number
WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE' WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE'
<if test="params.stationName!=null and params.stationName != ''"> <if test="params.stationName!=null and params.stationName != ''">
and s.name like concat('%', #{params.stationName}, '%') and s.name like concat('%', #{params.stationName}, '%')

View File

@ -53,13 +53,15 @@
SELECT SELECT
o.work_order_id as 'workOrderId', o.work_order_id as 'workOrderId',
o.title as 'title', o.title as 'title',
o.type as 'type', o.type as 'typeId',
td.name as 'typeName',
u.dept_id as 'deptId', u.dept_id as 'deptId',
d.dept_name as 'deptName', d.dept_name as 'deptName',
u.work_user_id as 'userId', u.work_user_id as 'userId',
u.user_name as 'userName', u.user_name as 'userName',
o.`status` as 'status' o.`status` as 'status'
from xhpc_work_order o from xhpc_work_order o
left join xhpc_work_type_dict td on td.work_type_id=o.type
LEFT JOIN xhpc_work_order_user ou on o.work_order_id=ou.order_id LEFT JOIN xhpc_work_order_user ou on o.work_order_id=ou.order_id
LEFT JOIN xhpc_work_user u on ou.user_id=u.work_user_id LEFT JOIN xhpc_work_user u on ou.user_id=u.work_user_id
LEFT JOIN xhpc_work_dept d on d.work_dept_id=u.dept_id LEFT JOIN xhpc_work_dept d on d.work_dept_id=u.dept_id