diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java index 77eedd31..8a8a99a5 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java @@ -29,6 +29,11 @@ public class LoginUser implements Serializable */ private String username; + /** + * 用户类型(0 C端用户 1 流量方用户 2社区用户 3B端用户) + */ + private Integer userType; + /** * 登录时间 */ @@ -148,4 +153,12 @@ public class LoginUser implements Serializable { this.sysUser = sysUser; } + + public Integer getUserType() { + return userType; + } + + public void setUserType(Integer userType) { + this.userType = userType; + } } 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 77e06488..0cdd3444 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 @@ -237,8 +237,8 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { DateTime parse = DateUtil.parse(DateUtil.format(startTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); DateTime parse1 = DateUtil.parse(DateUtil.format(updateTime2, "yyyy-MM-dd"), "yyyy-MM-dd"); //每分钟多少度电 - BigDecimal decimal = new BigDecimal((updateTime2.getTime() - startTime2.getTime())).divide(new BigDecimal(60000),2,BigDecimal.ROUND_DOWN); - BigDecimal divide = chargingDegree.divide(decimal,2,BigDecimal.ROUND_DOWN); + BigDecimal decimal = new BigDecimal((updateTime2.getTime() - startTime2.getTime())).divide(new BigDecimal(60000),4,BigDecimal.ROUND_DOWN); + BigDecimal divide = chargingDegree.divide(decimal,4,BigDecimal.ROUND_DOWN); long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY); if(betweenDay==0){ powerPriceTotal = getBigDecimal(rateModelId,DateUtil.formatTime(startTime2), DateUtil.formatTime(updateTime2), powerPriceTotal, divide); @@ -834,14 +834,11 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { return powerPriceTotal; } - private BigDecimal getRateTimeList(String startTime, String endTime, BigDecimal degree, BigDecimal powerPrice) { - System.out.println("startTime>>"+startTime); - System.out.println("endTime>>"+endTime); + private BigDecimal getRateTimeList(String startTime, String endTime, BigDecimal degree, BigDecimal powerPrice) { long time = DateUtil.parse(endTime).getTime(); long time1= DateUtil.parse(startTime).getTime(); - BigDecimal multiply = new BigDecimal(time-time1).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN).multiply(degree).setScale(2,BigDecimal.ROUND_DOWN); + BigDecimal multiply = new BigDecimal(time-time1).divide(new BigDecimal(60000),4, BigDecimal.ROUND_DOWN).multiply(degree).setScale(4,BigDecimal.ROUND_DOWN); BigDecimal bigDecimal = multiply.multiply(powerPrice).setScale(2, BigDecimal.ROUND_DOWN); - System.out.println("bigDecimal>>"+bigDecimal); return bigDecimal; } 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 b0eadbe0..1f7cfdff 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 @@ -5,6 +5,7 @@ import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.user.domain.XhpcCommunity; +import com.xhpc.user.domain.XhpcCommunityPersonnel; import com.xhpc.user.dto.MechanismDto; import com.xhpc.user.service.IMechanismService; import com.xhpc.user.service.IXhpcCommunityService; @@ -85,4 +86,60 @@ public class XhpcCommunityController extends BaseController { return AjaxResult.success(mechanismDtos); } + + /** + * 社区人员列表 + */ + @GetMapping("/communityPersonnelList") + public TableDataInfo communityPersonnelList(Long communityId,String account,String phone,Integer status) { + startPage(); + List> list = xhpcCommunityService.communityPersonnelList(communityId, account, phone, status); + return getDataTable(list); + } + + /** + * 社区人员添加 + * + */ + @PostMapping(value = "/addCommunityPersonnel") + public AjaxResult addCommunityPersonnel(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) { + return xhpcCommunityService.addCommunityPersonnel(xhpcCommunityPersonnel); + } + + /** + * 查看社区人员 + * + */ + @PostMapping(value = "/getCommunityPersonnelById") + public AjaxResult getCommunityPersonnelById(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) { + return AjaxResult.success(xhpcCommunityService.getCommunityPersonnelById(xhpcCommunityPersonnel)); + } + + /** + * 编辑社区人员 + * + */ + @PostMapping(value = "/updateCommunityPersonnel") + public AjaxResult updateCommunityPersonnel(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) { + return xhpcCommunityService.updateCommunityPersonnel(xhpcCommunityPersonnel); + } + + /** + * 删除社区人员 + */ + @PostMapping(value = "/deleteCommunityPersonnel") + public AjaxResult deleteCommunityPersonnel(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) { + xhpcCommunityService.deleteCommunityPersonnel(xhpcCommunityPersonnel); + return AjaxResult.success(); + } + + /** + * 删除社区人员 + */ + @PostMapping(value = "/updateCommunityPersonnelStatus") + public AjaxResult updateCommunityPersonnelStatus(@RequestBody XhpcCommunityPersonnel xhpcCommunityPersonnel) { + xhpcCommunityService.updateCommunityPersonnelStatus(xhpcCommunityPersonnel); + return AjaxResult.success(); + } + } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java new file mode 100644 index 00000000..ac3f7082 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcCommunityPersonnel.java @@ -0,0 +1,42 @@ +package com.xhpc.user.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author yuyang + * @date 2021/12/22 15:33 + */ +@Data +public class XhpcCommunityPersonnel extends BaseEntity { + + private Long communityPersonnelId; + + private Long communityId; + + private String name; + + private String account; + + private BigDecimal rechargeMoney; + + private BigDecimal consumeMoney; + + private BigDecimal redPacket; + + private BigDecimal surplusMoney; + + private String phone; + + private Integer type; + + private Integer status; + + private Integer delFlag; + /** + * 电站id + */ + private String chargingStationIds; +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java index fc99e58b..7f2e1684 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/MechanismMapper.java @@ -51,4 +51,14 @@ public interface MechanismMapper { * @return 结果 */ public List> dataChargingStationId(@Param("userId") Long userId, @Param("type") Integer type,@Param("operatorId") String operatorId,@Param("code") String cityCode); + + + /** + * 删除该社区组的数据维度 + */ + int updateMechanism(@Param("mechanismId")Long mechanismId,@Param("source")Integer source); + /** + * 添加数据维度 + */ + int addMechanism(@Param("chargingStationIds") List chargingStationIds,@Param("mechanismId")Long mechanismId,@Param("source")Integer source); } 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 39623352..b65c810d 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 @@ -1,6 +1,7 @@ package com.xhpc.user.mapper; import com.xhpc.user.domain.XhpcCommunity; +import com.xhpc.user.domain.XhpcCommunityPersonnel; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -21,11 +22,6 @@ public interface XhpcCommunityMapper { */ List> list(@Param("name") String name); - /** - * 添加数据维度 - */ - int addMechanism(@Param("chargingStationIds") List chargingStationIds,@Param("mechanismId")Long mechanismId,@Param("source")Integer source); - /** * 添加社区组 * @param xhpcCommunity @@ -40,7 +36,7 @@ public interface XhpcCommunityMapper { */ int updateCommunity(XhpcCommunity xhpcCommunity); /** - * 社区社区组 + * 删除社区社区组 * @param communityId */ void deleteCommunity(@Param("communityId")Long communityId); @@ -59,4 +55,42 @@ public interface XhpcCommunityMapper { * @return */ Map getCommunityById(@Param("communityId")Long communityId,@Param("name")String name,@Param("type")Integer type); + + + /** + * 社区人员列表 + * @return + */ + List> communityPersonnelList(@Param("communityId")Long communityId,@Param("account")String account,@Param("phone")String phone,@Param("status")Integer status); + + /** + * 添加社区人员 + * @param xhpcCommunityPersonnel + * @return + */ + int addCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 查询社区人员 + * @return + */ + Map getCommunityPersonnelById(@Param("communityPersonnelId")Long communityPersonnelId,@Param("phone")String phone,@Param("account")String account,@Param("type")Integer type); + + + /** + * 修改社区人员 + * @return + */ + int updateCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 删除社区社人员 + * @param communityPersonnelId + */ + void deleteCommunityPersonnel(@Param("communityPersonnelId")Long communityPersonnelId); + + /** + * 社区人员状态改变 + */ + void updateCommunityPersonnelStatus(@Param("communityPersonnelId")Long communityPersonnelId,@Param("status")Integer status); } 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 5a313199..747da683 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 @@ -17,4 +17,14 @@ public interface IMechanismService { * @return 结果 */ public List dataList(Integer status); + + /** + * 删除该社区组的数据维度 + */ + int updateMechanism(Long mechanismId,Integer source); + + /** + * 添加数据维度 + */ + int addMechanism(List chargingStationIds,Long mechanismId,Integer source); } 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 9bd87701..85060c08 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 @@ -3,6 +3,7 @@ package com.xhpc.user.service; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.user.domain.XhpcCommunity; +import com.xhpc.user.domain.XhpcCommunityPersonnel; import java.util.List; import java.util.Map; @@ -48,4 +49,42 @@ public interface IXhpcCommunityService { */ Map getCommunityById(XhpcCommunity xhpcCommunity); + /** + * 社区人员列表 + * @return + */ + List> communityPersonnelList(Long communityId,String account,String phone,Integer status); + + + /** + * 新增社区人员 + * @param + * @return + */ + AjaxResult addCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 查询社区人员 + * + * @return + */ + Map getCommunityPersonnelById(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 编辑社区组树 + * + * @param + * @return + */ + AjaxResult updateCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 删除社区人员 + */ + void deleteCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel); + + /** + * 社区人员状态改变 + */ + void updateCommunityPersonnelStatus(XhpcCommunityPersonnel xhpcCommunityPersonnel); } 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 2760b47e..10717af5 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 @@ -53,6 +53,16 @@ public class IMechanismServiceImpl implements IMechanismService { } } + @Override + public int updateMechanism(Long mechanismId, Integer source) { + return mechanismMapper.updateMechanism(mechanismId, source); + } + + @Override + public int addMechanism(List chargingStationIds, Long mechanismId, Integer source) { + return mechanismMapper.addMechanism(chargingStationIds, mechanismId, source); + } + /** * 地区树 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 105d966b..0ff15041 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 @@ -3,7 +3,9 @@ package com.xhpc.user.service.impl; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.user.domain.XhpcCommunity; +import com.xhpc.user.domain.XhpcCommunityPersonnel; import com.xhpc.user.mapper.XhpcCommunityMapper; +import com.xhpc.user.service.IMechanismService; import com.xhpc.user.service.IXhpcCommunityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +24,8 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { @Autowired private XhpcCommunityMapper xhpcCommunityMapper; + @Autowired + private IMechanismService mechanismService; @Override public List> list(String name) { @@ -55,7 +59,7 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { } xhpcCommunityMapper.addCommunity(xhpcCommunity); if(!"".equals(chargingStationIds) && chargingStationIds !=null){ - xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); + mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); } return AjaxResult.success(); } @@ -84,9 +88,10 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { }else{ xhpcCommunity.setStatus(1); } - xhpcCommunityMapper.addCommunity(xhpcCommunity); + xhpcCommunityMapper.updateCommunity(xhpcCommunity); + mechanismService.updateMechanism(xhpcCommunity.getCommunityId(),0); if(!"".equals(chargingStationIds) && chargingStationIds !=null){ - xhpcCommunityMapper.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); + mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcCommunity.getCommunityId(),0); } return AjaxResult.success(); } @@ -96,4 +101,63 @@ public class XhpcCommunityServiceImpl implements IXhpcCommunityService { return xhpcCommunityMapper.getCommunityById(xhpcCommunity.getCommunityId(),null,1); } + + @Override + public List> communityPersonnelList(Long communityId, String account, String phone, Integer status) { + return xhpcCommunityMapper.communityPersonnelList(communityId, account, phone, status); + } + + @Override + public AjaxResult addCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel) { + String phone = xhpcCommunityPersonnel.getPhone(); + String account = xhpcCommunityPersonnel.getAccount(); + Map communityPersonnelById = xhpcCommunityMapper.getCommunityPersonnelById(null, phone, account, 3); + if(communityPersonnelById !=null){ + if(phone.equals(communityPersonnelById.get("phone").toString())){ + return AjaxResult.error("手机号重复"); + } + if(account.equals(communityPersonnelById.get("account").toString())){ + return AjaxResult.error("账号重复"); + } + } + xhpcCommunityMapper.addCommunityPersonnel(xhpcCommunityPersonnel); + + //增加一条充值记录 + + return AjaxResult.success(); + } + + @Override + public Map getCommunityPersonnelById(XhpcCommunityPersonnel xhpcCommunityPersonnel) { + return xhpcCommunityMapper.getCommunityPersonnelById(xhpcCommunityPersonnel.getCommunityPersonnelId(), null, null, 1); + } + + @Override + public AjaxResult updateCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel) { + Long communityPersonnelId = xhpcCommunityPersonnel.getCommunityPersonnelId(); + String phone = xhpcCommunityPersonnel.getPhone(); + String account = xhpcCommunityPersonnel.getAccount(); + + Map communityPersonnelById = xhpcCommunityMapper.getCommunityPersonnelById(communityPersonnelId, phone, account, 2); + if(communityPersonnelById !=null){ + if(phone.equals(communityPersonnelById.get("phone").toString())){ + return AjaxResult.error("手机号重复"); + } + if(account.equals(communityPersonnelById.get("account").toString())){ + return AjaxResult.error("账号重复"); + } + } + xhpcCommunityMapper.updateCommunityPersonnel(xhpcCommunityPersonnel); + return AjaxResult.success(); + } + + @Override + public void deleteCommunityPersonnel(XhpcCommunityPersonnel xhpcCommunityPersonnel) { + xhpcCommunityMapper.deleteCommunityPersonnel(xhpcCommunityPersonnel.getCommunityPersonnelId()); + } + + @Override + public void updateCommunityPersonnelStatus(XhpcCommunityPersonnel xhpcCommunityPersonnel) { + xhpcCommunityMapper.updateCommunityPersonnelStatus(xhpcCommunityPersonnel.getCommunityPersonnelId(),xhpcCommunityPersonnel.getStatus()); + } } diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml index ed042905..99f6df29 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/MechanismMapper.xml @@ -128,4 +128,14 @@ and xcs.area_code = #{code} + + + update xhpc_mechanism set del_flag =1 where mechanism_id=#{mechanismId} and source=#{source } + + + insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUES + + #{item},#{mechanismId},#{source} + + 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 ef32c8f3..99e57b88 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml @@ -39,13 +39,6 @@ - - insert into xhpc_mechanism (charging_station_id,mechanism_id,source) VALUES - - #{item},#{mechanismId},#{source} - - - insert into xhpc_community @@ -170,7 +163,7 @@ + + + + insert into xhpc_community_personnel + + + community_personnel_id, + + + community_id, + + + name, + + + account, + + + recharge_money, + + + consume_money, + + + red_packet, + + + surplus_money, + + + phone, + + + type, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + + + #{communityPersonnelId}, + + + #{communityId}, + + + #{name}, + + + #{account}, + + + #{rechargeMoney}, + + + #{consumeMoney}, + + + #{redPacket}, + + + #{surplusMoney}, + + + #{phone}, + + + #{type}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + + + + + + + update xhpc_community_personnel + + community_id = #{communityId}, + name = #{name}, + account = #{account}, + phone = #{phone}, + type = #{type}, + address = #{status}, + del_flag = #{delFlag}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + remark = #{remark}, + + where community_personnel_id=#{communityPersonnelId} + + + + update xhpc_community_personnel set del_flag=1 where community_personnel_id=#{communityPersonnelId} + + + + update xhpc_community_personnel set status=#{status} where community_personnel_id=#{communityPersonnelId} +