Merge remote-tracking branch 'origin/master'

This commit is contained in:
fengjundan 2021-07-27 18:38:54 +08:00
commit 25718029fd
17 changed files with 1443 additions and 37 deletions

View File

@ -0,0 +1,62 @@
package com.xhpc.charging.station.controller;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.xhpc.charging.station.domain.XhpcChargingPile;
import com.xhpc.charging.station.dto.XhpcChargingStationDto;
import com.xhpc.charging.station.service.IXhpcChargingPileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2021/7/27 14:44
*/
@RestController
@RequestMapping("/chargingPile")
public class XhpcChargingPileController extends BaseController {
@Autowired
private IXhpcChargingPileService xhpcChargingPileService;
/**
* 桩列表
* @param serialNumber 桩编号
* @param type 桩类型
* @param name 桩名称
* @return
*/
//@PreAuthorize(hasPermi = "system:station:list")
@GetMapping("/list")
public TableDataInfo list(String name, Integer type, Integer status, String serialNumber,Long chargingStationId)
{
startPage();
List<Map<String,Object>> list = xhpcChargingPileService.selectXhpcChargingStationList(name,type,serialNumber,chargingStationId);
return getDataTable(list);
}
/**
* 新增桩
* @return
*/
@PostMapping(value = "/addXhpcChargingPile")
public AjaxResult addXhpcChargingPile(@RequestBody XhpcChargingPile xhpcChargingPile)
{
return AjaxResult.success(xhpcChargingPileService.addXhpcChargingPile(xhpcChargingPile));
}
/**
* 编辑桩
* @return
*/
@PostMapping(value = "/updateXhpcChargingPile")
public AjaxResult updateXhpcChargingPile(@RequestBody XhpcChargingPile xhpcChargingPile)
{
return AjaxResult.success(xhpcChargingPileService.updateXhpcChargingPile(xhpcChargingPile));
}
}

View File

@ -195,7 +195,7 @@ public class XhpcChargingStationController extends BaseController {
* @return
*/
@GetMapping(value = "/getWXXhpcChargingStationMessage")
public AjaxResult getWXXhpcChargingStationMessage(@Param("chargingStationId") Long chargingStationId,@Param("longitude")String longitude,@Param("latitude")String latitude)
public AjaxResult getWXXhpcChargingStationMessage(@RequestParam("chargingStationId") Long chargingStationId,@RequestParam("longitude")String longitude,@RequestParam("latitude")String latitude)
{
return AjaxResult.success(xhpcChargingStationService.getWXXhpcChargingStationMessage(chargingStationId,longitude,latitude));
}
@ -222,4 +222,24 @@ public class XhpcChargingStationController extends BaseController {
return AjaxResult.success(xhpcChargingStationService.getWXXhpcTerminalMassage(chargingStationId));
}
/**
* 编辑电站基本信息
* @return
*/
@PostMapping(value = "/updateXhpcTerminal")
public AjaxResult updateXhpcTerminal(@RequestBody XhpcChargingStation xhpcChargingStation)
{
return AjaxResult.success(xhpcChargingStationService.updateXhpcTerminal(xhpcChargingStation));
}
/**
* 编辑费率
* @return
*/
@PostMapping(value = "/updateXhpcRateTime")
public AjaxResult updateXhpcRateTime(@RequestBody XhpcChargingStationDto xhpcChargingStationDto)
{
return AjaxResult.success(xhpcChargingStationService.updateXhpcRateTime(xhpcChargingStationDto));
}
}

View File

@ -0,0 +1,85 @@
package com.xhpc.charging.station.controller;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.xhpc.charging.station.service.IXhpcTerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2021/7/27 9:29
*/
@RestController
@RequestMapping("/terminal")
public class XhpcTerminalController extends BaseController {
@Autowired
private IXhpcTerminalService xhpcTerminalService;
/**
* 终端列表
* @param serialNumber 终端编号
* @param type 桩类型
* @param status 0启用 1停用
* @param workStatus 0离线 1故障 2空闲 3充电
* @param chargingStationId
* @return
*/
//@PreAuthorize(hasPermi = "system:station:list")
@GetMapping("/list")
public TableDataInfo list(String serialNumber, Integer type,Integer status,String workStatus, Long chargingStationId)
{
startPage();
List<Map<String,Object>> list = xhpcTerminalService.getXhpcTerminalList(serialNumber,type,status,workStatus,chargingStationId);
return getDataTable(list);
}
/**
* 停用
* @return
*/
@PostMapping(value = "/updateStatus")
public AjaxResult updateStatus(Long terminalId,Integer Status)
{
return AjaxResult.success(xhpcTerminalService.updateStatus(terminalId,Status));
}
/**
* 查询
*/
@PostMapping(value = "/selectXhpcTerminalMessage")
public AjaxResult selectXhpcTerminalMessage(Long terminalId)
{
return AjaxResult.success(xhpcTerminalService.selectXhpcTerminalMessage(terminalId));
}
/**
* 修改
* @return
*/
@PostMapping(value = "/updateXhpcTerminalName")
public AjaxResult updateXhpcTerminalName(Long terminalId,String name,String serialNumber)
{
return AjaxResult.success(xhpcTerminalService.updateXhpcTerminalName(terminalId,name,serialNumber));
}
/**
* 终端详情
*/
@PostMapping(value = "/selectXhpcTerminalPileMessage")
public AjaxResult selectXhpcTerminalPileMessage(Long terminalId)
{
return AjaxResult.success(xhpcTerminalService.selectXhpcTerminalPileMessage(terminalId));
}
}

View File

