增加卡管理员信息

This commit is contained in:
yuyang 2022-03-21 14:11:01 +08:00
parent 7ce8bd484b
commit 57411f0ff9
10 changed files with 592 additions and 4 deletions

View File

@ -0,0 +1,75 @@
package com.xhpc.card.controller;
import com.xhpc.card.domain.CardClientUser;
import com.xhpc.card.service.IXhpcCardClientUserService;
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.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/3/21 10:32
*/
@RestController
@RequestMapping("/cardClientUser")
@Api(value = "卡管理员信息", tags = "卡管理员信息")
public class XhpcCardClientUserController extends BaseController {
@Autowired
private IXhpcCardClientUserService xhpcCardClientUserService;
@GetMapping("/list")
public TableDataInfo list(String userName, Integer usersLevel,Long operatorId,String tenantId) {
List<Map<String, Object>> list = xhpcCardClientUserService.selectXhpcCardClientUserList(userName, usersLevel, operatorId, tenantId);
return getDataTable(list);
}
/**
* 添加
* @param cardClientUser
* @return
*/
@Log(title = "添加", businessType = BusinessType.INSERT)
@PostMapping(value = "/addOrUpdateXhpcCardClientUser")
public AjaxResult addOrUpdateXhpcCardClientUser(@RequestBody CardClientUser cardClientUser) {
return xhpcCardClientUserService.addOrUpdateXhpcCardClientUser(cardClientUser);
}
/**
* 获取运营商接口
*/
@GetMapping("/getoperatorList")
public AjaxResult getoperatorList(String tenantId) {
return xhpcCardClientUserService.getoperatorList(tenantId);
}
/**
* 获取运营商接口
*/
@GetMapping("/getXhpcCardClientUserById")
public AjaxResult getXhpcCardClientUserById(Integer usersID) {
return AjaxResult.success(xhpcCardClientUserService.getXhpcCardClientUserById(usersID));
}
/**
* 修改状态
*/
@GetMapping("/getXhpcCardClientUserStatus")
public AjaxResult getXhpcCardClientUserStatus(Integer usersID,Integer status) {
return xhpcCardClientUserService.getXhpcCardClientUserStatus(usersID,status);
}
}

View File

@ -0,0 +1,65 @@
package com.xhpc.card.domain;
import lombok.Data;
/**
* @author yuyang
* @date 2022/3/21 10:02
*/
@Data
public class CardClientUser {
/**
*
*/
private Integer usersID;
/**
*命名规则:字母数字组合
*/
private String usersName;
/**
*用户密码
*/
private String usersPwd;
/**
*用户电话
*/
private String usersPhone;
/**
*用户Email
*/
private String usersEmail;
/**
*用户地址
*/
private String usersAdress;
/**
*用户级别 3.运营商管理员 4.平台管理员
*/
private Integer usersLevel;
/**
*所属运营商id,对应xhpc_operator.operator_id
*/
private String usersCorp;
/**
*所属运营商前缀
*/
private String corpNo;
/**
*所属运营商名称
*/
private String corpName;
/**
*添加日期
*/
private String usersTime;
/**
*租户id
*/
private String tenantId;
/**
*逻辑删除字段0存在1为删除
*/
private Integer delFlag;
}

View File

@ -0,0 +1,44 @@
package com.xhpc.card.mapper;
import com.xhpc.card.domain.CardClientUser;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcRateModel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/3/21 9:59
*/
public interface IXhpcCardClientUserMapper {
List<Map<String, Object>> selectXhpcCardClientUserList(@Param("userName") String userName, @Param("usersLevel")Integer usersLevel, @Param("operatorId")Long operatorId,@Param("tenantId") String tenantId,@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId);
/**
* 添加费率模型
*/
int insertXhpcCardClientUser(CardClientUser cardClientUser);
/**
* 添加费率模型
*/
int updateXhpcCardClientUser(CardClientUser cardClientUser);
/**
* 获取运营商接口
* @param tenantId
* @return
*/
List<Map<String, Object>> getoperatorList(String tenantId);
/**
* 列表
* @param usersID 用户Id
* @return
*/
Map<String, Object> getXhpcCardClientUserById(@Param("type")Integer type,@Param("usersID") Integer usersID,@Param("usersName")String usersName);
}

View File

