作者 shenhailong

电表充值 功能

... ... @@ -2,6 +2,7 @@ package com.sunyo.energy.location.controller;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.model.ElectricityBalanceThree;
import com.sunyo.energy.location.model.ElectricityMeter;
import com.sunyo.energy.location.model.WaterElectricityParameter;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.service.WaterElectricityParameterService;
... ... @@ -97,10 +98,10 @@ public class ElectricityParameterController {
@ApiOperation(value = "电表实时信息查询")
@RequestMapping(value = "/getEnergyInfoForRealTime")
@ResponseBody
public ElectricityBalanceThree getEnergyInfoForRealTime(@RequestParam(value = "eeId", required = false) String eeId){
public ElectricityMeter getEnergyInfoForRealTime(@RequestParam(value = "eeId", required = false) String eeId){
try {
ElectricityBalanceThree energyInfoForRealTime = electricityMeterService.getEnergyInfoForRealTime(eeId);
ElectricityMeter energyInfoForRealTime = electricityMeterService.getEnergyInfoForRealTime(eeId);
return energyInfoForRealTime;
}catch (Exception e){
e.printStackTrace();
... ... @@ -108,21 +109,4 @@ public class ElectricityParameterController {
}
}
/**
* 电表充值
* @param eeId
* @return
*/
@ApiOperation(value = "电表充值缴费")
@RequestMapping(value = "/rechargeDevices")
@ResponseBody
public ResultJson rechargeDevices(@RequestParam(value = "eeId", required = false) String eeId,
@RequestParam(value = "money", required = false) String money,
@RequestParam(value = "actionType", required = false) String actionType){
int i = electricityMeterService.rechargeDevices(eeId, money, actionType);
return i > 0 ? new ResultJson("200", "充值成功") : new ResultJson("500", "网络异常");
}
}
... ...
... ... @@ -6,6 +6,7 @@ import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.dao.PayResponseMapper;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.model.PayResponse;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.service.WaterMeterService;
import com.sunyo.energy.location.websocket.WebSocketServer;
import io.swagger.annotations.ApiOperation;
... ... @@ -34,6 +35,9 @@ public class PayRseponeController {
@Autowired
private PayRecordsMapper payRecordsMapper;
@Autowired
ElectricityMeterService electricityMeterService;
/**
* 接受字段
* @param POSID 商户柜台代码
... ... @@ -115,20 +119,55 @@ public class PayRseponeController {
payRecords.setOrdernumber(ORDERID);
payRecords.setReamke3("0");
}
// 修改订单状态
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
if (i1>0){
// 查询是水还是电
boolean selectType = payRecordsMapper.selectType(ORDERID);
if (selectType){
// 查询该订单设备编号
String eeId = payRecordsMapper.findOrderNumber(ORDERID);
if (!"".equals(eeId)){
// 通知充值电费
int eeResult = electricityMeterService.rechargeDevices(eeId, PAYMENT, "0");
if (eeResult > 0){
// 修改订单状态
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
if (i1>0){
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "Y");
webSocketServer.broadcast(jsonObject.toJSONString());
}else {
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "N");
webSocketServer.broadcast(jsonObject.toJSONString());
}
}
}
}else {
// 查询该订单设备编号
String orderNumber = payRecordsMapper.findOrderNumber(ORDERID);
String wmId = payRecordsMapper.findOrderNumber(ORDERID);
// 通知充值水费
if (!"".equals(orderNumber)){
ResultJson resultJson = waterMeterService.payWater(PAYMENT, orderNumber);
if (!"".equals(wmId)){
ResultJson resultJson = waterMeterService.payWater(PAYMENT, wmId);
if ("200".equals(resultJson.getCode())){
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "Y");
webSocketServer.broadcast(jsonObject.toJSONString());
// 修改订单状态
int i1 = payRecordsMapper.updateByPrimaryKey(payRecords);
if (i1>0){
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "Y");
webSocketServer.broadcast(jsonObject.toJSONString());
}else {
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "N");
webSocketServer.broadcast(jsonObject.toJSONString());
}
}else {
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
... ... @@ -137,13 +176,8 @@ public class PayRseponeController {
webSocketServer.broadcast(jsonObject.toJSONString());
}
}
}else {
WebSocketServer webSocketServer = new WebSocketServer();
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderNumber", ORDERID);
jsonObject.put("success", "N");
webSocketServer.broadcast(jsonObject.toJSONString());
}
}
return i==1? new ResultJson("200","支付回执信息接受成功"):new ResultJson("500","支付回执信息接受失败");
}
... ...
... ... @@ -50,9 +50,10 @@ public class UserPayController {
public ResultJson qrCode(@RequestParam(value = "payFees", required = false) String payFees,
@RequestParam(value = "wmId", required = false) String wmId,
@RequestParam(value = "userId", required = false) String userId,
@RequestParam(value = "realName", required = false) String realName) throws UnsupportedEncodingException {
@RequestParam(value = "realName", required = false) String realName,
@RequestParam(value = "deviceId", required = false) String eeId) throws UnsupportedEncodingException {
ResultJson resultJson = waterMeterService.qrCode(payFees, wmId, userId, realName);
ResultJson resultJson = waterMeterService.qrCode(payFees, wmId, userId, realName, eeId);
return resultJson;
}
... ...
... ... @@ -35,4 +35,12 @@ public class WaterMeterController {
}
@RequestMapping("/realTime")
@ResponseBody
public int realTime(){
return waterMeterService.realTime();
}
}
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.ElectricityMeter;
public interface ElectricityMeterMapper {
int deleteByPrimaryKey(String deviceId);
int insert(ElectricityMeter record);
int insertSelective(ElectricityMeter record);
ElectricityMeter selectByPrimaryKey(String deviceId);
int updateByPrimaryKeySelective(ElectricityMeter record);
int updateByPrimaryKey(ElectricityMeter record);
}
\ No newline at end of file
... ...
... ... @@ -28,10 +28,14 @@ public interface LocationMapper {
String selectRoomNumber(String roomNumber);
String selectRoomNumberElectricity(String roomNumber);
int countAdrName(Map<String, Object> map);
int countParent(Integer id);
String findWmId(String roomNumber);
String eeId(String roomNumber);
}
\ No newline at end of file
... ...
... ... @@ -23,4 +23,6 @@ public interface PayRecordsMapper {
@Param(value = "endTime") String endTime);
String findOrderNumber(String orderId);
boolean selectType(String orderId);
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,6 @@ public class ElectricityBalanceTwo {
private Number actionTime;
private List<ElectricityBalanceThree> datas;
private List<ElectricityMeter> datas;
}
... ...
package com.sunyo.energy.location.model;
import java.math.BigDecimal;
import java.util.Date;
public class ElectricityMeter {
private String deviceId;
private BigDecimal totalEnergy;
private BigDecimal tipEnergy;
private BigDecimal peakEnergy;
private BigDecimal valleyEnergy;
private BigDecimal flatEnergy;
private BigDecimal balance;
private Date actime;
private Date updatetime;
private String reamke1;
private String reamke2;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId == null ? null : deviceId.trim();
}
public BigDecimal getTotalEnergy() {
return totalEnergy;
}
public void setTotalEnergy(BigDecimal totalEnergy) {
this.totalEnergy = totalEnergy;
}
public BigDecimal getTipEnergy() {
return tipEnergy;
}
public void setTipEnergy(BigDecimal tipEnergy) {
this.tipEnergy = tipEnergy;
}
public BigDecimal getPeakEnergy() {
return peakEnergy;
}
public void setPeakEnergy(BigDecimal peakEnergy) {
this.peakEnergy = peakEnergy;
}
public BigDecimal getValleyEnergy() {
return valleyEnergy;
}
public void setValleyEnergy(BigDecimal valleyEnergy) {
this.valleyEnergy = valleyEnergy;
}
public BigDecimal getFlatEnergy() {
return flatEnergy;
}
public void setFlatEnergy(BigDecimal flatEnergy) {
this.flatEnergy = flatEnergy;
}
public BigDecimal getBalance() {
return balance;
}
public void setBalance(BigDecimal balance) {
this.balance = balance;
}
public Date getActime() {
return actime;
}
public void setActime(Date actime) {
this.actime = actime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getReamke1() {
return reamke1;
}
public void setReamke1(String reamke1) {
this.reamke1 = reamke1 == null ? null : reamke1.trim();
}
public String getReamke2() {
return reamke2;
}
public void setReamke2(String reamke2) {
this.reamke2 = reamke2 == null ? null : reamke2.trim();
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ package com.sunyo.energy.location.service;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.model.ElectricityBalanceThree;
import com.sunyo.energy.location.model.ElectricityMeter;
import java.math.BigDecimal;
import java.util.Map;
... ... @@ -18,8 +19,15 @@ public interface ElectricityMeterService {
* @param deviceId
* @return
*/
ElectricityBalanceThree getEnergyInfoForRealTime(String deviceId) throws Exception;
ElectricityMeter getEnergyInfoForRealTime(String deviceId) throws Exception;
/**
* 电表充值接口
* @param deviceId
* @param money
* @param actionType
* @return
*/
int rechargeDevices(String deviceId, String money, String actionType);
}
... ...
... ... @@ -19,7 +19,7 @@ public interface WaterMeterService {
/**
* 请求返回二维码
*/
ResultJson qrCode(String payFees, String wmId, String userId, String realName) throws UnsupportedEncodingException;
ResultJson qrCode(String payFees, String wmId, String userId, String realName, String eeId) throws UnsupportedEncodingException;
}
... ...
... ... @@ -2,12 +2,16 @@ package com.sunyo.energy.location.service.imp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.sun.deploy.net.HttpUtils;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.ElectricityMeterMapper;
import com.sunyo.energy.location.model.*;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.utils.HttpsUtils;
import com.sunyo.energy.location.utils.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import sun.security.provider.MD5;
... ... @@ -21,6 +25,9 @@ import java.util.Map;
@Service
public class ElectricityMeterServiceImp implements ElectricityMeterService {
@Autowired
ElectricityMeterMapper electricityMeterMapper;
/**
* 获取房间与设备信息
*/
... ... @@ -45,104 +52,35 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
private final static String rechargeDevicesUrl = "http://192.168.1.2:18080/api/emcs/rechargeDevices";
/**
* 电费查询
* 获取全部电表设备数据 定时查询 入临时电表
*/
public Map<String, Object> electricityInfo(String roomNumber){
try {
@Scheduled(cron = "0 0 03 * * ?" )
public void balanceList(){
Map<String, Object> map = new HashMap<>();
// 获取设备id
String deviceId = deviceId(roomNumber);
// 获取设备 通电状态
Number onAndOff = onAndOff(deviceId);
// 获取设备余额
Number balance = balance(deviceId);
try {
map.put("deviceId", deviceId);
map.put("onAndOff", onAndOff);
map.put("balance", balance);
Map<String, Object> stringObjectMap = eeInfo("all");
String infoForRealTime = HttpsUtils.sendPost(electricityBanlanceUrl, stringObjectMap);
ElectricityBalanceOne electricityBalanceOne = JSON.parseObject(infoForRealTime, ElectricityBalanceOne.class);
List<ElectricityMeter> electricityMeterList = electricityBalanceOne.getData().getDatas();
for (ElectricityMeter electricityMeter : electricityMeterList){
electricityMeterMapper.insertSelective(electricityMeter);
}
return map;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
/**
* 获取设备id
* @param roomNumber
* @return
*/
public String deviceId(String roomNumber){
// 获取电表id
String electricityInfo = HttpsUtils.sendPostHttpRequest(electricityUrl, roomNumber);
// 所有电表房间与电表设备id
ElectricityRoomDeviceOne electricityTemporary = JSON.parseObject(electricityInfo, ElectricityRoomDeviceOne.class);
ElectricityRoomDeviceTwo electricityData = electricityTemporary.getData();
List<ElectricityRoomDeviceThree> electricityList = electricityData.getDatas();
for (ElectricityRoomDeviceThree electricity: electricityList){
if (roomNumber.equals(electricity.getRoomName())){
return electricity.getDeviceId();
}
}
return "";
}
/**
* 获取电表实时通电状态
* @return
*/
public Number onAndOff(String deviceId){
// 获取电表通电状态
String s = HttpsUtils.sendPostHttpRequest(electricityStatus, "");
ElectricityDeviceOnAndOffOne electricityDevice = JSON.parseObject(s, ElectricityDeviceOnAndOffOne.class);
ElectricityDeviceOnAndOffTwo data = electricityDevice.getData();
List<ElectricityDeviceOnAndOffThree> onAndOffStatus = data.getDatas();
for (ElectricityDeviceOnAndOffThree electricityOnAndOffStatus: onAndOffStatus){
if (deviceId.equals(electricityOnAndOffStatus.getDeviceId())){
return electricityOnAndOffStatus.getOnAndOff();
}
}
return 0;
}
/**
* 获取设备余额
* @param deviceId
* @return
*/
public Number balance(String deviceId){
// 获取电表余额
String s1 = HttpsUtils.sendPostHttpRequest(electricityBanlanceUrl, "1");
ElectricityBalanceOne electricityBalanceOne = JSON.parseObject(s1, ElectricityBalanceOne.class);
ElectricityBalanceTwo data1 = electricityBalanceOne.getData();
List<ElectricityBalanceThree> electricityBalanceThreeList = data1.getDatas();
for (ElectricityBalanceThree electricityBalanceThree: electricityBalanceThreeList){
if (deviceId.equals(electricityBalanceThree.getDeviceId())){
return electricityBalanceThree.getBalance();
}
}
return 0;
}
@Override
public ElectricityBalanceThree getEnergyInfoForRealTime(String deviceId){
Map<String, Object> datas = new HashMap<>();
datas.put("deviceId", "1");
public ElectricityMeter getEnergyInfoForRealTime(String deviceId){
try {
String infoForRealTime = HttpsUtils.sendPost(electricityBanlanceUrl, datas);
Map<String, Object> stringObjectMap = eeInfo(deviceId);
String infoForRealTime = HttpsUtils.sendPost(electricityBanlanceUrl, stringObjectMap);
ElectricityBalanceOne electricityBalanceOne = JSON.parseObject(infoForRealTime, ElectricityBalanceOne.class);
List<ElectricityBalanceThree> infoForRealTimeList = electricityBalanceOne.getData().getDatas();
for (ElectricityBalanceThree electricityBalanceThree: infoForRealTimeList){
List<ElectricityMeter> infoForRealTimeList = electricityBalanceOne.getData().getDatas();
for (ElectricityMeter electricityBalanceThree: infoForRealTimeList){
if (electricityBalanceThree != null){
return electricityBalanceThree;
}
... ... @@ -182,4 +120,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
}
return 0;
}
public Map<String, Object> eeInfo(String deviceId){
Map<String, Object> datas = new HashMap<>();
datas.put("deviceId", deviceId);
return datas;
}
}
... ...
package com.sunyo.energy.location.service.imp;
import com.sunyo.energy.location.dao.ElectricityMeterMapper;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.model.ElectricityMeter;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.service.LocationService;
import com.sunyo.energy.location.utils.AllUtils;
... ... @@ -17,7 +19,10 @@ import java.util.Map;
public class LocationServiceImp implements LocationService {
@Autowired
private LocationMapper locationMapper;
LocationMapper locationMapper;
@Autowired
ElectricityMeterMapper electricityMeterMapper;
@Override
public List userPayList(String roomNumber) {
... ... @@ -58,13 +63,18 @@ public class LocationServiceImp implements LocationService {
}
}
/**
* 电费查询
* 电费查询 通过房间号查询设备id
*/
// ElectricityMeterServiceImp electricityMeterServiceImp = new ElectricityMeterServiceImp();
// // 获取 设备id 通电状态 余额
// Map<String, Object> electricityMap = electricityMeterServiceImp.electricityInfo(roomNumber);
//
// list.add(electricityMap);
String eeId = locationMapper.eeId(roomNumber);
ElectricityMeter electricityMeter = electricityMeterMapper.selectByPrimaryKey(eeId);
Map<String, Object> eeMap = new HashMap<>();
if (electricityMeter != null){
eeMap.put("deviceId", electricityMeter.getDeviceId());
eeMap.put("balance", electricityMeter.getBalance());
eeMap.put("wmId", "");
list.add(eeMap);
}
return list;
}
return null;
... ...
... ... @@ -159,25 +159,46 @@ public class WaterMeterServiceImp implements WaterMeterService {
// 请求返回二维码
@Override
public ResultJson qrCode(String payFees, String wmId, String userId, String realName) throws UnsupportedEncodingException {
public ResultJson qrCode(String payFees, String wmId, String userId, String realName, String eeId) throws UnsupportedEncodingException {
ResultJson<Object> resultJson = new ResultJson<>();
// 成功生成水费订单
PayRecords payRecords = payRecords(payFees, wmId, userId, realName);
// 请求返回二维码lujing
String url = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
if(!"".equals(url)){
payRecords.setReamke2(url);
// 返回map 包含订单号 二维码url
Map<String, Object> map = new HashMap<>();
map.put("url",url);
map.put("orderNumber", payRecords.getOrdernumber());
resultJson.setData(map);
}
int i = payRecordsMapper.insertSelective(payRecords);
if(i>0){
resultJson.setCode("200");
if (!"".equals(wmId)){
PayRecords payRecords = payRecords(payFees, wmId, userId, realName, "");
// 请求返回二维码lujing
String url = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
if(!"".equals(url)){
payRecords.setReamke2(url);
// 返回map 包含订单号 二维码url
Map<String, Object> map = new HashMap<>();
map.put("url",url);
map.put("orderNumber", payRecords.getOrdernumber());
resultJson.setData(map);
}
int i = payRecordsMapper.insertSelective(payRecords);
if(i>0){
resultJson.setCode("200");
}
}else {
PayRecords payRecords = payRecords(payFees, "", userId, realName, eeId);
// 请求返回二维码lujing
String url = QrDemo.orUrl(payRecords.getOrdernumber(), payFees);
if(!"".equals(url)){
payRecords.setReamke2(url);
// 返回map 包含订单号 二维码url
Map<String, Object> map = new HashMap<>();
map.put("url",url);
map.put("orderNumber", payRecords.getOrdernumber());
resultJson.setData(map);
}
int i = payRecordsMapper.insertSelective(payRecords);
if(i>0){
resultJson.setCode("200");
}
}
return resultJson;
}
... ... @@ -216,20 +237,28 @@ public class WaterMeterServiceImp implements WaterMeterService {
* @param realName
* @return
*/
public PayRecords payRecords(String payFees, String wmId, String userId, String realName){
public PayRecords payRecords(String payFees, String wmId, String userId, String realName, String eeId){
PayRecords payRecords = new PayRecords();
payRecords.setOrdernumber(AllUtils.getOrderIdByTime());
payRecords.setPayfees(new BigDecimal(payFees));
payRecords.setPaystatus(false);
payRecords.setPaytype(false);
if (!"".equals(wmId)){
payRecords.setPaytype(false);
payRecords.setPaytypeaddress(wmId);
String roomNumber = locationMapper.selectRoomNumber(wmId);
payRecords.setPaylocationname(roomNumber);
}else {
payRecords.setPaytype(true);
payRecords.setPaytypeaddress(eeId);
String roomNumber = locationMapper.selectRoomNumberElectricity(eeId);
payRecords.setPaylocationname(roomNumber);
}
payRecords.setReamke1("0");
payRecords.setPayuserid(Integer.valueOf(userId));
payRecords.setPaytime(new Date());
payRecords.setPayusername(realName);
payRecords.setPaytypeaddress(wmId);
String roomNumber = locationMapper.selectRoomNumber(wmId);
payRecords.setPaylocationname(roomNumber);
return payRecords;
}
... ...
<?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.ElectricityMeterMapper" >
<resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.ElectricityMeter" >
<id column="device_id" property="deviceId" jdbcType="VARCHAR" />
<result column="total_energy" property="totalEnergy" jdbcType="DECIMAL" />
<result column="tip_energy" property="tipEnergy" jdbcType="DECIMAL" />
<result column="peak_energy" property="peakEnergy" jdbcType="DECIMAL" />
<result column="valley_energy" property="valleyEnergy" jdbcType="DECIMAL" />
<result column="flat_energy" property="flatEnergy" jdbcType="DECIMAL" />
<result column="balance" property="balance" jdbcType="DECIMAL" />
<result column="acTime" property="actime" jdbcType="TIMESTAMP" />
<result column="updateTime" property="updatetime" jdbcType="TIMESTAMP" />
<result column="reamke1" property="reamke1" jdbcType="VARCHAR" />
<result column="reamke2" property="reamke2" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
device_id, total_energy, tip_energy, peak_energy, valley_energy, flat_energy, balance,
acTime, updateTime, reamke1, reamke2
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from electricity_meter
where device_id = #{deviceId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from electricity_meter
where device_id = #{deviceId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.energy.location.model.ElectricityMeter" >
insert into electricity_meter (device_id, total_energy, tip_energy,
peak_energy, valley_energy, flat_energy,
balance, acTime, updateTime,
reamke1, reamke2)
values (#{deviceId,jdbcType=VARCHAR}, #{totalEnergy,jdbcType=DECIMAL}, #{tipEnergy,jdbcType=DECIMAL},
#{peakEnergy,jdbcType=DECIMAL}, #{valleyEnergy,jdbcType=DECIMAL}, #{flatEnergy,jdbcType=DECIMAL},
#{balance,jdbcType=DECIMAL}, #{actime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP},
#{reamke1,jdbcType=VARCHAR}, #{reamke2,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.energy.location.model.ElectricityMeter" >
insert into electricity_meter
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="deviceId != null" >
device_id,
</if>
<if test="totalEnergy != null" >
total_energy,
</if>
<if test="tipEnergy != null" >
tip_energy,
</if>
<if test="peakEnergy != null" >
peak_energy,
</if>
<if test="valleyEnergy != null" >
valley_energy,
</if>
<if test="flatEnergy != null" >
flat_energy,
</if>
<if test="balance != null" >
balance,
</if>
<if test="actime != null" >
acTime,
</if>
<if test="updatetime != null" >
updateTime,
</if>
<if test="reamke1 != null" >
reamke1,
</if>
<if test="reamke2 != null" >
reamke2,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="deviceId != null" >
#{deviceId,jdbcType=VARCHAR},
</if>
<if test="totalEnergy != null" >
#{totalEnergy,jdbcType=DECIMAL},
</if>
<if test="tipEnergy != null" >
#{tipEnergy,jdbcType=DECIMAL},
</if>
<if test="peakEnergy != null" >
#{peakEnergy,jdbcType=DECIMAL},
</if>
<if test="valleyEnergy != null" >
#{valleyEnergy,jdbcType=DECIMAL},
</if>
<if test="flatEnergy != null" >
#{flatEnergy,jdbcType=DECIMAL},
</if>
<if test="balance != null" >
#{balance,jdbcType=DECIMAL},
</if>
<if test="actime != null" >
#{actime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
#{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="reamke1 != null" >
#{reamke1,jdbcType=VARCHAR},
</if>
<if test="reamke2 != null" >
#{reamke2,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.ElectricityMeter" >
update electricity_meter
<set >
<if test="totalEnergy != null" >
total_energy = #{totalEnergy,jdbcType=DECIMAL},
</if>
<if test="tipEnergy != null" >
tip_energy = #{tipEnergy,jdbcType=DECIMAL},
</if>
<if test="peakEnergy != null" >
peak_energy = #{peakEnergy,jdbcType=DECIMAL},
</if>
<if test="valleyEnergy != null" >
valley_energy = #{valleyEnergy,jdbcType=DECIMAL},
</if>
<if test="flatEnergy != null" >
flat_energy = #{flatEnergy,jdbcType=DECIMAL},
</if>
<if test="balance != null" >
balance = #{balance,jdbcType=DECIMAL},
</if>
<if test="actime != null" >
acTime = #{actime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
updateTime = #{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="reamke1 != null" >
reamke1 = #{reamke1,jdbcType=VARCHAR},
</if>
<if test="reamke2 != null" >
reamke2 = #{reamke2,jdbcType=VARCHAR},
</if>
</set>
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.ElectricityMeter" >
update electricity_meter
set total_energy = #{totalEnergy,jdbcType=DECIMAL},
tip_energy = #{tipEnergy,jdbcType=DECIMAL},
peak_energy = #{peakEnergy,jdbcType=DECIMAL},
valley_energy = #{valleyEnergy,jdbcType=DECIMAL},
flat_energy = #{flatEnergy,jdbcType=DECIMAL},
balance = #{balance,jdbcType=DECIMAL},
acTime = #{actime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
reamke1 = #{reamke1,jdbcType=VARCHAR},
reamke2 = #{reamke2,jdbcType=VARCHAR}
where device_id = #{deviceId,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -59,6 +59,15 @@
wm_id = #{value, jdbcType=VARCHAR}
</select>
<select id="selectRoomNumberElectricity" parameterType="java.lang.String" resultType="java.lang.String">
select
adrName
from
location
where
ee_id = #{value, jdbcType=VARCHAR}
</select>
<select id="countAdrName" resultType="int" parameterType="map">
select count(adrName) from location where adrName = #{adrName, jdbcType=VARCHAR} and parent = #{parent, jdbcType=VARCHAR}
</select>
... ... @@ -71,6 +80,10 @@
select wm_id from location where adrname = #{value}
</select>
<select id="eeId" parameterType="string" resultType="string">
select ee_id from location where adrname = #{value}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from location
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -48,7 +48,11 @@
</select>
<select id="findOrderNumber" parameterType="string" resultType="string">
select distinct payTypeAddress from pay_records where orderNumber = #{value}
select distinct payTypeAddress from pay_records where orderNumber = #{value, jdbcType=VARCHAR}
</select>
<select id="selectType" parameterType="string" resultType="boolean">
select distinct payType from pay_records where orderNumber = #{value, jdbcType=VARCHAR}
</select>
<update id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
... ...