feat(): 新增车辆归属查询功能,修改封闭区域人员进出记录统计逻辑
parent
1cca784a2a
commit
00279cd6dc
|
|
@ -46,6 +46,12 @@ public class ClosedAreaCarApplyController {
|
|||
return closedAreaCarApplyService.listPage(qry);
|
||||
}
|
||||
|
||||
@ApiOperation("根据车辆归属查询封闭区域现有车辆")
|
||||
@GetMapping("/getCarByCarBelongType")
|
||||
public PageResponse<ClosedAreaCarApplyCO> getCarByCarBelongType(ClosedAreaCarApplyPageQry qry) {
|
||||
return closedAreaCarApplyService.getCarByCarBelongType(qry);
|
||||
}
|
||||
|
||||
@ApiOperation("详情")
|
||||
@GetMapping("/{id}")
|
||||
public SingleResponse<ClosedAreaCarApplyCO> getInfoById(@PathVariable("id") Long id) {
|
||||
|
|
|
|||
|
|
@ -113,14 +113,18 @@ public class ClosedAreaPersonApplyUpdateExe {
|
|||
areaFgsPersonAreaGateway.removeByFgspersonAuthId(cmd.getUserId());
|
||||
ArrayList<ClosedAreaFgsPersonAreaE> objects = new ArrayList<>();
|
||||
List<ClosedAreaPersonApplyAuthCmd.FgsPersonArea> areaList = cmd.getAreaList();
|
||||
for (ClosedAreaPersonApplyAuthCmd.FgsPersonArea fgsPersonArea : areaList) {
|
||||
ClosedAreaFgsPersonAreaE closedAreaFgsPersonAreaE = new ClosedAreaFgsPersonAreaE();
|
||||
closedAreaFgsPersonAreaE.setClosedAreaId(fgsPersonArea.getClosedAreaId());
|
||||
closedAreaFgsPersonAreaE.setClosedAreaName(fgsPersonArea.getClosedAreaName());
|
||||
closedAreaFgsPersonAreaE.setFgsPersonAuthId(fgsPersonArea.getFgsPersonAuthId());
|
||||
objects.add(closedAreaFgsPersonAreaE);
|
||||
if (areaList != null) {
|
||||
for (ClosedAreaPersonApplyAuthCmd.FgsPersonArea fgsPersonArea : areaList) {
|
||||
ClosedAreaFgsPersonAreaE closedAreaFgsPersonAreaE = new ClosedAreaFgsPersonAreaE();
|
||||
closedAreaFgsPersonAreaE.setClosedAreaId(fgsPersonArea.getClosedAreaId());
|
||||
closedAreaFgsPersonAreaE.setClosedAreaName(fgsPersonArea.getClosedAreaName());
|
||||
closedAreaFgsPersonAreaE.setFgsPersonAuthId(cmd.getUserId());
|
||||
objects.add(closedAreaFgsPersonAreaE);
|
||||
}
|
||||
}
|
||||
if (!objects.isEmpty()) {
|
||||
areaFgsPersonAreaGateway.saveBatch(objects);
|
||||
}
|
||||
areaFgsPersonAreaGateway.saveBatch(objects);
|
||||
// 开启门禁权限时,查一级大华是否有已有权限,不覆盖
|
||||
if (cmd.getMkmjPermission() != null && cmd.getMkmjPermission().equals(1)) {
|
||||
// 获取人员身份证号
|
||||
|
|
|
|||
|
|
@ -62,5 +62,12 @@ public class ClosedAreaCarApplyQueryExe {
|
|||
}
|
||||
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
}
|
||||
|
||||
public PageResponse<ClosedAreaCarApplyCO> getCarByCarBelongType(ClosedAreaCarApplyPageQry qry) {
|
||||
Map<String, Object> params = PageQueryHelper.toHashMap(qry);
|
||||
PageResponse<ClosedAreaCarApplyDO> pageResponse = closedAreaCarApplyRepository.getCarByCarBelongType(params);
|
||||
List<ClosedAreaCarApplyCO> result = closedAreaCarApplyCoConvertor.converDOsToCOs(pageResponse.getData());
|
||||
return PageResponse.of(result, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public class ClosedAreaPersonApplyQueryExe {
|
|||
ClosedAreaFgsPersonAuthDO closedAreaFgsPersonAuthDO = closedAreaFgsPersonAuthRepository.getAuthorizationPersonInfo(id);
|
||||
QueryWrapper<ClosedAreaFgsPersonAreaDO> closedAreaFgsPersonAreaDOQueryWrapper = new QueryWrapper<>();
|
||||
closedAreaFgsPersonAreaDOQueryWrapper.eq("fgs_person_auth_id",id);
|
||||
closedAreaFgsPersonAreaDOQueryWrapper.eq("delete_enum","FALSE");
|
||||
List<ClosedAreaFgsPersonAreaDO> list = closedAreaFgsPersonAreaRepository.list(closedAreaFgsPersonAreaDOQueryWrapper);
|
||||
ClosedAreaPersonApplyCO closedAreaPersonApplyCO = new ClosedAreaPersonApplyCO();
|
||||
closedAreaPersonApplyCO.setApplyPersonUserId(id);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ public class ClosedAreaCarApplyServiceImpl implements ClosedAreaCarApplyServiceI
|
|||
return closedAreaCarApplyQueryExe.execute(qry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResponse<ClosedAreaCarApplyCO> getCarByCarBelongType(ClosedAreaCarApplyPageQry qry) {
|
||||
return closedAreaCarApplyQueryExe.getCarByCarBelongType(qry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse add(ClosedAreaCarApplyAddCmd cmd) {
|
||||
|
||||
|
|
|
|||
|
|
@ -149,10 +149,14 @@ public class ClosedAreaServiceImpl implements ClosedAreaServiceI {
|
|||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("closedAreaId", qry.getClosedAreaId());
|
||||
params.put("personName", qry.getPersonName());
|
||||
if (qry.getStartTime() != null) {
|
||||
params.put("startTime", qry.getStartTime());
|
||||
params.put("endTime", qry.getEndTime());
|
||||
params.put("deptId", qry.getDeptId());
|
||||
params.put("personPhone", qry.getPersonPhone());
|
||||
params.put("personIdCard", qry.getPersonIdCard());
|
||||
if (qry.getTimeRange() != null && qry.getTimeRange().size() == 2) {
|
||||
params.put("startTime", qry.getTimeRange().get(0));
|
||||
params.put("endTime", qry.getTimeRange().get(1));
|
||||
}
|
||||
params.put("doorName", qry.getDoorName());
|
||||
params.put("pageIndex", qry.getPageIndex());
|
||||
params.put("pageSize", qry.getPageSize());
|
||||
params.put("offset", (qry.getPageIndex() - 1) * qry.getPageSize());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public interface ClosedAreaCarApplyServiceI {
|
|||
|
||||
PageResponse<ClosedAreaCarApplyCO> listPage(ClosedAreaCarApplyPageQry qry);
|
||||
|
||||
PageResponse<ClosedAreaCarApplyCO> getCarByCarBelongType(ClosedAreaCarApplyPageQry qry);
|
||||
|
||||
SingleResponse<ClosedAreaCarApplyCO> add(ClosedAreaCarApplyAddCmd cmd);
|
||||
|
||||
void edit(ClosedAreaCarApplyUpdateCmd cmd);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ public class ClosedAreaCarApplyPageQry extends PageQuery {
|
|||
* - `le`: 小于等于比较查询
|
||||
* - `ne`: 不等比较查询,对应SQL的!=操作符
|
||||
*/
|
||||
@ApiModelProperty(value = "车牌号", name = "licenceLo")
|
||||
private String licenceLo;
|
||||
@ApiModelProperty(value = "车牌号", name = "licenceNo")
|
||||
private String licenceNo;
|
||||
@ApiModelProperty(value = "申请人姓名", name = "applyPersonUserName")
|
||||
private String applyPersonUserName;
|
||||
@ApiModelProperty(value = "审核状态(1:审核中;2审核通过; 3:审核驳回)", name = "auditFlag")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.primeport.dto;
|
||||
|
||||
import com.alibaba.cola.dto.PageQuery;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -23,11 +24,23 @@ public class PersonInOutRecordQry extends PageQuery {
|
|||
private Long closedAreaId;
|
||||
|
||||
@ApiModelProperty(value = "人员姓名(模糊查询)", name = "personName")
|
||||
@JsonAlias("name")
|
||||
private String personName;
|
||||
|
||||
@ApiModelProperty(value = "开始时间(格式:yyyy-MM-dd)", name = "startTime")
|
||||
private String startTime;
|
||||
@ApiModelProperty(value = "部门ID(全局人员记录查询时由页面传入)", name = "deptId")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "结束时间(格式:yyyy-MM-dd)", name = "endTime")
|
||||
private String endTime;
|
||||
@ApiModelProperty(value = "人员手机号(可选,用于平台人员辅助校验;海康进出事件不提供该字段)", name = "personPhone")
|
||||
@JsonAlias("phone")
|
||||
private String personPhone;
|
||||
|
||||
@ApiModelProperty(value = "人员身份证号Base64(可选;与海康事件 certNo 关联,建议页面可传时一并传入)", name = "personIdCard")
|
||||
@JsonAlias("userCard")
|
||||
private String personIdCard;
|
||||
|
||||
@ApiModelProperty(value = "时间范围(格式:yyyy-MM-dd)", name = "timeRange")
|
||||
private List<String> timeRange;
|
||||
|
||||
@ApiModelProperty(value = "口门名称", name = "doorName")
|
||||
private String doorName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class HkAccessRecordDO extends BaseDO {
|
|||
@ApiModelProperty(value = "门禁点所属区域编码", name = "doorRegionIndexCode")
|
||||
private String doorRegionIndexCode;
|
||||
|
||||
@ApiModelProperty(value = "进出方向(1-进,0-出,-1-未知)", name = "enterOrExit", allowableValues = "1,0,-1")
|
||||
@ApiModelProperty(value = "进出方向(1-进,2-出,-1-未知)", name = "enterOrExit", allowableValues = "1,2,-1")
|
||||
private Integer enterOrExit;
|
||||
|
||||
@ApiModelProperty(value = "开门结果(1-成功,0-失败)", name = "openResult", allowableValues = "0,1")
|
||||
|
|
|
|||
|
|
@ -28,14 +28,16 @@ public interface ClosedAreaCarApplyMapper extends BaseMapper<ClosedAreaCarApplyD
|
|||
|
||||
IPage<ClosedAreaCarApplyDO> listPage(Page<Map<String, Object>> page, @Param("params") Map<String, Object> params, String menuPerms);
|
||||
|
||||
IPage<ClosedAreaCarApplyDO> getCarByCarBelongType(Page<Map<String, Object>> page, @Param("params") Map<String, Object> params);
|
||||
|
||||
Integer countDashboardApproval(@Param("params") Map<String, Object> params);
|
||||
|
||||
IPage<ClosedAreaCarApplyDO> screenList(Page<Map<String, Object>> page, @Param("params") Map<String, Object> params);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<TwoLevelCar> getFgsCarToDay(@Param("licenceNo") String licenceNo);
|
||||
List<TwoLevelCar> getFgsCarToDay(@Param("licenceNo") String licenceNo, @Param("applyId") Long applyId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<TwoLevelCar> dockTmpCarLevelTwo(@Param("licenceNo") String licenceNo);
|
||||
List<TwoLevelCar> dockTmpCarLevelTwo(@Param("licenceNo") String licenceNo, @Param("applyId") Long applyId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@ import java.util.Map;
|
|||
public interface ClosedAreaCarApplyRepository extends BaseRepository<ClosedAreaCarApplyDO> {
|
||||
PageResponse<ClosedAreaCarApplyDO> listPage(Map<String, Object> params);
|
||||
|
||||
PageResponse<ClosedAreaCarApplyDO> getCarByCarBelongType(Map<String, Object> params);
|
||||
|
||||
Integer countDashboardApproval(Map<String, Object> params);
|
||||
|
||||
PageResponse<ClosedAreaCarApplyDO> screenList(Map<String, Object> params);
|
||||
|
||||
List<TwoLevelCar> getFgsCarToDay(String licenceNo);
|
||||
List<TwoLevelCar> getFgsCarToDay(String licenceNo, Long applyId);
|
||||
|
||||
List<TwoLevelCar> dockTmpCarLevelTwo(String licenceNo);
|
||||
List<TwoLevelCar> dockTmpCarLevelTwo(String licenceNo, Long applyId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ public class ClosedAreaCarApplyRepositoryImpl extends BaseRepositoryImpl<ClosedA
|
|||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResponse<ClosedAreaCarApplyDO> getCarByCarBelongType(Map<String, Object> params) {
|
||||
Page<Map<String, Object>> page = new Page<>(Integer.parseInt(params.get("pageIndex").toString()),
|
||||
Integer.parseInt(params.get("pageSize").toString()));
|
||||
page.setOptimizeJoinOfCountSql(false);
|
||||
IPage<ClosedAreaCarApplyDO> result = closedAreaCarApplyMapper.getCarByCarBelongType(page, params);
|
||||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countDashboardApproval(Map<String, Object> params) {
|
||||
return closedAreaCarApplyMapper.countDashboardApproval(params);
|
||||
|
|
@ -56,13 +65,13 @@ public class ClosedAreaCarApplyRepositoryImpl extends BaseRepositoryImpl<ClosedA
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TwoLevelCar> getFgsCarToDay(String licenceNo) {
|
||||
return closedAreaCarApplyMapper.getFgsCarToDay(licenceNo);
|
||||
public List<TwoLevelCar> getFgsCarToDay(String licenceNo, Long applyId) {
|
||||
return closedAreaCarApplyMapper.getFgsCarToDay(licenceNo, applyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TwoLevelCar> dockTmpCarLevelTwo(String licenceNo) {
|
||||
return closedAreaCarApplyMapper.dockTmpCarLevelTwo(licenceNo);
|
||||
public List<TwoLevelCar> dockTmpCarLevelTwo(String licenceNo, Long applyId) {
|
||||
return closedAreaCarApplyMapper.dockTmpCarLevelTwo(licenceNo, applyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,34 @@
|
|||
</if>
|
||||
order by c.id desc
|
||||
</select>
|
||||
<select id="getCarByCarBelongType" resultType="com.zcloud.primeport.persistence.dataobject.ClosedAreaCarApplyDO">
|
||||
SELECT
|
||||
c.*
|
||||
FROM
|
||||
closed_area_car_apply c
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
licence_no,
|
||||
MAX(id) id
|
||||
FROM
|
||||
closed_area_car_apply
|
||||
WHERE
|
||||
delete_enum = 'FALSE'
|
||||
AND audit_flag = 2
|
||||
<if test="params.carBelongType != null">
|
||||
AND car_belong_type = #{params.carBelongType}
|
||||
</if>
|
||||
<if test="params.licenceNo != null and params.licenceNo != ''">
|
||||
AND licence_no LIKE CONCAT('%', #{params.licenceNo}, '%')
|
||||
</if>
|
||||
GROUP BY
|
||||
licence_no
|
||||
) latest ON c.id = latest.id
|
||||
WHERE
|
||||
c.delete_enum = 'FALSE'
|
||||
ORDER BY
|
||||
c.id DESC
|
||||
</select>
|
||||
<select id="screenList" resultType="com.zcloud.primeport.persistence.dataobject.ClosedAreaCarApplyDO">
|
||||
select c.*, c.apply_person_user_name apply_user_name
|
||||
from closed_area_car_apply c
|
||||
|
|
@ -79,10 +107,13 @@
|
|||
</select>
|
||||
<select id="getFgsCarToDay" resultType="com.zcloud.primeport.plan.mjDevice.dto.TwoLevelCar">
|
||||
SELECT
|
||||
caca.id,
|
||||
caca.licence_no,
|
||||
GROUP_CONCAT( DISTINCT caca.licence_type ) licence_type,
|
||||
GROUP_CONCAT( DISTINCT mg.hk_index_code ) hk_index_code,
|
||||
mg.kh_park_sys_code
|
||||
mg.kh_park_sys_code,
|
||||
caca.visit_start_time,
|
||||
caca.visit_end_time
|
||||
FROM
|
||||
closed_area_car_apply caca
|
||||
INNER JOIN mkmj m ON caca.closed_area_id = m.closed_area_id
|
||||
|
|
@ -90,8 +121,9 @@
|
|||
WHERE
|
||||
caca.delete_enum = 'FALSE'
|
||||
AND caca.car_belong_type IN ( 1, 2, 3, 5 )
|
||||
AND caca.visit_end_time >= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND caca.visit_start_time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND caca.expired_expiration = '2'
|
||||
AND DATE(caca.visit_end_time) >= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
AND DATE(caca.visit_start_time) <= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
AND caca.audit_flag = 2
|
||||
AND m.delete_enum = 'FALSE'
|
||||
AND m.mkmj_status = 2
|
||||
|
|
@ -105,25 +137,35 @@
|
|||
<if test="licenceNo != null and licenceNo != ''">
|
||||
AND caca.licence_no = #{licenceNo}
|
||||
</if>
|
||||
<if test="applyId != null">
|
||||
AND caca.id = #{applyId}
|
||||
</if>
|
||||
GROUP BY
|
||||
caca.id,
|
||||
caca.licence_no,
|
||||
mg.kh_park_sys_code
|
||||
mg.kh_park_sys_code,
|
||||
caca.visit_start_time,
|
||||
caca.visit_end_time
|
||||
</select>
|
||||
<select id="dockTmpCarLevelTwo" resultType="com.zcloud.primeport.plan.mjDevice.dto.TwoLevelCar">
|
||||
SELECT
|
||||
caca.id,
|
||||
caca.licence_no,
|
||||
GROUP_CONCAT( DISTINCT caca.licence_type ) licence_type,
|
||||
caca.level_two_mkmj_id,
|
||||
GROUP_CONCAT( DISTINCT mg.hk_index_code ) hk_index_code,
|
||||
mg.kh_park_sys_code
|
||||
mg.kh_park_sys_code,
|
||||
caca.visit_start_time,
|
||||
caca.visit_end_time
|
||||
FROM
|
||||
closed_area_car_apply caca
|
||||
INNER JOIN mkmj_gate mg ON caca.level_two_mkmj_id = mg.mkmj_id
|
||||
WHERE
|
||||
caca.delete_enum = 'FALSE'
|
||||
AND caca.car_belong_type = 4
|
||||
AND caca.visit_end_time >= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND caca.visit_start_time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND caca.expired_expiration = '2'
|
||||
AND DATE(caca.visit_end_time) >= CURDATE()
|
||||
AND DATE(caca.visit_start_time) <= CURDATE()
|
||||
AND caca.audit_flag = 2
|
||||
AND mg.gate_type = 'HGKM_MKMJ_GATE_TYPE_CAR'
|
||||
AND mg.gate_status = 2
|
||||
|
|
@ -133,11 +175,16 @@
|
|||
<if test="licenceNo != null and licenceNo != ''">
|
||||
AND caca.licence_no = #{licenceNo}
|
||||
</if>
|
||||
<if test="applyId != null">
|
||||
AND caca.id = #{applyId}
|
||||
</if>
|
||||
GROUP BY
|
||||
caca.id,
|
||||
caca.licence_no,
|
||||
caca.level_two_mkmj_id,
|
||||
mg.kh_park_sys_code
|
||||
mg.kh_park_sys_code,
|
||||
caca.visit_start_time,
|
||||
caca.visit_end_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
|
|
@ -108,22 +108,144 @@
|
|||
c.id
|
||||
</select>
|
||||
|
||||
<!-- 近七天封闭区域现存人员、车辆:按同一区域同一身份最后一条进出记录判断,最后为进才计入 -->
|
||||
<select id="listPositionCount" resultType="com.zcloud.primeport.persistence.dataobject.ClosedAreaCountDO">
|
||||
WITH RECURSIVE area_tree AS (
|
||||
SELECT id AS ancestor_area_id, id AS area_id
|
||||
FROM closed_area
|
||||
WHERE delete_enum = 'FALSE'
|
||||
UNION ALL
|
||||
SELECT area_tree.ancestor_area_id, child.id AS area_id
|
||||
FROM area_tree
|
||||
INNER JOIN closed_area child ON child.parent_id = area_tree.area_id
|
||||
AND child.delete_enum = 'FALSE'
|
||||
),
|
||||
person_event_area AS (
|
||||
SELECT DISTINCT
|
||||
m.closed_area_id,
|
||||
har.id,
|
||||
har.person_id,
|
||||
har.enter_or_exit,
|
||||
har.event_time
|
||||
FROM hk_access_record har
|
||||
INNER JOIN mkmj_gate mg ON har.door_index_code = mg.hk_index_code
|
||||
AND mg.delete_enum = 'FALSE'
|
||||
INNER JOIN mkmj m ON mg.mkmj_id = m.id
|
||||
AND m.delete_enum = 'FALSE'
|
||||
WHERE har.delete_enum = 'FALSE'
|
||||
AND har.person_id IS NOT NULL
|
||||
AND har.person_id != ''
|
||||
AND har.enter_or_exit IN (1, 2)
|
||||
AND har.event_time >= DATE_SUB(UTC_TIMESTAMP() + INTERVAL 8 HOUR, INTERVAL 7 DAY)
|
||||
),
|
||||
person_last_record AS (
|
||||
SELECT
|
||||
person_event_area.closed_area_id,
|
||||
person_event_area.person_id,
|
||||
person_event_area.enter_or_exit,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY person_event_area.person_id
|
||||
ORDER BY person_event_area.event_time DESC, person_event_area.id DESC
|
||||
) AS row_num
|
||||
FROM person_event_area
|
||||
),
|
||||
unique_park_area AS (
|
||||
SELECT
|
||||
mg.kh_park_sys_code,
|
||||
MAX(m.closed_area_id) AS closed_area_id
|
||||
FROM mkmj_gate mg
|
||||
INNER JOIN mkmj m ON mg.mkmj_id = m.id
|
||||
AND m.delete_enum = 'FALSE'
|
||||
WHERE mg.delete_enum = 'FALSE'
|
||||
AND mg.kh_park_sys_code IS NOT NULL
|
||||
AND mg.kh_park_sys_code != ''
|
||||
GROUP BY mg.kh_park_sys_code
|
||||
HAVING COUNT(DISTINCT m.closed_area_id) = 1
|
||||
),
|
||||
vehicle_event_area AS (
|
||||
SELECT DISTINCT
|
||||
m.closed_area_id,
|
||||
hvar.id,
|
||||
hvar.plate_no,
|
||||
hvar.enter_or_exit,
|
||||
hvar.event_time
|
||||
FROM hk_vehicle_access_record hvar
|
||||
INNER JOIN mkmj_gate mg ON hvar.lane_index_code = mg.hk_index_code
|
||||
AND mg.delete_enum = 'FALSE'
|
||||
INNER JOIN mkmj m ON mg.mkmj_id = m.id
|
||||
AND m.delete_enum = 'FALSE'
|
||||
WHERE hvar.delete_enum = 'FALSE'
|
||||
AND hvar.plate_no IS NOT NULL
|
||||
AND hvar.plate_no != ''
|
||||
AND hvar.enter_or_exit IN (0, 1)
|
||||
AND hvar.event_time >= DATE_SUB(UTC_TIMESTAMP() + INTERVAL 8 HOUR, INTERVAL 7 DAY)
|
||||
UNION ALL
|
||||
SELECT
|
||||
unique_park_area.closed_area_id,
|
||||
hvar.id,
|
||||
hvar.plate_no,
|
||||
hvar.enter_or_exit,
|
||||
hvar.event_time
|
||||
FROM hk_vehicle_access_record hvar
|
||||
INNER JOIN unique_park_area ON hvar.park_syscode = unique_park_area.kh_park_sys_code
|
||||
WHERE hvar.delete_enum = 'FALSE'
|
||||
AND hvar.plate_no IS NOT NULL
|
||||
AND hvar.plate_no != ''
|
||||
AND hvar.enter_or_exit IN (0, 1)
|
||||
AND hvar.event_time >= DATE_SUB(UTC_TIMESTAMP() + INTERVAL 8 HOUR, INTERVAL 7 DAY)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM mkmj_gate lane_gate
|
||||
WHERE lane_gate.hk_index_code = hvar.lane_index_code
|
||||
AND lane_gate.delete_enum = 'FALSE'
|
||||
)
|
||||
),
|
||||
vehicle_last_record AS (
|
||||
SELECT
|
||||
vehicle_event_area.closed_area_id,
|
||||
vehicle_event_area.plate_no,
|
||||
vehicle_event_area.enter_or_exit,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY vehicle_event_area.plate_no
|
||||
ORDER BY vehicle_event_area.event_time DESC, vehicle_event_area.id DESC
|
||||
) AS row_num
|
||||
FROM vehicle_event_area
|
||||
),
|
||||
person_current_count AS (
|
||||
SELECT
|
||||
area_tree.ancestor_area_id AS closed_area_id,
|
||||
COUNT(*) AS person_count
|
||||
FROM person_last_record
|
||||
INNER JOIN area_tree ON area_tree.area_id = person_last_record.closed_area_id
|
||||
WHERE person_last_record.row_num = 1
|
||||
AND person_last_record.enter_or_exit = 1
|
||||
GROUP BY area_tree.ancestor_area_id
|
||||
),
|
||||
vehicle_current_count AS (
|
||||
SELECT
|
||||
area_tree.ancestor_area_id AS closed_area_id,
|
||||
COUNT(*) AS car_count
|
||||
FROM vehicle_last_record
|
||||
INNER JOIN area_tree ON area_tree.area_id = vehicle_last_record.closed_area_id
|
||||
WHERE vehicle_last_record.row_num = 1
|
||||
AND vehicle_last_record.enter_or_exit = 0
|
||||
GROUP BY area_tree.ancestor_area_id
|
||||
)
|
||||
SELECT
|
||||
c.*,
|
||||
CASE WHEN child_cnt > 0 THEN 1 ELSE 2 END AS has_child,
|
||||
0 AS person_count,
|
||||
0 AS car_count
|
||||
FROM
|
||||
closed_area c
|
||||
CASE WHEN child_cnt > 0 THEN 1 ELSE 2 END AS has_child,
|
||||
COALESCE(person_current_count.person_count, 0) AS person_count,
|
||||
COALESCE(vehicle_current_count.car_count, 0) AS car_count
|
||||
FROM closed_area c
|
||||
LEFT JOIN (
|
||||
SELECT parent_id, COUNT(id) child_cnt
|
||||
FROM closed_area
|
||||
WHERE delete_enum = 'FALSE'
|
||||
GROUP BY parent_id
|
||||
SELECT parent_id, COUNT(id) child_cnt
|
||||
FROM closed_area
|
||||
WHERE delete_enum = 'FALSE'
|
||||
GROUP BY parent_id
|
||||
) child ON c.id = child.parent_id
|
||||
WHERE
|
||||
c.delete_enum = 'FALSE'
|
||||
LEFT JOIN person_current_count ON c.id = person_current_count.closed_area_id
|
||||
LEFT JOIN vehicle_current_count ON c.id = vehicle_current_count.closed_area_id
|
||||
WHERE c.delete_enum = 'FALSE'
|
||||
<if test="params.corpId != null">
|
||||
AND c.jurisdictional_corp_id = #{params.corpId}
|
||||
</if>
|
||||
|
|
@ -131,12 +253,9 @@
|
|||
AND c.parent_id = #{params.parentId}
|
||||
</if>
|
||||
<if test="params.closedAreaName != null and params.closedAreaName != ''">
|
||||
AND C.closed_area_name LIKE CONCAT('%', #{params.closedAreaName}, '%')
|
||||
AND c.closed_area_name LIKE CONCAT('%', #{params.closedAreaName}, '%')
|
||||
</if>
|
||||
GROUP BY
|
||||
c.id
|
||||
ORDER BY
|
||||
c.id
|
||||
ORDER BY c.id
|
||||
</select>
|
||||
|
||||
<select id="corpStat" resultType="com.zcloud.primeport.persistence.dataobject.ClosedAreaCorpStatDO">
|
||||
|
|
@ -154,21 +273,7 @@
|
|||
</select>
|
||||
|
||||
<!-- 封闭区域人员进出记录(含子区域递归查询) -->
|
||||
<sql id="personInOutBaseQuery">
|
||||
WITH RECURSIVE area_tree AS (
|
||||
SELECT id FROM closed_area WHERE id = #{params.closedAreaId} AND delete_enum = 'FALSE'
|
||||
UNION ALL
|
||||
SELECT ca.id FROM closed_area ca INNER JOIN area_tree at ON ca.parent_id = at.id WHERE ca.delete_enum = 'FALSE'
|
||||
)
|
||||
SELECT har.*
|
||||
FROM hk_access_record har
|
||||
INNER JOIN mkmj_gate mg ON har.door_index_code = mg.hk_index_code AND mg.delete_enum = 'FALSE'
|
||||
INNER JOIN mkmj m ON mg.mkmj_id = m.id AND m.delete_enum = 'FALSE'
|
||||
INNER JOIN area_tree at ON m.closed_area_id = at.id
|
||||
WHERE har.delete_enum = 'FALSE'
|
||||
<if test="params.personName != null and params.personName != ''">
|
||||
AND har.person_name LIKE CONCAT('%', #{params.personName}, '%')
|
||||
</if>
|
||||
<sql id="personInOutTimeFilters">
|
||||
<if test="params.startTime != null and params.startTime != ''">
|
||||
AND har.event_time >= CONCAT(#{params.startTime}, ' 00:00:00')
|
||||
</if>
|
||||
|
|
@ -177,6 +282,64 @@
|
|||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 全部封闭区域人员进出记录:通过平台人员身份证与海康事件证件号关联 -->
|
||||
<sql id="personInOutBaseQuery">
|
||||
<choose>
|
||||
<when test="params.closedAreaId != null">
|
||||
WITH RECURSIVE area_tree AS (
|
||||
SELECT id FROM closed_area WHERE id = #{params.closedAreaId} AND delete_enum = 'FALSE'
|
||||
UNION ALL
|
||||
SELECT ca.id FROM closed_area ca INNER JOIN area_tree at ON ca.parent_id = at.id WHERE ca.delete_enum = 'FALSE'
|
||||
)
|
||||
SELECT har.*
|
||||
FROM hk_access_record har
|
||||
INNER JOIN mkmj_gate mg ON har.door_index_code = mg.hk_index_code AND mg.delete_enum = 'FALSE'
|
||||
INNER JOIN mkmj m ON mg.mkmj_id = m.id AND m.delete_enum = 'FALSE'
|
||||
INNER JOIN area_tree at ON m.closed_area_id = at.id
|
||||
WHERE har.delete_enum = 'FALSE'
|
||||
<if test="params.personName != null and params.personName != ''">
|
||||
AND har.person_name LIKE CONCAT('%', #{params.personName}, '%')
|
||||
</if>
|
||||
<include refid="personInOutTimeFilters"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
SELECT har.*
|
||||
FROM hk_access_record har
|
||||
INNER JOIN `user` u ON u.user_id_card = har.certificate_no AND u.delete_enum = 'FALSE'
|
||||
WHERE har.delete_enum = 'FALSE'
|
||||
<choose>
|
||||
<when test="params.deptId != null and ((params.personName != null and params.personName != '') or (params.personPhone != null and params.personPhone != '') or (params.personIdCard != null and params.personIdCard != ''))">
|
||||
AND u.department_id = #{params.deptId}
|
||||
</when>
|
||||
<when test="params.personIdCard != null and params.personIdCard != ''">
|
||||
AND u.user_id_card = #{params.personIdCard}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="params.personName != null and params.personName != ''">
|
||||
AND u.`name` LIKE CONCAT('%', #{params.personName}, '%')
|
||||
</if>
|
||||
<if test="params.personPhone != null and params.personPhone != ''">
|
||||
AND u.phone = #{params.personPhone}
|
||||
</if>
|
||||
<if test="params.personIdCard != null and params.personIdCard != ''">
|
||||
AND u.user_id_card = #{params.personIdCard}
|
||||
</if>
|
||||
<if test="params.startTime != null and params.startTime != ''">
|
||||
AND har.event_time >= CONCAT(#{params.startTime}, ' 00:00:00')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
AND har.event_time <= CONCAT(#{params.endTime}, ' 23:59:59')
|
||||
</if>
|
||||
<if test="params.doorName != null and params.doorName != ''">
|
||||
AND har.door_name LIKE CONCAT('%', #{params.doorName}, '%')
|
||||
</if>
|
||||
<include refid="personInOutTimeFilters"/>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
<select id="listPersonInOutRecord" resultType="com.zcloud.primeport.persistence.dataobject.HkAccessRecordDO">
|
||||
<include refid="personInOutBaseQuery"/>
|
||||
ORDER BY har.event_time DESC
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@
|
|||
SELECT
|
||||
capa.id,
|
||||
capa.closed_area_id,
|
||||
ca.jurisdictional_corp_id,
|
||||
ca.jurisdictional_corp_name,
|
||||
GROUP_CONCAT( DISTINCT mg.hk_index_code ) hk_index_code,
|
||||
capa.visit_start_time,
|
||||
capa.visit_end_time,
|
||||
|
|
@ -165,14 +167,15 @@
|
|||
capa.entourage
|
||||
FROM
|
||||
closed_area_person_apply capa
|
||||
INNER JOIN closed_area ca ON capa.closed_area_id = ca.id AND ca.delete_enum = 'FALSE'
|
||||
INNER JOIN mkmj m ON capa.closed_area_id = m.closed_area_id
|
||||
INNER JOIN mkmj_gate mg ON m.id = mg.mkmj_id
|
||||
WHERE
|
||||
capa.delete_enum = 'FALSE'
|
||||
AND capa.audit_flag = 2
|
||||
AND capa.person_belong_type IN ( 1, 2, 3 )
|
||||
AND capa.visit_end_time >= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND capa.visit_start_time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND DATE(capa.visit_end_time) >= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
AND DATE(capa.visit_start_time) <= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
AND m.delete_enum = 'FALSE'
|
||||
AND m.mkmj_status = 2
|
||||
AND m.mkmj_level = 2
|
||||
|
|
@ -189,6 +192,8 @@
|
|||
<select id="getDockAuthTmpInfoById" resultType="com.zcloud.primeport.plan.mjDevice.dto.TwoLevelUser">
|
||||
SELECT
|
||||
capa.id,
|
||||
ca.jurisdictional_corp_id,
|
||||
ca.jurisdictional_corp_name,
|
||||
GROUP_CONCAT( DISTINCT mg.hk_index_code ) hk_index_code,
|
||||
capa.visit_start_time,
|
||||
capa.visit_end_time,
|
||||
|
|
@ -198,6 +203,8 @@
|
|||
capa.apply_person_user_name user_name
|
||||
FROM
|
||||
closed_area_person_apply capa
|
||||
|
||||
INNER JOIN closed_area ca ON capa.closed_area_id = ca.id AND ca.delete_enum = 'FALSE'
|
||||
LEFT JOIN mkmj_gate mg ON capa.level_two_mkmj_id = mg.mkmj_id
|
||||
AND mg.delete_enum = 'FALSE'
|
||||
AND mg.gate_type = 'HGKM_MKMJ_GATE_TYPE_PERSON'
|
||||
|
|
@ -206,8 +213,8 @@
|
|||
capa.delete_enum = 'FALSE'
|
||||
AND capa.person_belong_type = 4
|
||||
AND capa.audit_flag = 2
|
||||
AND capa.visit_end_time >= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND capa.visit_start_time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
AND DATE(capa.visit_end_time) >= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
AND DATE(capa.visit_start_time) <= DATE(UTC_TIMESTAMP() + INTERVAL 8 HOUR)
|
||||
<if test="applyId != null">
|
||||
and capa.id = #{applyId}
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue