diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/IndexController/IndexController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/IndexController/IndexController.java new file mode 100644 index 0000000..1ee2e5f --- /dev/null +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/IndexController/IndexController.java @@ -0,0 +1,71 @@ +package com.ruoyi.web.controller.IndexController; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.AsUser; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.domain.EtOperatingArea; +import com.ruoyi.system.domain.vo.IndexAdminVo; +import com.ruoyi.system.domain.vo.IndexVo; +import com.ruoyi.system.service.IEtOperatingAreaService; +import com.ruoyi.system.service.IEtOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * index首页统计 + * 校验 + * @author ruoyi + */ +@RestController +@RequestMapping("/index") +public class IndexController extends BaseController +{ + + @Autowired + private IEtOrderService etOrderService; + + @Autowired + private IEtOperatingAreaService etOperatingAreaService; + + /** + * 根据token获取运营区列表(后台) + */ + @GetMapping("/getAreaList") + public AjaxResult getAreaList() + { + List longs = etOperatingAreaService.selectAreaListByDeptId2(getDeptId()); + logger.info("根据token获取运营区列表:【{}】", JSON.toJSON(longs)); + return success(longs); + } + + /** + * 首页统计-运营商 + */ + @GetMapping(value = "/statistics") + public AjaxResult statistics(Long areaId) + { + logger.info("【首页统计】请求参数: areaId={}", areaId); + IndexVo indexVo = etOrderService.statistics(areaId); + return success(indexVo); + } + + + /** + * 首页统计-总管理 + */ + @GetMapping(value = "/admim/statistics") + public AjaxResult admimStatistics() + { + logger.info("【首页统计】请求参数"); + IndexAdminVo indexAdminVo = etOrderService.admimStatistics(); + return success(indexAdminVo); + } + +} diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 3fd6050..50c3056 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -207,6 +207,11 @@ public class AppVerifyController extends BaseController return error(CommonUtil.format(status)); } } + // 当前有骑行中的订单 + EtOrder currentOrder = etOrderService.getCurrentOrder(asDevice.getSn()); + if(ObjectUtil.isNotNull(currentOrder)){ + return error("当前车辆有骑行中的订单,请换车"); + } //根据余额和充值记录判断是否有充值过押金,没有充值过押金,提示充值押金 if(!asUserService.checkIsDeposit(order.getUserId())){ return error("您还未充值押金,请先充值押金"); @@ -1041,14 +1046,14 @@ public class AppVerifyController extends BaseController */ @Log(title = "换车关锁", businessType = BusinessType.CHANGELOCK) @PostMapping("/changeVehicle/lock") - public AjaxResult changeVehicleLock(String orderNo,String changeReason) + public AjaxResult changeVehicleLock(String orderNo,String changeReason,String isBluetooth,String lon,String lat,String voltage) { if (StrUtil.isBlank(orderNo)){ logger.info("没有orderNo参数:【orderNo={}】",orderNo); return error("请传orderNo号参数"+"【orderNo="+orderNo+"】"); } logger.info("【换车关锁请求】:orderNo={}",orderNo); - Boolean aBoolean = etOrderService.changeVehicleLock(orderNo,changeReason); + Boolean aBoolean = etOrderService.changeVehicleLock(orderNo,changeReason,isBluetooth,lon,lat,voltage); return success(aBoolean); } @@ -1057,7 +1062,7 @@ public class AppVerifyController extends BaseController */ @Log(title = "换车开锁", businessType = BusinessType.CHANGEUNLOCK) @PostMapping("/changeVehicle/unlocking") - public AjaxResult changeVehicleLockUnlocking(String orderNo,String newSn) + public AjaxResult changeVehicleLockUnlocking(String orderNo,String newSn,String isBluetooth,String lon,String lat,String voltage) { if (StrUtil.isBlank(newSn)){ logger.info("没有sn号参数:【newSn={}】",newSn); @@ -1068,7 +1073,37 @@ public class AppVerifyController extends BaseController return error("请传orderNo号参数"+"【orderNo="+orderNo+"】"); } logger.info("【换车开锁请求】:orderNo={},newSn ={}",orderNo,newSn); - Boolean aBoolean =etOrderService.changeVehicleLockUnlocking(orderNo,newSn); + Boolean aBoolean =etOrderService.changeVehicleLockUnlocking(orderNo,newSn,isBluetooth,lon,lat,voltage); return success(aBoolean); } + + /** + * 开坐垫锁 + */ + @PostMapping("/device/seatCushionLock") + public AjaxResult seatCushionLock(String sn) + { + if(StrUtil.isBlank(sn)){ + logger.info("没有sn号参数:【sn={}】",sn); + return error("请传sn号参数"+"【sn="+sn+"】"); + } + Boolean i =asDeviceService.seatCushionLock(sn); + return success(i); + } + + + /** + * 坐垫锁用mac + */ + @PostMapping("/device/seatCushionLockByMac") + public AjaxResult seatCushionLockByMac(String mac) + { + if(StrUtil.isBlank(mac)){ + logger.info("没有mac号参数:【mac={}】",mac); + return error("请传mac号参数"+"【mac="+mac+"】"); + } + Boolean i =asDeviceService.seatCushionLockByMac(mac); + return success(i); + } + } diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtFeeRuleController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtFeeRuleController.java index 76bb490..07a4c05 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtFeeRuleController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtFeeRuleController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.domain.entity.SysDept; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtOperatingAreaController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtOperatingAreaController.java index e7c9884..657781e 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtOperatingAreaController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/EtOperatingAreaController.java @@ -1,15 +1,18 @@ package com.ruoyi.web.controller.system; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSON; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.EtOperatingArea; import com.ruoyi.system.service.IEtFeeRuleService; import com.ruoyi.system.service.IEtOperatingAreaService; +import com.ruoyi.system.service.IWxPayService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -33,6 +36,10 @@ public class EtOperatingAreaController extends BaseController @Autowired private IEtFeeRuleService etFeeRuleService; + @Autowired + private IWxPayService wxPayService; + + /** * 查询运营区列表 */ @@ -67,6 +74,11 @@ public class EtOperatingAreaController extends BaseController { AjaxResult ajax = AjaxResult.success(); EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); + SysDept sysDept = wxPayService.getDeptObjByAreaId(area.getAreaId()); + if(ObjectUtil.isNotNull(sysDept)){ + area.setDeptId(sysDept.getDeptId()); + area.setDeptName(sysDept.getDeptName()); + } ajax.put(AjaxResult.DATA_TAG, area); ajax.put("ruleIds", etFeeRuleService.selectRuleListByAreaId(areaId)); return ajax; diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index b3f086e..6c862b7 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -57,6 +57,7 @@ public class SysDeptController extends BaseController @GetMapping("/list") public AjaxResult list(SysDept dept) { + startPage(); List depts = deptService.selectDeptList(dept); return success(depts); } diff --git a/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java b/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java index 4855266..ab41731 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java +++ b/electripper-common/src/main/java/com/ruoyi/common/constant/IotConstants.java @@ -46,6 +46,11 @@ public class IotConstants { */ public static final String COMMAND_OPEN = "open"; + /** + * 命令 开坐垫锁 + */ + public static final String COMMAND_HPEN = "hpen"; + /** * 命令 关闭 */ diff --git a/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java b/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java index b07e581..d6f4d7b 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java +++ b/electripper-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java @@ -65,7 +65,7 @@ public class ServiceConstants { /**----------------------------支付场景end----------------------------*/ /**----------------------------订单状态start----------------------------*/ - /** 订单状态:0-预约中,1-取消预约,2-开始骑行,3-结束 4-订单结束 5-待审核 6-车辆有损坏 */ + /** 订单状态:0-预约中,1-取消预约,2-开始骑行,3-结束 4-订单结束 5-待审核 6-车辆有损坏 */ /** * 订单状态:0-预约中 */ diff --git a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java index 7dd7c8e..16fd1fc 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java +++ b/electripper-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -109,6 +109,28 @@ public class SysDept extends BaseEntity /** app用户id,用于提现 */ private Long appUserId; + /** 用户名 */ + private String userName; + + /** 区域名称 */ + private String areaName; + + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + public Long getAppUserId() { return appUserId; } diff --git a/electripper-common/src/main/java/com/ruoyi/common/utils/CommonUtil.java b/electripper-common/src/main/java/com/ruoyi/common/utils/CommonUtil.java index 41f6f8d..567fb90 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/utils/CommonUtil.java +++ b/electripper-common/src/main/java/com/ruoyi/common/utils/CommonUtil.java @@ -124,6 +124,10 @@ public class CommonUtil { if(multiply.compareTo(new BigDecimal(0)) < 0){ multiply = new BigDecimal(0); } + // 剩余续航里程大于满电续航里程 最大为满电续航里程 + if(multiply.compareTo(new BigDecimal(fullEndurance)) > 0){ + multiply = new BigDecimal(fullEndurance); + } log.info("当前剩余续航里程:{}km",multiply); return multiply.intValue(); } diff --git a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 860ff0a..1cd5337 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -269,6 +269,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils return Date.from(zdt.toInstant()); } + /** + * 减去多少天后的时间 + */ + public static Date getTimeAfterXDays(Date unlockTime, int xDays) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(unlockTime); + calendar.add(Calendar.DAY_OF_MONTH, -xDays); + return calendar.getTime(); // 返回新时间 + } + /** * 加上固定个小时后的时间 */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java index 114c803..ade1622 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtFault.java @@ -52,6 +52,10 @@ public class EtFault extends BaseEntity @Excel(name = "订单id") private Long orderId; + /** 订单号 */ + @Excel(name = "订单号") + private String orderNo; + /** 报修进度 */ @Excel(name = "报修进度") private String status; diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java index b4719ad..63fd594 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOperatingArea.java @@ -34,6 +34,10 @@ public class EtOperatingArea extends BaseEntityPlus implements Serializable @TableField(exist = false) private Long deptId; + /** 运营商 */ + @TableField(exist = false) + private String deptName; + /** 区域名称 */ @Excel(name = "区域名称") private String areaName; diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java new file mode 100644 index 0000000..7c5fe42 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java @@ -0,0 +1,172 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 首页统计响应 + * + * @author 邱贞招 + * @date 2024-05-09 + */ +@Data +public class IndexAdminVo { + + /** 运营商数 */ + private Integer operatorCount=0; + /** 独立小程序 */ + private Integer appCount=0; + + /** 商户总余额 */ + private BigDecimal totalBalance = BigDecimal.ZERO; + /** 已提现金额 */ + private BigDecimal withdrawn = BigDecimal.ZERO; + + /** 运营区数 */ + private Integer areaCount=0; + + /** 车辆型号数 */ + private Integer modelCount=0; + + /** 用户总数 */ + private Integer userCount=0; + /** 今日新增 */ + private Integer todayUserCount=0; + + /** 今日订单数 */ + private Integer todayOrderCount=0; + /** 总订单数 */ + private Integer totalOrderCount=0; + + /** 今日订单金额 */ + private BigDecimal todayOrderFee= BigDecimal.ZERO; + /** 订单总金额 */ + private BigDecimal totalOrderFee= BigDecimal.ZERO; + + /** 今日退款金额 */ + private BigDecimal todayRefundFee= BigDecimal.ZERO; + /** 总退款金额 */ + private BigDecimal totalRefundFee= BigDecimal.ZERO; + + /** 待付款订单金额 */ + private BigDecimal unpaidOrderFee= BigDecimal.ZERO; + /** 待付款订单数 */ + private Integer unpaidOrderCount=0; + + /** 待审核还车押金扣款 */ + private BigDecimal returnOrderDeductFee= BigDecimal.ZERO; + /** 还车待审核订单数 */ + private Integer returnOrderCount=0; + + /** 今日支付手续费 */ + private BigDecimal todayHandlingFee= BigDecimal.ZERO; + /** 总支付手续费 */ + private BigDecimal totalHandlingFee= BigDecimal.ZERO; + + /** 今日服务费 */ + private BigDecimal todayServiceFee= BigDecimal.ZERO; + /** 总服务费 */ + private BigDecimal totalServiceFee= BigDecimal.ZERO; + + /** 车辆统计 */ + private VehicleVo vehicleVo; + + /** 运维统计 */ + private OperationVo operationVo; + + /** 收入统计list */ + private List incomeVoList; + + /** + * 营收统计 incomeVo + */ + @Data + public static class IncomeVo { + /** 日期 */ + private String day; + /** 订单金额 */ + private BigDecimal orderFee; + /** 订单数 */ + private Integer orderNum; + } + + /** + * 车辆统计 + */ + @Data + public static class VehicleVo { + /** 全部车辆 */ + private Integer allNum; + + /** 行驶中 */ + private Integer ridingNum; + + /** 临时锁车 */ + private Integer temporarilyLockNum; + + /** 已禁用 */ + private Integer disabledNum; + + /** 已离线 */ + private Integer offlineNum; + + /** 正常待租 */ + private Integer normalNum; + + /** 预约中 */ + private Integer inAppointmentNum; + + /** 调度设备 */ + private Integer dispatchNum; + + /** 仓库设备 */ + private Integer inStashNum; + + /** 运营中 */ + private Integer inOperation; + } + + /** + * 运维统计 + */ + @Data + public static class OperationVo { + /** 4g解锁失败 */ + private Integer failedUnlockCount; + + /** 蓝牙解锁数 */ + private Integer bluetoothUnlockCount; + + /** 设备离线率 */ + private BigDecimal deviceOfflineRate; + + /** 异常排查车辆 */ + private Integer faultOrderCount; + + /** 待换电 */ + private Integer replacementOrderCount; + + /** 待维修 */ + private Integer repairCount; + + } + +// /** +// * 订单信息统计 +// */ +// @Data +// public static class OrderFeeStatisticsVo { +// /** 营收 */ +// private BigDecimal incomeFee = BigDecimal.ZERO; +// +// /** 订单金额 */ +// private BigDecimal orderFee = BigDecimal.ZERO; +// +// /** 订单数 */ +// private Integer orderCount = 0; +// } + + +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexVo.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexVo.java new file mode 100644 index 0000000..859e1c8 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/IndexVo.java @@ -0,0 +1,160 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 首页统计响应 + * + * @author 邱贞招 + * @date 2024-05-09 + */ +@Data +public class IndexVo { + + /** 余额 */ + private BigDecimal balance = BigDecimal.ZERO; + + /** 已提现 */ + private BigDecimal withdraw = BigDecimal.ZERO; + + /** 待结算金额 */ + private BigDecimal settlementAmount = BigDecimal.ZERO; + + /** 今日营收 */ + private BigDecimal todayIncome= BigDecimal.ZERO; + + /** 今日订单金额 */ + private BigDecimal todayOrderFee= BigDecimal.ZERO; + + /** 今日订单数 */ + private Integer todayOrderCount=0; + + /** 总营收 */ + private BigDecimal totalIncome= BigDecimal.ZERO; + + /** 总订单数 */ + private Integer totalOrderCount=0; + + /** 总订单金额 */ + private BigDecimal totalOrderFee= BigDecimal.ZERO; + + /** 待付款订单数 */ + private Integer unpaidOrderCount=0; + + /** 待付款订单金额 */ + private BigDecimal unpaidOrderFee= BigDecimal.ZERO; + + /** 还车待审核订单 */ + private Integer returnOrderCount=0; + + /** 骑行中订单 */ + private Integer ridingOrder=0; + + /** 今日退款金额 */ + private BigDecimal todayRefundFee= BigDecimal.ZERO; + + /** 待审核故障 */ + private Integer faultOrderCount=0; + + /** 车辆统计 */ + private VehicleVo vehicleVo; + + /** 运维统计 */ + private OperationVo operationVo; + + /** 收入统计list */ + private List incomeVoList; + + /** + * 收入统计 incomeVo + */ + @Data + public static class IncomeVo { + /** 日期 */ + private String day; + /** 收入 */ + private BigDecimal income; + /** 订单数 */ + private Integer orderNum; + } + + /** + * 车辆统计 + */ + @Data + public static class VehicleVo { + /** 全部车辆 */ + private Integer allNum; + + /** 行驶中 */ + private Integer ridingNum; + + /** 临时锁车 */ + private Integer temporarilyLockNum; + + /** 已禁用 */ + private Integer disabledNum; + + /** 已离线 */ + private Integer offlineNum; + + /** 正常待租 */ + private Integer normalNum; + + /** 预约中 */ + private Integer inAppointmentNum; + + /** 调度设备 */ + private Integer dispatchNum; + + /** 仓库设备 */ + private Integer inStashNum; + + /** 运营中 */ + private Integer inOperation; + } + + /** + * 运维统计 + */ + @Data + public static class OperationVo { + /** 换电工单 */ + private Integer replacementOrderCount; + + /** 已完成换电 */ + private Integer completedReplacementOrderCount; + + /** 调度工单 */ + private Integer dispatchCount; + + /** 已完成调度工单 */ + private Integer completedDispatchCount; + + /** 维修工单 */ + private Integer repairCount; + + /** 已完成维修工单 */ + private Integer completedRepairCount; + } + + /** + * 订单信息统计 + */ + @Data + public static class OrderFeeStatisticsVo { + /** 营收 */ + private BigDecimal incomeFee = BigDecimal.ZERO; + + /** 订单金额 */ + private BigDecimal orderFee = BigDecimal.ZERO; + + /** 订单数 */ + private Integer orderCount = 0; + } + + +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java index 42d229d..a316fb3 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/AsUserMapper.java @@ -156,4 +156,9 @@ public interface AsUserMapper * 快速查询 */ List fastSearch(String phonenumber); + + /** + * 获取用户总数 + */ + Integer selectAllCount(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAdminOrderMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAdminOrderMapper.java index 7857ec5..c8cd368 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAdminOrderMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAdminOrderMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.EtAdminOrder; +import org.apache.ibatis.annotations.Param; /** * 换电工单Mapper接口 @@ -82,4 +83,13 @@ public interface EtAdminOrderMapper * @return 换电工单 */ public Integer checkOrderUnique(String sn); + + /** + * 换电单状态统计 + * + * @param status + * @param areaId + * @return 结果 + */ + int getOrderCount(@Param("type") String type,@Param("status") String status, @Param("areaId")Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAreaDeptMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAreaDeptMapper.java index 2d4a8b6..3cd1675 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAreaDeptMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtAreaDeptMapper.java @@ -17,4 +17,12 @@ public interface EtAreaDeptMapper extends BaseMapper * @return 结果 */ public int deleteAreaDeptByDeptId(Long deptId); + + /** + * 通过区域id删除区域与部门关联 + * + * @param areaId 区域id + * @return 结果 + */ + public int deleteAreaDeptByAreaId(Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java index 4d18278..afd62b2 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtCapitalFlowMapper.java @@ -1,7 +1,9 @@ package com.ruoyi.system.mapper; +import java.math.BigDecimal; import java.util.List; import com.ruoyi.system.domain.EtCapitalFlow; +import org.apache.ibatis.annotations.Param; /** * 资金流水Mapper接口 @@ -60,4 +62,16 @@ public interface EtCapitalFlowMapper public int deleteEtCapitalFlowByFlowIds(Long[] flowIds); EtCapitalFlow selectEtCapitalFlowByOutTradeNo(String outTradeNo); + + /** + * 已提现金额 + * + * @param areaId 运营区id + * @return + */ + BigDecimal getWithdrawnFee(@Param("areaId") Long areaId, @Param("status") String status); + + BigDecimal getHandlingFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId); + + BigDecimal getServiceFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtFaultMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtFaultMapper.java index b8f6fbc..4e0d43d 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtFaultMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtFaultMapper.java @@ -2,18 +2,19 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.EtFault; +import org.apache.ibatis.annotations.Param; /** * 故障上报Mapper接口 - * + * * @author 邱贞招 * @date 2024-04-06 */ -public interface EtFaultMapper +public interface EtFaultMapper { /** * 查询故障上报 - * + * * @param faultId 故障上报主键 * @return 故障上报 */ @@ -21,7 +22,7 @@ public interface EtFaultMapper /** * 查询故障上报列表 - * + * * @param etFault 故障上报 * @return 故障上报集合 */ @@ -29,7 +30,7 @@ public interface EtFaultMapper /** * 新增故障上报 - * + * * @param etFault 故障上报 * @return 结果 */ @@ -37,7 +38,7 @@ public interface EtFaultMapper /** * 修改故障上报 - * + * * @param etFault 故障上报 * @return 结果 */ @@ -45,7 +46,7 @@ public interface EtFaultMapper /** * 删除故障上报 - * + * * @param faultId 故障上报主键 * @return 结果 */ @@ -53,9 +54,17 @@ public interface EtFaultMapper /** * 批量删除故障上报 - * + * * @param faultIds 需要删除的数据主键集合 * @return 结果 */ public int deleteEtFaultByFaultIds(Long[] faultIds); + + /** + * 获取待审核故障数量 + * + * @param areaId 区域id + * @return 结果 + */ + int getAuditFaultNum(Long areaId); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtModelMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtModelMapper.java index 96950af..c6f2f02 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtModelMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtModelMapper.java @@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtModel; /** * 车辆型号Mapper接口 - * + * * @author 邱贞招 * @date 2024-05-13 */ -public interface EtModelMapper +public interface EtModelMapper { /** * 查询车辆型号 - * + * * @param modelId 车辆型号主键 * @return 车辆型号 */ @@ -21,7 +21,7 @@ public interface EtModelMapper /** * 查询车辆型号列表 - * + * * @param etModel 车辆型号 * @return 车辆型号集合 */ @@ -29,7 +29,7 @@ public interface EtModelMapper /** * 新增车辆型号 - * + * * @param etModel 车辆型号 * @return 结果 */ @@ -37,7 +37,7 @@ public interface EtModelMapper /** * 修改车辆型号 - * + * * @param etModel 车辆型号 * @return 结果 */ @@ -45,7 +45,7 @@ public interface EtModelMapper /** * 删除车辆型号 - * + * * @param modelId 车辆型号主键 * @return 结果 */ @@ -53,9 +53,12 @@ public interface EtModelMapper /** * 批量删除车辆型号 - * + * * @param modelIds 需要删除的数据主键集合 * @return 结果 */ public int deleteEtModelByModelIds(Long[] modelIds); + + + int selectAllCount(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java index 710f48d..0e788cb 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtOrderMapper.java @@ -191,6 +191,26 @@ public interface EtOrderMapper */ String getUnpaidOrder(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId); + /** + * 还车待审核订单数 + */ + int getAuditOrderNum(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId); + + /** + * 待审核还车押金扣款 + */ + BigDecimal getReturnOrderDeductFee(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") String areaId); + + /** + * 获取订单数 + */ + int getOrderNum(@Param("timeStart") String timeStart, @Param("timeEnd") String timeEnd, @Param("areaId") Long areaId); + + /** + * 订单总金额 + */ + BigDecimal getOrderFee(@Param("startDateStr") String timeStart, @Param("endDateStr") String timeEnd, @Param("areaId") Long areaId); + /** * 手续费 */ @@ -258,4 +278,7 @@ public interface EtOrderMapper * 平台服务费 */ BigDecimal getPlatformServiceFee(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr, @Param("areaId") Long areaId); + + + Integer getAppCount(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index e64cb9f..cd21b46 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -136,4 +136,15 @@ public interface SysDeptMapper void changeDeptBalance(@Param("amount")BigDecimal amount,@Param("deptId")Long deptId); + /** + * 获取所有运营商数 + * + * @return 结果 + */ + int selectAllCount(); + + int getAppCount(); + + BigDecimal selectAllBalance(); + } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java index 5aa85d5..4109cec 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java @@ -184,6 +184,11 @@ public interface IAsDeviceService extends IService */ Boolean ring(String sn); + /** + * 开坐垫锁 + */ + Boolean seatCushionLock(String sn); + /** * 重启设备 @@ -199,6 +204,11 @@ public interface IAsDeviceService extends IService */ Boolean ringByMac(String mac); + /** + * 坐垫锁用mac + */ + Boolean seatCushionLockByMac(String mac); + /** * 临时锁车 */ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtCapitalFlowService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtCapitalFlowService.java index a0922ef..9ad851b 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtCapitalFlowService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtCapitalFlowService.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service; +import java.math.BigDecimal; import java.util.List; import com.ruoyi.system.domain.EtCapitalFlow; @@ -66,4 +67,12 @@ public interface IEtCapitalFlowService * @return 结果 */ public int deleteEtCapitalFlowByFlowId(Long flowId); + + /** + * 已提现金额 + * + * @param areaId 运营区id + * @return + */ + BigDecimal getWithdrawnFee(Long areaId,String status); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtModelService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtModelService.java index 79f63da..0ceb671 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtModelService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtModelService.java @@ -5,15 +5,15 @@ import com.ruoyi.system.domain.EtModel; /** * 车辆型号Service接口 - * + * * @author 邱贞招 * @date 2024-05-13 */ -public interface IEtModelService +public interface IEtModelService { /** * 查询车辆型号 - * + * * @param modelId 车辆型号主键 * @return 车辆型号 */ @@ -21,7 +21,7 @@ public interface IEtModelService /** * 查询车辆型号列表 - * + * * @param etModel 车辆型号 * @return 车辆型号集合 */ @@ -29,7 +29,7 @@ public interface IEtModelService /** * 新增车辆型号 - * + * * @param etModel 车辆型号 * @return 结果 */ @@ -37,7 +37,7 @@ public interface IEtModelService /** * 修改车辆型号 - * + * * @param etModel 车辆型号 * @return 结果 */ @@ -45,7 +45,7 @@ public interface IEtModelService /** * 批量删除车辆型号 - * + * * @param modelIds 需要删除的车辆型号主键集合 * @return 结果 */ @@ -53,9 +53,15 @@ public interface IEtModelService /** * 删除车辆型号信息 - * + * * @param modelId 车辆型号主键 * @return 结果 */ public int deleteEtModelByModelId(Long modelId); + + /** + * 查询所有车辆型号数 + * @return + */ + public int selectAllCount(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java index 0da0ff0..d1ee7fc 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IEtOrderService.java @@ -5,10 +5,7 @@ import java.util.List; import com.ruoyi.system.domain.EtOrder; import com.ruoyi.system.domain.EtRefund; -import com.ruoyi.system.domain.vo.EtOrderVo; -import com.ruoyi.system.domain.vo.OperatingDataVo; -import com.ruoyi.system.domain.vo.RechargeVo; -import com.ruoyi.system.domain.vo.ReconciliationVo; +import com.ruoyi.system.domain.vo.*; import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse; import com.wechat.pay.java.service.refund.model.Refund; @@ -205,15 +202,25 @@ public interface IEtOrderService /** * 换车关锁 */ - Boolean changeVehicleLock(String orderNo,String changeReason); + Boolean changeVehicleLock(String orderNo,String changeReason,String isBluetooth,String lon,String lat,String voltage); /** * 换车开锁 */ - Boolean changeVehicleLockUnlocking(String orderNo,String newSn); + Boolean changeVehicleLockUnlocking(String orderNo,String newSn,String isBluetooth,String lon,String lat,String voltage); /** * 押金订单 */ EtOrder getDepositOrder(Long userId); + + /** + * 首页统计-运营商 + */ + IndexVo statistics(Long areaId); + + /** + * 首页统计-总管理 + */ + IndexAdminVo admimStatistics(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/electripper-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index d407378..ca636ec 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -161,4 +161,19 @@ public interface ISysDeptService * 管理员提现失败 */ int rejectWithdraw(Long flowId); + + /** + * 运营商数 + */ + int selectAllCount(); + + /** + * 独立小程序 + */ + int getAppCount(); + + /** + * 所有余额 + */ + BigDecimal selectAllBalance(); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index 2050b7d..2a5a925 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -783,7 +783,7 @@ public class AsDeviceServiceImpl extends ServiceImpl i @Override public Boolean online(String sn) { AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); - asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL_STR); + asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); int device = asDeviceMapper.updateAsDevice(asDevice); if(device==0){ log.info("车辆上线状态失败"); @@ -909,6 +909,15 @@ public class AsDeviceServiceImpl extends ServiceImpl i log.info("【"+type+"】===>IOT请求调用结果:【{}】",result); JSONObject paramsObj = JSON.parseObject(result); String code = paramsObj.getString("code"); + + if ("10500".equals(code)) { // 超时 + log.info("第一次请求超时,进行第二次请求..."); + result = HttpUtils.sendPostWithToken(sendUrl, command, token); + log.info("【" + type + "】===>IOT第二次请求调用结果:【{}】", result); + paramsObj = JSON.parseObject(result); + code = paramsObj.getString("code"); + } + asynchronousSaveLog(sendUrl,command,mac,result,type,orderNo,userName); //记录命令 if (!HttpStatus.IOT_SUCCESS.equals(code)) @@ -980,6 +989,14 @@ public class AsDeviceServiceImpl extends ServiceImpl i String result = HttpUtils.sendPostWithToken(sendUrl, command, token); log.info("【"+type+"】===>IOT请求调用结果:【{}】",result); ResponseVo responseVo = JSON.parseObject(result, ResponseVo.class); + + if (responseVo.getCode() == 10500) { // 超时 + log.info("第一次请求超时,进行第二次请求..."); + result = HttpUtils.sendPostWithToken(sendUrl, command, token); + log.info("【" + type + "】===>IOT第二次请求调用结果:【{}】", result); + responseVo = JSON.parseObject(result, ResponseVo.class); + } + if(responseVo.getCode() != 0){ asynchronousUpdateOnlineStatus(mac); } @@ -1017,6 +1034,26 @@ public class AsDeviceServiceImpl extends ServiceImpl i return Boolean.TRUE; } + /** + * 开坐垫锁 + * @param sn + * @return + */ + @SneakyThrows + @Override + public Boolean seatCushionLock(String sn) { + AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); + /** 1.获取token*/ + String token = Token.getToken(); + Boolean execute = transactionTemplate.execute(e -> { + /** 2.发送命令*/ + sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_HPEN,"开坐垫锁",null,null); + return Boolean.TRUE; + }); + if(!execute)throw new ServiceException("开坐垫锁失败"); + return Boolean.TRUE; + } + /** * 重启设备 * @param sn @@ -1075,6 +1112,26 @@ public class AsDeviceServiceImpl extends ServiceImpl i return Boolean.TRUE; } + + /** + * 坐垫锁用mac + * @param mac + * @return + */ + @SneakyThrows + @Override + public Boolean seatCushionLockByMac(String mac) { + /** 1.获取token*/ + String token = Token.getToken(); + Boolean execute = transactionTemplate.execute(e -> { + /** 2.发送命令*/ + sendCommand(mac, token,IotConstants.COMMAND_HPEN,"开坐垫锁",null,null); + return Boolean.TRUE; + }); + if(!execute)throw new ServiceException("开坐垫锁失败"); + return Boolean.TRUE; + } + /** * 临时锁车 * @param orderNo @@ -1132,7 +1189,13 @@ public class AsDeviceServiceImpl extends ServiceImpl i /** 2.发送命令*/ sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车",null,userName); asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); - asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); + // 判断该sn是否有正在骑行中的订单,如果有骑行中的订单则修改为临时锁车 + EtOrder etOrder = etOrderService.getCurrentOrder(sn); + if(ObjectUtil.isNotNull(etOrder)){ + asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_TEMPORARILY_LOCK); + }else{ + asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); + } asDevice.setIsAdminUnlocking("0"); int device = asDeviceMapper.updateAsDevice(asDevice); if(device==0){ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtCapitalFlowServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtCapitalFlowServiceImpl.java index 17dc2b7..d314601 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtCapitalFlowServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtCapitalFlowServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service.impl; +import java.math.BigDecimal; import java.util.List; import com.ruoyi.common.annotation.DataScope; @@ -106,4 +107,15 @@ public class EtCapitalFlowServiceImpl implements IEtCapitalFlowService { return etCapitalFlowMapper.deleteEtCapitalFlowByFlowId(flowId); } + + /** + * 已提现金额 + * + * @param areaId 运营区id + * @return + */ + @Override + public BigDecimal getWithdrawnFee(Long areaId,String status) { + return etCapitalFlowMapper.getWithdrawnFee(areaId,status); + } } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFeeRuleServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFeeRuleServiceImpl.java index a041f56..ac8c15f 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFeeRuleServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtFeeRuleServiceImpl.java @@ -2,11 +2,14 @@ package com.ruoyi.system.service.impl; import java.util.List; +import cn.hutool.core.util.ObjectUtil; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.service.IEtOperatingAreaService; +import com.ruoyi.system.service.IWxPayService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.EtFeeRuleMapper; @@ -28,6 +31,9 @@ public class EtFeeRuleServiceImpl implements IEtFeeRuleService @Autowired private IEtOperatingAreaService etOperatingAreaService; + @Autowired + private IWxPayService wxPayService; + /** * 查询收费方式 * @@ -64,6 +70,10 @@ public class EtFeeRuleServiceImpl implements IEtFeeRuleService @DataScope(deptAlias = "d") public List selectEtFeeRuleList(EtFeeRule etFeeRule) { + if(ObjectUtil.isNotNull(etFeeRule.getAreaId())){ + SysDept sysDept = wxPayService.getDeptObjByAreaId(etFeeRule.getAreaId()); + etFeeRule.setDeptId(sysDept.getDeptId()); + } return etFeeRuleMapper.selectEtFeeRuleList(etFeeRule); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtModelServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtModelServiceImpl.java index 0d42ddb..810c161 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtModelServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtModelServiceImpl.java @@ -206,4 +206,9 @@ public class EtModelServiceImpl implements IEtModelService return etModelMapper.deleteEtModelByModelId(modelId); } + @Override + public int selectAllCount() { + return etModelMapper.selectAllCount(); + } + } diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java index 60c06d0..7105bd0 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOperatingAreaServiceImpl.java @@ -9,12 +9,15 @@ import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.map.GeoUtils; import com.ruoyi.system.domain.AsDevice; +import com.ruoyi.system.domain.EtAreaDept; import com.ruoyi.system.domain.EtAreaRule; import com.ruoyi.system.domain.EtOperatingArea; import com.ruoyi.system.mapper.AsDeviceMapper; +import com.ruoyi.system.mapper.EtAreaDeptMapper; import com.ruoyi.system.mapper.EtAreaRuleMapper; import com.ruoyi.system.mapper.EtOperatingAreaMapper; import com.ruoyi.system.service.IAsDeviceService; @@ -60,6 +63,9 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl 0){ + for (Long ruleId:ruleIds){ + etAreaRuleMapper.insert(EtAreaRule.builder().areaId(etOperatingArea.getAreaId()).ruleId(ruleId).build()); + } + } + Long deptId = SecurityUtils.getDeptId(); + if(deptId == 100){ + deptId = etOperatingArea.getDeptId(); + } + if(!ObjectUtil.isNotNull(etOperatingArea.getDeptId()) && deptId == 100){ + throw new ServiceException("请选择运营商"); + } + int insert1 = etAreaDeptMapper.insert(EtAreaDept.builder().areaId(etOperatingArea.getAreaId()).deptId(deptId).build()); + if(insert1 > 0){ + log.info("新增运营区与运营商关联成功"); } return insert; } @@ -175,6 +194,17 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl 0){ + etAreaDeptMapper.insert(EtAreaDept.builder().areaId(etOperatingArea.getAreaId()).deptId(deptId).build()); + } return i; } @@ -285,19 +315,24 @@ public class EtOperatingAreaServiceImpl extends ServiceImpl0){ for(EtOperatingArea etOperatingArea:etOperatingAreas){ - Geometry geometry = GeoUtils.fromWkt(etOperatingArea.getBoundary()); - if (geometry.contains(point)) { - return etOperatingArea; - }else{ - // 获取多边形的外边界 - Coordinate[] coordinates = geometry.getCoordinates(); - for (Coordinate coord : coordinates) { - double distance = GeoUtils.calculateDistance(lat, lon, coord.y, coord.x); - if (distance < minDistance) { - minDistance = distance; - closestArea = etOperatingArea; + String boundary = etOperatingArea.getBoundary(); + if(StrUtil.isNotBlank(boundary)){ + Geometry geometry = GeoUtils.fromWkt(etOperatingArea.getBoundary()); + if (geometry.contains(point)) { + return etOperatingArea; + }else{ + // 获取多边形的外边界 + Coordinate[] coordinates = geometry.getCoordinates(); + for (Coordinate coord : coordinates) { + double distance = GeoUtils.calculateDistance(lat, lon, coord.y, coord.x); + if (distance < minDistance) { + minDistance = distance; + closestArea = etOperatingArea; + } } } + }else{ + log.info("运营区【{}】没有边界",etOperatingArea.getAreaName()); } } }else{ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java index d5e8ecb..bf3ce23 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/EtOrderServiceImpl.java @@ -3,24 +3,25 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.IotConstants; import com.ruoyi.common.constant.ServiceConstants; import com.ruoyi.common.core.domain.entity.AsUser; import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CommonUtil; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.onenet.ResponseVo; import com.ruoyi.common.utils.onenet.Token; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.vo.*; -import com.ruoyi.system.mapper.AsDeviceMapper; -import com.ruoyi.system.mapper.EtOperatingAreaMapper; -import com.ruoyi.system.mapper.EtOrderMapper; -import com.ruoyi.system.mapper.EtRefundMapper; +import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.*; import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse; import com.wechat.pay.java.service.refund.model.Refund; @@ -29,11 +30,8 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; -import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.web.bind.annotation.RequestBody; @@ -62,6 +60,9 @@ public class EtOrderServiceImpl implements IEtOrderService @Resource private IAsUserService asUserService; + @Resource + private AsUserMapper asUserMapper; + @Autowired private IEtOperatingAreaService etOperatingAreaService; @@ -92,8 +93,8 @@ public class EtOrderServiceImpl implements IEtOrderService @Autowired private CallbackService callbackService; -// @Value("${et.handlingCharge}") -// private String handlingCharge; + @Autowired + private ISysDeptService deptService; @Resource private EtRefundMapper etRefundMapper; @@ -101,6 +102,21 @@ public class EtOrderServiceImpl implements IEtOrderService @Autowired private TransactionTemplate transactionTemplate; + @Resource + private IEtModelService etModelService; + + @Autowired + private IEtCapitalFlowService etCapitalFlowService; + + @Resource + private EtFaultMapper etFaultMapper; + + @Autowired + private EtAdminOrderMapper etAdminOrderMapper; + + @Autowired + private EtCapitalFlowMapper etCapitalFlowMapper; + /** * 查询订单 * @@ -537,6 +553,198 @@ public class EtOrderServiceImpl implements IEtOrderService throw new ServiceException("押金充值记录不存在"); } + /** + * 首页统计-运营商 + */ + @Override + public IndexVo statistics(Long areaId) { + /** 首页数据*/ + SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId); + IndexVo indexVo = createIndexVo(areaId,sysDept); + + /** 营收统计*/ + ArrayList incomeVos = new ArrayList<>(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtils.getNowDate()); + + for (int i = 0; i < 13; i++) { + String formattedDate = dateFormat.format(calendar.getTime()); + String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND; + String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND; + IndexVo.OrderFeeStatisticsVo todayOrderInfo = getOrderFeeStatistics(startDateStr, endDateStr, areaId,sysDept); + log.info("【首页统计】营收统计----------todayOrderInfo: {}" , JSON.toJSON(todayOrderInfo)); + IndexVo.IncomeVo incomeVo = new IndexVo.IncomeVo(); + incomeVo.setDay(formattedDate); + incomeVo.setOrderNum(todayOrderInfo.getOrderCount()); + incomeVo.setIncome(todayOrderInfo.getIncomeFee()); + incomeVos.add(incomeVo); + calendar.add(Calendar.DATE, -1); + } + + indexVo.setIncomeVoList(incomeVos); + + /** 车辆统计*/ + IndexVo.VehicleVo vehicleVo = new IndexVo.VehicleVo(); + DeviceNumVo deviceNumVo = asDeviceService.allVehicleNum("0","100",areaId+""); + com.ruoyi.common.utils.bean.BeanUtils.copyBeanProp(vehicleVo,deviceNumVo); + indexVo.setVehicleVo(vehicleVo); + + /** 运维统计*/ + IndexVo.OperationVo operationVo = new IndexVo.OperationVo(); + + operationVo.setReplacementOrderCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPLACEMENT,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_UNDER_WAY,areaId)); + operationVo.setCompletedReplacementOrderCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPLACEMENT,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_COMPLETED,areaId)); + + operationVo.setDispatchCount(0);// 暂时没有调度工单 + operationVo.setCompletedDispatchCount(0);// 暂时没有调度工单 + + operationVo.setRepairCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPAIR,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_REPAIR,areaId)); + operationVo.setCompletedRepairCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPAIR,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_COMPLETED,areaId)); + indexVo.setOperationVo(operationVo); + log.info("【首页统计】indexVo==={}",JSON.toJSON(indexVo)); + return indexVo; + } + + private IndexVo createIndexVo(Long areaId,SysDept sysDept) { + IndexVo indexVo = new IndexVo(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtils.getNowDate()); + String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime()); + String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND; + String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND; + + indexVo.setBalance(sysDept.getBalance());//余额 + BigDecimal withdrawFee = etCapitalFlowService.getWithdrawnFee(areaId,ServiceConstants.FLOW_STATUS_COMPLETE); + BigDecimal applyFee = etCapitalFlowService.getWithdrawnFee(areaId,ServiceConstants.FLOW_STATUS_APPLY); + indexVo.setWithdraw(defaultIfNull(withdrawFee, BigDecimal.ZERO));//已提现 + indexVo.setSettlementAmount(defaultIfNull(applyFee, BigDecimal.ZERO));//待结算金额 + + IndexVo.OrderFeeStatisticsVo todayOrderInfo = getOrderFeeStatistics(startDateStr, endDateStr, areaId,sysDept); + indexVo.setTodayIncome(todayOrderInfo.getIncomeFee());//今日营收 + indexVo.setTodayOrderFee(todayOrderInfo.getOrderFee());//今日订单金额 + indexVo.setTodayOrderCount(todayOrderInfo.getOrderCount());//今日订单数 + + IndexVo.OrderFeeStatisticsVo totalOrderInfo = getOrderFeeStatistics(null, null, areaId,sysDept); + indexVo.setTotalIncome(totalOrderInfo.getIncomeFee());//总营收 + indexVo.setTotalOrderFee(totalOrderInfo.getOrderFee());//总订单金额 + indexVo.setTotalOrderCount(totalOrderInfo.getOrderCount());//总订单数 + + indexVo.setUnpaidOrderCount(Integer.parseInt(etOrderMapper.getUnpaidOrder(null,null,areaId+"")));//待付款订单数 + indexVo.setUnpaidOrderFee(new BigDecimal(etOrderMapper.getTotalUnpaid(null,null,areaId+"")));//待付款订单金额 + indexVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum(null,null,areaId+""));//还车待审核订单 + indexVo.setRidingOrder(Integer.parseInt(etOrderMapper.getRidingOrder(null,null,areaId+"")));//骑行中订单 + indexVo.setTodayRefundFee(new BigDecimal(etOrderMapper.getTotalRefund(startDateStr,endDateStr,areaId+"")));// 今日退款金额 + indexVo.setFaultOrderCount(etFaultMapper.getAuditFaultNum(areaId));//待审核故障数量 + return indexVo; + } + + /** + * 订单信息统计 + */ + private IndexVo.OrderFeeStatisticsVo getOrderFeeStatistics(String startDateStr, String endDateStr, Long areaId,SysDept sysDept) { + IndexVo.OrderFeeStatisticsVo feeStatisticsVo = new IndexVo.OrderFeeStatisticsVo(); + String handlingCharge = sysDept.getHandlingCharge(); + BigDecimal payFee = defaultIfNull(etOrderMapper.getPayFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//新增 + BigDecimal refundFee = defaultIfNull(etOrderMapper.getRefundFee(startDateStr, endDateStr, null, areaId), BigDecimal.ZERO);//退款 + BigDecimal divide = new BigDecimal(handlingCharge).divide(new BigDecimal(1000), 4, RoundingMode.HALF_UP); + BigDecimal serviceFee = payFee.multiply(divide).setScale(2, RoundingMode.HALF_UP);//手续费 + BigDecimal incomeFee = defaultIfNull(payFee.subtract(serviceFee).subtract(refundFee), BigDecimal.ZERO);//营收 = 支付金额 - 手续费 - 退款金额 + int orderCount = etOrderMapper.getOrderNum(startDateStr, endDateStr, areaId); + feeStatisticsVo.setOrderFee(payFee); + feeStatisticsVo.setIncomeFee(incomeFee); + feeStatisticsVo.setOrderCount(orderCount); + return feeStatisticsVo; + } + + /** + * 首页统计-总管理 + */ + @Override + public IndexAdminVo admimStatistics() { + /** 首页数据*/ + IndexAdminVo indexAdminVo = createIndexAdminVo(); + + /** 营收统计*/ + ArrayList incomeVos = new ArrayList<>(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtils.getNowDate()); + + for (int i = 0; i < 13; i++) { + String formattedDate = dateFormat.format(calendar.getTime()); + String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND; + String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND; + int orderCount = etOrderMapper.getOrderNum(startDateStr, endDateStr, null); + IndexAdminVo.IncomeVo incomeVo = new IndexAdminVo.IncomeVo(); + incomeVo.setDay(formattedDate); + incomeVo.setOrderNum(orderCount); + incomeVo.setOrderFee(etOrderMapper.getOrderFee(startDateStr, endDateStr, null)); + incomeVos.add(incomeVo); + calendar.add(Calendar.DATE, -1); + } + indexAdminVo.setIncomeVoList(incomeVos); + + /** 车辆统计*/ + IndexAdminVo.VehicleVo vehicleVo = new IndexAdminVo.VehicleVo(); + DeviceNumVo deviceNumVo = asDeviceService.allVehicleNum("0","100",null); + com.ruoyi.common.utils.bean.BeanUtils.copyBeanProp(vehicleVo,deviceNumVo); + indexAdminVo.setVehicleVo(vehicleVo); + + /** 运维统计*/ + IndexAdminVo.OperationVo operationVo = new IndexAdminVo.OperationVo(); + operationVo.setReplacementOrderCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPLACEMENT,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_UNDER_WAY,null)); + operationVo.setRepairCount(etAdminOrderMapper.getOrderCount(ServiceConstants.ADMIN_ORDER_TYPE_REPAIR,ServiceConstants.REPLACEMENT_ELECTRICITY_STATUS_REPAIR,null)); + indexAdminVo.setOperationVo(operationVo); + log.info("【首页统计-总管理】indexAdminVo==={}",JSON.toJSON(indexAdminVo)); + + return indexAdminVo; + } + + private IndexAdminVo createIndexAdminVo() { + IndexAdminVo indexAdminVo = new IndexAdminVo(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtils.getNowDate()); + String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime()); + String startDateStr = formattedDate + " " + Constants.DATE_FORMAT_START_PEREND; + String endDateStr = formattedDate + " " + Constants.DATE_FORMAT_END_PEREND; + + indexAdminVo.setOperatorCount(deptService.selectAllCount());// 运营商数 + indexAdminVo.setAppCount(deptService.getAppCount());// 独立小程序 + + indexAdminVo.setTotalBalance(deptService.selectAllBalance());//商户总余额 + BigDecimal withdrawFee = etCapitalFlowService.getWithdrawnFee(null,ServiceConstants.FLOW_STATUS_COMPLETE); + indexAdminVo.setWithdrawn(defaultIfNull(withdrawFee, BigDecimal.ZERO));//已提现金额 + + indexAdminVo.setAreaCount(etOperatingAreaService.count());//运营区数 + indexAdminVo.setModelCount(etModelService.selectAllCount());//车辆型号数 + indexAdminVo.setUserCount(asUserMapper.selectAllCount(null,null));//用户总数 + indexAdminVo.setTodayUserCount(asUserMapper.selectAllCount(startDateStr,endDateStr));//今日新增 + + indexAdminVo.setTodayOrderCount(etOrderMapper.getOrderNum(startDateStr, endDateStr, null));//今日订单数 + indexAdminVo.setTodayOrderFee(etOrderMapper.getPayFee(startDateStr, endDateStr, null, null));//今日订单金额 + + indexAdminVo.setTodayOrderCount(etOrderMapper.getOrderNum(null, null, null));//总订单数 + indexAdminVo.setTodayOrderFee(etOrderMapper.getPayFee(null, null, null, null));//总订单金额 + + indexAdminVo.setTodayRefundFee(new BigDecimal(etOrderMapper.getTotalRefund(startDateStr,endDateStr,null)));// 今日退款金额 + indexAdminVo.setTodayRefundFee(new BigDecimal(etOrderMapper.getTotalRefund(null,null,null)));// 总退款金额 + + indexAdminVo.setUnpaidOrderCount(Integer.parseInt(etOrderMapper.getUnpaidOrder(null,null,null)));//待付款订单数 + indexAdminVo.setUnpaidOrderFee(new BigDecimal(etOrderMapper.getTotalUnpaid(null,null,null)));//待付款订单金额 + + indexAdminVo.setReturnOrderCount(etOrderMapper.getAuditOrderNum(null,null,null));//还车待审核订单 + indexAdminVo.setReturnOrderDeductFee(etOrderMapper.getReturnOrderDeductFee(null,null,null));// 待审核还车押金扣款 + + indexAdminVo.setTodayHandlingFee(etCapitalFlowMapper.getHandlingFee(startDateStr, endDateStr, null));// 今日支付手续费 + indexAdminVo.setTotalHandlingFee(etCapitalFlowMapper.getHandlingFee(null, null, null));// 总手续费 + + indexAdminVo.setTodayServiceFee(etCapitalFlowMapper.getServiceFee(startDateStr, endDateStr, null));//今日服务费 + indexAdminVo.setTotalServiceFee(etCapitalFlowMapper.getServiceFee(null, null, null));// 总服务费 + + return indexAdminVo; + } + private boolean toBePaid(String[] statusList) { boolean hasOne = false; boolean hasThree = false; @@ -1270,7 +1478,7 @@ public class EtOrderServiceImpl implements IEtOrderService @Override @Transactional @SneakyThrows - public Boolean changeVehicleLock(String orderNo,String changeReason) { + public Boolean changeVehicleLock(String orderNo,String changeReason,String isBluetooth,String lon,String lat,String voltage) { EtOrder order = etOrderMapper.selectEtOrderByOrderNo(orderNo); if(!ServiceConstants.ORDER_STATUS_RIDING.equals(order.getStatus())){ throw new ServiceException("该订单状态非骑行中"); @@ -1279,7 +1487,29 @@ public class EtOrderServiceImpl implements IEtOrderService if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空"); AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); /** 2.发送命令*/ - asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"换车关锁",order.getOrderNo(),order.getUserName()); + if(!"true".equals(isBluetooth)){ + ResponseVo responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "换车关锁",orderNo); + if(responseVo.getCode()!=0){ + log.info("【还车关锁】远程关锁失败"); + throw new ServiceException("远程关锁失败"); + } + }else{ + asDevice.setLongitude(lon); + asDevice.setLatitude(lat); + if(StrUtil.isNotBlank(voltage)){ + BigDecimal divide = new BigDecimal(voltage).divide(new BigDecimal(10)); + asDevice.setVoltage(divide.toString()); + EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId()); + Integer remainingMileage = 0; + if(StrUtil.isNotBlank(asDevice.getVoltage())){ + remainingMileage = CommonUtil.getRemainingMileage(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + } + Integer electricQuantity = CommonUtil.getElectricQuantity(asDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 + asDevice.setRemainingMileage(remainingMileage); + asDevice.setRemainingPower(electricQuantity.toString()); + } + asDevice.setLastTime(DateUtils.getNowDate()); + } asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL); asDevice.setIsAdminUnlocking("0"); @@ -1313,7 +1543,7 @@ public class EtOrderServiceImpl implements IEtOrderService @SneakyThrows @Override @Transactional - public Boolean changeVehicleLockUnlocking(String orderNo, String newSn) { + public Boolean changeVehicleLockUnlocking(String orderNo, String newSn,String isBluetooth,String lon,String lat,String voltage) { EtOrder order = etOrderMapper.selectEtOrderByOrderNo(orderNo); if(!ServiceConstants.ORDER_STATUS_RIDING.equals(order.getStatus())){ throw new ServiceException("该订单状态非骑行中"); @@ -1326,7 +1556,29 @@ public class EtOrderServiceImpl implements IEtOrderService String token = Token.getToken(); Boolean execute = transactionTemplate.execute(e -> { /** 2.发送命令*/ - asDeviceService.sendCommand(newDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"换车开锁",order.getOrderNo(),order.getUserName()); + if(!"true".equals(isBluetooth)){ + ResponseVo responseVo = asDeviceService.sendCommandWithResp(newDevice.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "换车开锁",orderNo); + if(responseVo.getCode()!=0){ + log.info("【还车关锁】远程关锁失败"); + throw new ServiceException("远程关锁失败"); + } + }else{ + newDevice.setLongitude(lon); + newDevice.setLatitude(lat); + if(StrUtil.isNotBlank(voltage)){ + BigDecimal divide = new BigDecimal(voltage).divide(new BigDecimal(10)); + newDevice.setVoltage(divide.toString()); + EtModel model = etModelService.selectEtModelByModelId(newDevice.getModelId()); + Integer remainingMileage = 0; + if(StrUtil.isNotBlank(newDevice.getVoltage())){ + remainingMileage = CommonUtil.getRemainingMileage(newDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); + } + Integer electricQuantity = CommonUtil.getElectricQuantity(newDevice.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 + newDevice.setRemainingMileage(remainingMileage); + newDevice.setRemainingPower(electricQuantity.toString()); + } + newDevice.setLastTime(DateUtils.getNowDate()); + } newDevice.setIsAdminUnlocking("1"); newDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING); newDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index d7bbccb..bb8a77d 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -530,6 +530,21 @@ public class SysDeptServiceImpl implements ISysDeptService return i; } + @Override + public int selectAllCount() { + return deptMapper.selectAllCount(); + } + + @Override + public int getAppCount() { + return deptMapper.getAppCount(); + } + + @Override + public BigDecimal selectAllBalance() { + return deptMapper.selectAllBalance(); + } + /** * 递归列表 */ diff --git a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml index f804c2c..32edc40 100644 --- a/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/AsUserMapper.xml @@ -157,6 +157,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + insert into et_user( diff --git a/electripper-system/src/main/resources/mapper/system/EtAdminOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtAdminOrderMapper.xml index 46262ed..5986980 100644 --- a/electripper-system/src/main/resources/mapper/system/EtAdminOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtAdminOrderMapper.xml @@ -78,6 +78,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select count(1) from et_admin_order where sn = #{sn} + + insert into et_admin_order diff --git a/electripper-system/src/main/resources/mapper/system/EtAreaDeptMapper.xml b/electripper-system/src/main/resources/mapper/system/EtAreaDeptMapper.xml index 7a9aef0..8cca11b 100644 --- a/electripper-system/src/main/resources/mapper/system/EtAreaDeptMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtAreaDeptMapper.xml @@ -7,4 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from et_area_dept where dept_id=#{deptId} + + + delete from et_area_dept where area_id=#{areaId} + + diff --git a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml index af86102..c86ab88 100644 --- a/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtCapitalFlowMapper.xml @@ -90,6 +90,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where out_trade_no = #{outTradeNo} + + + + + + + insert into et_capital_flow diff --git a/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml b/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml index 6445ee0..2a1aaa6 100644 --- a/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtFaultMapper.xml @@ -14,17 +14,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select fault_id, area_id, user_id, device_mac, sn, type, create_time, picture, detail, order_id, status, address from et_fault + select fault_id, area_id, user_id, device_mac, sn, type, create_time, picture, detail, order_id, order_no, status, address from et_fault + select COALESCE(count(1), 0) from et_fault f + where f.status = '1' + and f.area_id = #{areaId} + diff --git a/electripper-system/src/main/resources/mapper/system/EtModelMapper.xml b/electripper-system/src/main/resources/mapper/system/EtModelMapper.xml index 79a7d79..a82aa14 100644 --- a/electripper-system/src/main/resources/mapper/system/EtModelMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtModelMapper.xml @@ -42,6 +42,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where model_id = #{modelId} + + insert into et_model diff --git a/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml index 5374e26..90d55b3 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOperatingAreaMapper.xml @@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select COALESCE(SUM(total_fee), 0) from et_order where status = 3 and type = 1 and paid = 0 - AND date_format(create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') - AND date_format(create_time,'%y%m%d') <= date_format(#{timeEnd},'%y%m%d') + + AND date_format(create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') + + + AND date_format(create_time,'%y%m%d') <= date_format(#{timeEnd},'%y%m%d') + and area_id = #{areaId} @@ -303,7 +307,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select COALESCE(count(1), 0) from et_order where status = 4 and type = 1 and paid = 1 AND date_format(create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') AND date_format(create_time,'%y%m%d') <= date_format(#{timeEnd},'%y%m%d') - and area_id = #{areaId} + and area_id = #{areaId} select COALESCE(count(1), 0) from et_order where status = 3 and type = 1 and paid = 0 - AND date_format(create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') - AND date_format(create_time,'%y%m%d') <= date_format(#{timeEnd},'%y%m%d') + + AND date_format(create_time,'%y%m%d') >= date_format(#{timeStart},'%y%m%d') + + + AND date_format(create_time,'%y%m%d') <= date_format(#{timeEnd},'%y%m%d') + + and area_id = #{areaId} + + + + + + + + + @@ -348,6 +391,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - - where d.del_flag = '0' + SELECT d.dept_id, d.parent_id, d.ancestors, d.dept_name, + d.order_num, d.leader, d.phone, d.email, d.status, + d.del_flag, d.platform_service_fee, d.handling_charge, d.is_profit_sharing, d.separate_account, d.domain, d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret, + d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path, d.merchant_serial_number, d.refund_notify_url, d.app_user_id, + u.user_name AS userName, + GROUP_CONCAT(oa.area_name SEPARATOR ' | ') AS areaName, + d.create_by, d.create_time + FROM sys_dept d + LEFT JOIN et_user u ON d.app_user_id = u.user_id + LEFT JOIN et_area_dept ad ON ad.dept_id = d.dept_id + LEFT JOIN et_operating_area oa ON oa.area_id = ad.area_id + WHERE d.del_flag = '0' AND d.parent_id != 0 - AND dept_id = #{deptId} + AND d.dept_id = #{deptId} - - AND parent_id = #{parentId} + + AND d.parent_id = #{parentId} - AND dept_name like concat('%', #{deptName}, '%') + AND d.dept_name LIKE CONCAT('%', #{deptName}, '%') + + + AND oa.area_name LIKE CONCAT('%', #{areaName}, '%') + + + AND u.user_name LIKE CONCAT('%', #{userName}, '%') - AND status = #{status} + AND d.status = #{status} ${params.dataScope} - order by d.parent_id, d.order_num - + GROUP BY d.dept_id + ORDER BY d.create_time DESC + + select count(1) from sys_dept where del_flag = '0' + + + + + + diff --git a/electripper-system/src/main/resources/mapper/system/SysUserMapper.xml b/electripper-system/src/main/resources/mapper/system/SysUserMapper.xml index 97d36a5..4dcc0ac 100644 --- a/electripper-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -53,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.area_id,u.dividend_proportion,u.dividend_item,u.app_user_id, u.cooperation_time,u.dividend_status, + select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.area_id,u.dividend_proportion,u.dividend_item,u.app_user_id, u.cooperation_time,u.dividend_status,u.balance, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,a.area_name areaName from sys_user u @@ -64,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"