From 2a6a53a1ce60df20d0e47a0a768a3a0112624633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 27 Aug 2021 13:44:09 +0500 Subject: [PATCH] fix WellSectionsStat and WellOperationsEditor data mapping --- .../WellOperations/WellOperationsEditor.jsx | 2 +- src/pages/WellOperations/WellSectionsStat.jsx | 36 ++++++++++++++++--- src/pages/WellOperations/dictionary.js | 13 ++++--- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/pages/WellOperations/WellOperationsEditor.jsx b/src/pages/WellOperations/WellOperationsEditor.jsx index ab45ace..3220d67 100644 --- a/src/pages/WellOperations/WellOperationsEditor.jsx +++ b/src/pages/WellOperations/WellOperationsEditor.jsx @@ -31,7 +31,7 @@ export const WellOperationsEditor = ({idWell, idType}) => { async () => { const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0 const take = pageNumAndPageSize.pageSize - const paginatedOperations = await WellOperationService.getOperations(idWell, idType, undefined, undefined, undefined, undefined, skip, take ) + const paginatedOperations = await WellOperationService.getOperations(idWell, idType, undefined, undefined, undefined, undefined, undefined, undefined, skip, take ) const operations = paginatedOperations?.items ?? [] setOperations(operations) const total = paginatedOperations.count?? paginatedOperations.items?.length ?? 0 diff --git a/src/pages/WellOperations/WellSectionsStat.jsx b/src/pages/WellOperations/WellSectionsStat.jsx index 8843dee..6ca03fe 100644 --- a/src/pages/WellOperations/WellSectionsStat.jsx +++ b/src/pages/WellOperations/WellSectionsStat.jsx @@ -10,23 +10,51 @@ const columns = [ makeColumn('Тип секции','sectionType'), makeColumnsPlanFact('Глубина' ,'wellDepth', {render:makeNumberRender(2)}), makeColumnsPlanFact('Часы' ,'duration', {render:makeNumberRender(2)}), - makeColumnsPlanFact('МСП' ,'mechSpeed', {render:makeNumberRender(2)}), + makeColumnsPlanFact('МСП' ,'rop', {render:makeNumberRender(2)}), makeColumnsPlanFact('Рейсовая скорость' ,'routeSpeed', {render:makeNumberRender(2)}), makeColumnsPlanFact('Подъем КНБК' ,'bhaUpSpeed', {render:makeNumberRender(2)}), makeColumnsPlanFact('Спуск КНБК' ,'bhaDownSpeed', {render:makeNumberRender(2)}), makeColumnsPlanFact('Спуск ОК' ,'casingDownSpeed', {render:makeNumberRender(2)}), ] +const calcDuration = (start, end) => { + const msInDay = 1000*60*60*24 + const startD = new Date(start) + const endD = new Date(end) + const ms = endD - startD + return ms / msInDay +} + export const WellSectionsStat = ({idWell}) => { const [sections, setSections] = useState([]) const [showLoader, setShowLoader] = useState(false) useEffect(() => invokeWebApiWrapperAsync( async () => { - const sectionsResponse = await WellOperationStatService.getSectionsByWellId(idWell) + const sectionsResponse = await WellOperationStatService.getStatWell(idWell) - if(sectionsResponse){ - const sections = sectionsResponse.sort((a,b)=>a.wellDepthPlan - b.wellDepthPlan) + if(sectionsResponse?.sections){ + const sections = sectionsResponse.sections + .map(s=>({ + key: s.id, + sectionType: s.caption, + wellDepthPlan: s.plan?.wellDepthEnd, + durationPlan: calcDuration(s.plan?.start, s.plan?.end), + ropPlan: s.plan?.rop, + routeSpeedPlan: s.plan?.routeSpeed, + bhaUpSpeedPlan: s.plan?.bhaUpSpeed, + bhaDownSpeedPlan: s.plan?.bhaDownSpeed, + casingDownSpeedPlan: s.plan?.casingDownSpeed, + + wellDepthFact : s.fact?.wellDepthEnd, + durationFact : calcDuration(s.fact?.start, s.fact?.end), + ropFact : s.fact?.rop, + routeSpeedFact : s.fact?.routeSpeed, + bhaUpSpeedFact : s.fact?.bhaUpSpeed, + bhaDownSpeedFact : s.fact?.bhaDownSpeed, + casingDownSpeedFact : s.fact?.casingDownSpeed, + })) + .sort((a,b) => a.wellDepthPlan - b.wellDepthPlan) setSections(sections) } }, diff --git a/src/pages/WellOperations/dictionary.js b/src/pages/WellOperations/dictionary.js index 92b1db9..bf4a39f 100644 --- a/src/pages/WellOperations/dictionary.js +++ b/src/pages/WellOperations/dictionary.js @@ -1,11 +1,10 @@ export const dictionarySectionType = new Map([ - [1, 'Обощенное по скважине'], - [2, 'Пилотный ствол'], - [3, 'Направление'], - [4, 'Кондуктор'], - [5, 'Эксплуатационная колонна'], - [6, 'Транспортный ствол'], - [7, 'Хвостовик'], + [1, 'Пилотный ствол'], + [2, 'Направление'], + [3, 'Кондуктор'], + [4, 'Эксплуатационная колонна'], + [5, 'Транспортный ствол'], + [6, 'Хвостовик'], ]) export const getByKeyOrReturnKey = (dictionary, key) => {