From 88e762c926170f8ec7e5a4b250139354b98be160 Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 22 Dec 2021 12:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=81=E9=87=8F=E6=96=B9?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AE=A1=E6=A0=B8=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/XhpcRealTimeOrderServiceImpl.java | 17 ++--- .../controller/XhpcCommunityController.java | 19 +++++- .../xhpc/user/mapper/XhpcCommunityMapper.java | 16 +++++ .../xhpc/user/service/IMechanismService.java | 3 +- .../user/service/IXhpcCommunityService.java | 15 +++++ .../service/impl/IMechanismServiceImpl.java | 5 +- .../impl/XhpcCommunityServiceImpl.java | 37 ++++++++++- .../resources/mapper/XhpcCommunityMapper.xml | 62 ++++++++++++++++++- 8 files changed, 156 insertions(+), 18 deletions(-) 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 e1152979..77e06488 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 @@ -294,17 +294,18 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { xhpcChargeOrder.setAmountCharged(money); Long userId = xhpcChargeOrder.getUserId(); Map userMessage = xhpcChargeOrderService.getUserMessage(userId); - if (userMessage == null || userMessage.get("balance") == null) { - //订单异常 - xhpcChargeOrder.setStatus(2); - //异常原因 - xhpcChargeOrder.setErroRemark("用户id:" + userId + "为空"); - xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); - return AjaxResult.error("用户id:" + userId + "为空"); + if(xhpcChargeOrder.getInternetSerialNumber() ==null && xhpcChargeOrder.getStatus()==0){ + if (userMessage == null || userMessage.get("balance") == null) { + //订单异常 + xhpcChargeOrder.setStatus(2); + //异常原因 + xhpcChargeOrder.setErroRemark("用户id:" + userId + "为空"); + xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); + return AjaxResult.error("用户id:" + userId + "为空"); + } } //生成一条历史订单 XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder(); - xhpcHistoryOrder.setEndTime(xhpcChargeOrder.getEndTime()); xhpcHistoryOrder.setStartSoc(xhpcChargeOrder.getStartSoc()); xhpcHistoryOrder.setEndSoc(xhpcChargeOrder.getEndSoc()); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java index 11d1f2c5..b0eadbe0 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java @@ -56,6 +56,23 @@ public class XhpcCommunityController extends BaseController { return AjaxResult.success(); } + /** + * 查询社区组 + */ + @PostMapping(value = "/getCommunityById") + public AjaxResult getCommunityById(@RequestBody XhpcCommunity xhpcCommunity) { + return AjaxResult.success(xhpcCommunityService.getCommunityById(xhpcCommunity)); + } + + /** + * 编辑社区组树 + * + * @return + */ + @PostMapping(value = "/updateCommunity") + public AjaxResult updateCommunity(@RequestBody XhpcCommunity xhpcCommunity) { + return xhpcCommunityService.updateCommunity(xhpcCommunity); + } /** * 数据维度 @@ -64,7 +81,7 @@ public class XhpcCommunityController extends BaseController { */ @GetMapping(value = "/getMechanism") public AjaxResult getMechanism(@RequestParam(value = "status")Integer status) { - List mechanismDtos = mechanismService.dataList(1L, status); + List mechanismDtos = mechanismService.dataList(status); return AjaxResult.success(mechanismDtos); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java index 8c48cc77..39623352 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java @@ -33,6 +33,12 @@ public interface XhpcCommunityMapper { */ int addCommunity(XhpcCommunity xhpcCommunity); + /** + * 修改社区组 + * @param xhpcCommunity + * @return + */ + int updateCommunity(XhpcCommunity xhpcCommunity); /** * 社区社区组 * @param communityId @@ -43,4 +49,14 @@ public interface XhpcCommunityMapper { * 检查改组是否还存在社区人员 */ int countCommunityPersonnel(@Param("communityId")Long communityId); + + + /** + * 查询社区组 + * @param communityId 社区id + * @param name 名称 + * @param type 1 表示已社区id进行查询 2 排查社区id查询 + * @return + */ + Map getCommunityById(@Param("communityId")Long communityId,@Param("name")String name,@Param("type")Integer type); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java index 4147397d..5a313199 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IMechanismService.java @@ -14,8 +14,7 @@ public interface IMechanismService { /** * 用户拥有数据权限 * - * @param userId 用户id * @return 结果 */ - public List dataList(Long userId, Integer status); + public List dataList(Integer status); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java index 14f7ae7e..9bd87701 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java @@ -33,4 +33,19 @@ public interface IXhpcCommunityService { * 删除社区组树 */ void deleteCommunity(XhpcCommunity xhpcCommunity); + + /** + * 编辑社区组树 + * + * @param + * @return + */ + AjaxResult updateCommunity(XhpcCommunity xhpcCommunity); + /** + * 查询社区组 + * + * @return + */ + Map getCommunityById(XhpcCommunity xhpcCommunity); + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java index 539839e6..2760b47e 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/IMechanismServiceImpl.java @@ -23,10 +23,9 @@ public class IMechanismServiceImpl implements IMechanismService { @Autowired private MechanismMapper mechanismMapper; @Override - public List dataList(Long userId, Integer status) { + public List dataList(Integer status) { //获取登陆用户 - //Long logUserId = SecurityUtils.getUserId(); - Long logUserId = 1L; + Long logUserId = SecurityUtils.getUserId(); int type =1; //根据权限获取场站 if(logUserId !=1){ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index 85bb1c8c..105d966b 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -41,13 +41,21 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { @Override public AjaxResult addCommunity(XhpcCommunity xhpcCommunity) { + //名称重复不能入库 + Map communityById = xhpcCommunityMapper.getCommunityById(null, xhpcCommunity.getName(), null); + if(communityById !=null){ + return AjaxResult.error("社区名称重复"); + } + String chargingStationIds = xhpcCommunity.getChargingStationIds(); if("".equals(chargingStationIds) || chargingStationIds ==null){ xhpcCommunity.setStatus(0); + }else{ + xhpcCommunity.setStatus(1); } xhpcCommunityMapper.addCommunity(xhpcCommunity); if(!"".equals(chargingStationIds) && chargingStationIds !=null){ - xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),1); + xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); } return AjaxResult.success(); } @@ -61,4 +69,31 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { } } } + + @Override + public AjaxResult updateCommunity(XhpcCommunity xhpcCommunity) { + //名称重复不能入库 + Map communityById = xhpcCommunityMapper.getCommunityById(xhpcCommunity.getCommunityId(), xhpcCommunity.getName(), 2); + if(communityById !=null){ + return AjaxResult.error("社区名称重复"); + } + + String chargingStationIds = xhpcCommunity.getChargingStationIds(); + if("".equals(chargingStationIds) || chargingStationIds ==null){ + xhpcCommunity.setStatus(0); + }else{ + xhpcCommunity.setStatus(1); + } + xhpcCommunityMapper.addCommunity(xhpcCommunity); + if(!"".equals(chargingStationIds) && chargingStationIds !=null){ + xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); + } + return AjaxResult.success(); + } + + @Override + public Map getCommunityById(XhpcCommunity xhpcCommunity) { + + return xhpcCommunityMapper.getCommunityById(xhpcCommunity.getCommunityId(),null,1); + } } diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml index 06cebfa8..ef32c8f3 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml @@ -33,15 +33,16 @@ community_id as communityId, name as name from xhpc_community - where del_flag =1 + where del_flag =0 and name like CONCAT('%',#{name},'%') - - insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUE (#{item},#{mechanismId},#{source}) + insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUES + + #{item},#{mechanismId},#{source} @@ -72,6 +73,9 @@ dimension, + + status, + del_flag, @@ -116,6 +120,9 @@ #{dimension}, + + #{status}, + #{delFlag}, @@ -137,6 +144,27 @@ + + update xhpc_community + + name = #{name}, + service_preferential = #{servicePreferential}, + min_people = #{minPeople}, + contact_name = #{contactName}, + contact_phone = #{contactPhone}, + address = #{address}, + address = #{dimension}, + address = #{status}, + del_flag = #{delFlag}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + remark = #{remark}, + + where community_id=#{communityId} + + update xhpc_community set del_flag =1 where community_id=#{communityId} @@ -144,4 +172,32 @@ + + +