车辆出入记录

This commit is contained in:
cwchen 2024-04-18 11:30:39 +08:00
parent f265bcbdd6
commit 9016d980e9
10 changed files with 112 additions and 9 deletions

View File

@ -78,6 +78,7 @@ public class Constant {
public final static String PERSON_CAR_TYPE = "1907"; public final static String PERSON_CAR_TYPE = "1907";
/**人员闸机检测名称*/ /**人员闸机检测名称*/
public final static String PERSON = "绑定人"; public final static String PERSON = "绑定人";
public final static String CAR = "车牌号";
public final static String ACCESS_TIME = "出入时间"; public final static String ACCESS_TIME = "出入时间";
public final static String ACCESS_TYPE = "出入类型"; public final static String ACCESS_TYPE = "出入类型";

View File

@ -67,4 +67,7 @@ public class ParamDto {
@ApiModelProperty(value = "检测名称") @ApiModelProperty(value = "检测名称")
private String modeName; private String modeName;
@ApiModelProperty(value = "身份证号")
private String idNumber;
} }

View File

@ -53,5 +53,11 @@ public class VehicleVo {
private String startDate; private String startDate;
private String endDate; private String endDate;
private String typeCode;
private String modeName;
private String value;
} }

View File

@ -6,6 +6,7 @@ import com.securitycontrol.entity.background.vo.UserAccessVo;
import com.securitycontrol.entity.system.vo.ResourceFileVo; import com.securitycontrol.entity.system.vo.ResourceFileVo;
import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -167,6 +168,7 @@ public interface HumanManageMapper {
/** /**
* 获取人员出入场记录 * 获取人员出入场记录
*
* @param value * @param value
* @return String * @return String
* @description * @description
@ -174,4 +176,16 @@ public interface HumanManageMapper {
* @date 2024/4/3 17:44 * @date 2024/4/3 17:44
*/ */
String getUserAccessLists(String value); String getUserAccessLists(String value);
/**
* 获取人员入场 离场状态
* @param userId
* @param accessType
* @param type
* @return String
* @description
* @author cwchen
* @date 2024/4/18 10:13
*/
String getUserAccessStatus(@Param("userId") String userId, @Param("accessType") String accessType, @Param("type") int type);
} }

View File

