作者 shenhailong

水表信息查询

package com.sunyo.energy.location.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
import com.sunyo.energy.location.model.WaterMeterSacc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* @author shenhailong
* <p>
* 2020/7/7/15:48
*/
@Controller
@RequestMapping("/water_meter_sacc")
public class WaterMeterSaccController {
@Autowired
WaterMeterSaccMapper waterMeterSaccMapperl;
@RequestMapping("/list")
@ResponseBody
public PageInfo<WaterMeterSacc> list(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
@RequestParam(value = "pageSize", required = false, defaultValue = "30") int pageSize,
@RequestParam(value = "ardname", required = false) String ardname){
PageHelper.startPage(pageNum, pageSize);
List<WaterMeterSacc> list = waterMeterSaccMapperl.list(ardname);
return new PageInfo<>(list);
}
}
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.WaterMeterSacc;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface WaterMeterSaccMapper {
int deleteByPrimaryKey(String wmId);
int insert(WaterMeterSacc record);
int insertSelective(WaterMeterSacc record);
WaterMeterSacc selectByPrimaryKey(String wmId);
List<WaterMeterSacc> list(@Param("ardname") String ardname);
int updateByPrimaryKeySelective(WaterMeterSacc record);
int updateByPrimaryKey(WaterMeterSacc record);
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.model;
import java.math.BigDecimal;
public class WaterMeterSacc {
private String wmId;
private String ardname;
private BigDecimal unitPrice;
private BigDecimal wmSacc;
public String getWmId() {
return wmId;
}
public void setWmId(String wmId) {
this.wmId = wmId == null ? null : wmId.trim();
}
public String getArdname() {
return ardname;
}
public void setArdname(String ardname) {
this.ardname = ardname == null ? null : ardname.trim();
}
public BigDecimal getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
}
public BigDecimal getWmSacc() {
return wmSacc;
}
public void setWmSacc(BigDecimal wmSacc) {
this.wmSacc = wmSacc;
}
}
\ No newline at end of file
... ...
... ... @@ -142,40 +142,6 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
return datas;
}
/**
* 定时读取电表临时表 发起充值
*/
// @Scheduled(fixedDelay = 30000)
public void electricityInfo() {
List<ElectricityInfo> electricityInfos = electricityInfoMapper.selectAll("");
if (electricityInfos.size() > 0) {
for (ElectricityInfo electricityInfo : electricityInfos) {
Map<String, Object> stringObjectMap = mapCommon(electricityInfo.getActionType(),
electricityInfo.getDeviceId(),
String.valueOf(electricityInfo.getMoney()),
electricityInfo.getIpAddress());
stringObjectMap.put("secret", electricityInfo.getSecret());
String result = HttpsUtils.sendPost(rechargeDevicesUrl, stringObjectMap);
log.info("电表临时表充值请求信息:{}", electricityInfo.toString());
log.info("电表临时表充值返回信息:{}", result);
RechargeDevicesResult rechargeDevicesResult = JSON.parseObject(result, RechargeDevicesResult.class);
if (rechargeDevicesResult.getData() != null) {
List<RechargeDevicesResultData> data = rechargeDevicesResult.getData().getDatas();
Boolean message = null;
for (RechargeDevicesResultData rechargeDevicesResultData : data) {
message = rechargeDevicesResultData.getSuccess();
}
if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) {
payRecordsMapper.updateStatus(electricityInfo.getOrderNumber());
electricityInfo.setStatus("0");
electricityInfoMapper.updateByPrimaryKeySelective(electricityInfo);
}
}
}
}
log.info("定时任务处理完成");
}
public Map<String, Object> mapCommon(String actionType, String deviceId, String money, String ip_address) {
Map<String, Object> map = new HashMap<>();
... ...
<?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.WaterMeterSaccMapper" >
<resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.WaterMeterSacc" >
<id column="wm_id" property="wmId" jdbcType="VARCHAR" />
<result column="ardname" property="ardname" jdbcType="VARCHAR" />
<result column="unit_price" property="unitPrice" jdbcType="DECIMAL" />
<result column="wm_sacc" property="wmSacc" jdbcType="DECIMAL" />
</resultMap>
<sql id="Base_Column_List" >
wm_id, ardname, unit_price, wm_sacc
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from water_meter_sacc
where wm_id = #{wmId,jdbcType=VARCHAR}
</select>
<select id="list" resultMap="BaseResultMap" parameterType="java.lang.String">
select <include refid="Base_Column_List"/>
from water_meter_sacc
where 1=1
<if test="ardname != null and ardname != '' ">
and ardname = #{ardname, jdbcType=VARCHAR}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from water_meter_sacc
where wm_id = #{wmId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" >
insert into water_meter_sacc (wm_id, ardname, unit_price,
wm_sacc)
values (#{wmId,jdbcType=VARCHAR}, #{ardname,jdbcType=VARCHAR}, #{unitPrice,jdbcType=DECIMAL},
#{wmSacc,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" >
insert into water_meter_sacc
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="wmId != null" >
wm_id,
</if>
<if test="ardname != null" >
ardname,
</if>
<if test="unitPrice != null" >
unit_price,
</if>
<if test="wmSacc != null" >
wm_sacc,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="wmId != null" >
#{wmId,jdbcType=VARCHAR},
</if>
<if test="ardname != null" >
#{ardname,jdbcType=VARCHAR},
</if>
<if test="unitPrice != null" >
#{unitPrice,jdbcType=DECIMAL},
</if>
<if test="wmSacc != null" >
#{wmSacc,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" >
update water_meter_sacc
<set >
<if test="ardname != null" >
ardname = #{ardname,jdbcType=VARCHAR},
</if>
<if test="unitPrice != null" >
unit_price = #{unitPrice,jdbcType=DECIMAL},
</if>
<if test="wmSacc != null" >
wm_sacc = #{wmSacc,jdbcType=DECIMAL},
</if>
</set>
where wm_id = #{wmId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" >
update water_meter_sacc
set ardname = #{ardname,jdbcType=VARCHAR},
unit_price = #{unitPrice,jdbcType=DECIMAL},
wm_sacc = #{wmSacc,jdbcType=DECIMAL}
where wm_id = #{wmId,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...