作者 shenhailong

近期丢失的所有

正在显示 32 个修改的文件 包含 902 行增加72 行删除
... ... @@ -79,11 +79,19 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<<<<<<< Updated upstream
<dependency>
<groupId>com.tianbo</groupId>
<artifactId>util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
=======
<!--<dependency>-->
<!--<groupId>com.tianbo</groupId>-->
<!--<artifactId>util</artifactId>-->
<!--<version>1.0-SNAPSHOT</version>-->
<!--</dependency>-->
>>>>>>> Stashed changes
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
... ...
package com.sunyo.energy.location.controller;
import com.sunyo.energy.location.controller.response.ResultJson;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/electricity")
public class ElectricityMeterController {
//
// public ResultJson electricityPay(){
//
// }
}
... ...
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.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.model.Location;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/location")
public class LocationController {
@Autowired
private LocationMapper locationMapper;
@ApiOperation(value = "查询楼层")
@RequestMapping(value="/list",method= RequestMethod.GET)
public ResultJson startActivityDemo(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
int pageNum,
@RequestParam(value = "pageSize",required = false,defaultValue = "5")
int pageSize,
@RequestParam(value = "processName", required = false)
String adrname){
Page<Location> page = PageHelper.startPage(pageNum,pageSize);
List<Location> list = null;
if (StringUtils.isEmpty(adrname)) {
list= locationMapper.selectAll(0);
}else {
list= locationMapper.selectAllAdrName(adrname);
}
PageInfo<Location> result = new PageInfo<Location>(list);
return new ResultJson("200","success",result);
}
@ApiOperation(value = "新增楼层")
@PostMapping(value = "/add")
public ResultJson addLocation(@RequestParam("adrName") String adrName,
@RequestParam("parent") Integer parent,
@RequestParam("type") Integer type){
ResultJson resultJson = new ResultJson();
Location location = new Location();
Map map = new HashMap();
map.put("adrName", adrName);
map.put("parent", parent);
if (locationMapper.countAdrName(map) > 0){
resultJson.setCode("201");
} else {
location.setParent(parent);
location.setType(type);
location.setAdrname(adrName);
if (locationMapper.insertSelective(location)>0){
resultJson.setCode("200");
}else {
resultJson.setCode("202");
}
}
return resultJson;
}
@ApiOperation(value = "删除楼层")
@DeleteMapping(value = "/del")
public ResultJson delLocation(@RequestBody Location location){
ResultJson resultJson = new ResultJson();
if (locationMapper.countParent(location.getId()) > 0) {
resultJson.setCode("201");
return resultJson;
}else {
if (locationMapper.deleteByPrimaryKey(location.getId())>0){
resultJson.setCode("200");
return resultJson;
}else {
resultJson.setCode("201");
return resultJson;
}
}
}
@ApiOperation(value = "修改楼层")
@PutMapping(value = "/edit")
public ResultJson editLocation(@RequestBody Location location){
ResultJson resultJson = new ResultJson();
if (locationMapper.updateByPrimaryKeySelective(location)>0){
resultJson.setCode("200");
}else {
resultJson.setCode("201");
}
return resultJson;
}
}
... ...
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
... ... @@ -19,14 +24,26 @@ import java.util.List;
public class UserPayController {
@Autowired
private WaterElectricityParameterService waterElectricityParameterService;
private LocationService locationService;
@Autowired
private WaterMeterService waterMeterService;
@ApiOperation(value = "查询缴费订单")
@RequestMapping("/list")
public List userPayList(@RequestParam(value = "roomNumber", required = false) String roomNumber ){
return locationService.userPayList(roomNumber);
}
@ApiOperation(value = "充值水费")
@PostMapping("/add")
public ResultJson payWater(@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){
return waterElectricityParameterService.userPayList(roomNumber);
return waterMeterService.payWater(payFees, wmId, userId, realName);
}
}
... ...
... ... @@ -3,6 +3,7 @@ package com.sunyo.energy.location.controller;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.model.WaterElectricityParameter;
import com.sunyo.energy.location.service.WaterElectricityParameterService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -19,10 +20,8 @@ public class WaterElectricityParameterController {
private WaterElectricityParameterService waterElectricityParameterService;
/**
* 电表参数配置
*
*/
@ApiOperation(value = "电表参数配置")
@RequestMapping("/add")
@ResponseBody
public ResultJson eetParam(ResultJson resultJson, WaterElectricityParameter waterElectricityParameter){
... ... @@ -53,9 +52,7 @@ public class WaterElectricityParameterController {
}
/**
* 电表参数查询
*/
@ApiOperation(value = "电表参数查询")
@RequestMapping("/getEEModel")
@ResponseBody
public WaterElectricityParameter getEEModel(@RequestParam(value = "eeId", required = false) String eeId){
... ... @@ -65,9 +62,7 @@ public class WaterElectricityParameterController {
}
/**
* 电表参数编辑
*/
@ApiOperation(value = "电表参数编辑")
@RequestMapping("/edit")
@ResponseBody
public ResultJson edit(ResultJson resultJson, WaterElectricityParameter waterElectricityParameter){
... ...
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.controller.response.ResultJson;
import com.sunyo.energy.location.dao.WaterMeterMapper;
import com.sunyo.energy.location.model.Location;
import com.sunyo.energy.location.model.WaterElectricityParameter;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.service.WaterMeterService;
import io.swagger.annotations.ApiOperation;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/water_meter")
public class WaterMeterController {
... ... @@ -17,34 +26,21 @@ public class WaterMeterController {
@Autowired
private WaterMeterService waterMeterService;
// /**
// * 水表实施信息入库
// * @param resultJson
// * @return
// */
// @RequestMapping("/realTime")
// @ResponseBody
// public ResultJson realTime(ResultJson resultJson){
// int i = waterMeterService.realTime();
// if (i>0){
// resultJson.setCode("200");
// resultJson.setMsg("操作成功");
// }else {
// resultJson.setCode("500");
// resultJson.setMsg("操作失败");
// }
//
// return resultJson;
// }
/**
* 水表单个实施信息查询
*/
@ApiOperation(value = "水表单个实施信息查询")
@RequestMapping("/findRealTime")
@ResponseBody
public WaterMeter findRealTime(@RequestParam(value = "wmId", required = false) String wmId){
return waterMeterService.findRealTime(wmId);
}
// @RequestMapping("/findRealTimes")
// @ResponseBody
// public void findRealTimes(){
//
// waterMeterService.realTime();
// }
}
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.Location;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface LocationMapper {
int deleteByPrimaryKey(Integer id);
int insert(Location record);
int insertSelective(Location record);
List<Location> selectByPrimaryKey(Integer id);
List<Location> selectAll(Integer id);
List<Location> selectAllAdrName(String adrName);
int updateByPrimaryKeySelective(Location record);
int updateByPrimaryKey(Location record);
Map<String, Object> userPayList(String roomNumber);
String selectRoomNumber(String roomNumber);
int countAdrName(Map<String, Object> map);
int countParent(Integer id);
}
\ No newline at end of file
... ...
... ... @@ -21,5 +21,5 @@ public interface WaterElectricityParameterMapper {
WaterElectricityParameter findOneElectricity(String eeId);
List<WaterElectricityParameter> userPayList(String roomNumber);
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.dao;
import com.sunyo.energy.location.model.WaterMeter;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface WaterMeterMapper {
int insert(WaterMeter record);
int insertSelective(WaterMeter record);
List<WaterMeter> selectAll();
String findOneWmSacc(String wmId);
int update(@Param(value = "wmId") String wmId,
@Param(value = "allSacc") String allSacc);
}
\ No newline at end of file
... ...
package com.sunyo.energy.location.model;
/**
* 获取电表余额/实时数据1
*/
import lombok.Data;
@Data
public class ElectricityBalanceOne {
private String errcode;
private String errmessage;
private ElectricityBalanceTwo data;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
/**
* 获取电表余额/实时数据3
*/
@Data
public class ElectricityBalanceThree {
private Integer deviceId;
private Number totalEnergy;
private Number tipEnergy;
private Number peakEnergy;
private Number valleyEnergy;
private Number flatEnergy;
private Number balance;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
import java.util.List;
/**
* 获取电表余额/实时数据2
*/
@Data
public class ElectricityBalanceTwo {
private Number actionTime;
private List<ElectricityBalanceThree> datas;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
/**
* 获取设备实施通电状态 1
*/
@Data
public class ElectricityDeviceOnAndOffOne {
private String errcode;
private String errmessage;
private ElectricityDeviceOnAndOffTwo data;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
/**
* 获取设备实施通电状态 3
*/
@Data
public class ElectricityDeviceOnAndOffThree {
private Integer deviceId;
// 0 未查询到 1:通电 2:断电
private Integer onAndOff;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
import java.util.List;
/**
* 获取设备实施通电状态 2
*/
@Data
public class ElectricityDeviceOnAndOffTwo {
private Number actionTime;
private List<ElectricityDeviceOnAndOffThree> datas;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
/**
* 获取房间与楼层信息 1
*/
@Data
public class ElectricityRoomDeviceOne {
private String errcode;
private String errmessage;
private ElectricityRoomDeviceTwo data;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
/**
* 获取房间与楼层信息 3
*/
@Data
public class ElectricityRoomDeviceThree {
// 房间id
private Integer roomId;
// 房间名称
private String roomName;
// 设备id
private String deviceId;
// 设备名称
private String deviceName;
// 安装时间
private String startDate;
}
... ...
package com.sunyo.energy.location.model;
import lombok.Data;
import java.util.List;
/**
* 获取房间与楼层信息 2
*/
@Data
public class ElectricityRoomDeviceTwo {
private List<ElectricityRoomDeviceThree> datas;
}
... ...
package com.sunyo.energy.location.service;
import java.util.List;
public interface LocationService {
List userPayList(String roomNumber);
}
... ...
... ... @@ -14,6 +14,5 @@ public interface WaterElectricityParameterService {
WaterElectricityParameter findOneElectricity(String eeId);
List userPayList(String roomNumber);
}
... ...
package com.sunyo.energy.location.service;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.model.WaterMeter;
public interface WaterMeterService {
... ... @@ -9,5 +10,7 @@ public interface WaterMeterService {
WaterMeter findRealTime(String wmId);
ResultJson payWater(String payFees, String wmId, String userId, String realName);
}
... ...
package com.sunyo.energy.location.service.imp;
import com.alibaba.fastjson.JSON;
import com.sunyo.energy.location.model.*;
import com.sunyo.energy.location.utils.HttpsUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ElectricityMeterServiceImp {
// 获取房间与设备信息
private final static String electricityUrl = "/api/emcs/getRoomAndDevice";
// 获取所有电表实时通断电状态
private final static String electricityStatus = "/api/emcs/getAllDeviceControlStatus";
// 获取电表实时数据/余额
private final static String electricityBanlance = " /api/emcs/getEnergyInfoForRealTime";
/**
* 电费查询
*/
public Map<String, Object> electricityInfo(String roomNumber){
try {
Map<String, Object> map = new HashMap<>();
// 获取设备id
String deviceId = deviceId(roomNumber);
// 获取设备 通电状态
Number onAndOff = onAndOff(deviceId);
// 获取设备余额
Number balance = balance(deviceId);
map.put("deviceId", deviceId);
map.put("onAndOff", onAndOff);
map.put("balance", balance);
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(electricityBanlance, "");
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;
}
}
... ...
package com.sunyo.energy.location.service.imp;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.service.LocationService;
import com.sunyo.energy.location.utils.AllUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class LocationServiceImp implements LocationService {
@Autowired
private LocationMapper locationMapper;
@Override
public List userPayList(String roomNumber) {
try {
// 房间号如果为null 跳过
if (!StringUtils.isEmpty(roomNumber)){
List<Map<String, Object>> list = new ArrayList<>();
/**
* 水费查询
*/
// 查询房间号 水表实施查询list
Map<String, Object> waterMap = locationMapper.userPayList(roomNumber);
if (!StringUtils.isEmpty(waterMap.get("wmSacc").toString()) && !StringUtils.isEmpty( waterMap.get("wmLacc").toString())){
// 计算剩余量 充值量 减去 消费量 参数1 减去 参数2
String subtraction = AllUtils.nubmerSubtraction(waterMap.get("wmSacc").toString(), waterMap.get("wmLacc").toString());
// 余量
waterMap.put("subtraction", subtraction);
}
/**
* 电费查询
*/
// ElectricityMeterServiceImp electricityMeterServiceImp = new ElectricityMeterServiceImp();
// // 获取 设备id 通电状态 余额
// Map<String, Object> electricityMap = electricityMeterServiceImp.electricityInfo(roomNumber);
//
// list.add(electricityMap);
list.add(waterMap);
return list;
}
return null;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}
... ...
... ... @@ -45,9 +45,4 @@ public class WaterElectricityParameterServiceImp implements WaterElectricityPara
}
}
@Override
public List userPayList(String roomNumber) {
return waterElectricityParameterMapper.userPayList(roomNumber);
}
}
... ...
... ... @@ -2,13 +2,25 @@ package com.sunyo.energy.location.service.imp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.xml.internal.ws.message.stream.PayloadStreamReaderMessage;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.dao.WaterMeterMapper;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.service.WaterMeterService;
import com.sunyo.energy.location.utils.AllUtils;
import com.sunyo.energy.location.utils.HttpsUtils;
import com.sunyo.energy.location.utils.PropertiesLoader;
import org.apache.catalina.loader.ParallelWebappClassLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
... ... @@ -20,17 +32,29 @@ public class WaterMeterServiceImp implements WaterMeterService {
@Autowired
private WaterMeterMapper waterMeterMapper;
@Autowired
private PayRecordsMapper payRecordsMapper;
@Autowired
private LocationMapper locationMapper;
// 查询所有水表
private static final String selectUrl = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyMtId";
private static final String payUrl = "http://123.56.159.203:8023/mtfmset/allWMadd";
private static final String addUrl = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID";
@Override
@Scheduled(cron = "0 0 10 * * ?" )
@Scheduled(cron = "0 0 03 * * ?" )
public int realTime() {
try {
// 调用远程接口
String url = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID";
Map<String, Object> datas = new HashMap<>();
datas.put("ProjectID", "33-99-00-00-00-00-01");
String s = HttpsUtils.httpRequest(url, datas);
// 远程调用
String s = HttpsUtils.httpRequest(addUrl, datas);
JSONArray jsonArray = JSON.parseArray(s);
for (Object jsonObject:jsonArray){
WaterMeter waterMeter= new WaterMeter();
... ... @@ -45,6 +69,7 @@ public class WaterMeterServiceImp implements WaterMeterService {
waterMeter.setWmSignalpower(map.get("wm_signalpower").toString());
waterMeter.setWmVoltage(map.get("wm_voltage").toString());
waterMeter.setCreattime(new Date());
waterMeter.setReamke1(map.get("wm_sacc").toString());
waterMeterMapper.insertSelective(waterMeter);
}else {
if ("0".equals(map.get("state").toString())){
... ... @@ -63,12 +88,10 @@ public class WaterMeterServiceImp implements WaterMeterService {
@Override
public WaterMeter findRealTime(String wmId) {
try {
// 调用远程接口http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyMtId?MtId=68-74-40-34-05-29-55
String url = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyMtId";
Map<String, Object> datas = new HashMap<>();
datas.put("MtId", wmId);
String s = HttpsUtils.httpRequest(url, datas);
String s = HttpsUtils.httpRequest(selectUrl, datas);
JSONArray jsonArray = JSON.parseArray(s);
WaterMeter waterMeter= new WaterMeter();
for (Object jsonObject:jsonArray){
... ... @@ -91,4 +114,94 @@ public class WaterMeterServiceImp implements WaterMeterService {
return new WaterMeter();
}
}
/**
* 水费充值 换算总水量 生成订单
* @param payFees
* @param wmId
* @param userId
* @param realName
* @return
*/
@Override
public ResultJson payWater(String payFees, String wmId, String userId, String realName) {
ResultJson<Object> resultJson = new ResultJson<>();
try {
// 得到请求接口 返回值 和总水量
Map<String, Object> map = allWater(payFees, wmId);
Map hashMap = JSON.parseObject(map.get("status").toString(), HashMap.class);
if ("0".equals(hashMap.get("state").toString())){
int update = waterMeterMapper.update(wmId, map.get("allSacc").toString());
// 成功生成水费订单
PayRecords payRecords = payRecords(payFees, wmId, userId, realName);
int i = payRecordsMapper.insertSelective(payRecords);
if (update > 0 && i >0){
resultJson.setCode("200");
}
}else {
resultJson.setCode("203");
}
return resultJson;
}catch (Exception e){
e.printStackTrace();
resultJson.setCode("203");
return resultJson;
}
}
/**
* 总水量 换算
* @param payFees
* @param wmId
* @return
* @throws Exception
*/
public Map<String, Object> allWater(String payFees, String wmId) throws Exception {
// 充值最后立方水数值
String s = AllUtils.nubmerDivision(payFees);
// 查询累计充值量
String oneWmSacc = waterMeterMapper.findOneWmSacc(wmId);
String allSacc = AllUtils.nubmerAdd(s, oneWmSacc);
Map<String, Object> datas = new HashMap<>();
datas.put("MtId", wmId);
datas.put("Add_sacc", allSacc);
datas.put("Add_addmode", "2");
String status = HttpsUtils.httpRequest(payUrl, datas);
datas.put("allSacc",allSacc);
datas.put("status",status);
return datas;
}
/**
* 订单生成
* @param payFees
* @param wmId
* @param userId
* @param realName
* @return
*/
public PayRecords payRecords(String payFees, String wmId, String userId, String realName){
PayRecords payRecords = new PayRecords();
payRecords.setOrdernumber(AllUtils.getOrderIdByTime());
payRecords.setPayfees(Long.valueOf(payFees));
payRecords.setPaystatus(true);
payRecords.setPaytype(false);
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;
}
}
... ...
package com.sunyo.energy.location.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class AllUtils {
// 数字相减 参数1 减去 参数2
public static String nubmerSubtraction(String sacc, String lacc){
BigDecimal saccBigDecimal = new BigDecimal(sacc);
BigDecimal laccBigDecimal = new BigDecimal(lacc);
String surplus = saccBigDecimal.subtract(laccBigDecimal).toString();
return surplus;
}
// 数字相除 参数1 除以参数2
public static String nubmerDivision(String payFees){
// 单价
String unitprice = PropertiesLoader.getUnitPrice("unitprice");
BigDecimal payFessDecimal = new BigDecimal(payFees);
BigDecimal unitpriceDecimal = new BigDecimal(unitprice);
String s = payFessDecimal.divide(unitpriceDecimal, 2, RoundingMode.HALF_UP).toString();
return s;
}
//数字相加 参数1加参数2
public static String nubmerAdd(String oneWmSacc, String s){
BigDecimal bigDecimal = new BigDecimal(oneWmSacc);
BigDecimal bigDecimal1 = new BigDecimal(s);
String s1 = bigDecimal.add(bigDecimal1).toString();
return s1;
}
// 订单号生成 时间加随机数
public static String getOrderIdByTime() {
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
String newDate=sdf.format(new Date());
String result="";
Random random=new Random();
for(int i=0;i<3;i++){
result+=random.nextInt(10);
}
return newDate+result;
}
}
... ...
package com.sunyo.energy.location.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.Properties;
/**
* @description roperties属性文件加载
* @author gerry.zhang
* @date 2014-5-29
* @version 1.0
*
*/
public class PropertiesLoader {
private static final Logger logger = LoggerFactory.getLogger(PropertiesLoader.class);
private static final String UNIT_PRICE = "/unitprice.properties";
/**
* load properties文件
* @param propertyFile
* @return
*/
public static Properties loadProperty(String propertyFile){
InputStream in=PropertiesLoader.class.getResourceAsStream(propertyFile);
Properties properties = new Properties();
try{
properties.load(in);
}catch(Exception e){
logger.error("解析文件失败:文件名={}", propertyFile, e);
}
return properties;
}
public static String getUnitPrice(String key) {
Properties properties = PropertiesLoader.loadProperty(UNIT_PRICE);
return properties.getProperty(key);
}
public static String get(String key,String propertyFile){
Properties properties = loadProperty(propertyFile);
return (String) properties.get(key);
}
}
... ...
... ... @@ -25,6 +25,26 @@ ${AnsiColor.YELLOW}
# #
#####################################################
.::::.
.::::::::.
:::::::::::
..:::::::::::'
'::::::::::::'
.::::::::::
'::::::::::::::..
..::::::::::::.
``::::::::::::::::
::::``:::::::::' .:::.
::::' ':::::' .::::::::.
.::::' :::: .:::::::'::::.
.:::' ::::: .:::::::::' ':::::.
.::' :::::.:::::::::' ':::::.
.::' ::::::::::::::' ``::::.
...::: ::::::::::::' ``::.
```` ':. ':::::::::' ::::..
'.:::::' ':'````..
不存在的 你看我美吗
==================================================
Application Info:${application.title}
ver:${application.version}
... ...
... ... @@ -14,7 +14,7 @@
id, adrName, parent, type, wm_id, ee_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
select
<include refid="Base_Column_List" />
from location
where id = #{id,jdbcType=INTEGER}
... ... @@ -23,8 +23,50 @@
select
*
from location
where parent = #{parent,jdbcType=INTEGER}
where
parent = #{id,jdbcType=INTEGER}
<!--<if test="_adrname != '' and _adrname != null " >-->
<!--or adrName = #{adrname, jdbcType=VARCHAR}-->
<!--</if>-->
</select>
<select id="selectAllAdrName" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
*
from location
where
adrName = #{adrname, jdbcType=VARCHAR}
</select>
<select id="userPayList" resultType="java.util.HashMap">
select
wm.wm_id as wmId, wm.wm_fmstate as wmFmstate,
wm.wm_lacc as wmLacc, wm.wm_sacc as wmSacc
from
location lon
left join
water_meter wm on lon.wm_id = wm.wm_id
where
lon.adrName=#{value,jdbcType=VARCHAR}
</select>
<select id="selectRoomNumber" parameterType="java.lang.String" resultType="java.lang.String">
select
adrName
from
location
where
wm_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>
<select id="countParent" parameterType="int" resultType="int">
select count(parent) from location where parent = #{value}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from location
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -27,7 +27,7 @@
ee_id, reamke2, reamke3
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
select
<include refid="Base_Column_List" />
from water_electricity_parameter
where id = #{id,jdbcType=INTEGER}
... ... @@ -42,13 +42,6 @@
from water_electricity_parameter where ee_id = #{value,jdbcType=VARCHAR}
</select>
<select id="userPayList" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from water_electricity_parameter
where reamke2 = #{value,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from water_electricity_parameter
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -29,6 +29,20 @@
#{updatetime,jdbcType=TIMESTAMP}, #{reamke1,jdbcType=VARCHAR}, #{reamke2,jdbcType=VARCHAR},
#{reamke3,jdbcType=VARCHAR}, #{reamke4,jdbcType=VARCHAR})
</insert>
<select id="selectAll" resultMap="BaseResultMap">
select
*
from water_meter
order by wm_rdtime desc
</select>
<select id="findOneWmSacc" resultType="java.lang.String">
select reamke1 from water_meter where wm_id = #{value,jdbcType=VARCHAR}
</select>
<insert id="insertSelective" parameterType="com.sunyo.energy.location.model.WaterMeter" >
insert into water_meter
<trim prefix="(" suffix=")" suffixOverrides="," >
... ... @@ -121,18 +135,24 @@
</trim>
ON DUPLICATE KEY
UPDATE
wm_sacc = #{wmSacc,jdbcType=VARCHAR},
wm_lacc = #{wmLacc,jdbcType=VARCHAR},
wm_rdtime = #{wmRdtime,jdbcType=VARCHAR},
wm_fmstate = #{wmFmstate,jdbcType=VARCHAR},
wm_errmessage = #{wmErrmessage,jdbcType=VARCHAR},
wm_voltage = #{wmVoltage,jdbcType=VARCHAR},
wm_signalpower = #{wmSignalpower,jdbcType=VARCHAR},
creatTime = #{creattime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
reamke1 = #{reamke1,jdbcType=VARCHAR},
reamke2 = #{reamke2,jdbcType=VARCHAR},
reamke3 = #{reamke3,jdbcType=VARCHAR},
reamke4 = #{reamke4,jdbcType=VARCHAR}
wm_sacc = #{wmSacc,jdbcType=VARCHAR},
wm_lacc = #{wmLacc,jdbcType=VARCHAR},
wm_rdtime = #{wmRdtime,jdbcType=VARCHAR},
wm_fmstate = #{wmFmstate,jdbcType=VARCHAR},
wm_errmessage = #{wmErrmessage,jdbcType=VARCHAR},
wm_voltage = #{wmVoltage,jdbcType=VARCHAR},
wm_signalpower = #{wmSignalpower,jdbcType=VARCHAR},
creatTime = #{creattime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
reamke1 = #{reamke1,jdbcType=VARCHAR},
reamke2 = #{reamke2,jdbcType=VARCHAR},
reamke3 = #{reamke3,jdbcType=VARCHAR},
reamke4 = #{reamke4,jdbcType=VARCHAR}
</insert>
<update id="update" parameterType="java.lang.String">
update water_meter set reamke1 = #{allSacc,jdbcType=VARCHAR}
where wm_id = #{wmId, jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
# 水费单价
unitprice = 4.5
\ No newline at end of file
... ...