作者 shenhailong

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

... ... @@ -112,30 +112,11 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
}
if ("0".equals(rechargeDevicesResult.getErrcode()) && message == true) {
log.info("电表充值成功,充值额度:{}", money);
ElectricityMeter energyInfoForRealTime = getEnergyInfoForRealTime(deviceId);
if (energyInfoForRealTime.getBalance() != null){
int i = energyInfoForRealTime.getBalance().compareTo(BigDecimal.ZERO);
if (i > 0){
/**
* 通知送电
*/
Map<String, Object> map = new HashMap<>();
map.put("deviceId", deviceId);
map.put("action", "1");
String postResult = HttpsUtils.sendPost(remoteControlDevices, map);
RechargeDevicesResult rechargeDevicesResult1 = JSON.parseObject(postResult, RechargeDevicesResult.class);
if ("0".equals(rechargeDevicesResult1.getErrcode())){
// 成功不处理
log.info("送电成功------------------------");
}else {
// 失败插入临时表
ElectrifyInfo electrifyInfo = new ElectrifyInfo();
electrifyInfo.setDeviceid(deviceId);
electrifyInfoMapper.insertSelective(electrifyInfo);
log.info("送电失败插入临时表-----------------------------");
}
}
}
// 插入临时表交由定时服务处理
ElectrifyInfo electrifyInfo1 = new ElectrifyInfo();
electrifyInfo1.setDeviceid(deviceId);
electrifyInfoMapper.insertSelective(electrifyInfo1);
log.info("送电信息插入临时表-----------------------------------");
return 1;
} else {
log.info("电表充值失败,充值额度:{}", money);
... ...
... ... @@ -8,6 +8,7 @@ import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.dao.WaterMeterMapper;
import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
import com.sunyo.energy.location.demopay.QrDemo;
import com.sunyo.energy.location.model.ElectrifyInfo;
import com.sunyo.energy.location.model.PayRecords;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.model.WaterMeterSacc;
... ... @@ -165,6 +166,9 @@ public class WaterMeterServiceImp implements WaterMeterService {
int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc);
if (i > 0){
resultJson.setCode("200");
/**
* 修改短信通知表
*/
}else {
resultJson.setCode("203");
}
... ... @@ -279,7 +283,7 @@ public class WaterMeterServiceImp implements WaterMeterService {
public PayRecords payRecords(String payFees, String wmId, String userId, String realName, String eeId) {
PayRecords payRecords = new PayRecords();
payRecords.setOrdernumber(UUID.randomUUID().toString());
payRecords.setOrdernumber(AllUtils.getOrderIdByUUId());
payRecords.setPayfees(new BigDecimal(payFees));
payRecords.setPaystatus(false);
if (!"".equals(wmId)) {
... ...
... ... @@ -5,6 +5,7 @@ import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
public class AllUtils {
... ... @@ -42,17 +43,20 @@ public class AllUtils {
return s1;
}
public static String getOrderIdByUUId() {
// 订单号生成 时间加随机数
public static String getOrderIdByTime() {
// 商户码
String merchantId = "105001453995827";
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
String merchantId = "031575220";
int first = new Random(10).nextInt(8) + 1;
int hashCodeV = UUID.randomUUID().toString().hashCode();
if (hashCodeV < 0) {//有可能是负数
hashCodeV = -hashCodeV;
}
return merchantId + result;
// 0 代表前面补充0
// 4 代表长度为4
// d 代表参数为正数型
return merchantId + first + String.format("%015d", hashCodeV);
}
/**
... ...