@ -8,12 +8,14 @@ import java.util.List;
/** /**
* 车辆管理 * 车辆管理
*
* @author 黑子 * @author 黑子
*/ */
@Repository(value = "VehicleMapper") @Repository(value = "VehicleMapper")
public interface VehicleMapper { public interface VehicleMapper {
/** /**
* 获取车辆 * 获取车辆
*
* @param dto * @param dto
* @return * @return
*/ */
@ -21,18 +23,21 @@ public interface VehicleMapper {
/** /**
* 新增/修改车辆 * 新增/修改车辆
*
* @param vo * @param vo
*/ */
void addOrUpdateVehicle(VehicleVo vo); void addOrUpdateVehicle(VehicleVo vo);
/** /**
* 删除车辆 * 删除车辆
*
* @param dto * @param dto
*/ */
void delVehicleById(VehicleVo dto); void delVehicleById(VehicleVo dto);
/** /**
* 查询集合 * 查询集合
*
* @param dto * @param dto
* @return * @return
*/ */
@ -40,8 +45,19 @@ public interface VehicleMapper {
/** /**
* 查询集合 * 查询集合
*
* @param dto * @param dto
* @return * @return
*/ */
List<VehicleDto> getListsDto(VehicleDto dto); List<VehicleDto> getListsDto(VehicleDto dto);
/**
* 获取车辆入场 离场状态
* @param value
* @return String
* @description
* @author cwchen
* @date 2024/4/18 11:00
*/
String getCarAccessLists(String value);
} }

View File

@ -105,6 +105,8 @@ public class AppServiceImpl implements IAppService {
if (StringUtils.isNotEmpty(data)) { if (StringUtils.isNotEmpty(data)) {
String value = mapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2); String value = mapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2);
vo.setStatus(StringUtils.isEmpty(value) ? "离场" : value); vo.setStatus(StringUtils.isEmpty(value) ? "离场" : value);
}else{
vo.setStatus("离场");
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -134,6 +136,8 @@ public class AppServiceImpl implements IAppService {
if (StringUtils.isNotEmpty(data)) { if (StringUtils.isNotEmpty(data)) {
String value = mapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2); String value = mapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2);
vo.setAccessType(StringUtils.isEmpty(value) ? "离场" : value); vo.setAccessType(StringUtils.isEmpty(value) ? "离场" : value);
}else{
vo.setAccessType("离场");
} }
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -54,6 +54,15 @@ public class HumanServiceImpl implements HumanService {
List<HumanManageVo> list = new ArrayList<>(); List<HumanManageVo> list = new ArrayList<>();
try { try {
list = mapper.getHumanLists(dto); list = mapper.getHumanLists(dto);
for (HumanManageVo vo : list) {
String data = mapper.getUserAccessStatus(vo.getUserId(), Constant.ACCESS_TYPE, 1);
if (StringUtils.isNotEmpty(data)) {
String value = mapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2);
vo.setStatus(StringUtils.isEmpty(value) ? "离场" : value);
}else{
vo.setStatus("离场");
}
}
} catch (Exception e) { } catch (Exception e) {
log.error("获取人员列表",e); log.error("获取人员列表",e);
} }
@ -253,12 +262,12 @@ public class HumanServiceImpl implements HumanService {
try { try {
dto.setTypeCode(Constant.PERSON_CAR_TYPE); dto.setTypeCode(Constant.PERSON_CAR_TYPE);
dto.setModeName(Constant.PERSON); dto.setModeName(Constant.PERSON);
list = mapper.getPersonnelAccessLists(dto);
UserAccessVo userDetail = mapper.getUserDeatail(dto); UserAccessVo userDetail = mapper.getUserDeatail(dto);
String decryptIdNumber = AesCbcUtils.decrypt(userDetail.getIdNumber()); String decryptIdNumber = AesCbcUtils.decrypt(userDetail.getIdNumber());
if(decryptIdNumber != null){ if(decryptIdNumber != null){
userDetail.setIdNumber(decryptIdNumber); userDetail.setIdNumber(decryptIdNumber);
} }
list = mapper.getPersonnelAccessLists(dto);
for (UserAccessVo vo : list) { for (UserAccessVo vo : list) {
String value = vo.getValue(); String value = vo.getValue();
vo.setIdNumber(userDetail.getIdNumber()); vo.setIdNumber(userDetail.getIdNumber());

View File

@ -3,8 +3,11 @@ package com.securitycontrol.background.service.impl;
import com.securitycontrol.background.mapper.VehicleMapper; import com.securitycontrol.background.mapper.VehicleMapper;
import com.securitycontrol.background.service.VehicleService; import com.securitycontrol.background.service.VehicleService;
import com.securitycontrol.common.core.constant.Constant;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.utils.uuid.IdUtils; import com.securitycontrol.common.core.utils.uuid.IdUtils;
import com.securitycontrol.entity.background.dto.VehicleDto; import com.securitycontrol.entity.background.dto.VehicleDto;
import com.securitycontrol.entity.background.vo.UserAccessVo;
import com.securitycontrol.entity.background.vo.VehicleVo; import com.securitycontrol.entity.background.vo.VehicleVo;
import com.securitycontrol.common.core.utils.StringUtils; import com.securitycontrol.common.core.utils.StringUtils;
@ -98,15 +101,40 @@ public class VehicleServiceImpl implements VehicleService {
String[] arr = date.split("@"); String[] arr = date.split("@");
dto.setStartDate(arr[0]); dto.setStartDate(arr[0]);
dto.setEndDate(arr[1]); dto.setEndDate(arr[1]);
}else{
dto.setStartDate(DateTimeHelper.getNowDate());
dto.setEndDate(DateTimeHelper.getNowDate());
} }
try { try {
dto.setTypeCode(Constant.PERSON_CAR_TYPE);
dto.setModeName(Constant.CAR);
list = mapper.getLists(dto); list = mapper.getLists(dto);
for (VehicleVo vo : list) {
String value = vo.getValue();
String data = mapper.getCarAccessLists(value);
if(StringUtils.isNotEmpty(data)){
String[] dataArr = data.split(",");
setCarAccessData(vo,dataArr);
}
}
} catch (Exception e) { } catch (Exception e) {
log.error("获取进出场记录列表",e); log.error("获取进出场记录列表",e);
} }
return list; return list;
} }
public VehicleVo setCarAccessData(VehicleVo vo,String[] valArr){
for (String str : valArr) {
String[] splitStr = str.split("@");
if(Objects.equals(splitStr[0],Constant.ACCESS_TIME)){
vo.setAccesssTime(splitStr[1]);
}else if(Objects.equals(splitStr[0],Constant.ACCESS_TYPE)){
vo.setAccessType(splitStr[1]);
}
}
return vo;
}
@Override @Override
public List<VehicleDto> getListsDto(VehicleDto dto) { public List<VehicleDto> getListsDto(VehicleDto dto) {
List<VehicleDto> list = new ArrayList<>(); List<VehicleDto> list = new ArrayList<>();

View File

@ -157,7 +157,7 @@
SELECT thdv.source_type AS value SELECT thdv.source_type AS value
FROM tb_bd_device tbd FROM tb_bd_device tbd
INNER JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id AND tdd.del_flag = 0 INNER JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id AND tdd.del_flag = 0
INNER JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id AND thdv.val = #{id} INNER JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id AND thdv.val = #{id} AND thdv.create_time BETWEEN CONCAT(#{startTime},' 00:00:00') AND CONCAT(#{endTime},' 23:59:59')
WHERE tbd.devic_type = #{typeCode} AND tdd.mode_name = #{modeName} AND tbd.del_flag = 0 WHERE tbd.devic_type = #{typeCode} AND tdd.mode_name = #{modeName} AND tbd.del_flag = 0
</select> </select>
<select id="getBindHis" resultType="java.lang.Integer"> <select id="getBindHis" resultType="java.lang.Integer">
@ -186,4 +186,19 @@
WHERE thdv.source_type = #{value} WHERE thdv.source_type = #{value}
GROUP BY thdv.source_type GROUP BY thdv.source_type
</select> </select>
<!--获取人员入场 离场状态-->
<select id="getUserAccessStatus" resultType="java.lang.String">
<if test="type == 1">
SELECT tdd.device_id
FROM tb_device_value tdv
LEFT JOIN tb_device_detail tdd ON tdv.attribute_id = tdd.id AND tdd.del_flag = 0
WHERE tdv.val = #{userId}
</if>
<if test="type == 2">
SELECT tdv.val
FROM tb_device_detail tdd
LEFT JOIN tb_device_value tdv ON tdd.id = tdv.attribute_id
WHERE tdd.device_id = #{userId} AND tdd.mode_name = #{accessType} AND tdd.del_flag = 0
</if>
</select>
</mapper> </mapper>

View File

@ -20,13 +20,12 @@
</select> </select>
<select id="getLists" resultType="com.securitycontrol.entity.background.vo.VehicleVo"> <select id="getLists" resultType="com.securitycontrol.entity.background.vo.VehicleVo">
SELECT accesss_time as accesssTime, SELECT thdv.source_type AS value
case WHEN access_type= '0' then '入场' ELSE '出场' end accessType FROM tb_bd_device tbd
FROM `tb_car_access` INNER JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id AND tdd.del_flag = 0
WHERE car_id = #{id} INNER JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id AND thdv.create_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59')
<if test="date != null and date != ''"> INNER JOIN tb_car tc ON tc.car_num = thdv.val AND tc.id = #{id}
AND accesss_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59') WHERE tbd.devic_type = #{typeCode} AND tdd.mode_name = #{modeName} AND tbd.del_flag = 0
</if>
</select> </select>
<select id="getListsDto" resultType="com.securitycontrol.entity.background.dto.VehicleDto"> <select id="getListsDto" resultType="com.securitycontrol.entity.background.dto.VehicleDto">
@ -38,6 +37,14 @@
AND accesss_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59') AND accesss_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59')
</if> </if>
</select> </select>
<!--获取车辆入场 离场状态-->
<select id="getCarAccessLists" resultType="java.lang.String">
SELECT GROUP_CONCAT(CONCAT(tdd.mode_name,'@',thdv.val)) AS value
FROM tb_his_device_value thdv
INNER JOIN tb_device_detail tdd ON thdv.attribute_id = tdd.id AND tdd.del_flag = 0
WHERE thdv.source_type = #{value}
GROUP BY thdv.source_type
</select>
<!--新增/修改--> <!--新增/修改-->
<insert id="addOrUpdateVehicle"> <insert id="addOrUpdateVehicle">