小时统计增加判断
This commit is contained in:
parent
18e4f0a99d
commit
d9df9cb82c
@ -434,64 +434,67 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
if(list !=null && list.size()>0){
|
||||
for (XhpcChargeHistoryOrder xhpc:list) {
|
||||
try{
|
||||
//开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间
|
||||
Date startTime = xhpc.getStartTime();
|
||||
Date endTime = xhpc.getEndTime();
|
||||
Long rateModelId = xhpc.getRateModelId();
|
||||
Long operatorId =xhpc.getOperatorId();
|
||||
Long chargingStationId = xhpc.getChargingStationId();
|
||||
Long terminalId = xhpc.getTerminalId();
|
||||
Long historyOrderId = xhpc.getHistoryOrderId();
|
||||
//Date data = Calendar.getInstance().getTime();
|
||||
int count = xhpcStatisticsService.getStatisticsTimeHistoryOrderId(historyOrderId);
|
||||
if(count==0){
|
||||
//开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间
|
||||
Date startTime = xhpc.getStartTime();
|
||||
Date endTime = xhpc.getEndTime();
|
||||
Long rateModelId = xhpc.getRateModelId();
|
||||
Long operatorId =xhpc.getOperatorId();
|
||||
Long chargingStationId = xhpc.getChargingStationId();
|
||||
Long terminalId = xhpc.getTerminalId();
|
||||
//Date data = Calendar.getInstance().getTime();
|
||||
// if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){
|
||||
// continue;
|
||||
// }
|
||||
// if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){
|
||||
// continue;
|
||||
// }
|
||||
//每分钟多少度电
|
||||
//BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,BigDecimal.ROUND_HALF_UP);
|
||||
//每分钟多少度电
|
||||
//BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,BigDecimal.ROUND_HALF_UP);
|
||||
// if(v.compareTo(new BigDecimal(0)) !=1){
|
||||
// continue;
|
||||
// }
|
||||
int endHour = DateUtil.hour(endTime, true);
|
||||
//没有跨时段
|
||||
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
|
||||
xhpcSt.setStatus(endHour+1);
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
if(xhpc.getChargingTimeNumber() !=null){
|
||||
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP));
|
||||
int endHour = DateUtil.hour(endTime, true);
|
||||
//没有跨时段
|
||||
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
|
||||
xhpcSt.setStatus(endHour+1);
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
if(xhpc.getChargingTimeNumber() !=null){
|
||||
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
|
||||
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
|
||||
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
|
||||
xhpcSt.setActPrice(xhpc.getActPrice());
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
|
||||
xhpcSt.setOperatorId(operatorId);
|
||||
xhpcSt.setChargingStationId(chargingStationId);
|
||||
//xhpcSt.setCreateTime(data);
|
||||
xhpcSt.setTerminalId(terminalId);
|
||||
xhpcSt.setHistoryOrderId(historyOrderId);
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
//时间没有跨天
|
||||
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
|
||||
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setCreateTime(xhpc.getEndTime());
|
||||
xhpcStatisticsService.addStatisticsTime(xhpcSt);
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
|
||||
}
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
|
||||
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
|
||||
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
|
||||
xhpcSt.setActPrice(xhpc.getActPrice());
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
|
||||
xhpcSt.setOperatorId(operatorId);
|
||||
xhpcSt.setChargingStationId(chargingStationId);
|
||||
//xhpcSt.setCreateTime(data);
|
||||
xhpcSt.setTerminalId(terminalId);
|
||||
xhpcSt.setHistoryOrderId(historyOrderId);
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
//时间没有跨天
|
||||
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
|
||||
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setCreateTime(xhpc.getEndTime());
|
||||
xhpcStatisticsService.addStatisticsTime(xhpcSt);
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
|
||||
}catch (Exception e){
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId());
|
||||
}
|
||||
@ -933,44 +936,50 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
//场站、运营商、流量方
|
||||
if(list !=null && list.size()>0){
|
||||
for (XhpcChargeHistoryOrder xhpc:list) {
|
||||
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
if(xhpc.getChargingTimeNumber() !=null){
|
||||
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
|
||||
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
|
||||
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
|
||||
xhpcSt.setActPrice(xhpc.getActPrice());
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
|
||||
xhpcSt.setCreateTime(Calendar.getInstance().getTime());
|
||||
xhpcSt.setTerminalId(xhpc.getTerminalId());
|
||||
xhpcSt.setChargingMode(xhpc.getChargingMode());
|
||||
xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setCreateTime(xhpc.getEndTime());
|
||||
xhpcSt.setSource(xhpc.getSource());
|
||||
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
|
||||
Long historyOrderId = xhpc.getHistoryOrderId();
|
||||
for (int i = type; i <4 ; i++) {
|
||||
xhpcSt.setType(i);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
//查询统计表是否有已添加的数据
|
||||
int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i);
|
||||
if(count==0){
|
||||
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
if(xhpc.getChargingTimeNumber() !=null){
|
||||
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
|
||||
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
|
||||
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
|
||||
xhpcSt.setActPrice(xhpc.getActPrice());
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
|
||||
xhpcSt.setCreateTime(Calendar.getInstance().getTime());
|
||||
xhpcSt.setTerminalId(xhpc.getTerminalId());
|
||||
xhpcSt.setChargingMode(xhpc.getChargingMode());
|
||||
|
||||
xhpcSt.setHistoryOrderId(historyOrderId);
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setCreateTime(xhpc.getEndTime());
|
||||
xhpcSt.setSource(xhpc.getSource());
|
||||
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
|
||||
xhpcSt.setType(i);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
}
|
||||
}
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type+1);
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,type+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,13 +155,19 @@ public interface XhpcStatisticsServiceMapper {
|
||||
*/
|
||||
void addStatisticsStation(XhpcStatisticsStation xhpcStatisticsStation);
|
||||
|
||||
/**
|
||||
* 查询是否重复录入数据
|
||||
* @param historyOrderId
|
||||
* @return
|
||||
*/
|
||||
int getStatisticsTimeHistoryOrderId(@Param("historyOrderId")Long historyOrderId);
|
||||
/**
|
||||
* 获取流量方列表
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,String>> getInternetList(@Param("userId")Long userId,@Param("tenantId")String tenantId);
|
||||
|
||||
|
||||
int getStatisticsStationHistoryOrderId(@Param("historyOrderId")Long historyOrderId,@Param("type")Integer type);
|
||||
/**
|
||||
* 订单来源列表
|
||||
* @param userId 用户id
|
||||
|
||||
@ -175,7 +175,12 @@ public interface IXhpcStatisticsService {
|
||||
*/
|
||||
void addStatisticsTime(XhpcStatisticsTimeInterval xhpcStatisticsTimeInterval);
|
||||
|
||||
|
||||
/**
|
||||
* 查询是否重复录入数据
|
||||
* @param historyOrderId
|
||||
* @return
|
||||
*/
|
||||
int getStatisticsTimeHistoryOrderId(Long historyOrderId);
|
||||
/**
|
||||
* 添加订单统计
|
||||
*
|
||||
@ -183,6 +188,13 @@ public interface IXhpcStatisticsService {
|
||||
*/
|
||||
void addStatisticsStation(XhpcStatisticsStation xhpcStatisticsStation);
|
||||
|
||||
/**
|
||||
* 查询是否重复录入数据
|
||||
* @param historyOrderId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
int getStatisticsStationHistoryOrderId(Long historyOrderId,Integer type);
|
||||
|
||||
// -------------------- 导出功能 ------------------
|
||||
|
||||
|
||||
@ -469,11 +469,21 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
|
||||
xhpcStatisticsServiceMapper.addStatisticsTime(xhpcStatisticsTimeInterval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatisticsTimeHistoryOrderId(Long historyOrderId) {
|
||||
return xhpcStatisticsServiceMapper.getStatisticsTimeHistoryOrderId(historyOrderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatisticsStation(XhpcStatisticsStation xhpcStatisticsStation) {
|
||||
xhpcStatisticsServiceMapper.addStatisticsStation(xhpcStatisticsStation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatisticsStationHistoryOrderId(Long historyOrderId, Integer type) {
|
||||
return xhpcStatisticsServiceMapper.getStatisticsStationHistoryOrderId(historyOrderId, type);
|
||||
}
|
||||
|
||||
private boolean getJudge(Long internetUserId, Long operatorId, Integer type) {
|
||||
|
||||
if (type == null) {
|
||||
|
||||
@ -917,4 +917,11 @@
|
||||
</if>
|
||||
group by ss.charging_mode
|
||||
</select>
|
||||
|
||||
<select id="getStatisticsTimeHistoryOrderId" resultType="int">
|
||||
select count(statistics_time_interval_id) from xhpc_statistics_time_interval where history_order_id=#{historyOrderId}
|
||||
</select>
|
||||
<select id="getStatisticsStationHistoryOrderId" resultType="int">
|
||||
select count(statistics_station_id) from xhpc_statistics_station where history_order_id=#{historyOrderId} and type=#{type}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user