@ -0,0 +1,291 @@
package com.xhpc.charging.station.domain;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* xhpc_charging_pile
* @author yuyang
* @date 2021/7/27 14:11
*/
public class XhpcChargingPile extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 电桩id */
private Long chargingPileId;
/** 电站id */
private Long chargingStationId;
/** 名称 */
private String name;
/** 国标 */
private String nationalStandard;
/** 功率 */
private Double power;
/** 辅助电源支持 */
private Double auxiliaryPowerSupply;
/** 输入电压 */
private Double inputVoltage;
/** 最大电压 */
private Double maxVoltage;
/** 最小电压 */
private Double minVoltage;
/** 最大电流 */
private Double maxElectricCurrent;
/** 最小电流 */
private Double minElectriCurrent;
/** 桩编号 */
private String serialNumber;
/** 桩类型 */
private Integer type;
/** 程序版本 */
private String programVersion;
/** 网络链接类型 */
private String networkLinkType;
/** 终端数量 */
private Integer gunNumber;
/** 通讯协议版本 */
private String communicationProtocolVersion;
/** 通讯运营商 */
private String communicationOperator;
/** Sim卡 */
private String simCard;
/** 状态0正常 1停用 */
private String status;
/** 删除标志0代表存在 2代表删除 */
private Integer delFlag;
/** 计费模型id */
private Long rateModelId;
/** 桩编码 */
private String chargingPileNumber;
public Long getChargingPileId() {
return chargingPileId;
}
public void setChargingPileId(Long chargingPileId) {
this.chargingPileId = chargingPileId;
}
public Long getChargingStationId() {
return chargingStationId;
}
public void setChargingStationId(Long chargingStationId) {
this.chargingStationId = chargingStationId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNationalStandard() {
return nationalStandard;
}
public void setNationalStandard(String nationalStandard) {
this.nationalStandard = nationalStandard;
}
public Double getPower() {
return power;
}
public void setPower(Double power) {
this.power = power;
}
public Double getAuxiliaryPowerSupply() {
return auxiliaryPowerSupply;
}
public void setAuxiliaryPowerSupply(Double auxiliaryPowerSupply) {
this.auxiliaryPowerSupply = auxiliaryPowerSupply;
}
public Double getInputVoltage() {
return inputVoltage;
}
public void setInputVoltage(Double inputVoltage) {
this.inputVoltage = inputVoltage;
}
public Double getMaxVoltage() {
return maxVoltage;
}
public void setMaxVoltage(Double maxVoltage) {
this.maxVoltage = maxVoltage;
}
public Double getMinVoltage() {
return minVoltage;
}
public void setMinVoltage(Double minVoltage) {
this.minVoltage = minVoltage;
}
public Double getMaxElectricCurrent() {
return maxElectricCurrent;
}
public void setMaxElectricCurrent(Double maxElectricCurrent) {
this.maxElectricCurrent = maxElectricCurrent;
}
public Double getMinElectriCurrent() {
return minElectriCurrent;
}
public void setMinElectriCurrent(Double minElectriCurrent) {
this.minElectriCurrent = minElectriCurrent;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getProgramVersion() {
return programVersion;
}
public void setProgramVersion(String programVersion) {
this.programVersion = programVersion;
}
public String getNetworkLinkType() {
return networkLinkType;
}
public void setNetworkLinkType(String networkLinkType) {
this.networkLinkType = networkLinkType;
}
public Integer getGunNumber() {
return gunNumber;
}
public void setGunNumber(Integer gunNumber) {
this.gunNumber = gunNumber;
}
public String getCommunicationProtocolVersion() {
return communicationProtocolVersion;
}
public void setCommunicationProtocolVersion(String communicationProtocolVersion) {
this.communicationProtocolVersion = communicationProtocolVersion;
}
public String getCommunicationOperator() {
return communicationOperator;
}
public void setCommunicationOperator(String communicationOperator) {
this.communicationOperator = communicationOperator;
}
public String getSimCard() {
return simCard;
}
public void setSimCard(String simCard) {
this.simCard = simCard;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Long getRateModelId() {
return rateModelId;
}
public void setRateModelId(Long rateModelId) {
this.rateModelId = rateModelId;
}
public String getChargingPileNumber() {
return chargingPileNumber;
}
public void setChargingPileNumber(String chargingPileNumber) {
this.chargingPileNumber = chargingPileNumber;
}
}

View File

@ -25,8 +25,8 @@ public class XhpcChargingStation extends BaseEntity {
@Excel(name = "运营商id")
private Long operatorId;
/** 电站地址 */
@Excel(name = "电站地址")
/** 电站位置 */
@Excel(name = "电站位置")
private Integer type;
/** 建设场所 */
@ -94,7 +94,7 @@ public class XhpcChargingStation extends BaseEntity {
/** 营业说明 */
@Excel(name = "营业说明")
private String pbusinessInstructions;
private String businessInstructions;
/** 温馨提示说明 */
@Excel(name = "温馨提示说明")
@ -273,14 +273,14 @@ public class XhpcChargingStation extends BaseEntity {
this.imgId = imgId;
}
public String getPbusinessInstructions() {
public String getBusinessInstructions() {
return pbusinessInstructions;
return businessInstructions;
}
public void setPbusinessInstructions(String pbusinessInstructions) {
public void setBusinessInstructions(String businessInstructions) {
this.pbusinessInstructions = pbusinessInstructions;
this.businessInstructions = businessInstructions;
}
public String getReminderInstructions() {

View File

@ -0,0 +1,50 @@
package com.xhpc.charging.station.mapper;
import com.xhpc.charging.station.domain.XhpcChargingPile;
import com.xhpc.charging.station.domain.XhpcChargingStation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2021/7/27 14:37
*/
public interface XhpcChargingPileMapper {
/**
* 桩列表
* @param serialNumber 桩编号
* @param type 桩类型
* @param name 桩名称
* @return
*/
List<Map<String,Object>> selectXhpcChargingStationList(@Param("name") String name, @Param("type")Integer type,@Param("serialNumber") String serialNumber,@Param("chargingStationId")Long chargingStationId);
/**
* 终端
*
* @param xhpcChargingPile 终端
* @return 结果
*/
int addXhpcChargingPile(XhpcChargingPile xhpcChargingPile);
/**
* 查询电站
*
* @param chargingStationId 电站ID
* @return 电站
*/
Map<String,Object> selectXhpcChargingStationById(Long chargingStationId);
/**
* 查询终端
*
* @param chargingPileId 终端ID
* @return 电站
*/
XhpcChargingPile selectXhpcChargingPileById(Long chargingPileId);
}

View File

@ -196,9 +196,17 @@ public interface XhpcChargingStationMapper {
Map<String,Object> getXhpcRateTimeOrderStatistics(@Param("chargingStationId")Long chargingStationId);
/**
* 获取终端列表
* 删除之前的费率
* @param chargingStationId
* @return
*/
List<Map<String,Object>> getXhpcTerminalList(@Param("chargingStationId")Long chargingStationId);
int updateXhpcRate(@Param("chargingStationId")Long chargingStationId);
/**
* 删除之前的费率时段
* @param chargingStationId
* @return
*/
int updateXhpcRateTime(@Param("chargingStationId")Long chargingStationId);
}

View File

@ -1,5 +1,9 @@
package com.xhpc.charging.station.mapper;
import com.xhpc.charging.station.domain.XhpcChargingStation;
import com.xhpc.charging.station.domain.XhpcTerminal;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -18,4 +22,55 @@ public interface XhpcTerminalMapper {
* @return
*/
Map<String,Object> countXhpcTerminalWorkStatus(Long chargingStationId);
/**
* 终端列表
* @param serialNumber 终端编号
* @param type 桩类型
* @param status 0启用 1停用
* @param workStatus 0离线 1故障 2空闲 3充电
* @param chargingStationId
* @return
*/
List<Map<String, Object>> getXhpcTerminalList(@Param("serialNumber") String serialNumber,@Param("type") Integer type,@Param("status") Integer status, @Param("workStatus")String workStatus,@Param("chargingStationId") Long chargingStationId);
/**
* 查询电站
*
* @param terminalId 终端id
* @return 电站
*/
XhpcTerminal selectXhpcTerminalById(Long terminalId);
/**
* 修改终端
*
* @param xhpcTerminal 终端
* @return 结果
*/
int updateXhpcTerminal(XhpcTerminal xhpcTerminal);
/**
* 添加终端
*
* @param xhpcTerminal 终端
* @return 结果
*/
int addXhpcTerminal(XhpcTerminal xhpcTerminal);
/**
* 终端详情
*/
Map<String,Object> selectXhpcTerminalPileMessage(Long terminalId);
/**
* 返回费率时段设置时段
*/
List<Map<String,Object>> getXhpcRateTimeTypeList(@Param("chargingStationId")Long chargingStationId,@Param("type")Integer type);
/**
* 今日充电量今日充电用户今日充电次数
*/
Map<String,Object> getXhpcRateTimeOrderStatistics(@Param("chargingStationId")Long chargingStationId,@Param("gunNumber")String gunNumber);
}

View File

@ -0,0 +1,39 @@
package com.xhpc.charging.station.service;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.xhpc.charging.station.domain.XhpcChargingPile;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2021/7/27 14:36
*/
public interface IXhpcChargingPileService {
/**
* 桩列表
* @param serialNumber 桩编号
* @param type 桩类型
* @param name 桩名称
* @return
*/
List<Map<String,Object>> selectXhpcChargingStationList(String name, Integer type, String serialNumber,Long chargingStationId);
/**
* 添加电站编辑费率
* @param
* @return
*/
AjaxResult addXhpcChargingPile(XhpcChargingPile xhpcChargingPile);
/**
* 编辑电站编辑费率
* @param
* @return
*/
AjaxResult updateXhpcChargingPile(XhpcChargingPile xhpcChargingPile);
}

View File

@ -3,6 +3,7 @@ package com.xhpc.charging.station.service;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.xhpc.charging.station.domain.XhpcChargingStation;
import com.xhpc.charging.station.dto.XhpcChargingStationDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -143,4 +144,17 @@ public interface IXhpcChargingStationService {
*/
List<Map<String,Object>> getWXXhpcTerminalMassage(Long chargingStationId);
/**
* 编辑电站基本信息
* @param
* @return
*/
AjaxResult updateXhpcTerminal(XhpcChargingStation xhpcChargingStation);
/**
* 编辑电站编辑费率
* @param
* @return
*/
AjaxResult updateXhpcRateTime(XhpcChargingStationDto xhpcChargingStationDto);
}

View File

@ -1,5 +1,7 @@
package com.xhpc.charging.station.service;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.List;
import java.util.Map;
@ -19,5 +21,30 @@ public interface IXhpcTerminalService {
*/
public Map<String,Object> countXhpcTerminalWorkStatus(Long chargingStationId);
/**
* 列表接口
*/
List<Map<String, Object>> getXhpcTerminalList(String serialNumber, Integer type,Integer status,String workStatus, Long chargingStationId);
/**
* 停用
* @return
*/
AjaxResult updateStatus(Long terminalId,Integer Status);
/**
* 查询
*/
AjaxResult selectXhpcTerminalMessage(Long terminalId);
/**
* 修改
* @return
*/
AjaxResult updateXhpcTerminalName(Long terminalId,String name,String serialNumber);
/**
* 终端详情
*/
AjaxResult selectXhpcTerminalPileMessage(Long terminalId);
}

View File

@ -0,0 +1,74 @@
package com.xhpc.charging.station.service;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.xhpc.charging.station.domain.XhpcChargingPile;
import com.xhpc.charging.station.domain.XhpcTerminal;
import com.xhpc.charging.station.mapper.XhpcChargingPileMapper;
import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2021/7/27 14:36
*/
@Service
public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService{
@Autowired
private XhpcChargingPileMapper xhpcChargingPileMapper;
@Autowired
private XhpcTerminalMapper xhpcTerminalMapper;
/**
* 桩列表
* @param serialNumber 桩编号
* @param type 桩类型
* @param name 桩名称
* @return
*/
@Override
public List<Map<String,Object>> selectXhpcChargingStationList(String name, Integer type, String serialNumber, Long chargingStationId) {
return xhpcChargingPileMapper.selectXhpcChargingStationList(name,type,serialNumber,chargingStationId);
}
@Override
public AjaxResult addXhpcChargingPile(XhpcChargingPile xhpcChargingPile) {
Long chargingStationId = xhpcChargingPile.getChargingStationId();
//获取计费模型id
Map<String, Object> stringObjectMap = xhpcChargingPileMapper.selectXhpcChargingStationById(chargingStationId);
Long rateModelId = Long.parseLong(stringObjectMap.get("rateModelId").toString());
xhpcChargingPile.setRateModelId(rateModelId);
//
xhpcChargingPileMapper.addXhpcChargingPile(xhpcChargingPile);
//终端
Long chargingPileId=xhpcChargingPile.getChargingPileId();
String serialNumber = xhpcChargingPile.getSerialNumber();
if(xhpcChargingPile.getGunNumber()>0){
for (int i = 0; i < xhpcChargingPile.getGunNumber(); i++) {
XhpcTerminal xhpcTerminal =new XhpcTerminal();
xhpcTerminal.setChargingStationId(chargingStationId);
xhpcTerminal.setChargingPileId(chargingPileId);
xhpcTerminal.setName(serialNumber+"-"+(i+1));
xhpcTerminal.setPileSerialNumber(serialNumber);
xhpcTerminal.setWorkStatus(2);
xhpcTerminal.setStatus(0);
xhpcTerminalMapper.addXhpcTerminal(xhpcTerminal);
}
}
return AjaxResult.success();
}
@Override
public AjaxResult updateXhpcChargingPile(XhpcChargingPile xhpcChargingPile) {
return null;
}
}

View File

@ -212,7 +212,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
if(xhpcChargingStationDto.getParkingInstructions()==null){
return AjaxResult.error(1001,"停车说明不能为空");
}
if(xhpcChargingStationDto.getPbusinessInstructions()==null){
if(xhpcChargingStationDto.getBusinessInstructions()==null){
return AjaxResult.error(1001,"营业时间说明不能为空");
}
if(xhpcChargingStationDto.getReminderInstructions()==null){
@ -293,7 +293,6 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
Long chargingStationId = xhpcChargingStation.getChargingStationId();
//添加费率
Map<Long,Long> map =new HashMap<>();
List<XhpcRateDto> xhpcRateList = xhpcChargingStationDto.getXhpcRateList();
for (int k = 0; k < xhpcRateList.size(); k++) {
@ -393,10 +392,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
map.put("rateTimeList",xhpcRateTimeTypeList);
if(type ==2){
//统计终端充redis获取终端信息
map.putAll(xhpcChargingStationMapper.getXhpcRateTimeOrderStatistics(chargingStationId));
//桩列表
List<Map<String, Object>> xhpcTerminalList = xhpcChargingStationMapper.getXhpcTerminalList(chargingStationId);
map.put("terminalList",xhpcTerminalList);
}
return map;
}
@ -446,7 +443,9 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
List<Map<String, Object>> label_type = xhpcChargingStationMapper.getCode("service_facilities",serviceFacilitiesList);
map.put("serviceFacilities",label_type);
//空闲和使用从redis获取
map.put("free",10);
map.put("common",12);
}
}
return list;
@ -459,7 +458,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
Map<String, Object> map = xhpcChargingStationMapper.getWXXhpcChargingStationMessage(chargingStationId,longitude,latitude);
//桩空闲数量从redis获取
//标签
//服务设施
List<String> serviceFacilitiesList =new ArrayList<>();
if(map.get("serviceFacilities") !=null && map.get("serviceFacilities").toString() !=""){
String[] split = map.get("serviceFacilities").toString().split(",");
@ -468,6 +467,15 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
List<Map<String, Object>> service_facilities = xhpcChargingStationMapper.getCode("service_facilities",serviceFacilitiesList);
map.put("serviceFacilitiesList",service_facilities);
//周边设施
List<String> peripheryFacilities =new ArrayList<>();
if(map.get("peripheryFacilities") !=null && map.get("peripheryFacilities").toString() !=""){
String[] split = map.get("peripheryFacilities").toString().split(",");
peripheryFacilities=Arrays.asList(split);
}
List<Map<String, Object>> charging_periphery_facilities = xhpcChargingStationMapper.getCode("charging_periphery_facilities",peripheryFacilities);
map.put("peripheryFacilities",charging_periphery_facilities);
//图片信息
List<String> imgList =new ArrayList<>();
if(map.get("imgId") !=null && map.get("imgId").toString() !=""){
@ -514,6 +522,169 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
return list;
}
@Override
@Transactional
public AjaxResult updateXhpcTerminal(XhpcChargingStation xhpcChargingStation) {
//电站id不能为空
if(xhpcChargingStation.getChargingStationId() ==null){
return AjaxResult.error("1001","电站id为空");
}
//获取之前的模板id
XhpcChargingStation xhpc= xhpcChargingStationMapper.selectXhpcChargingStationById(xhpcChargingStation.getChargingStationId());
xhpcChargingStation.setRateModelId(xhpc.getRateModelId());
xhpcChargingStationMapper.updateXhpcChargingStation(xhpcChargingStation);
return AjaxResult.success();
}
@Override
public AjaxResult updateXhpcRateTime(XhpcChargingStationDto xhpcChargingStationDto) {
//电站id不能为空
if(xhpcChargingStationDto.getChargingStationId() ==null){
return AjaxResult.error("1001","电站id为空");
}
//电站id不能为空
if(xhpcChargingStationDto.getDefaultPeriodId() ==null){
return AjaxResult.error("1001","默认时段费率id为空");
}
//判断费率和费率时间段 是否有值
if(xhpcChargingStationDto.getXhpcRateList() ==null && xhpcChargingStationDto.getXhpcRateList().size()==0){
return AjaxResult.error(1001,"费率不能为空");
}
if(xhpcChargingStationDto.getXhpcRateTimeList() ==null && xhpcChargingStationDto.getXhpcRateTimeList().size()==0){
return AjaxResult.error(1001,"费率时段不能为空");
}
List<XhpcRateTimeDto> xhpcRateTimeList = xhpcChargingStationDto.getXhpcRateTimeList();
for (int i = 0; i < xhpcRateTimeList.size(); i++) {
XhpcRateTimeDto xhpcRateTime = xhpcRateTimeList.get(i);
String start = xhpcRateTime.getStartTime();
String end = xhpcRateTime.getEndTime();
//检查格式,正则验证 [0-2][0-9][0-6][0][0]{2}
String pattern ="^([0-2][0-9]:([0]|[3])[0]:[0][0])";
Pattern compile = Pattern.compile(pattern);
Matcher m =compile.matcher(start);
boolean isMatch = m.matches();
if(!isMatch){
return AjaxResult.error("1003","时间格式不对");
}
Matcher m1 =compile.matcher(end);
boolean isMatch1 = m1.matches();
if(!isMatch1){
return AjaxResult.error("1003","时间格式不对");
}
//判断结束时间是否小于开始时间
Date startTime = DateUtil.parse(start);
Date endTime = DateUtil.parse(end);
if(startTime.getTime()>endTime.getTime()){
return AjaxResult.error("1002","开始时间不能大于结束时间");
}
}
//判断是否有重叠
for (int i = 0; i < xhpcRateTimeList.size(); i++) {
XhpcRateTimeDto xhpcRateTimeOne = xhpcRateTimeList.get(i);
Date startOne = DateUtil.parse(xhpcRateTimeOne.getStartTime());
Date endOne = DateUtil.parse(xhpcRateTimeOne.getEndTime());
for (int j = i+1; j < xhpcRateTimeList.size(); j++) {
XhpcRateTimeDto xhpcRateTimeTwo = xhpcRateTimeList.get(j);
Date startTwo = DateUtil.parse(xhpcRateTimeTwo.getStartTime());
Date endTwo = DateUtil.parse(xhpcRateTimeTwo.getEndTime());
if (DateUtil.compare(startOne, endTwo)<0&&DateUtil.compare(startTwo, endOne)<0){
return AjaxResult.error("1004","时间段有重叠");
}
}
}
//添加费率计费模型
XhpcRateModel xhpcRateModel = new XhpcRateModel();
BeanUtils.copyProperties(xhpcChargingStationDto,xhpcRateModel);
xhpcRateModel.setRemark("修改");
int i = xhpcChargingStationMapper.addXhpcRateModel(xhpcRateModel);
if(i==0){
return AjaxResult.error("1005","费率计费模型添加失败");
}
//费率模型id
Long rateModelId = xhpcRateModel.getRateModelId();
Long chargingStationId = xhpcChargingStationDto.getChargingStationId();
//获取之前的模板id
XhpcChargingStation xhpc= xhpcChargingStationMapper.selectXhpcChargingStationById(chargingStationId);
xhpc.setRateModelId(rateModelId);
xhpcChargingStationMapper.updateXhpcChargingStation(xhpc);
//删除之前费率费率时段
xhpcChargingStationMapper.updateXhpcRateTime(chargingStationId);
xhpcChargingStationMapper.updateXhpcRate(chargingStationId);
//添加费率
Map<Long,Long> map =new HashMap<>();
List<XhpcRateDto> xhpcRateList = xhpcChargingStationDto.getXhpcRateList();
for (int k = 0; k < xhpcRateList.size(); k++) {
//存费率信息并存储Map,费率时段使用找到费率id
XhpcRateDto xhpcRateDto = xhpcRateList.get(k);
XhpcRate xhpcRate =new XhpcRate();
xhpcRate.setChargingStationId(chargingStationId);
xhpcRate.setName(xhpcRateDto.getName());
xhpcRate.setPowerFee(xhpcRateDto.getPowerFee());
xhpcRate.setServiceFee(xhpcRateDto.getServiceFee());
xhpcRate.setRateModelId(rateModelId);
xhpcChargingStationMapper.addXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(),xhpcRate.getRateId());
}
//添加费率时段
//冒泡排序结束时间小于开始时间排前面
//存费率时段从Map中获取费率id
//每个时间段都要存
//返回计费模型 24:00 转成 00:00
XhpcRateTimeDto [] xhpcRateTimeDtosArr =new XhpcRateTimeDto[xhpcRateTimeList.size()];
xhpcRateTimeList.toArray(xhpcRateTimeDtosArr);
XhpcRateTimeDto [] xhpcRateTimeDtos = bubbleSort(xhpcRateTimeDtosArr);
//排序好的费率时段
List<XhpcRateTimeDto> list = Arrays.asList(xhpcRateTimeDtos);
//默认时段费率Id
Long defaultPeriodId=null;
if(xhpcChargingStationDto.getDefaultPeriodId() !=null){
defaultPeriodId=map.get(xhpcChargingStationDto.getDefaultPeriodId());
}
int sort =1;
for (int k = 0; k < list.size(); k++) {
XhpcRateTimeDto xhpcRateTimeDto = list.get(k);
String startTime = xhpcRateTimeDto.getStartTime();
String endTime = xhpcRateTimeDto.getEndTime();
Long defaultPeriodIdMap = map.get(xhpcRateTimeDto.getId());
if(k==0){
if(!"00:00:00".equals(xhpcRateTimeDto.getStartTime())){
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodId,"00:00:00",startTime,sort,2);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodIdMap,startTime,endTime,sort,1);
}else if(k<list.size()){
//判断上条数据的结束时间是否等于现在这条数据的开始时间不等于添加一条默认费率时段
String endTimeK = list.get(k - 1).getEndTime();
if(!endTimeK.equals(startTime)){
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodId,endTimeK,startTime,sort,2);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodIdMap,startTime,endTime,sort,1);
}else{
String endTimeK = list.get(k - 1).getEndTime();
if(!endTimeK.equals(startTime)){
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodId,endTimeK,startTime,sort,2);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodIdMap,startTime,endTime,sort,1);
if(!endTime.equals("24:00:00")){
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId,rateModelId,defaultPeriodId,startTime,"24:00:00",sort,2);
}
}
}
return AjaxResult.success();
}
public static XhpcRateTimeDto [] bubbleSort(XhpcRateTimeDto [] args){
//冒泡排序算法
for(int i=0;i<args.length-1;i++){

View File

@ -1,5 +1,7 @@
package com.xhpc.charging.station.service;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.xhpc.charging.station.domain.XhpcTerminal;
import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -14,7 +16,7 @@ import java.util.Map;
* @date 2021-07-20
*/
@Service
public class XhpcTerminalServiceImpl implements IXhpcTerminalService{
public class XhpcTerminalServiceImpl implements IXhpcTerminalService{
@Autowired
private XhpcTerminalMapper xhpcTerminalMapper;
@ -29,4 +31,49 @@ public class XhpcTerminalServiceImpl implements IXhpcTerminalService{
return xhpcTerminalMapper.countXhpcTerminalWorkStatus(chargingStationId);
}
@Override
public List<Map<String, Object>> getXhpcTerminalList(String serialNumber, Integer type, Integer status, String workStatus, Long chargingStationId) {
return xhpcTerminalMapper.getXhpcTerminalList(serialNumber,type,status,workStatus,chargingStationId);
}
@Override
public AjaxResult updateStatus(Long terminalId, Integer Status) {
XhpcTerminal xhpcTerminal = xhpcTerminalMapper.selectXhpcTerminalById(terminalId);
xhpcTerminal.setStatus(Status);
xhpcTerminalMapper.updateXhpcTerminal(xhpcTerminal);
return AjaxResult.success();
}
@Override
public AjaxResult selectXhpcTerminalMessage(Long terminalId) {
XhpcTerminal xhpcTerminal = xhpcTerminalMapper.selectXhpcTerminalById(terminalId);
return AjaxResult.success(xhpcTerminal);
}
@Override
public AjaxResult updateXhpcTerminalName(Long terminalId,String name, String serialNumber) {
XhpcTerminal xhpcTerminal = xhpcTerminalMapper.selectXhpcTerminalById(terminalId);
xhpcTerminal.setName(name);
xhpcTerminal.setSerialNumber(serialNumber);
xhpcTerminalMapper.updateXhpcTerminal(xhpcTerminal);
return AjaxResult.success();
}
@Override
public AjaxResult selectXhpcTerminalPileMessage(Long terminalId) {
Map<String, Object> map = xhpcTerminalMapper.selectXhpcTerminalPileMessage(terminalId);
Long chargingStationId =Long.parseLong(map.get("chargingStationId").toString());
String gunNumber = map.get("serialNumber").toString();
//费率时段,先反设置时段在反默认时段
List<Map<String, Object>> xhpcRateTimeTypeList = xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 1);
xhpcRateTimeTypeList.addAll(xhpcTerminalMapper.getXhpcRateTimeTypeList(chargingStationId, 2));
map.put("rateTimeList",xhpcRateTimeTypeList);
//统计终端充redis获取终端信息
map.putAll(xhpcTerminalMapper.getXhpcRateTimeOrderStatistics(chargingStationId,gunNumber));
return AjaxResult.success(map);
}
}

View File

@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.charging.station.mapper.XhpcChargingPileMapper">
<resultMap id="BaseResultMap" type="com.xhpc.charging.station.domain.XhpcChargingPile">
<result property="chargingPileId" column="charging_pile_id" />
<result property="chargingStationId" column="charging_station_id" />
<result property="name" column="name" />
<result property="nationalStandard" column="national_standard" />
<result property="power" column="power" />
<result property="auxiliaryPowerSupply" column="auxiliary_power_supply" />
<result property="inputVoltage" column="input_voltage" />
<result property="maxVoltage" column="max_voltage" />
<result property="minVoltage" column="min_voltage" />
<result property="maxElectricCurrent" column="max_electric_current" />
<result property="minElectriCurrent" column="min_electric_current" />
<result property="serialNumber" column="serial_number" />
<result property="type" column="type" />
<result property="programVersion" column="program_version" />
<result property="networkLinkType" column="network_link_type" />
<result property="gunNumber" column="gun_number" />
<result property="communicationProtocolVersion" column="communication_protocol_version" />
<result property="communicationOperator" column="communication_operator" />
<result property="simCard" column="sim_card" />
<result property="rateModelId" column="rate_model_id" />
<result property="chargingPileNumber" column="charging_pile_number" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectXhpcChargingPileVo">
select charging_pile_id, charging_station_id, name, national_standard, power, auxiliary_power_supply, input_voltage, max_voltage, min_voltage, max_electric_current, min_electric_current, serial_number, type, program_version, network_link_type, gun_number,communication_protocol_version,communication_operator,sim_card,rate_model_id,charging_pile_number,status, del_flag, create_time, create_by, update_time, update_by, remark, rate_model_id from xhpc_charging_pile
</sql>
<select id="selectXhpcChargingStationList" resultType="map">
select
cp.charging_pile_id as chargingPileId,
cp.charging_station_id as chargingStationId,
st.name as chargingStationName,
cp.serial_number as serialNumber,
cp.type as type,
cp.power as power,
cp.gun_number as gunNumber,
cp.status as status
from xhpc_charging_pile as cp
left join xhpc_charging_station as st on st.charging_station_id =cp.charging_station_id
where cp.del_flag =0
<if test="name !=null and name !=''">
and cp.name like CONCAT('%',#{name},'%')
</if>
<if test="type !=null and type !=''">
and cp.type=#{type}
</if>
<if test="serialNumber !=null and serialNumber!=''">
and cp.serial_number=#{serialNumber}
</if>
<if test="chargingStationId !=null and chargingStationId!=''">
and cp.charging_station_id=#{chargingStationId}
</if>
order by cp.create_time desc
</select>
<insert id="addXhpcChargingPile" parameterType="com.xhpc.charging.station.domain.XhpcChargingPile" useGeneratedKeys="true" keyProperty="chargingPileId">
insert into xhpc_charging_pile
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != name ">
name,
</if>
<if test="null != nationalStandard ">
national_standard,
</if>
<if test="null != power ">
power,
</if>
<if test="null != auxiliaryPowerSupply ">
auxiliary_power_supply,
</if>
<if test="null != inputVoltage ">
input_voltage,
</if>
<if test="null != maxVoltage ">
max_voltage,
</if>
<if test="null != minVoltage ">
min_voltage,
</if>
<if test="null != maxElectricCurrent ">
max_electric_current,
</if>
<if test="null != minElectriCurrent ">
min_electric_current,
</if>
<if test="null != serialNumber ">
serial_number,
</if>
<if test="null != type ">
type,
</if>
<if test="null != programVersion ">
program_version,
</if>
<if test="null != networkLinkType ">
network_link_type,
</if>
<if test="null != gunNumber ">
gun_number,
</if>
<if test="null != communicationProtocolVersion ">
communication_protocol_version,
</if>
<if test="null != communicationOperator ">
communication_operator,
</if>
<if test="null != simCard ">
sim_card,
</if>
<if test="null != rateModelId ">
rate_model_id,
</if>
<if test="null != chargingPileNumber ">
charging_pile_number,
</if>
<if test="null != status ">
status,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != name ">
#{name},
</if>
<if test="null != nationalStandard ">
#{nationalStandard},
</if>
<if test="null != power ">
#{power},
</if>
<if test="null != auxiliaryPowerSupply ">
#{auxiliaryPowerSupply},
</if>
<if test="null != inputVoltage ">
#{inputVoltage},
</if>
<if test="null != maxVoltage ">
#{maxVoltage},
</if>
<if test="null != minVoltage ">
#{minVoltage},
</if>
<if test="null != maxElectricCurrent ">
#{maxElectricCurrent},
</if>
<if test="null != minElectriCurrent ">
#{minElectriCurrent},
</if>
<if test="null != serialNumber ">
#{serialNumber},
</if>
<if test="null != type ">
#{type},
</if>
<if test="null != programVersion ">
#{programVersion},
</if>
<if test="null != networkLinkType ">
#{networkLinkType},
</if>
<if test="null != gunNumber ">
#{gunNumber},
</if>
<if test="null != communicationProtocolVersion ">
#{communicationProtocolVersion},
</if>
<if test="null != communicationOperator ">
#{communicationOperator},
</if>
<if test="null != simCard ">
#{simCard},
</if>
<if test="null != rateModelId ">
#{rateModelId},
</if>
<if test="null != chargingPileNumber ">
#{chargingPileNumber},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark}
</if>
</trim>
</insert>
<select id="selectXhpcChargingStationById" resultType="map">
select
charging_station_id as chargingStationId,
rate_model_id as rateModelId
from xhpc_charging_station where charging_station_id=#{chargingStationId}
</select>
<select id="selectXhpcChargingPileById" resultMap="BaseResultMap">
<include refid="selectXhpcChargingPileVo"/>
where charging_pile_id = #{chargingPileId}
</select>
</mapper>

View File

@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="rateModelId" column="rate_model_id" />
<result property="imgId" column="img_id" />
<result property="pbusinessInstructions" column="business_instructions" />
<result property="businessInstructions" column="business_instructions" />
<result property="reminderInstructions" column="reminder_instructions" />
</resultMap>
@ -144,6 +144,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="rateModelId != null">rate_model_id = #{rateModelId},</if>
<if test="businessInstructions != null">business_instructions = #{businessInstructions},</if>
<if test="reminderInstructions != null">reminder_instructions = #{reminderInstructions},</if>
<if test="imgId != null">img_id = #{imgId},</if>
<if test="stationType != null">station_type = #{stationType},</if>
</trim>
where charging_station_id = #{chargingStationId}
</update>
@ -261,7 +265,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
url as url
from xhpc_img where del_flag=0 and status=0
<if test="imgIds !=null and imgIds.size()>0 ">
img_id in
and img_id in
<foreach collection="imgIds" item="chargingStationId" open="(" separator="," close=")">
#{chargingStationId}
</foreach>
@ -393,7 +397,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="null != imgId and '' != imgId">
img_id,
</if>
<if test="null != pbusinessInstructions and '' != pbusinessInstructions">
<if test="null != businessInstructions and '' != businessInstructions">
business_instructions,
</if>
<if test="null != reminderInstructions and '' != reminderInstructions">
@ -470,8 +474,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="null != imgId and '' != imgId">
#{imgId},
</if>
<if test="null != pbusinessInstructions and '' != pbusinessInstructions">
#{pbusinessInstructions},
<if test="null != businessInstructions and '' != businessInstructions">
#{businessInstructions},
</if>
<if test="null != reminderInstructions and '' != reminderInstructions">
#{reminderInstructions},
@ -707,19 +711,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select max(real_time_order_id) from xhpc_real_time_order WHERE to_days(create_time) = to_days(now()) and charging_station_id=#{chargingStationId} group by charging_order_id )
</select>
<select id="getXhpcTerminalList" resultType="map">
select
te.terminal_id as terminalId,
te.name as terminalName,
ct.name as chargingStationName,
te.pile_serial_number as pileSerialNumber,
cp.power as power,
cp.serial_number as serialNumber,
te.status as status,
te.work_status as workStatus
from xhpc_terminal as te
left join xhpc_charging_station as ct on ct.charging_station_id = te.charging_station_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = te.charging_pile_id
where te.charging_station_id=#{chargingStationId} and te.del_flag=0
</select>
<update id="updateXhpcRate">
update xhpc_rate set del_flag =1 where charging_station_id = #{chargingStationId} and del_flag =0
</update>
<update id="updateXhpcRateTime">
update xhpc_rate_time set del_flag =1 where charging_station_id = #{chargingStationId} and del_flag =0
</update>
</mapper>

View File

@ -22,6 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
</resultMap>
<sql id="selectXhpcTerminalVo">
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 from xhpc_terminal
</sql>
<select id="countXhpcTerminalWorkStatus" resultType="map">
select
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=0 and charging_station_id=#{chargingStationId}) offLine,
@ -30,4 +34,218 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=3 and charging_station_id=#{chargingStationId}) charge
from xhpc_terminal LIMIT 1
</select>
<select id="getXhpcTerminalList" resultType="map">
select
te.terminal_id as terminalId,
te.name as terminalName,
ct.name as chargingStationName,
te.pile_serial_number as pileSerialNumber,
cp.power as power,
cp.serial_number as serialNumber,
te.status as status,
te.work_status as workStatus
from xhpc_terminal as te
left join xhpc_charging_station as ct on ct.charging_station_id = te.charging_station_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = te.charging_pile_id
where te.del_flag=0
<if test="chargingStationId !=null">
and te.charging_station_id=#{chargingStationId}
</if>
<if test="serialNumber !=null and serialNumber !=''">
and te.serial_number like CONCAT('%',#{serialNumber},'%')
</if>
<if test="type !=null ">
and cp.type=#{type}
</if>
<if test="status !=null ">
and cp.status=#{status}
</if>
<if test="workStatus !=null and workStatus !=''">
and te.work_status=#{chargingStationId}
</if>
</select>
<select id="selectXhpcTerminalById" resultMap="BaseResultMap">
<include refid="selectXhpcTerminalVo"/>
where terminal_id = #{terminalId}
</select>
<update id="updateXhpcTerminal" parameterType="com.xhpc.charging.station.domain.XhpcTerminal">
update xhpc_terminal
<trim prefix="SET" suffixOverrides=",">
<if test="chargingPileId != null">charging_pile_id = #{chargingPileId},</if>
<if test="chargingStationId != null">charging_station_id = #{chargingStationId},</if>
<if test="name != null">name = #{name},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
<if test="pileSerialNumber != null">pile_serial_number = #{pileSerialNumber},</if>
<if test="gunStatus != null">gun_status = #{gunStatus},</if>
<if test="workStatus != null">work_status = #{workStatus},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where terminal_id = #{terminalId}
</update>
<insert id="addXhpcTerminal" parameterType="com.xhpc.charging.station.domain.XhpcTerminal" useGeneratedKeys="true" keyProperty="terminalId">
insert into xhpc_terminal
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargingPileId ">
charging_pile_id,
</if>
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != name ">
name,
</if>
<if test="null != serialNumber ">
serial_number,
</if>
<if test="null != pileSerialNumber ">
pile_serial_number,
</if>
<if test="null != gunstatus ">
gun_status,
</if>
<if test="null != workStatus ">
work_status,
</if>
<if test="null != status ">
status,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargingPileId ">
#{chargingPileId},
</if>
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != name ">
#{name},
</if>
<if test="null != serialNumber ">
#{serialNumber},
</if>
<if test="null != pileSerialNumber ">
#{pileSerialNumber},
</if>
<if test="null != gunstatus ">
#{gunstatus},
</if>
<if test="null != workStatus ">
#{workStatus},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark}
</if>
</trim>
</insert>
<select id="selectXhpcTerminalPileMessage" resultType="map">
select
ter.terminal_id as terminalId,
ter.charging_station_id as ter.chargingStationId,
ter.name as name,
ter.serial_number as serialNumber,
ter.gun_status as gunStatus,
ter.work_status as workStatus,
ter.status as status,
ct.name as chargingStationName,
ter.create_time as createTime,
cp.serial_number as pileSerialNumber,
cp.type as type,
cp.national_standard as nationalStandard,
cp.power as power,
cp.auxiliary_power_supply as auxiliaryPowerSupply,
cp.input_voltage as inputVoltage,
cp.max_voltage as maxVoltage,
cp.min_voltage as minVoltage,
cp.max_electric_current as maxElectricCurrent,
cp.min_electric_current as minElectricCurrent,
cp.communication_operator as communicationOperator,
cp.sim_card as simCard
from xhpc_terminal as ter
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join xhpc_charging_station as ct on ct.charging_station_id = ter.charging_station_id
where ter.terminal_id =#{terminalId}
</select>
<select id="getXhpcRateTimeTypeList" resultType="map">
<if test="type ==1">
select
rt.start_time as startTime,
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
rt.rate_id as rateId,
ra.name as rateName
from xhpc_rate_time as rt
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=1
</if>
<if test="type ==2">
select
rt.start_time as startTime,
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
rt.rate_id as rateId,
ra.name as rateName
from xhpc_rate_time as rt
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=2
group by type
</if>
</select>
<select id="getXhpcRateTimeOrderStatistics" resultType="map">
select
sum(charging_degree) as chargingDegreeSum,
COUNT(real_time_order_id) as realTimeOrderIdCount,
COUNT(DISTINCT user_id) as userIdCount
from xhpc_real_time_order
where real_time_order_id in (
select max(real_time_order_id) from xhpc_real_time_order WHERE to_days(create_time) = to_days(now()) and charging_station_id=#{chargingStationId} and gun_number =#{gunNumber} group by charging_order_id )
</select>
</mapper>