From b98305c06186f37c299c4a78674e5df662d86614 Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 9 Mar 2022 13:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=90=AF=E5=8A=A8=E5=92=8C=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xhpc/common/util/UserTypeUtil.java | 4 + .../controller/XhpcStatisticsController.java | 16 ++ .../order/mapper/XhpcHistoryOrderMapper.java | 1 + .../mapper/XhpcStatisticsServiceMapper.java | 4 + .../service/IXhpcHistoryOrderService.java | 3 + .../order/service/IXhpcStatisticsService.java | 5 + .../impl/XhpcChargeOrderServiceImpl.java | 17 +-- .../impl/XhpcHistoryOrderServiceImpl.java | 9 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 63 ++++---- .../impl/XhpcStatisticsServiceImpl.java | 35 +++++ .../mapper/XhpcHistoryOrderMapper.xml | 142 ++++++++++++++++++ 11 files changed, 256 insertions(+), 43 deletions(-) diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java index 6e8bada0..e869d608 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java @@ -5,6 +5,10 @@ package com.xhpc.common.util; * @date 2021/12/29 16:48 */ public class UserTypeUtil { + + //超管数据id + public static final Long USER_ID = 1L; + //c端用户 public static final String USER = "C"; //流量端用户 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java index d3478ecc..ee26db18 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java @@ -355,4 +355,20 @@ public class XhpcStatisticsController extends BaseController { { xhpcStatisticsService.getMechanismExport(request,response,chargingStationIds,internetUserId,operatorId,startTime,endTime,userId,type,source); } + + + + //-------------------------------------------------首页------------------------------------------------------------ + + /** + * 今日订单量、今日订电量、今日营收、今日充电枪状态 + */ + @GetMapping("/getToday") + public void getToday(@RequestParam("operatorId") Long operatorId, @RequestParam("chargingStationId")Long chargingStationId,@RequestParam("chargingPileId")Long chargingPileId) + { + xhpcStatisticsService.getToday(operatorId,chargingStationId,chargingPileId); + } + + + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index 2e4c20bb..885e2265 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -22,6 +22,7 @@ public interface XhpcHistoryOrderMapper { */ public int insert(XhpcHistoryOrder xhpcHistoryOrder); + int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder); /** * 更新 历史订单信息 * diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java index 69b50062..d488d6c1 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcStatisticsServiceMapper.java @@ -180,4 +180,8 @@ public interface XhpcStatisticsServiceMapper { * 获取登陆用户信息 */ Map getLandUser(@Param("userId")Long userId); + + + //今日订单量 + Map getTodayNUmber(Long operatorId, Long chargingStationId, Long chargingPileId,String tenantId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index f43c8742..a87df1a0 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -49,6 +49,9 @@ public interface IXhpcHistoryOrderService { void insert(XhpcHistoryOrder xhpcHistoryOrder); + int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder); + + /** * 历史订单记录(PC) * @return diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java index 96f9f03a..d2322933 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcStatisticsService.java @@ -274,4 +274,9 @@ public interface IXhpcStatisticsService { void terminalIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException; void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) throws IOException ; + + /** + * 今日订单量、今日订电量、今日营收、今日充电枪状态 + */ + Map getToday(Long operatorId,Long chargingStationId,Long chargingPileId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 421dd84b..fd02bf47 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -196,13 +196,13 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar } } } - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<无效的终端编号>>>>"+terminalSerialNumber+">>>>>>>>>>>>>"+tenantId); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>"+terminalSerialNumber+">>>>>>>>>>>>>"+tenantId); //终端信息 XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(terminalSerialNumber,tenantId); if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) { return AjaxResult.error(1104, "无效的终端编号"); } - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<无效的终端编号>>>>666666>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<终端编号>>>>>>>>>>>>>>>>"); //余额 String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString(); @@ -567,11 +567,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方充电返回>>>>>>>>>>>>>>>>>"); - if (r1.getCode() != 200) { - r.setCode(500); - r.setMsg(r1.getMsg()); - return r; - } + String startTime = DateUtil.format(date, "yyyy-MM-dd HH: mm: ss"); Map extraData1 = xhpcChargeOrderMapper.selectDate3rdNeedBy(connectorId).get(0); Long rateModelId = Long.valueOf(r1.getData().toString()); @@ -583,13 +579,12 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar Long userId = (Long) extraData2.get("userId"); int res = xhpcChargeOrderMapper.addBy3rd(internetSerialNumber, orderNo, driverId, chargingAmt, plateNum, status, date, rateModelId, terminalId, power, chargingStationId, chargingMode, 1, userId); Map data = new HashMap<>(); - System.out.println(res); + data.put("orderNo", orderNo); + data.put("startTime", startTime); + r.setData(data); if (res != 0) { r.setCode(200); - data.put("orderNo", orderNo); - data.put("startTime", startTime); r.setMsg("成功"); - r.setData(data); } else { r.setCode(500); r.setMsg("内部服务调用错误"); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index 3da3d868..c99b7168 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -201,6 +201,11 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis xhpcHistoryOrderMapper.insert(xhpcHistoryOrder); } + @Override + public int updateXhpcHistoryOrderSerialNumber(XhpcHistoryOrder xhpcHistoryOrder) { + return xhpcHistoryOrderMapper.updateXhpcHistoryOrderSerialNumber(xhpcHistoryOrder); + } + @Override public List> getListPage(String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) { @@ -222,7 +227,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis String tenantId = loginUser.getTenantId(); //桩的统计、该时段金额 List> list = new ArrayList<>(); - if (userId != 1) { + if (userId != UserTypeUtil.USER_ID) { Map landUser = xhpcHistoryOrderMapper.getLandUser(logUserId); if (landUser != null) { if (landUser.get("userType") != null) { @@ -268,7 +273,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis //桩的统计、该时段金额 List> list = new ArrayList<>(); - if (userId != 1) { + if (userId != UserTypeUtil.USER_ID) { Map landUser = xhpcHistoryOrderMapper.getLandUser(logUserId); if (landUser != null) { if (landUser.get("userType") != null) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index e128ee88..43b3702c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -633,13 +633,18 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe map.put("remark","充电结算自动申请退款"); } } - xhpcHistoryOrderService.insert(xhpcHistoryOrder); + + int number = xhpcHistoryOrderService.updateXhpcHistoryOrderSerialNumber(xhpcHistoryOrder); + if(number==0){ + xhpcHistoryOrderService.insert(xhpcHistoryOrder); + } xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>>>>>>>>>>>>>"+xhpcHistoryOrder.getSerialNumber()); final BigDecimal balance = actPrice; final String balance2 = subtract.toString(); final String openids =openid; final String refundTypes =refundType; + Map xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId()); // 另起线程处理业务上传redis数据 executorService.execute(new Runnable() { @Override @@ -653,26 +658,26 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe Map userMessage = (Map)user.getData(); if (userMessage != null && userMessage.get("phone") != null) { logger.info("<<<<<<<<<<<<<<<<进行入短信发送222>>>>>>>>>>>>>>>>>"); - HashMap paramMap = new HashMap<>(); - paramMap.put("elec", xhpcChargeOrder.getEndSoc()); - paramMap.put("sumMoney", balance.toString()); - paramMap.put("phone", userMessage.get("phone").toString()); - paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。"); - smsService.sendNotice(paramMap); -// if("1".equals(xhpcChargingPile.get("type").toString())){ -// HashMap paramMap = new HashMap<>(); -// paramMap.put("elec", xhpcChargeOrder.getEndSoc()); -// paramMap.put("sumMoney", balance.toString()); -// paramMap.put("phone", userMessage.get("phone").toString()); -// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。"); -// smsService.sendNotice(paramMap); -// }else { -// HashMap paramMap = new HashMap<>(); -// paramMap.put("sumMoney", balance.toString()); -// paramMap.put("phone", userMessage.get("phone").toString()); -// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。"); -// smsService.sendNotice(paramMap); -// } +// HashMap paramMap = new HashMap<>(); +// paramMap.put("elec", xhpcChargeOrder.getEndSoc()); +// paramMap.put("sumMoney", balance.toString()); +// paramMap.put("phone", userMessage.get("phone").toString()); +// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。"); +// smsService.sendNotice(paramMap); + if("1".equals(xhpcChargingPile.get("type").toString())){ + HashMap paramMap = new HashMap<>(); + paramMap.put("elec", xhpcChargeOrder.getEndSoc()); + paramMap.put("sumMoney", balance.toString()); + paramMap.put("phone", userMessage.get("phone").toString()); + paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。"); + smsService.sendNotice(paramMap); + }else { + HashMap paramMap = new HashMap<>(); + paramMap.put("sumMoney", balance.toString()); + paramMap.put("phone", userMessage.get("phone").toString()); + paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。"); + smsService.sendNotice(paramMap); + } } } } @@ -683,10 +688,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe try{ //充电结算后自动申请退款 if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){ - logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>"); if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){ if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){ - logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>"); refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款"); } } @@ -719,14 +722,14 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe Date date = new Date(); Long chargeOrderId = xhpcChargeOrder.getChargeOrderId(); //删除实时数据,获取最新的实时数据 - deleteRealTimeOrder(xhpcChargeOrder.getChargeOrderId()); + //deleteRealTimeOrder(xhpcChargeOrder.getChargeOrderId()); //添加新的实时数据 - List list = (List) cacheMap.get("realtimeDataList"); - if (list != null && list.size() > 0) { - for (CacheRealtimeData cacheRealtimeData : list) { - addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, type); - } - } +// List list = (List) cacheMap.get("realtimeDataList"); +// if (list != null && list.size() > 0) { +// for (CacheRealtimeData cacheRealtimeData : list) { +// addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, type); +// } +// } //添加redis到数据库 XhpcOrderRedisRecord xhpcOrderRedisRecord =new XhpcOrderRedisRecord(); xhpcOrderRedisRecord.setChargeOrderId(chargeOrderId); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java index 3da23e56..a6a954af 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java @@ -964,5 +964,40 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati IoUtil.close(out); } + /** + * 今日订单量、今日订电量、今日营收、今日充电枪状态 + * + * @param operatorId + * @param chargingStationId + * @param chargingPileId + */ + @Override + public Map getToday(Long operatorId, Long chargingStationId, Long chargingPileId) { + + LoginUser loginUser = tokenService.getLoginUser(); + String tenantId = loginUser.getTenantId(); + SysUser sysUser = loginUser.getSysUser(); + //今日订单量 + if(tenantId !=null && !"".equals(tenantId)){ + if(sysUser.getUserId() !=UserTypeUtil.USER_ID){ + if ("01".equals(sysUser.getUserType())) { + Long logOperatorId = sysUser.getOperatorId(); + + }else{ + + } + }else{ + + } + } + + + //今日订电量 + //今日营收 + //今日充电枪状态 + + return null; + } + } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 3fd96adb..dc222662 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -979,4 +979,146 @@ and co.tenant_id = #{tenantId} + + + UPDATE xhpc_history_order + + + charging_station_id = #{chargingStationId}, + + + charge_order_id = #{chargeOrderId}, + + + user_id = #{userId}, + + + terminal_id = #{terminalId}, + + + serial_number = #{serialNumber}, + + + internet_serial_number = #{internetSerialNumber}, + + + power_price_total = #{powerPriceTotal}, + + + service_price_total = #{servicePriceTotal}, + + + total_price = #{totalPrice}, + + + promotion_discount = #{promotionDiscount}, + + + act_price = #{actPrice}, + + + act_power_price = #{actPowerPrice}, + + + act_service_price = #{actServicePrice}, + + + internet_commission = #{internetCommission}, + + + internet_svc_commission = #{internetSvcCommission}, + + + platform_commission = #{platformCommission}, + + + platform_svc_commisssion = #{platformSvcCommisssion}, + + + operation_commission = #{operationCommission}, + + + operation_svc_commission = #{operationSvcCommission}, + + + start_soc = #{startSoc}, + + + end_soc = #{endSoc}, + + + reconciliation_status = #{reconciliationStatus}, + + + sorting_status = #{sortingStatus}, + + + `type` = #{type}, + + + `status` = #{status}, + + + del_flag = #{delFlag}, + + + create_time = #{createTime}, + + + create_by = #{createBy}, + + + update_time = #{updateTime}, + + + update_by = #{updateBy}, + + + remark = #{remark}, + + + `state` = #{state}, + + + vin_normal = #{vinNormal}, + + + search_value = #{searchValue}, + + + operator_id_evcs = #{operatorIdEvcs}, + + + charge_model_evcs = #{chargeModelEvcs}, + + + connector_power_evcs = #{connectorPowerEvcs}, + + + meter_value_end_evcs = #{meterValueEndEvcs}, + + + meter_value_start_evcs = #{meterValueStartEvcs}, + + + operator_id3rdpty_evcs = #{operatorId3rdptyEvcs}, + + + start_time = #{startTime}, + + + stop_reason_evcs = #{stopReasonEvcs}, + + + total_power = #{totalPower}, + + + user_name_evcs = #{userNameEvcs}, + + + phone = #{phone}, + + + where internet_serial_number = #{internetSerialNumber} +