|
|
@@ -0,0 +1,172 @@
|
|
|
+package com.yunfeiyun.agmp.iotm.device.ybq.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
|
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
+import com.yunfeiyun.agmp.common.core.page.TableSupport;
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotCbdimg;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotYbqEnvData;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotYbqPredictData;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.reqvo.IotYbqdataReqVo;
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
+import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
+import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/ybq")
|
|
|
+@Slf4j
|
|
|
+public class IotYbqController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private IIotDeviceService iIotDeviceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MongoService mongoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 水稻稻瘟病
|
|
|
+ *
|
|
|
+ * @param reqVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/device/list/dwb")
|
|
|
+ public TableDataInfo getDwbDevicelist(IotDeviceListReqVo reqVo) {
|
|
|
+ return selectDevice(IotDeviceDictConst.TYPE_HS_YBQ_DWB, reqVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小麦赤霉病
|
|
|
+ *
|
|
|
+ * @param reqVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/device/list/cmb")
|
|
|
+ public TableDataInfo getCmbDevicelist(IotDeviceListReqVo reqVo) {
|
|
|
+ return selectDevice(IotDeviceDictConst.TYPE_HS_YBQ_CMB, reqVo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 玉米大斑病
|
|
|
+ *
|
|
|
+ * @param reqVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/device/list/dbb")
|
|
|
+ public TableDataInfo getDbbDevicelist(IotDeviceListReqVo reqVo) {
|
|
|
+ return selectDevice(IotDeviceDictConst.TYPE_HS_YBQ_DBB, reqVo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ TableDataInfo selectDevice(String devTypeId, IotDeviceListReqVo reqVo) {
|
|
|
+ reqVo.setDevtypeBid(devTypeId);
|
|
|
+ startPage();
|
|
|
+ List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取预测数据
|
|
|
+ */
|
|
|
+ @RequestMapping("/data/predict/list")
|
|
|
+ public TableDataInfo list(IotYbqdataReqVo reqVo) {
|
|
|
+ String devBizId = reqVo.getDevBid();
|
|
|
+ if (StringUtils.isEmpty(devBizId)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备id不可为空");
|
|
|
+ }
|
|
|
+ String ybqType = reqVo.getDateDevType();
|
|
|
+ if (StringUtils.isEmpty(ybqType)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "数据类型不可为空");
|
|
|
+ }
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(reqVo);
|
|
|
+ // 预测时间可能会被更新,所以用修改时间,创建时候这个值会默认有
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("gte_ybqdataModifiedDate", reqVo.getStartDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("lte_ybqdataModifiedDate", reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("time_ybqdataModifiedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ map.remove("startDate");
|
|
|
+ map.remove("endDate");
|
|
|
+ return getDataTable(mongoService.findListPage(IotYbqPredictData.class, map, TableSupport.buildPageRequest()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取环境列表数据
|
|
|
+ */
|
|
|
+ @RequestMapping("/data/env/list")
|
|
|
+ public TableDataInfo getEnvList(IotYbqdataReqVo reqVo) {
|
|
|
+ String devBizId = reqVo.getDevBid();
|
|
|
+ if (StringUtils.isEmpty(devBizId)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备id不可为空");
|
|
|
+ }
|
|
|
+ String ybqType = reqVo.getDateDevType();
|
|
|
+ if (StringUtils.isEmpty(ybqType)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "数据类型不可为空");
|
|
|
+ }
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(reqVo);
|
|
|
+ // 预测时间可能会被更新,所以用修改时间,创建时候这个值会默认有
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("gte_ybqdataCreatedDate", reqVo.getStartDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("lte_ybqdataCreatedDate", reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("time_ybqdataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ map.remove("startDate");
|
|
|
+ map.remove("endDate");
|
|
|
+ return getDataTable(mongoService.findListPage(IotYbqEnvData.class, map, TableSupport.buildPageRequest()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取环境列表数据
|
|
|
+ */
|
|
|
+ @RequestMapping("/data/env/stat")
|
|
|
+ public AjaxResult getEnvStatList(IotYbqdataReqVo reqVo) {
|
|
|
+ String devBizId = reqVo.getDevBid();
|
|
|
+ if (StringUtils.isEmpty(devBizId)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备id不可为空");
|
|
|
+ }
|
|
|
+ String ybqType = reqVo.getDateDevType();
|
|
|
+ if (StringUtils.isEmpty(ybqType)) {
|
|
|
+ throw new IotBizException(IotErrorCode.FAILURE.getCode(), "数据类型不可为空");
|
|
|
+ }
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(reqVo);
|
|
|
+ // 预测时间可能会被更新,所以用修改时间,创建时候这个值会默认有
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("gte_ybqdataCreatedDate", reqVo.getStartDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("lte_ybqdataCreatedDate", reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
|
|
|
+ map.put("time_ybqdataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
|
|
|
+ }
|
|
|
+ map.remove("startDate");
|
|
|
+ map.remove("endDate");
|
|
|
+ return AjaxResult.success(mongoService.findAll(IotYbqEnvData.class, map, "ybqdataCreatedDate,asc"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|