From fc568b6542b9845d715c2c2bd541b31f35d5cff6 Mon Sep 17 00:00:00 2001 From: ZZ Date: Fri, 4 Mar 2022 13:56:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AF=B9=E6=9C=AA=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9A=84=E8=BF=9E=E6=8E=A5=E5=92=8C=E6=B6=88=E6=81=AF=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=97=A0=E6=83=85=E6=8A=9B=E5=BC=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pp/server/ChargingPileBinaryHandler.java | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java index 2dc0aa97..30e3ea60 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java @@ -63,10 +63,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { public void handleBinary(ClientHandler handler, byte[] data) throws IOException { try { + String pileNo = ChargingPileServer.getPileNo(handler); List dataList = parseDataList(data); for (byte[] d : dataList) { String dataStr = toHex(d); - String pileNo = ChargingPileServer.getPileNo(handler); log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo); if (d.length <= 2 || !dataStr.startsWith("68")) { 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 version = ChargingPileServer.getVersion(handler.getName()); @@ -105,8 +106,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { cachePile.put("tcfg", false); REDIS.setCacheMap(pilekey, cachePile); regHandler(handler, pileNo, req); - } - if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) { + } else if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) { setCachePileRM(pilekey); } if (result.getBinary() != null) { @@ -130,25 +130,30 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler { xhpcDeviceMessageMapper.insertByDomain(deviceMessage); } if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) { - Boolean tcfg = (Boolean) cachePile.get("tcfg"); - if (tcfg == null || !tcfg) { - String skey = pilekey.concat(".seqhex"); - Thread.sleep(500); - Date date = Calendar.getInstance().getTime(); - String timebin = getTimeBin(seqHex(skey), pileNo, date); - cachePile.put("configTime", DateUtil.format(date, NORM_DATETIME_FORMAT)); - REDIS.setCacheMap(pilekey, cachePile); - log.debug("server send time config msg >>>> ({}) |{}|", pileNo, timebin); - if (!handler.isOpen()) { - log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo); - removeHandler(pileNo); - } else { - handler.sendClientBinary(HexUtils.toBytes(timebin)); - if (gunId != null) { - hori2(pileNo, gunId); - } - cachePile.put("tcfg", true); + pileNo = ChargingPileServer.getPileNo(handler); + if (null == pileNo) { + handler.forceClose(); + } else { + Boolean tcfg = (Boolean) cachePile.get("tcfg"); + if (tcfg == null || !tcfg) { + String skey = pilekey.concat(".seqhex"); + Thread.sleep(500); + Date date = Calendar.getInstance().getTime(); + String timebin = getTimeBin(seqHex(skey), pileNo, date); + cachePile.put("configTime", DateUtil.format(date, NORM_DATETIME_FORMAT)); REDIS.setCacheMap(pilekey, cachePile); + log.debug("server send time config msg >>>> ({}) |{}|", pileNo, timebin); + if (!handler.isOpen()) { + log.error("send message failed. [{}]({}) connection lost", handler.getName(), pileNo); + removeHandler(pileNo); + } else { + handler.sendClientBinary(HexUtils.toBytes(timebin)); + if (gunId != null) { + hori2(pileNo, gunId); + } + cachePile.put("tcfg", true); + REDIS.setCacheMap(pilekey, cachePile); + } } } } From d4c03942938b62f13919f46e80954e0a5e3a4768 Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Fri, 4 Mar 2022 14:44:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=90=E7=BB=B4?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WorkStationServiceImpl.java | 46 ++++++++++++++++++- .../mapper/XhpcStationDeviceMapper.xml | 6 ++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java index c1496c47..3a29cde4 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkStationServiceImpl.java @@ -3,6 +3,7 @@ package com.xhpc.workorder.service.impl; import cn.hutool.core.util.StrUtil; import com.xhpc.common.core.exception.CustomException; 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.XhpcWorkStationDomain; import com.xhpc.workorder.mapper.XhpcStationDeviceMapper; @@ -26,9 +27,52 @@ public class WorkStationServiceImpl implements WorkStationService { @Resource 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 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 public List> getStationDevice(Map params){ - return deviceMapper.selectStationGunDeviceListByParams(params); + + List> deviceList = deviceMapper.selectStationGunDeviceListByParams(params); + for(Map map : deviceList){ + //状态 + int pileSerialNumber = getTerminalStatus(map.get("gunSerialNumber").toString()); + map.put("workStatus",pileSerialNumber); + } + + + return deviceList; } diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml index c31531d2..008c4899 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml @@ -45,10 +45,14 @@ d2.serial_number as 'gunSerialNumber', d2.brand_model as 'gunBrandModel', 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 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_terminal t on t.serial_number = d2.serial_number WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE' and s.name like concat('%', #{params.stationName}, '%') From af3032dba8d37067a10cb454ee0750b70b63a850 Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Fri, 4 Mar 2022 17:36:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B9=9F=E6=95=B0=E6=8D=AE=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/XhpcWorkOrderMapper.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkOrderMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkOrderMapper.xml index d8492b8e..32550c7e 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkOrderMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcWorkOrderMapper.xml @@ -53,13 +53,15 @@ SELECT o.work_order_id as 'workOrderId', o.title as 'title', - o.type as 'type', + o.type as 'typeId', + td.name as 'typeName', u.dept_id as 'deptId', d.dept_name as 'deptName', u.work_user_id as 'userId', u.user_name as 'userName', o.`status` as 'status' 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_user u on ou.user_id=u.work_user_id LEFT JOIN xhpc_work_dept d on d.work_dept_id=u.dept_id