bug修复

This commit is contained in:
Administrator 2023-03-16 17:57:27 +08:00
parent 1babfb30d2
commit aa77916f5f
2 changed files with 16 additions and 11 deletions

View File

@ -1,12 +1,14 @@
package com.zhgd.xmgl.device.ammeter.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
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.util.AmmeterUtils;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.modules.ammeter.entity.Ammeter;
import com.zhgd.xmgl.modules.ammeter.entity.AmmeterSupplierRecord;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
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());
if (StringUtils.isNotEmpty(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"));
ammeter.setDeviceId(result.getString("deviceId"));
ammeter.setDeviceStatus(result.getInteger("deviceStatus"));

View File

@ -60,7 +60,7 @@ public class AmmeterUtils {
// log.info("=====添加设备接口返回信息resultStr:" + resultStr);
// return null;
} catch (Exception e) {
e.printStackTrace();
log.error("err", e);
}
return null;
}
@ -628,14 +628,17 @@ public class AmmeterUtils {
log.info("Sign string: " + string);
// hmac-sha1编码
byte[] bytes = null;
SecretKey secretKey = new SecretKeySpec(secret.getBytes("utf-8"), "HmacSha1");
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
mac.init(secretKey);
bytes = mac.doFinal(string.getBytes("utf-8"));
// base64编码
String encryptedString = new String(Base64.encodeBase64(bytes));
// 得到需要提交的signature签名数据
return encryptedString;
if (secret != null) {
SecretKey secretKey = new SecretKeySpec(secret.getBytes("utf-8"), "HmacSha1");
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
mac.init(secretKey);
bytes = mac.doFinal(string.getBytes("utf-8"));
// base64编码
String encryptedString = new String(Base64.encodeBase64(bytes));
// 得到需要提交的signature签名数据
return encryptedString;
}
return null;
}
/**