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