作者 shenhailong

添加电表充值成功后 插入送电临时表

package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.ElectrifyInfo;
public interface ElectrifyInfoMapper {
int deleteByPrimaryKey(Integer id);
int insert(ElectrifyInfo record);
int insertSelective(ElectrifyInfo record);
ElectrifyInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ElectrifyInfo record);
int updateByPrimaryKey(ElectrifyInfo record);
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.model;
public class ElectrifyInfo {
private Integer id;
private String deviceid;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDeviceid() {
return deviceid;
}
public void setDeviceid(String deviceid) {
this.deviceid = deviceid == null ? null : deviceid.trim();
}
}
\ No newline at end of file
... ...
... ... @@ -34,6 +34,9 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
@Autowired
USERSMapper usersMapper;
@Autowired
ElectrifyInfoMapper electrifyInfoMapper;
/**
* 获取电表实时数据/余额
... ... @@ -111,20 +114,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
}
if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) {
log.info("电表充值成功,充值额度:{}", money);
/**
* 充值成功送电
*/
ElectricityMeter energyInfoForRealTime = getEnergyInfoForRealTime(deviceId);
if (energyInfoForRealTime.getBalance() != null){
int i = energyInfoForRealTime.getBalance().compareTo(BigDecimal.ZERO);
if (i > 0){
Map<String, Object> map = new HashMap<>();
map.put("deviceId", deviceId);
map.put("action", "1");
HttpsUtils.sendPost(remoteControlDevices, map);
}
}
// 插入临时表交由定时服务处理
ElectrifyInfo electrifyInfo1 = new ElectrifyInfo();
electrifyInfo1.setDeviceid(deviceId);
electrifyInfoMapper.insertSelective(electrifyInfo1);
log.info("送电信息插入临时表-----------------------------------");
return 1;
} else {
log.info("电表充值失败,充值额度:{}", money);
... ...
... ... @@ -47,7 +47,7 @@
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="electricity_info" domainObjectName="ElectricityInfo" enableCountByExample="false"
<table tableName="electrify_info" domainObjectName="ElectrifyInfo" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="true"></table>
</context>
... ...
<?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.sunyo.energy.location.dao.ElectrifyInfoMapper" >
<resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.ElectrifyInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="deviceId" property="deviceid" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, deviceId
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from electrify_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from electrify_info
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
insert into electrify_info (id, deviceId)
values (#{id,jdbcType=INTEGER}, #{deviceid,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
insert into electrify_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="deviceid != null" >
deviceId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="deviceid != null" >
#{deviceid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
update electrify_info
<set >
<if test="deviceid != null" >
deviceId = #{deviceid,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
update electrify_info
set deviceId = #{deviceid,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...