Commit 40ebeb68 authored by 高晓帆's avatar 高晓帆

最新代码

parent 6fc99df2
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
package-lock.json*
yarn.lock*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
cmake_minimum_required(VERSION 3.5)
project (TruckMonitorView)
set (CMAKE_CXX_STANDARD 11)
# Version.
set (MAJOR_VERSION "1")
set (MINOR_VERSION "1")
set (PATCH_VERSION "3")
# Import cmake modules.
list (APPEND CMAKE_MODULE_PATH "$ENV{HT_BUILDSYS_CMAKE_MODULES}")
include (HtCMakePub)
install_system_packages (
PACKAGES "nodejs"
)
add_custom_command (
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/dist"
COMMAND "npm" "install" "--force"
COMMAND "npm" "run" "build"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
add_custom_target ("${PROJECT_NAME}" ALL
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/dist"
)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/dist"
DESTINATION "/var/www/${PROJECT_NAME}"
)
# Pack.
set (CPACK_PACKAGE_NAME "ht-${PROJECT_NAME}")
set (CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set (CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set (CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set (CPACK_PACKAGE_CONTACT "Fan Jianping <jianping.fan@waytous.com>, Li Lingyan <lingyan.li@waytous.com>, Gao Xiaofan <xiaofan.gao@waytous.com>")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION "webtruckview. Branch: ${GIT_BRANCH}. Commit: ${GIT_LAST_COMMIT}.")
include(HtCMakeDeb)
# truck-monitor-project
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
{
"name": "truck-monitor-project",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@turf/turf": "^6.5.0",
"axios": "^1.3.4",
"deck.gl": "^8.9.21",
"dexie": "^3.2.3",
"leaflet": "^1.9.3",
"leaflet-rotate": "^0.2.5",
"leaflet-rotatedmarker": "^0.2.0",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"pako": "^2.1.0",
"pinia": "^2.0.33",
"view-ui-plus": "^1.3.5",
"vue": "^3.2.47",
"vue-router": "^4.1.6",
"worker-loader": "^3.0.8"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"vite": "^4.1.4"
}
}
{
"SERVICE_IP": "172.16.0.153:1234",
"MAP_CENTER": [39.74441007068,111.24544532751],
"version": "1.1.3"
}
\ No newline at end of file
<script setup>
import { RouterView } from 'vue-router'
</script>
<template>
<RouterView />
</template>
<style scoped>
</style>
/* color palette from <https://github.com/vuejs/theme> */
:root {
height: 100%;
width: 100%;
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
position: relative;
font-weight: normal;
}
body {
width: 100%;
height: 100%;
overflow: hidden;
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html, body {
overflow: hidden;
font-size: 100px;
}
.ivu-modal-content {
background: #3b4147 !important;
border-radius: 10px;
}
.ivu-modal-header {
border-bottom: 1px solid #6a727b !important;
background: #111521;
border-radius: 10px 10px 0 0 ;
display: flex;
height: .5rem;
line-height: .5rem;
}
.ivu-modal-body {
background: #1B202E;
border-radius: 0 0 10px 10px;
font-size: 1.2vw !important;
}
.ivu-modal-footer {
border-top: 1px solid #6a727b !important;
background: #111521;
display: flex;
justify-content: end;
}
.ivu-modal-header-inner, .ivu-modal-body {
color: #fff !important;
}
.ivu-message-notice-content {
background: #3b4147 !important;
color: #fff !important;
}
.modal-detail .ivu-modal-body {
padding: 0;
font-size: 16px;
}
.ivu-btn-primary {
background: rgba(99,169,251,0.6);
border-radius: 6px 6px 6px 6px;
opacity: 1;
border: 2px solid #63A9FB;
}
ul {
list-style: none;
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
@import './base.css';
#app {
width: 100%;
height: 100%;
box-sizing: border-box;
font-size: 1.2vw;
}
import Worker from './worker/index'
import Socket from './socket/index'
import IndexDB from './indexDB/IndexDB'
export default class IndexRoot {
constructor() {
this.worker = null
this.sock = null
this.indexDB = null
}
init() {
const self = this
return new Promise((resolve) => {
let worker = new Worker(this)
let indexDB = new IndexDB(this)
this.worker = worker
this.indexDB = indexDB
let sock = new Socket(this)
sock.getConnection().then(socket => {
self.sock = socket
resolve(socket)
})
})
}
destroyData() {
this.worker.destroyData()
}
}
\ No newline at end of file
import Dexie from "dexie";
const DB_NAME = 'Truck_Monitor1';
export default class IndexDB {
constructor(root) {
this.db = null;
this.version = 1
this.root = root
this.openLocalDB()
}
async openLocalDB () {
this.db = new Dexie(DB_NAME)
try {
this.db && await this.db.open()
this.version = this.db.verno
} catch (error) {
return console.warn('No data is stored yet!', error)
}
// 需要获取db的当前的version,再升级的时候存储新的store
// this.version = this.db.verno
}
async initStore (list) {
let msg = {}
list.forEach(item => {
msg[item] = 'version'
})
let version = parseInt(this.db.verno, 10)
console.log(version)
version = version || 1
await this.db.close()
console.log('dbOpen', this.db.isOpen())
this.db.version(version + 1).stores(msg)
this.version = version + 1
await this.db.open()
}
async compareTable(list) {
let tables = this.db.tables.map(item => item.name)
if (tables.length !== list.length) {
let initList = []
list.forEach(item => {
if (!tables.includes(item)) {
initList.push(item.layerName)
}
})
await this.initStore(initList)
}
}
async storeData(name, msg, version) {
await this.db.open()
let storeTable;
try {
storeTable = this.db.table(name)
if (storeTable) {
await storeTable.clear()
}
let data = {msg, version}
this.db.transaction('rw', storeTable, () => {
storeTable.put(data)
}).then(() => {
console.log(`added ${name}`)
}).catch(err => {
console.warn(err)
})
} catch (error) {
console.error(error)
storeTable = null;
}
}
async getStoreData(name, version) {
try{
if (!this.db.isOpen()) {
await this.db.open()
}
if (this.db.tables.length && this.db.table(name)) {
return this.db.table(name).get({ version })
} else {
return new Promise((resolve) => {
resolve('')
})
}
} catch(error) {
console.warn(error)
return new Promise((resolve) => {
resolve('')
})
}
}
}
\ No newline at end of file
This diff is collapsed.
const VEHICLE_IMAGE = {
1: 'exca_planform',
20: 'exca_planform',
21: 'exca_planform',
2: 'dumpMachine',
30: 'dumpMachine',
31: 'dumpMachine',
3: 'manCar',
40: 'manCar',
41: 'wateringCar',
42: 'manCar',
43: 'grader'
}
function dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
const { enable, data } = safe
if (!enable) return
const safeType = [1, 20, 21].includes(vehicleType) ? 'circle' : 'rectangle'
const dealedData = []
for (let i = 0; i < data.length; i++) {
let item = data[i]
if (safeType === 'rectangle') {
let [lngs, lats] = item
let datas = []
lngs.forEach((item, index) => datas.push([lats[index], item]))
dealedData.push(datas)
}
}
safe = Object.assign({}, safe, {
dealedData,
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return safe
}
function dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude) {
let {enable, data} = safe
let {enable: preEnable, data: preData} = preSafe
if (enable === preEnable && enable === false) return
if (enable === false) return safe
if (data.length !== preData.length) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
let isDiff = false
for (let i = 0; i < data.length; i++) {
let item = data[i]
let preItem = preData[i]
if (item.toString() != preItem.toString()) {
isDiff = true
break
}
}
if (isDiff) return dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude) {
if (!traj) return
let { trajPath, radius } = traj
// if ((!trajPath || !trajPath.length) && ![1, 20, 21].includes(vehicleType) && !radius) return
if([1, 20, 21].includes(vehicleType) && radius) return
if (![1, 20, 21].includes(vehicleType)) {
if(!trajPath || !trajPath.length) return;
let datas = []
trajPath.forEach(item => {
let [lon, lat] = item
datas.push([lat, lon])
})
traj['dealedData'] = datas
}
traj = Object.assign({}, traj, {
vehicleLatitude,
vehicleLongtitude,
vehicleType
})
return traj
}
function dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic) {
let {radius, trajPath} = traj
let {radius: preRadius, trajPath: preTrajPath} = preTraj
// if (preRadius === radius && radius === 0) return
if (!preTrajPath) return
if (preTrajPath.length === trajPath.length && trajPath.length === 0) return
if ([1, 20, 21].includes(vehicleType)) {
if (preBasic.vehicleLatitude == vehicleLatitude && preBasic.vehicleLongtitude == vehicleLongtitude && preRadius == radius) return
return traj
}
if (trajPath.toString() == preTrajPath.toString()) return
return dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude)
}
function dealDiffBasic(preBasic, basic, deviceId) {
let {vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
if (vehicleID === deviceId) return false
let isSame = vehicleType === preBasic.vehicleType
&& vehicleLoad === preBasic.vehicleLoad
&& vehicleLatitude === preBasic.vehicleLatitude
&& vehicleLongtitude === preBasic.vehicleLongtitude
&& vehicleHeading === preBasic.vehicleHeading
return isSame
}
self.onmessage = function({data}) {
let gps = 4, currentBasic = null
try {
const {type, msg, deviceId, pre} = data
let safeObj = {}, trajObj = {}, vehicles = []
for (let i = 0; i < msg.length; i++) {
let item = msg[i]
const { basic, safe, traj } = item
const { vehicleType, vehicleLoad, vehicleLatitude, vehicleLongtitude, vehicleHeading, vehicleID } = basic
let image = null
if ([0, 11, 10, 15].includes(vehicleType)) {
image = vehicleLoad > 10 ? 'heavyTruck1' : 'emptyTruck1'
} else {
image = VEHICLE_IMAGE[vehicleType]
}
basic['image'] = image
let preVehicle = pre.find(p => p.basic.vehicleID === vehicleID)
let isSame = false, safeResult, trajResult
if (preVehicle) {
let {basic: preBasic, safe: preSafe, traj: preTraj} = preVehicle
safeResult = dealSafeDiff(preSafe, safe, vehicleType, vehicleLatitude, vehicleLongtitude,)
trajResult = dealTrjaDiff(preTraj, traj, vehicleType, vehicleLatitude, vehicleLongtitude, preBasic)
isSame = dealDiffBasic(preBasic, basic, deviceId)
} else {
safeResult = dealSafe(safe, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
trajResult = dealTraj(traj, vehicleType, vehicleLatitude, vehicleLongtitude, vehicleID)
isSame = false
}
if (safeResult) safeObj[vehicleID] = safeResult
if (trajResult) trajObj[vehicleID] = trajResult
if (!isSame) vehicles.push(basic)
if (vehicleID === deviceId) {
gps = basic.gps
currentBasic = basic
}
}
self.postMessage({type, vehicles, safeObj, trajObj, gps, currentBasic})
data = null
currentBasic = null
safeObj = {}
trajObj = {}
vehicles = []
} catch(err) {
console.log(err)
}
}
\ No newline at end of file
import pako from 'pako'
self.onmessage = function({ data }) {
let result = null;
let mapName = null;
try {
const {type, msg} = data;
let [, , name] = type.split('/')
mapName = name
let charData = msg.split('').map( x => x.charCodeAt(0));
let binData = new Uint8Array(charData);
result = pako.inflate(binData, {to: 'string'});
} catch(error) {
console.log(error)
}
self.postMessage({mapName, result, mapVersion: data.version})
data = null;
result = null;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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