出入管理修改
This commit is contained in:
parent
32aa795b31
commit
d3d677e57a
|
|
@ -81,10 +81,9 @@ public class Constant {
|
|||
public final static String CAR = "车牌号";
|
||||
public final static String ACCESS_TIME = "出入时间";
|
||||
public final static String ACCESS_TYPE = "出入类型";
|
||||
|
||||
|
||||
|
||||
|
||||
public final static String ACCESS_TYPE_IN = "入";
|
||||
public final static String ACCESS_TYPE_OUT = "出";
|
||||
public final static String TYPE = "1";
|
||||
|
||||
public final static String[] BUILD_ARR = {"12A0,合肥","12B0,马鞍山","12C0,芜湖","12D0,安庆","12F0,淮南",
|
||||
"12G0,宣城","12H0,阜阳","12J0,铜陵","12L0,蚌埠","12M0,滁州","12N0,六安","12P0,淮北","12Q0,宿州","12R0,池州",
|
||||
|
|
|
|||
|
|
@ -882,4 +882,21 @@ public class DateTimeHelper {
|
|||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前月的第一天和最后一天
|
||||
*/
|
||||
public static String getMonthFirstAndLastDay() {
|
||||
Calendar a = Calendar.getInstance();
|
||||
//把日期设置为当月第一天
|
||||
a.set(Calendar.DATE, 1);
|
||||
//日期回滚一天,也就是最后一天
|
||||
a.roll(Calendar.DATE, -1);
|
||||
//当月有多少天
|
||||
int maxDate = a.get(Calendar.DATE);
|
||||
SimpleDateFormat sdfTwo = new SimpleDateFormat("yyyy-MM-");
|
||||
String startTime = sdfTwo.format(new Date()) + "01";
|
||||
String endTime = sdfTwo.format(new Date()) + maxDate;
|
||||
return startTime + " - " + endTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,10 @@ public class AccessMgeDto {
|
|||
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "字典编码")
|
||||
private String typeCode;
|
||||
|
||||
@ApiModelProperty(value = "检测名称")
|
||||
private String modeName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,8 @@ public class AccessMgeVo {
|
|||
@ApiModelProperty(value = "时间")
|
||||
@Excel(name = "时间", width = 10.0, orderNum = "6")
|
||||
private String accesssTime;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String userId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import com.securitycontrol.common.core.utils.ExcelStyleUtil;
|
||||
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
|
||||
import com.securitycontrol.common.core.utils.aes.StringHelper;
|
||||
import com.securitycontrol.common.core.web.controller.BaseController;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -75,9 +76,12 @@ public class AccessMgeController extends BaseController {
|
|||
try{
|
||||
startLayPage();
|
||||
if(StringHelper.isNotEmpty(dto.getDate())){
|
||||
String[] date = dto.getDate().split("~");
|
||||
String[] date = dto.getDate().split(" - ");
|
||||
dto.setStartDate(date[0]);
|
||||
dto.setEndDate(date[1]);
|
||||
}else{
|
||||
dto.setStartDate(DateTimeHelper.getNowDate());
|
||||
dto.setEndDate(DateTimeHelper.getNowDate());
|
||||
}
|
||||
List<AccessMgeVo> list = service.getVehicleStatisticsList(dto);
|
||||
return getDataTableLayui(list);
|
||||
|
|
@ -93,9 +97,12 @@ public class AccessMgeController extends BaseController {
|
|||
try {
|
||||
List<AccessMgeVo> proExportVoList = new ArrayList<>();
|
||||
if(StringHelper.isNotEmpty(dto.getDate())){
|
||||
String[] date = dto.getDate().split("~");
|
||||
String[] date = dto.getDate().split(" - ");
|
||||
dto.setStartDate(date[0]);
|
||||
dto.setEndDate(date[1]);
|
||||
}else{
|
||||
dto.setStartDate(DateTimeHelper.getNowDate());
|
||||
dto.setEndDate(DateTimeHelper.getNowDate());
|
||||
}
|
||||
List<AccessMgeVo> proLists = service.getVehicleStatisticsList(dto);
|
||||
for (int i = 0; i < proLists.size(); i++) {
|
||||
|
|
@ -104,11 +111,11 @@ public class AccessMgeController extends BaseController {
|
|||
BeanUtils.copyProperties(proLists.get(i), exportVo);
|
||||
proExportVoList.add(exportVo);
|
||||
}
|
||||
ExportParams exportParams = new ExportParams("今日、当月车辆出入场统计", "今日、当月车辆出入场统计", ExcelType.XSSF);
|
||||
ExportParams exportParams = new ExportParams("车辆出入统计", "车辆出入统计", ExcelType.XSSF);
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, AccessMgeVo.class, proExportVoList);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("今日、当月车辆出入场统计" + ".xlsx", "UTF-8"));
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("车辆出入统计" + ".xlsx", "UTF-8"));
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
|
|
@ -150,9 +157,12 @@ public class AccessMgeController extends BaseController {
|
|||
try{
|
||||
startLayPage();
|
||||
if(StringHelper.isNotEmpty(dto.getDate())){
|
||||
String[] date = dto.getDate().split("~");
|
||||
String[] date = dto.getDate().split(" - ");
|
||||
dto.setStartDate(date[0]);
|
||||
dto.setEndDate(date[1]);
|
||||
}else{
|
||||
dto.setStartDate(DateTimeHelper.getNowDate());
|
||||
dto.setEndDate(DateTimeHelper.getNowDate());
|
||||
}
|
||||
List<AccessMgeVo> list = service.getPerStatisticsList(dto);
|
||||
return getDataTableLayui(list);
|
||||
|
|
@ -168,9 +178,12 @@ public class AccessMgeController extends BaseController {
|
|||
try {
|
||||
List<AccessMgesVo> proExportVoList = new ArrayList<>();
|
||||
if(StringHelper.isNotEmpty(dto.getDate())){
|
||||
String[] date = dto.getDate().split("~");
|
||||
String[] date = dto.getDate().split(" - ");
|
||||
dto.setStartDate(date[0]);
|
||||
dto.setEndDate(date[1]);
|
||||
}else{
|
||||
dto.setStartDate(DateTimeHelper.getNowDate());
|
||||
dto.setEndDate(DateTimeHelper.getNowDate());
|
||||
}
|
||||
List<AccessMgeVo> proLists = service.getPerStatisticsList(dto);
|
||||
for (int i = 0; i < proLists.size(); i++) {
|
||||
|
|
@ -179,11 +192,11 @@ public class AccessMgeController extends BaseController {
|
|||
BeanUtils.copyProperties(proLists.get(i), exportVo);
|
||||
proExportVoList.add(exportVo);
|
||||
}
|
||||
ExportParams exportParams = new ExportParams("今日、当月人员出入场统计", "今日、当月人员出入场统计", ExcelType.XSSF);
|
||||
ExportParams exportParams = new ExportParams("人员出入统计", "人员出入统计", ExcelType.XSSF);
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, AccessMgesVo.class, proExportVoList);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("今日、当月人员出入场统计" + ".xlsx", "UTF-8"));
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("人员出入统计" + ".xlsx", "UTF-8"));
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
|
|
|
|||
|
|
@ -9,19 +9,15 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 出入管理
|
||||
*
|
||||
* @author lsun
|
||||
*/
|
||||
@Repository("AccessMgeMapper")
|
||||
public interface AccessMgeMapper {
|
||||
/**
|
||||
* 今日、当月车辆出入场统计
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<AccessMgeVo> getVehicleStatistics(AccessMgeDto dto);
|
||||
|
||||
/**
|
||||
* 今日、当月车辆出入场统计图片
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -29,20 +25,15 @@ public interface AccessMgeMapper {
|
|||
|
||||
/**
|
||||
* 今日、当月车辆出入场统计列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<AccessMgeVo> getVehicleStatisticsList(AccessMgeDto dto);
|
||||
|
||||
/**
|
||||
* 今日、当月人员出入场统计
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<AccessMgeVo> getPerStatistics(AccessMgeDto dto);
|
||||
|
||||
/**
|
||||
* 今日、当月人员出入场统计图片
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -50,8 +41,41 @@ public interface AccessMgeMapper {
|
|||
|
||||
/**
|
||||
* 今日、当月人员出入场统计列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<AccessMgeVo> getPerStatisticsList(AccessMgeDto dto);
|
||||
|
||||
/**
|
||||
* 车辆基本信息
|
||||
*
|
||||
* @param carNum
|
||||
* @return String
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/4/19 10:14
|
||||
*/
|
||||
String getCarBasicInfo(String carNum);
|
||||
|
||||
/**
|
||||
* 获取车辆/人员入场 离场状态
|
||||
*
|
||||
* @param sourceType
|
||||
* @return String
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/4/19 10:19
|
||||
*/
|
||||
String getAccessLists(String sourceType);
|
||||
|
||||
/**
|
||||
* 人员基本信息
|
||||
* @param userId
|
||||
* @return String
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/4/19 13:12
|
||||
*/
|
||||
String getPeopleBasicInfo(String userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.securitycontrol.screen.service.impl;
|
||||
|
||||
import com.securitycontrol.common.core.constant.Constant;
|
||||
import com.securitycontrol.common.core.utils.StringUtils;
|
||||
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.entity.screen.dto.AccessMgeDto;
|
||||
import com.securitycontrol.entity.screen.vo.AccessMgeVo;
|
||||
|
|
@ -11,9 +14,11 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 出入管理
|
||||
*
|
||||
* @author lsun
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
@ -24,13 +29,7 @@ public class AccessMgeServiceImpl implements AccessMgeService {
|
|||
|
||||
@Override
|
||||
public AjaxResult getVehicleStatistics(AccessMgeDto dto) {
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.getVehicleStatistics(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("今日、当月车辆出入场统计-查询失败", e);
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
return totalAccessData("1",dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -47,23 +46,25 @@ public class AccessMgeServiceImpl implements AccessMgeService {
|
|||
@Override
|
||||
public List<AccessMgeVo> getVehicleStatisticsList(AccessMgeDto dto) {
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.getVehicleStatisticsList(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("获取今日、当月车辆出入场统计列表",e);
|
||||
}
|
||||
list = getOutAndInRecord("1", dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
public AccessMgeVo setAccessData(AccessMgeVo 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
|
||||
public AjaxResult getPerStatistics(AccessMgeDto dto) {
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.getPerStatistics(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("今日、当月人员出入场统计-查询失败", e);
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
return totalAccessData("2",dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -79,12 +80,87 @@ public class AccessMgeServiceImpl implements AccessMgeService {
|
|||
|
||||
@Override
|
||||
public List<AccessMgeVo> getPerStatisticsList(AccessMgeDto dto) {
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
list = getOutAndInRecord("2", dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员/车辆 出入场记录
|
||||
* @return List<AccessMgeVo>
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/4/19 13:33
|
||||
*/
|
||||
public List<AccessMgeVo> getOutAndInRecord(String type, AccessMgeDto dto) {
|
||||
// type : 1.车辆 2.人员
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
try {
|
||||
list = mapper.getPerStatisticsList(dto);
|
||||
dto.setTypeCode(Constant.PERSON_CAR_TYPE);
|
||||
dto.setModeName(Objects.equals(Constant.TYPE, type) ? Constant.CAR : Constant.PERSON);
|
||||
list = Objects.equals(Constant.TYPE, type) ? mapper.getVehicleStatisticsList(dto) : mapper.getPerStatisticsList(dto);
|
||||
for (AccessMgeVo accessMgeVo : list) {
|
||||
String basicInfo = Objects.equals(Constant.TYPE, type) ? mapper.getCarBasicInfo(accessMgeVo.getCarNum()) : mapper.getPeopleBasicInfo(accessMgeVo.getUserId());
|
||||
String data = mapper.getAccessLists(accessMgeVo.getSourceType());
|
||||
if (StringUtils.isNotBlank(basicInfo)) {
|
||||
String[] split = basicInfo.split("@");
|
||||
accessMgeVo.setUserName(split[0]);
|
||||
accessMgeVo.setPhone(split[1]);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(data)) {
|
||||
String[] dataArr = data.split(",");
|
||||
setAccessData(accessMgeVo, dataArr);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取今日、当月人员出入场统计列表",e);
|
||||
log.error(Objects.equals(Constant.TYPE, type) ? "获取车辆出入场记录" : "获取人员出入场记录", e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public AjaxResult totalAccessData(String type, AccessMgeDto dto){
|
||||
System.err.println(type);
|
||||
// type : 1.车辆 2.人员
|
||||
List<AccessMgeVo> dataList = new ArrayList<>();
|
||||
List<AccessMgeVo> list = new ArrayList<>();
|
||||
try {
|
||||
dto.setTypeCode(Constant.PERSON_CAR_TYPE);
|
||||
dto.setModeName(Objects.equals(Constant.TYPE, type) ? Constant.CAR : Constant.PERSON);
|
||||
String[] dateArr = DateTimeHelper.getMonthFirstAndLastDay().split(" - ");
|
||||
dto.setStartDate(dateArr[0]);
|
||||
dto.setEndDate(dateArr[1]);
|
||||
AccessMgeVo vo = new AccessMgeVo();
|
||||
list = Objects.equals(Constant.TYPE, type) ? mapper.getVehicleStatisticsList(dto) : mapper.getPerStatisticsList(dto);
|
||||
for (AccessMgeVo accessMgeVo : list) {
|
||||
String data = mapper.getAccessLists(accessMgeVo.getSourceType());
|
||||
if (StringUtils.isNotEmpty(data)) {
|
||||
String[] dataArr = data.split(",");
|
||||
setAccessData(accessMgeVo, dataArr);
|
||||
}
|
||||
}
|
||||
// 今日入 今日出 当月入 当月出
|
||||
int jtrNum = 0, jrcNum = 0, dyrNum = 0, dycNum = 0;
|
||||
for (AccessMgeVo mgeVo : list) {
|
||||
if (Objects.equals(mgeVo.getAccessType(), Constant.ACCESS_TYPE_IN)) {
|
||||
dyrNum++;
|
||||
if (mgeVo.getAccesssTime().contains(DateTimeHelper.getNowDate())) {
|
||||
jtrNum++;
|
||||
}
|
||||
} else if (Objects.equals(mgeVo.getAccessType(), Constant.ACCESS_TYPE_OUT)) {
|
||||
dycNum++;
|
||||
if (mgeVo.getAccesssTime().contains(DateTimeHelper.getNowDate())) {
|
||||
jrcNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
vo.setJtrNum(jtrNum + "");
|
||||
vo.setJrcNum(jrcNum + "");
|
||||
vo.setDyrNum(dyrNum + "");
|
||||
vo.setDycNum(dycNum + "");
|
||||
dataList.add(vo);
|
||||
} catch (Exception e) {
|
||||
log.error(Objects.equals(Constant.TYPE, type) ? "统计车辆出入场数量" : "统计人员出入场数量", e);
|
||||
}
|
||||
return AjaxResult.success(dataList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,66 +2,6 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.securitycontrol.screen.mapper.AccessMgeMapper">
|
||||
|
||||
<select id="getVehicleStatistics" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
SELECT
|
||||
LPAD( SUM( jtrNum ), 3, '0' ) AS jtrNum,
|
||||
LPAD( SUM( jrcNum ), 3, '0' ) AS jrcNum,
|
||||
LPAD( SUM( dyrNum ), 4, '0' ) AS dyrNum,
|
||||
LPAD( SUM( dycNum ), 4, '0' ) AS dycNum
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
sum( CASE WHEN aa.val LIKE '%入%' THEN 1 ELSE 0 END ) jtrNum,
|
||||
sum( CASE WHEN aa.val LIKE '%出%' THEN 1 ELSE 0 END ) jrcNum,
|
||||
0 AS dyrNum,
|
||||
0 AS dycNUm
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
thdv.source_type,
|
||||
thdv.create_time,
|
||||
tpb.bid_code,
|
||||
GROUP_CONCAT( thdv.val ) AS val
|
||||
FROM
|
||||
`tb_pro_bd` tpb
|
||||
LEFT JOIN tb_bd_device tbd ON tpb.id = tbd.bd_id
|
||||
LEFT JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id
|
||||
LEFT JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id
|
||||
WHERE
|
||||
tpb.bid_code = #{bidCode}
|
||||
AND tbd.device_code = '1907001'
|
||||
AND to_days( thdv.create_time ) = to_days(
|
||||
NOW())
|
||||
GROUP BY
|
||||
thdv.source_type
|
||||
) aa UNION ALL
|
||||
SELECT
|
||||
0 AS jtrNum,
|
||||
0 AS jrcNUm,
|
||||
sum( CASE WHEN bb.val LIKE '%入%' THEN 1 ELSE 0 END ) dyrNum,
|
||||
sum( CASE WHEN bb.val LIKE '%出%' THEN 1 ELSE 0 END ) dycNUm
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
thdv.source_type,
|
||||
thdv.create_time,
|
||||
tpb.bid_code,
|
||||
GROUP_CONCAT( thdv.val ) AS val
|
||||
FROM
|
||||
`tb_pro_bd` tpb
|
||||
LEFT JOIN tb_bd_device tbd ON tpb.id = tbd.bd_id
|
||||
LEFT JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id
|
||||
LEFT JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id
|
||||
WHERE
|
||||
tpb.bid_code = #{bidCode}
|
||||
AND tbd.device_code = '1907001'
|
||||
AND DATE_FORMAT( thdv.create_time, '%Y%m' ) = DATE_FORMAT( NOW(), '%Y%m' )
|
||||
GROUP BY
|
||||
thdv.source_type
|
||||
) bb
|
||||
) ab
|
||||
</select>
|
||||
|
||||
<select id="getVehicleStatisticsPhoto" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
SELECT tw.warn_content as warnContent, trf.file_name as fileName, trf.file_suffix as fileSuffix , trf.file_id as fileId, trf.file_type as fileType
|
||||
FROM tb_project tp
|
||||
|
|
@ -80,84 +20,20 @@
|
|||
</select>
|
||||
|
||||
<select id="getVehicleStatisticsList" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
SELECT tp.pro_name as proName, tc.car_num as carNum, tc.user_name as userName, tc.phone ,
|
||||
case when tca.access_type ='1' then '入场' else '出场' END accessType, tca.accesss_time as accesssTime
|
||||
FROM tb_project tp
|
||||
LEFT JOIN tb_car tc ON tp.bid_code = tc.bid_code
|
||||
LEFT JOIN tb_car_access tca on tca.car_id = tc.id
|
||||
WHERE tp.bid_code = #{bidCode}
|
||||
<if test="proName != null and proName != ''">
|
||||
and tp.pro_name LIKE concat('%',#{proName},'%')
|
||||
SELECT thdv.source_type AS sourceType,thdv.val AS carNum,tp.pro_name AS proName
|
||||
FROM tb_his_device_value thdv
|
||||
INNER JOIN tb_device_detail tdd ON tdd.id = thdv.attribute_id AND tdd.del_flag = 0 AND tdd.mode_name = #{modeName}
|
||||
INNER JOIN tb_bd_device tbd ON tbd.device_id = tdd.device_id AND tbd.del_flag = 0 AND tbd.devic_type = #{typeCode}
|
||||
INNER JOIN tb_project tp ON thdv.bid_code = tp.bid_code AND tp.del_flag = 0
|
||||
WHERE thdv.create_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59')
|
||||
AND thdv.bid_code = #{bidCode}
|
||||
<if test="carNum!=null and carNum!=''">
|
||||
AND INSTR(thdv.val,#{carNum}) > 0
|
||||
</if>
|
||||
|
||||
<if test="carNum != null and carNum != ''">
|
||||
and tc.car_num LIKE concat('%',#{carNum},'%')
|
||||
<if test="proName!=null and proName!=''">
|
||||
AND INSTR(tp.pro_name,#{proName}) > 0
|
||||
</if>
|
||||
|
||||
<if test="date != null and date != ''">
|
||||
AND tca.accesss_time BETWEEN CONCAT(#{startDate}) AND CONCAT(#{endDate})
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getPerStatistics" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
SELECT
|
||||
LPAD( SUM( jtrNum ), 3, '0' ) AS jtrNum,
|
||||
LPAD( SUM( jrcNum ), 3, '0' ) AS jrcNum,
|
||||
LPAD( SUM( dyrNum ), 4, '0' ) AS dyrNum,
|
||||
LPAD( SUM( dycNum ), 4, '0' ) AS dycNum
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
sum( CASE WHEN aa.val LIKE '%入%' THEN 1 ELSE 0 END ) jtrNum,
|
||||
sum( CASE WHEN aa.val LIKE '%出%' THEN 1 ELSE 0 END ) jrcNum,
|
||||
0 AS dyrNum,
|
||||
0 AS dycNUm
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
thdv.source_type,
|
||||
thdv.create_time,
|
||||
tpb.bid_code,
|
||||
GROUP_CONCAT( thdv.val ) AS val
|
||||
FROM
|
||||
`tb_pro_bd` tpb
|
||||
LEFT JOIN tb_bd_device tbd ON tpb.id = tbd.bd_id
|
||||
LEFT JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id
|
||||
LEFT JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id
|
||||
WHERE
|
||||
tpb.bid_code = #{bidCode}
|
||||
AND tbd.device_code = '1907002'
|
||||
AND to_days( thdv.create_time ) = to_days(
|
||||
NOW())
|
||||
GROUP BY
|
||||
thdv.source_type
|
||||
) aa UNION ALL
|
||||
SELECT
|
||||
0 AS jtrNum,
|
||||
0 AS jrcNUm,
|
||||
sum( CASE WHEN bb.val LIKE '%入%' THEN 1 ELSE 0 END ) dyrNum,
|
||||
sum( CASE WHEN bb.val LIKE '%出%' THEN 1 ELSE 0 END ) dycNUm
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
thdv.source_type,
|
||||
thdv.create_time,
|
||||
tpb.bid_code,
|
||||
GROUP_CONCAT( thdv.val ) AS val
|
||||
FROM
|
||||
`tb_pro_bd` tpb
|
||||
LEFT JOIN tb_bd_device tbd ON tpb.id = tbd.bd_id
|
||||
LEFT JOIN tb_device_detail tdd ON tbd.device_id = tdd.device_id
|
||||
LEFT JOIN tb_his_device_value thdv ON tdd.id = thdv.attribute_id
|
||||
WHERE
|
||||
tpb.bid_code = #{bidCode}
|
||||
AND tbd.device_code = '1907002'
|
||||
AND DATE_FORMAT( thdv.create_time, '%Y%m' ) = DATE_FORMAT( NOW(), '%Y%m' )
|
||||
GROUP BY
|
||||
thdv.source_type
|
||||
) bb
|
||||
) ab
|
||||
ORDER BY thdv.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="getPerStatisticsPhoto" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
|
|
@ -178,23 +54,37 @@
|
|||
</select>
|
||||
|
||||
<select id="getPerStatisticsList" resultType="com.securitycontrol.entity.screen.vo.AccessMgeVo">
|
||||
SELECT tp.pro_name as proName, tua.user_name as userName, tua.user_phone as phone ,
|
||||
case when tua.access_type ='1' then '入场' else '出场' END accessType, tua.access_time as accesssTime
|
||||
FROM tb_project tp
|
||||
LEFT JOIN tb_work_team twt ON twt.bid_code = tp.bid_code
|
||||
LEFT JOIN t_team_people ttp on twt.team_id = ttp.team_id
|
||||
LEFT JOIN tb_user_access tua ON ttp.user_id = tua.user_id
|
||||
WHERE tp.bid_code = #{bidCode}
|
||||
<if test="proName != null and proName != ''">
|
||||
and tp.pro_name LIKE concat('%',#{proName},'%')
|
||||
SELECT thdv.source_type AS sourceType,
|
||||
thdv.val AS userId,
|
||||
tp.pro_name AS proName
|
||||
FROM tb_his_device_value thdv
|
||||
INNER JOIN tb_device_detail tdd ON tdd.id = thdv.attribute_id AND tdd.del_flag = 0 AND tdd.mode_name = #{modeName}
|
||||
INNER JOIN tb_bd_device tbd ON tbd.device_id = tdd.device_id AND tbd.del_flag = 0 AND tbd.devic_type = #{typeCode}
|
||||
INNER JOIN tb_project tp ON thdv.bid_code = tp.bid_code AND tp.del_flag = 0
|
||||
WHERE thdv.create_time BETWEEN CONCAT(#{startDate},' 00:00:00') AND CONCAT(#{endDate},' 23:59:59')
|
||||
AND thdv.bid_code = #{bidCode}
|
||||
<if test="userName!=null and userName!=''">
|
||||
AND INSTR(thdv.val,#{carNum}) > 0
|
||||
</if>
|
||||
|
||||
<if test="userName != null and userName != ''">
|
||||
and tua.user_name LIKE concat('%',#{userName},'%')
|
||||
</if>
|
||||
|
||||
<if test="date != null and date != ''">
|
||||
AND tca.accesss_time BETWEEN CONCAT(#{startDate}) AND CONCAT(#{endDate})
|
||||
<if test="proName!=null and proName!=''">
|
||||
AND INSTR(tp.pro_name,#{proName}) > 0
|
||||
</if>
|
||||
ORDER BY thdv.create_time DESC
|
||||
</select>
|
||||
<!--车辆基本信息-->
|
||||
<select id="getCarBasicInfo" resultType="java.lang.String">
|
||||
SELECT CONCAT(IFNULL(user_name,'/'),'@',IFNULL(phone,'/')) FROM tb_car WHERE car_num = #{carNum}
|
||||
</select>
|
||||
<!--获取车辆/人员入场 离场状态-->
|
||||
<select id="getAccessLists" 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 = #{sourceType}
|
||||
GROUP BY thdv.source_type
|
||||
</select>
|
||||
<!--人员基本信息-->
|
||||
<select id="getPeopleBasicInfo" resultType="java.lang.String">
|
||||
SELECT CONCAT(IFNULL(user_name,'/'),'@',IFNULL(phone,'/')) FROM t_team_people WHERE user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue