feat:app端研发

This commit is contained in:
Zxuyoubin 2024-04-03 17:30:56 +08:00
parent 1a902bb828
commit 2669fbe488
6 changed files with 239 additions and 129 deletions

View File

@ -4,6 +4,14 @@ import Taro from "@tarojs/taro"
import TabWrapper from "../../components/customized/tabWrapper" import TabWrapper from "../../components/customized/tabWrapper"
import { ScrollView } from "@tarojs/components" import { ScrollView } from "@tarojs/components"
import { request } from "../../config/axios" import { request } from "../../config/axios"
//获取设备
const getdevice=(data)=>{
return request({
url:'/agriculture/check-logs/getCountPageByBaseId',
method:'GET',
data
})
}
const EquipMent = () => { const EquipMent = () => {
//获取基地 //获取基地
const [topMenus,setTopMenus] = useState([ const [topMenus,setTopMenus] = useState([
@ -31,17 +39,7 @@ const EquipMent = () => {
data data
}) })
} }
const [dataList,setDataList] = useState([
useEffect(()=>{
getDeviceInfoCard({pageNo:1,pageSize:10}).then(res=>{
console.log(res,'获取基地');
// setTopMenus(res.data.list)
})
},[])
const [selectedMenuId, setSelectedMenuId] = useState('all')
const dataList = [
{ {
id: '1', id: '1',
}, },
@ -51,7 +49,30 @@ const EquipMent = () => {
{ {
id: '3', id: '3',
}, },
] ])
const getdevice2=(id)=>{
getdevice({pageNo:1,pageSize:10,baseId:id}).then(res=>{
console.log(res,'获取数据');
setDataList(res.data.list)
})
}
useEffect(()=>{
getDeviceInfoCard({}).then(res=>{
console.log(res,'获取基地');
setTopMenus(res.data.list.map((item,index)=>({
title:item.name,
id:index,
id2:item.id
})).reverse())
getdevice2(res.data.list.reverse()[1].id)
})
},[])
const [selectedMenuId, setSelectedMenuId] = useState('all')
const [refreshTrigger, setRefreshTrigger] = useState(false) const [refreshTrigger, setRefreshTrigger] = useState(false)
const refreshFunc = (): Promise<void> => { const refreshFunc = (): Promise<void> => {
@ -89,15 +110,15 @@ const EquipMent = () => {
<Image src={img} className="w-12 h-12"></Image> <Image src={img} className="w-12 h-12"></Image>
</View> */} </View> */}
<View className="w-full flex flex-col justify-between items-start pb-1"> <View className="w-full flex flex-col justify-between items-start pb-1">
<View className="text-lg pb-1"></View> <View className="text-lg pb-1">{item.categoryName}</View>
<View className="w-full flex items-center space-x-8"> <View className="w-full flex items-center space-x-8">
<View className="flex items-center space-x-2"> <View className="flex items-center space-x-2">
<View></View> <View></View>
<View style={{ color: 'green' }}>3</View> <View style={{ color: 'green' }}>{item.finishCheckNum }</View>
</View> </View>
<View className="flex items-center space-x-2"> <View className="flex items-center space-x-2">
<View></View> <View></View>
<View style={{ color: 'red' }}>3</View> <View style={{ color: 'red' }}>{item.unFinishCheckNum}</View>
</View> </View>
</View> </View>
</View> </View>
@ -105,7 +126,7 @@ const EquipMent = () => {
className="rounded-xl w-20 bg-green-500 text-center py-1" className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }} style={{ color: 'white' }}
onClick={() => { onClick={() => {
Taro.navigateTo({ url: '/inspectionManager/inspection/index?id=' + item.id }) Taro.navigateTo({ url: `/inspectionManager/inspection/index?id=${topMenus[1].id2}&categoryId=${item.categoryId}` })
}} }}
></View> ></View>
</View> </View>

View File

@ -1,9 +1,22 @@
import { View, Image } from "@tarojs/components" import { View, Image } from "@tarojs/components"
import { useState } from "react" import { useEffect, useState } from "react"
import Taro from "@tarojs/taro" import Taro from "@tarojs/taro"
import PageWrapper from "../../components/customized/pageWrapper" import PageWrapper from "../../components/customized/pageWrapper"
import { request } from "../../config/axios"
//获取巡检设备
const getCheckDeviceBySomet=(data)=>{
return request({
url:'/agriculture/check-logs/getCheckDeviceBySome',
method:'GET',
data
})
}
const EquipMent = () => { const EquipMent = () => {
const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id
const categoryId2 = Taro.getCurrentInstance().router?.params.categoryId || 0; // 基地id
const [selectedMenuId, setSelectedMenuId] = useState('all') const [selectedMenuId, setSelectedMenuId] = useState('all')
const topMenus = [ const topMenus = [
{ {
@ -16,7 +29,7 @@ const EquipMent = () => {
} }
] ]
const dataList = [ const [dataList,setDataList] = useState([
{ {
id: '1', id: '1',
}, },
@ -26,7 +39,27 @@ const EquipMent = () => {
{ {
id: '3', id: '3',
}, },
] ])
//获取数据
useEffect(()=>{
getList('0')
},[])
const getList=(id)=>{
getCheckDeviceBySomet({pageNo:1,pageSize:10,base:baseId,categoryId:categoryId2,inspectionState:id }).then(res=>{
console.log(res,'huoqushuju');
setDataList(res.data.list)
})
}
const tabCli=(id)=>{
setSelectedMenuId(id)
console.log(id,'tab id');
if(id=='1'){
getList('0')
}else{
getList('1')
}
}
return ( return (
<PageWrapper title="气象站"> <PageWrapper title="气象站">
<View className="p-1 h-full"> <View className="p-1 h-full">
@ -39,7 +72,7 @@ const EquipMent = () => {
className={`p-1 px-3 ${selectedMenuId === item.id ? 'border-b-4 border-lime-800' : ''}`} className={`p-1 px-3 ${selectedMenuId === item.id ? 'border-b-4 border-lime-800' : ''}`}
key={item.id} key={item.id}
style={{ color: 'white' }} style={{ color: 'white' }}
onClick={() => setSelectedMenuId(item.id)} onClick={() => tabCli(item.id)}
>{ item.title }</View> >{ item.title }</View>
) )
}) })
@ -53,8 +86,8 @@ const EquipMent = () => {
className="py-2 pt-0 rounded-md shadow-xl bg-white relative" className="py-2 pt-0 rounded-md shadow-xl bg-white relative"
> >
<Image src={'https://picx.zhimg.com/70/v2-76efadc2e5b562f6f727521aedbb31ef_1440w.image?source=172ae18b&biz_tag=Post'} className="w-full h-[6rem] rounded-md"></Image> <Image src={'https://picx.zhimg.com/70/v2-76efadc2e5b562f6f727521aedbb31ef_1440w.image?source=172ae18b&biz_tag=Post'} className="w-full h-[6rem] rounded-md"></Image>
<View className="text-lg px-4 text-bold">1</View> <View className="text-lg px-4 text-bold">{item.equName}</View>
<View className="text-sm px-4" style={{ color: '#00000090' }}> 2023-1-11</View> <View className="text-sm px-4" style={{ color: '#00000090' }}> {item.inspectionTime}</View>
<View className="w-full px-4 flex justify-between items-start py-2 space-x-1"> <View className="w-full px-4 flex justify-between items-start py-2 space-x-1">
<View <View
className="rounded-xl w-20 bg-green-500 text-center py-1" className="rounded-xl w-20 bg-green-500 text-center py-1"
@ -75,7 +108,7 @@ const EquipMent = () => {
className="absolute left-0 top-0 text-white p-1 text-sm px-2" className="absolute left-0 top-0 text-white p-1 text-sm px-2"
style={{ backgroundColor: '#0FC87C', color: 'white', borderRadius: '.3rem 0 .3rem 0' }} style={{ backgroundColor: '#0FC87C', color: 'white', borderRadius: '.3rem 0 .3rem 0' }}
> >
{ '在线' } { item.inspectionState=='1'?'在线':'离线'}
</View> </View>
</View> </View>
) )

View File

@ -66,112 +66,69 @@ const EnvMonitor = () => {
getEquipment({deviceType:baseId}).then(res=>{ getEquipment({deviceType:baseId}).then(res=>{
console.log(res,'shbei'); console.log(res,'shbei');
setDataList(res.data) setDataList(res.data)
// getList2(res.data[0].id) setDeviceObj(res.data[0])
// getChart2(res.data[0].id) getList2({id:res.data[0].id})
// setDeviceObj(res.data[0])
}) })
},[]) },[])
const [contObj, setContObj] = useState({}) const [contObj, setContObj] = useState({})
let [chartList,setChartList]=useState([])
let [time,setTime]=useState([])
let [yAxisData,setyAxisData]=useState([])
//实时数据接口 //实时数据接口
const getList=(data)=>{ const getList=(data)=>{
return request({ return request({
url:'/agriculture/big-screen/getDeviceNewData', url:'/agriculture/app/getInsectDataById',
method:'GET', method:'GET',
data data
}) })
} }
const getList2=(id)=>{ const getList2=(id)=>{
getList({equipmentCode:id,equipmentType:'15'}).then(res=>{ getList(id).then(res=>{
console.log(res,'获取数据'); console.log(res,'获取数据');
setContObj(res.data) setContObj(res.data)
setChartList(res.data.list)
})
}
//获取echarts
let [time,setTime]=useState([])
let [yAxisData,setyAxisData]=useState([])
const [chartList, setChartList] = useState([])
const getChart=(data)=>{
return request({
url:'/agriculture/big-screen/getDeviceDataView',
method:'GET',
data
})
}
const getChart2=async (id)=>{
let res= await getChart({equipmentCode:id,equipmentType:'15'})
console.log(res,'获取ecahrts');
setChartList(res.data)
let time2=[] let time2=[]
let list=[] let data=[]
res.data.forEach(item => { res.data.list.forEach(item=>{
time2.push(item.reportDate) time2.push(item.gatherHour)
list.push(item.temperature) data.push(item.insectPestNumber)
}); })
setTime(time2.reverse()) setTime(time2)
setyAxisData(list.reverse()) setyAxisData(data)
})
} }
const [curDeviceId, setCurDeviceId] = useState('1') const [curDeviceId, setCurDeviceId] = useState('1')
const [selectedLabel, setSelectedLabel] = useState('1') const [selectedLabel, setSelectedLabel] = useState('1')
const tabChart=(id)=>{ const tabChart=(id)=>{
setSelectedLabel(id) setSelectedLabel(id)
let time2=[]
let list=[]
if(id==1){ if(id==1){
let time=[]
let list=[]
chartList.forEach(item => { chartList.forEach(item => {
time.push(item.reportDate) time2.push(item.gatherHour)
list.push(item.temperature) list.push(item.insectPestNumber)
}); });
setTime(time.reverse())
setyAxisData(list.reverse())
}else if(id==2){ }else if(id==2){
let time=[]
let list=[]
chartList.forEach(item => { chartList.forEach(item => {
time.push(item.reportDate) time2.push(item.gatherHour)
list.push(item.humidity) list.push(item.insectPestKind)
}); });
setTime(time.reverse())
setyAxisData(list.reverse())
}else if(id==3){ }else if(id==3){
let time=[]
let list=[]
chartList.forEach(item => { chartList.forEach(item => {
time.push(item.reportDate) time2.push(item.gatherHour)
list.push(item.lighting) list.push(item.insectTemperature)
}); });
setTime(time.reverse())
setyAxisData(list.reverse())
}else if(id==4){ }else if(id==4){
let time=[]
let list=[]
chartList.forEach(item => { chartList.forEach(item => {
time.push(item.reportDate) time.push(item.gatherHour)
list.push(item.airPressure) list.push(item.dryingTemperature)
}); });
setTime(time.reverse())
setyAxisData(list.reverse())
}else if(id==5){
let time=[]
let list=[]
chartList.forEach(item => {
time.push(item.reportDate)
list.push(item.rainfall)
});
setTime(time.reverse())
setyAxisData(list.reverse())
}else if(id==6){
let time=[]
let list=[]
chartList.forEach(item => {
time.push(item.reportDate)
list.push(item.windSpeed)
});
setTime(time.reverse())
setyAxisData(list.reverse())
} }
setTime(time2)
setyAxisData(list)
} }
const echartsRef = useRef<EchartsHandle>(null) const echartsRef = useRef<EchartsHandle>(null)
const option: EChartOption = { const option: EChartOption = {
@ -195,7 +152,11 @@ const EnvMonitor = () => {
series: [ series: [
{ {
data: yAxisData, data: yAxisData,
type: 'line' type: 'line',
symbol:'none',
areaStyle:{
color:'#5470c6'
}
} }
], ],
grid: { grid: {
@ -207,12 +168,10 @@ const EnvMonitor = () => {
// 数据监测顶部标签 // 数据监测顶部标签
const [dataLabel, setDataLabel] = useState([ const [dataLabel, setDataLabel] = useState([
{ id: '1', label: '温度' }, { id: '1', label: '数量' },
{ id: '2', label: '湿度' }, { id: '2', label: '种类' },
{ id: '3', label: '光照' }, { id: '3', label: '杀虫仓温度℃' },
{ id: '4', label: '气压' }, { id: '4', label: '烘干仓温度℃' },
{ id: '5', label: '雨量' },
{ id: '6', label: '风速' },
]); ]);
const tabCli=(index,val)=>{ const tabCli=(index,val)=>{
setCurDeviceId(index+1) setCurDeviceId(index+1)
@ -237,7 +196,7 @@ const EnvMonitor = () => {
} }
</View> </View>
<View className="h-full flex flex-col space-y-2 p-2 rounded-sm"> <View className="h-full flex flex-col space-y-2 p-2 rounded-sm">
<BasicInfoCard imgSrc={deviceObj.imgId} title={deviceObj.deviceName} info={deviceObj.deviceCode} status={true} /> <BasicInfoCard imgSrc={deviceObj?.imgId} title={deviceObj?.deviceName} info={deviceObj?.deviceCode} status={true} />
<SubTitle title="实时数据" updateTime="2023-04-04" /> <SubTitle title="实时数据" updateTime="2023-04-04" />
<GridContainer> <GridContainer>
<View className="p-2 py-3"> <View className="p-2 py-3">

View File

@ -195,7 +195,11 @@ const EnvMonitor = () => {
series: [ series: [
{ {
data: yAxisData, data: yAxisData,
type: 'line' type: 'line',
symbol:'none',
areaStyle:{
color:'#5470c6'
}
} }
], ],
grid: { grid: {
@ -217,7 +221,8 @@ const EnvMonitor = () => {
const tabCli=(index,val)=>{ const tabCli=(index,val)=>{
setCurDeviceId(index+1) setCurDeviceId(index+1)
setDeviceObj(val) setDeviceObj(val)
getChart2(val.id)
getList2(val.id)
} }
return ( return (
<PageWrapper title="棚内环境监测"> <PageWrapper title="棚内环境监测">

View File

@ -2,7 +2,7 @@ import { Image, View } from "@tarojs/components"
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import { useState, useRef, useEffect } from "react"; import { useState, useRef, useEffect } from "react";
import img from '../../assets/images/img.png' import img from '../../assets/images/img.png'
import { icon1, icon2, icon3, icon4 } from "../../assets/images/icons/data"; import { icon1, icon2, icon3, icon4,icon5 } from "../../assets/images/icons/data";
import Echarts, { EChartOption, EchartsHandle } from 'taro-react-echarts' import Echarts, { EChartOption, EchartsHandle } from 'taro-react-echarts'
import echarts from '../../assets/js/echarts' import echarts from '../../assets/js/echarts'
import IconLabelValue from "../../components/iot/iconLabelValue"; import IconLabelValue from "../../components/iot/iconLabelValue";
@ -39,7 +39,6 @@ const BasicInfoCard = ({ title, info, status, imgSrc }) => {
const SoilMoisture = () => { const SoilMoisture = () => {
const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id
console.log(baseId,'id')
//获取设备 //获取设备
const [deviceList,setDeviceList ]= useState([ const [deviceList,setDeviceList ]= useState([
{ {
@ -55,6 +54,11 @@ const SoilMoisture = () => {
title: '设备3' title: '设备3'
}, },
]) ])
const [deviceInfo,setDeviceInfo]=useState([])
const [curDeviceId, setCurDeviceId] = useState('1')
let [chartList,setChartList]=useState([])
let [time,setTime]=useState([])
let [yAxisData,setyAxisData]=useState([])
const getEquipment=(data)=>{ const getEquipment=(data)=>{
return request({ return request({
url:'/agriculture/app/getDevice', url:'/agriculture/app/getDevice',
@ -62,15 +66,74 @@ const SoilMoisture = () => {
data data
}) })
} }
const getList=async ()=>{
let {data}=await getEquipment({deviceType:baseId})
console.log(data,'huoqushebei');
setDeviceList(data)
setDeviceInfo(data[0])
getData2({id:data[0].id})
}
useEffect(()=>{ useEffect(()=>{
getEquipment({deviceType:baseId}).then(res=>{ getList()
console.log(res,'huoqushebei');
setDeviceList(res.data)
})
},[]) },[])
const [curDeviceId, setCurDeviceId] = useState('1') //获取实时数据
const getData=(data)=>{
return request({
url:'/agriculture/app/getSoilDataById',
method:'GET',
data
})
}
let [soilObj,setSoilObj]=useState({})
const getData2=(id)=>{
getData(id).then(res=>{
console.log(res,'获取实时数据');
setSoilObj(res.data)
setChartList(res.data.list)
let time2= []
let data=[]
res.data.list.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilTemperature)
})
setTime(time2)
setyAxisData(data)
})
}
const tabChart=(id)=>{
setSelectedLabel(id)
let time2= []
let data=[]
if(id==1){
chartList.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilTemperature)
})
}else if(id==2){
chartList.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilHumidity)
})
}else if(id==3){
chartList.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilPh)
})
}else if(id==4){
chartList.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilEc)
})
}else{
chartList.forEach(item=>{
time2.push(item.gatherHour)
data.push(item.soilDepth)
})
}
setTime(time2)
setyAxisData(data)
}
const echartsRef = useRef<EchartsHandle>(null) const echartsRef = useRef<EchartsHandle>(null)
const option: EChartOption = { const option: EChartOption = {
legend: { legend: {
@ -85,15 +148,19 @@ const SoilMoisture = () => {
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] data: time
}, },
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
series: [ series: [
{ {
data: [150, 230, 224, 218, 135, 147, 260], data: yAxisData,
type: 'line' type: 'line',
symbol:'none',
areaStyle:{
color:'#5470c6'
}
} }
], ],
grid: { grid: {
@ -109,28 +176,49 @@ const SoilMoisture = () => {
{ id: '2', label: '湿度' }, { id: '2', label: '湿度' },
{ id: '3', label: 'PH' }, { id: '3', label: 'PH' },
{ id: '4', label: 'EC' }, { id: '4', label: 'EC' },
{ id: '5', label: '土壤深度' },
]); ]);
const [selectedLabel, setSelectedLabel] = useState('1') const [selectedLabel, setSelectedLabel] = useState('1')
const tabCli=(index,val)=>{
setCurDeviceId(index+1)
getData2({id:val.id})
setDeviceInfo(val)
}
return ( return (
<PageWrapper title="土壤墒情"> <PageWrapper title="土壤墒情">
<TabWrapper options={deviceList} selectedId={curDeviceId} callback={setCurDeviceId}></TabWrapper> <View className="flex px-2 py-1">
{
deviceList.map((item,index) => {
return (
<View
className={`p-1 px-3 ${curDeviceId === index+1 ? 'text-lime-600 border-b-4 border-lime-800' : ''}`}
key={item.id}
style={{ color: 'white' }}
onClick={() => tabCli(index,item)}
>{ item.deviceName }</View>
)
})
}
</View>
<View className="h-full flex flex-col px-1"> <View className="h-full flex flex-col px-1">
<View className="h-full flex flex-col space-y-2 p-2 rounded-sm"> <View className="h-full flex flex-col space-y-2 p-2 rounded-sm">
<BasicInfoCard imgSrc={img} title={'土壤墒情传感器'} info={'BNYKLH09LK001'} status={true} /> <BasicInfoCard imgSrc={deviceInfo?.imgId} title={deviceInfo?.deviceName} info={deviceInfo?.deviceCode} status={deviceInfo?.deviceStatus=='online'} />
<SubTitle title="实时数据" updateTime="2023-04-04" /> <SubTitle title="实时数据" updateTime="2023-04-04" />
<GridContainer> <GridContainer>
<View className="p-2 py-3"> <View className="p-2 py-3">
<IconLabelValue value={27.34} label={'大气温度'} unit={'℃'} img={icon1} /> <IconLabelValue value={soilObj.soilTemperature} label={'土壤温度'} img={icon1} />
</View> </View>
<View className="p-2 py-3"> <View className="p-2 py-3">
<IconLabelValue value={76.21} label={'大气湿度'} unit={'%/RH'} img={icon2} /> <IconLabelValue value={soilObj.soilHumidity} label={'土壤湿度'} img={icon2} />
</View> </View>
<View className="p-2 py-3"> <View className="p-2 py-3">
<IconLabelValue value={20890} label={'光照'} unit={'Lux'} img={icon3} /> <IconLabelValue value={soilObj.soilPh} label={'PH值'} img={icon3} />
</View> </View>
<View className="p-2 py-3"> <View className="p-2 py-3">
<IconLabelValue value={27.34} label={'大气温度'} unit={'℃'} img={icon4} /> <IconLabelValue value={soilObj.soilEc} label={'EC'} img={icon4} />
</View>
<View className="p-2 py-3">
<IconLabelValue value={soilObj.soilDepth} label={'土壤深度'} img={icon5} />
</View> </View>
</GridContainer> </GridContainer>
<SubTitle title="数据监测" /> <SubTitle title="数据监测" />
@ -150,7 +238,7 @@ const SoilMoisture = () => {
'color': selectedLabel === item.id ? 'white' : 'black', 'color': selectedLabel === item.id ? 'white' : 'black',
'backgroundColor': selectedLabel === item.id ? '#0fc87c' : 'white' 'backgroundColor': selectedLabel === item.id ? '#0fc87c' : 'white'
}} }}
onClick={() => setSelectedLabel(item.id)} onClick={() => tabChart(item.id)}
>{ item.label }</View> >{ item.label }</View>
) )
}) })

View File

@ -205,7 +205,11 @@ const WeatherStation = () => {
series: [ series: [
{ {
data: yAxisData, data: yAxisData,
type: 'line' type: 'line',
symbol:'none',
areaStyle:{
color:'#5470c6'
}
} }
], ],
grid: { grid: {