庞家镇

This commit is contained in:
Alan-mx 2023-06-29 16:59:03 +08:00
parent a94bad2a78
commit 3c7b59498c
183 changed files with 15217 additions and 4959 deletions

View File

@ -15,8 +15,13 @@
web服务入口
</description>
<dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>20.5</geotools.version>
<jts.version>1.16.1</jts.version>
</properties>
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -94,7 +99,170 @@
<version>1.7.0-pdok2</version>
</dependency>
<!-- 引入jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
</dependency>
<!-- AOP -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.12</version>
</dependency>
<!-- geotools start -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-api</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-opengis</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-metadata</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geometry</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-coverage</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-cql</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-data</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-wkt</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-jdbc</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools.jdbc</groupId>
<artifactId>gt-jdbc-postgis</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.16.1</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-wms</artifactId>
<version>${geotools.version}</version>
</dependency>
<!-- geotools end -->
<!--geotools-->
<!-- <dependency>-->
<!-- <groupId>org.geotools</groupId>-->
<!-- <artifactId>gt-shapefile</artifactId>-->
<!-- <version>${geotools.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.geotools</groupId>-->
<!-- <artifactId>gt-swing</artifactId>-->
<!-- <version>${geotools.version}</version>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.locationtech.jts/jts-core &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.locationtech.jts</groupId>-->
<!-- <artifactId>jts-core</artifactId>-->
<!-- <version>1.16.1</version>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.geotools/gt-main &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.geotools</groupId>-->
<!-- <artifactId>gt-main</artifactId>-->
<!-- <version>22-RC</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.vividsolutions</groupId>-->
<!-- <artifactId>jts</artifactId>-->
<!-- <version>1.13</version>-->
<!-- </dependency>-->
</dependencies>
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>
<build>
<plugins>
@ -126,4 +294,5 @@
<finalName>${project.artifactId}</finalName>
</build>
</project>

View File

@ -3,6 +3,7 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
/**

View File

@ -0,0 +1,113 @@
package com.ruoyi.web.aop;
import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.crops.domain.InterfaceStatistics;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.lang.reflect.Array;
import java.time.Duration;
import java.util.*;
/**
* API访问历史统计
* @author yangjunqiang
*/
@Aspect
@Component
public class ApiVisitHistory {
private Logger log = LoggerFactory.getLogger(ApiVisitHistory.class);
private ThreadLocal<Long> startTime = new ThreadLocal<>();
private Set userIds = new HashSet();
@Autowired
private RedisTemplate redisTemplate;
/**
* 定义切面
* - 此处代表com.ruoyi.web.controller.crops包下的所有接口都会被统计
*/
@Pointcut("execution(* com.ruoyi.web.controller.crops..*.*(..))")
public void pointCut(){
}
@Before("pointCut()")
public void doBefore(JoinPoint joinPoint) {
startTime.set(System.currentTimeMillis());
//计数
AtomicCounter.getInstance().increase();
}
@AfterReturning(returning = "returnVal", pointcut = "pointCut()")
public void doAfterReturning(JoinPoint joinPoint, Object returnVal) {
//判断访问接口的用户数
try {
userIds.add(SecurityUtils.getUserId());
}catch (Exception e){}
//从redis中获取数据
InterfaceStatistics iS = (InterfaceStatistics) redisTemplate.opsForValue().get("interfaceStatistics");
//当前时间和今天24点相差毫秒数
long millis = DateUtil.dateDiff(new Date(), DateUtil.getDayEnd());
//如果redis中有数据
if (iS!=null){
Integer visits = iS.getVisits();
Integer dataEntries = iS.getDataEntries();
dataEntries +=getLength(returnVal);
Integer accessingUsers = iS.getAccessingUsers();
// log.info("耗费时间:[{}] ms,访问次数:{},交换数据总量:{}", System.currentTimeMillis() - startTime.get(),AtomicCounter.getInstance().getValue(),dataEntries);
InterfaceStatistics interfaceStatistics = new InterfaceStatistics();
//访问次数进行自增
interfaceStatistics.setVisits(++visits);
//数据总量
interfaceStatistics.setDataEntries(dataEntries);
//用户访问数只取最大
interfaceStatistics.setAccessingUsers((userIds.size()>accessingUsers)?userIds.size():accessingUsers);
redisTemplate.opsForValue().set("interfaceStatistics",interfaceStatistics, Duration.ofMillis(millis));
}else {
InterfaceStatistics interfaceStatistics = new InterfaceStatistics();
interfaceStatistics.setVisits(1);
interfaceStatistics.setDataEntries(1);
interfaceStatistics.setAccessingUsers(1);
redisTemplate.opsForValue().set("interfaceStatistics",interfaceStatistics, Duration.ofMillis(millis));
}
}
/**
* 当接口报错时执行此方法
*/
@AfterThrowing(pointcut = "pointCut()")
public void doAfterThrowing(JoinPoint joinPoint) {
log.info("接口访问失败");
}
//判断Object 的类型(map,set,list,array),并返回长度
private static int getLength(Object obj) {
if (obj == null) {
return 0;
}
if (obj.getClass().isArray()){
int length = Array.getLength(obj);
return length;
}if (obj instanceof List) {
return ((List) obj).size();
}if (obj instanceof Set) {
return ((Set) obj).size();
}if (obj instanceof Map) {
Object data = ((Map) obj).get("data");
getLength(data);
}
return 1;
}
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.web.aop;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 计数器统计当前执行的任务数
* @author yangjunqiang
*
*/
public class AtomicCounter {
/**
* 创建了一个私有静态的AtomicCounter对象作为单例模式的实例
*/
private static final AtomicCounter atomicCounter = new AtomicCounter();
/**
* 私有的构造函数用于限制类的实例化其他类无法直接实例化该类只能通过getInstance()方法获取单例对象
*/
private AtomicCounter() {
}
/**
* 公共静态方法getInstance()用于获取AtomicCounter类的单例对象
* @return 返回之前创建的静态atomicCounter对象
*/
public static AtomicCounter getInstance() {
return atomicCounter;
}
/**
* 创建了一个私有静态的AtomicInteger对象counter用于存储计数器的值
*/
private static AtomicInteger counter = new AtomicInteger();
/**
* 公共方法getValue()用于获取计数器的当前值
* @return 通过调用counter.get()来获取counter的当前值并返回
*/
public int getValue() {
return counter.get();
}
/**
* 公共方法increase()用于递增计数器的值
* @return 通过调用counter.incrementAndGet()来递增counter的值并返回递增后的新值
*/
public int increase() {
return counter.incrementAndGet();
}
/**
* 公共方法decrease()用于递减计数器的值
* 通过调用counter.decrementAndGet()来递减counter的值并返回递减后的新值
* @return
*/
public int decrease() {
return counter.decrementAndGet();
}
}

View File

@ -1,10 +1,8 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.crops.domain.CropsComprehensiveData;
import com.ruoyi.crops.service.ICropsComprehensiveDataService;
@ -17,9 +15,6 @@ import java.util.List;
/**
* 作物综合数据Controller
*
* @author my
* @date 2023-04-19
*/
@RestController
@RequestMapping("/crops/data")
@ -31,7 +26,7 @@ public class CropsComprehensiveDataController extends BaseController
/**
* 查询作物综合数据列表
*/
@PreAuthorize("@ss.hasPermi('crops:data:list')")
@GetMapping("/list")
public TableDataInfo list(CropsComprehensiveData cropsComprehensiveData)
{
@ -44,7 +39,6 @@ public class CropsComprehensiveDataController extends BaseController
* 导出作物综合数据列表
*/
@Log(title = "作物综合数据", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CropsComprehensiveData cropsComprehensiveData)
{
@ -67,7 +61,6 @@ public class CropsComprehensiveDataController extends BaseController
* 新增作物综合数据
*/
@Log(title = "作物综合数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CropsComprehensiveData cropsComprehensiveData)
{
@ -78,7 +71,7 @@ public class CropsComprehensiveDataController extends BaseController
* 修改作物综合数据
*/
@Log(title = "作物综合数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CropsComprehensiveData cropsComprehensiveData)
{
@ -89,7 +82,6 @@ public class CropsComprehensiveDataController extends BaseController
* 删除作物综合数据
*/
@Log(title = "作物综合数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{

View File

@ -1,10 +1,12 @@
package com.ruoyi.web.controller.crops;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsDrought;
import com.ruoyi.crops.service.ICropsDroughtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@ -36,6 +38,7 @@ public class CropsDroughtController extends BaseController {
* @param time
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:drought:list')")
@GetMapping("/{time}")
public List<CropsDrought> selectByTime(@PathVariable("time")Date time){
return iCropsDroughtService.selectByTime(time);

View File

@ -6,6 +6,7 @@ import com.ruoyi.crops.domain.CropStructure;
import com.ruoyi.crops.domain.CropsGrowth;
import com.ruoyi.crops.service.ICropsGrowthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@ -22,7 +23,7 @@ public class CropsGrowthController extends BaseController {
private ICropsGrowthService iCropsGrowthService;
/**
* 批量新增
* 批量新增作物长势数据
* @param map
* @return
*/
@ -33,10 +34,11 @@ public class CropsGrowthController extends BaseController {
}
/**
* 根据时间查询
* 根据时间查询作物长势数据
* @param time
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:growth:list')")
@GetMapping("/{time}")
public List<CropsGrowth> selectByTime(@PathVariable("time") Date time){
return iCropsGrowthService.selectByTime(time);

View File

@ -7,6 +7,7 @@ import com.ruoyi.crops.service.ICropsStructureService;
import org.apache.ibatis.annotations.Param;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;
@ -48,6 +49,7 @@ public class CropsStructureController extends BaseController {
* @param time
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:structure:list')")
@GetMapping("/{time}")
public List<CropStructure> selectByTime(@PathVariable Date time){
return iCropsStructureService.selectByTime(time);

View File

@ -0,0 +1,112 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsUser;
import com.ruoyi.crops.service.ICropsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.util.List;
/**
* 用户controller
*/
@RestController
@RequestMapping("/crops/user")
public class CropsUserController extends BaseController {
@Autowired
private ICropsUserService iCropsUserService;
/**
* 根据id查询用户
* @param phone
* @return
*/
@GetMapping("/{phone}")
public CropsUser selectByPhone(@PathVariable String phone) {
return iCropsUserService.selectByPhone(phone);
}
/**
* 获取所有用户列表
*
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:user:list')")
@GetMapping()
public List<CropsUser> list() {
return iCropsUserService.list();
}
/**
* 删除用户
*
* @param id
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:user:delete')")
@DeleteMapping("/{id}")
public AjaxResult delete(@PathVariable Integer id) {
return toAjax(iCropsUserService.delete(id));
}
/**
* 注册用户
*
* @param cropsUser
* @return
*/
@PostMapping("/register")
public AjaxResult register(@Valid CropsUser cropsUser, Errors errors, String psw2) {
if (errors.hasErrors()) {
return AjaxResult.error(errors.getAllErrors().get(0).getDefaultMessage());
} else if (!cropsUser.getPassword().equals(psw2)) {
return AjaxResult.error("两次密码不同");
} else {
try {
int ret = iCropsUserService.regist(cropsUser);
if (ret > 0) {
return AjaxResult.success(cropsUser);
} else {
return AjaxResult.error("注册失败");
}
} catch (Exception ex) {
return AjaxResult.error(ex.getMessage());
}
}
}
@PostMapping("/login")
public AjaxResult login(@Valid CropsUser cropsUser, Errors errors, HttpSession session) {
if (errors.hasErrors()) {
return AjaxResult.error(errors.getAllErrors().get(0).getDefaultMessage());
} else {
CropsUser user = iCropsUserService.login(cropsUser);
if (user != null) {
session.setAttribute("cropsUser", user);
return AjaxResult.success("登录成功");
} else {
return AjaxResult.error("用户不存在/密码错误");
}
}
}
/**
* 修改用户
*
* @param id
* @return
*/
@PutMapping("/{id}")
public AjaxResult update(@PathVariable Integer id) {
return toAjax(iCropsUserService.update(id));
}
}

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsYield;
import com.ruoyi.crops.service.ICropsYieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@ -12,7 +13,7 @@ import java.util.List;
import java.util.Map;
/**
* 作物产量查询
* 作物产量Controller
*/
@RestController
@RequestMapping("/crops/yield")
@ -25,6 +26,7 @@ public class CropsYieldConeroller extends BaseController {
* @param year
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:yield:list')")
@GetMapping("/{year}")
public List<CropsYield> selectByYear(@PathVariable Integer year){
return iCropsYieldService.selectByYear(year);

View File

@ -0,0 +1,41 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.crops.domain.DataAcquisition;
import com.ruoyi.crops.service.IDataAcquisitionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.FileNotFoundException;
import java.util.List;
/**
* 数据采集Controller
*/
@RestController
@RequestMapping("/crops/acquisition")
public class DataAcquisitionController extends BaseController {
@Autowired
private IDataAcquisitionService iDataAcquisitionService;
private static final Logger logger = LoggerFactory.getLogger(DataAcquisition.class);
@GetMapping
@PreAuthorize("@ss.hasPermi('crops:acquisition:list')")
public DataAcquisition getData() {
return iDataAcquisitionService.getData();
}
@Scheduled(fixedDelay = 60 * 60 * 1000)
public DataAcquisition getdataAcquisition(){
logger.info("每小时更新天空地一体化农业检测数据");
return iDataAcquisitionService.getdataAcquisition();
}
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.crops;
import cn.hutool.http.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.DeviceSense;
import com.ruoyi.crops.domain.gsonBean.GsonDeviceSenseBean;
@ -13,16 +14,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 设备状态信息Controller
*/
@RestController
@RequestMapping("/crops/device")
public class DeviceSenseController {
private static final Logger logger = LoggerFactory.getLogger("scheduled");
public class DeviceSenseController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DeviceSenseController.class);
@Value("${url.deviceSense}")
String url;//指定UR
@ -40,71 +45,91 @@ public class DeviceSenseController {
* @param endTime
* @return
*/
@GetMapping
public List<DeviceSense> selectBytime(@RequestParam String startTime, @RequestParam String endTime) {
@PreAuthorize("@ss.hasPermi('crops:device:select')")
@GetMapping()
public List<DeviceSense> selectBytime(@RequestParam Date startTime, @RequestParam Date endTime) {
return iDeviceSenseService.selectByTime(startTime, endTime);
}
/**
* 定时任务调用接口获取数据插入数据库
*
* @throws Exception
*/
@Scheduled(fixedDelay = 6 * 60 * 1000)
public void getsense() throws Exception {
public DeviceSense getsense(){
String deviceId = "863070042491174-1-1";
Map<String, Object> map = new HashMap<>();//存放参数
map.put("deviceId", deviceId);
//发送get请求
String result = HttpUtil.createGet(url).form(map).execute().body();
//格式化json时间类型数据
Gson gson = new GsonBuilder().setDateFormat("yyyy/MM/dd HH:mm:ss").create();
//格式化json封装到GsonDeviceSenseBean类型
GsonDeviceSenseBean model = gson.fromJson(result, GsonDeviceSenseBean.class);
//创建DeviceSense对象设置deviceId
DeviceSense deviceSense = new DeviceSense();
deviceSense.setDeviceId(deviceId);
//通过反射获取成员变量name与json字段匹配入库
Class clazz = Class.forName("com.ruoyi.crops.domain.DeviceSense");
for (GsonDeviceSenseBean.AttDataList attDataList : model.data.attDataList) {
//2.获取成员变量
String attributeValue = attDataList.attributeValue;
Field field = clazz.getDeclaredField(attDataList.attributeName);
//设置私有变量也可访问
field.setAccessible(true);
//判断数据类型进行相应转换
if (attributeValue != null) {
switch (field.getType().getName()) {
case "java.lang.Double":
field.set(deviceSense, Double.valueOf(attributeValue));
break;
case "java.lang.Integer":
field.set(deviceSense, Integer.valueOf(attributeValue));
break;
case "java.lang.String":
field.set(deviceSense, attributeValue);
break;
case "java.util.Date":
field.set(deviceSense, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attributeValue));
try {
//格式化json时间类型数据
Gson gson = new GsonBuilder().setDateFormat("yyyy/MM/dd HH:mm:ss").create();
//格式化json封装到GsonDeviceSenseBean类型
GsonDeviceSenseBean model = gson.fromJson(result, GsonDeviceSenseBean.class);
//创建DeviceSense对象设置deviceId
DeviceSense deviceSense = new DeviceSense();
deviceSense.setDeviceId(deviceId);
//通过反射获取成员变量name与json字段匹配入库
Class clazz = Class.forName("com.ruoyi.crops.domain.DeviceSense");
for (GsonDeviceSenseBean.AttDataList attDataList : model.data.attDataList) {
//2.获取成员变量
String attributeValue = attDataList.attributeValue;
Field field = clazz.getDeclaredField(attDataList.attributeName);
//设置私有变量也可访问
field.setAccessible(true);
//判断数据类型进行相应转换
if (attributeValue != null) {
switch (field.getType().getName()) {
case "java.lang.Double":
field.set(deviceSense, Double.valueOf(attributeValue));
break;
case "java.lang.Integer":
field.set(deviceSense, Integer.valueOf(attributeValue));
break;
case "java.lang.String":
field.set(deviceSense, attributeValue);
break;
case "java.util.Date":
field.set(deviceSense, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attributeValue));
}
}
}
}
//使用sql判断重复数据插入
iDeviceSenseService.dedupInsert(deviceSense);
//使用sql判断重复数据插入
iDeviceSenseService.dedupInsert(deviceSense);
//判断设备预警信息 插入异常数据库
iWarningService.insertWarning(deviceSense);
logger.info("每6分钟更新一次设备传感数据");
//判断设备预警信息 插入异常数据库
iWarningService.judgeWarning(deviceSense);
logger.info("每6分钟更新一次设备传感数据");
return deviceSense;
} catch (Exception e) {
logger.info(e.toString());
logger.info("获取传感设备数据失败");
return null;
}
}
/**
* 根据小时获取其平均值数据
*
* @param type
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:device:sense')")
@GetMapping("/sense")
public AjaxResult averageList(@RequestParam String type) {
return AjaxResult.success(iDeviceSenseService.averageList(type));
}
/**
* 根据时间查询设备状态
* @param startTime
* @param endTime
* @return
*/
@GetMapping("/select")
public List<DeviceSense> select(@RequestParam Date startTime, @RequestParam Date endTime) {
return iDeviceSenseService.selectByTime(startTime, endTime);
}
}

View File

@ -0,0 +1,447 @@
package com.ruoyi.web.controller.crops;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShapeUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.crops.domain.*;
import com.ruoyi.common.utils.MyPoint;
import com.ruoyi.crops.domain.gsonBean.GsonFarmMachineryBean;
import com.ruoyi.crops.domain.gsonBean.GsonMachineryPositionBean;
import com.ruoyi.crops.domain.vo.FarmMachineryVo;
import com.ruoyi.crops.domain.vo.MachineryJobDataVo;
import com.ruoyi.crops.service.IFarmMachineryService;
import com.ruoyi.crops.service.IGeoServer;
import com.ruoyi.crops.service.IMapDrawPolygonService;
import com.ruoyi.crops.service.IWarningFarmService;
import org.apache.commons.collections.map.HashedMap;
import org.checkerframework.checker.units.qual.A;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.WKTReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
@RestController
@RequestMapping("/farm/machinery")
public class FarmMachineryController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(FarmMachineryController.class);
@Autowired
private IFarmMachineryService iFarmMachineryService;
@Autowired
private IMapDrawPolygonService iMapDrawPolygonService;
@Autowired
private IWarningFarmService iWarningFarmService;
@Autowired
private IGeoServer iGeoServer;
@Value("${FarmMachinery.vehicleList}")
private String vehicleListUrl;
@Value("${FarmMachinery.vehiclePos}")
private String vehiclePosUrl;
@Value("${FarmMachinery.vehicleTrack}")
private String vehicleTrackUrl;
@Value("${FarmMachinery.vehicleJobData}")
private String vehicleJobDataUrl;
@Value("${FarmMachinery.clienttoken}")
private String clienttoken;
/**
* 农机设备信息查询
*
* @return
*/
@GetMapping("selectMachineryData")
public TableDataInfo selectMachineryData() {
startPage();
List<FarmMachineryVo> list = iFarmMachineryService.selectMachineryData();
return getDataTable(list);
}
/**
* 农机位置查询
*
* @param vehicleno
* @return
*/
@GetMapping("/position")
public JSONObject machineryPosition(@RequestParam(value = "vehicleno", required = false) String vehicleno) {
Map<String, Object> map = new HashMap<>();//存放参数
map.put("clienttoken", clienttoken);
if (vehicleno != null) {
map.put("vehicleno", vehicleno);
}
String result = HttpUtil.createPost(vehiclePosUrl).form(map).execute().body();
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
GsonMachineryPositionBean gsonMachineryPositionBean = gson.fromJson(result, GsonMachineryPositionBean.class);
List<MachineryPosition> position = gsonMachineryPositionBean.getPosition();
if (position.size()>0){
iFarmMachineryService.insertPositions(position);
WithinAndIntersects(position);
}
return JSONObject.parseObject(result);
}
//判断农机经纬度是否在范围内
public void WithinAndIntersects(List<MachineryPosition> position) {
List<Map<String, Object>> maps = null;
try {
//读取上传的shp文件
maps = ShapeUtil.readShp(RuoYiConfig.getUploadPath() + "/shpFile/shapefile.shp");
} catch (IOException e) {
e.printStackTrace();
}
for (Map<String, Object> map : maps) {
String wkt = (String) map.get("wkt");
//更改字符串格式 11,22|22,33|33,22|11,22
String substring = wkt.substring(16, wkt.length() - 3);
String replace = substring.replace(", ", "|").replace(" ", ",");
for (MachineryPosition machineryPosition : position) {
if (!iFarmMachineryService.withinAndIntersects(replace, machineryPosition.getLng(), machineryPosition.getLat())){
WarningFarm warningFarm = new WarningFarm();
String vehicleno = machineryPosition.getVehicleno();
warningFarm.setVehicleno(vehicleno);
FarmMachineryVo farmMachineryVos = iFarmMachineryService.selectMachineryData(vehicleno);
warningFarm.setOwnername(farmMachineryVos.getOwnername());
warningFarm.setTime(new Date());
warningFarm.setWarningInfo("作业范围超出");
iWarningFarmService.insertWarning(warningFarm);
}
}
}
}
/**
* 历史作业信息查询
*
* @return
*/
@GetMapping("/selectMachineryJobData")
public TableDataInfo selectMachineryJobData(@RequestParam(required = false, name = "startTime") Date startTime,
@RequestParam(required = false, name = "endTime") Date endTime,
@RequestParam(required = false, name = "vehicleno") String vehicleno) {
startPage();
List<MachineryJobDataVo> list = iFarmMachineryService.selectMachineryJobData(startTime, endTime, vehicleno);
return getDataTable(list);
}
/**
* 查询全部农机编号
* @return
*/
@GetMapping("/selectVehicleno")
public AjaxResult selectVehicleno(){
List<String> list = iFarmMachineryService.selectVehicleno();
return AjaxResult.success(list);
}
/**
* 今日作业查询
*
* @return
*/
@GetMapping("/selectTodayJobData")
public AjaxResult selectTodayJobData() {
MachineryJobDataVo data = iFarmMachineryService.selectTodayJobData();
Map<String, Double> map = new HashedMap();
map.put("area", data.getArea());
map.put("workhours", data.getWorkhours());
return AjaxResult.success(map);
}
/**
* 农机作业信息导出
*
* @param
*/
// @Log(title = "农机作业信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public AjaxResult export(@RequestParam("startTime") Date startTime,
@RequestParam("endTime") Date endTime,
@RequestParam("vehicleno") String vehicleno) {
List<MachineryJobDataVo> list = iFarmMachineryService.selectMachineryJobData(startTime, endTime, vehicleno);
ExcelUtil<MachineryJobDataVo> util = new ExcelUtil<>(MachineryJobDataVo.class);
// util.exportExcel(response, list, "农机作业信息");
AjaxResult excelName = util.exportExcel(list, "农机作业信息");
String msg = (String) excelName.get("msg");
Map<String, String> result = new HashMap<>();
result.put("path", RuoYiConfig.getDownloadPath() + msg);
return AjaxResult.success(result);
}
/**
* 查询农机轨迹信息
*
* @param workplace
* @param pttime
* @return
*/
@GetMapping("/VehicleTrack")
public List<MachineryTrajectory> selectVehicleTrack(String workplace, Date pttime) {
return iFarmMachineryService.selectVehicleTrack(workplace, pttime);
}
/**
* 农机设备状态查询
*
* @return
*/
@GetMapping("/selectFarmStatus")
public FarmStatus selectFarmStatus() {
FarmStatus farmStatus = new FarmStatus();
//农机设备信息查询
List<FarmMachineryVo> farmMachineryVos = iFarmMachineryService.selectMachineryData();
int total = farmMachineryVos.size();
farmStatus.setTotal(total);
int working = iFarmMachineryService.selectWorkingMachinery();
farmStatus.setWorking(working);
farmStatus.setUnwork(total - working);
int Online = iFarmMachineryService.selectMachineryOnline();
farmStatus.setOnline(Online);
farmStatus.setOffline(total - Online);
return farmStatus;
}
//定时获取数据库农机轨迹并发布服务
@Scheduled(fixedDelay = 10* 60 * 1000)
public AjaxResult Machinert() throws Exception {
Map<String, Map<String, String>> areaWorkhoursMap = new HashMap<>();
//查询作业地块
List<String> workplaceList = iFarmMachineryService.distinctWorkplace();
Map result = new HashMap<>();
StringBuilder multiPolygon = new StringBuilder("MULTIPOLYGON((");
List<String> userdata = new ArrayList<>();
StringBuilder multiLineString = new StringBuilder("MULTILINESTRING(");
for (String workplace : workplaceList) {
List<MyPoint> pointList = new ArrayList<>();
Date date = new Date(2023 - 1900, 3 - 1, 13);
//根据作业地块和时间查询农机轨迹数据
List<MachineryTrajectory> machineryTrajectories = iFarmMachineryService.selectVehicleTrack(workplace, date);
for (MachineryTrajectory machineryTrajectory : machineryTrajectories) {
pointList.add(new MyPoint(machineryTrajectory.getLng(), machineryTrajectory.getLat()));
}
//数据大于1000进行抽稀缩减
if (pointList.size() > 1000) {
for (int i = 0; i < pointList.size(); i += 3) {
pointList.remove(i);
}
}
String polygon = ShapeUtil.point2WktPolygon(pointList);
String line = ShapeUtil.point2WktLine(pointList);
Map<String, String> map = new HashMap<>();
map.put("polygon", polygon);
//在经纬度数组后加入第一个点位形成闭环
pointList.add(pointList.size(), pointList.get(0));
//使用凸包算法过滤出边界
List<MyPoint> myPoints = iMapDrawPolygonService.DrawPolygon(pointList);
//第二次过滤转换为wkt格式
String drawPolygon = ShapeUtil.point2WktPolygon(iMapDrawPolygonService.DrawPolygon(myPoints));
//userdata中添加农机编号
MachineryTrajectory trajectory = machineryTrajectories.get(0);
//查询农机编号
String vehicleno = trajectory.getVehicleno();
userdata.add(vehicleno);
userdata.add(trajectory.getWorkplace());
//通过农机编号查询作业类型
userdata.add(String.valueOf(iFarmMachineryService.selectJobtype(vehicleno)));
//截取wkt格式字符串改变为MULTIPOLYGON格式
String substring = drawPolygon.substring(8, drawPolygon.length() - 1);
String linestring = line.substring(10);
multiPolygon.append(substring).append("),(");
multiLineString.append(linestring).append(",");
//计算地块面积
String area = String.format("%.2f", ShapeUtil.getAreaByWkt(polygon) / 666.67);
map.put("area", area);
//计算作业时间
float workingHours = Float.parseFloat(DateUtil.dateDiffHours(trajectory.getPttime(),
machineryTrajectories.get(machineryTrajectories.size() - 1).getPttime()));
String pttime = String.valueOf(workingHours);
map.put("workHours", pttime);
if (areaWorkhoursMap.containsKey(trajectory.getVehicleno())) {
Map<String, String> sMap = areaWorkhoursMap.get(trajectory.getVehicleno());
float va = Float.parseFloat(area);
float fa = Float.parseFloat(sMap.get("area"));
area = String.format("%.2f", (va + fa));
float vw = Float.parseFloat(pttime);
float fw = Float.parseFloat(sMap.get("workHours"));
pttime = String.format("%.2f", (vw + fw));
}
Map<String, String> mp = new HashMap<>();
mp.put("area", area);
mp.put("workHours", pttime);
areaWorkhoursMap.put(trajectory.getVehicleno(), mp);
result.put(workplace, map);
}
//统计作业时长和面积插入数据库
for (Map.Entry<String, Map<String, String>> entry : areaWorkhoursMap.entrySet()) {
String vehicleno = entry.getKey();
Map<String, String> map = entry.getValue();
double area = Float.parseFloat(map.get("area"));
double workingHours = Float.parseFloat(map.get("workHours"));
iFarmMachineryService.updateAreaWorkhours(vehicleno, area, workingHours);
}
String mPolygon = multiPolygon.delete(multiPolygon.length() - 2,multiPolygon.length()).append(")").toString();
String mLineString = multiLineString.deleteCharAt(multiLineString.length() - 1).append(")").toString();
String polygonPath = RuoYiConfig.getUploadPath()+ "/shpFile/" + LocalDate.now() + "polygon.shp";
String lineStringPath = RuoYiConfig.getUploadPath()+ "/shpFile/lineString.shp";
// 生成shp文件
ShapeUtil.writeShape(mPolygon,"MultiPolygon",polygonPath,userdata);
ShapeUtil.writeShape(mLineString,"MultiLineString",lineStringPath,userdata) ;
String fileName = LocalDate.now() + "polygon";
String polygonZipPath = RuoYiConfig.getUploadPath()+ "/shpFile/" + LocalDate.now() + "polygon.zip";
String lineStringZipPath = RuoYiConfig.getUploadPath()+ "/shpFile/lineString.zip";
//发布shp服务
String polygonShpResult = iGeoServer.publishShp("PJZ", fileName, fileName, polygonZipPath);
String lineStringShpResult = iGeoServer.publishShp("PJZ", "lineString", "lineString", lineStringZipPath);
result.put("publishPolygonShp", polygonShpResult);
result.put("publishlineStringShp", lineStringShpResult);
return AjaxResult.success(result);
}
/**
* 物联网接口获取农机轨迹数据
*
* @param vehicleno
* @param jobday
* @param jobtype
* @return
*/
public String gettrack(String vehicleno, Date jobday, String jobtype) {
//格式化作业日期
String formatjobday = new SimpleDateFormat("yyyy-MM-dd").format(jobday);
Map<String, Object> map = new HashMap<>();//存放参数
map.put("clienttoken", clienttoken);
//农机编号
map.put("vehicleno", vehicleno);
//作业日期
map.put("jobday", formatjobday);
//作业类型码
map.put("jobtype", jobtype);
String result = HttpUtil.createPost(vehicleTrackUrl).form(map).execute().body();
return result;
}
//定时获取农机轨迹信息
@Scheduled(fixedDelay = 10 * 1000)
public void processPositions() {
// List<MachineryJobDataVo> machineryJobDataVos = iFarmMachineryService.selectMachineryJobData(DateUtil.getDayBegin(), DateUtil.getBeginDayOfTomorrow(), null);
//查询作业信息
List<MachineryJobDataVo> machineryJobDataVos = iFarmMachineryService.selectMachineryJobData();
iFarmMachineryService.updateworkplace();
//根据农机作业信息进行轨迹查询
for (MachineryJobDataVo machineryJobDataVo : machineryJobDataVos) {
// String json = gettrack(machineryJobDataVo.getVehicleno(), DateUtil.getDayBegin(), machineryJobDataVo.getJobtype());
String json = gettrack(machineryJobDataVo.getVehicleno(), machineryJobDataVo.getJobday(), machineryJobDataVo.getJobtype());
JSONObject jsonObject = JSONObject. parseObject(json);
String postions = jsonObject.getString("postions");
String vehicleno = jsonObject.getString("vehicleno");
List<MachineryTrajectory> list = JSON.parseArray(postions, MachineryTrajectory.class);
iFarmMachineryService.insertProcessPositions(list, vehicleno);
}
}
//农机作业任务查询每天九点查询一次
@Scheduled(cron = "0 0 9 * * ?")
public void getMachineryJobData() throws ParseException {
Map<String, Object> map = new HashMap<>();//存放参数
map.put("clienttoken", clienttoken);
//按要求格式化日期数据进行查询七天数据
Date beginDayOf7day = DateUtil.getBeginDayOf7day();
Date dayBegin = DateUtil.getDayBegin();
String startTime = DateUtils.parseDateToStr("yyyy/MM/dd", beginDayOf7day);
String endTime = DateUtils.parseDateToStr("yyyy/MM/dd", dayBegin);
map.put("jobday", "[\"" + startTime + "\",\"" + endTime + "\"]");
String result = HttpUtil.createPost(vehicleJobDataUrl).form(map).execute().body();
//解析json
JSONObject jsonObject = JSONObject.parseObject(result);
JSONArray jobdata = jsonObject.getJSONArray("jobdata");
//今日农机作业任务数据
List<MachineryJobData> list = JSONArray.parseArray(jobdata.toJSONString(), MachineryJobData.class);
//进行数据去重
List<MachineryJobData> machineryJobData = iFarmMachineryService.selectJobDataByTime(beginDayOf7day, dayBegin);
for (int i = 0; i < list.size(); i++) {
MachineryJobData mj = list.get(i);
for (MachineryJobData md : machineryJobData) {
if (mj.getJobday().equals(md.getJobday()) &&
mj.getVehicleno().equals(md.getVehicleno()) &&
mj.getJobarea().equals(md.getJobarea())) {
list.remove(i);
i--;
}
}
}
if (!list.isEmpty()) {
logger.info("更新农机作业任务");
iFarmMachineryService.insertJobDataBatch(list);
}
}
//每周一九点获取农机数据
@Scheduled(cron = " 0 0 9 ? * 2")
public void getMachineryData() {
Map<String, Object> map = new HashMap<>();//存放参数
map.put("clienttoken", clienttoken);
String result = HttpUtil.createPost(vehicleListUrl).form(map).execute().body();
Gson gson = new Gson();
GsonFarmMachineryBean vehicleList = gson.fromJson(result, GsonFarmMachineryBean.class);
//创建一个空的list集合存放json解析的Meteorological实体数据
List<FarmMachinery> list = vehicleList.getVehicle();
//从数据库里查询出来的数据
List<FarmMachineryVo> farmMachineryList = iFarmMachineryService.selectMachineryData();
//剔除两个集合里面重复元素根据Vmeid和Vehicleno
for (int i = 0; i < list.size(); i++) {
FarmMachinery fm = list.get(i);
for (FarmMachineryVo f : farmMachineryList) {
if (fm.getOwnername().equals(f.getOwnername()) && fm.getVehicleno().equals(f.getVehicleno())) {
list.remove(i);
i--;//不进行i--会数组下标越界异常
}
}
}
if (!list.isEmpty()) {
logger.info("更新农机数据");
iFarmMachineryService.insertBatch(list);
}
}
}

View File

@ -3,7 +3,6 @@ package com.ruoyi.web.controller.crops;
import cn.hutool.http.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.crops.domain.DeviceSense;
import com.ruoyi.crops.domain.FertigationSense;
import com.ruoyi.crops.domain.gsonBean.GsonDeviceSenseBean;
import com.ruoyi.crops.service.IFertigationSenseService;
@ -16,66 +15,79 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.util.DateUtil.now;
/**
* 水肥一体机设备传感数据Controller
*/
@RestController
@RequestMapping
public class FertigationSenseController {
private static final Logger logger = LoggerFactory.getLogger("scheduled");
private static final Logger logger = LoggerFactory.getLogger(FertigationSenseController.class);
@Value("${url.deviceSense}")
String url;//指定UR
String url;//指定URL
@Autowired
private IFertigationSenseService iFertigationSenseService;
/**
* 定时获取水肥一体机设备数据
* @throws Exception
*/
@Scheduled(fixedDelay = 60 * 60 * 1000)
public void getsense() throws Exception {
public FertigationSense getsense() throws Exception {
String deviceId = "645281df92edbc7ee9427230_NHWL-MengLiangGu-Fertigation";
Map<String, Object> map = new HashMap<>();//存放参数
map.put("deviceId", deviceId);
//发送get请求
String result = HttpUtil.createGet(url).form(map).execute().body();
//格式化json时间类型数据
Gson gson = new GsonBuilder().setDateFormat("yyyy/MM/dd HH:mm:ss").create();
//格式化json封装到GsonDeviceSenseBean类型
GsonDeviceSenseBean model = gson.fromJson(result, GsonDeviceSenseBean.class);
//创建DeviceSense对象设置deviceId
FertigationSense fertigationSense = new FertigationSense();
fertigationSense.setDeviceId(deviceId);
fertigationSense.setTime(now());
//通过反射获取成员变量name与json字段匹配入库
Class clazz = Class.forName("com.ruoyi.crops.domain.FertigationSense");
for (GsonDeviceSenseBean.AttDataList attDataList : model.data.attDataList) {
//2.获取成员变量
String attributeValue = attDataList.attributeValue;
Field field = clazz.getDeclaredField(attDataList.attributeName);
//设置私有变量也可访问
field.setAccessible(true);
//判断数据类型进行相应转换
if (attributeValue != null) {
switch (field.getType().getName()) {
case "java.lang.Double":
field.set(fertigationSense, Double.valueOf(attributeValue));
break;
case "java.lang.Integer":
field.set(fertigationSense, Integer.valueOf(attributeValue));
break;
case "java.lang.String":
field.set(fertigationSense, attributeValue);
break;
try{
//格式化json时间类型数据
Gson gson = new GsonBuilder().setDateFormat("yyyy/MM/dd HH:mm:ss").create();
//格式化json封装到GsonDeviceSenseBean类型
GsonDeviceSenseBean model = gson.fromJson(result, GsonDeviceSenseBean.class);
//创建DeviceSense对象设置deviceId
FertigationSense fertigationSense = new FertigationSense();
fertigationSense.setDeviceId(deviceId);
fertigationSense.setTime(now());
//通过反射获取成员变量name与json字段匹配入库
Class clazz = Class.forName("com.ruoyi.crops.domain.FertigationSense");
for (GsonDeviceSenseBean.AttDataList attDataList : model.data.attDataList) {
//2.获取成员变量
String attributeValue = attDataList.attributeValue;
Field field = clazz.getDeclaredField(attDataList.attributeName);
//设置私有变量也可访问
field.setAccessible(true);
//判断数据类型进行相应转换
if (attributeValue != null) {
switch (field.getType().getName()) {
case "java.lang.Double":
field.set(fertigationSense, Double.valueOf(attributeValue));
break;
case "java.lang.Integer":
field.set(fertigationSense, Integer.valueOf(attributeValue));
break;
case "java.lang.String":
field.set(fertigationSense, attributeValue);
break;
// case "java.util.Date":
// field.set(fertigationSense, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attributeValue));
}
}
}
iFertigationSenseService.insert(fertigationSense);
logger.info("每小时更新一次水肥一体机设备传感数据");
return fertigationSense;
}catch (Exception e){
logger.info(e.toString());
logger.info("获取水肥一体机设备传感数据失败");
return null;
}
//使用sql判断重复数据插入
iFertigationSenseService.insert(fertigationSense);
logger.info("每小时更新一次水肥一体机设备传感数据");
}
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.InterfaceStatistics;
import com.ruoyi.crops.domain.vo.InterfaceStatisticsVo;
import com.ruoyi.crops.service.InterfaceStatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.ruoyi.common.utils.Threads.sleep;
@RestController
@RequestMapping("/interface/statistics")
public class InterfaceStatisticsController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(InterfaceStatisticsController.class);
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private InterfaceStatisticsService interfaceStatisticsService;
@Scheduled(fixedDelay = 60 * 60 * 1000)
public AjaxResult getStatistics(){
//启动时延时一秒其他定时任务先执行
sleep(1000);
InterfaceStatistics interfaceStatistics = (InterfaceStatistics) redisTemplate.opsForValue().get("interfaceStatistics");
logger.info("每小时更新接口访问数据");
return toAjax(interfaceStatisticsService.insert(interfaceStatistics));
}
@PreAuthorize("@ss.hasPermi('interface:statistics:day')")
@GetMapping("/day")
public InterfaceStatistics day(){
return interfaceStatisticsService.selectByDay();
}
@PreAuthorize("@ss.hasPermi('interface:statistics:total')")
@GetMapping("/total")
public InterfaceStatisticsVo total(){
return interfaceStatisticsService.selectTotal();
}
}

View File

@ -1,43 +1,152 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.MachineParameter;
import com.ruoyi.crops.domain.OperationRecords;
import com.ruoyi.crops.domain.vo.MachineParameterVo;
import com.ruoyi.crops.service.IMachineParameterService;
import com.ruoyi.crops.service.IOperationRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static org.assertj.core.util.DateUtil.now;
/**
* 水肥一体机参数controller
*/
@RestController
@RequestMapping("/machine/parameter")
public class MachineParameterController extends BaseController {
public class MachineParameterController extends BaseController {
@Autowired
private IMachineParameterService machineParameterService;
/**
* 根据大棚名称进行查询
*
* @param name
* @return
*/
@GetMapping("/{name}")
public List<MachineParameter> selectByName(@PathVariable String name) {
return machineParameterService.selectByName(name);
}
@Autowired
private IOperationRecordsService iOperationRecordsService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 新增单条数据
* 获取水肥一体机状态进行两次对比得到哪些参数被修改存入操作记录
*
* @param type
* @return
* @throws Exception
*/
@GetMapping("/getcompare")
public String getMachineParameter(Integer type) throws Exception {
//判断是开启还是关闭界面
if (type == 0) {
//临时存入redis中和第二次做对比
MachineParameter machineParameter = machineParameterService.getMachineParameter();
redisTemplate.opsForValue().set("machineParameter", machineParameter, Duration.ofMinutes(10));
return machineParameter.toString();
} else if (type == 1) {
//操作好关闭界面再次发送请求
MachineParameter machineParameter = machineParameterService.getMachineParameter();
MachineParameter parameter = (MachineParameter) redisTemplate.opsForValue().get("machineParameter");
//记录修改了几个字段值
int count = 0;
StringBuilder sb = new StringBuilder();
//反射获取类对象
for (Field declaredField : MachineParameter.class.getDeclaredFields()) {
try {
//通过下面compareColumns里定义的字段名进行对比
if (compareColumns.containsKey(declaredField.getName())) {
declaredField.setAccessible(true);
// 转成string 比较字符串内容
Object obj1 = declaredField.get(parameter);
Object obj2 = declaredField.get(machineParameter);
if (Objects.nonNull(obj1) && !obj1.equals(obj2)) {
OperationRecords operationRecords = new OperationRecords();
//状态为0阀门关闭
if (obj2.equals("0")) {
operationRecords.setOperationContent(compareColumns.get(declaredField.getName()) + "关闭");
} else if (obj2.equals("1")) {
operationRecords.setOperationContent(compareColumns.get(declaredField.getName()) + "打开");
}
operationRecords.setUpdateTime(now());
//插入操作记录
iOperationRecordsService.insert(operationRecords);
if (count == 2) {
sb.append("等信息已更新");
break;
}
if (count > 0) {
sb.append(",");
}
sb.append(compareColumns.get(declaredField.getName()));
count++;
}
}
} catch (IllegalAccessException e) {
// log.info("initCustomerDetailCount:{}", e);
}
}
return ("compare result:" + sb.toString());
}
return "参数错误";
}
Map<String, String> compareColumns = new HashMap<String, String>() {
{
put("Valve1", "阀门1");
put("valve2", "阀门2");
put("Valve3", "阀门3");
put("Valve4", "阀门4");
put("Valve5", "阀门5");
put("Valve6", "阀门6");
put("Valve7", "阀门7");
put("Valve8", "阀门8");
put("Valve9", "阀门9");
put("Valve10", "阀门10");
put("Valve11", "阀门11");
put("Valve12", "阀门12");
put("Valve13", "阀门13");
put("Valve14", "阀门14");
put("Valve15", "阀门15");
put("Valve16", "阀门16");
put("Valve17", "阀门17");
put("Valve18", "阀门18");
put("Valve19", "阀门19");
put("Valve20", "阀门20");
put("JiaoBan1", "搅拌1");
put("JiaoBan2", "搅拌2");
put("JiaoBan3", "搅拌3");
put("JiaoBan4", "搅拌4");
put("PowerMode", "功率模式");
put("ControlMode", "控制模式");
}
};
/**
* 获取ph值流量压力值
*
* @param machineParameter
* @return
*/
@PostMapping
public AjaxResult insert(@RequestBody MachineParameter machineParameter) {
return toAjax(machineParameterService.insert(machineParameter));
@GetMapping("/select")
public MachineParameterVo selectParameter() throws Exception {
return machineParameterService.selectParameter();
}
}

View File

@ -1,27 +1,35 @@
package com.ruoyi.web.controller.crops;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.gsonBean.GsonMeteorologicalBean;
import com.ruoyi.crops.domain.Meteorological;
import com.ruoyi.crops.service.IMeteorologicalService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@RestController
@RequestMapping("/crops")
/**
* 天气数据
*/
public class MeteorologicalController {
private static final Logger logger = LoggerFactory.getLogger("scheduled");
private static final Logger logger = LoggerFactory.getLogger(MeteorologicalController.class);
@Value("${Meteorological.url}")
private String url;
@ -33,6 +41,13 @@ public class MeteorologicalController {
@Autowired
private IMeteorologicalService iMeteorologicalService;
/**
* 查询预警数据
*
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:meterological:select')")
@GetMapping("/meterological")
public AjaxResult selectByTime() {
if (iMeteorologicalService.selectByTime().isEmpty()) {
@ -41,40 +56,24 @@ public class MeteorologicalController {
return AjaxResult.success(iMeteorologicalService.selectByTime());
}
/**
* 定时查询天气数据并去重保存
*/
@Scheduled(fixedDelay = 60 * 60 * 1000)
public void MeteorologicalInfo() {
public List<Meteorological> MeteorologicalInfo() {
Map<String, Object> map = new HashMap<>();//存放参数
map.put("city_code", code);
map.put("key", key);
// HashMap<String, String> headers = new HashMap<>();//存放请求头可以存放多个请求头
// headers.put("xxx", xxx);
//发送get请求并接收响应数据
String result = HttpUtil.createGet(url).form(map).execute().body();
//格式化Json时间类型
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
//json转换成对应实体类
//json转换成对应实体类
GsonMeteorologicalBean model = gson.fromJson(result, GsonMeteorologicalBean.class);
//判断json是否有数据
if (model.result != null) {
ArrayList<GsonMeteorologicalBean.Meteorological> meteorologicalArrayList = model.result;
//创建一个空的list集合存放json解析的Meteorological实体数据
List<Meteorological> list = new ArrayList<>();
//遍历json数组里的参数存入实体类
for (GsonMeteorologicalBean.Meteorological meteorological : meteorologicalArrayList) {
//新建实体类
Meteorological ml = new Meteorological();
ml.setWarnId(meteorological.id);
ml.setTitle(meteorological.title);
ml.setLevel(meteorological.level);
ml.setType(meteorological.type);
ml.setTime(meteorological.time);
ml.setProvince(meteorological.province);
ml.setCity(meteorological.city);
ml.setDistrict(meteorological.district);
ml.setContent(meteorological.content);
list.add(ml);
}
List<Meteorological> list = model.result;
//从数据库查询出今日的预警信息
List<Meteorological> meteorologicals = iMeteorologicalService.selectByTime();
//剔除两个集合里面重复元素根据WarnId和Time
@ -82,20 +81,26 @@ public class MeteorologicalController {
Meteorological me = list.get(i);
for (int j = 0; j < meteorologicals.size(); j++) {
Meteorological m = meteorologicals.get(j);
if (me.getWarnId().equals(m.getWarnId()) && me.getTime().equals(m.getTime())) {
if (me.getId() == Integer.parseInt(m.getWarnId()) && me.getTime().equals(m.getTime())) {
list.remove(i);
i--;
}
}
}
//遍历去重集合插入数据库
for (Meteorological meteorological : list) {
iMeteorologicalService.insert(meteorological);
if (!list.isEmpty()) {
//list顺序反转
Collections.reverse(list);
logger.info("每小时更新1次天气预警");
iMeteorologicalService.insertBatch(list);
} else {
logger.info("本小时内无新预警");
}
logger.info("每小时更新1次天气预警");
return list;
} else {
logger.info("今日暂无预警");
}
return model.result;
}
}

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.OperationRecords;
import com.ruoyi.crops.service.IOperationRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -23,6 +24,7 @@ public class OperationRecordsController extends BaseController {
*
* @return
*/
@PreAuthorize("@ss.hasPermi('operation:records:list')")
@GetMapping("/list")
public List<OperationRecords> listAll() {
return iOperationRecordsService.selectAll();

View File

@ -5,12 +5,13 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.ServiceType;
import com.ruoyi.crops.service.IServiceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 服务类型controller
* 服务类型Controller
*/
@RestController
@RequestMapping("/service/type")
@ -24,6 +25,7 @@ public class ServiceTypeController extends BaseController {
* @param type
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:service:type')")
@GetMapping("/{type}")
public List<ServiceType> selectByType(@PathVariable String type) {
return typeService.selectByType(type);
@ -34,6 +36,7 @@ public class ServiceTypeController extends BaseController {
*
* @return
*/
@PreAuthorize("@ss.hasPermi('service:type:selectAll')")
@GetMapping
public List<ServiceType> selectAll() {
return typeService.selectAll();
@ -45,6 +48,7 @@ public class ServiceTypeController extends BaseController {
* @param serviceType
* @return
*/
@PreAuthorize("@ss.hasPermi('service:type:insert')")
@PostMapping("insert")
public AjaxResult insert(@RequestBody ServiceType serviceType) {
return toAjax(typeService.insert(serviceType));
@ -56,6 +60,7 @@ public class ServiceTypeController extends BaseController {
* @param ids
* @return
*/
@PreAuthorize("@ss.hasPermi('service:type:delete')")
@DeleteMapping("/{ids}")
private AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(typeService.deleteByIds(ids));

View File

@ -1,17 +1,16 @@
package com.ruoyi.web.controller.crops;
import cn.hutool.http.HttpUtil;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.BashUtils;
import com.ruoyi.common.utils.ShapeUtil;
import com.ruoyi.crops.domain.ServiceType;
import com.ruoyi.crops.service.IFarmMachineryService;
import com.ruoyi.crops.service.IGeoServer;
import com.ruoyi.crops.service.IUploadService;
import com.ruoyi.crops.service.IexeService;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -20,17 +19,15 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/crops")
public class UploadController {
@Value("${url.group1Upload}")
private String url;
private String workSpace = "PJZ";
@Value("${path.exepath}")
@ -48,6 +45,9 @@ public class UploadController {
@Autowired
private IexeService iexeService;
@Autowired
private IFarmMachineryService iFarmMachineryService;
/**
* 上传TIFF文件
*
@ -57,19 +57,17 @@ public class UploadController {
* @throws Exception
*/
@PostMapping("/upload")
@Transactional(rollbackFor = Exception.class)
public AjaxResult upload(@RequestParam("type") String type, @RequestParam("file") MultipartFile file) throws Exception {
//获得项目的static路径
String realPath = ResourceUtils.getURL("classpath:").getPath() + "static";
//获得文件路径
String filePath = iUploadService.upload(type, file, realPath);
String uploadPath = RuoYiConfig.getUploadPath();
//保存文件到本地并获得文件路径
String filePath = iUploadService.upload(file, uploadPath+"/tifFile");
//调用接口上传文件到服务器
Map<String, Object> map = new HashMap<>();//存放参数
// Map<String, Object> map = new HashMap<>();//存放参数
File targetFile = new File(filePath);
map.put("file", targetFile);
map.put("path", "pjz/tif");
String result = HttpUtil.createPost(url).form(map).execute().body();
// map.put("file", targetFile);
// map.put("path", "pjz/tif");
// String result = HttpUtil.createPost(url).form(map).execute().body();
//获取文件信息
String name = targetFile.getName();
@ -87,10 +85,11 @@ public class UploadController {
serviceType.setTime(date);
serviceType.setServiceName(servieName);
serviceType.setFileName(name);
serviceType.setFilePath(result);
serviceType.setFilePath(filePath);
serviceType.setStyle(type);
//发送地图服务
String pjz = iGeoServer.GeoServer(workSpace, fileName, filePath);
String pjz = iGeoServer.publishTiff(workSpace, fileName, filePath, type);
//调用exe批量导入数据
String res = iexeService.execCommand(type, targetFile.getAbsolutePath(), boundaryDataPath);
@ -99,4 +98,26 @@ public class UploadController {
return AjaxResult.success(pjz + res);
}
/**
* 上传shp.zip文件
* @param file
* @return
*/
@PostMapping("/uploadShp")
public AjaxResult uploadShp(@RequestParam("file") MultipartFile file){
String uploadPath = RuoYiConfig.getUploadPath();
//保存文件到本地并获得文件路径
String filePath = null;
try {
filePath = iUploadService.upload(file, uploadPath+"/shpFile");
//解压上传的shp.zip文件
String unzip = ShapeUtil.unzip(filePath, uploadPath + "/shpFile/");
return AjaxResult.success(unzip);
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
}
}

View File

@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
@ -18,9 +19,8 @@ import java.util.HashMap;
@RestController
@RequestMapping("/user/info")
public class UserInfoController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger("scheduled");
private static final Logger logger = LoggerFactory.getLogger(UserInfoController.class);
@Autowired
private RedisTemplate redisTemplate;

View File

@ -2,18 +2,22 @@ package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.crops.domain.DeviceSense;
import com.ruoyi.crops.domain.WaringNumber;
import com.ruoyi.crops.domain.WarningInformation;
import com.ruoyi.crops.service.IDeviceSenseService;
import com.ruoyi.crops.service.IWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* 预警信息controller
* 预警信息Controller
*/
@RestController
@RequestMapping("/warning/information")
@ -22,13 +26,17 @@ public class WarningController extends BaseController {
private IWarningService iWarningService;
/**
* 根据时间查询
* 预警信息根据时间查询
*
* @return
*/
@PreAuthorize("@ss.hasPermi('warning:information:selectByTime')")
@GetMapping("/selectByTime")
public List<WarningInformation> selectBytTime(@RequestParam Date startTime, @RequestParam Date endTime) {
return iWarningService.selectByTime(startTime, endTime);
public TableDataInfo selectBytTime(@RequestParam(required = false) Date startTime,
@RequestParam(required = false) Date endTime) {
startPage();
List<WarningInformation> list = iWarningService.selectByTime(startTime, endTime);
return getDataTable(list);
}
/**
@ -42,6 +50,12 @@ public class WarningController extends BaseController {
return toAjax(iWarningService.insert(warningInformation));
}
/**
* 大棚预警次数查询
*
* @return
*/
@PreAuthorize("@ss.hasPermi('warning:information:numberOfTimes')")
@GetMapping("/numberOfTimes")
public AjaxResult numberOfTimes() {
List<WarningInformation> daylist = iWarningService.selectByTime(DateUtil.getDayBegin(), DateUtil.getDayEnd());
@ -58,5 +72,6 @@ public class WarningController extends BaseController {
waringNumber.setMonthNumber(monthNumber);
return AjaxResult.success(waringNumber);
}
}

View File

@ -0,0 +1,111 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.crops.domain.MachineryTrajectory;
import com.ruoyi.crops.domain.WaringNumber;
import com.ruoyi.crops.domain.WarningFarm;
import com.ruoyi.crops.domain.vo.FarmMachineryVo;
import com.ruoyi.crops.service.IFarmMachineryService;
import com.ruoyi.crops.service.IWarningFarmService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/warning/farm")
public class WarningFarmController extends BaseController {
@Autowired
private IFarmMachineryService iFarmMachineryService;
@Autowired
private IWarningFarmService iWarningFarmService;
private static final Logger logger = LoggerFactory.getLogger(WarningFarmController.class);
/**
* 农机预警次数查询
* @return
*/
@GetMapping("/numberOfTimes")
public AjaxResult numberOfTimes() {
List<WarningFarm> daylist = iWarningFarmService.selectByTime(DateUtil.getDayBegin(), DateUtil.getDayEnd());
int dayNumber = daylist.size();
List<WarningFarm> weeklist = iWarningFarmService.selectByTime(DateUtil.getBeginDayOfWeek(), DateUtil.getEndDayOfWeek());
int weekNumber = weeklist.size();
List<WarningFarm> monthlist = iWarningFarmService.selectByTime(DateUtil.getBeginDayOfMonth(), DateUtil.getEndDayOfMonth());
int monthNumber = monthlist.size();
WaringNumber waringNumber = new WaringNumber();
waringNumber.setDayNumber(dayNumber);
waringNumber.setWeekNumber(weekNumber);
waringNumber.setMonthNumber(monthNumber);
return AjaxResult.success(waringNumber);
}
/**
* 农机预警信息根据时间查询
* @param startTime
* @param endTime
* @return
*/
@GetMapping("/selectByTime")
public TableDataInfo selectBytTime(@RequestParam(required = false) Date startTime,
@RequestParam(required = false) Date endTime) {
startPage();
List<WarningFarm> list = iWarningFarmService.selectByTime(startTime, endTime);
return getDataTable(list);
}
//判断农机预警
@Scheduled(fixedDelay = 5 * 60 * 1000)
public void warning() {
//查询今日作业农机编号
List<String> vehiclenoList = iFarmMachineryService.distinctVehicleno();
//根据编号查询作业地块
for (String vehicleno : vehiclenoList) {
List<String> workplaceList = iFarmMachineryService.distinctWorkplace(vehicleno);
Date lastTime = null;
//根据地块查询具体作业数据
for (String workplace : workplaceList) {
Date date = new Date(2023 - 1900, 3 - 1, 13);
//根据作业地块和时间查询农机轨迹数据
List<MachineryTrajectory> machineryTrajectories = iFarmMachineryService.selectVehicleTrack(workplace, date);
MachineryTrajectory trajectory = machineryTrajectories.get(0);
Date lastPttime = machineryTrajectories.get(machineryTrajectories.size() - 1).getPttime();
//农机此次作业时长
float workingHours = Float.parseFloat(DateUtil.dateDiffHours(trajectory.getPttime(), lastPttime));
WarningFarm warningFarm = new WarningFarm();
warningFarm.setVehicleno(vehicleno);
warningFarm.setTime(new Date());
FarmMachineryVo farmMachineryVos = iFarmMachineryService.selectMachineryData(vehicleno);
warningFarm.setOwnername(farmMachineryVos.getOwnername());
if (lastTime != null) {
float freeTime = Float.parseFloat(DateUtil.dateDiffHours(lastTime, trajectory.getPttime()));
if (freeTime > 0.1) {
//插入数据库预警
warningFarm.setWarningInfo("闲置时间过长");
iWarningFarmService.insertWarning(warningFarm);
logger.info("农机闲置时间预警更新:" + vehicleno +"-"+ freeTime + "小时");
}
}
lastTime = machineryTrajectories.get(machineryTrajectories.size() - 1).getPttime();
if (workingHours > 0.5) {
//预警
warningFarm.setWarningInfo("作业时间过长");
iWarningFarmService.insertWarning(warningFarm);
logger.info("农机作业时间预警更新:" + vehicleno +"-"+ workingHours + "小时");
}
}
}
}
}

View File

@ -0,0 +1,94 @@
package com.ruoyi.web.controller.crops;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.crops.domain.WeatherPredictionEntity;
import com.ruoyi.crops.domain.vo.WeatherPredoctionVo;
import com.ruoyi.crops.service.IWeatherPredictionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/crops/weather")
public class WeatherPredictionController extends BaseController {
@Autowired
private IWeatherPredictionService iWeatherPredictionService;
private static final Logger logger = LoggerFactory.getLogger(WeatherPredictionController.class);
/**
* 查询一周的天气数据
*
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:weather:selectWeek')")
@GetMapping("/selectWeek")
public List<WeatherPredictionEntity> selectWeek() {
return iWeatherPredictionService.selectWeek();
}
/**
* 气象数据对比查询
*
* @param time1
* @param time2
* @return
*/
@PreAuthorize("@ss.hasPermi('crops:weather:compareTime')")
@GetMapping("/compareTime")
public List<WeatherPredoctionVo> compareTime(@RequestParam Date time1, @RequestParam Date time2) {
List<WeatherPredoctionVo> weather1 = iWeatherPredictionService.selectByTime(time1);
List<WeatherPredoctionVo> weather2 = iWeatherPredictionService.selectByTime(time2);
for (WeatherPredoctionVo weatherPredoctopnVo : weather1) {
if (weatherPredoctopnVo != null) {
weatherPredoctopnVo.setWeatherTime(time1);
String windSpeed = String.format("%.2f", Double.parseDouble(weatherPredoctopnVo.getWindSpeed()));
String precipitation = String.format("%.2f", Double.parseDouble(weatherPredoctopnVo.getPrecipitation()));
weatherPredoctopnVo.setWindSpeed(windSpeed);
weatherPredoctopnVo.setPrecipitation(precipitation);
}
}
for (WeatherPredoctionVo weatherPredoctopnVo : weather2) {
if (weatherPredoctopnVo != null) {
weatherPredoctopnVo.setWeatherTime(time2);
String windSpeed = String.format("%.2f", Double.parseDouble(weatherPredoctopnVo.getWindSpeed()));
String precipitation = String.format("%.2f", Double.parseDouble(weatherPredoctopnVo.getPrecipitation()));
weatherPredoctopnVo.setWindSpeed(windSpeed);
weatherPredoctopnVo.setPrecipitation(precipitation);
}
}
List<WeatherPredoctionVo> list = new ArrayList<>();
list.addAll(weather1);
list.addAll(weather2);
return list;
}
/**
* 定时查询更新天气数据
*
* @throws IOException
*/
// @Scheduled(cron = "0 0 8,12,20 * * ?")
@Scheduled(fixedDelay = 60 * 60 * 1000)
public List<WeatherPredictionEntity> getWeather() throws IOException {
List<WeatherPredictionEntity> weatherList = iWeatherPredictionService.getWeather();
iWeatherPredictionService.insertBatch(weatherList);
logger.info("每小时更新博兴天气数据");
return weatherList;
}
}

View File

@ -17,7 +17,7 @@ import java.util.List;
/**
* 生产厂家信息Controller
*
*
* @author my
* @date 2023-04-18
*/

View File

@ -133,8 +133,9 @@ xss:
url:
foundation: 'http://api.nonghaiiot.com/api/foundation/getFoundationByUserId.zzdy'
userInfo: 'http://api.nonghaiiot.com/admin/sys/login'
group1Upload: '192.168.2.20:4096/group1/upload'
deviceSense : 'http://admin.nonghaiiot.com/app/queryDataByPropertyAll'
# group1Upload: '192.168.2.20:4096/group1/upload'
deviceSense: 'http://admin.nonghaiiot.com/app/queryDataByPropertyAll'
machine: 'http://api.nonghaiiot.com/api/device/getFertigationProperty.zzdy'
geoserver:
url: 'http://192.168.2.20:9080/geoserver'
@ -148,6 +149,12 @@ path:
Meteorological:
url: 'https://apis.juhe.cn/fapig/alarm/queryV2'
# key: 'f072a23affd5551ecd9ae3a98d703b1c'
key : '123'
key: 'f072a23affd5551ecd9ae3a98d703b1c'
code: '150700'
FarmMachinery:
vehicleList: 'https://www.amtiot.cn/amapi/jzzy/VehicleList/query'
vehiclePos: 'https://www.amtiot.cn/amapi/jzzy/VehiclePos/query'
vehicleTrack: 'https://www.amtiot.cn/amapi/jzzy/VehicleTrack/query'
vehicleJobData: 'https://www.amtiot.cn/amapi/jzzy/VehicleJobData/query'
clienttoken: 'Ts7kePaCiWg+VRMrDkbdFnsY3TX0OaYckpC3eMV0Rvu01cuP9xeSBxbJYR5DnXUn1injVF36EopkBCiXYqteGpz1U/RpD2xs1vNoRenHE7tIPL0FK9gRTeLQCJm+d1AcH6uQBEmG+YiDrvanBSTnzdu2O61ZENEu4LZVQPZNsOENQfB8CRGvk1y9BKdf9uTj4d8Oaxwq4kpHegQSHReR9nylunAO1dN7NuX1mSzZ0sSyNcf43Nsrl/EMAJmA2V5lu2aSPZ455wmCbC7n2BSydRQp76thforrYM4SMKQ2i7u215e9S/A9Ll5syzyykwnkVlk2vfy9+U3fgG5ySeu6ITvkaLrk8tw3pI/sSWlajR9vyluJXmUlvgFeXfjSlcL6XfQcoSc5LaERZhn9e0GIczfpNDGrjvQgFgWB3E0y6WH5vU3Lr5AofbDnMceuY7wYefVcOtr+EOTB7f2p8aCPxZXWkSiN+WFWpuzLXCOkr1shAgMfGFARxHN/Zp8ABgc3aweVO29BFiv7PGgEc7mJ/w'

View File

@ -1,77 +1,100 @@
package com.ruoyi.web;
import cn.hutool.http.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.crops.domain.DeviceSense;
import com.ruoyi.crops.domain.FertigationSense;
import com.ruoyi.crops.domain.WarningInformation;
import com.ruoyi.crops.domain.gsonBean.GsonDeviceSenseBean;
import com.ruoyi.crops.service.IFertigationSenseService;
import com.ruoyi.crops.service.IWarningService;
import it.geosolutions.geoserver.rest.GeoServerRESTManager;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
import com.ruoyi.common.utils.ShapeUtil;
import com.ruoyi.crops.domain.WarningFarm;
import com.ruoyi.crops.service.*;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import java.lang.reflect.Field;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.util.DateUtil.now;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@SpringBootTest
public class PssTest {
@Value("${geoserver.url}")
@Value("${url.machine}")
private String url;
@Value("${geoserver.username}")
private String username;
@Value("${geoserver.password}")
private String password;
@Autowired
private IWeatherPredictionService iWeatherPredictionService;
@Autowired
private IDataAcquisitionService iDataAcquisitionService;
@Autowired
private IWarningService iWarningService;
private IMapDrawPolygonService iMapDrawPolygonService;
@Autowired
private IFarmMachineryService iFarmMachineryService;
@Autowired
private IWarningFarmService iWarningFarmService;
@Test
public void test() throws Exception {
// publisherLayer("PJZ","zwhq_2023-05-11","zwhq","a","PJZ:zwcl_xm_2023-04-20","c",1);
getDayBegin();
// List<WeatherPredictionEntity> weatherPredictionEntities = weatherPredictionMapper.selectWeek();
// WeatherPredictionEntity weatherPredictionEntity = weatherPredictionEntities.get(0);
// String airTemperature = weatherPredictionEntity.getAirTemperature();
// for(int i = 0 ;i< arr.length -1; i++){
// for(int j = 0; j<arr.length-1-i; j++){
// if(arr[j]>arr[j+1]){
// temp = arr[j];
// arr[j] = arr[j+1];
// arr[j+1] = temp;
// }
// }
// }
}
public static java.util.Date getDayBegin() {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
System.out.println(cal.getTime());
return cal.getTime();
@Test
public void test5() throws ParseException {
// List<WeatherPredictionEntity> weatherPredoction = iWeatherPredictionService.select(new SimpleDateFormat("yyyy-MM-dd").parse("2023-05-22"));
// weatherPredoction.sort(Comparator.comparing(WeatherPredictionEntity::getAirTemperature));
// String maxAirTemperature = weatherPredoction.get(0).getAirTemperature();
// String minAirTemperature = weatherPredoction.get(weatherPredoction.size()-1).getAirTemperature();
//比较器排序后的集合
// Comparator<WeatherPredictionEntity> comparing = Comparator.comparing(WeatherPredictionEntity::getAirTemperature);
// Comparator<WeatherPredictionEntity> humidity = Comparator.comparing(WeatherPredictionEntity::getHumidity);
// Comparator<WeatherPredictionEntity> windSpeed = Comparator.comparing(WeatherPredictionEntity::getWindSpeed);
// String maxAirTemperature = weatherPredoction.stream().max(comparing).get().getAirTemperature();
// String minAirTemperature = weatherPredoction.stream().min(comparing).get().getAirTemperature();
// String maxHumidity = weatherPredoction.stream().max(humidity).get().getHumidity();
// String minHumidity = weatherPredoction.stream().min(humidity).get().getHumidity();
// String awindSpeed = weatherPredoction.stream().(humidity).get().getWindSpeed();
//
// System.out.println(maxAirTemperature);
// System.out.println(minAirTemperature);
// System.out.println(maxHumidity);
// System.out.println(minHumidity);
}
public boolean publisherLayer(String workspaceName,String dataStoreName,String styleName, String tableName,String layerName, String layerAlias, int crsCode) throws Exception {
URL u = new URL(url);
GeoServerRESTManager manager = new GeoServerRESTManager(u, username, password);
GeoServerRESTPublisher publisher = manager.getPublisher();
public static void main(String[] args) throws Exception {
//图层设置
GSFeatureTypeEncoder gsFeatureTypeEncoder = new GSFeatureTypeEncoder();
gsFeatureTypeEncoder.setNativeName(tableName); //表名
gsFeatureTypeEncoder.setName(layerName); // 图层名称
gsFeatureTypeEncoder.setTitle(layerAlias);// 图层别名
gsFeatureTypeEncoder.setSRS("EPSG:" + crsCode); //坐标系
// String wkt = "MULTIPOLYGON ((30 20, 45 40, 10 40, 30 20), (15 5, 40 10, 10 20, 5 10, 15 5))";
// ShapeUtil.writeShape(wkt,"MultiPolygon","D:\\ruoyi\\uploadPath\\upload\\shpFile\\lineString.shp");
GSLayerEncoder styleEncoder = new GSLayerEncoder(); //设置样式
styleEncoder.setDefaultStyle(workspaceName,styleName);
//读取shp文件
//
// List list = ShapeUtil.readShp("D:\\ruoyi\\uploadPath\\upload\\shpFile\\2023-06-25polygon.shp");
// Map<String,String> map =(Map) list.get(0);
// String wkt = map.get("wkt");
// System.out.println(wkt);
//
// WKTReader wktReader = new WKTReader();
// Geometry geometry = wktReader.read(wkt);
// test(geometry);
boolean publishDBLayerResult = publisher.publishDBLayer(workspaceName, dataStoreName, gsFeatureTypeEncoder, styleEncoder);
return publishDBLayerResult;
// ShapeUtil.unzip("", "");
}
}

View File

@ -129,7 +129,42 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>20.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>20.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>
</project>

View File

@ -76,6 +76,14 @@ public class DateUtil {
return cal.getTime();
}
//获取七天前的开始时间
public static Date getBeginDayOf7day() {
Calendar cal = new GregorianCalendar();
cal.setTime(getDayBegin());
cal.add(Calendar.DAY_OF_MONTH, -7);
return cal.getTime();
}
// 获取本周的开始时间
@SuppressWarnings("unused")
public static Date getBeginDayOfWeek() {
@ -233,6 +241,27 @@ public class DateUtil {
long date2ms = endDate.getTime();
return date2ms - date1ms;
}
//两个日期相差多少小时
public static String dateDiffHours(Date beginDate,Date endDate){
long nd = 1000 * 24 * 60 * 60;
float nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
float diff = endDate.getTime() - beginDate.getTime();
// 计算差多少天
// long day = diff / nd;
// 计算差多少小时
// float hour = diff % nd / nh;
float hour = diff / nh;
String fhour = String.format("%.2f", hour);
// 计算差多少分钟
// long min = diff % nd % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
// return day + "" + hour + "小时" + min + "分钟";
return fhour;
}
// 获取两个日期中的最大日期
public static Date max(Date beginDate, Date endDate) {

View File

@ -0,0 +1,38 @@
package com.ruoyi.common.utils;
public class MyPoint {
private double x;
private double y;
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public MyPoint() {
}
public MyPoint(double x, double y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return "MyPoint{" +
"x=" + x +
", y=" + y +
'}';
}
}

View File

@ -0,0 +1,414 @@
package com.ruoyi.common.utils;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.geotools.data.DefaultTransaction;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.Transaction;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.data.simple.SimpleFeatureStore;
import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.*;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.opengis.feature.Property;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ShapeUtil {
private static final Logger logger = LoggerFactory.getLogger("ShapeUtil.class");
static class polygonPoint {
public double x;
public double y;
public polygonPoint(double x, double y) {
this.x = x;
this.y = y;
}
}
/**
* 生成shp文件
* @param wkt wkt格式 经纬度必须首尾相连
* @throws IOException
* @throws FactoryException
*/
public static String writeShape(String wkt,String geoType,String targetPath,List userdata) throws Exception {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Feature");
/**
* //方式一
* CRS.decode("EPSG:4326");
* //方式二
* DefaultGeographicCRS.WGS84;
*
* EPSG:4490为大地坐标系_国家2000大地坐标系CGCS2000
* EPSG:4326支持一种默认的定义方式, 坐标系WGS84
*/
// builder.setCRS(DefaultGeographicCRS.WGS84);
builder.setCRS(CRS.decode("EPSG:4326"));
//农机编号
builder.add("vehicleno", String.class);
//作业地块
builder.add("workplace", String.class);
//作业类型
builder.add("jobtype", String.class);
if ("Polygon".equals(geoType) || "polygon".equals(geoType)) {
builder.add("the_geom", Polygon.class);
} else if ("MultiPolygon".equals(geoType)) {
builder.add("the_geom", MultiPolygon.class);
} else if ("Point".equals(geoType) || "point".equals(geoType)) {
builder.add("the_geom", Point.class);
} else if ("MultiPoint".equals(geoType)) {
builder.add("the_geom", MultiPoint.class);
} else if ("LineString".equals(geoType)) {
builder.add("the_geom", LineString.class);
} else if ("MultiLineString".equals(geoType) || "Polyline".equals(geoType) || "polyline".equals(geoType)) {
builder.add("the_geom", MultiLineString.class);
} else {
throw new Exception("Geometry中没有该类型" + geoType);
}
SimpleFeatureType featureType = builder.buildFeatureType();
// DefaultFeatureCollection collection = new DefaultFeatureCollection();
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
// SimpleFeature feature = (SimpleFeature) toFeature(wkt, featureType, geometryFactory,geoType);
DefaultFeatureCollection collection = toFeature(wkt, featureType, geometryFactory, geoType,userdata);
// collection.add(feature);
// collection.forEach(name -> System.out.println(name));
// File shapeFile = new File(new File("").getAbsolutePath() +
// "\\ruoyi-admin\\src\\main\\resources\\shp\\shapefile.shp");
File shapeFile = new File(targetPath);
// String fileName = RuoYiConfig.getUploadPath() + "/shpFile/" + LocalDate.now() + "shapefile.shp";
// File shapeFile = new File(fileName);
Map<String, Serializable> params = new HashMap<>();
params.put("url", shapeFile.toURI().toURL());
params.put("create spatial index", Boolean.TRUE);
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
ShapefileDataStore dataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
// dataStore.setCharset(StandardCharsets.UTF_8);
dataStore.createSchema(featureType);
Transaction transaction = new DefaultTransaction("create");
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
featureStore.setTransaction(transaction);
try {
featureStore.addFeatures(collection);
transaction.commit();
zipShapeFile(shapeFile.getPath());
} catch (Exception problem) {
transaction.rollback();
} finally {
transaction.close();
}
}
logger.info("生成shp文件成功"+shapeFile.getAbsolutePath());
return shapeFile.getAbsolutePath();
}
/**
* 创建要素
*
* @param wkt
* @param featureType
* @param geometryFactory
* @return
*/
public static DefaultFeatureCollection toFeature(String wkt, SimpleFeatureType featureType,
GeometryFactory geometryFactory, String geoType,List userdata) throws Exception {
//通过坐标对象Coordinate创建
// Coordinate[] coords = new Coordinate[locations.size()];
// int i = 0;
// for (MyPoint location : locations) {
// Coordinate coord = new Coordinate(location.getX(), location.getY(), 0);
// coords[i] = (coord);
// i++;
// }
// Polygon polygon = geometryFactory.createPolygon(coords);
//通过WKT创建
WKTReader reader = new WKTReader(geometryFactory);
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
if ("Polygon".equals(geoType) || "polygon".equals(geoType)) {
Polygon polygon = (Polygon) reader.read(wkt);
featureBuilder.add(polygon);
} else if ("MultiPolygon".equals(geoType)) {
MultiPolygon multiPolygon = (MultiPolygon) reader.read(wkt);
int index = -1;
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Polygon polygon = (Polygon) multiPolygon.getGeometryN(i);
featureBuilder.add(userdata.get(++index));
featureBuilder.add(userdata.get(++index));
featureBuilder.add(userdata.get(++index));
featureBuilder.add(polygon);
SimpleFeature feature = featureBuilder.buildFeature(null);
featureCollection.add(feature);
}
return featureCollection;
} else if ("Point".equals(geoType) || "point".equals(geoType)) {
Point point = (Point) reader.read(wkt);
featureBuilder.add(point);
} else if ("MultiPoint".equals(geoType)) {
MultiPoint multiPoint = (MultiPoint) reader.read(wkt);
featureBuilder.add(multiPoint);
} else if ("LineString".equals(geoType)) {
LineString lineString = (LineString) reader.read(wkt);
featureBuilder.add(lineString);
} else if ("MultiLineString".equals(geoType) || "Polyline".equals(geoType) || "polyline".equals(geoType)) {
MultiLineString multiLineString = (MultiLineString) reader.read(wkt);
int index = -1;
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
LineString lineString = (LineString) multiLineString.getGeometryN(i);
featureBuilder.add(userdata.get(++index));
featureBuilder.add(userdata.get(++index));
featureBuilder.add(userdata.get(++index));
featureBuilder.add(lineString);
SimpleFeature feature = featureBuilder.buildFeature(null);
featureCollection.add(feature);
}
return featureCollection;
} else {
throw new Exception("Geometry中没有该类型" + geoType);
}
featureCollection.add(featureBuilder.buildFeature(null));
return featureCollection;
}
/**
* 读取shp文件
* @param shpPath
* @return
* @throws IOException
*/
public static List<Map<String, Object>> readShp(String shpPath) throws IOException {
//加载文件
File file = new File(shpPath);
if (file == null) {
return null;
}
//map记录shapefile key-value数据
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//通过store获取featurecollection
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
SimpleFeatureCollection simpleFeatureCollection = featureSource.getFeatures();
SimpleFeatureIterator itertor = simpleFeatureCollection.features();
//遍历featurecollection
while (itertor.hasNext()) {
Map<String, Object> data = new HashMap<>();
SimpleFeature feature = itertor.next();
Collection<Property> p = feature.getProperties();
Iterator<Property> it = p.iterator();
//遍历feature的properties
while (it.hasNext()) {
Property pro = it.next();
String field = pro.getName().toString();
String value = pro.getValue().toString();
field = field.equals("the_geom") ? "wkt" : field;
byte[] bytes = value.getBytes("iso8859-1");
value = new String(bytes, "gbk");
data.put(field, value);
}
list.add(data);
}
itertor.close();
return list;
}
/**
* 根据wkt计算多边形面积
* @param wkt 待计算wkt
* @return 面积数据
*/
public static double getAreaByWkt(String wkt){
Geometry geometry ;
WKTReader reader = new WKTReader();
try {
geometry = reader.read(wkt);
} catch (ParseException e) {
geometry = null;
e.printStackTrace();
}
return getArea(geometry);
}
/**
* 根据多边形类型计算出多边形面积单位平方米
* @param geometry 多边形对象
* @return 面积
*/
public static double getArea(Geometry geometry){
CoordinateReferenceSystem source = null;
try {
// WGS84(一般项目中常用的是CSR:84和EPSG:4326)
source = CRS.decode("EPSG:4326");
} catch (FactoryException e) {
e.printStackTrace();
}
CoordinateReferenceSystem target = null;
try {
target = CRS.decode("EPSG:3857");
// target = CRS.decode("EPSG:3005");
} catch (FactoryException e) {
e.printStackTrace();
}
MathTransform transform = null;
try {
transform = CRS.findMathTransform(source, target, true);
} catch (FactoryException e) {
e.printStackTrace();
}
Geometry transform1 = null;
try {
transform1 = JTS.transform(geometry, transform);
} catch (TransformException e) {
e.printStackTrace();
}
double area = transform1.getArea();
//周长
double length = transform1.getLength();
return area;
}
/**
* 压缩shape文件
*
* @param shpPath shape文件路径包含shape文件名称
*/
public static void zipShapeFile(String shpPath) {
try {
File shpFile = new File(shpPath);
String shpRoot = shpFile.getParentFile().getPath();
String shpName = shpFile.getName().substring(0, shpFile.getName().lastIndexOf("."));
String zipPath = shpRoot + File.separator + shpName + ".zip";
File zipFile = new File(zipPath);
InputStream input = null;
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
// zip的名称为
zipOut.setComment(shpName);
String[] shpFiles = new String[]{
shpRoot + File.separator + shpName + ".dbf",
shpRoot + File.separator + shpName + ".prj",
shpRoot + File.separator + shpName + ".shp",
shpRoot + File.separator + shpName + ".shx",
shpRoot + File.separator + shpName + ".fix"
};
for (int i = 0; i < shpFiles.length; i++) {
File file = new File(shpFiles[i]);
input = new FileInputStream(file);
zipOut.putNextEntry(new ZipEntry(file.getName()));
int temp = 0;
while ((temp = input.read()) != -1) {
zipOut.write(temp);
}
input.close();
}
zipOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*文件解压缩
* @param zipfile 要解压缩的zip文件
* @param destpath 解压后文件所放的目录需要"D:\\""D:\\test\"格式
* @throws FileNotFoundException
* @throws IOException
*/
public static String unzip(String zipfile, String destpath) throws IOException {
try {
File zipFile = new File(zipfile);
if (!zipFile.exists()) {
throw new IOException("要解压的压缩文件不存在");
}
File pathFile = new File(destpath);
if (!pathFile.exists()) {
pathFile.mkdirs();
}
FileInputStream fis = new FileInputStream(zipfile);
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry z1 = null;
while ((z1 = zis.getNextEntry()) != null) {
if (z1.isDirectory()) {
File f = new File("D:\\" + z1.getName());
f.mkdirs();
} else {
String fileName = z1.getName();
FileOutputStream fos = new FileOutputStream(destpath + fileName);
int tmp = -1;
while ((tmp = zis.read()) != -1) {
/*写入到目标文件中*/
fos.write(tmp);
}
zis.closeEntry();
fos.close();
}
}
zis.close();
} catch (Exception e) {
throw new IOException(e);
}
return "解压成功!文件路径:"+destpath;
}
//将经纬度数组转换为wkt格式
public static String point2WktPolygon(List<MyPoint> points) {
StringBuilder sb = new StringBuilder("POLYGON((");
for (MyPoint point : points) {
sb.append(point.getX()).append(" ").append(point.getY()).append(",");
}
sb.append(points.get(0).getX()).append(" ").append(points.get(0).getY()).append("))");
return sb.toString();
}
public static String point2WktLine(List<MyPoint> points) {
StringBuilder sb = new StringBuilder("LINESTRING(");
for (MyPoint point : points) {
sb.append(point.getX()).append(" ").append(point.getY()).append(", ");
}
sb.append(points.get(0).getX()).append(" ").append(points.get(0).getY()).append(")");
return sb.toString();
}
}

View File

@ -31,6 +31,26 @@
<version>1.7.0-pdok2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>

View File

@ -14,7 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author my
* @date 2023-04-20
*/
public class CropsComprehensiveData extends BaseEntity
public class CropsComprehensiveData
{
private static final long serialVersionUID = 1L;
@ -22,83 +22,65 @@ public class CropsComprehensiveData extends BaseEntity
private Long id;
/** 镇耕地面积(万亩) */
@Excel(name = "镇耕地面积(万亩)")
private Float cultivatedArea;
/** 粮食总产(万吨) */
@Excel(name = "粮食总产(万吨)")
private Float foodstuffProduction;
/** 蔬菜种植面积(亩) */
@Excel(name = "蔬菜种植面积(亩)")
private Long vegetablePlantingArea;
/** 蔬菜总产(吨) */
@Excel(name = "蔬菜总产(吨)")
private Long vegetableProduction;
/** 农产品种类 */
@Excel(name = "农产品种类")
private Long type;
/** 农产品种植面积(亩) */
@Excel(name = "农产品种植面积(亩)")
private Long agriculturalPlantingArea;
/** 特色农业总产量(吨) */
@Excel(name = "特色农业总产量(吨)")
private Long agricultureProduction;
/** 特色农业年产值(万元) */
@Excel(name = "特色农业年产值(万元)")
private Long agricultureOutputVaule;
/** 总人口(人) */
@Excel(name = "总人口(人)")
private Long totalPopulation;
/** 占地面积(平方公里) */
@Excel(name = "占地面积(平方公里)")
private Float coverArea;
/** 示范大棚数量(个) */
@Excel(name = "示范大棚数量(个)")
private Long exampleGreenhouse;
/** 村居数量(个) */
@Excel(name = "村居数量(个)")
private Long rusticate;
/** 联合社耕地面积(万亩) */
@Excel(name = "联合社耕地面积(万亩)")
private Float cultivatedAlly;
/** 大棚数量(个) */
@Excel(name = "大棚数量(个)")
private Long greenhouse;
/** 农产品产值(万元) */
@Excel(name = "农产品产值(万元)")
private Long outputValue;
/** 庞家镇矢量边界 */
@Excel(name = "庞家镇矢量边界")
private String vectorBoundary;
/** 庞家镇村庄矢量边界 */
@Excel(name = "庞家镇村庄矢量边界")
private String villageVectorBoundary;
/** 图片 */
private String img;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
public void setId(Long id)

View File

@ -0,0 +1,123 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
/**
* 用户表;
* @author : http://www.chiner.pro
* @date : 2023-5-19
*/
@Entity
@Table(name = "crops_user")
public class CropsUser implements Serializable{
/** id */
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "crops_user_seq_gen")
@SequenceGenerator(name = "crops_user_seq_gen", sequenceName = "crops_user_seq")
private Integer id ;
/** 用户名 */
@NotNull()
private String userName ;
/** 密码 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@NotBlank(message = "密码不能为空")
private String password ;
/** 联系方式 */
@Pattern(regexp = "1[3457][0-9]{9}",message = "请输入正确的手机号")
@NotBlank(message = "手机号不能为空")
private String phone ;
/** 角色 */
private String role ;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date creatTime ;
/** 备注 */
private String remark ;
/** 帐号状态0正常 1停用 */
private Integer status ;
/** 删除标志0存在 1删除 */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer delFlag ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 用户名 */
public String getUserName(){
return this.userName;
}
/** 用户名 */
public void setUserName(String userName){
this.userName=userName;
}
/** 密码 */
public String getPassword(){
return this.password;
}
/** 密码 */
public void setPassword(String password){
this.password=password;
}
/** 联系方式 */
public String getPhone(){
return this.phone;
}
/** 联系方式 */
public void setPhone(String phone){
this.phone=phone;
}
/** 角色 */
public String getRole(){
return this.role;
}
/** 角色 */
public void setRole(String role){
this.role=role;
}
/** 创建时间 */
public Date getCreatTime(){
return this.creatTime;
}
/** 创建时间 */
public void setCreatTime(Date creatTime){
this.creatTime=creatTime;
}
/** 备注 */
public String getRemark(){
return this.remark;
}
/** 备注 */
public void setRemark(String remark){
this.remark=remark;
}
/** 帐号状态0正常 1停用 */
public Integer getStatus(){
return this.status;
}
/** 帐号状态0正常 1停用 */
public void setStatus(Integer status){
this.status=status;
}
/** 删除标志0存在 1删除 */
public Integer getDelFlag(){
return this.delFlag;
}
/** 删除标志0存在 1删除 */
public void setDelFlag(Integer delFlag){
this.delFlag=delFlag;
}
}

View File

@ -0,0 +1,113 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 数据采集表;
* @author : http://www.chiner.pro
* @date : 2023-5-23
*/
public class DataAcquisition{
/** id */
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer id ;
/** 影像数据条数 */
private Integer imageData ;
/** 影像数据总量 */
private Float imageDataTotal ;
/** 无人机数据条数 */
private Integer droneData ;
/** 无人机数据总量 */
private Float droneDataTotal ;
/** 传感器数据条数 */
private Integer sensorData ;
/** 传感器数据总量 */
private Float sensorDataTotal ;
/** 时间 */
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//接收时间类型
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")//返回时间类型
private Date time ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 影像数据条数 */
public Integer getImageData(){
return this.imageData;
}
/** 影像数据条数 */
public void setImageData(Integer imageData){
this.imageData=imageData;
}
/** 影像数据总量 */
public Float getImageDataTotal(){
return this.imageDataTotal;
}
/** 影像数据总量 */
public void setImageDataTotal(Float imageDataTotal){
this.imageDataTotal=imageDataTotal;
}
/** 无人机数据条数 */
public Integer getDroneData(){
return this.droneData;
}
/** 无人机数据条数 */
public void setDroneData(Integer droneData){
this.droneData=droneData;
}
/** 无人机数据总量 */
public Float getDroneDataTotal(){
return this.droneDataTotal;
}
/** 无人机数据总量 */
public void setDroneDataTotal(Float droneDataTotal){
this.droneDataTotal=droneDataTotal;
}
/** 传感器数据条数 */
public Integer getSensorData(){
return this.sensorData;
}
/** 传感器数据条数 */
public void setSensorData(Integer sensorData){
this.sensorData=sensorData;
}
/** 传感器数据总量 */
public Float getSensorDataTotal(){
return this.sensorDataTotal;
}
/** 传感器数据总量 */
public void setSensorDataTotal(Float sensorDataTotal){
this.sensorDataTotal=sensorDataTotal;
}
/** 时间 */
public Date getTime(){
return this.time;
}
/** 时间 */
public void setTime(Date time){
this.time=time;
}
@Override
public String toString() {
return "DataAcquisition{" +
"id=" + id +
", imageData=" + imageData +
", imageDataTotal='" + imageDataTotal + '\'' +
", droneData=" + droneData +
", droneDataTotal='" + droneDataTotal + '\'' +
", sensorData=" + sensorData +
", sensorDataTotal='" + sensorDataTotal + '\'' +
", time=" + time +
'}';
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -85,7 +86,8 @@ public class DeviceSense {
private Integer BeiYong2 ;
/** 上报时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//接收时间类型
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//返回时间类型
private Date time ;
public Integer getId() {

View File

@ -0,0 +1,130 @@
package com.ruoyi.crops.domain;
/**
* 农机设备信息表;
* @author : http://www.chiner.pro
* @date : 2023-6-6
*/
public class FarmMachinery{
/** id */
private Integer id ;
/** 农机所属省 */
private String province ;
/** 农机所属市 */
private String city ;
/** 农机所属县 */
private String county ;
/** 农机所属乡镇 */
private String town ;
/** 终端编号 */
private String vmeid ;
/** 农机编号 */
private String vehicleno ;
/** 农机类型 */
private String vehicletype ;
/** 农机型号 */
private String vehiclenum ;
/** 车主姓名 */
private String ownername ;
/** 车主电话 */
private String ownertel ;
/** 归属合作社 */
private String belongcorp ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 农机所属省 */
public String getProvince(){
return this.province;
}
/** 农机所属省 */
public void setProvince(String province){
this.province=province;
}
/** 农机所属市 */
public String getCity(){
return this.city;
}
/** 农机所属市 */
public void setCity(String city){
this.city=city;
}
/** 农机所属县 */
public String getCounty(){
return this.county;
}
/** 农机所属县 */
public void setCounty(String county){
this.county=county;
}
/** 农机所属乡镇 */
public String getTown(){
return this.town;
}
/** 农机所属乡镇 */
public void setTown(String town){
this.town=town;
}
/** 终端编号 */
public String getVmeid(){
return this.vmeid;
}
/** 终端编号 */
public void setVmeid(String vmeid){
this.vmeid=vmeid;
}
/** 农机编号 */
public String getVehicleno(){
return this.vehicleno;
}
/** 农机编号 */
public void setVehicleno(String vehicleno){
this.vehicleno=vehicleno;
}
/** 农机类型 */
public String getVehicletype(){
return this.vehicletype;
}
/** 农机类型 */
public void setVehicletype(String vehicletype){
this.vehicletype=vehicletype;
}
/** 农机型号 */
public String getVehiclenum(){
return this.vehiclenum;
}
/** 农机型号 */
public void setVehiclenum(String vehiclenum){
this.vehiclenum=vehiclenum;
}
/** 车主姓名 */
public String getOwnername(){
return this.ownername;
}
/** 车主姓名 */
public void setOwnername(String ownername){
this.ownername=ownername;
}
/** 车主电话 */
public String getOwnertel(){
return this.ownertel;
}
/** 车主电话 */
public void setOwnertel(String ownertel){
this.ownertel=ownertel;
}
/** 归属合作社 */
public String getBelongcorp(){
return this.belongcorp;
}
/** 归属合作社 */
public void setBelongcorp(String belongcorp){
this.belongcorp=belongcorp;
}
}

View File

@ -0,0 +1,75 @@
package com.ruoyi.crops.domain;
public class FarmStatus {
/**
* 农机总量
*/
private int total;
/**
* 在线机器数量
*/
private int online;
/**
* 离线机器数量
*/
private int offline;
/**
* 作业机器数量
*/
private int working;
/**
* 未作业机器数量
*/
private int unwork;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getOnline() {
return online;
}
public void setOnline(int online) {
this.online = online;
}
public int getOffline() {
return offline;
}
public void setOffline(int offline) {
this.offline = offline;
}
public int getWorking() {
return working;
}
public void setWorking(int working) {
this.working = working;
}
public int getUnwork() {
return unwork;
}
public void setUnwork(int unwork) {
this.unwork = unwork;
}
@Override
public String toString() {
return "FarmStatus{" +
"total=" + total +
", online=" + online +
", offline=" + offline +
", working=" + working +
", unwork=" + unwork +
'}';
}
}

View File

@ -0,0 +1,81 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.persistence.*;
import java.util.Date;
/**
* 接口数据量统计;
* @author : http://www.chiner.pro
* @date : 2023-5-24
*/
@Table(name="interface_statistics")
public class InterfaceStatistics{
/** id */
@Id
@GeneratedValue
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer id ;
/** 访问次数 */
private Integer visits ;
/** 访问用户量 */
private Integer accessingUsers ;
/** 交换数据量 */
private Integer dataEntries ;
/** 时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date time ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 访问次数 */
public Integer getVisits(){
return this.visits;
}
/** 访问次数 */
public void setVisits(Integer visits){
this.visits=visits;
}
/** 访问用户量 */
public Integer getAccessingUsers(){
return this.accessingUsers;
}
/** 访问用户量 */
public void setAccessingUsers(Integer accessingUsers){
this.accessingUsers=accessingUsers;
}
/** 交换数据量 */
public Integer getDataEntries(){
return this.dataEntries;
}
/** 交换数据量 */
public void setDataEntries(Integer dataEntries){
this.dataEntries=dataEntries;
}
/** 时间 */
public Date getTime(){
return this.time;
}
/** 时间 */
public void setTime(Date time){
this.time=time;
}
@Override
public String toString() {
return "InterfaceStatistics{" +
"id=" + id +
", visits=" + visits +
", accessingUsers=" + accessingUsers +
", dataEntries=" + dataEntries +
", time=" + time +
'}';
}
}

View File

@ -1,70 +1,378 @@
package com.ruoyi.crops.domain;
/**
* 水肥一体机参数;
* 水肥一体机状态表;
* @author : http://www.chiner.pro
* @date : 2023-4-27
* @date : 2023-5-18
*/
public class MachineParameter{
/** id */
private String id ;
/** 大棚名称 */
private String greenhouseName ;
/** 压力 */
private Double pressure ;
/** 流量 */
private Double flow ;
// /** id */
// private Integer id ;
/** 阀门1 */
private String Valve1 ;
/** 阀门2 */
private String valve2 ;
/** 阀门3 */
private String Valve3 ;
/** 阀门4 */
private String Valve4 ;
/** 阀门5 */
private String Valve5 ;
/** 阀门6 */
private String Valve6 ;
/** 阀门7 */
private String Valve7 ;
/** 阀门8 */
private String Valve8 ;
/** 阀门9 */
private String Valve9 ;
/** 阀门10 */
private String Valve10 ;
/** 阀门11 */
private String Valve11 ;
/** 阀门12 */
private String Valve12 ;
/** 阀门13 */
private String Valve13 ;
/** 阀门14 */
private String Valve14 ;
/** 阀门15 */
private String Valve15 ;
/** 阀门16 */
private String Valve16 ;
/** 阀门17 */
private String Valve17 ;
/** 阀门18 */
private String Valve18 ;
/** 阀门19 */
private String Valve19 ;
/** 阀门20 */
private String Valve20 ;
/** 进水泵 */
private String InflowPump ;
/** 出料泵 */
private String FeedingPump ;
/** 搅拌1 */
private String JiaoBan1 ;
/** 搅拌2 */
private String JiaoBan2 ;
/** 搅拌3 */
private String JiaoBan3 ;
/** 搅拌4 */
private String JiaoBan4 ;
/** pH值 */
private Double pH ;
/** 电导率 */
private Double conductivity ;
private Double Conduct ;
/** 进水流量 */
private Double Inflow ;
/** 进水压力 */
private Double InflowPressure ;
/** 功率模式 */
private String PowerMode ;
/** 控制模式 */
private String ControlMode ;
public String getId() {
return id;
/** id */
// public Integer getId(){
// return this.id;
// }
/** id */
// public void setId(Integer id){
// this.id=id;
// }
public String getValve1() {
return Valve1;
}
public void setId(String id) {
this.id = id;
public void setValve1(String valve1) {
Valve1 = valve1;
}
public String getGreenhouseName() {
return greenhouseName;
public String getvalve2() {
return valve2;
}
public void setGreenhouseName(String greenhouseName) {
this.greenhouseName = greenhouseName;
public void setvalve2(String valve2) {
this.valve2 = valve2;
}
public Double getPressure() {
return pressure;
public String getValve3() {
return Valve3;
}
public void setPressure(Double pressure) {
this.pressure = pressure;
public void setValve3(String valve3) {
Valve3 = valve3;
}
public Double getFlow() {
return flow;
public String getValve4() {
return Valve4;
}
public void setFlow(Double flow) {
this.flow = flow;
public void setValve4(String valve4) {
Valve4 = valve4;
}
public Double getConductivity() {
return conductivity;
public String getValve5() {
return Valve5;
}
public void setConductivity(Double conductivity) {
this.conductivity = conductivity;
public void setValve5(String valve5) {
Valve5 = valve5;
}
public String getValve6() {
return Valve6;
}
public void setValve6(String valve6) {
Valve6 = valve6;
}
public String getValve7() {
return Valve7;
}
public void setValve7(String valve7) {
Valve7 = valve7;
}
public String getValve8() {
return Valve8;
}
public void setValve8(String valve8) {
Valve8 = valve8;
}
public String getValve9() {
return Valve9;
}
public void setValve9(String valve9) {
Valve9 = valve9;
}
public String getValve10() {
return Valve10;
}
public void setValve10(String valve10) {
Valve10 = valve10;
}
public String getValve11() {
return Valve11;
}
public void setValve11(String valve11) {
Valve11 = valve11;
}
public String getValve12() {
return Valve12;
}
public void setValve12(String valve12) {
Valve12 = valve12;
}
public String getValve13() {
return Valve13;
}
public void setValve13(String valve13) {
Valve13 = valve13;
}
public String getValve14() {
return Valve14;
}
public void setValve14(String valve14) {
Valve14 = valve14;
}
public String getValve15() {
return Valve15;
}
public void setValve15(String valve15) {
Valve15 = valve15;
}
public String getValve16() {
return Valve16;
}
public void setValve16(String valve16) {
Valve16 = valve16;
}
public String getValve17() {
return Valve17;
}
public void setValve17(String valve17) {
Valve17 = valve17;
}
public String getValve18() {
return Valve18;
}
public void setValve18(String valve18) {
Valve18 = valve18;
}
public String getValve19() {
return Valve19;
}
public void setValve19(String valve19) {
Valve19 = valve19;
}
public String getValve20() {
return Valve20;
}
public void setValve20(String valve20) {
Valve20 = valve20;
}
public String getInflowPump() {
return InflowPump;
}
public void setInflowPump(String inflowPump) {
InflowPump = inflowPump;
}
public String getFeedingPump() {
return FeedingPump;
}
public void setFeedingPump(String feedingPump) {
FeedingPump = feedingPump;
}
public String getJiaoBan1() {
return JiaoBan1;
}
public void setJiaoBan1(String jiaoBan1) {
JiaoBan1 = jiaoBan1;
}
public String getJiaoBan2() {
return JiaoBan2;
}
public void setJiaoBan2(String jiaoBan2) {
JiaoBan2 = jiaoBan2;
}
public String getJiaoBan3() {
return JiaoBan3;
}
public void setJiaoBan3(String jiaoBan3) {
JiaoBan3 = jiaoBan3;
}
public String getJiaoBan4() {
return JiaoBan4;
}
public void setJiaoBan4(String jiaoBan4) {
JiaoBan4 = jiaoBan4;
}
public Double getpH() {
return pH;
}
public void setpH(Double pH) {
this.pH = pH;
}
public Double getConduct() {
return Conduct;
}
public void setConduct(Double conduct) {
Conduct = conduct;
}
public Double getInflow() {
return Inflow;
}
public void setInflow(Double inflow) {
Inflow = inflow;
}
public Double getInflowPressure() {
return InflowPressure;
}
public void setInflowPressure(Double inflowPressure) {
InflowPressure = inflowPressure;
}
public String getPowerMode() {
return PowerMode;
}
public void setPowerMode(String powerMode) {
PowerMode = powerMode;
}
public String getControlMode() {
return ControlMode;
}
public void setControlMode(String controlMode) {
ControlMode = controlMode;
}
@Override
public String toString() {
return "MachineParameter{" +
"id='" + id + '\'' +
", greenhouseName='" + greenhouseName + '\'' +
", pressure=" + pressure +
", flow=" + flow +
", conductivity=" + conductivity +
"Valve1='" + Valve1 + '\'' +
", valve2='" + valve2 + '\'' +
", Valve3='" + Valve3 + '\'' +
", Valve4='" + Valve4 + '\'' +
", Valve5='" + Valve5 + '\'' +
", Valve6='" + Valve6 + '\'' +
", Valve7='" + Valve7 + '\'' +
", Valve8='" + Valve8 + '\'' +
", Valve9='" + Valve9 + '\'' +
", Valve10='" + Valve10 + '\'' +
", Valve11='" + Valve11 + '\'' +
", Valve12='" + Valve12 + '\'' +
", Valve13='" + Valve13 + '\'' +
", Valve14='" + Valve14 + '\'' +
", Valve15='" + Valve15 + '\'' +
", Valve16='" + Valve16 + '\'' +
", Valve17='" + Valve17 + '\'' +
", Valve18='" + Valve18 + '\'' +
", Valve19='" + Valve19 + '\'' +
", Valve20='" + Valve20 + '\'' +
", InflowPump='" + InflowPump + '\'' +
", FeedingPump='" + FeedingPump + '\'' +
", JiaoBan1='" + JiaoBan1 + '\'' +
", JiaoBan2='" + JiaoBan2 + '\'' +
", JiaoBan3='" + JiaoBan3 + '\'' +
", JiaoBan4='" + JiaoBan4 + '\'' +
", pH=" + pH +
", Conduct=" + Conduct +
", Inflow=" + Inflow +
", InflowPressure=" + InflowPressure +
", PowerMode='" + PowerMode + '\'' +
", ControlMode='" + ControlMode + '\'' +
'}';
}
}

View File

@ -0,0 +1,188 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 农机作业任务表;
* @author : http://www.chiner.pro
* @date : 2023-6-7
*/
public class MachineryJobData {
/** id */
private Integer id ;
/** 归属省 */
private String province ;
/** 归属地市 */
private String city ;
/** 归属区县 */
private String county ;
/** 作业日期 */
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern="yyyy-MM-dd")
private Date jobday ;
/** 作业类型码 */
private Integer jobtype ;
/** 农机编号 */
private String vehicleno ;
/** 终端编号 */
private String vmeid ;
/** 作业地块面积(单位:亩) */
private Double plotarea ;
/** 作业面积(单位:亩) */
private Double jobarea ;
/** 达标比() */
private Double qualratio ;
/** 达标面积(单位:亩) */
private Double qualarea ;
/** 作业幅宽(单位:米) */
private Double jobwidth ;
/** 面积(单位:亩) */
private Double area ;
/** 时长(单位:小时) */
private Double workhours ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 归属省 */
public String getProvince(){
return this.province;
}
/** 归属省 */
public void setProvince(String province){
this.province=province;
}
/** 归属地市 */
public String getCity(){
return this.city;
}
/** 归属地市 */
public void setCity(String city){
this.city=city;
}
/** 归属区县 */
public String getCounty(){
return this.county;
}
/** 归属区县 */
public void setCounty(String county){
this.county=county;
}
/** 作业日期 */
public Date getJobday(){
return this.jobday;
}
/** 作业日期 */
public void setJobday(Date jobday){
this.jobday=jobday;
}
/** 作业类型码 */
public Integer getJobtype(){
return this.jobtype;
}
/** 作业类型码 */
public void setJobtype(Integer jobtype){
this.jobtype=jobtype;
}
/** 农机编号 */
public String getVehicleno(){
return this.vehicleno;
}
/** 农机编号 */
public void setVehicleno(String vehicleno){
this.vehicleno=vehicleno;
}
/** 终端编号 */
public String getVmeid(){
return this.vmeid;
}
/** 终端编号 */
public void setVmeid(String vmeid){
this.vmeid=vmeid;
}
/** 作业地块面积(单位:亩) */
public Double getPlotarea(){
return this.plotarea;
}
/** 作业地块面积(单位:亩) */
public void setPlotarea(Double plotarea){
this.plotarea=plotarea;
}
/** 作业面积(单位:亩) */
public Double getJobarea(){
return this.jobarea;
}
/** 作业面积(单位:亩) */
public void setJobarea(Double jobarea){
this.jobarea=jobarea;
}
/** 达标比() */
public Double getQualratio(){
return this.qualratio;
}
/** 达标比() */
public void setQualratio(Double qualratio){
this.qualratio=qualratio;
}
/** 达标面积(单位:亩) */
public Double getQualarea(){
return this.qualarea;
}
/** 达标面积(单位:亩) */
public void setQualarea(Double qualarea){
this.qualarea=qualarea;
}
/** 作业幅宽(单位:米) */
public Double getJobwidth(){
return this.jobwidth;
}
/** 作业幅宽(单位:米) */
public void setJobwidth(Double jobwidth){
this.jobwidth=jobwidth;
}
public Double getArea() {
return area;
}
public void setArea(Double area) {
this.area = area;
}
public Double getWorkhours() {
return workhours;
}
public void setWorkhours(Double workhours) {
this.workhours = workhours;
}
@Override
public String toString() {
return "MachineryJobData{" +
"id=" + id +
", province='" + province + '\'' +
", city='" + city + '\'' +
", county='" + county + '\'' +
", jobday=" + jobday +
", jobtype=" + jobtype +
", vehicleno='" + vehicleno + '\'' +
", vmeid='" + vmeid + '\'' +
", plotarea=" + plotarea +
", jobarea=" + jobarea +
", qualratio=" + qualratio +
", qualarea=" + qualarea +
", jobwidth=" + jobwidth +
", area=" + area +
", workhours=" + workhours +
'}';
}
}

View File

@ -0,0 +1,92 @@
package com.ruoyi.crops.domain;
import java.util.Date;
/**
* 农机位置表;
* @author : http://www.chiner.pro
* @date : 2023-6-6
*/
public class MachineryPosition {
/** id */
private Integer id ;
/** 农机编号 */
private String vehicleno ;
/** 时间(北京时间) */
private Date postime ;
/** 纬度值(WGS84 坐标系) */
private Double lat ;
/** 经度值(WGS84 坐标系) */
private Double lng ;
/** 速度km/h */
private Double speed ;
/** 作业类型代码 */
private Integer jobtype ;
/** 作业深度cm */
private Double depth ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 农机编号 */
public String getVehicleno(){
return this.vehicleno;
}
/** 农机编号 */
public void setVehicleno(String vehicleno){
this.vehicleno=vehicleno;
}
/** 时间(北京时间) */
public Date getPostime(){
return this.postime;
}
/** 时间(北京时间) */
public void setPostime(Date postime){
this.postime=postime;
}
/** 纬度值(WGS84 坐标系) */
public Double getLat(){
return this.lat;
}
/** 纬度值(WGS84 坐标系) */
public void setLat(Double lat){
this.lat=lat;
}
/** 经度值(WGS84 坐标系) */
public Double getLng(){
return this.lng;
}
/** 经度值(WGS84 坐标系) */
public void setLng(Double lng){
this.lng=lng;
}
/** 速度km/h */
public Double getSpeed(){
return this.speed;
}
/** 速度km/h */
public void setSpeed(Double speed){
this.speed=speed;
}
/** 作业类型代码 */
public Integer getJobtype(){
return this.jobtype;
}
/** 作业类型代码 */
public void setJobtype(Integer jobtype){
this.jobtype=jobtype;
}
/** 作业深度cm */
public Double getDepth(){
return this.depth;
}
/** 作业深度cm */
public void setDepth(Double depth){
this.depth=depth;
}
}

View File

@ -17,8 +17,6 @@ public class OperationRecords {
private Date updateTime ;
/** 操作内容 */
private String operationContent ;
/** 更新人 */
private String updateBy ;
public String getId() {
return id;
@ -44,21 +42,12 @@ public class OperationRecords {
this.operationContent = operationContent;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
@Override
public String toString() {
return "OperationRecords{" +
"id='" + id + '\'' +
", updateTime=" + updateTime +
", operationContent='" + operationContent + '\'' +
", updateBy='" + updateBy + '\'' +
'}';
}
}

View File

@ -0,0 +1,65 @@
package com.ruoyi.crops.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 农机信息预警表;
* @author : http://www.chiner.pro
* @date : 2023-6-15
*/
public class WarningFarm{
/** id */
private Integer id ;
/** 农机名称 */
private String vehicleno ;
/** 车主姓名 */
private String ownername ;
/** 异常类型 */
private String warningInfo ;
/** 预警时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date time ;
/** id */
public Integer getId(){
return this.id;
}
/** id */
public void setId(Integer id){
this.id=id;
}
/** 农机名称 */
public String getVehicleno(){
return this.vehicleno;
}
/** 农机名称 */
public void setVehicleno(String vehicleno){
this.vehicleno=vehicleno;
}
/** 车主姓名 */
public String getOwnername(){
return this.ownername;
}
/** 车主姓名 */
public void setOwnername(String ownername){
this.ownername=ownername;
}
/** 异常类型 */
public String getWarningInfo(){
return this.warningInfo;
}
/** 异常类型 */
public void setWarningInfo(String warningInfo){
this.warningInfo=warningInfo;
}
/** 预警时间 */
public Date getTime(){
return this.time;
}
/** 预警时间 */
public void setTime(Date time){
this.time=time;
}
}

View File

@ -0,0 +1,154 @@
package com.ruoyi.crops.domain;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 气象预报
* @author tajochen
*/
@Entity
@Table(name="weather_prediction")
public class WeatherPredictionEntity implements Serializable {
/**
* 指定主键建立自增序列主键值取自序列
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "weather_prediction_seq_gen")
@SequenceGenerator(name = "weather_prediction_seq_gen", sequenceName = "weather_prediction_seq")
private Integer id;
// 气象时间
private LocalDateTime weatherTime;
// 气象名称
@Column(length = 16, columnDefinition = "varchar(16)")
private String weatherName;
// 气温
@Column(length = 16, columnDefinition = "varchar(16)")
private String airTemperature;
// 降水量
@Column(length = 16, columnDefinition = "varchar(16)")
private String precipitation;
// 风速
@Column(length = 16, columnDefinition = "varchar(16)")
private String windSpeed;
// 风向
@Column(length = 16, columnDefinition = "varchar(16)")
private String windDirection;
// 气压
@Column(length = 16, columnDefinition = "varchar(16)")
private String atmosphericPressure;
// 湿度
@Column(length = 16, columnDefinition = "varchar(16)")
private String humidity;
// 云量
@Column(length = 16, columnDefinition = "varchar(16)")
private String cloudCover;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public LocalDateTime getWeatherTime() {
return weatherTime;
}
public void setWeatherTime(LocalDateTime weatherTime) {
this.weatherTime = weatherTime;
}
public String getWeatherName() {
return weatherName;
}
public void setWeatherName(String weatherName) {
this.weatherName = weatherName;
}
public String getAirTemperature() {
return airTemperature;
}
public void setAirTemperature(String airTemperature) {
this.airTemperature = airTemperature;
}
public String getPrecipitation() {
return precipitation;
}
public void setPrecipitation(String precipitation) {
this.precipitation = precipitation;
}
public String getWindSpeed() {
return windSpeed;
}
public void setWindSpeed(String windSpeed) {
this.windSpeed = windSpeed;
}
public String getWindDirection() {
return windDirection;
}
public void setWindDirection(String windDirection) {
this.windDirection = windDirection;
}
public String getAtmosphericPressure() {
return atmosphericPressure;
}
public void setAtmosphericPressure(String atmosphericPressure) {
this.atmosphericPressure = atmosphericPressure;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getCloudCover() {
return cloudCover;
}
public void setCloudCover(String cloudCover) {
this.cloudCover = cloudCover;
}
@Override
public String toString() {
return "WeatherPredictionEntity{" +
"id=" + id +
", weatherTime=" + weatherTime +
", weatherName='" + weatherName + '\'' +
", airTemperature='" + airTemperature + '\'' +
", precipitation='" + precipitation + '\'' +
", windSpeed='" + windSpeed + '\'' +
", windDirection='" + windDirection + '\'' +
", atmosphericPressure='" + atmosphericPressure + '\'' +
", humidity='" + humidity + '\'' +
", cloudCover='" + cloudCover + '\'' +
'}';
}
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.crops.domain.gsonBean;
import com.ruoyi.crops.domain.FarmMachinery;
import java.util.List;
public class GsonFarmMachineryBean {
public int status;
public List<FarmMachinery> vehicle;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<FarmMachinery> getVehicle() {
return vehicle;
}
public void setVehicle(List<FarmMachinery> vehicle) {
this.vehicle = vehicle;
}
}

View File

@ -0,0 +1,353 @@
package com.ruoyi.crops.domain.gsonBean;
public class GsonMachineParameterBean {
public GsonMachineParameterBean() {
}
public String msg;
public MachineParameter data;
public Integer code;
public Boolean result;
public String time;
public class MachineParameter{
/** 阀门1 */
public property Valve1 ;
/** 阀门2 */
public property valve2 ;
/** 阀门3 */
public property Valve3 ;
/** 阀门4 */
public property Valve4 ;
/** 阀门5 */
public property Valve5 ;
/** 阀门6 */
public property Valve6 ;
/** 阀门7 */
public property Valve7 ;
/** 阀门8 */
public property Valve8 ;
/** 阀门9 */
public property Valve9 ;
/** 阀门10 */
public property Valve10 ;
/** 阀门11 */
public property Valve11 ;
/** 阀门12 */
public property Valve12 ;
/** 阀门13 */
public property Valve13 ;
/** 阀门14 */
public property Valve14 ;
/** 阀门15 */
public property Valve15 ;
/** 阀门16 */
public property Valve16 ;
/** 阀门17 */
public property Valve17 ;
/** 阀门18 */
public property Valve18 ;
/** 阀门19 */
public property Valve19 ;
/** 阀门20 */
public property Valve20 ;
/** 进水泵 */
public property InflowPump ;
/** 出料泵 */
public property FeedingPump ;
/** 搅拌1 */
public property JiaoBan1 ;
/** 搅拌2 */
public property JiaoBan2 ;
/** 搅拌3 */
public property JiaoBan3 ;
/** 搅拌4 */
public property JiaoBan4 ;
/** pH值 */
public property pH ;
/** 电导率 */
public property Conduct ;
/** 进水流量 */
public property Inflow ;
/** 进水压力 */
public property InflowPressure ;
/** 功率模式 */
public property PowerMode ;
/** 控制模式 */
public property ControlMode ;
public property getValve1() {
return Valve1;
}
public void setValve1(property valve1) {
Valve1 = valve1;
}
public property getvalve2() {
return valve2;
}
public void setvalve2(property valve2) {
this.valve2 = valve2;
}
public property getValve3() {
return Valve3;
}
public void setValve3(property valve3) {
Valve3 = valve3;
}
public property getValve4() {
return Valve4;
}
public void setValve4(property valve4) {
Valve4 = valve4;
}
public property getValve5() {
return Valve5;
}
public void setValve5(property valve5) {
Valve5 = valve5;
}
public property getValve6() {
return Valve6;
}
public void setValve6(property valve6) {
Valve6 = valve6;
}
public property getValve7() {
return Valve7;
}
public void setValve7(property valve7) {
Valve7 = valve7;
}
public property getValve8() {
return Valve8;
}
public void setValve8(property valve8) {
Valve8 = valve8;
}
public property getValve9() {
return Valve9;
}
public void setValve9(property valve9) {
Valve9 = valve9;
}
public property getValve10() {
return Valve10;
}
public void setValve10(property valve10) {
Valve10 = valve10;
}
public property getValve11() {
return Valve11;
}
public void setValve11(property valve11) {
Valve11 = valve11;
}
public property getValve12() {
return Valve12;
}
public void setValve12(property valve12) {
Valve12 = valve12;
}
public property getValve13() {
return Valve13;
}
public void setValve13(property valve13) {
Valve13 = valve13;
}
public property getValve14() {
return Valve14;
}
public void setValve14(property valve14) {
Valve14 = valve14;
}
public property getValve15() {
return Valve15;
}
public void setValve15(property valve15) {
Valve15 = valve15;
}
public property getValve16() {
return Valve16;
}
public void setValve16(property valve16) {
Valve16 = valve16;
}
public property getValve17() {
return Valve17;
}
public void setValve17(property valve17) {
Valve17 = valve17;
}
public property getValve18() {
return Valve18;
}
public void setValve18(property valve18) {
Valve18 = valve18;
}
public property getValve19() {
return Valve19;
}
public void setValve19(property valve19) {
Valve19 = valve19;
}
public property getValve20() {
return Valve20;
}
public void setValve20(property valve20) {
Valve20 = valve20;
}
public property getInflowPump() {
return InflowPump;
}
public void setInflowPump(property inflowPump) {
InflowPump = inflowPump;
}
public property getFeedingPump() {
return FeedingPump;
}
public void setFeedingPump(property feedingPump) {
FeedingPump = feedingPump;
}
public property getJiaoBan1() {
return JiaoBan1;
}
public void setJiaoBan1(property jiaoBan1) {
JiaoBan1 = jiaoBan1;
}
public property getJiaoBan2() {
return JiaoBan2;
}
public void setJiaoBan2(property jiaoBan2) {
JiaoBan2 = jiaoBan2;
}
public property getJiaoBan3() {
return JiaoBan3;
}
public void setJiaoBan3(property jiaoBan3) {
JiaoBan3 = jiaoBan3;
}
public property getJiaoBan4() {
return JiaoBan4;
}
public void setJiaoBan4(property jiaoBan4) {
JiaoBan4 = jiaoBan4;
}
public property getpH() {
return pH;
}
public void setpH(property pH) {
this.pH = pH;
}
public property getConduct() {
return Conduct;
}
public void setConduct(property conduct) {
Conduct = conduct;
}
public property getInflow() {
return Inflow;
}
public void setInflow(property inflow) {
Inflow = inflow;
}
public property getInflowPressure() {
return InflowPressure;
}
public void setInflowPressure(property inflowPressure) {
InflowPressure = inflowPressure;
}
public property getPowerMode() {
return PowerMode;
}
public void setPowerMode(property powerMode) {
PowerMode = powerMode;
}
public property getControlMode() {
return ControlMode;
}
public void setControlMode(property controlMode) {
ControlMode = controlMode;
}
}
public class property{
public String propertyName;
public String dataType;
public String propertyNameShow;
public String propertyValve;
@Override
public String toString() {
return "property{" +
"propertyName='" + propertyName + '\'' +
", dataType='" + dataType + '\'' +
", propertyNameShow='" + propertyNameShow + '\'' +
", propertyValve='" + propertyValve + '\'' +
'}';
}
}
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.crops.domain.gsonBean;
import com.ruoyi.crops.domain.MachineryPosition;
import java.util.List;
public class GsonMachineryPositionBean {
public int status;
public List<MachineryPosition> position;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<MachineryPosition> getPosition() {
return position;
}
public void setPosition(List<MachineryPosition> position) {
this.position = position;
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.crops.domain.gsonBean;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.crops.domain.Meteorological;
import java.util.ArrayList;
import java.util.Date;
@ -10,26 +11,4 @@ public class GsonMeteorologicalBean {
public ArrayList<Meteorological> result;
public String error_code;
public class Meteorological{
/** 预警消息ID */
public String id ;
/** 预警消息标题 */
public String title ;
/** 预警等级, 橙色/红色/蓝色/黄色/未知 */
public String level ;
/** 预警类型 */
public String type ;
/** 预警发布时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date time ;
/** 省份, 可能为空 */
public String province ;
/** 城市, 可能为空 */
public String city ;
/** 区域, 可能为空 */
public String district ;
/** 预警详细内容 */
public String content ;
}
}

View File

@ -0,0 +1,119 @@
package com.ruoyi.crops.domain.gsonBean;
import java.util.Date;
import java.util.List;
public class GsonVehicleTrackBean {
private int status;
private String vehicleno;
private List<postions> postions;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getVehicleno() {
return vehicleno;
}
public void setVehicleno(String vehicleno) {
this.vehicleno = vehicleno;
}
public List<GsonVehicleTrackBean.postions> getPostions() {
return postions;
}
public void setPostions(List<GsonVehicleTrackBean.postions> postions) {
this.postions = postions;
}
public class postions{
private Date pttime;
private float lat;
private float lng;
private float course;
private int haspic;
private String imgurl;
private int iswork;
private double jobwidth;
private float depth;
public Date getPttime() {
return pttime;
}
public void setPttime(Date pttime) {
this.pttime = pttime;
}
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLng() {
return lng;
}
public void setLng(float lng) {
this.lng = lng;
}
public float getCourse() {
return course;
}
public void setCourse(float course) {
this.course = course;
}
public int getHaspic() {
return haspic;
}
public void setHaspic(int haspic) {
this.haspic = haspic;
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl;
}
public int getIswork() {
return iswork;
}
public void setIswork(int iswork) {
this.iswork = iswork;
}
public double getJobwidth() {
return jobwidth;
}
public void setJobwidth(double jobwidth) {
this.jobwidth = jobwidth;
}
public float getDepth() {
return depth;
}
public void setDepth(float depth) {
this.depth = depth;
}
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.crops.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -20,7 +21,8 @@ public class DeviceSenseVo {
/** 二氧化碳浓度[ppm] */
private Double AvgCO2 ;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//接收时间类型
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//返回时间类型
private Date time ;
public String getDid() {

View File

@ -0,0 +1,44 @@
package com.ruoyi.crops.domain.vo;
public class FarmMachineryVo {
/** id */
private Integer id ;
/** 农机编号 */
private String vehicleno ;
/** 农机类型 */
private String vehicletype ;
/** 车主姓名 */
private String ownername ;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getVehicleno() {
return vehicleno;
}
public void setVehicleno(String vehicleno) {
this.vehicleno = vehicleno;
}
public String getVehicletype() {
return vehicletype;
}
public void setVehicletype(String vehicletype) {
this.vehicletype = vehicletype;
}
public String getOwnername() {
return ownername;
}
public void setOwnername(String ownername) {
this.ownername = ownername;
}
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.crops.domain.vo;
public class InterfaceStatisticsVo {
/** 访问次数 */
private Integer visits ;
/** 访问用户量 */
private Integer accessingUsers ;
/** 交换数据量 */
private Integer dataEntries ;
/** 数据库总量 */
private Float volume;
public Integer getVisits() {
return visits;
}
public void setVisits(Integer visits) {
this.visits = visits;
}
public Integer getAccessingUsers() {
return accessingUsers;
}
public void setAccessingUsers(Integer accessingUsers) {
this.accessingUsers = accessingUsers;
}
public Integer getDataEntries() {
return dataEntries;
}
public void setDataEntries(Integer dataEntries) {
this.dataEntries = dataEntries;
}
public Float getVolume() {
return volume;
}
public void setVolume(Float volume) {
this.volume = volume;
}
@Override
public String toString() {
return "InterfaceStatisticsVo{" +
"visits=" + visits +
", accessingUsers=" + accessingUsers +
", dataEntries=" + dataEntries +
", volume='" + volume + '\'' +
'}';
}
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.domain.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
public class MachineParameterVo {
private Double pH;
private Double Conduct;
private Double Inflow;
private Double InflowPressure;
}

View File

@ -0,0 +1,143 @@
package com.ruoyi.crops.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class MachineryJobDataVo {
/** 作业类型码 */
private String jobtype ;
/** 农机编号 */
@Excel(name = "设备编号")
private String vehicleno ;
/** 农机类型 */
@Excel(name = "设备类型")
private String vehicletype ;
/** 终端编号 */
@Excel(name = "机器码")
private String vmeid ;
/** 作业日期 */
@Excel(name = "作业日期",dateFormat = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern="yyyy-MM-dd")
private Date jobday ;
@Excel(name = "作业面积(亩)")
/** 作业面积(单位:亩) */
private Double jobarea ;
/** 车主姓名 */
@Excel(name = "用户名")
private String ownername ;
/** 车主电话 */
@Excel(name = "联系方式")
private String ownertel ;
/** 面积(单位:亩) */
private Double area ;
/** 时长(单位:小时) */
private Double workhours ;
public String getVehicletype() {
return vehicletype;
}
public void setVehicletype(String vehicletype) {
this.vehicletype = vehicletype;
}
public String getVehicleno() {
return vehicleno;
}
public void setVehicleno(String vehicleno) {
this.vehicleno = vehicleno;
}
public String getVmeid() {
return vmeid;
}
public void setVmeid(String vmeid) {
this.vmeid = vmeid;
}
public Date getJobday() {
return jobday;
}
public void setJobday(Date jobday) {
this.jobday = jobday;
}
public Double getJobarea() {
return jobarea;
}
public void setJobarea(Double jobarea) {
this.jobarea = jobarea;
}
public String getOwnername() {
return ownername;
}
public void setOwnername(String ownername) {
this.ownername = ownername;
}
public String getOwnertel() {
return ownertel;
}
public void setOwnertel(String ownertel) {
this.ownertel = ownertel;
}
public String getJobtype() {
return jobtype;
}
public void setJobtype(String jobtype) {
this.jobtype = jobtype;
}
public Double getArea() {
return area;
}
public void setArea(Double area) {
this.area = area;
}
public Double getWorkhours() {
return workhours;
}
public void setWorkhours(Double workhours) {
this.workhours = workhours;
}
@Override
public String toString() {
return "MachineryJobDataVo{" +
"jobtype='" + jobtype + '\'' +
", vehicleno='" + vehicleno + '\'' +
", vehicletype='" + vehicletype + '\'' +
", vmeid='" + vmeid + '\'' +
", jobday=" + jobday +
", jobarea=" + jobarea +
", ownername='" + ownername + '\'' +
", ownertel='" + ownertel + '\'' +
", area=" + area +
", workhours=" + workhours +
'}';
}
}

View File

@ -0,0 +1,88 @@
package com.ruoyi.crops.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class WeatherPredoctionVo {
private String maxAirTemperature;
private String minAirTemperature;
private String maxHumidity;
private String minHumidity;
private String windSpeed;
private String precipitation;
@DateTimeFormat(pattern = "yyyy-MM-dd")//接收时间类型
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")//返回时间类型
private Date weatherTime;
public String getMaxAirTemperature() {
return maxAirTemperature;
}
public void setMaxAirTemperature(String maxAirTemperature) {
this.maxAirTemperature = maxAirTemperature;
}
public String getMinAirTemperature() {
return minAirTemperature;
}
public void setMinAirTemperature(String minAirTemperature) {
this.minAirTemperature = minAirTemperature;
}
public String getMaxHumidity() {
return maxHumidity;
}
public void setMaxHumidity(String maxHumidity) {
this.maxHumidity = maxHumidity;
}
public String getMinHumidity() {
return minHumidity;
}
public void setMinHumidity(String minHumidity) {
this.minHumidity = minHumidity;
}
public String getWindSpeed() {
return windSpeed;
}
public void setWindSpeed(String windSpeed) {
this.windSpeed = windSpeed;
}
public String getPrecipitation() {
return precipitation;
}
public void setPrecipitation(String precipitation) {
this.precipitation = precipitation;
}
public Date getWeatherTime() {
return weatherTime;
}
public void setWeatherTime(Date weatherTime) {
this.weatherTime = weatherTime;
}
@Override
public String toString() {
return "WeatherPredoctionVo{" +
"maxAirTemperature='" + maxAirTemperature + '\'' +
", minAirTemperature='" + minAirTemperature + '\'' +
", maxHumidity='" + maxHumidity + '\'' +
", minHumidity='" + minHumidity + '\'' +
", windSpeed='" + windSpeed + '\'' +
", precipitation='" + precipitation + '\'' +
", weatherTime=" + weatherTime +
'}';
}
}

View File

@ -7,7 +7,17 @@ import java.util.Date;
import java.util.List;
public interface CropsDroughtMapper {
/**
* 批量新增作物长势数据
* @param cropsDroughtList
* @return
*/
public int insertBatch(@Param("list") List<CropsDrought> cropsDroughtList);
/**
* 根据时间查询作物长势数据
* @param time
* @return
*/
List<CropsDrought> selectByTime(Date time);
}

View File

@ -14,7 +14,17 @@ public interface CropsStructureMapper {
*/
public int insertCropsStructure(CropStructure cropStructure);
/**
* 批量新增作物种植结构
* @param list
* @return
*/
public int insertBatch(@Param("list") List<CropStructure> list);
/**
* 根据时间查询作物种植结构
* @param time
* @return
*/
public List<CropStructure> selectByTime(Date time);
}

View File

@ -0,0 +1,47 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsUser;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CropsUserMapper {
/**
* 获取用户列表
* @return
*/
List<CropsUser> list();
/**
* 新增用户
* @param cropsUser
* @return
*/
int insert(CropsUser cropsUser);
/**
* 删除用户
* @param id
* @return
*/
int delete(Integer id);
/**
* 修改用户
* @param id
* @return
*/
int update(Integer id);
/**
* 根据id查询用户
* @param phone
* @return
*/
CropsUser selectByPhone(String phone);
CropsUser login(CropsUser user);
int selectCountByName(String userName);
}

View File

@ -7,7 +7,17 @@ import java.util.Date;
import java.util.List;
public interface CropsYieldMapper {
/**
* 根据年份查询
* @param year
* @return
*/
public List<CropsYield> selectByYear(Integer year);
/**
* 批量新增
* @param list
* @return
*/
public int insertBatch(@Param("list") List<CropsYield> list);
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.DataAcquisition;
import java.util.List;
public interface DataAcquisitionMapper {
DataAcquisition getData();
int insert(DataAcquisition data);
void analyze();
DataAcquisition getSensorData();
}

View File

@ -15,10 +15,10 @@ public interface DeviceSenseMapper {
List<DeviceSense> selectById(String deviceId);
List<DeviceSense> selectByTime(@Param("startTime") String startTime, @Param("endTime") String endTime);
List<DeviceSense> selectByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<DeviceSenseVo> selecthours(@Param("startTime") String startTime, @Param("endTime") String endTime);
List<DeviceSenseVo> selecthours(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<DeviceSenseVo> selectdays(@Param("startTime") String startTime, @Param("endTime") String endTime);
List<DeviceSenseVo> selectdays(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.FarmMachinery;
import com.ruoyi.crops.domain.vo.FarmMachineryVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface FarmMachineryMapper {
public FarmMachineryVo selectMachineryData(@Param("vehicleno") String vehicleno);
public List<FarmMachineryVo> selectMachineryData();
public int insertBatch(@Param("entities") List<FarmMachinery> farmMachineryList);
}

View File

@ -4,7 +4,7 @@ import com.ruoyi.crops.domain.FertigationSense;
public interface FertigationSenseMapper {
void dedupInsert (FertigationSense fertigationSense);
void dedupInsert(FertigationSense fertigationSense);
int insert(FertigationSense fertigationSense);
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.InterfaceStatistics;
import com.ruoyi.crops.domain.vo.InterfaceStatisticsVo;
import java.util.List;
public interface InterfaceStatisticsMapper {
int insert(InterfaceStatistics interfaceStatistics);
InterfaceStatistics selectByDay();
InterfaceStatisticsVo selectTotal();
}

View File

@ -1,11 +0,0 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.MachineParameter;
import java.util.List;
public interface MachineParameterMapper {
List<MachineParameter> selectByName(String name);
int insert(MachineParameter machineParameter);
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.crops.domain.MachineryJobData;
import com.ruoyi.crops.domain.vo.MachineryJobDataVo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface MachineryJobDataMapper {
int insertBatch(@Param("entities") List<MachineryJobData> list);
List<MachineryJobData> selectByTime(@Param("startTime") Date startTime,@Param("endTime")Date endTime);
List<MachineryJobDataVo> selectMachineryJobData(@Param("startTime") Date startTime,@Param("endTime")Date endTime,@Param("vehicleno") String vehicleno);
List<MachineryJobDataVo> selectMachineryJobData();
void updateAreaWorkhours(@Param("vehicleno")String vehicleno, @Param("workArea") Double workArea, @Param("workhours")Double workhours);
MachineryJobDataVo selectTodayJobData();
/**
* 查询全部农机编号
* @return
*/
List<String> selectVehicleno();
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.MachineryPosition;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MachineryPositionMapper {
/**
* 查询农机在线数量
* @return
*/
public int selectMachineryOnline();
/**
* 插入农机位置
* @param machineryPositions
* @return
*/
public int insertBatch(@Param("entities")List<MachineryPosition> machineryPositions);
/**
* 查询农机作业类型
* @param vehicleno
* @return
*/
int selectJobtype(String vehicleno);
}

View File

@ -0,0 +1,30 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.MachineryTrajectory;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface MachineryTrajectoryMapper {
int insertTrajectory(@Param("entities") List<MachineryTrajectory> tragectory);
List<MachineryTrajectory> selectByVehicleno(String vehicleno);
List<MachineryTrajectory> selectVehicleTrack(@Param("workplace") String workplace, @Param("pttime") Date pttime);
List<String> distinctWorkplace(@Param("vehicleno") String vehicleno);
List<String> distinctWorkplace();
/**
* 查询今日作业农机编号
* @return
*/
List<String> distinctVehicleno();
/**
* 查询正在作业农机数量
* @return
*/
int selectWorkingMachinery();
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.Meteorological;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -10,5 +11,7 @@ public interface MeteorologicalMapper {
int insert(Meteorological ml);
int insertBatch(@Param("entities") List<Meteorological> ml);
// void insert2(Meteorological ml2);
}

View File

@ -6,13 +6,42 @@ import java.util.List;
public interface ServiceTypeMapper {
/**
* 根据类型查询
*
* @param type
* @return
*/
List<ServiceType> selectByType(String type);
/**
* 新增单条数据
*
* @param serviceType
* @return
*/
int insert(ServiceType serviceType);
/**
* 查询全部数据
*
* @return
*/
List<ServiceType> selectAll();
/**
* 根据id数组删除
*
* @param ids
* @return
*/
int deleteByIds(Long[] ids);
/**
* 查询数据库是否存在相同文件名数据
*
* @param name
* @return
*/
int selectByfile(String name);
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.WarningFarm;
import com.ruoyi.crops.domain.WarningInformation;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface WarningFarmMapper {
int insertWarning(WarningFarm warningFarm);
List<WarningFarm> selectByTime(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
}

View File

@ -8,7 +8,7 @@ import java.util.Date;
import java.util.List;
public interface WarningMapper {
List<WarningInformation> selectByTime(@Param("startTime") Date startTime,@Param("endTime") Date endTime);
List<WarningInformation> selectByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
int insert(WarningInformation warningInformation);

View File

@ -0,0 +1,22 @@
package com.ruoyi.crops.mapper;
import com.ruoyi.crops.domain.WeatherPredictionEntity;
import com.ruoyi.crops.domain.vo.WeatherPredoctionVo;
import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List;
public interface WeatherPredictionMapper {
int insert(WeatherPredictionEntity weatherPredictionEntity);
int insertBatch(@Param("list") List<WeatherPredictionEntity> list);
List<WeatherPredictionEntity> selectWeek();
List<WeatherPredoctionVo> selectByTime(Date time);
List<WeatherPredictionEntity> select(Date time);
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.crops.runner;
import com.ruoyi.crops.service.impl.FarmMachineryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class Runner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// System.out.println("程序初始化");
}
}

View File

@ -8,11 +8,16 @@ import java.util.List;
public interface ICropsGrowthService {
/**
* 批量新增
* 批量新增作物长势数据
* @param cropGrowth
* @return
*/
public int insertBatch(List<CropsGrowth> cropGrowth);
/**
* 根据时间查询作物长势数据
* @param time
* @return
*/
public List<CropsGrowth> selectByTime(Date time);
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.crops.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsUser;
import java.util.List;
public interface ICropsUserService {
/**
* 获取全部用户
* @return
*/
List<CropsUser> list();
/**
* 新增用户
* @param cropsUser
* @return
*/
int insert(CropsUser cropsUser);
/**
* 删除用户
* @param id
* @return
*/
int delete(Integer id);
/**
* 修改用户
* @param id
* @return
*/
int update(Integer id);
/**
* 根据id查询用户
* @param phone
* @return
*/
CropsUser selectByPhone(String phone);
CropsUser login(CropsUser user);
int regist(CropsUser cropsUser);
}

View File

@ -6,7 +6,17 @@ import java.util.Date;
import java.util.List;
public interface ICropsYieldService {
/**
* 根据年份查询作物产量
* @param year
* @return
*/
public List<CropsYield> selectByYear(Integer year);
/**
* 批量新增作物产量数据
* @param cropYieldList
* @return
*/
public int insertBatch (List<CropsYield> cropYieldList);
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.crops.service;
import com.ruoyi.crops.domain.DataAcquisition;
import java.io.FileNotFoundException;
import java.util.List;
public interface IDataAcquisitionService {
DataAcquisition getData();
int insert(DataAcquisition data);
DataAcquisition getdataAcquisition();
}

View File

@ -7,14 +7,35 @@ import java.util.Date;
import java.util.List;
public interface IDeviceSenseService {
/**
* 插入设备状态信息
* @param deviceSense
* @return
*/
int insert(DeviceSense deviceSense);
//sql判断重复数据后插入
void dedupInsert(DeviceSense deviceSense);
/**
* 根据id查询设备状态信息
* @param deviceId
* @return
*/
List<DeviceSense> selectById(String deviceId);
List<DeviceSense> selectByTime(String startTime, String endTime);
/**
* 根据时间进行查询设备状态信息
* @param startTime
* @param endTime
* @return
*/
List<DeviceSense> selectByTime(Date startTime, Date endTime);
/**
* 根据类型查询平均数据
* @param type
* @return
*/
List<DeviceSenseVo> averageList(String type);
}

View File

@ -0,0 +1,173 @@
package com.ruoyi.crops.service;
import com.ruoyi.crops.domain.FarmMachinery;
import com.ruoyi.crops.domain.MachineryJobData;
import com.ruoyi.crops.domain.MachineryPosition;
import com.ruoyi.crops.domain.MachineryTrajectory;
import com.ruoyi.crops.domain.vo.FarmMachineryVo;
import com.ruoyi.crops.domain.vo.MachineryJobDataVo;
import org.apache.ibatis.annotations.Param;
import org.locationtech.jts.geom.Coordinate;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface IFarmMachineryService {
/**
* 将字符串多坐标点转换为坐标数组
*
* @param latLonString "116.616634,40.272665|116.644733,40.280371|116.636181,40.264352|116.616634,40.272665"
* @return org.locationtech.jts.geom.Coordinate[]
*/
public Coordinate[] getCoordinateArray(String latLonString);
/**
* 判断坐标点是否在多坐标点组成的多边形面内
*
* @param coordinateArray
* @param coordinate
* @return boolean
* @author guochao.bj@fang.com
* within 判断是否在内部边缘点返回false
* intersects 判断是否相交弥补 within边缘点缺陷
*/
public boolean withinAndIntersects(Coordinate[] coordinateArray, Coordinate coordinate);
/**
* @param lnglatPolygon 坐标数组
* @param lng 经度
* @param lat 纬度
* @return
*/
public boolean withinAndIntersects(String lnglatPolygon, double lng, double lat);
/**
* 农机信息查询
* @return
*/
public List<FarmMachineryVo> selectMachineryData();
public FarmMachineryVo selectMachineryData(String vehicleno);
/**
* 在线农机数量查询
* @return
*/
public int selectMachineryOnline();
/**
* 批量插入农机设备信息
* @param farmMachineryList
* @return
*/
public int insertBatch(List<FarmMachinery> farmMachineryList);
/**
* 批量插入农机作业任务
* @param list
* @return
*/
public int insertJobDataBatch(List<MachineryJobData> list);
/**
* 农机作业任务查询
* @param startTime
* @param endTime
* @return
*/
public List<MachineryJobData> selectJobDataByTime(Date startTime,Date endTime);
/**
* 历史作业信息查询
* @param startTime
* @param endTime
* @param vehicleno
* @return
*/
List<MachineryJobDataVo> selectMachineryJobData(Date startTime,Date endTime,String vehicleno);
List<MachineryJobDataVo> selectMachineryJobData();
/**
* 农机轨迹数据分类
* @param machineryTrajectories
* @param vehicleno
* @return
*/
public List<List<MachineryTrajectory>> processPositions(List<MachineryTrajectory> machineryTrajectories,String vehicleno);
/**
* 插入农机轨迹数据
* @param list
* @param vehicleno
* @return
*/
public void insertProcessPositions(List<MachineryTrajectory> list,String vehicleno);
/**
* 查询农机轨迹数据
* @param workplace
* @param pttime
* @return
*/
List<MachineryTrajectory> selectVehicleTrack(String workplace, Date pttime);
/**
* 查询今日作业地块
* @param vehicleno 农机编号为空查询今日全部
* @return
*/
List<String> distinctWorkplace(String vehicleno);
List<String> distinctWorkplace();
/**
* 查询今日作业农机编号
* @return
*/
List<String> distinctVehicleno();
/**
* 更新作业面积和时长
* @param vehicleno
* @param area
* @param workingHours
*/
void updateAreaWorkhours(String vehicleno,double area, double workingHours);
/**
* 查询今日作业数据
* @return
*/
MachineryJobDataVo selectTodayJobData();
/**
* 查询正在作业农机数量
*/
int selectWorkingMachinery();
/**
* 插入农机位置
* @param position
*/
void insertPositions(List<MachineryPosition> position);
/**
* 查询农机作业类型
* @param vehicleno
* @return
*/
int selectJobtype(@Param("vehicleno")String vehicleno);
void updateworkplace();
/**
* 查询全部农机编号
* @return
*/
List<String> selectVehicleno();
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.crops.domain.DeviceSense;
import com.ruoyi.crops.domain.FertigationSense;
public interface IFertigationSenseService {
//使用sql判断重复数据插入
void dedupInsert(FertigationSense fertigationSense);
int insert(FertigationSense fertigationSense);
}

View File

@ -1,9 +1,11 @@
package com.ruoyi.crops.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.ServiceType;
public interface IGeoServer {
public String GeoServer(String workSpace, String storeName, String filePath) throws Exception;
public String publishTiff(String workSpace, String storeName, String filePath ,String styleName) throws Exception;
public String publishShp(String workSpace, String storeName, String layername, String filePath);
int insert(ServiceType serviceType);
}

View File

@ -1,11 +1,33 @@
package com.ruoyi.crops.service;
import cn.hutool.http.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ruoyi.crops.domain.MachineParameter;
import com.ruoyi.crops.domain.UserInfo;
import com.ruoyi.crops.domain.gsonBean.GsonMachineParameterBean;
import com.ruoyi.crops.domain.vo.MachineParameterVo;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public interface IMachineParameterService {
List<MachineParameter> selectByName(String name);
int insert(MachineParameter machineParameter);
/**
* 获取水肥机全部状态参数
* @return
* @throws Exception
*/
public MachineParameter getMachineParameter() throws Exception;
/**
* 获取ph值流量压力值
* @return
* @throws Exception
*/
MachineParameterVo selectParameter() throws Exception;
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.service;
import com.ruoyi.common.utils.MyPoint;
import java.util.List;
public interface IMapDrawPolygonService {
/**
* 根据经纬度数筛选出边界数据
* @param points
* @return
* @throws Exception
*/
public List<MyPoint> DrawPolygon(List<MyPoint> points) throws Exception;
}

View File

@ -6,7 +6,23 @@ import java.util.List;
public interface IMeteorologicalService {
/**
* 根据时间查询
* @return
*/
List<Meteorological> selectByTime();
/**
* 新增单条数据
* @param ml
* @return
*/
int insert(Meteorological ml);
/**
* 批量插入数据
* @param ml
* @return
*/
int insertBatch(List<Meteorological> ml);
}

View File

@ -6,11 +6,30 @@ import java.util.List;
public interface IServiceTypeService {
/**
* 根据类型查询
* @param type
* @return
*/
List<ServiceType> selectByType(String type);
/**
* 新增数据
* @param serviceType
* @return
*/
int insert(ServiceType serviceType);
/**
* 查询全部
* @return
*/
List<ServiceType> selectAll();
/**
* 根据id批量删除
* @param ids
* @return
*/
int deleteByIds(Long[] ids);
}

View File

@ -5,6 +5,12 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
public interface IUploadService {
String upload(String type,MultipartFile file, String fileRoot) throws IOException;
/**
* 文件上传
* @param file 文件名
* @param fileRoot 文件路径
* @return
* @throws IOException
*/
String upload(MultipartFile file, String fileRoot) throws IOException;
}

View File

@ -0,0 +1,13 @@
package com.ruoyi.crops.service;
import com.ruoyi.crops.domain.WarningFarm;
import com.ruoyi.crops.domain.WarningInformation;
import java.util.Date;
import java.util.List;
public interface IWarningFarmService {
int insertWarning(WarningFarm warningFarm);
List<WarningFarm> selectByTime(Date beginTime, Date endTime);
}

View File

@ -8,9 +8,9 @@ import java.util.Date;
import java.util.List;
public interface IWarningService {
List<WarningInformation> selectByTime(Date startTime,Date endTime);
List<WarningInformation> selectByTime(Date startTime, Date endTime);
int insert(WarningInformation warningInformation);
int insertWarning(DeviceSense deviceSense);
int judgeWarning(DeviceSense deviceSense);
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.crops.service;
import com.ruoyi.crops.domain.WeatherPredictionEntity;
import com.ruoyi.crops.domain.vo.WeatherPredoctionVo;
import java.io.IOException;
import java.util.Date;
import java.util.List;
public interface IWeatherPredictionService {
public List<WeatherPredictionEntity> getWeather() throws IOException;
public int insert(WeatherPredictionEntity weatherPredictionEntity);
public int insertBatch(List<WeatherPredictionEntity> list);
public List<WeatherPredictionEntity> selectWeek();
List<WeatherPredoctionVo> selectByTime(Date time);
List<WeatherPredictionEntity> select(Date time);
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.crops.service;
import com.ruoyi.crops.domain.InterfaceStatistics;
import com.ruoyi.crops.domain.vo.InterfaceStatisticsVo;
import java.util.List;
public interface InterfaceStatisticsService {
int insert(InterfaceStatistics interfaceStatistics);
InterfaceStatistics selectByDay();
InterfaceStatisticsVo selectTotal();
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.crops.service.impl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.crops.domain.CropsDrought;
import com.ruoyi.crops.domain.CropsYield;
import com.ruoyi.crops.mapper.CropsDroughtMapper;
@ -14,11 +15,22 @@ import java.util.List;
public class CropsDroughtServiceImpl implements ICropsDroughtService {
@Autowired
private CropsDroughtMapper cropsDroughtMapper;
/**
* 批量插入作物旱情数据
* @param cropsYieldList
* @return
*/
@Override
public int insertBatch(List<CropsDrought> cropsYieldList) {
return cropsDroughtMapper.insertBatch(cropsYieldList);
}
/**
* 根据时间查询作物旱情数据
* @param time
* @return
*/
@Override
public List<CropsDrought> selectByTime(Date time) {
return cropsDroughtMapper.selectByTime(time);

View File

@ -13,11 +13,22 @@ import java.util.List;
public class CropsGrowthServiceImpl implements ICropsGrowthService {
@Autowired
private CropsGrowthMapper cropsGrowthMapper;
/**
* 批量新增作物长势数据
* @param cropGrowth
* @return
*/
@Override
public int insertBatch(List<CropsGrowth> cropGrowth) {
return cropsGrowthMapper.insertBatch(cropGrowth);
}
/**
* 根据时间查询作物长势数据
* @param time
* @return
*/
@Override
public List<CropsGrowth> selectByTime(Date time) {
return cropsGrowthMapper.selectByTime(time);

View File

@ -34,6 +34,11 @@ public class CropsStructureServiceImpl implements ICropsStructureService {
return cropsStructureMapper.insertBatch(cropStructureList);
}
/**
* 根据时间查询作物种植结构
* @param time
* @return
*/
@Override
public List<CropStructure> selectByTime(Date time) {
return cropsStructureMapper.selectByTime(time);

View File

@ -0,0 +1,78 @@
package com.ruoyi.crops.service.impl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.crops.domain.CropsUser;
import com.ruoyi.crops.mapper.CropsUserMapper;
import com.ruoyi.crops.service.ICropsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CropsUserServiceImpl implements ICropsUserService {
@Autowired
private CropsUserMapper cropsUserMapper;
/**
* 获取全部用户列表
* @return
*/
@Override
public List<CropsUser> list() {
return cropsUserMapper.list();
}
/**
* 新增用户
* @param cropsUser
* @return
*/
@Override
public int insert(CropsUser cropsUser) {
return cropsUserMapper.insert(cropsUser);
}
/**
* 删除用户
* @param id
* @return
*/
@Override
public int delete(Integer id) {
return cropsUserMapper.delete(id);
}
/**
* 修改用户
* @param id
* @return
*/
@Override
public int update(Integer id) {
return cropsUserMapper.update(id);
}
@Override
public CropsUser selectByPhone(String phone) {
return cropsUserMapper.selectByPhone(phone);
}
@Override
public CropsUser login(CropsUser user) {
return cropsUserMapper.login(user);
}
@Override
public int regist(CropsUser cropsUser) {
CropsUser cnt = cropsUserMapper.selectByPhone(cropsUser.getPhone());
if (cnt!=null){
throw new RuntimeException("手机号已存在");
}
int tmp = cropsUserMapper.selectCountByName(cropsUser.getUserName());
if (tmp == 1){
throw new RuntimeException("用户名已存在");
}
return cropsUserMapper.insert(cropsUser);
}
}

View File

@ -6,18 +6,39 @@ import com.ruoyi.crops.service.ICropsYieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class CropsYieldServiceImpl implements ICropsYieldService {
@Autowired
private CropsYieldMapper cropsYieldMapper;
/**
* 根据年份查询作物产量
* @param year
* @return
*/
@Override
public List<CropsYield> selectByYear(Integer year) {
return cropsYieldMapper.selectByYear(year);
List<CropsYield> cropsYields = cropsYieldMapper.selectByYear(year);
for (CropsYield cropsYield : cropsYields) {
switch (cropsYield.getCropType()) {
case "ym":cropsYield.setCropType("玉米");
case "xm":cropsYield.setCropType("小麦");
case "dd":cropsYield.setCropType("大豆");
case "hs":cropsYield.setCropType("花生");
case "qt":cropsYield.setCropType("其他");
}
}
return cropsYields;
}
/**
* 批量新增作物产量数据
* @param cropYieldList
* @return
*/
@Override
public int insertBatch(List<CropsYield> cropYieldList) {
return cropsYieldMapper.insertBatch(cropYieldList);

View File

@ -0,0 +1,63 @@
package com.ruoyi.crops.service.impl;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.crops.domain.DataAcquisition;
import com.ruoyi.crops.mapper.DataAcquisitionMapper;
import com.ruoyi.crops.service.IDataAcquisitionService;
import org.apache.poi.ss.formula.functions.Now;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
@Service
public class DataAcquisitionServiceImpl implements IDataAcquisitionService {
@Autowired
private DataAcquisitionMapper dataAcquisitionMapper;
long numb = 0;//总大小(字节)
int length = 0;//文件个数
@Override
public DataAcquisition getData() {
return dataAcquisitionMapper.getData();
}
@Override
public int insert(DataAcquisition data) {
return dataAcquisitionMapper.insert(data);
}
@Override
public DataAcquisition getdataAcquisition(){
File file = new File(RuoYiConfig.getUploadPath()+"\\tifFile");
countfile(file);//统计tiff影像文件
//查询前刷新表数据
dataAcquisitionMapper.analyze();
DataAcquisition sensorData = dataAcquisitionMapper.getSensorData();
sensorData.setImageData(length);
sensorData.setImageDataTotal((float)numb / 1024 / 1024);
insert(sensorData);
return sensorData;
}
public void countfile(File fpath){
String path = fpath.getPath();
File file = new File(path); //获取其file对象
File[] fs = file.listFiles(); //遍历path下的文件和目录放在File数组中
length = fs.length;
for (File f : fs) { //遍历File[]数组
if (!f.isDirectory()) //若非目录(即文件)对其进行遍历
{
numb += f.length();//获取文件大小(字节)
} else {
countfile(f);
}
}
}
}

View File

@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -37,29 +38,45 @@ public class DeviceSenseServiceImpl implements IDeviceSenseService {
deviceSenseMapper.dedupInsert(deviceSense);
}
/**
* 根据设备id查询
* @param deviceId
* @return
*/
@Override
public List<DeviceSense> selectById(String deviceId) {
return deviceSenseMapper.selectById(deviceId);
}
/**
* 根据时间查询设备状态
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
@Override
public List<DeviceSense> selectByTime(String startTime, String endTime) {
public List<DeviceSense> selectByTime(Date startTime, Date endTime) {
return deviceSenseMapper.selectByTime(startTime, endTime);
}
/**
* 根据天周月查询设备状态平均值
* @param type
* @return
*/
@Override
public List<DeviceSenseVo> averageList(String type) {
if (type.equals("hours")) {
String dayBegin = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getBeginDayOfYesterday());
String dayend = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getBeginDayOfTomorrow());
Date dayBegin = DateUtil.getBeginDayOfYesterday();
Date dayend = DateUtil.getBeginDayOfTomorrow();
return deviceSenseMapper.selecthours(dayBegin, dayend);
} else if (type.equals("week")) {
String weekBegin = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getBeginDayOfWeek());
String weekEnd = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getEndDayOfWeek());
Date weekBegin = DateUtil.getBeginDayOf7day();
Date weekEnd = DateUtil.getDayBegin();
return deviceSenseMapper.selectdays(weekBegin, weekEnd);
} else if (type.equals("month")) {
String monthBegin = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getBeginDayOfMonth());
String monthEnd = new SimpleDateFormat("yyyy-MM-dd").format(DateUtil.getEndDayOfMonth());
Date monthBegin = DateUtil.getBeginDayOfMonth();
Date monthEnd = DateUtil.getEndDayOfMonth();
return deviceSenseMapper.selectdays(monthBegin, monthEnd);
}
return null;

View File

@ -12,21 +12,41 @@ public class ExeServiceImpl implements IexeService {
@Override
public String execCommand(String type, String filePath, String boundaryDataPath) {
String path;
if (type.equals("zzjg")) {
path = exePath + "农作物种植结构.exe ";
} else if (type.equals("zwzs")) {
path = exePath + "农作物长势.exe ";
} else if (type.equals("zwhq")) {
path = exePath + "农作物旱情.exe ";
} else if (type.equals("zyzd_hq")) {
path = exePath + "旱情指导.exe ";
} else if (type.equals("zyzd_zs")) {
path = exePath + "长势指导.exe ";
} else {
path = exePath + "农作物产量.exe ";
String path = "";
String yieldType = "";
switch (type) {
case "zzjg":
path = exePath + "农作物种植结构.exe ";
break;
case "zwzs":
path = exePath + "农作物长势.exe ";
break;
case "zwhq":
path = exePath + "农作物旱情.exe ";
break;
case "zwcl_ym":
path = exePath + "农作物产量.exe ";
yieldType = " '玉米'";
break;
case "zwcl_xm":
path = exePath + "农作物产量.exe ";
yieldType = " '小麦'";
break;
case "zwcl_qt":
path = exePath + "农作物产量.exe ";
yieldType = " '其他'";
break;
case "zwcl_hs":
path = exePath + "农作物产量.exe ";
yieldType = " '花生'";
break;
case "zwcl_dd":
path = exePath + "农作物产量.exe ";
yieldType = " '大豆'";
break;
default:return " 未执行exe";
}
return BashUtils.execCommand(path + "\"" + filePath + "\"" + " \"" + boundaryDataPath + "\"");
return BashUtils.execCommand(path + "\"" + filePath + "\"" + " \"" + boundaryDataPath + "\"" + yieldType);
}
}

Some files were not shown because too many files have changed in this diff Show More