|
|
@@ -1,25 +1,16 @@
|
|
|
package com.yunfeiyun.agmp.iotm.device.pest.controller;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSONArray;
|
|
|
-import com.yunfeiyun.agmp.common.annotation.Log;
|
|
|
import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
|
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
|
-import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
-import com.yunfeiyun.agmp.common.enums.BusinessType;
|
|
|
-import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
|
|
|
-import com.yunfeiyun.agmp.iot.common.domain.*;
|
|
|
import com.yunfeiyun.agmp.iotm.device.pest.service.IIotAidispestService;
|
|
|
import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
-import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
-import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.List;
|
|
|
+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;
|
|
|
|
|
|
/**
|
|
|
* 害虫信息Controller
|
|
|
@@ -39,31 +30,6 @@ public class IotPestController extends BaseController
|
|
|
private IIotAidispestService iotAidispestService;
|
|
|
|
|
|
/**
|
|
|
- * 查询害虫信息列表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:list')")
|
|
|
- @GetMapping("/list")
|
|
|
- public TableDataInfo list(IotPest iotPest)
|
|
|
- {
|
|
|
- startPage();
|
|
|
- List<IotPest> list = iotPestService.selectIotPestList(iotPest);
|
|
|
- return getDataTable(list);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出害虫信息列表
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:export')")
|
|
|
- @Log(title = "害虫信息", businessType = BusinessType.EXPORT)
|
|
|
- @PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, IotPest iotPest)
|
|
|
- {
|
|
|
- List<IotPest> list = iotPestService.selectIotPestList(iotPest);
|
|
|
- ExcelUtil<IotPest> util = new ExcelUtil<IotPest>(IotPest.class);
|
|
|
- util.exportExcel(response, list, "害虫信息数据");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 获取害虫信息详细信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('iot:pest:query')")
|
|
|
@@ -73,77 +39,103 @@ public class IotPestController extends BaseController
|
|
|
return success(iotPestService.selectIotPestByPestBid(pestBid));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取害虫信息详细信息
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:plug:query')")
|
|
|
- @GetMapping(value = "/plug/info")
|
|
|
- public AjaxResult getPlugInfo(@RequestParam("pestBid") String pestBid)
|
|
|
- {
|
|
|
- Criteria criteria = new Criteria();
|
|
|
- criteria.and("pestBusid").is(pestBid);
|
|
|
- Query query = new Query(criteria);
|
|
|
- query.with(Sort.by(Sort.Direction.DESC, "pestrecogCreatedDate"));
|
|
|
- IotPestrecog iotPestrecog = mongoTemplate.findOne(query, IotPestrecog.class, "IotPestrecog");
|
|
|
- IotPest iotPest = iotPestService.selectIotPestByPestBid(pestBid);
|
|
|
- if (iotPestrecog != null) {
|
|
|
- Criteria criteria2 = new Criteria();
|
|
|
- criteria2.and("pestrecogBid").is(iotPestrecog.getPestrecogBid());
|
|
|
- IotCbdpest iotCbdpest = mongoTemplate.findOne(new Query(criteria2), IotCbdpest.class, "IotCbdpest");
|
|
|
- if (iotCbdpest != null) {
|
|
|
- Criteria criteria3 = new Criteria();
|
|
|
- criteria3.and("cbdrecogBid").is(iotCbdpest.getCbdrecogBid());
|
|
|
- IotCbdrecog iotCbdrecog = mongoTemplate.findOne(new Query(criteria3), IotCbdrecog.class, "IotCbdrecog");
|
|
|
- if (iotCbdrecog != null) {
|
|
|
- Criteria criteria4 = new Criteria();
|
|
|
- criteria4.and("cbdimgBid").is(iotCbdrecog.getCbdimgBid());
|
|
|
- IotCbdimg iotCbdimg = mongoTemplate.findOne(new Query(criteria4), IotCbdimg.class, "IotCbdimg");
|
|
|
- iotPest.setPestImgUrl(iotCbdimg.getCbdimgAddr());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- JSONArray preventiveMeasuresInfo = iotAidispestService.getPreventiveMeasuresInfo(iotPest.getPestName());
|
|
|
- if (preventiveMeasuresInfo.size() > 0) {
|
|
|
- iotPest.setPestInfo(preventiveMeasuresInfo.getJSONObject(0).toJSONString());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("获得防治措施异常", e);
|
|
|
- }
|
|
|
- return success(iotPest);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增害虫信息
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:add')")
|
|
|
- @Log(title = "害虫信息", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping("/add")
|
|
|
- public AjaxResult add(@RequestBody IotPest iotPest)
|
|
|
- {
|
|
|
- return toAjax(iotPestService.insertIotPest(iotPest));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改害虫信息
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:edit')")
|
|
|
- @Log(title = "害虫信息", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/edit")
|
|
|
- public AjaxResult edit(@RequestBody IotPest iotPest)
|
|
|
- {
|
|
|
- return toAjax(iotPestService.updateIotPest(iotPest));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除害虫信息
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('iot:pest:remove')")
|
|
|
- @Log(title = "害虫信息", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/delete")
|
|
|
- public AjaxResult remove(@RequestParam("ids") Long[] ids)
|
|
|
- {
|
|
|
- return toAjax(iotPestService.deleteIotPestByIds(ids));
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 查询害虫信息列表
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:list')")
|
|
|
+// @GetMapping("/list")
|
|
|
+// public TableDataInfo list(IotPest iotPest)
|
|
|
+// {
|
|
|
+// startPage();
|
|
|
+// List<IotPest> list = iotPestService.selectIotPestList(iotPest);
|
|
|
+// return getDataTable(list);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 导出害虫信息列表
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:export')")
|
|
|
+// @Log(title = "害虫信息", businessType = BusinessType.EXPORT)
|
|
|
+// @PostMapping("/export")
|
|
|
+// public void export(HttpServletResponse response, IotPest iotPest)
|
|
|
+// {
|
|
|
+// List<IotPest> list = iotPestService.selectIotPestList(iotPest);
|
|
|
+// ExcelUtil<IotPest> util = new ExcelUtil<IotPest>(IotPest.class);
|
|
|
+// util.exportExcel(response, list, "害虫信息数据");
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取害虫信息详细信息
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:plug:query')")
|
|
|
+// @GetMapping(value = "/plug/info")
|
|
|
+// public AjaxResult getPlugInfo(@RequestParam("pestBid") String pestBid)
|
|
|
+// {
|
|
|
+// Criteria criteria = new Criteria();
|
|
|
+// criteria.and("pestBusid").is(pestBid);
|
|
|
+// Query query = new Query(criteria);
|
|
|
+// query.with(Sort.by(Sort.Direction.DESC, "pestrecogCreatedDate"));
|
|
|
+// IotPestrecog iotPestrecog = mongoTemplate.findOne(query, IotPestrecog.class, "IotPestrecog");
|
|
|
+// IotPest iotPest = iotPestService.selectIotPestByPestBid(pestBid);
|
|
|
+// if (iotPestrecog != null) {
|
|
|
+// Criteria criteria2 = new Criteria();
|
|
|
+// criteria2.and("pestrecogBid").is(iotPestrecog.getPestrecogBid());
|
|
|
+// IotCbdpest iotCbdpest = mongoTemplate.findOne(new Query(criteria2), IotCbdpest.class, "IotCbdpest");
|
|
|
+// if (iotCbdpest != null) {
|
|
|
+// Criteria criteria3 = new Criteria();
|
|
|
+// criteria3.and("cbdrecogBid").is(iotCbdpest.getCbdrecogBid());
|
|
|
+// IotCbdrecog iotCbdrecog = mongoTemplate.findOne(new Query(criteria3), IotCbdrecog.class, "IotCbdrecog");
|
|
|
+// if (iotCbdrecog != null) {
|
|
|
+// Criteria criteria4 = new Criteria();
|
|
|
+// criteria4.and("cbdimgBid").is(iotCbdrecog.getCbdimgBid());
|
|
|
+// IotCbdimg iotCbdimg = mongoTemplate.findOne(new Query(criteria4), IotCbdimg.class, "IotCbdimg");
|
|
|
+// iotPest.setPestImgUrl(iotCbdimg.getCbdimgAddr());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// try {
|
|
|
+// JSONArray preventiveMeasuresInfo = iotAidispestService.getPreventiveMeasuresInfo(iotPest.getPestName());
|
|
|
+// if (preventiveMeasuresInfo.size() > 0) {
|
|
|
+// iotPest.setPestInfo(preventiveMeasuresInfo.getJSONObject(0).toJSONString());
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// logger.error("获得防治措施异常", e);
|
|
|
+// }
|
|
|
+// return success(iotPest);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 新增害虫信息
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:add')")
|
|
|
+// @Log(title = "害虫信息", businessType = BusinessType.INSERT)
|
|
|
+// @PostMapping("/add")
|
|
|
+// public AjaxResult add(@RequestBody IotPest iotPest)
|
|
|
+// {
|
|
|
+// return toAjax(iotPestService.insertIotPest(iotPest));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 修改害虫信息
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:edit')")
|
|
|
+// @Log(title = "害虫信息", businessType = BusinessType.UPDATE)
|
|
|
+// @PutMapping("/edit")
|
|
|
+// public AjaxResult edit(@RequestBody IotPest iotPest)
|
|
|
+// {
|
|
|
+// return toAjax(iotPestService.updateIotPest(iotPest));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 删除害虫信息
|
|
|
+// */
|
|
|
+// @PreAuthorize("@ss.hasPermi('iot:pest:remove')")
|
|
|
+// @Log(title = "害虫信息", businessType = BusinessType.DELETE)
|
|
|
+// @DeleteMapping("/delete")
|
|
|
+// public AjaxResult remove(@RequestParam("ids") Long[] ids)
|
|
|
+// {
|
|
|
+// return toAjax(iotPestService.deleteIotPestByIds(ids));
|
|
|
+// }
|
|
|
}
|