From b046dacaa2aae5cb21587e52f957df6bf43c0963 Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Mon, 23 Oct 2023 17:52:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BD=A6=E7=89=8C=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/v2.2.sql | 21 +++- .../XhpcChargingStationPowerController.java | 2 +- .../xhpc/order/domain/XhpcRealTimeOrder.java | 24 ++++ .../order/mapper/XhpcChargeOrderMapper.java | 2 + .../order/mapper/XhpcRealTimeOrderMapper.java | 5 + .../impl/XhpcChargeOrderServiceImpl.java | 6 + .../impl/XhpcRealTimeOrderServiceImpl.java | 6 + .../mapper/XhpcChargeOrderMapper.xml | 7 ++ .../mapper/XhpcChargingStationPowerMapper.xml | 8 +- .../mapper/XhpcRealTimeOrderMapper.xml | 24 +++- .../xhpc/pp/controller/StationController.java | 1 + .../controller/XhpcAppUserController.java | 10 +- .../controller/XhpcUserVehicleConeroller.java | 40 ++++++ .../com/xhpc/user/domain/XhpcUserVehicle.java | 42 +++++++ .../user/mapper/XhpcUserVehicleMapper.java | 25 ++++ .../user/service/IXhpcUserVehicleService.java | 21 ++++ .../service/impl/XhpcAppUserServiceImpl.java | 5 + .../impl/XhpcUserVehicleServiceImpl.java | 76 +++++++++++ .../resources/mapper/XhpcCommonMapper.xml | 6 + .../mapper/XhpcUserVehicleMapper.xml | 118 ++++++++++++++++++ 20 files changed, 439 insertions(+), 10 deletions(-) create mode 100644 xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserVehicleConeroller.java create mode 100644 xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcUserVehicle.java create mode 100644 xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcUserVehicleMapper.java create mode 100644 xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcUserVehicleService.java create mode 100644 xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcUserVehicleServiceImpl.java create mode 100644 xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserVehicleMapper.xml diff --git a/sql/v2.2.sql b/sql/v2.2.sql index 40098fa3..b2b3ba3b 100644 --- a/sql/v2.2.sql +++ b/sql/v2.2.sql @@ -38,8 +38,8 @@ ALTER TABLE `xhpc_charging_station` ADD COLUMN `rated_power` DOUBLE(10,4) NULL DEFAULT NULL COMMENT '站点额定总功率' AFTER `business_expand_type`, ADD COLUMN `period_fee` INT(4) NULL DEFAULT NULL COMMENT '峰谷分时' AFTER `rated_power`, ADD COLUMN `official_run_time` VARCHAR(50) NULL DEFAULT NULL COMMENT '正式投运时间' AFTER `period_fee`, - ADD COLUMN `video_monitor` INT(4) NULL DEFAULT NULL COMMENT '视频监控配套情况' AFTER `official_run_time`; - + ADD COLUMN `video_monitor` INT(4) NULL DEFAULT NULL COMMENT '视频监控配套情况' AFTER `official_run_time`, + ADD COLUMN `barrier_gate_id` INT(4) NULL DEFAULT NULL COMMENT '道闸' AFTER `video_monitor`; ALTER TABLE `xhpc_charging_pile` ADD COLUMN `equipment_product_code` VARCHAR(30) NULL DEFAULT NULL COMMENT '设备出厂编码(由设备生厂商定义的设备出厂唯一编码)' AFTER `tenant_id`, @@ -85,3 +85,20 @@ CREATE TABLE `xhpc_equipment_accident` ( ALTER TABLE `xhpc_charging_station_power` ADD COLUMN `type` int(4) NULL DEFAULT '0' COMMENT '是否推送 0 未推送 1已推送' AFTER `installed_total_power`; + + +CREATE TABLE `xhpc_user_vehicle` ( + `vehicle_id` bigint(20) NOT NULL, + `app_user_id` bigint(20) DEFAULT NULL, + `vehicle_name` varchar(10) DEFAULT NULL COMMENT '车牌', + `type` int(4) DEFAULT NULL COMMENT '1.小型纯电车 2.小型混动电车 3.大型纯电车', + `del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)', + `create_by` varchar(64) DEFAULT '' COMMENT '创建者', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(64) DEFAULT '' COMMENT '更新者', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `remark` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '备注', + `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户id', + PRIMARY KEY (`vehicle_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车牌'; + diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcChargingStationPowerController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcChargingStationPowerController.java index 6e95d765..931d15fc 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcChargingStationPowerController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcChargingStationPowerController.java @@ -32,7 +32,7 @@ public class XhpcChargingStationPowerController extends BaseController { private IXhpcChargingStationPowerService xhpcChargingStationPowerService; @GetMapping("/test1") - @Scheduled(cron = "0 0/5 0/1 * * ? ") + @Scheduled(cron = "0 0/3 0/1 * * ? ") public void test1(){ xhpcChargingStationPowerService.addChargingStationPower(); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java index b58c1b16..ac40ee1c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcRealTimeOrder.java @@ -108,6 +108,14 @@ public class XhpcRealTimeOrder extends BaseEntity { * 场站id */ private Long chargingStationId; + /** + * 电桩id + */ + private Long chargingPileId; + /** + * 终端id + */ + private Long terminalId; /** * 订单来源(0 C端用户 1 流量方用户 2社区用户 3B端用户) @@ -363,4 +371,20 @@ public class XhpcRealTimeOrder extends BaseEntity { public void setSource(Integer source) { this.source = source; } + + public Long getChargingPileId() { + return chargingPileId; + } + + public void setChargingPileId(Long chargingPileId) { + this.chargingPileId = chargingPileId; + } + + public Long getTerminalId() { + return terminalId; + } + + public void setTerminalId(Long terminalId) { + this.terminalId = terminalId; + } } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index 7f320762..24110331 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -134,6 +134,8 @@ public interface XhpcChargeOrderMapper { */ Map getOperatorMessage(@Param("chargingStationId") Long chargingStationId); + Map getXhpcUserVehicleMessage(@Param("userId")Long userId,@Param("source")Integer source); + //获取桩信息 Map getXhpcChargingPileById(@Param("chargingPileid") Long chargingPileid,@Param("tenantId")String tenantId); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java index d4b1cad3..90b5c82c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java @@ -1,5 +1,6 @@ package com.xhpc.order.mapper; +import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.order.domain.*; import com.xhpc.order.dto.RateTime; import com.xhpc.order.dto.XhpcActivityDiscountDto; @@ -201,4 +202,8 @@ public interface XhpcRealTimeOrderMapper { void deleteRealTimeOrderBms(@Param("time")String time); + + //获取桩id + XhpcChargingPile getSerialNumber(@Param("serialNumber")String serialNumber); + } 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 1f18d51a..420580f4 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 @@ -317,6 +317,12 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar } xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime()); xhpcChargeOrder.setType("91"); + + //获取车牌 + Map xhpcUserVehicleMessage = xhpcChargeOrderMapper.getXhpcUserVehicleMessage(xhpcChargeOrder.getUserId(), xhpcChargeOrder.getSource()); + if(xhpcUserVehicleMessage !=null && xhpcUserVehicleMessage.get("vehicleName") !=null){ + xhpcChargeOrder.setPlateNum(xhpcUserVehicleMessage.get("vehicleName").toString()); + } xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder); executorService.execute(new Runnable() { 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 e15b6ecf..b572c89f 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 @@ -17,6 +17,7 @@ import com.xhpc.common.core.web.service.BaseService; import com.xhpc.common.data.redis.CacheBmsReqChargerOutputData; import com.xhpc.common.data.redis.CacheOrderData; import com.xhpc.common.data.redis.CacheRealtimeData; +import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.common.domain.XhpcRate; import com.xhpc.common.enums.StopReasonEnum; import com.xhpc.common.redis.service.RedisService; @@ -1552,6 +1553,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe Long chargingStationId = xhpcChargeOrder.getChargingStationId(); xhpcRealTimeOrder.setChargingStationId(chargingStationId); xhpcRealTimeOrder.setChargingTimeNumber(cacheRealtimeData.getChargingTime()); + + XhpcChargingPile xhpcChargingPiles = xhpcRealTimeOrderMapper.getSerialNumber(xhpcChargeOrder.getSerialNumber().substring(0, 14)); + + xhpcRealTimeOrder.setChargingPileId(xhpcChargingPiles.getChargingPileId()); + xhpcRealTimeOrder.setTerminalId(xhpcChargeOrder.getTerminalId()); addXhpcRealTimeOrder(xhpcRealTimeOrder); //实时数据存入MYsql、soc、电流、电压 diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 6bcc17f8..40f1c6f2 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -438,6 +438,13 @@ where operator_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId}) + + select + charging_pile_id as chargingPileId, + charging_station_id as chargingStationId + from xhpc_charging_pile where serial_number =#{serialNumber} + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java index 2ec3ae22..9aff6209 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java @@ -40,6 +40,7 @@ public class StationController { public void addNotificationStationInfo(@RequestParam("stationId")Long stationId){ CDStationInfo xhpcChargingStation = deviceMessageMapper.getXhpcChargingStation(stationId); if(xhpcChargingStation !=null){ + System.out.println("=================生成场站推送数据信息==================="); //场站信息入缓存 String skey = "cdjgpc:station:".concat(stationId.toString())+".notification"; REDIS.deleteObject(skey); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index bc8c3473..937e8a36 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -22,6 +22,7 @@ import com.xhpc.common.log.annotation.Log; import com.xhpc.common.log.enums.BusinessType; import com.xhpc.common.redis.service.RedisService; import com.xhpc.user.service.IXhpcAppUserUserService; +import com.xhpc.user.service.IXhpcUserVehicleService; import com.xhpc.user.util.WechatDecryptDataUtil; import io.swagger.annotations.ApiOperation; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -30,6 +31,7 @@ import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; @@ -61,6 +63,8 @@ public class XhpcAppUserController extends BaseController { private Environment environment; @Autowired private RedisService redisService; + @Resource + private IXhpcUserVehicleService xhpcUserVehicleService; /** * C端用户详情 @@ -586,6 +590,10 @@ public class XhpcAppUserController extends BaseController { } - + //获取用户车牌号 + @GetMapping("/getXhpcUserVehicleMessage") + public R getXhpcUserVehicleMessage(Long userId, Integer source){ + return xhpcUserVehicleService.getXhpcUserVehicleMessage(userId, source); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserVehicleConeroller.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserVehicleConeroller.java new file mode 100644 index 00000000..b437acf1 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcUserVehicleConeroller.java @@ -0,0 +1,40 @@ +package com.xhpc.user.controller; + +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.user.domain.XhpcUserVehicle; +import com.xhpc.user.service.IXhpcUserVehicleService; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2023-10-19 17:26 + */ +@RestController +@RequestMapping("/xhpc/userVehicle") +public class XhpcUserVehicleConeroller extends BaseController { + + + @Resource + IXhpcUserVehicleService xhpcUserVehicleService; + + @ApiOperation("添加车牌号") + @PostMapping("/addUserVehicle") + public R addUserVehicle(@RequestBody XhpcUserVehicle xhpcUserVehicle){ + return xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle); + } + + @GetMapping("/list") + public TableDataInfo list(HttpServletRequest request, String vehicleName, String phone,String chargingStationName) { + List> list = xhpcUserVehicleService.list(request,vehicleName,phone,chargingStationName); + return getDataTable(list); + } + +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcUserVehicle.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcUserVehicle.java new file mode 100644 index 00000000..1eebae25 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcUserVehicle.java @@ -0,0 +1,42 @@ +package com.xhpc.user.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +/** + * @author yuyang + * @date 2023-10-19 16:41 + */ +@Data +public class XhpcUserVehicle extends BaseEntity { + /** + * 车辆id + */ + private Long vehicleId; + /** + * 用户id + */ + private Long appUserId; + + private Long chargingStationId; + + private Integer source; + /** + * 车牌 + */ + @Length(max = 10, message = "车牌不能超过10位") + private String vehicleName; + /** + * 1.小型纯电车 2.小型混动电车 3.大型纯电车 + */ + private Integer type; + /** + * 删除标志(0代表存在 2代表删除) + */ + private String delFlag; + + + private String tenantId; + +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcUserVehicleMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcUserVehicleMapper.java new file mode 100644 index 00000000..7414da43 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcUserVehicleMapper.java @@ -0,0 +1,25 @@ +package com.xhpc.user.mapper; + +import com.xhpc.user.domain.XhpcUserVehicle; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2023-10-19 17:08 + */ +public interface XhpcUserVehicleMapper { + + + void deleteUserVehicle(@Param("userId") Long userId,@Param("vehicleId") Long vehicleId); + + void addUserVehicle(XhpcUserVehicle xhpcUserVehicle); + + void updateUserVehicle(XhpcUserVehicle xhpcUserVehicle); + + List> list(@Param("vehicleName") String vehicleName,@Param("phone") String phone,@Param("chargingStationName")String chargingStationName,@Param("logOperatorId")Long logOperatorId,@Param("type")Integer type,@Param("tenantId")String tenantId); + + Map getXhpcUserVehicleMessage(@Param("userId") Long userId,@Param("source") Integer source); +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcUserVehicleService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcUserVehicleService.java new file mode 100644 index 00000000..72d32afb --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcUserVehicleService.java @@ -0,0 +1,21 @@ +package com.xhpc.user.service; + +import com.xhpc.common.core.domain.R; +import com.xhpc.user.domain.XhpcUserVehicle; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2023-10-19 17:05 + */ +public interface IXhpcUserVehicleService { + + R addUserVehicle(XhpcUserVehicle xhpcUserVehicle); + + List> list(HttpServletRequest request,String vehicleName,String phone,String chargingStationName); + + R getXhpcUserVehicleMessage(Long userId,Integer source); +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index d0632cd3..bf7558a8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -483,6 +483,11 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU R user = xhpcCommonController.getMechanism(null, userid, userType, null, tenantId); if(user !=null && user.getData() !=null){ Map map = (Map)user.getData(); + if(map.get("vehicleName") !=null){ + map.put("vehicleType",1); + }else{ + map.put("vehicleType",0); + } //发票、留言板、版本、客服电话 // Long invoice =null; // String globalInvoice="global:invoice:"+ tenantId +":"; diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcUserVehicleServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcUserVehicleServiceImpl.java new file mode 100644 index 00000000..9ac7eca8 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcUserVehicleServiceImpl.java @@ -0,0 +1,76 @@ +package com.xhpc.user.service.impl; + +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.web.service.BaseService; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.system.api.domain.SysUser; +import com.xhpc.system.api.model.LoginUser; +import com.xhpc.user.domain.XhpcUserVehicle; +import com.xhpc.user.mapper.XhpcUserVehicleMapper; +import com.xhpc.user.service.IXhpcUserVehicleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +/** + * @author yuyang + * @date 2023-10-19 17:06 + */ +@Service +public class XhpcUserVehicleServiceImpl extends BaseService implements IXhpcUserVehicleService { + + @Resource + XhpcUserVehicleMapper xhpcUserVehicleMapper; + @Resource + TokenService tokenService; + + @Override + public R addUserVehicle(XhpcUserVehicle xhpcUserVehicle) { + //标记该用户其他车牌号为空 + xhpcUserVehicleMapper.deleteUserVehicle(xhpcUserVehicle.getAppUserId(),xhpcUserVehicle.getVehicleId()); + if(xhpcUserVehicle.getVehicleId() !=null){ + xhpcUserVehicleMapper.addUserVehicle(xhpcUserVehicle); + }else{ + xhpcUserVehicleMapper.updateUserVehicle(xhpcUserVehicle); + } + return R.ok(); + } + + @Override + public List> list(HttpServletRequest request, String vehicleName,String phone,String chargingStationName) { + + //获取登陆用户 + LoginUser loginUser = tokenService.getLoginUser(request); + SysUser sysUser = loginUser.getSysUser(); + Long sysUserId = sysUser.getUserId(); + String tenantId = loginUser.getTenantId(); + //桩的统计、该时段金额 + List> list =new ArrayList<>(); + if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){ + if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){ + Long logOperatorId = sysUser.getOperatorId(); + //运营商看自己的场站 + list = xhpcUserVehicleMapper.list(vehicleName,phone,chargingStationName,logOperatorId,1,tenantId); + }else{ + //查询赋值的场站 + list = xhpcUserVehicleMapper.list(vehicleName,phone,chargingStationName,sysUserId,2,tenantId); + } + }else{ + startPage(); + list = xhpcUserVehicleMapper.list(vehicleName,phone,chargingStationName,sysUserId,0,tenantId); + } + + return list; + } + + @Override + public R getXhpcUserVehicleMessage(Long userId, Integer source) { + return R.ok(xhpcUserVehicleMapper.getXhpcUserVehicleMessage(userId,source)); + } +} diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index 03f0f149..596ff88b 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -28,9 +28,11 @@ xau.tenant_id tenantId, xau.soc_protect socProtect, ten.status tenantStatus, + xuv.vehicle_name as vehicleName, xau.create_time as createTime from xhpc_app_user xau left join xhpc_tenant ten on ten.tenant_id = xau.tenant_id and ten.is_deleted =0 + left join xhpc_user_vehicle xuv on xuv.app_user_id = xau.app_user_id and xuv.source=0 and xuv.del_flag=0 where xau.del_flag=0 and xau.phone =#{phone} @@ -64,12 +66,14 @@ xcp.soc_protect socProtect, ten.status tenantStatus, concat("ST") as userTypeName, + xuv.vehicle_name as vehicleName, (select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, xcp.create_time as createTime from xhpc_community_personnel xcp left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0 + left join xhpc_user_vehicle xuv on xuv.app_user_id = xcp.community_personnel_id and xuv.source=2 and xuv.del_flag=0 where xcp.del_flag=0 and xcp.account =#{phone} @@ -103,12 +107,14 @@ xcp.soc_protect socProtect, ten.status tenantStatus, concat("BE") as userTypeName, + xuv.vehicle_name as vehicleName, (select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, xcp.create_time as createTime from xhpc_customers_personnel xcp left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0 + left join xhpc_user_vehicle xuv on xuv.app_user_id = xcp.customers_personnel_id and xuv.source=3 and xuv.del_flag=0 where xcp.del_flag=0 and xcp.account =#{phone} diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserVehicleMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserVehicleMapper.xml new file mode 100644 index 00000000..299da382 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserVehicleMapper.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + update xhpc_user_vehicle set del_flag =1 where app_user_id=#{userId} + + and vehicle_id !=#{vehicleId} + + + + + + + UPDATE xhpc_user_vehicle + + vehicle_id = #{appUserId}, + vehicle_name = #{vehicleName}, + type = #{type}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark} + + WHERE vehicle_id = #{vehicleId} + + + + insert into xhpc_user_vehicle( + app_user_id, + vehicle_name, + type, + del_flag, + create_by, + create_time, + update_by, + update_time, + remark, + tenant_id, + )values( + #{appUserId}, + #{vehicleName}, + #{type}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{tenantId}, + ) + + + +