New file |
| | |
| | | package com.ruoyi.jianguan.controller; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.vo.ChargingOrderVo; |
| | | import com.ruoyi.jianguan.model.SupChargeOrderInfo; |
| | | import com.ruoyi.jianguan.model.SupEquipChargeStatus; |
| | | import com.ruoyi.jianguan.util.ChuanYiChongSuperviseUtil; |
| | | import com.ruoyi.jianguan.util.TCECSuperviseUtil; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.other.api.domain.Operator; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/7/12 10:07 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/chargingMessage") |
| | | public class ChargingMessageController { |
| | | |
| | | @Resource |
| | | private TCECSuperviseUtil tcecSuperviseUtil; |
| | | |
| | | private final static String operatorId = "906171535"; |
| | | @Resource |
| | | private ChargingGunClient chargingGunClient; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private ChuanYiChongSuperviseUtil chuanYiChongSuperviseUtil; |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | |
| | | /** |
| | | * 推送充电订单信息 |
| | | * @param chargingOrder |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/pushOrderInfo") |
| | | public R pushOrderInfo(@RequestBody ChargingOrderVo chargingOrder){ |
| | | SupChargeOrderInfo supChargeOrderInfo = new SupChargeOrderInfo(); |
| | | supChargeOrderInfo.setOperatorID(operatorId); |
| | | supChargeOrderInfo.setEquipmentOwnerID(operatorId); |
| | | supChargeOrderInfo.setStationID(String.valueOf(chargingOrder.getSiteId())); |
| | | supChargeOrderInfo.setEquipmentID(String.valueOf(chargingOrder.getChargingPileId())); |
| | | supChargeOrderInfo.setOrderNo(operatorId+chargingOrder.getCode()); |
| | | TChargingGun chargingGun1 = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | supChargeOrderInfo.setConnectorID(chargingGun1.getFullNumber()); |
| | | supChargeOrderInfo.setEquipmentClassification(1); |
| | | supChargeOrderInfo.setPushTimeStamp(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | supChargeOrderInfo.setStartTime(chargingOrder.getStartTime() != null ? chargingOrder.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : ""); |
| | | supChargeOrderInfo.setEndTime(chargingOrder.getEndTime() != null ? chargingOrder.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : ""); |
| | | supChargeOrderInfo.setTotalPower(chargingOrder.getElectrovalence()); |
| | | supChargeOrderInfo.setTotalElecMoney(chargingOrder.getElectrovalence()); |
| | | supChargeOrderInfo.setTotalServiceMoney(chargingOrder.getServiceCharge()); |
| | | supChargeOrderInfo.setTotalMoney(chargingOrder.getOrderAmount()); |
| | | switch (chargingOrder.getEndMode()){ |
| | | case 0: |
| | | supChargeOrderInfo.setStopReason(5); |
| | | supChargeOrderInfo.setStopDesc("异常终止"); |
| | | break; |
| | | case 1: |
| | | supChargeOrderInfo.setStopReason(0); |
| | | supChargeOrderInfo.setStopDesc("用户手动停止充电"); |
| | | break; |
| | | case 2: |
| | | supChargeOrderInfo.setStopReason(1); |
| | | supChargeOrderInfo.setStopDesc("客户归属地运营商平台停止充电"); |
| | | break; |
| | | case 3: |
| | | supChargeOrderInfo.setStopReason(1); |
| | | supChargeOrderInfo.setStopDesc("费用不足中止"); |
| | | break; |
| | | } |
| | | tcecSuperviseUtil.notificationChargeOrderInfo(new Operator(), supChargeOrderInfo); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送充电订单状态 |
| | | * @param chargingOrder |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/pushOrderStatus") |
| | | public R pushOrderStatus(@RequestBody ChargingOrderVo chargingOrder){ |
| | | log.info("推送充电订单状态:{}", chargingOrder); |
| | | SupEquipChargeStatus supEquipChargeStatus = new SupEquipChargeStatus(); |
| | | supEquipChargeStatus.setOperatorID(operatorId); |
| | | supEquipChargeStatus.setEquipmentOwnerID(operatorId); |
| | | supEquipChargeStatus.setStationID(String.valueOf(chargingOrder.getSiteId())); |
| | | supEquipChargeStatus.setEquipmentID(String.valueOf(chargingOrder.getChargingPileId())); |
| | | supEquipChargeStatus.setOrderNo(operatorId+chargingOrder.getCode()); |
| | | switch (chargingOrder.getStatus()){ |
| | | case 2: |
| | | supEquipChargeStatus.setConnectorStatus(1); |
| | | break; |
| | | case 3: |
| | | supEquipChargeStatus.setConnectorStatus(2); |
| | | break; |
| | | case 4: |
| | | supEquipChargeStatus.setConnectorStatus(3); |
| | | break; |
| | | case 5: |
| | | supEquipChargeStatus.setConnectorStatus(4); |
| | | break; |
| | | } |
| | | TChargingGun chargingGun2 = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | supEquipChargeStatus.setConnectorID(chargingGun2.getFullNumber()); |
| | | supEquipChargeStatus.setEquipmentClassification(1); |
| | | supEquipChargeStatus.setPushTimeStamp(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | switch (chargingGun2.getStatus()){ |
| | | case 1: |
| | | supEquipChargeStatus.setConnectorStatus(0); |
| | | break; |
| | | case 2: |
| | | supEquipChargeStatus.setConnectorStatus(1); |
| | | break; |
| | | case 3: |
| | | supEquipChargeStatus.setConnectorStatus(2); |
| | | break; |
| | | case 4: |
| | | supEquipChargeStatus.setConnectorStatus(3); |
| | | break; |
| | | case 5: |
| | | supEquipChargeStatus.setConnectorStatus(3); |
| | | break; |
| | | case 6: |
| | | supEquipChargeStatus.setConnectorStatus(4); |
| | | break; |
| | | case 7: |
| | | supEquipChargeStatus.setConnectorStatus(255); |
| | | break; |
| | | } |
| | | supEquipChargeStatus.setCurrentA(chargingOrder.getCurrent()); |
| | | |
| | | supEquipChargeStatus.setSOC(null != chargingOrder.getTotalElectricity()?chargingOrder.getTotalElectricity():new BigDecimal("1")); |
| | | supEquipChargeStatus.setStartTime(chargingOrder.getStartTime() != null ? chargingOrder.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : ""); |
| | | supEquipChargeStatus.setEndTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | supEquipChargeStatus.setTotalPower(chargingOrder.getElectrovalence()); |
| | | tcecSuperviseUtil.notificationSupEquipChargeStatus(new Operator(), supEquipChargeStatus); |
| | | TAppUser data = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | // 川逸充 |
| | | if (chargingOrder.getRechargePaymentType()==3){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("StartChargeSeq",chargingOrder.getCode()); |
| | | jsonObject.put("ConnectorID",chargingGun2.getFullNumber()); |
| | | LocalDateTime startTime = chargingOrder.getStartTime(); |
| | | log.info("川逸充用户信息"+data); |
| | | if (StringUtils.hasLength(data.getPhone())){ |
| | | jsonObject.put("Mobile",data.getPhone()); |
| | | } |
| | | //状态(0=未知,1=等待中/已插枪,2=启动中,3=充电中,4=停止中,5=已结束) |
| | | int tempStatus = 0; |
| | | switch (chargingOrder.getStatus()){ |
| | | case 1: |
| | | tempStatus=1; |
| | | |
| | | case 2: |
| | | tempStatus=1; |
| | | jsonObject.put("StartChargeSeqStat",tempStatus); |
| | | if (startTime!=null){ |
| | | jsonObject.put("StartTime",startTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | }else{ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 转化为yyyy-MM-dd HH:mm:ss格式字符串 |
| | | jsonObject.put("StartTime",now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | } |
| | | chuanYiChongSuperviseUtil.notificationStationStatus(new Operator(), jsonObject); |
| | | break; |
| | | case 3: |
| | | tempStatus=2; |
| | | jsonObject.put("StartChargeSeqStat",tempStatus); |
| | | if (startTime!=null){ |
| | | jsonObject.put("StartTime",startTime.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | }else{ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 转化为yyyy-MM-dd HH:mm:ss格式字符串 |
| | | jsonObject.put("StartTime",now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | } |
| | | chuanYiChongSuperviseUtil.notificationStationStatus(new Operator(), jsonObject); |
| | | break; |
| | | case 4: |
| | | break; |
| | | case 5: |
| | | jsonObject.put("StartChargeSeqStat",4); |
| | | int temp = 0; |
| | | //充电枪状态(1=离线,2=空闲,3=占用(未充电),4=占用(充电中),5=占用(已充满),6=占用(预约锁定),7=故障) |
| | | switch (chargingGun2.getStatus()){ |
| | | case 1: |
| | | temp = 0; |
| | | break; |
| | | case 2: |
| | | temp=1; |
| | | break; |
| | | case 3: |
| | | temp=2; |
| | | break; |
| | | case 4: |
| | | temp=3; |
| | | break; |
| | | case 5: |
| | | temp=4; |
| | | break; |
| | | case 6: |
| | | temp=4; |
| | | break; |
| | | case 7: |
| | | temp = 255; |
| | | break; |
| | | } |
| | | jsonObject.put("ConnectorStatus",temp); |
| | | |
| | | jsonObject.put("CurrentA",chargingOrder.getCurrent()); |
| | | jsonObject.put("VoltageA",chargingOrder.getVoltage()); |
| | | LocalDateTime startTime2 = chargingOrder.getStartTime(); |
| | | |
| | | if (startTime2!=null){ |
| | | jsonObject.put("StartTime",startTime2.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | }else{ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 转化为yyyy-MM-dd HH:mm:ss格式字符串 |
| | | jsonObject.put("StartTime",now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 转化为yyyy-MM-dd HH:mm:ss格式字符串 |
| | | jsonObject.put("EndTime",now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | jsonObject.put("TotalPower",chargingOrder.getElectricity()); |
| | | jsonObject.put("TotalMoney",chargingOrder.getOrderAmount()); |
| | | chuanYiChongSuperviseUtil.notificationSupEquipChargeStatus(new Operator(), jsonObject); |
| | | break; |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查询订单状态 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/getOrderById") |
| | | public R pushOrderStatus(@RequestParam Long orderId){ |
| | | log.info("川易充通过id查询订单:{}", orderId); |
| | | R<TChargingOrder> tChargingOrderR = chargingOrderClient.orderDetail(orderId); |
| | | return R.ok(tChargingOrderR.getData()); |
| | | } |
| | | } |