作者 shenhailong

修改电表送电插入临时表逻辑

@@ -112,30 +112,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { @@ -112,30 +112,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
112 } 112 }
113 if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) { 113 if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) {
114 log.info("电表充值成功,充值额度:{}", money); 114 log.info("电表充值成功,充值额度:{}", money);
115 - ElectricityMeter energyInfoForRealTime = getEnergyInfoForRealTime(deviceId);  
116 - if (energyInfoForRealTime.getBalance() != null){  
117 - int i = energyInfoForRealTime.getBalance().compareTo(BigDecimal.ZERO);  
118 - if (i > 0){  
119 - /**  
120 - * 通知送电  
121 - */  
122 - Map<String, Object> map = new HashMap<>();  
123 - map.put("deviceId", deviceId);  
124 - map.put("action", "1");  
125 - String postResult = HttpsUtils.sendPost(remoteControlDevices, map);  
126 - RechargeDevicesResult rechargeDevicesResult1 = JSON.parseObject(postResult, RechargeDevicesResult.class);  
127 - if ("0".equals(rechargeDevicesResult1.getErrcode())){  
128 - // 成功不处理  
129 - log.info("送电成功------------------------");  
130 - }else {  
131 - // 失败插入临时表  
132 - ElectrifyInfo electrifyInfo = new ElectrifyInfo();  
133 - electrifyInfo.setDeviceid(deviceId);  
134 - electrifyInfoMapper.insertSelective(electrifyInfo);  
135 - log.info("送电失败插入临时表-----------------------------");  
136 - }  
137 - }  
138 - } 115 + // 插入临时表交由定时服务处理
  116 + ElectrifyInfo electrifyInfo1 = new ElectrifyInfo();
  117 + electrifyInfo1.setDeviceid(deviceId);
  118 + electrifyInfoMapper.insertSelective(electrifyInfo1);
  119 + log.info("送电信息插入临时表-----------------------------------");
139 return 1; 120 return 1;
140 } else { 121 } else {
141 log.info("电表充值失败,充值额度:{}", money); 122 log.info("电表充值失败,充值额度:{}", money);
@@ -8,6 +8,7 @@ import com.sunyo.energy.location.dao.PayRecordsMapper; @@ -8,6 +8,7 @@ import com.sunyo.energy.location.dao.PayRecordsMapper;
8 import com.sunyo.energy.location.dao.WaterMeterMapper; 8 import com.sunyo.energy.location.dao.WaterMeterMapper;
9 import com.sunyo.energy.location.dao.WaterMeterSaccMapper; 9 import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
10 import com.sunyo.energy.location.demopay.QrDemo; 10 import com.sunyo.energy.location.demopay.QrDemo;
  11 +import com.sunyo.energy.location.model.ElectrifyInfo;
11 import com.sunyo.energy.location.model.PayRecords; 12 import com.sunyo.energy.location.model.PayRecords;
12 import com.sunyo.energy.location.model.WaterMeter; 13 import com.sunyo.energy.location.model.WaterMeter;
13 import com.sunyo.energy.location.model.WaterMeterSacc; 14 import com.sunyo.energy.location.model.WaterMeterSacc;
@@ -165,6 +166,9 @@ public class WaterMeterServiceImp implements WaterMeterService { @@ -165,6 +166,9 @@ public class WaterMeterServiceImp implements WaterMeterService {
165 int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc); 166 int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc);
166 if (i > 0){ 167 if (i > 0){
167 resultJson.setCode("200"); 168 resultJson.setCode("200");
  169 + /**
  170 + * 修改短信通知表
  171 + */
168 }else { 172 }else {
169 resultJson.setCode("203"); 173 resultJson.setCode("203");
170 } 174 }
@@ -279,7 +283,7 @@ public class WaterMeterServiceImp implements WaterMeterService { @@ -279,7 +283,7 @@ public class WaterMeterServiceImp implements WaterMeterService {
279 public PayRecords payRecords(String payFees, String wmId, String userId, String realName, String eeId) { 283 public PayRecords payRecords(String payFees, String wmId, String userId, String realName, String eeId) {
280 284
281 PayRecords payRecords = new PayRecords(); 285 PayRecords payRecords = new PayRecords();
282 - payRecords.setOrdernumber(UUID.randomUUID().toString()); 286 + payRecords.setOrdernumber(AllUtils.getOrderIdByUUId());
283 payRecords.setPayfees(new BigDecimal(payFees)); 287 payRecords.setPayfees(new BigDecimal(payFees));
284 payRecords.setPaystatus(false); 288 payRecords.setPaystatus(false);
285 if (!"".equals(wmId)) { 289 if (!"".equals(wmId)) {
@@ -5,6 +5,7 @@ import java.math.RoundingMode; @@ -5,6 +5,7 @@ import java.math.RoundingMode;
5 import java.text.SimpleDateFormat; 5 import java.text.SimpleDateFormat;
6 import java.util.Date; 6 import java.util.Date;
7 import java.util.Random; 7 import java.util.Random;
  8 +import java.util.UUID;
8 9
9 public class AllUtils { 10 public class AllUtils {
10 11
@@ -42,17 +43,20 @@ public class AllUtils { @@ -42,17 +43,20 @@ public class AllUtils {
42 return s1; 43 return s1;
43 } 44 }
44 45
  46 + public static String getOrderIdByUUId() {
45 47
46 - // 订单号生成 时间加随机数  
47 - public static String getOrderIdByTime() {  
48 // 商户码 48 // 商户码
49 - String merchantId = "105001453995827";  
50 - String result = "";  
51 - Random random = new Random();  
52 - for (int i = 0; i < 3; i++) {  
53 - result += random.nextInt(10); 49 + String merchantId = "031575220";
  50 +
  51 + int first = new Random(10).nextInt(8) + 1;
  52 + int hashCodeV = UUID.randomUUID().toString().hashCode();
  53 + if (hashCodeV < 0) {//有可能是负数
  54 + hashCodeV = -hashCodeV;
54 } 55 }
55 - return merchantId + result; 56 + // 0 代表前面补充0
  57 + // 4 代表长度为4
  58 + // d 代表参数为正数型
  59 + return merchantId + first + String.format("%015d", hashCodeV);
56 } 60 }
57 61
58 /** 62 /**