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)); 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)); byte[] data = toBytes(reverseHex(hex));
return toInteger(data, 0, data.length); return toInteger(data, 0, data.length);
@ -64,7 +64,7 @@ public class HexUtils {
return toString(ArrayUtils.subarray(data, start, end)); 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) if (data == null || data.length < end)
return 0; return 0;

View File

@ -634,14 +634,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
} }
@Override @Override
public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId) { public R cardStartup(Long userId, String serialNumber, Integer userType, String tenantId, Integer type,
try{ String grantOperator, String rateModelId) {
R user = userTypeService.getUser(null, userId, userType, null,tenantId);
if(user ==null || user.getData() ==null){ try {
R user = userTypeService.getUser(null, userId, userType, null, tenantId);
if (user == null || user.getData() == null) {
return R.fail(Constants.INVALID_USER); 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})"; String pattern = "^([0-9]{16})";
Pattern compile = Pattern.compile(pattern); 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.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic; import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils; import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -24,8 +25,6 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.genOrder;
@Lazy @Lazy
@Component("PileStartChargingDataLogic") @Component("PileStartChargingDataLogic")
public class PileStartChargingDataLogic implements ServiceLogic { public class PileStartChargingDataLogic implements ServiceLogic {
@ -64,12 +63,13 @@ public class PileStartChargingDataLogic implements ServiceLogic {
if (iccardInfo.getCardtype() == 0) { if (iccardInfo.getCardtype() == 0) {
resultStr = "06"; resultStr = "06";
} else { } else {
// 调用订单接口 todo // 调用订单接口
orderNo = genOrder(connectorId);
cardNo = iccardInfo.getCardno(); 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) { if (r.getCode() == 200) {
result = ServiceResult.HEX_01; result = ServiceResult.HEX_01;
orderNo = (String) ((Map) r.getData()).get("serialNumber");
} }
cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0"); cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0");
resultStr = r.getMsg(); resultStr = r.getMsg();
@ -78,7 +78,8 @@ public class PileStartChargingDataLogic implements ServiceLogic {
resultStr = "01"; 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 = "充电桩发起充电"; String remark = "充电桩发起充电";
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
deviceMessage.setType(StationDeviceEnum.PILE.getCode()); deviceMessage.setType(StationDeviceEnum.PILE.getCode());