pc-start ipgr

This commit is contained in:
ZZ 2022-02-22 16:08:27 +08:00
parent 728bc78ede
commit b792e9d46a
3 changed files with 16 additions and 13 deletions

View File

@ -16,7 +16,7 @@ public class HexUtils {
return toHex(toIntBytes(String.format("%08d", dec), 8));
}
public static int reverseHexInt(String hex) {
public static Integer reverseHexInt(String hex) {
byte[] data = toBytes(reverseHex(hex));
return toInteger(data, 0, data.length);
@ -64,7 +64,7 @@ public class HexUtils {
return toString(ArrayUtils.subarray(data, start, end));
}
public static int toInteger(byte[] data, int start, int end) {
public static Integer toInteger(byte[] data, int start, int end) {
if (data == null || data.length < end)
return 0;

View File

@ -634,14 +634,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
@Override
public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId) {
try{
R user = userTypeService.getUser(null, userId, userType, null,tenantId);
if(user ==null || user.getData() ==null){
public R cardStartup(Long userId, String serialNumber, Integer userType, String tenantId, Integer type,
String grantOperator, String rateModelId) {
try {
R user = userTypeService.getUser(null, userId, userType, null, tenantId);
if (user == null || user.getData() == null) {
return R.fail(Constants.INVALID_USER);
}
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
Map<String, Object> userMessage = (Map<String, Object>) user.getData();
//桩号是否有效
String pattern = "^([0-9]{16})";
Pattern compile = Pattern.compile(pattern);

View File

@ -14,6 +14,7 @@ import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,8 +25,6 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.genOrder;
@Lazy
@Component("PileStartChargingDataLogic")
public class PileStartChargingDataLogic implements ServiceLogic {
@ -64,12 +63,13 @@ public class PileStartChargingDataLogic implements ServiceLogic {
if (iccardInfo.getCardtype() == 0) {
resultStr = "06";
} else {
// 调用订单接口 todo
orderNo = genOrder(connectorId);
// 调用订单接口
cardNo = iccardInfo.getCardno();
R r = cardService.cardStartup(cardNo, orderNo, pileStartChargingData.getRateModelId().toString());
R r = cardService.cardStartup(cardNo, connectorId,
HexUtils.reverseHexInt(pileStartChargingData.getRateModelId().toString()).toString()); //todo 费率处理
if (r.getCode() == 200) {
result = ServiceResult.HEX_01;
orderNo = (String) ((Map) r.getData()).get("serialNumber");
}
cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0");
resultStr = r.getMsg();
@ -78,7 +78,8 @@ public class PileStartChargingDataLogic implements ServiceLogic {
resultStr = "01";
}
}
String hex = orderNo.concat(connectorId).concat(cardNo).concat(balance).concat(resultStr).concat(result); //todo
String hex = orderNo.concat(connectorId).concat(cardNo).concat(balance).concat(result).concat(resultStr);
hex = hex.concat(CRCCalculator.calcCrc(hex));
String remark = "充电桩发起充电";
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
deviceMessage.setType(StationDeviceEnum.PILE.getCode());