增加场站费率租户

This commit is contained in:
yuyang 2022-10-09 14:22:50 +08:00
parent f40ce29969
commit 2eec496458
9 changed files with 80 additions and 36 deletions

View File

@ -35,10 +35,10 @@ public class XhpcChargingStationApiController extends BaseController {
*/
//@PreAuthorize(hasPermi = "system:station:list")
@GetMapping("/getWXList")
public TableDataInfo getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude) {
public TableDataInfo getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude,String tenantId) {
startPage();
List<Map<String, Object>> list = xhpcChargingStationService.getWXList(name, serviceFacilities, code, longitude, latitude);
List<Map<String, Object>> list = xhpcChargingStationService.getWXList(name, serviceFacilities, code, longitude, latitude,tenantId);
return getDataTable(list);
}

View File

@ -124,7 +124,7 @@ public interface XhpcChargingStationMapper {
* @param clientVisible 微信小程序是否可见 2可见
* @return
*/
List<Map<String, Object>> getWXList(@Param("name") String name, @Param("serviceFacilities") List<String> serviceFacilities, @Param("code") Integer code, @Param("longitude") String longitude, @Param("latitude") String latitude, @Param("clientVisible") Integer clientVisible,@Param("date") String date);
List<Map<String, Object>> getWXList(@Param("name") String name, @Param("serviceFacilities") List<String> serviceFacilities, @Param("code") Integer code, @Param("longitude") String longitude, @Param("latitude") String latitude, @Param("clientVisible") Integer clientVisible,@Param("date") String date,@Param("tenantId")String tenantId);
/**

View File

@ -143,7 +143,7 @@ public interface IXhpcChargingStationService {
* @param latitude 维度
* @return
*/
List<Map<String, Object>> getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude);
List<Map<String, Object>> getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude,String tenantId);
/**

View File

@ -452,12 +452,13 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
}
}
}
String tenantId = loginUser.getTenantId();
//添加费率计费模型
XhpcRateModel xhpcRateModel = new XhpcRateModel();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel);
xhpcRateModel.setCreateBy(userName);
xhpcRateModel.setUpdateBy(userName);
xhpcRateModel.setTenantId(tenantId);
int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel);
if (i == 0) {
return AjaxResult.error("1005", "费率计费模型添加失败");
@ -468,6 +469,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
XhpcChargingStation xhpcChargingStation = new XhpcChargingStation();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcChargingStation);
xhpcChargingStation.setRateModelId(rateModelId);
xhpcChargingStation.setTenantId(tenantId);
int j = xhpcChargingStationMapper.insertxhpcChargingStation(xhpcChargingStation);
if (j == 0) {
return AjaxResult.error("1006", "电站基本信息添加失败");
@ -500,6 +502,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
xhpcRate.setRateValue(xhpcRateDto.getId());
xhpcRate.setCreateBy(userName);
xhpcRate.setUpdateBy(userName);
xhpcRate.setTenantId(tenantId);
xhpcChargingStationMapper.insertXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(), xhpcRate.getRateId());
}else{
@ -565,15 +568,15 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName,tenantId);
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
if(!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName,tenantId);
}
}else{
if(k == 0){
@ -582,9 +585,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName,tenantId);
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
}else if(k < list.size()-1){
String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) {
@ -592,10 +595,10 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName,tenantId);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
}else{
String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) {
@ -604,17 +607,17 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return AjaxResult.error("请填写默认时间段费率");
}
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName,tenantId);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
if (!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName,tenantId);
}
}
}
@ -753,7 +756,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return map;
}
private int addXhpcRateTime(Long chargingStationId, Long rateModelId, Long defaultPeriodId, String startTime, String endTime, int sort, int type, String rateValue, String userName) {
private int addXhpcRateTime(Long chargingStationId, Long rateModelId, Long defaultPeriodId, String startTime, String endTime, int sort, int type, String rateValue, String userName,String tenantId) {
XhpcRateTime xhpcRateTime = new XhpcRateTime();
xhpcRateTime.setChargingStationId(chargingStationId);
@ -769,12 +772,13 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
xhpcRateTime.setCreateTime(Calendar.getInstance().getTime());
xhpcRateTime.setCreateBy(userName);
xhpcRateTime.setUpdateBy(userName);
xhpcRateTime.setTenantId(tenantId);
xhpcChargingStationMapper.insertXhpcRateTime(xhpcRateTime);
return sort++;
}
@Override
public List<Map<String, Object>> getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude) {
public List<Map<String, Object>> getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude,String tenantId) {
if(null==longitude||"".equals(longitude)||null==latitude||"".equals(latitude)){
longitude="104.065861"; latitude="30.657401";
@ -788,7 +792,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
stringList = Arrays.asList(split);
}
String date = DateUtil.formatTime(new Date());
List<Map<String, Object>> list = xhpcChargingStationMapper.getWXList(name, stringList, code, longitude, latitude, 2,date);
List<Map<String, Object>> list = xhpcChargingStationMapper.getWXList(name, stringList, code, longitude, latitude, 2,date,tenantId);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Map<String, Object> map = list.get(i);
@ -1055,7 +1059,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
public AjaxResult updateXhpcRateTime(HttpServletRequest request, XhpcChargingStationDto xhpcChargingStationDto) {
LoginUser loginUser = logUserUtils.getLogUser(request);
String userName = loginUser.getUsername();
String tenantId = loginUser.getTenantId();
//电站id不能为空
if (xhpcChargingStationDto.getChargingStationId() == null) {
return AjaxResult.error("1001", "电站id为空");
@ -1212,15 +1216,15 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName,tenantId);
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
if(!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName,tenantId);
}
}else{
if(k == 0){
@ -1229,9 +1233,9 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName);
sort= addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, "00:00:00", startTime, sort, 2, rateValue, userName,tenantId);
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
}else if(k < list.size()-1){
String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) {
@ -1239,10 +1243,10 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName,tenantId);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
}else{
String endTimeK = list.get(k - 1).getEndTime();
if (!endTimeK.equals(startTime)) {
@ -1251,17 +1255,17 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
return AjaxResult.error("请填写默认时间段费率");
}
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTimeK, startTime, sort, 2, rateValue, userName,tenantId);
}
//并把本条数据也添加上
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodIdMap, startTime, endTime, sort, 1, rateValues, userName,tenantId);
if (!endTime.equals("24:00:00")) {
if(rateValue ==null || "".equals(rateValue)){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("请填写默认时间段费率");
}
//添加一条默认费率时段
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName);
sort = addXhpcRateTime(chargingStationId, rateModelId, defaultPeriodId, endTime, "24:00:00", sort, 2, rateValue, userName,tenantId);
}
}
}

View File

@ -323,6 +323,9 @@
<if test="code !=null and code !=''">
and cs.area_code in (select code from xhpc_area where pcode=#{code}) or cs.area_code=#{code}
</if>
<if test="tenantId !=null and tenantId !=''">
and cs.tenant_id =#{tenantId}
</if>
ORDER BY distance asc
</select>
@ -434,7 +437,10 @@
update_by,
</if>
<if test="null != remark and '' != remark">
remark
remark,
</if>
<if test="null != tenantId and '' != tenantId">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -457,7 +463,10 @@
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark}
#{remark},
</if>
<if test="null != tenantId and '' != tenantId">
#{tenantId},
</if>
</trim>
</insert>
@ -555,6 +564,9 @@
</if>
<if test="installedTotalPower != null">installed_total_power,</if>
<if test="runningTotalPower != null">running_total_power,</if>
<if test="tenantId != null and '' != tenantId">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != name and '' != name">
@ -646,6 +658,9 @@
</if>
<if test="installedTotalPower != null">#{installedTotalPower},</if>
<if test="runningTotalPower != null">#{runningTotalPower},</if>
<if test="tenantId != null and '' != tenantId">
#{tenantId},
</if>
</trim>
</insert>
@ -687,7 +702,10 @@
rate_value,
</if>
<if test="null != rateModelId">
rate_model_id
rate_model_id,
</if>
<if test="null != tenantId and ''!=tenantId">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -728,9 +746,11 @@
#{rateValue},
</if>
<if test="null != rateModelId">
#{rateModelId}
#{rateModelId},
</if>
<if test="null != tenantId and ''!=tenantId">
#{tenantId},
</if>
</trim>
</insert>

View File

@ -495,7 +495,7 @@
from xhpc_operator
where del_flag =0
<if test="type==1">
and operator_id in (select operator_id from xhpc_charging_station where operator_id=#{userId})
and operator_id=#{userId}
</if>
<if test="type==2">
and operator_id in (select operator_id from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}))

View File

@ -59,6 +59,7 @@ public class XhpcOperatorController extends BaseController {
LoginUser loginUser = tokenService.getLoginUser();
xhpcOperator.setTenantId(loginUser.getTenantId());
xhpcOperator.setCorpNo(xhpcOperator.getOperatorIdEvcs());
SysUser sysUser = new SysUser();
BigDecimal t3 =new BigDecimal(100);
BigDecimal t4 =new BigDecimal(0);
@ -149,6 +150,7 @@ public class XhpcOperatorController extends BaseController {
sysUser.setUserName(xhpcOperator.getPhone());
sysUser.setPassword("123456");
iXhpcUserService.updateUser(sysUser);
xhpcOperator.setCorpNo(xhpcOperator.getOperatorIdEvcs());
return toAjax(iXhpcOperatorService.update(xhpcOperator));
}

View File

@ -18,6 +18,7 @@ public class XhpcOperator extends BaseEntity {
*/
private Long operatorId;
private String corpNo;
/**
* 名称
*/
@ -372,4 +373,12 @@ public class XhpcOperator extends BaseEntity {
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public String getCorpNo() {
return corpNo;
}
public void setCorpNo(String corpNo) {
this.corpNo = corpNo;
}
}

