场站、桩增加租户设置的场站、桩数量限制

This commit is contained in:
yuyang 2022-03-28 14:51:34 +08:00
parent a9e3149d8e
commit c33f2b8f0c
9 changed files with 66 additions and 10 deletions

View File

@ -23,6 +23,10 @@ public interface XhpcChargingPileMapper {
*/ */
List<Map<String, Object>> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId,@Param("operatorId")Long operatorId,@Param("number")Integer number,@Param("tenantId") String tenantId); List<Map<String, Object>> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId,@Param("operatorId")Long operatorId,@Param("number")Integer number,@Param("tenantId") String tenantId);
int getCountXhpcChargingPile(@Param("chargingStationId") Long chargingStationId,@Param("tenantId") String tenantId);
/** /**
* 终端 * 终端
* *

View File

@ -172,6 +172,8 @@ public interface XhpcChargingStationMapper {
List<Map<String, Object>> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId); List<Map<String, Object>> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId);
int getCountXhpcChargingStation(@Param("tenantId") String tenantId);
/** /**
* 添加费率模型 * 添加费率模型
*/ */

View File

@ -10,6 +10,7 @@ import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
import com.xhpc.charging.station.pojo.XhpcImg; import com.xhpc.charging.station.pojo.XhpcImg;
import com.xhpc.charging.station.utils.img.QrImgUtils; import com.xhpc.charging.station.utils.img.QrImgUtils;
import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.PowerPileService;
import com.xhpc.common.api.TenantService;
import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.HttpStatus;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.exception.CustomException; import com.xhpc.common.core.exception.CustomException;
@ -67,6 +68,9 @@ public class XhpcChargingPileServiceImpl extends BaseService implements IXhpcCha
private LogUserUtils logUserUtils; private LogUserUtils logUserUtils;
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired
private TenantService tenantService;
//字母集合 //字母集合
private static Map letterMap; private static Map letterMap;
@ -121,6 +125,24 @@ public class XhpcChargingPileServiceImpl extends BaseService implements IXhpcCha
@Override @Override
@Transactional @Transactional
public AjaxResult addXhpcChargingPile(XhpcChargingPile xhpcChargingPile) { public AjaxResult addXhpcChargingPile(XhpcChargingPile xhpcChargingPile) {
Long chargingStationId = xhpcChargingPile.getChargingStationId();
LoginUser loginUser = tokenService.getLoginUser();
R r1 = tenantService.gettenantIdTime(loginUser.getTenantId());
if(r1.getCode()!=200){
return AjaxResult.error(1001, "请重新登录");
}else{
Map<String, Object> map = (Map<String, Object>)r1.getData();
if(map !=null){
if(!map.get("stationPileQuote").equals("-1")){
int count = xhpcChargingPileMapper.getCountXhpcChargingPile(chargingStationId,loginUser.getTenantId());
if(Integer.parseInt(map.get("stationPileQuote").toString())<count){
return AjaxResult.error(1001, "桩已达到限额,如要在创建桩请联系管理员");
}
}
}else{
return AjaxResult.error(1001, "无法创建桩请联系管理员");
}
}
if(xhpcChargingPile.getGunNumber() ==null || xhpcChargingPile.getGunNumber()>26){ if(xhpcChargingPile.getGunNumber() ==null || xhpcChargingPile.getGunNumber()>26){
return AjaxResult.error("终端数量不能大于26"); return AjaxResult.error("终端数量不能大于26");
@ -128,7 +150,7 @@ public class XhpcChargingPileServiceImpl extends BaseService implements IXhpcCha
if(xhpcChargingPile.getSerialNumber() ==null || xhpcChargingPile.getSerialNumber().length()!=14){ if(xhpcChargingPile.getSerialNumber() ==null || xhpcChargingPile.getSerialNumber().length()!=14){
return AjaxResult.error("桩编号14位"); return AjaxResult.error("桩编号14位");
} }
Long chargingStationId = xhpcChargingPile.getChargingStationId();
//获取计费模型id //获取计费模型id
Map<String, Object> stringObjectMap = xhpcChargingPileMapper.selectXhpcChargingStationById(chargingStationId); Map<String, Object> stringObjectMap = xhpcChargingPileMapper.selectXhpcChargingStationById(chargingStationId);
Long rateModelId = Long.parseLong(StringUtils.valueOf(stringObjectMap.get("rateModelId"))); Long rateModelId = Long.parseLong(StringUtils.valueOf(stringObjectMap.get("rateModelId")));

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper; import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
import com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper; import com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper;
import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.PowerPileService;
import com.xhpc.common.api.TenantService;
import com.xhpc.common.api.dto.XhpcChargingStationDto; import com.xhpc.common.api.dto.XhpcChargingStationDto;
import com.xhpc.common.api.dto.XhpcRateDto; import com.xhpc.common.api.dto.XhpcRateDto;
import com.xhpc.common.api.dto.XhpcRateTimeDto; import com.xhpc.common.api.dto.XhpcRateTimeDto;
@ -14,10 +15,7 @@ import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService; import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.data.redis.CacheRateModel; import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.common.domain.XhpcChargingStation; import com.xhpc.common.domain.*;
import com.xhpc.common.domain.XhpcRate;
import com.xhpc.common.domain.XhpcRateModel;
import com.xhpc.common.domain.XhpcRateTime;
import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.util.LogUserUtils; import com.xhpc.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser; import com.xhpc.system.api.model.LoginUser;
@ -56,6 +54,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private LogUserUtils logUserUtils; private LogUserUtils logUserUtils;
@Autowired
private TenantService tenantService;
@Autowired @Autowired
private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper; private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper;
@ -318,6 +319,24 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
LoginUser loginUser = logUserUtils.getLogUser(request); LoginUser loginUser = logUserUtils.getLogUser(request);
String userName = loginUser.getUsername(); String userName = loginUser.getUsername();
R r1 = tenantService.gettenantIdTime(loginUser.getTenantId());
if(r1.getCode()!=200){
return AjaxResult.error(1001, "请重新登录");
}else{
Map<String, Object> map = (Map<String, Object>)r1.getData();
if(map !=null){
if(!map.get("getStationQuote").equals("-1")){
int count = xhpcChargingStationMapper.getCountXhpcChargingStation(loginUser.getTenantId());
if(Integer.parseInt(map.get("getStationQuote").toString())<count){
return AjaxResult.error(1001, "场站已达到限额,如要在创建场站请联系管理员");
}
}
}else{
return AjaxResult.error(1001, "无法创建场站请联系管理员");
}
}
if (xhpcChargingStationDto.getName() == null || "".equals(xhpcChargingStationDto.getName())) { if (xhpcChargingStationDto.getName() == null || "".equals(xhpcChargingStationDto.getName())) {
return AjaxResult.error(1001, "电站名称不能为空"); return AjaxResult.error(1001, "电站名称不能为空");
} }

View File

@ -72,6 +72,10 @@
equipment_type equipmentType equipment_type equipmentType
from xhpc_charging_pile from xhpc_charging_pile
</sql> </sql>
<select id="getCountXhpcChargingPile" resultType="int">
select count(charging_pile_id) from xhpc_charging_pile where charging_station_id=#{chargingStationId} and tenant_id=#{tenantId} and del_flag =0
</select>
<select id="selectXhpcChargingPileList" resultType="java.util.Map"> <select id="selectXhpcChargingPileList" resultType="java.util.Map">
select select
cp.charging_pile_id as chargingPileId, cp.charging_pile_id as chargingPileId,

View File

@ -399,6 +399,11 @@
order by te.serial_number desc order by te.serial_number desc
</select> </select>
<select id="getCountXhpcChargingStation" resultType="int">
select count(charging_station_id) from xhpc_charging_station where tenant_id=#{tenantId} and del_flag=0
</select>
<insert id="insertXhpcRateModel" parameterType="com.xhpc.common.domain.XhpcRateModel" useGeneratedKeys="true" <insert id="insertXhpcRateModel" parameterType="com.xhpc.common.domain.XhpcRateModel" useGeneratedKeys="true"
keyProperty="rateModelId"> keyProperty="rateModelId">
insert into xhpc_rate_model insert into xhpc_rate_model

View File

@ -2,7 +2,6 @@ package com.xhpc.tenant.controller;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.page.TableDataInfo; import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log; import com.xhpc.common.log.annotation.Log;
@ -20,7 +19,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
@ -116,7 +114,7 @@ public class XhpcTenantController extends BaseController {
@Log(title = "租户管理-删除租户", businessType = BusinessType.DELETE) @Log(title = "租户管理-删除租户", businessType = BusinessType.DELETE)
@DeleteMapping("/detail") @DeleteMapping("/deleteTenantByPk")
public R deleteTenantByPk(@RequestParam("tenantId")String tenantId){ public R deleteTenantByPk(@RequestParam("tenantId")String tenantId){
return R.ok(tenantService.deleteByPk(tenantId)); return R.ok(tenantService.deleteByPk(tenantId));
} }
@ -126,7 +124,7 @@ public class XhpcTenantController extends BaseController {
public R getTenantIdTime(@RequestParam("tenantId")String tenantId){ public R getTenantIdTime(@RequestParam("tenantId")String tenantId){
XhpcTenantDomain infoByPk = tenantService.getInfoByPk(tenantId); XhpcTenantDomain infoByPk = tenantService.getInfoByPk(tenantId);
if(infoByPk !=null && infoByPk.getIsDeleted()==0 && infoByPk.getStatus()==1){ if(infoByPk !=null && infoByPk.getIsDeleted()==0 && infoByPk.getStatus()==1){
return R.ok(); return R.ok(infoByPk);
} }
return R.fail(); return R.fail();
} }

View File

@ -2,7 +2,6 @@ package com.xhpc.tenant.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.SmsService; import com.xhpc.common.api.SmsService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.tenant.domain.XhpcTenantDomain; import com.xhpc.tenant.domain.XhpcTenantDomain;
import com.xhpc.tenant.mapper.XhpcTenantMapper; import com.xhpc.tenant.mapper.XhpcTenantMapper;

View File

@ -265,7 +265,10 @@
`domain` = #{domain,jdbcType=VARCHAR}, `domain` = #{domain,jdbcType=VARCHAR},
background_url = #{backgroundUrl,jdbcType=VARCHAR}, background_url = #{backgroundUrl,jdbcType=VARCHAR},
linkman = #{linkman,jdbcType=VARCHAR}, linkman = #{linkman,jdbcType=VARCHAR},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
contact_number = #{contactNumber,jdbcType=VARCHAR}, contact_number = #{contactNumber,jdbcType=VARCHAR},
station_quote = #{stationQuote,jdbcType=INTEGER},
station_pile_quote = #{stationPileQuote,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR},
update_user = #{updateUser,jdbcType=BIGINT}, update_user = #{updateUser,jdbcType=BIGINT},
update_time = sysdate() update_time = sysdate()