刷卡todo:理清表关系,调用订单服务
This commit is contained in:
parent
01314496c2
commit
dd56f871de
@ -122,8 +122,12 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
}
|
||||
|
||||
public static String transferInternetOrderNo(String orderKeyOrNo, String operatorId) {
|
||||
// "80836000010001012110191723410021";
|
||||
//80836000010001012110191723410021
|
||||
//MA6DFCTD5202201111742100140
|
||||
String orderNo = orderKeyOrNo.replace("order:", "");
|
||||
if (operatorId.length() > 9) {
|
||||
operatorId = operatorId.substring(0, 9);
|
||||
}
|
||||
return operatorId.concat(DateUtil.getYYYY()).concat(orderNo.substring(18));
|
||||
}
|
||||
|
||||
|
||||
@ -73,6 +73,7 @@ public class HexUtils {
|
||||
|
||||
public static byte[] toBytes(String hex) {
|
||||
|
||||
if (hex == null) return null;
|
||||
hex = hex.trim();
|
||||
if (hex.length() == 0 || hex.length() % 2 != 0)
|
||||
return null;
|
||||
@ -172,7 +173,7 @@ public class HexUtils {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (byte b: bytes) {
|
||||
for (int i=0; i<8; i++) {
|
||||
result. append((int)(b >> (8-(i+1)) & 0x0001));
|
||||
result.append(b >> (8 - (i + 1)) & 0x0001);
|
||||
}
|
||||
}
|
||||
return result. toString();
|
||||
|
||||
@ -3,22 +3,26 @@ package com.xhpc.pp.logic;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xhpc.common.data.up.PileStartChargingData;
|
||||
import com.xhpc.common.enums.StationDeviceEnum;
|
||||
import com.xhpc.pp.domain.IccardInfo;
|
||||
import com.xhpc.pp.domain.IccardInfoExample;
|
||||
import com.xhpc.pp.domain.XhpcDeviceMessage;
|
||||
import com.xhpc.pp.mapper.ServiceFieldMapper;
|
||||
import com.xhpc.pp.mapper.IccardInfoMapper;
|
||||
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xhpc.pp.tx.ServiceResult.HEX_00;
|
||||
|
||||
@Lazy
|
||||
@Component("PileStartChargingDataLogic")
|
||||
public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
@ -28,34 +32,60 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
@Resource
|
||||
private XhpcDeviceMessageMapper deviceMessageMapper;
|
||||
@Resource
|
||||
private ServiceFieldMapper fieldMapper;
|
||||
private IccardInfoMapper iccardInfoMapper;
|
||||
|
||||
@Override
|
||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||
|
||||
String resultStr = null;
|
||||
String result = ServiceResult.FAIL;
|
||||
Map<String, Object> req = sp.getParameters();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
PileStartChargingData pileStartChargingData = objectMapper.convertValue(req, PileStartChargingData.class);
|
||||
String terminalId = pileStartChargingData.getPileNo().concat(pileStartChargingData.getGunId());
|
||||
String connectorId = pileStartChargingData.getPileNo().concat(pileStartChargingData.getGunId());
|
||||
String accountOrCardNo = pileStartChargingData.getAccountOrCardNo();
|
||||
String corpNo = terminalId.substring(0, 6);
|
||||
String corpNo = connectorId.substring(0, 6);
|
||||
String balance = "0000";
|
||||
String cardNo = "00000000";
|
||||
if (pileStartChargingData.getStartType().equals("01")) { //刷卡启动
|
||||
String sql = "select i.* from t_iccard_info i where cardNo='" + accountOrCardNo + "' and corpNo = '" + corpNo +
|
||||
"'";
|
||||
Map<String, String> param = new HashMap<>();
|
||||
param.put("sql", sql);
|
||||
List<Map<String, Object>> resultMap = fieldMapper.querySQL(param);
|
||||
|
||||
IccardInfoExample example = new IccardInfoExample();
|
||||
IccardInfoExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andCardidEqualTo(accountOrCardNo).andCorpnoEqualTo(corpNo);
|
||||
List<IccardInfo> iccardInfos = iccardInfoMapper.selectByExample(example);
|
||||
if (iccardInfos.size() == 1) {
|
||||
IccardInfo iccardInfo = iccardInfos.get(0);
|
||||
cardNo = iccardInfo.getCardno();
|
||||
//todo 桩停用
|
||||
if (!iccardInfo.getCorpno().equals(corpNo)) {
|
||||
resultStr = "06";
|
||||
} else if (HEX_00.equals(pileStartChargingData.getPasswordRequired())
|
||||
|| (HEX_00.equals(pileStartChargingData.getPasswordRequired()) && pileStartChargingData.getPassword().equals(iccardInfo.getPassword()))) {
|
||||
int balanceInt = iccardInfo.getBalance();
|
||||
balance = HexUtils.toHexInt(balanceInt);
|
||||
if (balanceInt < 100) {
|
||||
resultStr = "01";
|
||||
result = ServiceResult.OK;
|
||||
} else {
|
||||
resultStr = "03";
|
||||
}
|
||||
} else if (iccardInfo.getStatus() != 1) {
|
||||
result = "02";
|
||||
}
|
||||
} else {
|
||||
result = "01";
|
||||
}
|
||||
}
|
||||
String remark = "充电桩主动申请起动充电";
|
||||
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
|
||||
deviceMessage.setType(StationDeviceEnum.PILE.getCode());
|
||||
deviceMessage.setSerialNumber(terminalId);
|
||||
deviceMessage.setSerialNumber(connectorId);
|
||||
deviceMessage.setRemark(remark);
|
||||
deviceMessage.setStatus(0);
|
||||
deviceMessage.setContent((String) req.get("hex"));
|
||||
deviceMessageMapper.insertByDomain(deviceMessage);
|
||||
return new ServiceResult(false);
|
||||
String hex = "orderNo".concat(connectorId).concat(cardNo).concat(balance).concat(resultStr).concat(result); //todo
|
||||
// 调用订单接口
|
||||
return new ServiceResult(HexUtils.toBytes(hex), result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -43,7 +43,6 @@ public class PileTimeConfigReplyDataLogic implements ServiceLogic {
|
||||
cachePile.put("configTime", configTime);
|
||||
REDIS.setCacheMap(pk, cachePile);
|
||||
log.debug("({}) set time success√: [{}]", pileNo, configTime);
|
||||
|
||||
String remark = "充电桩同步时钟";
|
||||
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
|
||||
deviceMessage.setType(StationDeviceEnum.PILE.getCode());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user