Commit 326e96bc by 李金轩

ljx

1 parent b6694db2
import {axiosInstance} from "@/Request/PublicAxiosInstance"
import {} from "@/PublicUtil/PublicUtil"
import imagePackageApi from '@/views/DataLabel/ImagePackage/ImagePackageApi'
export const getUserNameIdMap = function(targetData) {
axiosInstance.request(
{
method: 'GET',
url: `/users`,
}
).then(
(r) => {
const list = r.data
for (const item of list)
{
targetData[item.name] = item.id
}
}
)
}
export const getCompanyMap = function(targetData) {
axiosInstance.request(
{
method: 'GET',
url: `/accounts`,
}
).then(
(r) => {
const list = r.data
for (const item of list)
{
targetData[item.id] = item.name
}
}
)
}
export const getImagePackageMap = function(targetData) {
imagePackageApi.getImagePackageList().then(
(r) => {
const list = r.data
for (const item of list)
{
targetData[item.name] = item.id
}
}
)
}
export const getCanCreateUsernameIdMap = function() {
const currentUserType = localStorage.getItem('currentUserType')
switch (currentUserType)
{
case '0': // 超级管理员
{
return {
"超级管理员": 0,
"项目经理": 1,
"内部质检员": 2,
"外部管理员": 3,
"外部质检员": 4,
"外部标注员": 5,
"兼职标注员": 6,
"数据清洗员": 7,
}
}
case '1': // 项目经理
{
return {
"内部质检员": 2,
"外部管理员": 3,
"外部质检员": 4,
"外部标注员": 5,
"兼职标注员": 6,
}
}
case '3': // 外部管理员
{
return {
"外部质检员": 4,
"外部标注员": 5,
"兼职标注员": 6,
}
}
default:
{
return {}
}
}
}
...@@ -15,7 +15,7 @@ axiosInstance.interceptors.request.use( ...@@ -15,7 +15,7 @@ axiosInstance.interceptors.request.use(
config => { config => {
if (window.location.hostname === 'localhost') if (window.location.hostname === 'localhost')
{ {
config.headers.Authorization = 'c3b85226-4301-45fb-a087-4caf3194fc90' config.headers.Authorization = '967c22ec-4257-40c8-9385-5c0f068afaa7'
} }
else else
{ {
......
<template> <template>
<a-select v-model:value="value" mode="multiple" style="width: 200px"> <a-form :model="querySnapshotRecordForm" layout="inline">
<a-select-option value="jack">全选</a-select-option> <a-form-item label="集团:">
<a-select-option value="jack">Jack</a-select-option> <a-select v-model:value="querySnapshotRecordForm.account_id"
<a-select-option value="lucy">Lucy</a-select-option> style="width: 200px"
<a-select-option value="disabled">Disabled</a-select-option> mode="multiple"
<a-select-option value="Yiminghe">yiminghe</a-select-option> :maxTagCount="1"
@change="onAccountChange"
>
<a-select-option
v-for="item in accountList"
:value="item.id"
>
{{ item.name }}
</a-select-option>
</a-select> </a-select>
</a-form-item>
<a-form-item label="广场:">
<a-select v-model:value="querySnapshotRecordForm.plaza_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
@change="onPlazaChange"
>
<a-select-option
v-for="item in plazaList"
:value="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="选择日期:">
<a-range-picker v-model:value="querySnapshotRecordForm.date" :format="'YYYY-MM-DD'"/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="confirmSearch" :loading="isLoading">查询</a-button>
</a-form-item>
</a-form>
<div v-loading="isLoading">
<el-row v-for="row in pagedTableDataList">
<el-col :span="3" v-for="item in row">
<div style="margin: 0 5px">
<div style="display:flex; justify-content: flex-end ">
<span @click="downloadFile(item.features_url)"
style="color: #409EFF;font-size: 15px;cursor: pointer;">
下载特征值文件
</span>
</div>
<el-image :src="item.picture_url"
:fit="'fill'"
class="single-image">
</el-image>
<div>时间:{{ item.counttime }}</div>
<div>方向:{{ formatDirection(item.direction) }}</div>
<div>地点:{{ item.gate_name }}</div>
</div>
</el-col>
</el-row>
<a-pagination
v-model:current="pageNum"
v-model:pageSize="pageSize"
:total="total"
:show-total="total => `共 ${total} 条`"
:pageSizeOptions="['24', '48', '96', '192']"
@change="onPageNumChange"
@showSizeChange="onPageSizeChange"
show-size-changer
show-quick-jumper
style="text-align:center"
/>
</div>
</template> </template>
<script> <script>
import {reactive, ref} from 'vue' import {computed, reactive, ref, toRaw} from 'vue'
import dataRerunApi from '@/views/DataRerun/DataRerunApi' import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import {isArray} from '@/PublicUtil/Judgment'
import moment from 'moment'
import {filterEmptyValueInObject, formatDate, formatTime, getPagedList} from '@/PublicUtil/PublicUtil'
export default { export default {
setup: function() { setup() {
// scalar // scalar
const value = ref() const pageNum = ref(1)
const pageSize = ref(24)
const total = ref()
const isLoading = ref(false)
// sequence // sequence
// mapping const dataList = ref([])
const accountMap = reactive({}) const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
const pagedTableDataList = computed(
() => {
return getPagedList(dataList.value, 8)
}
)
const querySnapshotRecordForm = reactive(
{
account_id: [],
plaza_id: [],
zone_id: [],
gate_id: [],
type: 0,
direction: [1, -1, 0],
picType: 2,
personType: [1, 2],
date: [moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'), moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD')],
startTime: moment('00:00:00', 'HH:mm:ss'),
endTime: moment('23:59:59', 'HH:mm:ss'),
}
)
// function // function
const onPageNumChange = function(num) {
pageNum.value = num
confirmSearch()
}
const onPageSizeChange = function(current, size) {
pageNum.value = 1
pageSize.value = size
confirmSearch()
}
const onSubmit = function() {
}
const onAccountChange = function() {
getPlazaList()
getZoneList()
getGateList()
}
const onPlazaChange = function() {
getZoneList()
getGateList()
}
const onZoneChange = function() {
getGateList()
}
const getPlazaList = function() {
querySnapshotRecordForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList(
{
account_id: querySnapshotRecordForm.account_id.toString()
}
).then(
(r) => {
if (isArray(r))
{
plazaList.value = r
}
}
)
}
const getZoneList = function() {
querySnapshotRecordForm.zone_id = []
zoneList.value = []
snapshotRecordApi.getZoneList(
{
account_id: querySnapshotRecordForm.account_id.toString(),
plaza_id: querySnapshotRecordForm.plaza_id.toString(),
}
).then(
(r) => {
if (isArray(r))
{
zoneList.value = r
}
}
)
}
const getGateList = function() {
querySnapshotRecordForm.gate_id = []
gateList.value = []
snapshotRecordApi.getGateList(
{
account_id: querySnapshotRecordForm.account_id.toString(),
plaza_id: querySnapshotRecordForm.plaza_id.toString(),
zone_id: querySnapshotRecordForm.zone_id.toString(),
type: querySnapshotRecordForm.type,
}
).then(
(r) => {
if (isArray(r.data))
{
gateList.value = r.data
}
}
)
}
const getAccountList = function() { const getAccountList = function() {
dataRerunApi.getAccountList().then( querySnapshotRecordForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => { (r) => {
for (const item of r) if (isArray(r))
{ {
accountMap[item.id] = item.name accountList.value = r
}
}
)
}
const confirmSearch = function() {
isLoading.value = true
const rawData = toRaw(querySnapshotRecordForm)
const data = filterEmptyValueInObject(
{
account_id: rawData.account_id.toString(),
type: rawData.type,
plaza_id: rawData.plaza_id.toString(),
zone_id: rawData.zone_id.toString(),
gate_id: rawData.gate_id.toString(),
direction: rawData.direction.toString(),
picType: rawData.picType,
personType: rawData.personType.toString(),
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
page: pageNum.value - 1,
pageSize: pageSize.value,
} }
)
snapshotRecordApi.getSnapshotRecordList(data).then(
(r) => {
isLoading.value = false
dataList.value = r.data.persons
total.value = r.data.pageNum
} }
) )
} }
const initialize = function() { const formatDirection = function(number) {
switch (number)
{
case 1:
{
return '进'
}
case 0:
{
return '出'
}
case 2:
{
return '横穿'
}
default:
{
break
}
}
}
const downloadFile = function(url) {
window.open(url)
}
const __main = function() {
getAccountList() getAccountList()
} }
initialize() __main()
return { return {
// scalar // scalar
value, isLoading,
pageNum,
pageSize,
total,
// sequence // sequence
accountList,
plazaList,
zoneList,
gateList,
pagedTableDataList,
// mapping // mapping
querySnapshotRecordForm,
// function // function
onPageNumChange,
onPageSizeChange,
onSubmit,
onAccountChange,
onPlazaChange,
onZoneChange,
confirmSearch,
formatDirection,
downloadFile,
} }
} }
} }
</script> </script>
<style scoped> <style lang="less" scoped>
@import "./DataRerun.less";
</style> </style>
<template> <template>
<a-form :model="querySnapshotRecordForm" layout="inline">
<a-form-item label="集团:">
<a-select v-model:value="querySnapshotRecordForm.account_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
@change="onAccountChange"
>
<a-select-option
v-for="item in accountList"
:value="item.id"
>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="广场:">
<a-select v-model:value="querySnapshotRecordForm.plaza_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
>
<a-select-option
v-for="item in plazaList"
:value="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="特征重提类型:">
<a-select v-model:value="querySnapshotRecordForm.featureRevisitType" style="width: 200px">
<a-select-option :value="1">店员库重建</a-select-option>
<a-select-option :value="2">顾客库重建</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="选择日期:" v-if="querySnapshotRecordForm.featureRevisitType === 2">
<a-date-picker v-model:value="querySnapshotRecordForm.date"/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="initializeWebSocket">查询</a-button>
</a-form-item>
</a-form>
<div class="result-header">结果展示</div>
<el-progress v-for="item in resultList" :text-inside="true" :stroke-width="26" :percentage="item?.progress"/>
</template> </template>
<script> <script>
import featureLibraryRebuildApi from '@/views/FeatureLibraryRebuild/FeatureLibraryRebuildApi'
import {reactive, ref, toRaw} from 'vue'
import moment from 'moment'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import {isArray} from '@/PublicUtil/Judgment'
import {formatDate, formatTime} from '@/PublicUtil/PublicUtil'
export default { export default {
name: "FeatureLibraryRebuild" setup() {
let webSocket = undefined
const resultList = ref([])
// sequence
const dataList = ref([])
const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
const querySnapshotRecordForm = reactive(
{
account_id: [],
plaza_id: [],
featureRevisitType: 1,
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
}
)
const onAccountChange = function() {
getPlazaList()
}
const getPlazaList = function() {
querySnapshotRecordForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList(
{
account_id: querySnapshotRecordForm.account_id.toString()
}
).then(
(r) => {
if (isArray(r))
{
plazaList.value = r
}
}
)
}
const getAccountList = function() {
querySnapshotRecordForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => {
if (isArray(r))
{
accountList.value = r
}
}
)
}
const floatToPercent = function(floatNum) {
if (!floatNum)
{
return 0
}
let formatNum = Math.floor(floatNum * 100)
return formatNum >= 100 ? 100 : formatNum
}
const dealMessage = function(message) {
// scheduleType
const {dates, mallIds, mallNames, status, stepCount, scheduleType, counter} = message
let resObj = {}
resObj.dates = dates
resObj.mallIds = mallIds
resObj.mallNames = mallNames
resObj.status = status
resObj.progress = floatToPercent(stepCount)
resObj.totalNum = 0
resObj.totalPage = 0
resObj.current = 0
resObj.curPageSize = 0
resObj.currentPage = 0
resObj.scheduleType = scheduleType
if (counter)
{
// dataNum dateMallNum step totalData totalDate totalMall totalMallDateProduct allDataCount
resObj.totalNum = counter.allDataCount
resObj.totalPage = counter.totalMallDateProduct
resObj.current = counter.dataNum
resObj.curPageSize = counter.totalData
resObj.currentPage = counter.dateMallNum
}
if (resultList.value.length)
{
const isSameScheduleType = resultList.value.some(item => item.scheduleType === scheduleType)
isSameScheduleType
? resultList.value.forEach(item => {
//
item.progress = floatToPercent(stepCount)
if (counter)
{
item.totalNum = counter.allDataCount
item.totalPage = counter.totalMallDateProduct
item.current = counter.dataNum
item.curPageSize = counter.totalData
item.currentPage = counter.dateMallNum
}
})
: resultList.value.push(resObj)
resObj = {}
}
else
{
resultList.value.push(resObj)
resObj = {}
}
}
const initializeWebSocket = function() {
if (webSocket !== undefined)
{
webSocket.close()
}
resultList.value = []
webSocket = new WebSocket(`ws://store.keliuyun.com:9998/recal/schedule/rebuildFeatureLib${querySnapshotRecordForm.featureRevisitType}`)
webSocket.onopen = queryData
webSocket.onmessage = function(event) {
let message = JSON.parse(event.data)
log('[onmessage]:', message)
dealMessage(message)
if (message.stepCount === 1)
{
webSocket.close()
}
}
}
const queryData = function() {
const rawData = toRaw(querySnapshotRecordForm)
switch (rawData.featureRevisitType)
{
case 1:
{
const data = {
mallIds: rawData.plaza_id,
scheduleType: `rebuildFeatureLib${rawData.featureRevisitType}`,
}
featureLibraryRebuildApi.getStaffResult(data)
break
}
case 2:
{
const data = {
mallIds: rawData.plaza_id,
scheduleType: `rebuildFeatureLib${rawData.featureRevisitType}`,
startDate: formatDate(rawData.date) + ' ' + '00:00:00',
endDate: formatDate(rawData.date) + ' ' + '23:59:59',
}
featureLibraryRebuildApi.getCustomResult(data)
break
}
}
}
const __main = function() {
getAccountList()
}
__main()
return {
// sequence
accountList,
plazaList,
zoneList,
gateList,
resultList,
querySnapshotRecordForm,
onAccountChange,
initializeWebSocket,
}
}
} }
</script> </script>
......
import axiosInstance from "@/Request/PublicAxiosInstance"
import {filterEmptyValueInObject} from "@/PublicUtil/PublicUtil"
class FeatureLibraryRebuildApi {
getStaffResult(data) {
return axiosInstance.request(
{
method: 'POST',
url: `/mall/staffPool`,
data: data
}
)
}
getCustomResult(data) {
return axiosInstance.request(
{
method: 'POST',
url: `/mall/customPool`,
data: data
}
)
}
}
const featureLibraryRebuildApi = new FeatureLibraryRebuildApi()
export default featureLibraryRebuildApi
<template> <template>
<a-form :model="querySnapshotRecordForm" layout="inline">
<a-form-item label="集团:">
<a-select v-model:value="querySnapshotRecordForm.account_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
@change="onAccountChange"
>
<a-select-option
v-for="item in accountList"
:value="item.id"
>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="广场:">
<a-select v-model:value="querySnapshotRecordForm.plaza_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
>
<a-select-option
v-for="item in plazaList"
:value="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="特征重提类型:">
<a-select v-model:value="querySnapshotRecordForm.featureRevisitType" style="width: 200px">
<a-select-option :value="0">人脸+全身照特征</a-select-option>
<a-select-option :value="1">人脸特征</a-select-option>
<a-select-option :value="2">全身照特征</a-select-option>
<a-select-option :value="3">店员特征</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="选择日期:" v-if="querySnapshotRecordForm.featureRevisitType !== 3">
<a-date-picker v-model:value="querySnapshotRecordForm.date"/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="initializeWebSocket">查询</a-button>
</a-form-item>
</a-form>
<div class="result-header">结果展示</div>
<el-progress v-for="item in resultList" :text-inside="true" :stroke-width="26" :percentage="item?.progress"/>
</template> </template>
<script> <script>
import featureLibraryRebuildApi from '@/views/FeatureLibraryRebuild/FeatureLibraryRebuildApi'
import {reactive, ref, toRaw} from 'vue'
import moment from 'moment'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import {isArray} from '@/PublicUtil/Judgment'
import {formatDate, formatTime} from '@/PublicUtil/PublicUtil'
import featureReExtractApi from '@/views/FeatureReExtract/FeatureReExtractApi'
export default { export default {
name: "FeatureRe-extract" setup() {
let webSocket = undefined
const resultList = ref([])
// sequence
const dataList = ref([])
const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
const querySnapshotRecordForm = reactive(
{
account_id: [],
plaza_id: [],
featureRevisitType: 1,
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
}
)
const onAccountChange = function() {
getPlazaList()
}
const getPlazaList = function() {
querySnapshotRecordForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList(
{
account_id: querySnapshotRecordForm.account_id.toString()
}
).then(
(r) => {
if (isArray(r))
{
plazaList.value = r
}
}
)
}
const getAccountList = function() {
querySnapshotRecordForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => {
if (isArray(r))
{
accountList.value = r
}
}
)
}
const floatToPercent = function(floatNum) {
if (!floatNum)
{
return 0
}
let formatNum = Math.floor(floatNum * 100)
return formatNum >= 100 ? 100 : formatNum
}
const dealMessage = function(message) {
// scheduleType
const {dates, mallIds, mallNames, status, stepCount, scheduleType, counter} = message
let resObj = {}
resObj.dates = dates
resObj.mallIds = mallIds
resObj.mallNames = mallNames
resObj.status = status
resObj.progress = floatToPercent(stepCount)
resObj.totalNum = 0
resObj.totalPage = 0
resObj.current = 0
resObj.curPageSize = 0
resObj.currentPage = 0
resObj.scheduleType = scheduleType
if (counter)
{
// dataNum dateMallNum step totalData totalDate totalMall totalMallDateProduct allDataCount
resObj.totalNum = counter.allDataCount
resObj.totalPage = counter.totalMallDateProduct
resObj.current = counter.dataNum
resObj.curPageSize = counter.totalData
resObj.currentPage = counter.dateMallNum
}
if (resultList.value.length)
{
const isSameScheduleType = resultList.value.some(item => item.scheduleType === scheduleType)
isSameScheduleType
? resultList.value.forEach(item => {
//
item.progress = floatToPercent(stepCount)
if (counter)
{
item.totalNum = counter.allDataCount
item.totalPage = counter.totalMallDateProduct
item.current = counter.dataNum
item.curPageSize = counter.totalData
item.currentPage = counter.dateMallNum
}
})
: resultList.value.push(resObj)
resObj = {}
}
else
{
resultList.value.push(resObj)
resObj = {}
}
}
const initializeWebSocket = function() {
if (webSocket !== undefined)
{
webSocket.close()
}
resultList.value = []
webSocket = new WebSocket(`ws://store.keliuyun.com:9998/recal/schedule/revisitFeature${querySnapshotRecordForm.featureRevisitType}`)
webSocket.onopen = queryData
webSocket.onmessage = function(event) {
let message = JSON.parse(event.data)
dealMessage(message)
if (message.stepCount === 1)
{
webSocket.close()
}
}
}
const queryData = function() {
const rawData = toRaw(querySnapshotRecordForm)
if ([0, 1, 2].includes(rawData.featureRevisitType))
{
const data = {
mallIds: rawData.plaza_id,
featureType: rawData.featureRevisitType,
scheduleType: `revisitFeature${rawData.featureRevisitType}`,
startDate: formatDate(rawData.date) + ' ' + '00:00:00',
endDate: formatDate(rawData.date) + ' ' + '23:59:59',
}
featureReExtractApi.getFeatureResult(data)
}
else
{
const data = {
mallIds: rawData.plaza_id,
featureType: rawData.featureRevisitType,
scheduleType: `revisitFeature${rawData.featureRevisitType}`,
}
featureReExtractApi.getStaffFeatureResult(data)
}
}
const __main = function() {
getAccountList()
}
__main()
return {
// sequence
accountList,
plazaList,
zoneList,
gateList,
resultList,
querySnapshotRecordForm,
onAccountChange,
initializeWebSocket,
}
}
} }
</script> </script>
......
import axiosInstance from "@/Request/PublicAxiosInstance"
import {filterEmptyValueInObject} from "@/PublicUtil/PublicUtil"
class FeatureReExtractApi {
getFeatureResult(data) {
return axiosInstance.request(
{
method: 'POST',
url: `/mall/feature`,
data: data
}
)
}
getStaffFeatureResult(data) {
return axiosInstance.request(
{
method: 'POST',
url: `/mall/staffFeature`,
data: data
}
)
}
}
const featureReExtractApi = new FeatureReExtractApi()
export default featureReExtractApi
...@@ -54,11 +54,11 @@ export default defineComponent({ ...@@ -54,11 +54,11 @@ export default defineComponent({
) )
} }
const initialize = function() { const __main = function() {
// log(accessedMenu) // log(accessedMenu)
} }
initialize() __main()
return { return {
// scalar // scalar
......
<template> <template>
<a-form :model="querySnapshotRecordForm" layout="inline">
<a-form-item label="集团:">
<a-select v-model:value="querySnapshotRecordForm.account_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
@change="onAccountChange"
>
<a-select-option
v-for="item in accountList"
:value="item.id"
>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="广场:">
<a-select v-model:value="querySnapshotRecordForm.plaza_id"
style="width: 200px"
mode="multiple"
:maxTagCount="1"
>
<a-select-option
v-for="item in plazaList"
:value="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="特征重提类型:">
<a-select v-model:value="querySnapshotRecordForm.featureRevisitType" style="width: 200px">
<a-select-option :value="1">店员库重建</a-select-option>
<a-select-option :value="2">顾客库重建</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="选择日期:" v-if="querySnapshotRecordForm.featureRevisitType === 2">
<a-date-picker v-model:value="querySnapshotRecordForm.date"/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="initializeWebSocket">查询</a-button>
</a-form-item>
</a-form>
<div class="result-header">结果展示</div>
<el-progress v-for="item in resultList" :text-inside="true" :stroke-width="26" :percentage="item?.progress"/>
</template> </template>
<script> <script>
import featureLibraryRebuildApi from '@/views/FeatureLibraryRebuild/FeatureLibraryRebuildApi'
import {reactive, ref, toRaw} from 'vue'
import moment from 'moment'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import {isArray} from '@/PublicUtil/Judgment'
import {formatDate, formatTime} from '@/PublicUtil/PublicUtil'
export default { export default {
name: "PeopleReContrast" setup() {
let webSocket = undefined
const resultList = ref([])
// sequence
const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
const querySnapshotRecordForm = reactive(
{
account_id: [],
plaza_id: [],
featureRevisitType: 1,
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
}
)
const onAccountChange = function() {
getPlazaList()
}
const getPlazaList = function() {
querySnapshotRecordForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList(
{
account_id: querySnapshotRecordForm.account_id.toString()
}
).then(
(r) => {
if (isArray(r))
{
plazaList.value = r
}
}
)
}
const getAccountList = function() {
querySnapshotRecordForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => {
if (isArray(r))
{
accountList.value = r
}
}
)
}
const floatToPercent = function(floatNum) {
if (!floatNum)
{
return 0
}
let formatNum = Math.floor(floatNum * 100)
return formatNum >= 100 ? 100 : formatNum
}
const dealMessage = function(message) {
// scheduleType
const {dates, mallIds, mallNames, status, stepCount, scheduleType, counter} = message
let resObj = {}
resObj.dates = dates
resObj.mallIds = mallIds
resObj.mallNames = mallNames
resObj.status = status
resObj.progress = floatToPercent(stepCount)
resObj.totalNum = 0
resObj.totalPage = 0
resObj.current = 0
resObj.curPageSize = 0
resObj.currentPage = 0
resObj.scheduleType = scheduleType
if (counter)
{
// dataNum dateMallNum step totalData totalDate totalMall totalMallDateProduct allDataCount
resObj.totalNum = counter.allDataCount
resObj.totalPage = counter.totalMallDateProduct
resObj.current = counter.dataNum
resObj.curPageSize = counter.totalData
resObj.currentPage = counter.dateMallNum
}
if (resultList.value.length)
{
const isSameScheduleType = resultList.value.some(item => item.scheduleType === scheduleType)
isSameScheduleType
? resultList.value.forEach(item => {
//
item.progress = floatToPercent(stepCount)
if (counter)
{
item.totalNum = counter.allDataCount
item.totalPage = counter.totalMallDateProduct
item.current = counter.dataNum
item.curPageSize = counter.totalData
item.currentPage = counter.dateMallNum
}
})
: resultList.value.push(resObj)
resObj = {}
}
else
{
resultList.value.push(resObj)
resObj = {}
}
}
const initializeWebSocket = function() {
if (webSocket !== undefined)
{
webSocket.close()
}
resultList.value = []
webSocket = new WebSocket(`ws://store.keliuyun.com:9998/recal/schedule/rebuildFeatureLib${querySnapshotRecordForm.featureRevisitType}`)
webSocket.onopen = queryData
webSocket.onmessage = function(event) {
let message = JSON.parse(event.data)
log('[onmessage]:', message)
dealMessage(message)
if (message.stepCount === 1)
{
webSocket.close()
}
}
}
const queryData = function() {
const rawData = toRaw(querySnapshotRecordForm)
switch (rawData.featureRevisitType)
{
case 1:
{
const data = {
mallIds: rawData.plaza_id,
scheduleType: `rebuildFeatureLib${rawData.featureRevisitType}`,
}
featureLibraryRebuildApi.getStaffResult(data)
break
}
case 2:
{
const data = {
mallIds: rawData.plaza_id,
scheduleType: `rebuildFeatureLib${rawData.featureRevisitType}`,
startDate: formatDate(rawData.date) + ' ' + '00:00:00',
endDate: formatDate(rawData.date) + ' ' + '23:59:59',
}
featureLibraryRebuildApi.getCustomResult(data)
break
}
}
}
const __main = function() {
getAccountList()
}
__main()
return {
// sequence
accountList,
plazaList,
zoneList,
gateList,
resultList,
querySnapshotRecordForm,
onAccountChange,
initializeWebSocket,
}
}
} }
</script> </script>
......
...@@ -355,11 +355,11 @@ export default { ...@@ -355,11 +355,11 @@ export default {
window.open(url) window.open(url)
} }
const initialize = function() { const __main = function() {
getAccountList() getAccountList()
} }
initialize() __main()
return { return {
// scalar // scalar
......
...@@ -335,11 +335,11 @@ export default { ...@@ -335,11 +335,11 @@ export default {
window.open(url) window.open(url)
} }
const initialize = function() { const __main = function() {
getAccountList() getAccountList()
} }
initialize() __main()
return { return {
// scalar // scalar
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!