package com.zjxdqh.evcs.service;
import com.github.pagehelper.PageInfo;
import com.zjxdqh.evcs.enums.*;
import com.zjxdqh.evcs.mq.RabbitMqSender;
import com.zjxdqh.evcs.supervise.SuperviseUtils;
import com.zjxdqh.evcs.supervise.notification.NotificationService;
import com.zjxdqh.evcs.supervise.vo.ChargeOrderDetailVo;
import com.zjxdqh.evcs.supervise.vo.ChargeStateVo;
import com.zjxdqh.evcs.supervise.vo.*;
import com.zjxdqh.evcs.tools.DateUtil;
import com.zjxdqh.evcs.tools.JsonUtils;
import com.zjxdqh.face.enums.OrderEnum;
import com.zjxdqh.face.exception.BuzzException;
import com.zjxdqh.face.exception.ExceptionEnum;
import com.zjxdqh.face.param.DeviceStatusParam;
import com.zjxdqh.face.param.QueryPileGunStateParam;
import com.zjxdqh.face.param.StartChargeParam;
import com.zjxdqh.face.service.CollectService;
import com.zjxdqh.face.service.HappyOrderService;
import com.zjxdqh.face.service.HappyService;
import com.zjxdqh.face.service.HappyUserService;
import com.zjxdqh.face.vo.*;
import com.zjxdqh.face.vo.user.FUser;
import com.zjxdqh.tools.MathUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import static com.zjxdqh.evcs.supervise.SuperviseUtils.getConnectorID;
/**
* MQ信息业务处理类
*
* @author Yorking
* @date 2019/05/09
*/
@Service
@Log4j2
public class EvcsService {
/**
* 监管平台id
*/
@Value("${supervise.supersiveId}")
public String supersiveId;
@Value("${chongqin.applySubsidyPrice}")
public Double applySubsidyPrice;
@Value("${chongqin.time}")
public Integer time;
@Resource
private HappyService happyService;
@Resource
HappyUserService happyUserService;
@Resource
private HappyOrderService orderService;
@Resource(name = "notificationService")
private NotificationService notificationService;
@Autowired
private RabbitMqSender rabbitMqSender;
@Autowired
private CollectService collectService;
/**
* 推送订单信息
*
* @param orderNo 订单id
*/
//申领奖补修改
public void pushOrderInfo(String orderNo) {
com.zjxdqh.face.param.ChargeStateParam chargeStatParam = new com.zjxdqh.face.param.ChargeStateParam();
chargeStatParam.setStartChargeSeq(orderNo);
ChargeStateBaseVo baseOrder = happyService.queryChargeStateBaseVo(chargeStatParam);
if (baseOrder != null &&
(baseOrder.getStartChargeSeqStat()==OrderEnum.Ostat.FINISH.key()
||baseOrder.getStartChargeSeqStat()==OrderEnum.Ostat.PAYING.key()) ) {
ChargeOrderInfoParam orderInfoParam = new ChargeOrderInfoParam();
orderInfoParam.setConnectorID(SuperviseUtils.getConnectorID(baseOrder.getPid(), baseOrder.getGunnumber()));
orderInfoParam.setStartChargeSeq(baseOrder.getStartChargeSeq());
orderInfoParam.setChargeModel(3);//充电启动方式,必填,默认无卡启动
orderInfoParam.setStartTime(DateUtil.getYYYYMMDDHHMMSS(baseOrder.getStartTime()));
orderInfoParam.setEndTime(DateUtil.getYYYYMMDDHHMMSS(baseOrder.getEndTime()));
orderInfoParam.setTotalPower(baseOrder.getUseEle());
ChargeSuccessStateVo chargeSuccessStateVo = happyService.queryChargeSuccessStateVo(chargeStatParam);
if (chargeSuccessStateVo != null) {
orderInfoParam.setTotalMoney(chargeSuccessStateVo.getTotalMoney());
orderInfoParam.setTotalElecMoney(chargeSuccessStateVo.getElecMoney());
orderInfoParam.setTotalSeviceMoney(chargeSuccessStateVo.getSeviceMoney());
}
orderInfoParam.setStopReason(baseOrder.getEndReason() == 5 ? 2 : 0);
// 分时结算电价
orderInfoParam.setChargeDetails(Collections.EMPTY_LIST);
orderInfoParam.setSumPeriod(orderInfoParam.getChargeDetails().size());
List<FOrderSettlementDetail> fOrderSettlementDetail = happyService.getFOrderSettlementDetailBySn(orderNo);
if (CollectionUtils.isEmpty(fOrderSettlementDetail)) {
orderInfoParam.setChargeDetails(Collections.EMPTY_LIST);
orderInfoParam.setSumPeriod(orderInfoParam.getChargeDetails().size());
} else {
// 设置 结算的分时电价明细
List<ChargeOrderDetailVo> details = convertChargeOrderDetailVo(fOrderSettlementDetail, baseOrder, chargeSuccessStateVo);
orderInfoParam.setChargeDetails(details);
orderInfoParam.setSumPeriod(details.size());
}
//查询客户姓名
FUser fUser = happyUserService.getUserById(baseOrder.getUserId());
if (baseOrder == null){
log.info("未查询客户数据,订单推送失败");
return;
}
//查询桩信息
FPile fPile = happyService.getPileByNum(baseOrder.getPid());
if(fPile == null){
log.info("未查询桩数据,订单推送失败");
return;
}
//组装用户、桩、站、额定电压等信息
orderInfoParam.setUserName(fUser.getUname());
orderInfoParam.setEquipmentID(baseOrder.getPid());
orderInfoParam.setStationID(fPile.getSid()+"");
orderInfoParam.setConnectorPower(Double.parseDouble(fPile.getPower()));
/* //查询充电结束信息
BChargeEndInfo bChargeEndInfo = happyService.getBChargeEndInfo(baseOrder.getSn());
//未查询到桩充电结束返回数据,订单推送失败
if (bChargeEndInfo == null){
log.info("未查询到桩充电结束返回数据,订单推送失败");
return;
}
//电表起止值,采集已有数据,若是已有数据为空,默认为起值为0
if (bChargeEndInfo.getInitKilowatt() == null){
bChargeEndInfo.setInitKilowatt(0);
}
orderInfoParam.setMeterValueStart((double) bChargeEndInfo.getInitKilowatt());
//由于桩通信传过来的电表止值有问题,手动以10%电损计算止值
double d = baseOrder.getUseEle() * 1.1 + bChargeEndInfo.getInitKilowatt();
BigDecimal b = new BigDecimal(d);
d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
orderInfoParam.setMeterValueEnd(d);*/
//计算充电时间
if (baseOrder.getEndTime() == null || baseOrder.getStartTime() == null){
orderInfoParam.setChargeLast(0);
}else{
Long time = baseOrder.getEndTime().getTime() - baseOrder.getStartTime().getTime();
if(time < 0){
orderInfoParam.setChargeLast(0);
}else{
orderInfoParam.setChargeLast((int)(time/1000));
}
}
ResponseResult<ChargeOrderInfoResult> orderInfoResult = notificationService.notificationChargeOrderInfo(orderInfoParam);
}
}
/**
* 定时推送设备状态
*/
public void timerPushPileState(){
List<EvcsPushPile> evcsPushPiles = happyService.getEvcsPushPile();
for (EvcsPushPile evcsPushPile: evcsPushPiles) {
pushPileState(evcsPushPile.getPilenum(),evcsPushPile.getGunnumber());
}
}
/**
* 推送设备状态改变
*
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1、该资源内项目代码经过严格调试,下载即用确保可以运行! 2、该资源适合计算机相关专业(如计科、人工智能、大数据、数学、电子信息等)正在做课程设计、期末大作业和毕设项目的学生、或者相关技术学习者作为学习资料参考使用。 3、该资源包括全部源码,需要具备一定基础才能看懂并调试代码。 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip 新能源汽车充电协议及算费.zip新能源汽车充电协议及算费.zip
资源推荐
资源详情
资源评论






























收起资源包目录





































































































共 130 条
- 1
- 2
资源评论



辣椒种子
- 粉丝: 4514
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 网络营销战略计划的制定.pptx
- 上海大学逻辑与可编程控制器plc组态王交通灯实验课程报告.doc
- 基于AT89C51单片机温度报警系统设计与制作.doc
- 2023年人口与计划生育信息化竞赛试题目库.doc
- 网络营销试卷样卷A.doc
- 中小企业网络规划毕业设计网络专业.doc
- 网络安全22入侵检测系统ppt课件.ppt
- 互联网餐饮连锁股份有限公司创业计划书.doc
- 中国电信LTE网络质量评估测试规范样稿样本.docx
- ThinkCMF-移动应用开发资源
- 上海城市交通信息监控系统软件运维项目需求书.doc
- 如何写项目管理计划书.doc
- 新版网络安全技术解读PPT课件.pptx
- 拓贸隆综合布线设计方案.doc
- 项目管理规划[最终版].pdf
- Oracle试题.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
