正在显示
5 个修改的文件
包含
199 行增加
和
34 行删除
| 1 | +package com.sunyo.energy.location.controller; | ||
| 2 | + | ||
| 3 | +import com.github.pagehelper.Page; | ||
| 4 | +import com.github.pagehelper.PageHelper; | ||
| 5 | +import com.github.pagehelper.PageInfo; | ||
| 6 | +import com.sunyo.energy.location.dao.WaterMeterSaccMapper; | ||
| 7 | +import com.sunyo.energy.location.model.WaterMeterSacc; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.stereotype.Controller; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 12 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @author shenhailong | ||
| 18 | + * <p> | ||
| 19 | + * 2020/7/7/15:48 | ||
| 20 | + */ | ||
| 21 | +@Controller | ||
| 22 | +@RequestMapping("/water_meter_sacc") | ||
| 23 | +public class WaterMeterSaccController { | ||
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + WaterMeterSaccMapper waterMeterSaccMapperl; | ||
| 27 | + | ||
| 28 | + @RequestMapping("/list") | ||
| 29 | + @ResponseBody | ||
| 30 | + public PageInfo<WaterMeterSacc> list(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum, | ||
| 31 | + @RequestParam(value = "pageSize", required = false, defaultValue = "30") int pageSize, | ||
| 32 | + @RequestParam(value = "ardname", required = false) String ardname){ | ||
| 33 | + PageHelper.startPage(pageNum, pageSize); | ||
| 34 | + List<WaterMeterSacc> list = waterMeterSaccMapperl.list(ardname); | ||
| 35 | + | ||
| 36 | + return new PageInfo<>(list); | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | +} | 
| 1 | +package com.sunyo.energy.location.dao; | ||
| 2 | + | ||
| 3 | +import com.sunyo.energy.location.model.WaterMeterSacc; | ||
| 4 | +import org.apache.ibatis.annotations.Param; | ||
| 5 | + | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +public interface WaterMeterSaccMapper { | ||
| 9 | + int deleteByPrimaryKey(String wmId); | ||
| 10 | + | ||
| 11 | + int insert(WaterMeterSacc record); | ||
| 12 | + | ||
| 13 | + int insertSelective(WaterMeterSacc record); | ||
| 14 | + | ||
| 15 | + WaterMeterSacc selectByPrimaryKey(String wmId); | ||
| 16 | + | ||
| 17 | + List<WaterMeterSacc> list(@Param("ardname") String ardname); | ||
| 18 | + | ||
| 19 | + int updateByPrimaryKeySelective(WaterMeterSacc record); | ||
| 20 | + | ||
| 21 | + int updateByPrimaryKey(WaterMeterSacc record); | ||
| 22 | +} | 
| 1 | +package com.sunyo.energy.location.model; | ||
| 2 | + | ||
| 3 | +import java.math.BigDecimal; | ||
| 4 | + | ||
| 5 | +public class WaterMeterSacc { | ||
| 6 | + private String wmId; | ||
| 7 | + | ||
| 8 | + private String ardname; | ||
| 9 | + | ||
| 10 | + private BigDecimal unitPrice; | ||
| 11 | + | ||
| 12 | + private BigDecimal wmSacc; | ||
| 13 | + | ||
| 14 | + public String getWmId() { | ||
| 15 | + return wmId; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public void setWmId(String wmId) { | ||
| 19 | + this.wmId = wmId == null ? null : wmId.trim(); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public String getArdname() { | ||
| 23 | + return ardname; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public void setArdname(String ardname) { | ||
| 27 | + this.ardname = ardname == null ? null : ardname.trim(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public BigDecimal getUnitPrice() { | ||
| 31 | + return unitPrice; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public void setUnitPrice(BigDecimal unitPrice) { | ||
| 35 | + this.unitPrice = unitPrice; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public BigDecimal getWmSacc() { | ||
| 39 | + return wmSacc; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void setWmSacc(BigDecimal wmSacc) { | ||
| 43 | + this.wmSacc = wmSacc; | ||
| 44 | + } | ||
| 45 | +} | 
| @@ -142,40 +142,6 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { | @@ -142,40 +142,6 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { | ||
| 142 | return datas; | 142 | return datas; | 
| 143 | } | 143 | } | 
| 144 | 144 | ||
| 145 | - /** | ||
| 146 | - * 定时读取电表临时表 发起充值 | ||
| 147 | - */ | ||
| 148 | -// @Scheduled(fixedDelay = 30000) | ||
| 149 | - public void electricityInfo() { | ||
| 150 | - List<ElectricityInfo> electricityInfos = electricityInfoMapper.selectAll(""); | ||
| 151 | - if (electricityInfos.size() > 0) { | ||
| 152 | - for (ElectricityInfo electricityInfo : electricityInfos) { | ||
| 153 | - Map<String, Object> stringObjectMap = mapCommon(electricityInfo.getActionType(), | ||
| 154 | - electricityInfo.getDeviceId(), | ||
| 155 | - String.valueOf(electricityInfo.getMoney()), | ||
| 156 | - electricityInfo.getIpAddress()); | ||
| 157 | - stringObjectMap.put("secret", electricityInfo.getSecret()); | ||
| 158 | - String result = HttpsUtils.sendPost(rechargeDevicesUrl, stringObjectMap); | ||
| 159 | - log.info("电表临时表充值请求信息:{}", electricityInfo.toString()); | ||
| 160 | - log.info("电表临时表充值返回信息:{}", result); | ||
| 161 | - RechargeDevicesResult rechargeDevicesResult = JSON.parseObject(result, RechargeDevicesResult.class); | ||
| 162 | - if (rechargeDevicesResult.getData() != null) { | ||
| 163 | - List<RechargeDevicesResultData> data = rechargeDevicesResult.getData().getDatas(); | ||
| 164 | - Boolean message = null; | ||
| 165 | - for (RechargeDevicesResultData rechargeDevicesResultData : data) { | ||
| 166 | - message = rechargeDevicesResultData.getSuccess(); | ||
| 167 | - } | ||
| 168 | - if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) { | ||
| 169 | - payRecordsMapper.updateStatus(electricityInfo.getOrderNumber()); | ||
| 170 | - electricityInfo.setStatus("0"); | ||
| 171 | - electricityInfoMapper.updateByPrimaryKeySelective(electricityInfo); | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - } | ||
| 175 | - } | ||
| 176 | - log.info("定时任务处理完成"); | ||
| 177 | - | ||
| 178 | - } | ||
| 179 | 145 | ||
| 180 | public Map<String, Object> mapCommon(String actionType, String deviceId, String money, String ip_address) { | 146 | public Map<String, Object> mapCommon(String actionType, String deviceId, String money, String ip_address) { | 
| 181 | Map<String, Object> map = new HashMap<>(); | 147 | Map<String, Object> map = new HashMap<>(); | 
| 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.WaterMeterSaccMapper" > | ||
| 4 | + <resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
| 5 | + <id column="wm_id" property="wmId" jdbcType="VARCHAR" /> | ||
| 6 | + <result column="ardname" property="ardname" jdbcType="VARCHAR" /> | ||
| 7 | + <result column="unit_price" property="unitPrice" jdbcType="DECIMAL" /> | ||
| 8 | + <result column="wm_sacc" property="wmSacc" jdbcType="DECIMAL" /> | ||
| 9 | + </resultMap> | ||
| 10 | + <sql id="Base_Column_List" > | ||
| 11 | + wm_id, ardname, unit_price, wm_sacc | ||
| 12 | + </sql> | ||
| 13 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > | ||
| 14 | + select | ||
| 15 | + <include refid="Base_Column_List" /> | ||
| 16 | + from water_meter_sacc | ||
| 17 | + where wm_id = #{wmId,jdbcType=VARCHAR} | ||
| 18 | + </select> | ||
| 19 | + | ||
| 20 | + <select id="list" resultMap="BaseResultMap" parameterType="java.lang.String"> | ||
| 21 | + select <include refid="Base_Column_List"/> | ||
| 22 | + from water_meter_sacc | ||
| 23 | + where 1=1 | ||
| 24 | + <if test="ardname != null and ardname != '' "> | ||
| 25 | + and ardname = #{ardname, jdbcType=VARCHAR} | ||
| 26 | + </if> | ||
| 27 | + </select> | ||
| 28 | + | ||
| 29 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > | ||
| 30 | + delete from water_meter_sacc | ||
| 31 | + where wm_id = #{wmId,jdbcType=VARCHAR} | ||
| 32 | + </delete> | ||
| 33 | + <insert id="insert" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
| 34 | + insert into water_meter_sacc (wm_id, ardname, unit_price, | ||
| 35 | + wm_sacc) | ||
| 36 | + values (#{wmId,jdbcType=VARCHAR}, #{ardname,jdbcType=VARCHAR}, #{unitPrice,jdbcType=DECIMAL}, | ||
| 37 | + #{wmSacc,jdbcType=DECIMAL}) | ||
| 38 | + </insert> | ||
| 39 | + <insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
| 40 | + insert into water_meter_sacc | ||
| 41 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
| 42 | + <if test="wmId != null" > | ||
| 43 | + wm_id, | ||
| 44 | + </if> | ||
| 45 | + <if test="ardname != null" > | ||
| 46 | + ardname, | ||
| 47 | + </if> | ||
| 48 | + <if test="unitPrice != null" > | ||
| 49 | + unit_price, | ||
| 50 | + </if> | ||
| 51 | + <if test="wmSacc != null" > | ||
| 52 | + wm_sacc, | ||
| 53 | + </if> | ||
| 54 | + </trim> | ||
| 55 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
| 56 | + <if test="wmId != null" > | ||
| 57 | + #{wmId,jdbcType=VARCHAR}, | ||
| 58 | + </if> | ||
| 59 | + <if test="ardname != null" > | ||
| 60 | + #{ardname,jdbcType=VARCHAR}, | ||
| 61 | + </if> | ||
| 62 | + <if test="unitPrice != null" > | ||
| 63 | + #{unitPrice,jdbcType=DECIMAL}, | ||
| 64 | + </if> | ||
| 65 | + <if test="wmSacc != null" > | ||
| 66 | + #{wmSacc,jdbcType=DECIMAL}, | ||
| 67 | + </if> | ||
| 68 | + </trim> | ||
| 69 | + </insert> | ||
| 70 | + <update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
| 71 | + update water_meter_sacc | ||
| 72 | + <set > | ||
| 73 | + <if test="ardname != null" > | ||
| 74 | + ardname = #{ardname,jdbcType=VARCHAR}, | ||
| 75 | + </if> | ||
| 76 | + <if test="unitPrice != null" > | ||
| 77 | + unit_price = #{unitPrice,jdbcType=DECIMAL}, | ||
| 78 | + </if> | ||
| 79 | + <if test="wmSacc != null" > | ||
| 80 | + wm_sacc = #{wmSacc,jdbcType=DECIMAL}, | ||
| 81 | + </if> | ||
| 82 | + </set> | ||
| 83 | + where wm_id = #{wmId,jdbcType=VARCHAR} | ||
| 84 | + </update> | ||
| 85 | + <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
| 86 | + update water_meter_sacc | ||
| 87 | + set ardname = #{ardname,jdbcType=VARCHAR}, | ||
| 88 | + unit_price = #{unitPrice,jdbcType=DECIMAL}, | ||
| 89 | + wm_sacc = #{wmSacc,jdbcType=DECIMAL} | ||
| 90 | + where wm_id = #{wmId,jdbcType=VARCHAR} | ||
| 91 | + </update> | ||
| 92 | +</mapper> | 
- 
请 注册 或 登录 后发表评论