Commit f4851b4f authored by 耿迪迪's avatar 耿迪迪

车辆进出场 gengdidi

parent a2d2aad5
......@@ -53,6 +53,13 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--sqlserver驱动 -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.zehong</groupId>
......
package com.zehong.web.controller.entranceguard;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.system.service.OutParkRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author geng
* 车辆统计信息
*/
@RestController
@RequestMapping("/outParkRecords")
public class OutParkRecordsController {
@Autowired
private OutParkRecordsService outParkRecordsService;
@GetMapping("/statisticsVehicles")
public AjaxResult statisticsVehicles(){
return AjaxResult.success(outParkRecordsService.statisticsVehicles());
}
}
......@@ -17,20 +17,21 @@ server:
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://36.138.181.113:33060/danger_manage_area_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://36.138.181.113:33060/danger_manage_area_a?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: zehong_/sjz!D
# 从库数据源
slave:
# sqlserver 数据源
sqlserver:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://218.207.92.101:1433;DatabaseName=Park_DB
username: sa
password: haosql
# 初始连接数
initialSize: 5
# 最小连接池数量
......@@ -46,7 +47,7 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
......@@ -75,11 +76,11 @@ spring:
# 地址
host: 127.0.0.1
# 端口,默认为6379
port: 6379
port: 6378
# 数据库索引
database: 1
# 密码
password:
password: Redis@2021
# 连接超时时间
timeout: 10s
lettuce:
......
......@@ -21,16 +21,17 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://36.138.181.113:33060/danger_manage_area_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
# 从库数据源
slave:
password: zehong_/sjz!D
# sqlserver 数据源
sqlserver:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://218.207.92.101:1433;DatabaseName=Park_DB
username: sa
password: haosql
# 初始连接数
initialSize: 5
# 最小连接池数量
......@@ -46,7 +47,7 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
......
......@@ -13,7 +13,7 @@ public enum DataSourceType
MASTER,
/**
*
* sqlserver数据
*/
SLAVE
SQL_SERVER
}
......@@ -41,9 +41,9 @@ public class DruidConfig
}
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
@ConfigurationProperties("spring.datasource.druid.sqlserver")
@ConditionalOnProperty(prefix = "spring.datasource.druid.sqlserver", name = "enabled", havingValue = "true")
public DataSource sqlServerDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
......@@ -55,7 +55,7 @@ public class DruidConfig
{
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
setDataSource(targetDataSources, DataSourceType.SQL_SERVER.name(), "sqlServerDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources);
}
......
package com.zehong.system.mapper;
import com.zehong.common.annotation.DataSource;
import com.zehong.common.enums.DataSourceType;
import java.util.List;
import java.util.Map;
/**
* @author geng
* 车辆进出记录
*/
public interface OutParkRecordsMapper {
/**
* 统计进出车辆数量
* @return 统计数
*/
List<Map<String,Object>> statisticsVehicleByActionType();
/**
* 统计在场车辆数量
* @return 统计结果
*/
List<Map<String,Object>> statisticsStayInVehicles();
/**
* 最新进场车辆记录
* @return 车辆信息
*/
Map<String,Object> lastImportData();
/**
* 最新出场车辆记录
* @return 车辆信息
*/
Map<String,Object> lastExportData();
}
package com.zehong.system.service;
import java.util.List;
import java.util.Map;
/**
* @author geng
* 车辆进出记录
*/
public interface OutParkRecordsService {
/**
* 统计进出及在场车辆数量
* @return 统计数
*/
Map<String,Object> statisticsVehicles();
}
package com.zehong.system.service.impl;
import com.zehong.common.annotation.DataSource;
import com.zehong.common.enums.DataSourceType;
import com.zehong.system.mapper.OutParkRecordsMapper;
import com.zehong.system.service.OutParkRecordsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author geng
* 进出车辆统计
*/
@Service
public class OutParkRecordsServiceImpl implements OutParkRecordsService {
@Resource
private OutParkRecordsMapper outParkRecordsMapper;
@DataSource(DataSourceType.SQL_SERVER)
@Override
public Map<String, Object> statisticsVehicles() {
Map<String,Object> result = new HashMap<>(16);
List<Map<String,Object>> exportAndImport = outParkRecordsMapper.statisticsVehicleByActionType();
for(Map info : exportAndImport){
if("0".equals(info.get("actionType"))){
result.put("importCount",info.get("counts"));
}
if("1".equals(info.get("actionType"))){
result.put("exportCount",info.get("counts"));
}
}
List<Map<String,Object>> stayInCarsData = outParkRecordsMapper.statisticsStayInVehicles();
result.put("stayInCount",stayInCarsData.size());
result.put("stayInCarsData",stayInCarsData);
result.put("lastImportData",outParkRecordsMapper.lastImportData());
result.put("lastExportData",outParkRecordsMapper.lastExportData());
return result;
}
}
<?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.zehong.system.mapper.OutParkRecordsMapper">
<resultMap id="statisticsVehicleByActionTypeResult" type="HashMap">
<result property="actionType" column="action_type" jdbcType="VARCHAR" />
<result property="counts" column="counts" jdbcType="INTEGER"/>
</resultMap>
<resultMap id="statisticsImportVehicleResult" type="HashMap">
<result property="plateNumber" column="plateNumber" jdbcType="VARCHAR" />
<result property="inParkTime" column="InParkTime" jdbcType="DATE"/>
</resultMap>
<resultMap id="statisticsExportVehicleResult" type="HashMap">
<result property="plateNumber" column="plateNumber" jdbcType="VARCHAR" />
<result property="outParkTime" column="OutParkTime" jdbcType="DATE"/>
</resultMap>
<select id="statisticsVehicleByActionType" resultMap="statisticsVehicleByActionTypeResult">
SELECT
'0' as action_type,
COUNT(id) as counts
FROM
Sys_Park_OutParkRecords
WHERE
InParkTime IS NOT NULL
UNION ALL
SELECT
'1' as action_type,
COUNT(id) as counts
FROM
Sys_Park_OutParkRecords
WHERE
OutParkTime IS NOT NULL
</select>
<select id="statisticsStayInVehicles" resultMap="statisticsImportVehicleResult">
SELECT
plateNumber,
InParkTime
FROM(
SELECT
plateNumber,
MAX(InParkTime) as InParkTime,
MAX(OutParkTime) as OutParkTime
FROM
Sys_Park_OutParkRecords
GROUP BY plateNumber
)stay
WHERE ISNULL(DATEDIFF(S, '1970-01-01 00:00:00', stay.InParkTime),0) - ISNULL(DATEDIFF(S, '1970-01-01 00:00:00', stay.OutParkTime),0) >0
</select>
<select id="lastImportData" resultMap="statisticsImportVehicleResult">
SELECT
TOP 1 plateNumber,InParkTime
FROM
Sys_Park_OutParkRecords
WHERE
InParkTime IS NOT NULL
ORDER BY InParkTime DESC
</select>
<select id="lastExportData" resultMap="statisticsExportVehicleResult">
SELECT
TOP 1 plateNumber,OutParkTime
FROM
Sys_Park_OutParkRecords
WHERE
OutParkTime IS NOT NULL
ORDER BY OutParkTime DESC
</select>
</mapper>
\ No newline at end of file
......@@ -59,3 +59,12 @@ export function exportInfo(query) {
params: query
})
}
//车辆统计信息
export function statisticsVehicles(query) {
return request({
url: '/outParkRecords/statisticsVehicles',
method: 'get',
params: query
})
}
......@@ -47,7 +47,7 @@
</div>
<div class="ru-in-r">
<span>入场</span>
<div style="color: #0fb980;">0</div>
<div style="color: #0fb980;">{{importCars}}</div>
</div>
</div>
<div class="ent-ru-in">
......@@ -56,7 +56,7 @@
</div>
<div class="ru-in-r">
<span>出场</span>
<div style="color: #f95f5f;">0</div>
<div style="color: #f95f5f;">{{exportCars}}</div>
</div>
</div>
<div class="ent-ru-in">
......@@ -65,33 +65,11 @@
</div>
<div class="ru-in-r">
<span>在场</span>
<div style="color: #3a65ed">0</div>
<div style="color: #3a65ed">{{stayInCars}}</div>
</div>
</div>
</div>
</div>
<!-- <div class="ent-r ent">
<span>车辆出入</span>
<div class="ent-div"></div>
<div class="ent-r-car">
<div class="r-car-in">
<img src="../../assets/img/Group 1.png" alt="">
<div>车辆进场</div>
<p style="color: #07b9b9;">0</p>
</div>
<div class="r-car-in">
<img src="../../assets/img/Gr.png" alt="">
<div>车辆进场</div>
<p style="color: rgb(250 81 81);">0</p>
</div>
<div class="r-car-in">
<img src="../../assets/img/Group.png" alt="">
<div>车辆进场</div>
<p style="color: rgb(54 98 236);">0</p>
</div>
</div>
</div> -->
</div>
<div class="entrance-l-a">
......@@ -135,8 +113,8 @@
<div class="ent-b-in">
<img src="../../assets/img/car.png" alt="">
<div>车辆类型:<span></span> </div>
<div>车辆号牌:<span></span> </div>
<div>入场时间:<span></span> </div>
<div>车辆号牌:<span>{{lastImportCarData?lastImportCarData.plateNumber:"-"}}</span> </div>
<div>入场时间:<span>{{lastImportCarData?changeDateFormat(lastImportCarData.inParkTime):"-"}}</span> </div>
</div>
</div>
<div class="ent-b-car1">
......@@ -148,8 +126,8 @@
<div class="ent-b-in">
<img src="../../assets/img/car.png" alt="">
<div>车辆类型:<span></span> </div>
<div>车辆号牌:<span></span> </div>
<div>入场时间:<span></span> </div>
<div>车辆号牌:<span>{{lastExportCarData?lastExportCarData.plateNumber:"-"}}</span> </div>
<div>入场时间:<span>{{lastExportCarData?changeDateFormat(lastExportCarData.outParkTime):"-"}}</span> </div>
</div>
</div>
</div>
......@@ -162,7 +140,7 @@
:data="tableData"
style="width: 100%">
<el-table-column
prop="date"
prop="plateNumber"
label="车牌号"
width="170">
</el-table-column>
......@@ -171,7 +149,7 @@
label="类型">
</el-table-column>
<el-table-column
prop="address"
prop="inParkTime"
label="入场时间"
width="200">
</el-table-column>
......@@ -189,29 +167,12 @@
</template>
<script>
import { getEntranceGuardPersonInfo } from "@/api/entranceguard/entranceguardPerson"
import { getEntranceGuardPersonInfo,statisticsVehicles } from "@/api/entranceguard/entranceguardPerson"
export default {
name: "",
data() {
return {
tableData: [
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
// { date: '冀A66666',name: '小轿车',address: '2022-10-15 12:00:00'},
],
tableData: [],
//入场人数
exportCount:"",
//出场人数
......@@ -221,11 +182,32 @@
//最新入场信息
lastImportData:{},
//最新出场信息
lastExportData:{}
lastExportData:{},
//出场车辆
exportCars:"",
//入场车辆数
importCars:"",
//在场人数
stayInCars:"",
//最新入场信息
lastImportCarData:{},
//最新出场信息
lastExportCarData:{},
timer:""
}
},
created(){
this.initPersonData();
let that = this;
that.initPersonData();
that.initVehicleData();
let timer = setInterval(() => {
that.initPersonData();
that.initVehicleData();
}, 3000);
this.$once('hook:beforeDestroy', () => {
clearInterval(timer)
timer = null
})
},
methods:{
initPersonData(){
......@@ -241,6 +223,28 @@
//最新出场信息
this.lastExportData = res.data.lastExportData;
})
},
initVehicleData(){
statisticsVehicles().then(res =>{
//入场车辆数
this.importCars = res.data.importCount;
//出场车辆数
this.exportCars = res.data.exportCount;
//在场车辆数
this.stayInCars = res.data.stayInCount;
//在场车辆
this.tableData = res.data.stayInCarsData;
//最新入场信息
this.lastImportCarData = res.data.lastImportData;
//最新出场信息
this.lastExportCarData = res.data.lastExportData;
})
},
changeDateFormat(jsondate) {
if(!jsondate){
return;
}
return new Date(jsondate).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
}
}
};
......
......@@ -34,8 +34,8 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
// target: process.env.VUE_APP_TARGET,
target: `http://192.168.2.21:8908/dangerManage`,
target: process.env.VUE_APP_TARGET,
//target: `http://192.168.2.21:8908/dangerManage`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment