作者 shenhailong

完善电表充值机逻辑

... ... @@ -71,7 +71,10 @@ spring:
#spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码
#url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true
url: jdbc:mysql://118.31.66.166:3306/EMPT?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://192.168.1.7:10098/empt?useUnicode=true&characterEncoding=utf8&nullCatalogMeansCurrent=true&serverTimezone=Asia/Shanghai
# username: shl
username: 110
# password: vmvnv1v2VV
password: QAHqCJf2kFYCLirM
driver-class-name: com.mysql.cj.jdbc.Driver
max-idle: 20
... ... @@ -137,7 +140,7 @@ logging:
file:
path: ./logs/
name: system.log
config: classpath:logback-dev.xml
config: config/logback-dev.xml
#转移到logback配置文件中
#level:
#org.apache.tomcat: info
... ... @@ -168,3 +171,15 @@ devops:
#10079
eeid:
ipAddress: 192.168.50.23
#电表所需要接口
eeUrl:
#电表充值路径
rechargeDevicesUrl: "http://10.5.10.102:8000/api/emcs/rechargeDevices"
# rechargeDevicesUrl: "http://192.168.1.7:18080/api/emcs/rechargeDevices"
#获取电表实时数据/余额
electricityBanlanceUrl: "http://10.5.10.102:8000/api/emcs/getEnergyInfoForRealTime"
# electricityBanlanceUrl: "http://192.168.1.7:18080/api/emcs/getEnergyInfoForRealTime"
#获取设备跟公寓信息
getRoomAndDeviceUrl: "http://10.5.10.102:8000/api/emcs/getRoomAndDevice"
# getRoomAndDeviceUrl: "http://192.168.1.7:18080/api/emcs/getRoomAndDevice"
... ...
package com.sunyo.energy.location.controller;
import com.github.pagehelper.PageInfo;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.model.WaterElectricityParameter;
import com.sunyo.energy.location.service.LocationService;
import com.sunyo.energy.location.service.WaterElectricityParameterService;
import com.sunyo.energy.location.service.WaterMeterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
... ... @@ -17,7 +13,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(description = "用户支付管理")
@RestController
... ... @@ -30,6 +28,9 @@ public class UserPayController {
@Autowired
private WaterMeterService waterMeterService;
@Autowired
private LocationMapper locationMapper;
@ApiOperation(value = "查看缴费房间")
@RequestMapping("/list")
public List userPayList(@RequestParam(value = "roomNumber", required = false) String roomNumber ){
... ... @@ -57,4 +58,17 @@ public class UserPayController {
return resultJson;
}
@ApiOperation(value = "钉钉小程序请求水电返回数据")
@PostMapping("/mincData")
public Map<String, Object> mincData(@RequestParam(value = "loginName", required = false) String loginName){
Map<String, Object> map = new HashMap<>();
/**
* 查询该账号所绑定的水电编号
*/
return map;
}
}
... ...
... ... @@ -38,4 +38,7 @@ public interface LocationMapper {
String eeId(String roomNumber);
int editEeId(@Param(value = "name") String name,
@Param(value = "deviceId") String deviceId);
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.USERS;
public interface USERSMapper {
int deleteByPrimaryKey(Integer userId);
int insert(USERS record);
int insertSelective(USERS record);
USERS selectByPrimaryKey(Integer userId);
int updateByPrimaryKeySelective(USERS record);
int updateByPrimaryKey(USERS record);
}
\ No newline at end of file
... ...
... ... @@ -18,19 +18,41 @@ public class QrDemo {
public static String orUrl(String orderId, String payMent) throws UnsupportedEncodingException {
String bankURL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain";
String MERCHANTID = "105001453995827";
String POSID = "031575220";
/**
* 商户代码
*/
String MERCHANTID = "105000045820502";
// String MERCHANTID = "105001453995827";
/**
* 商户柜台代码
*/
String POSID = "049347762";
// String POSID = "031575220";
/**
* 分行代码
*/
// String BRANCHID = "410803805";
String BRANCHID = "410000000";
// String ORDERID = "1050014539958271238454321";
// String PAYMENT= "0.01";
/**
* 货币种类 01 人民币 只支持人民币
*/
String CURCODE="01";
/**
* 交易码
*/
String TXCODE = "530550";
String REMARK1 = "";
String REMARK2 = "";
/**
* 返回类型
*/
String RETURNTYPE="3";
String TIMEOUT = "";
String PUB32TR2= "8578d1cd9340dba556126a71020111";
/**
* 应柜台的公钥后30位
*/
String PUB32TR2= "57b3055539f4925efaf9dacb020111";
// String PUB32TR2= "8578d1cd9340dba556126a71020111";
StringBuffer tmp = new StringBuffer(); //ÑéÇ©×Ö¶Î
tmp.append("MERCHANTID=");
... ...
... ... @@ -8,9 +8,11 @@ public class QrURLDemo {
public String getSUCCESS() {
return SUCCESS;
}
public void setSUCCESS(String success) {
SUCCESS = success;
}
public String getPAYURL() {
return PAYURL;
}
... ...
package com.sunyo.energy.location.model;
import java.util.Date;
public class USERS {
private Integer userId;
private String username;
private String password;
private Date birthday;
private String sex;
private String address;
private Boolean state;
private String mobilephone;
private Date creattime;
private Date updatetime;
private String userface;
private String realname;
private String email;
private Integer age;
private Integer companyId;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username == null ? null : username.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex == null ? null : sex.trim();
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public Boolean getState() {
return state;
}
public void setState(Boolean state) {
this.state = state;
}
public String getMobilephone() {
return mobilephone;
}
public void setMobilephone(String mobilephone) {
this.mobilephone = mobilephone == null ? null : mobilephone.trim();
}
public Date getCreattime() {
return creattime;
}
public void setCreattime(Date creattime) {
this.creattime = creattime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getUserface() {
return userface;
}
public void setUserface(String userface) {
this.userface = userface == null ? null : userface.trim();
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname == null ? null : realname.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Integer getCompanyId() {
return companyId;
}
public void setCompanyId(Integer companyId) {
this.companyId = companyId;
}
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.service.imp;
import com.alibaba.fastjson.JSON;
import com.sunyo.energy.location.dao.ElectricityInfoMapper;
import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.dao.*;
import com.sunyo.energy.location.model.*;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.utils.HttpsUtils;
... ... @@ -29,10 +28,19 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
@Autowired
PayRecordsMapper payRecordsMapper;
@Autowired
LocationMapper locationMapper;
@Autowired
USERSMapper usersMapper;
/**
* 获取电表实时数据/余额
*/
private final static String electricityBanlanceUrl = "http://192.168.1.2:18080/api/emcs/getEnergyInfoForRealTime";
@Value("${eeUrl.electricityBanlanceUrl}")
private String electricityBanlanceUrl;
/**
* 电表充值接口读取配置文件ip地址
... ... @@ -42,11 +50,13 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
/**
* 电表充值接口地址
*/
private final static String rechargeDevicesUrl = "http://192.168.1.2:18080/api/emcs/rechargeDevices";
@Value("${eeUrl.rechargeDevicesUrl}")
private String rechargeDevicesUrl;
/**
* 获取设备跟公寓信息
*/
private final static String getRoomAndDeviceUrl = "http://192.168.1.2:18080/api/emcs/getRoomAndDevice";
@Value("${eeUrl.getRoomAndDeviceUrl}")
private String getRoomAndDeviceUrl;
/**
* 实施获取电表数据
... ... @@ -135,7 +145,7 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
/**
* 定时读取电表临时表 发起充值
*/
@Scheduled(fixedDelay = 5000)
@Scheduled(fixedDelay = 30000)
public void electricityInfo(){
List<ElectricityInfo> electricityInfos = electricityInfoMapper.selectAll("");
if (electricityInfos.size() > 0){
... ... @@ -173,4 +183,23 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
map.put("ipAddress", ip_address);
return map;
}
/**
* 批量添加用户
*/
// @Scheduled(fixedDelay = 10000)
public void loginName() throws Exception {
Map<String, Object> stringObjectMap = new HashMap<>();
String s = HttpsUtils.sendPostHttpRequest("http://192.168.1.7:18080/api/emcs/getRoomAndDevice", "");
List<ElectricityRoomDeviceThree> datas = JSON.parseObject(s, ElectricityRoomDeviceOne.class).getData().getDatas();
for (ElectricityRoomDeviceThree electricityRoomDeviceThree: datas){
USERS users = new USERS();
users.setUserId(electricityRoomDeviceThree.getRoomId());
users.setUsername(electricityRoomDeviceThree.getRoomName());
users.setPassword(Md5Utils.getMD5("ZZAIRPORT20200631@EMPT", true, 32));
usersMapper.insertSelective(users);
}
}
}
... ...
... ... @@ -153,4 +153,10 @@
type = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="editEeId" parameterType="string">
update location
set ee_id = #{deviceId,jdbcType=VARCHAR}
where adrName = #{name,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.USERSMapper" >
<resultMap id="BaseResultMap" type="com.sunyo.energy.location.model.USERS" >
<id column="user_id" property="userId" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="birthday" property="birthday" jdbcType="TIMESTAMP" />
<result column="sex" property="sex" jdbcType="CHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="state" property="state" jdbcType="BIT" />
<result column="mobilePhone" property="mobilephone" jdbcType="VARCHAR" />
<result column="creatTime" property="creattime" jdbcType="TIMESTAMP" />
<result column="updateTime" property="updatetime" jdbcType="TIMESTAMP" />
<result column="userFace" property="userface" jdbcType="VARCHAR" />
<result column="realName" property="realname" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="age" property="age" jdbcType="INTEGER" />
<result column="company_id" property="companyId" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
user_id, username, password, birthday, sex, address, state, mobilePhone, creatTime,
updateTime, userFace, realName, email, age, company_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from users
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from users
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.sunyo.energy.location.model.USERS" >
insert into users (user_id, username, password,
birthday, sex, address,
state, mobilePhone, creatTime,
updateTime, userFace, realName,
email, age, company_id
)
values (#{userId,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{birthday,jdbcType=TIMESTAMP}, #{sex,jdbcType=CHAR}, #{address,jdbcType=VARCHAR},
#{state,jdbcType=BIT}, #{mobilephone,jdbcType=VARCHAR}, #{creattime,jdbcType=TIMESTAMP},
#{updatetime,jdbcType=TIMESTAMP}, #{userface,jdbcType=VARCHAR}, #{realname,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.sunyo.energy.location.model.USERS" >
insert into users
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="userId != null" >
user_id,
</if>
<if test="username != null" >
username,
</if>
<if test="password != null" >
password,
</if>
<if test="birthday != null" >
birthday,
</if>
<if test="sex != null" >
sex,
</if>
<if test="address != null" >
address,
</if>
<if test="state != null" >
state,
</if>
<if test="mobilephone != null" >
mobilePhone,
</if>
<if test="creattime != null" >
creatTime,
</if>
<if test="updatetime != null" >
updateTime,
</if>
<if test="userface != null" >
userFace,
</if>
<if test="realname != null" >
realName,
</if>
<if test="email != null" >
email,
</if>
<if test="age != null" >
age,
</if>
<if test="companyId != null" >
company_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="username != null" >
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
#{birthday,jdbcType=TIMESTAMP},
</if>
<if test="sex != null" >
#{sex,jdbcType=CHAR},
</if>
<if test="address != null" >
#{address,jdbcType=VARCHAR},
</if>
<if test="state != null" >
#{state,jdbcType=BIT},
</if>
<if test="mobilephone != null" >
#{mobilephone,jdbcType=VARCHAR},
</if>
<if test="creattime != null" >
#{creattime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
#{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="userface != null" >
#{userface,jdbcType=VARCHAR},
</if>
<if test="realname != null" >
#{realname,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="age != null" >
#{age,jdbcType=INTEGER},
</if>
<if test="companyId != null" >
#{companyId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.energy.location.model.USERS" >
update users
<set >
<if test="username != null" >
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null" >
password = #{password,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
birthday = #{birthday,jdbcType=TIMESTAMP},
</if>
<if test="sex != null" >
sex = #{sex,jdbcType=CHAR},
</if>
<if test="address != null" >
address = #{address,jdbcType=VARCHAR},
</if>
<if test="state != null" >
state = #{state,jdbcType=BIT},
</if>
<if test="mobilephone != null" >
mobilePhone = #{mobilephone,jdbcType=VARCHAR},
</if>
<if test="creattime != null" >
creatTime = #{creattime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
updateTime = #{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="userface != null" >
userFace = #{userface,jdbcType=VARCHAR},
</if>
<if test="realname != null" >
realName = #{realname,jdbcType=VARCHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
<if test="age != null" >
age = #{age,jdbcType=INTEGER},
</if>
<if test="companyId != null" >
company_id = #{companyId,jdbcType=INTEGER},
</if>
</set>
where user_id = #{userId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.USERS" >
update users
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
birthday = #{birthday,jdbcType=TIMESTAMP},
sex = #{sex,jdbcType=CHAR},
address = #{address,jdbcType=VARCHAR},
state = #{state,jdbcType=BIT},
mobilePhone = #{mobilephone,jdbcType=VARCHAR},
creatTime = #{creattime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
userFace = #{userface,jdbcType=VARCHAR},
realName = #{realname,jdbcType=VARCHAR},
email = #{email,jdbcType=VARCHAR},
age = #{age,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...