作者 shenhailong

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

  1 +package com.sunyo.energy.location.dao;
  2 +
  3 +import com.sunyo.energy.location.model.ElectrifyInfo;
  4 +
  5 +public interface ElectrifyInfoMapper {
  6 + int deleteByPrimaryKey(Integer id);
  7 +
  8 + int insert(ElectrifyInfo record);
  9 +
  10 + int insertSelective(ElectrifyInfo record);
  11 +
  12 + ElectrifyInfo selectByPrimaryKey(Integer id);
  13 +
  14 + int updateByPrimaryKeySelective(ElectrifyInfo record);
  15 +
  16 + int updateByPrimaryKey(ElectrifyInfo record);
  17 +}
  1 +package com.sunyo.energy.location.model;
  2 +
  3 +public class ElectrifyInfo {
  4 + private Integer id;
  5 +
  6 + private String deviceid;
  7 +
  8 + public Integer getId() {
  9 + return id;
  10 + }
  11 +
  12 + public void setId(Integer id) {
  13 + this.id = id;
  14 + }
  15 +
  16 + public String getDeviceid() {
  17 + return deviceid;
  18 + }
  19 +
  20 + public void setDeviceid(String deviceid) {
  21 + this.deviceid = deviceid == null ? null : deviceid.trim();
  22 + }
  23 +}
@@ -34,6 +34,9 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { @@ -34,6 +34,9 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
34 @Autowired 34 @Autowired
35 USERSMapper usersMapper; 35 USERSMapper usersMapper;
36 36
  37 + @Autowired
  38 + ElectrifyInfoMapper electrifyInfoMapper;
  39 +
37 40
38 /** 41 /**
39 * 获取电表实时数据/余额 42 * 获取电表实时数据/余额
@@ -111,20 +114,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { @@ -111,20 +114,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
111 } 114 }
112 if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) { 115 if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) {
113 log.info("电表充值成功,充值额度:{}", money); 116 log.info("电表充值成功,充值额度:{}", money);
114 -  
115 - /**  
116 - * 充值成功送电  
117 - */  
118 - ElectricityMeter energyInfoForRealTime = getEnergyInfoForRealTime(deviceId);  
119 - if (energyInfoForRealTime.getBalance() != null){  
120 - int i = energyInfoForRealTime.getBalance().compareTo(BigDecimal.ZERO);  
121 - if (i > 0){  
122 - Map<String, Object> map = new HashMap<>();  
123 - map.put("deviceId", deviceId);  
124 - map.put("action", "1");  
125 - HttpsUtils.sendPost(remoteControlDevices, map);  
126 - }  
127 - } 117 + // 插入临时表交由定时服务处理
  118 + ElectrifyInfo electrifyInfo1 = new ElectrifyInfo();
  119 + electrifyInfo1.setDeviceid(deviceId);
  120 + electrifyInfoMapper.insertSelective(electrifyInfo1);
  121 + log.info("送电信息插入临时表-----------------------------------");
128 return 1; 122 return 1;
129 } else { 123 } else {
130 log.info("电表充值失败,充值额度:{}", money); 124 log.info("电表充值失败,充值额度:{}", money);
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 <property name="enableSubPackages" value="true"/> 47 <property name="enableSubPackages" value="true"/>
48 </javaClientGenerator> 48 </javaClientGenerator>
49 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> 49 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
50 - <table tableName="electricity_info" domainObjectName="ElectricityInfo" enableCountByExample="false" 50 + <table tableName="electrify_info" domainObjectName="ElectrifyInfo" enableCountByExample="false"
51 enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" 51 enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
52 selectByExampleQueryId="true"></table> 52 selectByExampleQueryId="true"></table>
53 </context> 53 </context>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.sunyo.energy.location.dao.ElectrifyInfoMapper" >
  4 + <resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.ElectrifyInfo" >
  5 + <id column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="deviceId" property="deviceid" jdbcType="VARCHAR" />
  7 + </resultMap>
  8 + <sql id="Base_Column_List" >
  9 + id, deviceId
  10 + </sql>
  11 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  12 + select
  13 + <include refid="Base_Column_List" />
  14 + from electrify_info
  15 + where id = #{id,jdbcType=INTEGER}
  16 + </select>
  17 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  18 + delete from electrify_info
  19 + where id = #{id,jdbcType=INTEGER}
  20 + </delete>
  21 + <insert id="insert" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
  22 + insert into electrify_info (id, deviceId)
  23 + values (#{id,jdbcType=INTEGER}, #{deviceid,jdbcType=VARCHAR})
  24 + </insert>
  25 + <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
  26 + insert into electrify_info
  27 + <trim prefix="(" suffix=")" suffixOverrides="," >
  28 + <if test="id != null" >
  29 + id,
  30 + </if>
  31 + <if test="deviceid != null" >
  32 + deviceId,
  33 + </if>
  34 + </trim>
  35 + <trim prefix="values (" suffix=")" suffixOverrides="," >
  36 + <if test="id != null" >
  37 + #{id,jdbcType=INTEGER},
  38 + </if>
  39 + <if test="deviceid != null" >
  40 + #{deviceid,jdbcType=VARCHAR},
  41 + </if>
  42 + </trim>
  43 + </insert>
  44 + <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
  45 + update electrify_info
  46 + <set >
  47 + <if test="deviceid != null" >
  48 + deviceId = #{deviceid,jdbcType=VARCHAR},
  49 + </if>
  50 + </set>
  51 + where id = #{id,jdbcType=INTEGER}
  52 + </update>
  53 + <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.ElectrifyInfo" >
  54 + update electrify_info
  55 + set deviceId = #{deviceid,jdbcType=VARCHAR}
  56 + where id = #{id,jdbcType=INTEGER}
  57 + </update>
  58 +</mapper>