Merge branch 'zz'
This commit is contained in:
commit
4f8198248b
@ -86,6 +86,19 @@ public class XhpcChargingStation extends BaseEntity {
|
||||
@Column(name = "service_tel")
|
||||
private String serviceTel;
|
||||
|
||||
@Column(name = "park_nums")
|
||||
private Integer parkNums;
|
||||
|
||||
public Integer getParkNums() {
|
||||
|
||||
return parkNums;
|
||||
}
|
||||
|
||||
public void setParkNums(Integer parkNums) {
|
||||
|
||||
this.parkNums = parkNums;
|
||||
}
|
||||
|
||||
public String getServiceTel() {
|
||||
|
||||
return serviceTel;
|
||||
|
||||
@ -95,12 +95,15 @@ public class StationsInfoController extends CoreDispatcher {
|
||||
chargingStationDto.setType(xhpcChargingStation.getType());
|
||||
chargingStationDto.setOperatorId(xhpcChargingStation.getOperatorIdEvcs() == null ? "MA6DFCTD5"
|
||||
: xhpcChargingStation.getOperatorIdEvcs());
|
||||
chargingStationDto.setAddress(xhpcChargingStation.getAddress());
|
||||
chargingStationDto.setAreaCode(xhpcChargingStation.getAreaCode().toString());
|
||||
chargingStationDto.setName(xhpcChargingStation.getName());
|
||||
chargingStationDto.setServiceTel(xhpcChargingStation.getServiceTel());
|
||||
chargingStationDto.setParkNums(xhpcChargingStation.getParkNums());
|
||||
REDIS.setCacheObject(stationKey, chargingStationDto);
|
||||
}
|
||||
}
|
||||
station.setAddress(chargingStationDto.getAddress());
|
||||
station.setStationLat(chargingStationDto.getLat());
|
||||
station.setStationLng(chargingStationDto.getLng());
|
||||
station.setStationType(chargingStationDto.getType());
|
||||
@ -110,6 +113,7 @@ public class StationsInfoController extends CoreDispatcher {
|
||||
station.setEquipmentOwnerId(chargingStationDto.getOperatorId());
|
||||
station.setStationName(chargingStationDto.getName());
|
||||
station.setCountryCode("CN");
|
||||
station.setServiceTel(chargingStationDto.getServiceTel());
|
||||
station.setAreaCode(chargingStationDto.getAreaCode());
|
||||
station.setConstruction(chargingStationDto.getConstruction());
|
||||
List<EquipmentInfo> piles = getEquipmentInfos(chargingStationDto.getPiles());
|
||||
|
||||
@ -7,6 +7,7 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@ -30,4 +31,6 @@ public interface AuthSecretTokenRepository extends JpaRepository<AuthSecretToken
|
||||
|
||||
Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenType(String operatorId, String secretTokenType);
|
||||
|
||||
List<AuthSecretToken> findBySecretTokenType(String secretTokenType);
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface XhpcChargingStationRepository extends JpaRepository<XhpcChargingStation, String>,
|
||||
public interface XhpcChargingStationRepository extends JpaRepository<XhpcChargingStation, Long>,
|
||||
QueryByExampleExecutor<XhpcChargingStation>, JpaSpecificationExecutor<XhpcChargingStation> {
|
||||
|
||||
}
|
||||
|
||||
@ -3,15 +3,14 @@ package com.xhpc.evcs.notification;
|
||||
import com.xhpc.evcs.api.CoreDispatcher;
|
||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||
import com.xhpc.evcs.domain.EtOrderMapping;
|
||||
import com.xhpc.evcs.domain.XhpcChargingStation;
|
||||
import com.xhpc.evcs.domain.XhpcStatisticsTimeInterval;
|
||||
import com.xhpc.evcs.dto.CDChargeOrder4BonusInfoRes;
|
||||
import com.xhpc.evcs.dto.CDChargeOrderInfo4BonusReq;
|
||||
import com.xhpc.evcs.dto.CommonRequest;
|
||||
import com.xhpc.evcs.dto.DTOJsonHelper;
|
||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||
import com.xhpc.evcs.jpa.OrderMappingRepository;
|
||||
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
|
||||
import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository;
|
||||
import com.xhpc.evcs.jpa.*;
|
||||
import com.xhpc.evcs.utils.DateUtil;
|
||||
import com.xhpc.evcs.utils.JSONUtil;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import org.slf4j.Logger;
|
||||
@ -25,7 +24,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT;
|
||||
import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.transferInternetOrderNo;
|
||||
|
||||
@Component
|
||||
public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
@ -38,6 +36,8 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
private StatisticTimeIntervalRepository statisticTimeIntervalRepository;
|
||||
@Autowired
|
||||
private OrderMappingRepository orderMappingRepository;
|
||||
@Autowired
|
||||
private XhpcChargingStationRepository chargingStationRepo;
|
||||
private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfo4BonusTask.class);
|
||||
|
||||
@Scheduled(fixedRate = 1000 * 60)
|
||||
@ -61,10 +61,15 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
|
||||
public void notify(XhpcHistoryOrder xhpcHistoryOrder, AuthSecretToken authSecretTokenOut) throws IOException {
|
||||
|
||||
EtOrderMapping etOrderMapping = saveOrderMapping(xhpcHistoryOrder, orderMappingRepository);
|
||||
String operatorIdEvcs = xhpcHistoryOrder.getOperatorIdEvcs();
|
||||
if (operatorIdEvcs == null) {
|
||||
Long chargingStationId = xhpcHistoryOrder.getChargingStationId();
|
||||
XhpcChargingStation station = chargingStationRepo.findById(chargingStationId).orElse(null);
|
||||
operatorIdEvcs = station.getOperatorIdEvcs();
|
||||
}
|
||||
EtOrderMapping etOrderMapping = saveOrderMapping(xhpcHistoryOrder, orderMappingRepository, operatorIdEvcs);
|
||||
CDChargeOrderInfo4BonusReq cdChargeOrderInfo4BonusReq = new CDChargeOrderInfo4BonusReq(xhpcHistoryOrder,
|
||||
etOrderMapping);
|
||||
String operatorIdEvcs = xhpcHistoryOrder.getOperatorIdEvcs();
|
||||
operatorIdEvcs = operatorIdEvcs == null ? "MA6DFCTD5" : operatorIdEvcs;
|
||||
String data = JSONUtil.toJSONString(cdChargeOrderInfo4BonusReq);
|
||||
logger.debug(data);
|
||||
@ -84,30 +89,40 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
|
||||
}
|
||||
|
||||
private EtOrderMapping saveOrderMapping(XhpcHistoryOrder xhpcHistoryOrder,
|
||||
OrderMappingRepository orderMappingRepository) {
|
||||
OrderMappingRepository orderMappingRepository, String operatorId) {
|
||||
|
||||
String internetSerialNumber = xhpcHistoryOrder.getInternetSerialNumber();
|
||||
String xhOrderNo = xhpcHistoryOrder.getSerialNumber();
|
||||
return saveOrderMapping(xhOrderNo, internetSerialNumber, orderMappingRepository);
|
||||
return saveOrderMapping(xhOrderNo, internetSerialNumber, orderMappingRepository, operatorId);
|
||||
}
|
||||
|
||||
static EtOrderMapping saveOrderMapping(String xhOrderNo, String internetSerialNumber,
|
||||
OrderMappingRepository orderMappingRepository) {
|
||||
public static String transferInternetOrderNo(String orderKeyOrNo, String operatorId) {
|
||||
// "80836000010001012110191723410021";
|
||||
String orderNo = orderKeyOrNo.replace("order:", "");
|
||||
return operatorId.concat(DateUtil.getYYYY()).concat(orderNo.substring(18));
|
||||
}
|
||||
|
||||
public static EtOrderMapping saveOrderMapping(String xhOrderNo, String internetSerialNumber,
|
||||
OrderMappingRepository orderMappingRepository, String operatorId) {
|
||||
|
||||
EtOrderMapping etOrderMapping;
|
||||
EtOrderMapping om = new EtOrderMapping();
|
||||
if (internetSerialNumber != null) {
|
||||
etOrderMapping = new EtOrderMapping();
|
||||
etOrderMapping.setXhOrderNo(xhOrderNo);
|
||||
etOrderMapping.setEvcsOrderNo(internetSerialNumber);
|
||||
om.setXhOrderNo(xhOrderNo);
|
||||
om.setEvcsOrderNo(internetSerialNumber);
|
||||
Example<EtOrderMapping> example = Example.of(om);
|
||||
etOrderMapping = orderMappingRepository.findOne(example).orElse(null);
|
||||
if (etOrderMapping == null) {
|
||||
etOrderMapping = orderMappingRepository.save(om);
|
||||
}
|
||||
} else {
|
||||
EtOrderMapping om = new EtOrderMapping();
|
||||
om.setXhOrderNo(xhOrderNo);
|
||||
Example<EtOrderMapping> example = Example.of(om);
|
||||
etOrderMapping = orderMappingRepository.findOne(example).orElse(null);
|
||||
if (etOrderMapping == null) {
|
||||
etOrderMapping = new EtOrderMapping();
|
||||
etOrderMapping.setXhOrderNo(xhOrderNo);
|
||||
etOrderMapping.setEvcsOrderNo(transferInternetOrderNo(xhOrderNo));
|
||||
etOrderMapping.setEvcsOrderNo(transferInternetOrderNo(xhOrderNo, operatorId));
|
||||
etOrderMapping = orderMappingRepository.save(etOrderMapping);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,12 +43,10 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
||||
@Scheduled(fixedRate = 1000 * 50)
|
||||
public void run() throws IOException {
|
||||
|
||||
AuthSecretToken authSecretTokenOut =
|
||||
authSecretTokenRepository.findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(
|
||||
"765367656", "MA6DFCTD5", SECRET_TOKEN_TYPE_OUT).orElse(null); //todo
|
||||
// maybe对接第三方
|
||||
if (authSecretTokenOut != null) {
|
||||
final Collection<String> gunkeys = REDIS.keys("gun:*");
|
||||
List<AuthSecretToken> authSecretTokenOutList = authSecretTokenRepository.findBySecretTokenType(SECRET_TOKEN_TYPE_OUT);
|
||||
final Collection<String> gunkeys = REDIS.keys("gun:*");
|
||||
for (AuthSecretToken authSecretToken : authSecretTokenOutList) {
|
||||
|
||||
for (String gunkey : gunkeys) {
|
||||
if (!gunkey.endsWith(".seqdec") && !gunkey.endsWith(".seqhex") && !gunkey.endsWith(".hori")) {
|
||||
final Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
@ -56,7 +54,7 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
||||
if (isInteger(status)) {
|
||||
final String orderkey = cacheGun.get("orderkey").toString();
|
||||
EquipChargeStatus equipChargeStatus = new EquipChargeStatus();
|
||||
equipChargeStatus.setStartChargeSeq(transferInternetOrderNo(orderkey));
|
||||
// equipChargeStatus.setStartChargeSeq(transferInternetOrderNo(orderkey)); //todo
|
||||
equipChargeStatus.setStartChargeSeqStat(2);
|
||||
equipChargeStatus.setConnectorID(orderkey.substring(6, 22));
|
||||
String current = REDIS.getCacheMapValue(gunkey, "current");
|
||||
@ -75,23 +73,13 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
|
||||
"rateModelId");
|
||||
final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||
calculateEm(equipChargeStatus, cacheRateModel);
|
||||
notify(equipChargeStatus, authSecretTokenOut);
|
||||
String xhOrderNo = orderkey.substring(6);
|
||||
String internetSerialNumber = REDIS.getCacheMapValue(orderkey, "internetSerialNumber"); //todo set it
|
||||
// in redis cache
|
||||
NotificationChargeOrderInfo4BonusTask.saveOrderMapping(xhOrderNo, internetSerialNumber,
|
||||
orderMappingRepository);
|
||||
notify(equipChargeStatus, authSecretToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String transferInternetOrderNo(String orderKeyOrNo) {
|
||||
|
||||
return "MA6DFCTD5".concat(DateUtil.getYYYY()).concat(orderKeyOrNo.substring(24));
|
||||
}
|
||||
|
||||
private void calculateEm(EquipChargeStatus equipChargeStatusCD, CacheRateModel cacheRateModel) {
|
||||
|
||||
final Date endTime = DateUtil.string2Date(equipChargeStatusCD.getEndTime());
|
||||
|
||||
@ -10,8 +10,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.transferInternetOrderNo;
|
||||
|
||||
public class DateUtil {
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "yyyyMMddHHmmss";
|
||||
@ -481,16 +479,17 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println(transferInternetOrderNo("order:69852145896548012109281708240063"));
|
||||
DateUtil.isWeekend(new Date());
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-08", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-09", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-10", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-11", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-12", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-13", "yyyy-MM-dd"));
|
||||
DateUtil.isWeekend(DateUtil.string2Date("2016-06-14", "yyyy-MM-dd"));
|
||||
// "80836000010001012110191723410021";
|
||||
// return operatorId.concat(DateUtil.getYYYY()).concat(orderNo.substring(17));
|
||||
System.out.println("80836000010001012110191723410021".substring(18));
|
||||
// DateUtil.isWeekend(new Date());
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-08", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-09", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-10", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-11", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-12", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-13", "yyyy-MM-dd"));
|
||||
// DateUtil.isWeekend(DateUtil.string2Date("2016-06-14", "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -12,11 +12,22 @@ public class ChargingStationDto {
|
||||
private Double lng;
|
||||
private Integer type;
|
||||
private Long construction;
|
||||
private String address;
|
||||
private String areaCode;
|
||||
private String name;
|
||||
private String serviceTel;
|
||||
private Integer parkNums;
|
||||
|
||||
public String getAddress() {
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Integer getParkNums() {
|
||||
|
||||
return parkNums;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user