@ -0,0 +1,55 @@
package com.xhpc.card.service;
import com.xhpc.card.domain.CardClientUser;
import com.xhpc.common.api.dto.XhpcChargingStationDto;
import com.xhpc.common.core.web.domain.AjaxResult;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/3/21 9:45
*/
public interface IXhpcCardClientUserService {
/**
* 列表
* @param userName 用户名称
* @param usersLevel 用户级别
* @param operatorId 运营商id
* @param tenantId 租户id
* @return
*/
List<Map<String, Object>> selectXhpcCardClientUserList(String userName, Integer usersLevel,Long operatorId,String tenantId);
/**
* 添加
* @param cardClientUser
* @return
*/
AjaxResult addOrUpdateXhpcCardClientUser(CardClientUser cardClientUser);
/**
* 获取运营商接口
* @param tenantId 租户id
* @return
*/
AjaxResult getoperatorList(String tenantId);
/**
* 详情
* @param usersID 用户Id
* @return
*/
Map<String, Object> getXhpcCardClientUserById(Integer usersID);
/**
* 获取运营商接口
* @param tenantId 租户id
* @return
*/
AjaxResult getXhpcCardClientUserStatus(Integer usersID,Integer status);
}

View File

@ -0,0 +1,153 @@
package com.xhpc.card.service.impl;
import com.xhpc.card.domain.CardClientUser;
import com.xhpc.card.mapper.IXhpcCardClientUserMapper;
import com.xhpc.card.service.IXhpcCardClientUserService;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.naming.ldap.PagedResultsControl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
* @date 2022/3/21 9:46
*/
@Service
public class XhpcCardClientUserServiceImpl extends BaseService implements IXhpcCardClientUserService {
@Autowired
private TokenService tokenService;
@Autowired
private IXhpcCardClientUserMapper xhpcCardClientUserMapper;
@Override
public List<Map<String, Object>> selectXhpcCardClientUserList(String userName, Integer usersLevel, Long operatorId, String tenantId) {
LoginUser loginUser = tokenService.getLoginUser();
String loginUserTenantId = loginUser.getTenantId();
Long logUserId = loginUser.getUserid();
SysUser sysUser = loginUser.getSysUser();
List<Map<String, Object>> list = new ArrayList<>();
startPage();
if (logUserId != UserTypeUtil.USER_ID) {
Long logOperatorId = sysUser.getOperatorId();
if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())) {
//运营商看自己的场站
list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,1,logOperatorId);
} else {
//查询赋值的场站
list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,2,logOperatorId);
}
}else{
list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,0,null);
}
return list;
}
/**
* 添加
*
* @param cardClientUser
* @return
*/
@Override
public AjaxResult addOrUpdateXhpcCardClientUser(CardClientUser cardClientUser) {
if(cardClientUser.getUsersName() ==null || "".equals(cardClientUser.getUsersName())){
return AjaxResult.error("用户名称为空");
}
if(cardClientUser.getUsersID()==null){
Map<String, Object> xhpcCardClientUserById = xhpcCardClientUserMapper.getXhpcCardClientUserById(1,null, cardClientUser.getUsersName());
if(xhpcCardClientUserById !=null &&( false ==(boolean)xhpcCardClientUserById.get("delFlag") || "0".equals(xhpcCardClientUserById.get("delFlag").toString()))){
return AjaxResult.error("用户名称已存在");
}
}else{
Map<String, Object> xhpcCardClientUserById = xhpcCardClientUserMapper.getXhpcCardClientUserById(1,cardClientUser.getUsersID(), cardClientUser.getUsersName());
if(xhpcCardClientUserById !=null &&( false ==(boolean)xhpcCardClientUserById.get("delFlag") || "0".equals(xhpcCardClientUserById.get("delFlag").toString()))){
return AjaxResult.error("用户名称已存在");
}
}
if(cardClientUser.getUsersPwd() ==null || "".equals(cardClientUser.getUsersPwd())){
return AjaxResult.error("用户密码为空");
}
if(cardClientUser.getTenantId() ==null || "".equals(cardClientUser.getTenantId())){
return AjaxResult.error("租户为空");
}
if(cardClientUser.getUsersLevel() ==null){
return AjaxResult.error("级别为空");
}else{
// if(cardClientUser.getUsersLevel() ==3){
// if(cardClientUser.getCorpNo() ==null || "".equals(cardClientUser.getCorpNo())){
// return AjaxResult.error("运营商为空");
// }
// }
}
if(cardClientUser.getCorpNo() ==null || "".equals(cardClientUser.getCorpNo())){
return AjaxResult.error("运营商为空");
}
if(cardClientUser.getUsersID()==null){
int i = xhpcCardClientUserMapper.insertXhpcCardClientUser(cardClientUser);
if(i==0){
return AjaxResult.error("添加失败");
}
}else{
int i = xhpcCardClientUserMapper.updateXhpcCardClientUser(cardClientUser);
if(i==0){
return AjaxResult.error("添加失败");
}
}
return AjaxResult.success();
}
/**
* 获取运营商接口
*
* @param tenantId 租户id
* @return
*/
@Override
public AjaxResult getoperatorList(String tenantId) {
return AjaxResult.success(xhpcCardClientUserMapper.getoperatorList(tenantId));
}
/**
* 详情
*
* @param usersID 用户Id
* @return
*/
@Override
public Map<String, Object> getXhpcCardClientUserById(Integer usersID) {
return xhpcCardClientUserMapper.getXhpcCardClientUserById(0,usersID,null);
}
/**
* 获取运营商接口
*
* @param usersID
* @param status
* @return
*/
@Override
public AjaxResult getXhpcCardClientUserStatus(Integer usersID, Integer status) {
CardClientUser cardClientUser =new CardClientUser();
cardClientUser.setUsersID(usersID);
cardClientUser.setDelFlag(status);
int i = xhpcCardClientUserMapper.updateXhpcCardClientUser(cardClientUser);
if(i==0){
return AjaxResult.error("状态改变失败");
}else{
return AjaxResult.error("状态改变成功");
}
}
}

