forked from ddrilling/asb_cloud_front
Исправлено наложение активных телеметрий
This commit is contained in:
parent
d7669a2317
commit
a04090db57
@ -140,6 +140,7 @@ export const normalizeData = (data) => data?.map(item => ({
|
||||
const dateSorter = makeDateSorter('date')
|
||||
|
||||
const TelemetryView = memo(() => {
|
||||
const [currentWellId, setCurrentWellId] = useState(null)
|
||||
const [dataSaub, setDataSaub] = useState([])
|
||||
const [dataSpin, setDataSpin] = useState([])
|
||||
const [chartInterval, setChartInterval] = useState(defaultPeriod)
|
||||
@ -155,15 +156,15 @@ const TelemetryView = memo(() => {
|
||||
const saubSubject$ = useMemo(() => new BehaviorSubject(), [])
|
||||
const spinSubject$ = useMemo(() => new BehaviorSubject(), [])
|
||||
|
||||
const handleDataSaub = useCallback((data) => {
|
||||
if (data) {
|
||||
const dataSaub = normalizeData(data)
|
||||
const handleDataSaub = useCallback((data, replace = false) => {
|
||||
setDataSaub((prev) => {
|
||||
const out = [...prev, ...dataSaub]
|
||||
if (!data)
|
||||
return replace ? [] : prev
|
||||
const dataSaub = normalizeData(data)
|
||||
const out = replace ? [...dataSaub] : [...prev, ...dataSaub]
|
||||
out.sort(dateSorter)
|
||||
return out
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleDataSpin = useCallback((data) => data && setDataSpin((prev) => [...prev, ...data]), [])
|
||||
@ -185,24 +186,22 @@ const TelemetryView = memo(() => {
|
||||
}, [spinSubject$])
|
||||
|
||||
useEffect(() => {
|
||||
const cancel = invokeWebApiWrapperAsync(
|
||||
async (signal) => {
|
||||
if (signal.aborted) return false
|
||||
if (currentWellId == well.id) return
|
||||
setCurrentWellId(well.id)
|
||||
invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const flowChart = await DrillFlowChartService.getByIdWell(well.id)
|
||||
const dataSaub = await TelemetryDataSaubService.getData(well.id, null, chartInterval)
|
||||
const dataSpin = await TelemetryDataSpinService.getData(well.id, null, chartInterval)
|
||||
if (signal.aborted) return false
|
||||
setFlowChartData(flowChart ?? [])
|
||||
handleDataSaub(dataSaub)
|
||||
handleDataSpin(dataSpin)
|
||||
handleDataSaub(dataSaub, true)
|
||||
setDataSpin(Array.isArray(dataSpin) ? dataSpin : [])
|
||||
},
|
||||
setIsDataLoading,
|
||||
`Не удалось получить данные`,
|
||||
{ actionName: 'Получение данных по скважине', well }
|
||||
)
|
||||
|
||||
return () => cancel()
|
||||
}, [well, chartInterval, handleDataSpin, handleDataSaub])
|
||||
}, [well, chartInterval, currentWellId, handleDataSaub])
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = Subscribe(
|
||||
|
Loading…
Reference in New Issue
Block a user