完成刷卡系统查询卡授权设备列表接口

This commit is contained in:
wen 2022-01-25 17:39:13 +08:00
parent 4f2f3b0d15
commit c060b74622
10 changed files with 546 additions and 18 deletions

View File

@ -1,20 +1,16 @@
package com.xhpc.card.controller;
import com.xhpc.card.domain.ListOfAuthorizedDevices;
import com.xhpc.card.service.IXhpcCardService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author yuyang
* @date 2022/1/20 11:33
@ -27,8 +23,6 @@ public class XhpcCardController extends BaseController {
@Autowired
private IXhpcCardService xhpcCardService;
private static final Logger logger = LoggerFactory.getLogger(XhpcCardController.class);
/**
* 卡启动前判断
* @param cardno 卡物理卡号
@ -36,9 +30,18 @@ public class XhpcCardController extends BaseController {
* @return
*/
@GetMapping("/cardStartup")
public R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber){
public R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber) {
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>");
return xhpcCardService.cardStartup(cardno, serialNumber);
}
@GetMapping("/devices")
public R<ListOfAuthorizedDevices> queryDeviceList() {
return xhpcCardService.queryDeviceList();
}
}

View File

@ -0,0 +1,62 @@
package com.xhpc.card.domain;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 卡授权设备列表包装类
*
* @author WH
* @date 2022/1/25 16:21
* @since version-1.0
*/
@NoArgsConstructor
@Data
public class ListOfAuthorizedDevices {
/**
* totalItems
*/
@JsonProperty("totalItems")
private Integer totalItems;
/**
* data
*/
@JsonProperty("data")
private List<DataDTO> data;
/**
* DataDTO
*/
@NoArgsConstructor
@Data
public static class DataDTO {
/**
* deviceNumber
*/
@JsonProperty("deviceNumber")
private String deviceNumber;
/**
* deviceName
*/
@JsonProperty("deviceName")
private String deviceName;
/**
* deviceType
*/
@JsonProperty("deviceType")
private String deviceType;
/**
* grantOperator
*/
@JsonProperty("grantOperator")
private String grantOperator;
}
}

View File

@ -0,0 +1,30 @@
package com.xhpc.card.mapper;
import com.xhpc.card.pojo.TIccardDevice;
import java.util.List;
public interface TIccardDeviceMapper {
int deleteByPrimaryKey(Integer id);
int insert(TIccardDevice record);
int insertSelective(TIccardDevice record);
TIccardDevice selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TIccardDevice record);
int updateByPrimaryKey(TIccardDevice record);
/**
* 查询所有记录
*
* @author WH
* @date 2022/1/25 17:07
* @since version-1.0
*/
List<TIccardDevice> selectAll();
}

View File

@ -0,0 +1,19 @@
package com.xhpc.card.mapper;
import com.xhpc.card.pojo.TIccardUsers;
public interface TIccardUsersMapper {
int deleteByPrimaryKey(Integer id);
int insert(TIccardUsers record);
int insertSelective(TIccardUsers record);
TIccardUsers selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TIccardUsers record);
int updateByPrimaryKey(TIccardUsers record);
}

View File

@ -0,0 +1,50 @@
package com.xhpc.card.pojo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* t_iccard_device
*
* @author WH
*/
@Data
public class TIccardDevice implements Serializable {
private Integer id;
/**
* 设备名称
*/
private String devname;
/**
* 设备型号
*/
private String devtype;
/**
* 卡读写器全球唯一编号
*/
private String serialnumber;
/**
* 企业索引
*/
private Integer corpindex;
/**
* 添加日期
*/
private Date createtime;
/**
* 租户id
*/
private String tenantId;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,60 @@
package com.xhpc.card.pojo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* t_iccard_users
*
* @author
*/
@Data
public class TIccardUsers implements Serializable {
private Integer id;
/**
* 用户姓名
*/
private String username;
/**
* 年龄
*/
private Byte userage;
/**
* 性别
*/
private Byte usersex;
/**
* 身份证号码
*/
private String idnumber;
/**
* 电话号码
*/
private String phone;
/**
* 车牌号码
*/
private String licenceplate;
/**
* 添加日期
*/
private Date createtime;
/**
* 租户id
*/
private String tenantId;
private static final long serialVersionUID = 1L;
}

View File

@ -1,5 +1,6 @@
package com.xhpc.card.service;
import com.xhpc.card.domain.ListOfAuthorizedDevices;
import com.xhpc.common.core.domain.R;
/**
@ -10,9 +11,21 @@ public interface IXhpcCardService {
/**
* 卡启动充电判断
* @param cardno 卡物理卡号
* @param serialNumber 终端卡号
*
* @param cardno 卡物理卡号
* @param serialNumber 终端卡号
* @return
*/
R cardStartup(String cardno,String serialNumber);
R cardStartup(String cardno, String serialNumber);
/**
* 查询卡授权列表
*
* @return 返回卡授权列表
* @author WH
* @date 2022/1/25 16:18
* @since version-1.0
*/
R<ListOfAuthorizedDevices> queryDeviceList();
}