View File

@ -605,7 +605,9 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
Integer operatorId = tIccardLog.getOperatorid();
XhpcOperator operator = xhpcOperatorMapper.selectByPrimaryKey(Long.valueOf(operatorId));
dataDTO.setOperatorName(operator.getName());
dataDTO.setOperateTime(MyDateUtil.parseDateToStr(tIccardLog.getCreatetime()));
if(tIccardLog.getCreatetime() !=null){
dataDTO.setOperateTime(MyDateUtil.parseDateToStr(tIccardLog.getCreatetime()));
}
operateDevicesLogResponse.getData().add(dataDTO);
}
return R.ok(operateDevicesLogResponse);

View File

@ -0,0 +1,193 @@
<?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.card.mapper.IXhpcCardClientUserMapper">
<resultMap id="BaseResultMap" type="com.xhpc.card.domain.CardClientUser">
<id column="usersID" jdbcType="INTEGER" property="usersID"/>
<result column="usersName" jdbcType="VARCHAR" property="usersName"/>
<result column="usersPwd" jdbcType="VARCHAR" property="usersPwd"/>
<result column="usersPhone" jdbcType="VARCHAR" property="usersPhone"/>
<result column="usersEmail" jdbcType="VARCHAR" property="usersEmail"/>
<result column="usersAdress" jdbcType="VARCHAR" property="usersAdress"/>
<result column="usersLevel" jdbcType="INTEGER" property="usersLevel"/>
<result column="usersCorp" jdbcType="VARCHAR" property="usersCorp"/>
<result column="corpNo" jdbcType="VARCHAR" property="corpNo"/>
<result column="corpName" jdbcType="VARCHAR" property="corpName"/>
<result column="usersTime" jdbcType="DATE" property="usersTime"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
</resultMap>
<select id="selectXhpcCardClientUserList" resultType="map">
select
ccu.usersID as usersID,
ccu.usersName as usersName,
ccu.usersLevel as usersLevel,
ope.name as operatorName,
ope.corp_no as corpNo,
ccu.tenant_id as tenantId,
ccu.usersTime as usersTime
from t_iccard_client_users ccu
join xhpc_operator ope on ope.corp_no = ccu.corpNo
where ccu.del_flag=0
<if test="userName !=null and userName !=''">
and ccu.usersName like concat('%', #{userName}, '%')
</if>
<if test="usersLevel !=null">
and ccu.usersLevel =#{usersLevel}
</if>
<if test="operatorId !=null">
and ope.operator_id =#{operatorId}
</if>
<if test="tenantId !=null and tenantId !=''">
and ccu.tenant_id =#{tenantId}
</if>
<if test="status!=0">
and ope.operator_id =#{logOperatorId}
</if>
order by ccu.usersTime desc
</select>
<insert id="insertXhpcCardClientUser">
insert into t_iccard_client_users
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != usersName and ''!=usersName">
usersName,
</if>
<if test="null != usersPwd and ''!=usersPwd">
usersPwd,
</if>
<if test="null != usersPhone and ''!=usersPhone">
usersPhone,
</if>
<if test="null != usersAdress and ''!=usersAdress">
usersAdress,
</if>
<if test="null != usersLevel">
usersLevel,
</if>
<if test="null != usersCorp ">
usersCorp,
</if>
<if test="null != corpNo and '' != corpNo">
corpNo,
</if>
<if test="null != corpName and ''!=corpName ">
corpName,
</if>
<if test="null != usersTime">
usersTime,
</if>
<if test="null != tenantId and '' != tenantId">
tenant_id
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != usersName and ''!=usersName">
#{usersName},
</if>
<if test="null != usersPwd and ''!=usersPwd">
#{usersPwd},
</if>
<if test="null != usersPhone and ''!=usersPhone">
#{usersPhone},
</if>
<if test="null != usersAdress and ''!=usersAdress">
#{usersAdress},
</if>
<if test="null != usersLevel">
#{usersLevel},
</if>
<if test="null != usersCorp ">
#{usersCorp},
</if>
<if test="null != corpNo and '' != corpNo">
#{corpNo},
</if>
<if test="null != corpName and ''!=corpName ">
#{corpNameand},
</if>
<if test="null != usersTime">
#{usersTime},
</if>
<if test="null != tenantId and '' != tenantId">
#{tenantId}
</if>
</trim>
</insert>
<select id="getoperatorList" resultType="map">
select
corp_no as corpNo,
name as name
from xhpc_operator where tenant_id=#{tenantId} and del_flag =0
</select>
<select id="getXhpcCardClientUserById" resultType="map">
select
ccu.usersID as usersID,
ccu.usersName as usersName,
ccu.usersName as usersPhone,
ccu.usersName as usersEmail,
ccu.usersName as usersAdress,
ccu.usersLevel as usersLevel,
ope.name as operatorName,
ope.corp_no as corpNo,
ccu.tenant_id as tenantId,
ccu.del_flag as delFlag,
ccu.usersTime as usersTime
from t_iccard_client_users ccu
join xhpc_operator ope on ope.corp_no = ccu.corpNo
where 1=1
<if test="type==0">
<if test="usersID !=null">
and ccu.usersID=#{usersID}
</if>
</if>
<if test="type==1">
<if test="usersID !=null">
and ccu.usersID !=#{usersID}
</if>
</if>
<if test="null != usersName and ''!=usersName">
and ccu.usersName=#{usersName}
</if>
</select>
<update id="updateXhpcCardClientUser" >
update t_iccard_client_users
<trim prefix="SET" suffixOverrides=",">
<if test="null != usersName and ''!=usersName">
usersName= #{usersName},
</if>
<if test="null != usersPwd and ''!=usersPwd">
usersPwd= #{usersPwd},
</if>
<if test="null != usersPhone and ''!=usersPhone">
usersPhone= #{usersPhone},
</if>
<if test="null != usersAdress and ''!=usersAdress">
usersAdress=#{usersAdress},
</if>
<if test="null != usersLevel">
usersLevel=#{usersLevel},
</if>
<if test="null != usersCorp ">
usersCorp=#{usersCorp},
</if>
<if test="null != corpNo and '' != corpNo">
corpNo= #{corpNo},
</if>
<if test="null != corpName and ''!=corpName ">
corpName= #{corpNameand},
</if>
<if test="null != usersTime">
usersTime=#{usersTime},
</if>
<if test="null != tenantId and '' != tenantId">
tenant_id= #{tenantId}
</if>
</trim>
where usersID = #{usersID}
</update>
</mapper>

View File

@ -73,6 +73,7 @@
<if test="logEndTime!=null and logEndTime!='' ">
AND createTime &lt;= #{logEndTime}
</if>
order by createTime desc
limit #{currentPage},#{items}
</select>
<select id="selectCountOfDeviceLogListByCondition" resultType="java.lang.Long">

View File

@ -88,7 +88,7 @@
<where>
del_flag IS NULL
<if test="creator!=null and creator!='' ">
and creator = #{creator}
and creator like concat('%', #{creator}, '%')
</if>
<if test="creatorType!=null">
and creator_type = #{creatorType}

View File

@ -232,7 +232,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
if (landUser != null) {
if (landUser.get("userType") != null) {
startPage();
if ("01".equals(landUser.get("userType").toString())) {
if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(landUser.get("userType").toString())) {
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
//运营商看自己的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult,tenantId);
@ -277,7 +277,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
Map<String, Object> landUser = xhpcHistoryOrderMapper.getLandUser(logUserId);
if (landUser != null) {
if (landUser.get("userType") != null) {
if ("01".equals(landUser.get("userType").toString())) {
if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(landUser.get("userType").toString())) {
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
//运营商看自己的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult,tenantId);