|
|
|
@ -34,6 +34,7 @@
@@ -34,6 +34,7 @@
|
|
|
|
|
import { BasicTable, useTable, EditRecordRow, BasicColumn, ActionItem, TableAction } from '/@/components/Table'; |
|
|
|
|
import { formTaskColumns, formSchemeColumns, largeHospitalMapList, smallHospitalMapList, } from './map.data'; |
|
|
|
|
import { buildUUID } from '/@/utils/uuid'; |
|
|
|
|
import { add, divide } from 'lodash-es'; |
|
|
|
|
|
|
|
|
|
/** 类型规范统一声明定义区域 */ |
|
|
|
|
interface WindowState { |
|
|
|
@ -151,48 +152,80 @@
@@ -151,48 +152,80 @@
|
|
|
|
|
const scheme = []; |
|
|
|
|
|
|
|
|
|
const origin = state.formData.takeSpecimenId; |
|
|
|
|
// 抽离计算属性 |
|
|
|
|
const taskDataSource = getDataSource(); |
|
|
|
|
const smallHospitals = Array<any>(); |
|
|
|
|
const largeHospitals = Array<any>(); |
|
|
|
|
taskDataSource.forEach(item => { |
|
|
|
|
const smallHospitalPositions:any[] = []; |
|
|
|
|
const largeHospitalPositions:any[] = []; |
|
|
|
|
taskDataSource.forEach(item => { |
|
|
|
|
// 任务上下级医院唯一匹配ID |
|
|
|
|
const key = buildUUID(); |
|
|
|
|
smallHospitals.push({ |
|
|
|
|
key: key, |
|
|
|
|
smallHospitalId: item.smallHospitalId, |
|
|
|
|
workable: false |
|
|
|
|
}); |
|
|
|
|
largeHospitals.push({ |
|
|
|
|
key: key, |
|
|
|
|
largeHospitalId: item.largeHospitalId, |
|
|
|
|
workable: false |
|
|
|
|
}); |
|
|
|
|
const smallHospital = smallHospitalMapList.find(index => index.id == item.smallHospitalId); |
|
|
|
|
if(smallHospital) smallHospitalPositions.push([key, new AMap.LngLat(smallHospital.lng, smallHospital.lat)]); |
|
|
|
|
const largeHospital = largeHospitalMapList.find(index => index.id == item.largeHospitalId); |
|
|
|
|
if(largeHospital) largeHospitalPositions.push([key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]); |
|
|
|
|
}); |
|
|
|
|
// 途径点 |
|
|
|
|
const waypoints = Array<any>(); |
|
|
|
|
const waypoints:any[] = []; |
|
|
|
|
// 目的地 |
|
|
|
|
let destination; |
|
|
|
|
|
|
|
|
|
/** 1.计算预测大致的智能规划方案可行性数量 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 循环计算出最优方案 |
|
|
|
|
smallHospitals.forEach(small => { |
|
|
|
|
const smallHospital = smallHospitalMapList.find(index => index.id == small.smallHospitalId); |
|
|
|
|
if(smallHospital) { |
|
|
|
|
small.workable = true; |
|
|
|
|
waypoints.push(new AMap.LngLat(smallHospital.lng, smallHospital.lat)); |
|
|
|
|
// 下级医院规划方案二维数组 |
|
|
|
|
const smallHospitalScheme = Array.from({ length: smallHospitalPositions.length }, () => Array(smallHospitalPositions.length).fill(0)); |
|
|
|
|
for(let i = 0; i < smallHospitalPositions.length; ++i) { |
|
|
|
|
// 提取一维数组,方案索引 |
|
|
|
|
const oneDimensionArray = smallHospitalScheme[i]; |
|
|
|
|
// 推动数组位置坐标,实现让每个方案的坐标位置都不一致 |
|
|
|
|
let indexs = Object.keys(smallHospitalPositions); |
|
|
|
|
const reverseIndexs = indexs.slice(0, i); |
|
|
|
|
indexs.splice(0, i); |
|
|
|
|
indexs.push(...reverseIndexs); |
|
|
|
|
// 处理二维数组坐标位置存储 |
|
|
|
|
for(let j = 0; j < indexs.length; ++j) { |
|
|
|
|
const index = indexs[j]; |
|
|
|
|
const smallHospitalPosition = smallHospitalPositions[index]; |
|
|
|
|
oneDimensionArray[j] = smallHospitalPosition; |
|
|
|
|
} |
|
|
|
|
largeHospitals.forEach(large => { |
|
|
|
|
const largeHospital = largeHospitalMapList.find(index => index.id == large.largeHospitalId); |
|
|
|
|
largeHospital |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 计算组合规范方案 |
|
|
|
|
const composeScheme = mapSchemePermuteUnique([]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 地图方案组合排列算法,可确保二叉树当存在数组内容相同排列不重复 */ |
|
|
|
|
function mapSchemePermuteUnique(composeQueue: number[]) { |
|
|
|
|
const ans: number[][] = []; |
|
|
|
|
const arr: number[] = []; |
|
|
|
|
const used: boolean[] = []; |
|
|
|
|
function helper() { |
|
|
|
|
// 找到一组排列直接退出 |
|
|
|
|
if (arr.length === composeQueue.length) { |
|
|
|
|
ans.push(arr.slice(0)); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 在同一层递归里,相同的数只能枚举一次,避免重复 |
|
|
|
|
let last: unknown = undefined; |
|
|
|
|
for (let i = 0; i < composeQueue.length; i++){ |
|
|
|
|
// 如果这个位置已经用过了跳过 |
|
|
|
|
if (used[i]) continue; |
|
|
|
|
// 在同一层递归里,如果这个数重复了跳过 |
|
|
|
|
if (last == composeQueue[i]) continue; |
|
|
|
|
// 标记已使用 |
|
|
|
|
last = composeQueue[i]; |
|
|
|
|
used[i] = true; |
|
|
|
|
// 取用这个数 |
|
|
|
|
arr.push(composeQueue[i]); |
|
|
|
|
// 进到下一层 |
|
|
|
|
helper(); |
|
|
|
|
// 恢复现场 |
|
|
|
|
arr.pop(); |
|
|
|
|
used[i] = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
helper(); |
|
|
|
|
return ans; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 处理路线预览 */ |
|
|
|
|