View File

@ -1,6 +1,11 @@
package com.xhpc.card.service.impl;
import com.xhpc.card.domain.ListOfAuthorizedDevices;
import com.xhpc.card.mapper.TIccardDeviceMapper;
import com.xhpc.card.mapper.TIccardUsersMapper;
import com.xhpc.card.mapper.XhpcCardMapper;
import com.xhpc.card.pojo.TIccardDevice;
import com.xhpc.card.pojo.TIccardUsers;
import com.xhpc.card.service.IXhpcCardService;
import com.xhpc.common.api.CardHistoryOrderService;
import com.xhpc.common.core.constant.Constants;
@ -10,6 +15,10 @@ import com.xhpc.common.domain.XhpcIcCardInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @author yuyang
* @date 2022/1/20 13:44
@ -22,6 +31,10 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
@Autowired
private CardHistoryOrderService cardHistoryOrderService;
@Resource
private TIccardDeviceMapper tIccardDeviceMapper;
@Resource
private TIccardUsersMapper tIccardUsersMapper;
/**
@ -56,14 +69,36 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
}
//查询卡号对应的用户
XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString());
if(xhpcIcCardInfo ==null){
if (xhpcIcCardInfo == null) {
return R.fail(Constants.LNVALID_USER);
}
Long userId=xhpcIcCardInfo.getUserId();
Integer userType=xhpcIcCardInfo.getUserType();
String tenantId=xhpcIcCardInfo.getTenantId();
Integer type =1;
String grantOperator=xhpcIcCardInfo.getGrantOperatorId();
return cardHistoryOrderService.cardStartup(userId, serialNumber, userType,tenantId,type,grantOperator);
Long userId = xhpcIcCardInfo.getUserId();
Integer userType = xhpcIcCardInfo.getUserType();
String tenantId = xhpcIcCardInfo.getTenantId();
Integer type = 1;
String grantOperator = xhpcIcCardInfo.getGrantOperatorId();
return cardHistoryOrderService.cardStartup(userId, serialNumber, userType, tenantId, type, grantOperator);
}
@Override
public R<ListOfAuthorizedDevices> queryDeviceList() {
ListOfAuthorizedDevices listOfAuthorizedDevices = new ListOfAuthorizedDevices();
listOfAuthorizedDevices.setData(new ArrayList<>());
listOfAuthorizedDevices.setTotalItems(0);
List<TIccardDevice> tIccardDeviceList = tIccardDeviceMapper.selectAll();
if (tIccardDeviceList.isEmpty()) {
return R.ok(listOfAuthorizedDevices);
}
for (TIccardDevice tIccardDevice : tIccardDeviceList) {
ListOfAuthorizedDevices.DataDTO dataDTO = new ListOfAuthorizedDevices.DataDTO();
dataDTO.setDeviceName(tIccardDevice.getDevname());
dataDTO.setDeviceType(tIccardDevice.getDevtype());
dataDTO.setDeviceNumber(tIccardDevice.getSerialnumber());
TIccardUsers tIccardUser = tIccardUsersMapper.selectByPrimaryKey(tIccardDevice.getCorpindex());
dataDTO.setGrantOperator(tIccardUser.getUsername());
}
return R.ok(listOfAuthorizedDevices);
}
}

View File

@ -0,0 +1,119 @@
<?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">
<!--suppress ALL -->
<mapper namespace="com.xhpc.card.mapper.TIccardDeviceMapper">
<resultMap id="BaseResultMap" type="com.xhpc.card.pojo.TIccardDevice">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="devName" jdbcType="VARCHAR" property="devname"/>
<result column="devType" jdbcType="VARCHAR" property="devtype"/>
<result column="serialNumber" jdbcType="VARCHAR" property="serialnumber"/>
<result column="corpIndex" jdbcType="INTEGER" property="corpindex"/>
<result column="createTime" jdbcType="TIMESTAMP" property="createtime"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
</resultMap>
<sql id="Base_Column_List">
id
, devName, devType, serialNumber, corpIndex, createTime, tenant_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_iccard_device
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_iccard_device
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from t_iccard_device
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardDevice"
useGeneratedKeys="true">
insert into t_iccard_device (devName, devType, serialNumber,
corpIndex, createTime, tenant_id)
values (#{devname,jdbcType=VARCHAR}, #{devtype,jdbcType=VARCHAR}, #{serialnumber,jdbcType=VARCHAR},
#{corpindex,jdbcType=INTEGER}, #{createtime,jdbcType=TIMESTAMP}, #{tenantId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardDevice"
useGeneratedKeys="true">
insert into t_iccard_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="devname != null">
devName,
</if>
<if test="devtype != null">
devType,
</if>
<if test="serialnumber != null">
serialNumber,
</if>
<if test="corpindex != null">
corpIndex,
</if>
<if test="createtime != null">
createTime,
</if>
<if test="tenantId != null">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="devname != null">
#{devname,jdbcType=VARCHAR},
</if>
<if test="devtype != null">
#{devtype,jdbcType=VARCHAR},
</if>
<if test="serialnumber != null">
#{serialnumber,jdbcType=VARCHAR},
</if>
<if test="corpindex != null">
#{corpindex,jdbcType=INTEGER},
</if>
<if test="createtime != null">
#{createtime,jdbcType=TIMESTAMP},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.TIccardDevice">
update t_iccard_device
<set>
<if test="devname != null">
devName = #{devname,jdbcType=VARCHAR},
</if>
<if test="devtype != null">
devType = #{devtype,jdbcType=VARCHAR},
</if>
<if test="serialnumber != null">
serialNumber = #{serialnumber,jdbcType=VARCHAR},
</if>
<if test="corpindex != null">
corpIndex = #{corpindex,jdbcType=INTEGER},
</if>
<if test="createtime != null">
createTime = #{createtime,jdbcType=TIMESTAMP},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.TIccardDevice">
update t_iccard_device
set devName = #{devname,jdbcType=VARCHAR},
devType = #{devtype,jdbcType=VARCHAR},
serialNumber = #{serialnumber,jdbcType=VARCHAR},
corpIndex = #{corpindex,jdbcType=INTEGER},
createTime = #{createtime,jdbcType=TIMESTAMP},
tenant_id = #{tenantId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,137 @@
<?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.TIccardUsersMapper">
<resultMap id="BaseResultMap" type="com.xhpc.card.pojo.TIccardUsers">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="userName" jdbcType="VARCHAR" property="username"/>
<result column="userAge" jdbcType="TINYINT" property="userage"/>
<result column="userSex" jdbcType="TINYINT" property="usersex"/>
<result column="idNumber" jdbcType="VARCHAR" property="idnumber"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="licencePlate" jdbcType="VARCHAR" property="licenceplate"/>
<result column="createTime" jdbcType="TIMESTAMP" property="createtime"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
</resultMap>
<sql id="Base_Column_List">
id
, userName, userAge, userSex, idNumber, phone, licencePlate, createTime, tenant_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_iccard_users
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from t_iccard_users
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardUsers"
useGeneratedKeys="true">
insert into t_iccard_users (userName, userAge, userSex,
idNumber, phone, licencePlate,
createTime, tenant_id)
values (#{username,jdbcType=VARCHAR}, #{userage,jdbcType=TINYINT}, #{usersex,jdbcType=TINYINT},
#{idnumber,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{licenceplate,jdbcType=VARCHAR},
#{createtime,jdbcType=TIMESTAMP}, #{tenantId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardUsers"
useGeneratedKeys="true">
insert into t_iccard_users
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="username != null">
userName,
</if>
<if test="userage != null">
userAge,
</if>
<if test="usersex != null">
userSex,
</if>
<if test="idnumber != null">
idNumber,
</if>
<if test="phone != null">
phone,
</if>
<if test="licenceplate != null">
licencePlate,
</if>
<if test="createtime != null">
createTime,
</if>
<if test="tenantId != null">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="userage != null">
#{userage,jdbcType=TINYINT},
</if>
<if test="usersex != null">
#{usersex,jdbcType=TINYINT},
</if>
<if test="idnumber != null">
#{idnumber,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="licenceplate != null">
#{licenceplate,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
#{createtime,jdbcType=TIMESTAMP},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.TIccardUsers">
update t_iccard_users
<set>
<if test="username != null">
userName = #{username,jdbcType=VARCHAR},
</if>
<if test="userage != null">
userAge = #{userage,jdbcType=TINYINT},
</if>
<if test="usersex != null">
userSex = #{usersex,jdbcType=TINYINT},
</if>
<if test="idnumber != null">
idNumber = #{idnumber,jdbcType=VARCHAR},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="licenceplate != null">
licencePlate = #{licenceplate,jdbcType=VARCHAR},
</if>
<if test="createtime != null">
createTime = #{createtime,jdbcType=TIMESTAMP},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.TIccardUsers">
update t_iccard_users
set userName = #{username,jdbcType=VARCHAR},
userAge = #{userage,jdbcType=TINYINT},
userSex = #{usersex,jdbcType=TINYINT},
idNumber = #{idnumber,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
licencePlate = #{licenceplate,jdbcType=VARCHAR},
createTime = #{createtime,jdbcType=TIMESTAMP},
tenant_id = #{tenantId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>