Отображение статуса добавлено

This commit is contained in:
goodmice 2021-10-20 17:02:51 +05:00
parent 5c008043c5
commit 4937dddf87
5 changed files with 55 additions and 3 deletions

View File

@ -71,7 +71,8 @@ export default function ClusterWells({statsWells}) {
notProductiveTimePlan: well.total?.plan?.nonProductiveHours, notProductiveTimePlan: well.total?.plan?.nonProductiveHours,
notProductiveTimeFact: well.total?.fact?.nonProductiveHours, notProductiveTimeFact: well.total?.fact?.nonProductiveHours,
companies: well.companies, companies: well.companies,
lastTelemetryDate: well.lastTelemetryDate lastTelemetryDate: well.lastTelemetryDate,
idState: well.idState
} }
}) })
@ -97,7 +98,7 @@ export default function ClusterWells({statsWells}) {
(_, item) => ( (_, item) => (
<Link to={`/well/${item.id}`} style={{display: 'flex', alignItems: 'center'}}> <Link to={`/well/${item.id}`} style={{display: 'flex', alignItems: 'center'}}>
<PointerIcon <PointerIcon
color={item.state === 'working' ? 'black' : 'gray'} color={item.idState === 1 ? 'black' : 'gray'}
size={32} size={32}
online={item.lastTelemetryDate && ((new Date()).getTime() - Date.parse(item.lastTelemetryDate)) / 1000 < ONLINE_DEADTIME} online={item.lastTelemetryDate && ((new Date()).getTime() - Date.parse(item.lastTelemetryDate)) / 1000 < ONLINE_DEADTIME}
onlineColor={'currentColor'} onlineColor={'currentColor'}

View File

@ -10,7 +10,7 @@ import { UserOfWell } from './UserOfWells'
import LoaderPortal from '../../components/LoaderPortal' import LoaderPortal from '../../components/LoaderPortal'
import { Grid, GridItem, Flex } from '../../components/Grid' import { Grid, GridItem, Flex } from '../../components/Grid'
import { Subscribe } from '../../services/signalr' import { Subscribe } from '../../services/signalr'
import { TelemetryDataSaubService, TelemetryDataSpinService } from '../../services/api' import { TelemetryDataSaubService, TelemetryDataSpinService, WellService } from '../../services/api'
import { invokeWebApiWrapperAsync } from '../../components/factory' import { invokeWebApiWrapperAsync } from '../../components/factory'
import MomentStabPicEnabled from '../../images/DempherOn.png' import MomentStabPicEnabled from '../../images/DempherOn.png'
@ -259,6 +259,7 @@ export default function TelemetryView({ idWell }) {
const [dataSaub, setDataSaub] = useState([]) const [dataSaub, setDataSaub] = useState([])
const [dataSpin, setDataSpin] = useState([]) const [dataSpin, setDataSpin] = useState([])
const [chartInterval, setChartInterval] = useState(defaultChartInterval) const [chartInterval, setChartInterval] = useState(defaultChartInterval)
const [wellData, setWellData] = useState({idState: 0})
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const options = timePeriodCollection.map((line) => <Option key={line.value}>{line.label}</Option>) const options = timePeriodCollection.map((line) => <Option key={line.value}>{line.label}</Option>)
@ -301,6 +302,27 @@ export default function TelemetryView({ idWell }) {
} }
}, [idWell, chartInterval]) }, [idWell, chartInterval])
useEffect(() => invokeWebApiWrapperAsync(
async () => {
const well = await WellService.get(idWell)
setWellData(well ?? {})
},
setShowLoader,
`Не удалось загрузить данные по скважине "${idWell}"`
), [idWell])
const onStatusChanged = (value) => {
invokeWebApiWrapperAsync(
async () => {
const well = {...wellData, idState: value}
await WellService.updateWell(idWell, well)
setWellData(well)
},
setShowLoader,
`Не удалось задать состояние скважины "${idWell}"`
)
}
return ( return (
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<Grid style={{ gridTemplateColumns: 'auto repeat(6, 1fr)' }}> <Grid style={{ gridTemplateColumns: 'auto repeat(6, 1fr)' }}>
@ -313,6 +335,14 @@ export default function TelemetryView({ idWell }) {
{options} {options}
</Select> </Select>
</div> </div>
<div style={{ marginLeft: '1rem'}}>
Статус:&nbsp;
<Select value={wellData.idState} onChange={onStatusChanged}>
<Option value={0} disabled>Неизвестно</Option>
<Option value={1}>В работе</Option>
<Option value={2}>Завершено</Option>
</Select>
</div>
<span style={{ flexGrow: 20 }}>&nbsp;</span> <span style={{ flexGrow: 20 }}>&nbsp;</span>
<img src={isTorqueStabEnabled(dataSpin) ? MomentStabPicEnabled : MomentStabPicDisabled} style={{ marginRight: '15px' }} alt={'TorqueMaster'} /> <img src={isTorqueStabEnabled(dataSpin) ? MomentStabPicEnabled : MomentStabPicDisabled} style={{ marginRight: '15px' }} alt={'TorqueMaster'} />
<img src={isSpinEnabled(dataSpin) ? SpinPicEnabled : SpinPicDisabled} style={{ marginRight: '15px' }} alt={'SpinMaster'} /> <img src={isSpinEnabled(dataSpin) ? SpinPicEnabled : SpinPicDisabled} style={{ marginRight: '15px' }} alt={'SpinMaster'} />

View File

@ -10,6 +10,7 @@ export type StatWellDto = {
id?: number; id?: number;
caption?: string | null; caption?: string | null;
wellType?: string | null; wellType?: string | null;
idState?: number;
state?: string | null; state?: string | null;
lastTelemetryDate?: string; lastTelemetryDate?: string;
sections?: Array<StatSectionDto> | null; sections?: Array<StatSectionDto> | null;

View File

@ -12,6 +12,7 @@ export type WellDto = {
latitude?: number | null; latitude?: number | null;
longitude?: number | null; longitude?: number | null;
wellType?: string | null; wellType?: string | null;
idWellType?: number;
idState?: number; idState?: number;
lastTelemetryDate?: string; lastTelemetryDate?: string;
telemetry?: TelemetryDto; telemetry?: TelemetryDto;

View File

@ -44,6 +44,25 @@ export class WellService {
return result.body; return result.body;
} }
/**
* Возвращает информацию о требуемой скважине
* @param idWell Id требуемой скважины
* @returns WellDto Success
* @throws ApiError
*/
public static async get(
idWell?: number,
): Promise<WellDto> {
const result = await __request({
method: 'GET',
path: `/api/well/getWell`,
query: {
'idWell': idWell,
},
});
return result.body;
}
/** /**
* Возвращает список скважин, передающих телеметрию в данный момент * Возвращает список скважин, передающих телеметрию в данный момент
* @returns WellDto Success * @returns WellDto Success