From e23777fc9320ecd97bca2b628ff5234ec8172655 Mon Sep 17 00:00:00 2001 From: panshuling321 Date: Thu, 28 Apr 2022 13:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E7=B3=BB=E7=BB=9F=E6=89=80=E9=9C=80=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E7=9A=84=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/XhpcChargingPileMapper.java | 2 + .../mapper/XhpcChargingStationMapper.java | 2 + .../mapper/XhpcStationDeviceMapper.java | 2 + .../activity/mapper/XhpcTerminalMapper.java | 132 ++++++ .../mapper/XhpcWorkStationMapper.java | 6 + .../activity/task/SyncDeviceDataTask.java | 93 ++++ .../mapper/XhpcChargingPileMapper.xml | 42 ++ .../mapper/XhpcChargingStationMapper.xml | 5 + .../mapper/XhpcStationDeviceMapper.xml | 11 +- .../resources/mapper/XhpcTerminalMapper.xml | 410 ++++++++++++++++++ .../mapper/XhpcWorkStationMapper.xml | 47 +- 11 files changed, 750 insertions(+), 2 deletions(-) create mode 100644 xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcTerminalMapper.java create mode 100644 xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/SyncDeviceDataTask.java create mode 100644 xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcTerminalMapper.xml diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingPileMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingPileMapper.java index ade97a37..129a7671 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingPileMapper.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingPileMapper.java @@ -54,4 +54,6 @@ public interface XhpcChargingPileMapper { XhpcChargingPile getXhpcChargingPileBySerialNumber(@Param("serialNumber") String serialNumber); + + List selectByStationId(@Param("stationId") String stationId); } diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingStationMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingStationMapper.java index 656a648b..610d5f2d 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingStationMapper.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcChargingStationMapper.java @@ -1,5 +1,6 @@ package com.xhpc.activity.mapper; +import com.xhpc.common.domain.XhpcChargingStation; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -28,4 +29,5 @@ public interface XhpcChargingStationMapper { List> selectBaseRateTimeListByRateId(@Param("rateId")Integer rateId); + List selectAll(); } diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcStationDeviceMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcStationDeviceMapper.java index 5b8cf705..bc562591 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcStationDeviceMapper.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcStationDeviceMapper.java @@ -33,4 +33,6 @@ public interface XhpcStationDeviceMapper { int updateByPrimaryKey(XhpcStationDeviceDomain record); + XhpcStationDeviceDomain selectBySerialNumber(@Param("serialNumber")String serialNumber); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcTerminalMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcTerminalMapper.java new file mode 100644 index 00000000..68c925e2 --- /dev/null +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcTerminalMapper.java @@ -0,0 +1,132 @@ +package com.xhpc.activity.mapper; + +import com.xhpc.common.domain.XhpcTerminal; +import org.apache.ibatis.annotations.Param; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 终端Mapper接口 + * + * @author yuyang + * @date 2021-07-19 + */ +public interface XhpcTerminalMapper { + + + /** + * PC端页面统计 + * + * @param chargingStationId 电站id + * @return + */ + Map countXhpcTerminalWorkStatus(Long chargingStationId); + + /** + * 终端列表 + * + * @param serialNumber 终端编号 + * @param type 桩类型 + * @param status 0启用 1停用 + * @param workStatus 0离线 1故障 2空闲 3充电 + * @param chargingStationId + * @return + */ + List> getXhpcTerminalList(@Param("serialNumber") String serialNumber, @Param("type") Integer type, @Param("status") Integer status, @Param("workStatus") String workStatus, @Param("chargingStationId") Long chargingStationId, @Param("tenantId") String tenantId); + + + /** + * 查询电站 + * + * @param terminalId 终端id + * @return 电站 + */ + XhpcTerminal selectXhpcTerminalById(Long terminalId); + + + /** + * 修改终端 + * + * @param xhpcTerminal 终端 + * @return 结果 + */ + int updateXhpcTerminal(@Param("name") String name,@Param("serialNumber") String serialNumber,@Param("connectorType") Integer connectorType,@Param("status") Integer status,@Param("terminalId") Long terminalId); + + /** + * 添加终端 + * + * @param xhpcTerminal 终端 + * @return 结果 + */ + int insertXhpcTerminal(XhpcTerminal xhpcTerminal); + + /** + * 终端详情 + */ + Map selectXhpcTerminalPileMessage(Long terminalId); + + /** + * 返回费率时段(设置时段) + */ + List> getXhpcRateTimeTypeList(@Param("chargingStationId") Long chargingStationId, @Param("type") Integer type); + + /** + * 今日充电量、今日充电用户、今日充电次数 + */ + Map getXhpcRateTimeOrderStatistics(@Param("chargingStationId") Long chargingStationId, @Param("terminalId")Long terminalId); + + /** + * 通过终端编号进入小程序开始充电页面 + * + * @param pNum 终端编号 + * @return + */ + Map getWXpNumMessage(@Param("pNum") String pNum); + + + /** + * 获取图片信息 + * + * @param imgIds + * @return + */ + List> getImageList(@Param("imgIds") List imgIds); + + /** + * 查询所有桩名称、场站名称、终端编号 + * @return + */ + List> selectPileNameAndStationNameAndTerminalNum(); + + /** + * 查询桩名称、场站名称、终端编号 + * @param terminalSerialNumber 搜索参数:终端名称 + * @param pileName 搜索参数:桩名 + * @param stationName 搜索参数:站名 + * @return list + */ + List> getXhpcPileNameAndStationNameAndTerminalNumList(@Param("terminalSerialNumber") String terminalSerialNumber, @Param("pileName") String pileName, @Param("stationName") String stationName); + + + /** + * 根据电站获取终端的编号 + * + * @param chargingStationId + * @return + */ + List getTerminal(@Param("chargingStationId") Long chargingStationId, @Param("status") Integer status); + + /** + * according pileIds query xhpcTerminalList + * + * @author WH + * @date 2022/2/17 11:13 + * @since version-1.0 + */ + List selectXhpcTerminalIdByPileIds(ArrayList pileIds); + + + List selectByPileId(@Param("pileId")String pileId); +} diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkStationMapper.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkStationMapper.java index 4fb4c11e..d2b269a1 100644 --- a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkStationMapper.java +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/mapper/XhpcWorkStationMapper.java @@ -18,6 +18,12 @@ public interface XhpcWorkStationMapper { int insert(XhpcWorkStationDomain record); + int insertBatch(@Param("domainList") List domainList); + + List selectBySerialNumbers(@Param("serialNumbers")String serialNumbers); + + XhpcWorkStationDomain selectBySerialNumber(@Param("serialNumber")String serialNumbers); + int insertSelective(XhpcWorkStationDomain record); XhpcWorkStationDomain selectByPrimaryKey(Long workStationId); diff --git a/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/SyncDeviceDataTask.java b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/SyncDeviceDataTask.java new file mode 100644 index 00000000..b896cad2 --- /dev/null +++ b/xhpc-modules/xhpc-activity/src/main/java/com/xhpc/activity/task/SyncDeviceDataTask.java @@ -0,0 +1,93 @@ +package com.xhpc.activity.task; + + +import com.xhpc.activity.domain.XhpcStationDeviceDomain; +import com.xhpc.activity.domain.XhpcWorkStationDomain; +import com.xhpc.activity.mapper.*; +import com.xhpc.common.core.utils.bean.BeanUtils; +import com.xhpc.common.domain.XhpcChargingPile; +import com.xhpc.common.domain.XhpcChargingStation; +import com.xhpc.common.domain.XhpcTerminal; +import com.xhpc.common.enums.StationDeviceEnum; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +@Component +public class SyncDeviceDataTask { + + @Resource + XhpcWorkStationMapper stationMapper; + @Resource + XhpcStationDeviceMapper deviceMapper; + + @Resource + XhpcChargingStationMapper chargingStationMapper; + @Resource + XhpcChargingPileMapper chargingPileMapper; + @Resource + XhpcTerminalMapper terminalMapper; + + + /** + * 自动同步场站设备信息 + */ + @Scheduled(cron = "0 0 18 * * ?") + private void autoClearDeviceMessageData(){ + List chargingStationList = chargingStationMapper.selectAll(); + for (XhpcChargingStation chargingStation: chargingStationList){ + XhpcWorkStationDomain workStationDomain = stationMapper.selectBySerialNumber(chargingStation.getSerialNumber()); + if(workStationDomain == null){ + workStationDomain = new XhpcWorkStationDomain(); + BeanUtils.copyProperties(chargingStation, workStationDomain); + workStationDomain.setWorkStationId(chargingStation.getChargingStationId()); + stationMapper.insert(workStationDomain); + } + List chargingPileList = chargingPileMapper.selectByStationId(chargingStation.getChargingStationId().toString()); + int sort=1; + for(XhpcChargingPile chargingPile: chargingPileList){ + XhpcStationDeviceDomain pileDeviceDomain = deviceMapper.selectBySerialNumber(chargingPile.getSerialNumber()); + if(pileDeviceDomain == null){ + pileDeviceDomain = new XhpcStationDeviceDomain(); + pileDeviceDomain.setDeviceName(chargingPile.getName() + "号桩"); + pileDeviceDomain.setDeviceType(StationDeviceEnum.PILE.getCode()); + pileDeviceDomain.setCurrentType(chargingPile.getType() == 1? "直流(快)": "交流(慢)"); //// + pileDeviceDomain.setStationId(workStationDomain.getWorkStationId()); + pileDeviceDomain.setBrandModel(chargingPile.getBrandModel()); + pileDeviceDomain.setParentDeviceId(null); + pileDeviceDomain.setSerialNumber(chargingPile.getSerialNumber()); + pileDeviceDomain.setSorted(sort); sort ++; + pileDeviceDomain.setStatus(Short.parseShort(chargingPile.getStatus().toString())); + pileDeviceDomain.setDelFlag(Short.parseShort(chargingPile.getDelFlag().toString())); + pileDeviceDomain.setCreateBy(chargingPile.getCreateBy()); + pileDeviceDomain.setUpdateBy(chargingPile.getUpdateBy()); + deviceMapper.insert(pileDeviceDomain); + } + + + List terminalList = terminalMapper.selectByPileId(chargingPile.getChargingPileId().toString()); + for(XhpcTerminal terminal: terminalList){ + XhpcStationDeviceDomain gunDeviceDomain = deviceMapper.selectBySerialNumber(terminal.getSerialNumber()); + if(gunDeviceDomain == null){ + gunDeviceDomain = new XhpcStationDeviceDomain(); + gunDeviceDomain.setDeviceName(terminal.getName()); + gunDeviceDomain.setDeviceType(StationDeviceEnum.TERMINAL.getCode()); + gunDeviceDomain.setCurrentType(chargingPile.getType() == 1? "直流(快)": "交流(慢)"); //// + gunDeviceDomain.setStationId(workStationDomain.getWorkStationId()); + gunDeviceDomain.setBrandModel(chargingPile.getBrandModel()); + gunDeviceDomain.setParentDeviceId(pileDeviceDomain.getDeviceId()); + gunDeviceDomain.setSerialNumber(terminal.getSerialNumber()); + gunDeviceDomain.setSorted(sort); sort ++; + gunDeviceDomain.setStatus(Short.parseShort(terminal.getStatus().toString())); + gunDeviceDomain.setDelFlag(Short.parseShort(terminal.getDelFlag().toString())); + gunDeviceDomain.setCreateBy(terminal.getCreateBy()); + gunDeviceDomain.setUpdateBy(terminal.getUpdateBy()); + deviceMapper.insert(gunDeviceDomain); + } + } + } + } + } +} diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingPileMapper.xml index 75f9772f..25fbbcff 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingPileMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -432,4 +432,46 @@ from xhpc_charging_pile where serial_number = #{serialNumber} + + + + diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingStationMapper.xml index d38a99d5..f3c7e179 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -62,4 +62,9 @@ FROM xhpc_rate WHERE rate_model_id=#{rateId}; + + + diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcStationDeviceMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcStationDeviceMapper.xml index 5b431eb4..320c2346 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcStationDeviceMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcStationDeviceMapper.xml @@ -195,7 +195,8 @@ from xhpc_station_device where device_id = #{deviceId,jdbcType=INTEGER} - + + update xhpc_station_device set del_flag = 2 where device_id = #{deviceId,jdbcType=INTEGER} @@ -339,4 +340,12 @@ update_by = #{updateBy,jdbcType=VARCHAR} where device_id = #{deviceId,jdbcType=INTEGER} + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcTerminalMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcTerminalMapper.xml new file mode 100644 index 00000000..0189b331 --- /dev/null +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcTerminalMapper.xml @@ -0,0 +1,410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select terminal_id, + charging_pile_id, + charging_station_id, + name, + serial_number, + pile_serial_number, + gun_status, + work_status, + status, + del_flag, + create_time, + create_by, + update_time, + update_by, + remark, + connector_type + from xhpc_terminal + + + + + + + + + + + update xhpc_terminal + + + name = #{name}, + + + serial_number = #{serialNumber}, + + + status = #{status}, + + + connector_type = #{connectorType}, + + + where terminal_id = #{terminalId} + + + + insert into xhpc_terminal + + + charging_pile_id, + + + charging_station_id, + + + name, + + + serial_number, + + + pile_serial_number, + + + gun_status, + + + work_status, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + rate_model_id, + + + number, + + + operator_id_evcs, + + + tenant_id, + + + + + #{chargingPileId}, + + + #{chargingStationId}, + + + #{name}, + + + #{serialNumber}, + + + #{pileSerialNumber}, + + + #{gunStatus}, + + + #{workStatus}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{rateModelId}, + + + #{number}, + + + #{operatorIdEvcs}, + + + #{tenantId}, + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkStationMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkStationMapper.xml index 86394c5c..b03dd4a4 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkStationMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkStationMapper.xml @@ -98,6 +98,7 @@ from xhpc_work_station where work_station_id = #{workStationId,jdbcType=BIGINT} + update xhpc_work_station set del_flag=2 where work_station_id = #{workStationId,jdbcType=BIGINT} @@ -273,7 +274,8 @@ - + + update xhpc_work_station @@ -373,4 +375,47 @@ tenant_id = #{tenantId,jdbcType=VARCHAR} where work_station_id = #{workStationId,jdbcType=BIGINT} + + + + insert into xhpc_work_station (work_station_id, `name`, operator_id, `type`, + construction_site, service_facilities, periphery_facilities, + address, detailed_address, longitude, + latitude, parking_instructions, serial_number, + `status`, del_flag, create_time, + create_by, update_time, update_by, + remark, business_instructions, reminder_instructions, + img_id, station_type, service_tel, + park_nums, tenant_id) + values + + (#{domain.workStationId}, #{domain.name}, #{domain.operatorId}, #{domain.type}, + #{domain.constructionSite}, #{domain.serviceFacilities}, #{domain.peripheryFacilities}, + #{domain.address}, #{domain.detailedAddress}, #{domain.longitude}, + #{domain.latitude}, #{domain.parkingInstructions}, #{domain.serialNumber}, + #{domain.status}, 0, sysdate(), + #{domain.createBy}, sysdate(), #{domain.updateBy}, + #{domain.remark}, #{domain.businessInstructions}, #{domain.reminderInstructions}, + #{domain.imgId}, #{domain.stationType}, #{domain.serviceTel}, + #{domain.parkNums}, #{domain.tenantId}) + + + + + + + + + + \ No newline at end of file