增加桩版本号控制
This commit is contained in:
parent
c5fd596a15
commit
bdd5d358a7
@ -44,7 +44,6 @@ public class SysUser extends BaseEntity
|
||||
* 用户类型(00系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 租户id(000000平台)
|
||||
*/
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.xhpc.charging.station.controller;
|
||||
|
||||
import com.xhpc.charging.station.service.IXhpcPileEditionService;
|
||||
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
import com.xhpc.common.domain.XhpcPileEdition;
|
||||
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 2022/8/30 14:17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pileEdition")
|
||||
public class XhpcPileEditionController extends BaseController {
|
||||
|
||||
|
||||
@Resource
|
||||
private IXhpcPileEditionService xhpcPileEditionService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HttpServletRequest request,Long chargingStationId,String chargingPileIds) {
|
||||
startPage();
|
||||
List<Map<String, Object>> list = xhpcPileEditionService.list(request,chargingStationId,chargingPileIds);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/addPileEdition")
|
||||
public AjaxResult addPileEdition(HttpServletRequest request, @RequestBody XhpcPileEdition xhpcPileEdition) {
|
||||
return xhpcPileEditionService.addPileEdition(request, xhpcPileEdition);
|
||||
}
|
||||
@PostMapping("/status")
|
||||
public AjaxResult status(@RequestParam(value = "status", required = true) Integer status,@RequestParam(value = "pileEditionId", required = true) Long pileEditionId) {
|
||||
|
||||
return xhpcPileEditionService.status(pileEditionId,status);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.xhpc.charging.station.mapper;
|
||||
|
||||
import com.xhpc.common.domain.XhpcPileEdition;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/8/30 14:15
|
||||
*/
|
||||
public interface XhpcPileEditionMapper {
|
||||
|
||||
List<Map<String, Object>> list(@Param("chargingStationId")Long chargingStationId, @Param("chargingPileIds") String chargingPileIds,@Param("logOperatorId")Long logOperatorId, @Param("type")Integer type, @Param("tenantId")String tenantId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pileEditionId
|
||||
* @param chargingPileIds
|
||||
* @param type 1是去掉自己
|
||||
* @return
|
||||
*/
|
||||
int getXhpcPileEditions(@Param("pileEditionId")Long pileEditionId,@Param("chargingPileIds") String chargingPileIds,@Param("type")Integer type);
|
||||
|
||||
int insertXhpcPileEdition(XhpcPileEdition xhpcPileEdition);
|
||||
|
||||
int updatePileEdition(XhpcPileEdition xhpcPileEdition);
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.xhpc.charging.station.service;
|
||||
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.domain.XhpcPileEdition;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/8/30 14:09
|
||||
*/
|
||||
public interface IXhpcPileEditionService {
|
||||
|
||||
|
||||
/**
|
||||
* 查询版本列表
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> list(HttpServletRequest request, Long chargingStationId, String chargingPileIds);
|
||||
|
||||
|
||||
AjaxResult addPileEdition(HttpServletRequest request, XhpcPileEdition xhpcPileEdition);
|
||||
|
||||
AjaxResult status(Long pileEditionId,Integer status);
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.xhpc.charging.station.service;
|
||||
|
||||
import com.xhpc.charging.station.mapper.XhpcPileEditionMapper;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.service.BaseService;
|
||||
import com.xhpc.common.domain.XhpcChargingStation;
|
||||
import com.xhpc.common.domain.XhpcPileEdition;
|
||||
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 org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/8/30 14:10
|
||||
*/
|
||||
@Service
|
||||
public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPileEditionService{
|
||||
|
||||
@Resource
|
||||
private XhpcPileEditionMapper xhpcPileEditionMapper;
|
||||
@Resource
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 查询版本列表
|
||||
*
|
||||
* @param request
|
||||
* @param chargingStationId
|
||||
* @param chargingPileIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> list(HttpServletRequest request, Long chargingStationId, String chargingPileIds) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
Long sysUserId = sysUser.getUserId();
|
||||
String tenantId =loginUser.getTenantId();
|
||||
//判断登录人的权限
|
||||
List<Map<String, Object>> list =new ArrayList<>();
|
||||
if(UserTypeUtil.SYS_USER_TYPE_FOUR.equals(sysUser.getUserType())){
|
||||
//运维人员权限
|
||||
}else{
|
||||
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
|
||||
// startPage();
|
||||
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
|
||||
Long logOperatorId = sysUser.getOperatorId();
|
||||
//运营商看自己的场站
|
||||
list = xhpcPileEditionMapper.list(chargingStationId,chargingPileIds,logOperatorId,1,tenantId);
|
||||
}else{
|
||||
//查询赋值的场站
|
||||
list = xhpcPileEditionMapper.list(chargingStationId,chargingPileIds,sysUserId,2,tenantId);
|
||||
}
|
||||
}else{
|
||||
// startPage();
|
||||
list = xhpcPileEditionMapper.list(chargingStationId,chargingPileIds,sysUserId,0,tenantId);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult addPileEdition(HttpServletRequest request, XhpcPileEdition xhpcPileEdition) {
|
||||
|
||||
//判断是否已添加该桩
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1);
|
||||
|
||||
if(xhpcPileEditions >0){
|
||||
return AjaxResult.error(500, "有重复桩");
|
||||
}
|
||||
if(xhpcPileEdition.getPileEditionId() ==null){
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
String tenantId =loginUser.getTenantId();
|
||||
xhpcPileEdition.setTenantId(tenantId);
|
||||
xhpcPileEditionMapper.insertXhpcPileEdition(xhpcPileEdition);
|
||||
}else{
|
||||
xhpcPileEditionMapper.updatePileEdition(xhpcPileEdition);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult status(Long pileEditionId,Integer status) {
|
||||
XhpcPileEdition xhpcPileEdition = new XhpcPileEdition();
|
||||
xhpcPileEdition.setPileEditionId(pileEditionId);
|
||||
xhpcPileEdition.setStatus(status);
|
||||
if(status==0){
|
||||
int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1);
|
||||
if(xhpcPileEditions >0){
|
||||
return AjaxResult.error(500, "有重复桩");
|
||||
}
|
||||
}
|
||||
xhpcPileEditionMapper.updatePileEdition(xhpcPileEdition);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xhpc.charging.station.mapper.XhpcPileEditionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcPileEdition">
|
||||
<result property="pileEditionId" column="pile_edition_id"/>
|
||||
<result property="chargingStationId" column="charging_station_id"/>
|
||||
<result property="chargingPileIds" column="charging_pile_ids"/>
|
||||
<result property="directNumber" column="direct_number"/>
|
||||
<result property="communicationNumber" column="communication_number"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="list" resultType="map">
|
||||
select
|
||||
xcs.name as chargingStationName,
|
||||
xpe.pile_edition_id as pileEditionId,
|
||||
xpe.direct_number as directNumber,
|
||||
xpe.communication_number as communicationNumber,
|
||||
xpe.status as status,
|
||||
<if test="chargingPileIds !=null and chargingPileIds !=''">
|
||||
(SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,#{chargingPileIds})) as chargingPileName
|
||||
</if>
|
||||
<if test="chargingPileIds==null">
|
||||
concat('--') as chargingPileName
|
||||
</if>
|
||||
from xhpc_pile_edition as xpe
|
||||
left join xhpc_charging_station xcs on xpe.charging_station_id = xcs.charging_station_id
|
||||
where xpe.del_flag=0
|
||||
<if test="chargingStationId !=null">
|
||||
and xpe.charging_station_id = #{chargingStationId}
|
||||
</if>
|
||||
<if test="chargingPileIds !=null and chargingPileIds !=''">
|
||||
and find_in_set(xpe.charging_pile_ids, #{chargingPileIds})
|
||||
</if>
|
||||
<if test="type ==1">
|
||||
and xpe.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
|
||||
</if>
|
||||
<if test="type ==2">
|
||||
and xpe.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
|
||||
</if>
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
and xpe.tenant_id=#{tenantId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getXhpcPileEditions" resultType="int">
|
||||
select
|
||||
count(xpe.pile_edition_id) number
|
||||
from xhpc_pile_edition xpe
|
||||
where find_in_set(xpe.charging_pile_ids, #{chargingPileIds}) and xpe.del_flag=0 and xpe.status =0
|
||||
<if test="type ==1">
|
||||
and xpe.pile_edition_id != #{pileEditionId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertXhpcPileEdition">
|
||||
insert into xhpc_pile_edition
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != chargingStationId ">
|
||||
charging_station_id,
|
||||
</if>
|
||||
<if test="null != chargingPileIds and chargingPileIds !=''">
|
||||
charging_pile_ids,
|
||||
</if>
|
||||
<if test="null != directNumber and directNumber !=''">
|
||||
direct_number,
|
||||
</if>
|
||||
<if test="null != communicationNumber and communicationNumber !=''">
|
||||
communication_number,
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
status,
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
del_flag,
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
update_by,
|
||||
</if>
|
||||
<if test="null != remark and '' != remark">
|
||||
remark,
|
||||
</if>
|
||||
<if test="null != tenantId and '' != tenantId">
|
||||
tenant_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != chargingStationId ">
|
||||
#{chargingStationId},
|
||||
</if>
|
||||
<if test="null != chargingPileIds and chargingPileIds !=''">
|
||||
#{chargingPileIds},
|
||||
</if>
|
||||
<if test="null != directNumber and directNumber !=''">
|
||||
#{directNumber},
|
||||
</if>
|
||||
<if test="null != communicationNumber and communicationNumber !=''">
|
||||
#{communicationNumber},
|
||||
</if>
|
||||
<if test="null != status ">
|
||||
#{status},
|
||||
</if>
|
||||
<if test="null != delFlag ">
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="null != createBy and '' != createBy">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="null != updateBy and '' != updateBy">
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="null != remark and '' != remark">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="null != tenantId and '' != tenantId">
|
||||
#{tenantId},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePileEdition">
|
||||
update xhpc_pile_edition
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="chargingStationId != null">charging_station_id = #{chargingStationId},</if>
|
||||
<if test="chargingPileIds != null and chargingPileIds !=''">charging_pile_ids = #{chargingPileIds},</if>
|
||||
<if test="directNumber != null and directNumber!=''">direct_number = #{directNumber},</if>
|
||||
<if test="communicationNumber != null and communicationNumber !=''">communication_number = #{communicationNumber},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="tenantId != null and tenantId!=''">tenant_id=#{tenantId},</if>
|
||||
</trim>
|
||||
where pile_edition_id = #{pileEditionId}
|
||||
</update>
|
||||
</mapper>
|
||||
@ -0,0 +1,38 @@
|
||||
package com.xhpc.common.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/8/30 13:47
|
||||
*/
|
||||
@Data
|
||||
public class XhpcPileEdition extends BaseEntity {
|
||||
|
||||
|
||||
private Long pileEditionId;
|
||||
|
||||
/** 电站id */
|
||||
private Long chargingStationId;
|
||||
|
||||
/** 桩id集合 */
|
||||
private String chargingPileIds;
|
||||
|
||||
/** 直流版本号 */
|
||||
private String directNumber;
|
||||
|
||||
/** 交流版本号 */
|
||||
private String communicationNumber;
|
||||
|
||||
/** 状态(0正常 1停用) */
|
||||
private Integer status;
|
||||
|
||||
/** 删除标志(0代表存在 1代表删除) */
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -88,13 +88,13 @@ public class UserTypeUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 系统用户(00 平台管理员 01 运营上 03 子账户)
|
||||
* 系统用户(00 平台管理员 01 运营上 03 子账户 04运维人员)
|
||||
*/
|
||||
public static final String SYS_USER_TYPE_ZERO = "00";
|
||||
public static final String SYS_USER_TYPE_ONE = "01";
|
||||
public static final String SYS_USER_TYPE_TWO = "02";
|
||||
public static final String SYS_USER_TYPE_THREE = "03";
|
||||
|
||||
public static final String SYS_USER_TYPE_FOUR = "04";
|
||||
|
||||
/**
|
||||
* 启动方式 微信、支付宝、刷卡
|
||||
|
||||
@ -58,14 +58,14 @@ public class XhpcStopChargingOrderController extends BaseController {
|
||||
|
||||
if(cacheMap!=null){
|
||||
if(cacheMap.get("orderkey") !=null){
|
||||
String orderkey = cacheMap.get("orderkey").toString().substring(6);
|
||||
String orderNumber = cacheMap.get("orderkey").toString().substring(6);
|
||||
String orderkey = cacheMap.get("orderkey").toString();
|
||||
|
||||
Map<String, Object> xhpcChargingPileById = xhpcChargeOrderService.getXhpcChargingPileById(chargingPileId);
|
||||
String version ="0A";
|
||||
if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){
|
||||
version=xhpcChargingPileById.get("communicationProtocolVersion").toString();
|
||||
if(cacheMap.get("version") !=null){
|
||||
version =cacheMap.get("version").toString();
|
||||
}
|
||||
R r = powerPileService.stopCharging(orderkey, orderkey.substring(0,14), orderkey.substring(0,16), version);
|
||||
R r = powerPileService.stopCharging(orderNumber, orderkey.substring(0,14), orderkey.substring(0,16), version);
|
||||
|
||||
if(r.getCode()==200){
|
||||
return AjaxResult.success("停止充电命令已下发");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user