bug修复
This commit is contained in:
parent
1babfb30d2
commit
aa77916f5f
@ -1,12 +1,14 @@
|
|||||||
package com.zhgd.xmgl.device.ammeter.service.impl;
|
package com.zhgd.xmgl.device.ammeter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||||
import com.zhgd.xmgl.device.ammeter.service.IAmmeterDeviceService;
|
import com.zhgd.xmgl.device.ammeter.service.IAmmeterDeviceService;
|
||||||
import com.zhgd.xmgl.device.ammeter.util.AmmeterUtils;
|
import com.zhgd.xmgl.device.ammeter.util.AmmeterUtils;
|
||||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
|
||||||
import com.zhgd.xmgl.modules.ammeter.entity.Ammeter;
|
import com.zhgd.xmgl.modules.ammeter.entity.Ammeter;
|
||||||
import com.zhgd.xmgl.modules.ammeter.entity.AmmeterSupplierRecord;
|
import com.zhgd.xmgl.modules.ammeter.entity.AmmeterSupplierRecord;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -27,7 +29,7 @@ public class QcAmmeterDeviceServiceImpl implements IAmmeterDeviceService {
|
|||||||
String s = AmmeterUtils.addDevice(ammeter.getAmmeterNo(), ammeter.getAmmeterNo(), "admin", 0, ammeterSupplierRecord.getSupplierProductId(), ammeterSupplierRecord.getMasterKey(), ammeterSupplierRecord.getAppKey(), ammeterSupplierRecord.getAppSecret());
|
String s = AmmeterUtils.addDevice(ammeter.getAmmeterNo(), ammeter.getAmmeterNo(), "admin", 0, ammeterSupplierRecord.getSupplierProductId(), ammeterSupplierRecord.getMasterKey(), ammeterSupplierRecord.getAppKey(), ammeterSupplierRecord.getAppSecret());
|
||||||
if (StringUtils.isNotEmpty(s)) {
|
if (StringUtils.isNotEmpty(s)) {
|
||||||
JSONObject jsonObject = JSON.parseObject(s);
|
JSONObject jsonObject = JSON.parseObject(s);
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (ObjectUtil.equal(jsonObject.getInteger("code"), 0)) {
|
||||||
JSONObject result = JSON.parseObject(jsonObject.getString("result"));
|
JSONObject result = JSON.parseObject(jsonObject.getString("result"));
|
||||||
ammeter.setDeviceId(result.getString("deviceId"));
|
ammeter.setDeviceId(result.getString("deviceId"));
|
||||||
ammeter.setDeviceStatus(result.getInteger("deviceStatus"));
|
ammeter.setDeviceStatus(result.getInteger("deviceStatus"));
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class AmmeterUtils {
|
|||||||
// log.info("=====添加设备接口返回信息resultStr:" + resultStr);
|
// log.info("=====添加设备接口返回信息resultStr:" + resultStr);
|
||||||
// return null;
|
// return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("err:", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -628,14 +628,17 @@ public class AmmeterUtils {
|
|||||||
log.info("Sign string: " + string);
|
log.info("Sign string: " + string);
|
||||||
// hmac-sha1编码
|
// hmac-sha1编码
|
||||||
byte[] bytes = null;
|
byte[] bytes = null;
|
||||||
SecretKey secretKey = new SecretKeySpec(secret.getBytes("utf-8"), "HmacSha1");
|
if (secret != null) {
|
||||||
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
|
SecretKey secretKey = new SecretKeySpec(secret.getBytes("utf-8"), "HmacSha1");
|
||||||
mac.init(secretKey);
|
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
|
||||||
bytes = mac.doFinal(string.getBytes("utf-8"));
|
mac.init(secretKey);
|
||||||
// base64编码
|
bytes = mac.doFinal(string.getBytes("utf-8"));
|
||||||
String encryptedString = new String(Base64.encodeBase64(bytes));
|
// base64编码
|
||||||
// 得到需要提交的signature签名数据
|
String encryptedString = new String(Base64.encodeBase64(bytes));
|
||||||
return encryptedString;
|
// 得到需要提交的signature签名数据
|
||||||
|
return encryptedString;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user