|
|
|
@ -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,46 +152,70 @@
@@ -151,46 +152,70 @@
|
|
|
|
|
const scheme = []; |
|
|
|
|
|
|
|
|
|
const origin = state.formData.takeSpecimenId; |
|
|
|
|
// 抽离计算属性 |
|
|
|
|
const taskDataSource = getDataSource(); |
|
|
|
|
const smallHospitals = Array<any>(); |
|
|
|
|
const largeHospitals = Array<any>(); |
|
|
|
|
taskDataSource.forEach(item => { |
|
|
|
|
const smallHospitalPositions = Array<any>(); |
|
|
|
|
const largeHospitalPositions = Array<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>(); |
|
|
|
|
// 目的地 |
|
|
|
|
let destination; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 循环计算出最优方案 |
|
|
|
|
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)); |
|
|
|
|
// 下级医院规划方案二维数组,默认填充0数据 |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
// 计算不重复插入匹配上级医院 |
|
|
|
|
for (let i = 0; i < smallHospitalScheme.length; ++i) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 计算下级医院组合次数 |
|
|
|
|
for(let i = 0; i < smallHospitals.length; ++i) { |
|
|
|
|
const composeCycle = add(i,1); |
|
|
|
|
const hospitalCycle = Math.ceil(divide(smallHospitals.length, composeCycle)); |
|
|
|
|
for(let j = 0; j < hospitalCycle; ++j) { |
|
|
|
|
for(let k = 0; k < composeCycle; ++k) { |
|
|
|
|
const index = add(j, k); |
|
|
|
|
const small = smallHospitals[index]; |
|
|
|
|
const smallHospital = smallHospitalMapList.find(index => index.id == small.smallHospitalId); |
|
|
|
|
if(smallHospital) waypoints.push([small.key, new AMap.LngLat(smallHospital.lng, smallHospital.lat)]); |
|
|
|
|
} |
|
|
|
|
for (let k = 0; k < ; ++k) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
largeHospitals.forEach(large => { |
|
|
|
|
// 匹配下级医院,当存在时才能存放上级医院途径点,需求必须要在下级医院取完标本才能送往上级医院 |
|
|
|
|
if(waypoints.find(waypoint => waypoint[0] == large.key)){ |
|
|
|
|
const largeHospital = largeHospitalMapList.find(index => index.id == large.largeHospitalId); |
|
|
|
|
if(largeHospital) waypoints.push([large.key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|