Commit 2d232289 by 林永健

修改bug

1 parent 75ecd16f
......@@ -5,7 +5,6 @@ import cn.com.glsx.evbusiness.modules.model.request.ChargingGunSearch;
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;
import java.util.List;
......@@ -13,6 +12,5 @@ import java.util.List;
public interface ChargingGunMapper extends CommonBaseMapper<ChargingGun> {
List<ChargingGun> page(ChargingGunSearch search);
@Select("select * from charging_gun where pileId = #{pileId} and gun_number = #{gunNumber}")
ChargingGun findByPileIdAndNumber(@Param("pileId") String pileId, @Param("gunNumber") byte gunNumber);
}
\ No newline at end of file
......@@ -4,11 +4,9 @@ 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
......@@ -46,7 +46,7 @@ public class ChargingGunService {
List<ChargingGun> list = gunMapper.page(search);
if (!CollectionUtils.isEmpty(list)) {
Function<ChargingGun, ChargingGunResponse> mapHandle = search.isShowDetail() ?
ChargingGunConverter.INSTANCE::toResp : this::detail;
this::detail : ChargingGunConverter.INSTANCE::toResp;
res.setList(list.stream().map(mapHandle).collect(Collectors.toList()));
}
return res;
......@@ -56,11 +56,15 @@ public class ChargingGunService {
return detail(gunMapper.selectByPrimaryKey(id));
}
public ChargingGunResponse detail(ChargingGun gun) {
if (null == gun) {
if (Objects.isNull(gun)) {
return null;
}
ChargingGunResponse res = ChargingGunConverter.INSTANCE.toResp(gun);
ChargingPile pile = pileService.getByPileId(gun.getPileId());
if (Objects.isNull(pile)) {
log.warn("该枪设备无绑定充电桩,请检查, gun: {}", gun);
return res;
}
res.setPileInfo(ChargingPileConverter.INSTANCE.toResp(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">
<resultMap id="BaseResult" type="cn.com.glsx.evbusiness.modules.entity.ChargingGun">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pile_id" jdbcType="VARCHAR" property="pileId" />
<result column="gun_number" jdbcType="TINYINT" property="gunNumber" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="if_return" jdbcType="TINYINT" property="ifReturn" />
<result column="if_charging" jdbcType="TINYINT" property="ifCharging" />
<result column="gun_wire_number" jdbcType="VARCHAR" property="gunWireNumber" />
<result column="hardware_fault" jdbcType="SMALLINT" property="hardwareFault" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
</resultMap>
<sql id="Base_Column_List">
id, name, pile_id, gun_number, status, if_return, if_charging, gun_wire_number, hardware_fault, created_by, updated_by, created_time, updated_time
</sql>
<select id="page" resultType="cn.com.glsx.evbusiness.modules.entity.ChargingGun">
select *
<select id="page" resultMap="BaseResult">
select
<include refid="Base_Column_List" />
from charging_gun
<where>
<if test="pileId != null and pileId != ''">
......@@ -15,4 +34,8 @@
</if>
</where>
</select>
<select id="findByPileIdAndNumber" resultMap="BaseResult">
select * from charging_gun where pileId = #{pileId} and gun_number = #{gunNumber}
</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">
<resultMap id="BaseResult" type="cn.com.glsx.evbusiness.modules.entity.ChargingPile">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="pile_id" jdbcType="VARCHAR" property="pileId"/>
<result column="station_id" jdbcType="VARCHAR" property="stationId"/>
<result column="model_code" jdbcType="VARCHAR" property="modelCode"/>
<result column="point_type" jdbcType="TINYINT" property="pointType"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="gun_count" jdbcType="TINYINT" property="gunCount"/>
<result column="protocol_version" jdbcType="TINYINT" property="protocolVersion"/>
<result column="soft_version" jdbcType="VARCHAR" property="softVersion"/>
<result column="network" jdbcType="TINYINT" property="network"/>
<result column="sim" jdbcType="VARCHAR" property="sim"/>
<result column="operator" jdbcType="TINYINT" property="operator"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
</resultMap>
<sql id="Base_Column_List">
id,name,pile_id,station_id,model_code,point_type,status,gun_count,protocol_version,soft_version,network,sim,operator,created_by,updated_by,created_time,updated_time
</sql>
<select id="findByPileId" resultMap="BaseResult">
select * from charging_pile where pile_id = #{pileId}
</select>
</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!