Commit 0d4fdfe8 by 林永健

[+] 充电桩、充电枪实体定义;充电枪相关接口定义

1 parent 3c59f54b
Showing 16 changed files with 553 additions and 0 deletions
package cn.com.glsx.evbusiness.modules.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 充电枪
*/
@Table(name = "charging_gun")
@Data
public class ChargingGun implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 名称
*/
@Column(name = "`name`")
private String name;
/**
* 桩编号(7byte:BCD)
*/
@Column(name = "pile_id")
private String pileId;
/**
* 枪编号(1byte:BCD)
*/
@Column(name = "gun_number")
private String gunNumber;
/**
* 状态
* @see cn.com.glsx.evbusiness.modules.enums.GunStatusEnums
*/
@Column(name = "gun_status")
private Integer gunStatus;
/**
* 归位状态
* @see cn.com.glsx.evbusiness.modules.enums.GunReturnStatusEnums
*/
@Column(name = "if_return")
private byte ifReturn;
/**
* 插枪状态
* @see cn.com.glsx.evbusiness.modules.enums.GunInUseStatusEnums
*/
@Column(name = "if_charging")
private byte ifCharging;
/**
* 枪线编码 BIN 码
* 没有置零
*/
@Column(name = "gun_wire_number")
private String gunWireNumber;
/**
* SOC BIN 码
* 待机置零;交流桩置零
*/
@Column(name = "soc")
private byte soc;
/**
* 故障类型
* @see cn.com.glsx.evbusiness.modules.enums.HardwareFaultEnums
*/
@Column(name = "hardware_fault")
private String hardwareFault;
/**
* 创建人
*/
@Column(name = "created_by")
private Integer createdBy;
/**
* 更新人
*/
@Column(name = "updated_by")
private Integer updatedBy;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
}
\ No newline at end of file
package cn.com.glsx.evbusiness.modules.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 充电桩
*/
@Table(name = "charging_pile")
@Data
public class ChargingPile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 名称
*/
@Column(name = "`name`")
private String name;
/**
* 桩编号(7byte:BCD)
*/
@Column(name = "pile_id")
private String pileId;
/**
* 充电站ID
*/
@Column(name = "station_id")
private Integer stationId;
/**
* 桩类型(1byte:BIN) 0 表示直流桩,1 表示交流桩
*
* @see cn.com.glsx.evbusiness.modules.enums.PileTypeEnums
*/
@Column(name = "pile_type")
private byte pileType;
/**
* 桩类型(1byte:BIN) 0 表示直流桩,1 表示交流桩
*
* @see cn.com.glsx.evbusiness.modules.enums.PileStatusEnums
*/
@Column(name = "pile_status")
private byte pileStatus;
/**
* 充电枪数量
*/
@Column(name = "gun_count")
private Integer gunCount;
/**
* 通信协议版本(1byte:BIN)
*/
@Column(name = "protocol_version")
private String protocolVersion;
/**
* 网络链接类型(1byte:BIN)
*
* @see cn.com.glsx.evbusiness.modules.enums.PileNetworkTypeEnums
*/
@Column(name = "network_type")
private String networkType;
/**
* Sim卡号(10byte:BCD)
*/
@Column(name = "sim_number")
private String simNumber;
/**
* 运营商
* 0x00 移动
* 0x02 电信
* 0x03 联通
* 0x04 其他
*/
@Column(name = "network_isp")
private String networkIsp;
/**
* 创建人
*/
@Column(name = "created_by")
private Integer createdBy;
/**
* 更新人
*/
@Column(name = "updated_by")
private Integer updatedBy;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
}
\ No newline at end of file
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电枪(占用)插入状态枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum GunInUseStatusEnums {
NO(0, "否"),
YES(1, "是");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电枪归位状态枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum GunReturnStatusEnums {
NO(0, "否"),
YES(1, "是"),
UNKNOWN(2, "未知");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电枪状态枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum GunStatusEnums {
ONLINE(0, "离线"),
FAULT(1, "故障"),
IDLE(2, "空闲"),
CHARGING(3, "充电中");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电桩网络类型枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum PileNetworkTypeEnums {
SIM(0, "SIM卡"),
LAN(1, "LAN"),
WAN(2, "WAN"),
OTHER(3, "其他");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电桩状态枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum PileStatusEnums {
ONLINE(0, "离线"),
OFFLINE(1, "在线");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @Description 充电桩类型枚举
* @Author lyj
* @Date 2023/11/14
* @Version 1.0
*/
@AllArgsConstructor
@Getter
public enum PileTypeEnums {
DIRECT(0, "直流桩"),
ALTERNATE(1, "交流桩");
private Integer code;
private String msg;
}
package cn.com.glsx.evbusiness.modules.mapper;
import cn.com.glsx.evbusiness.modules.entity.ChargingGun;
import cn.com.glsx.evbusiness.modules.model.ChargingGunSearch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ChargingGunMapper extends CommonBaseMapper<ChargingGun> {
List<ChargingGun> page(ChargingGunSearch search);
}
\ No newline at end of file
package cn.com.glsx.evbusiness.modules.mapper;
import cn.com.glsx.evbusiness.modules.entity.ChargingPile;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface ChargingPileMapper extends CommonBaseMapper<ChargingPile> {
@Select("select * from charging_pile where pile_id = #{pileId}")
ChargingPile findByPileId(@Param("pileId") String pileId);
}
\ No newline at end of file
package cn.com.glsx.evbusiness.modules.model;
import cn.com.glsx.evbusiness.modules.entity.ChargingGun;
import cn.com.glsx.evbusiness.modules.entity.ChargingPile;
import lombok.Data;
import java.io.Serializable;
/**
* @Title: 充电枪返回值
* @Author lyj
* @Date 2023/11/14
**/
@Data
public class ChargingGunResp implements Serializable {
private ChargingGun gunInfo;
private ChargingPile pileInfo;
}
package cn.com.glsx.evbusiness.modules.model;
import cn.hutool.db.Page;
import lombok.Data;
/**
* @Title:
* @Description:
* @Author lyj
* @Date 2023/11/14
**/
@Data
public class ChargingGunSearch extends Page {
/**
* 充电桩id
*/
private String pileId;
/**
* 充电枪名称
*/
private String name;
@Override
public int getPageNumber() {
return super.getPageNumber() == 0 ? 1 : super.getPageNumber();
}
}
package cn.com.glsx.evbusiness.modules.controller;
import cn.com.glsx.evbusiness.modules.entity.ChargingGun;
import cn.com.glsx.evbusiness.modules.model.ChargingGunResp;
import cn.com.glsx.evbusiness.modules.model.ChargingGunSearch;
import cn.com.glsx.evbusiness.modules.service.ChargingGunService;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Title: 充电枪接口
* @Description:
* @Author lyj
* @Date 2023/11/14
**/
@Slf4j
@Tag(name = "充电枪接口")
@RestController
@RequestMapping(value = "/chargeGun")
@ResponseResultBody
public class ChargingGunController {
@Autowired
private ChargingGunService gunService;
@Operation(summary = "分页查询充电枪", description = "分页查询充电枪")
@GetMapping
public PageInfo<ChargingGun> page(ChargingGunSearch search) {
return gunService.page(search);
}
@Operation(summary = "查询充电枪详情", description = "查询充电枪详情")
@GetMapping("/{id}")
public ChargingGunResp detail(@PathVariable("id") Long id) {
return gunService.detail(id);
}
}
package cn.com.glsx.evbusiness.modules.service;
import cn.com.glsx.evbusiness.modules.entity.ChargingGun;
import cn.com.glsx.evbusiness.modules.entity.ChargingPile;
import cn.com.glsx.evbusiness.modules.mapper.ChargingGunMapper;
import cn.com.glsx.evbusiness.modules.mapper.ChargingPileMapper;
import cn.com.glsx.evbusiness.modules.model.ChargingGunResp;
import cn.com.glsx.evbusiness.modules.model.ChargingGunSearch;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Title:
* @Description:
* @Author lyj
* @Date 2023/11/14
**/
@Service
public class ChargingGunService {
@Autowired
private ChargingPileMapper pileMapper;
@Autowired
private ChargingGunMapper gunMapper;
public PageInfo<ChargingGun> page(ChargingGunSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<ChargingGun> list = gunMapper.page(search);
return new PageInfo<>(list);
}
public ChargingGunResp detail(Long id) {
ChargingGun gun = gunMapper.selectByPrimaryKey(id);
if (null == gun) {
return null;
}
ChargingGunResp res = new ChargingGunResp();
res.setGunInfo(gun);
ChargingPile pile = pileMapper.findByPileId(gun.getPileId());
res.setPileInfo(pile);
return res;
}
}
<?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="cn.com.glsx.evbusiness.modules.mapper.ChargingGunMapper">
<select id="page" resultType="cn.com.glsx.evbusiness.modules.entity.ChargingGun">
select *
from charging_gun
<where>
<if test="pileId != null and pileId != ''">
and `pile_id` = #{pileId}
</if>
<if test="name != null and name != ''">
and `name` like concat('%',#{name},'%')
</if>
</where>
</select>
</mapper>
\ No newline at end of file
<?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="cn.com.glsx.evbusiness.modules.mapper.ChargingPileMapper">
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!