View File

@ -55,6 +55,9 @@
<if test="null != name and '' != name">
name,
</if>
<if test="null != corpNo and '' != corpNo">
corp_no,
</if>
<if test="null != contactName and '' != contactName">
contact_name,
</if>
@ -144,6 +147,9 @@
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != corpNo and '' != corpNo">
#{corpNo},
</if>
<if test="null != contactName and '' != contactName">
#{contactName},
</if>
@ -236,6 +242,7 @@
<set>
<if test="null != operatorId and '' != operatorId">operator_id = #{operatorId},</if>
<if test="null != name and '' != name">name = #{name},</if>
<if test="null != corpNo and '' != corpNo">corp_no = #{corpNo},</if>
<if test="null != contactName and '' != contactName">contact_name = #{contactName},</if>
<if test="null != contactPhone and '' != contactPhone">contact_phone = #{contactPhone},</if>
<if test="null != phone and '' != phone">phone = #{phone},</if>
@ -287,10 +294,12 @@
<include refid="Base_Column_List"/>,
xo.operator_id_evcs operatorIdEvcs,
xdb.dict_value attributenName,`xa`.merger_name mergerName,
concat(0) roleId,
xo.business_license_id businessLicenseUrl
from xhpc_operator `xo`
LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xo.area_code
where xo.del_flag = 0 and xo.operator_id = #{operatorId}
</select>
@ -325,7 +334,7 @@
and xo.operator_id =#{operatorId}
</if>
<if test="type==1">
and xo.operator_id in (select operator_id from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId}))
and xo.operator_id=#{logOperatorId}
</if>
<if test="type==2">
and xo.operator_id in (select operator_id from xhpc_charging_station where charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId}))