From 782e84d68779471c0640584678d4c4df3afa80a2 Mon Sep 17 00:00:00 2001
From: 于紫祥_1901 <email@yuzixiang_1910>
Date: Mon, 14 Dec 2020 17:29:08 +0800
Subject: [PATCH] 电子屏

---
 src/main/java/com/moral/controller/DeviceController.java |   77 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/moral/controller/DeviceController.java b/src/main/java/com/moral/controller/DeviceController.java
index 87e7fa1..d02ddd8 100644
--- a/src/main/java/com/moral/controller/DeviceController.java
+++ b/src/main/java/com/moral/controller/DeviceController.java
@@ -1,11 +1,29 @@
 package com.moral.controller;
 
-import com.moral.common.bean.PageBean;
-import com.moral.common.bean.ResultBean;
-import com.moral.service.DeviceService;
-import org.springframework.web.bind.annotation.*;
+import static com.moral.common.util.WebUtils.getParametersStartingWith;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import com.moral.mapper.DeviceMapper;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.alibaba.fastjson.JSONObject;
+import com.moral.common.bean.PageBean;
+import com.moral.common.bean.ResultBean;
+import com.moral.entity.Device;
+import com.moral.entity.DeviceProperty;
+import com.moral.service.DeviceService;
 
 @RestController
 @RequestMapping("device")
@@ -13,6 +31,16 @@
 public class DeviceController {
     @Resource
     DeviceService deviceService;
+    @Resource
+    DeviceMapper deviceMapper;
+    @GetMapping("count-by-example")
+    public ResultBean<Integer> countByExample(PageBean pageBean){
+        return  new ResultBean<Integer>(deviceService.countByExample(pageBean));
+    }
+    @GetMapping("count-by-times")
+    public ResultBean<List<Map>> countByTimes(Date start, Date end){
+        return  new ResultBean<List<Map>>(deviceService.countByTimes(start,end,"%Y-%m"));
+    }
     @GetMapping("page-list")
     public PageBean pageList(PageBean pageBean) {
         return deviceService.queryByPageBean(pageBean);
@@ -23,4 +51,45 @@
         ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
         return resultBean;
     }
+    @PostMapping("add-or-modify")
+    public ResultBean addOrModify(@RequestBody Device device){
+        deviceService.addOrModify(device);
+        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
+        return resultBean;
+    }
+
+    @GetMapping("monitorPointId")
+    public ResultBean<List<Device>> getDevicesByMonitorPointId(@RequestParam(name="monitorPointId")Integer  monitorPointId) {
+    	
+    	List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId);
+        return new ResultBean<List<Device>>(devices);
+    }
+
+    @GetMapping("professionId")
+    public ResultBean<List<Device>> getDevicesByProfessionId(HttpServletRequest request) {
+		Map<String, Object> parameters = getParametersStartingWith(request, null);
+    	List<Device> devices = deviceService.getDevicesByProfessionId(parameters);
+        return new ResultBean<List<Device>>(devices);
+    }
+
+    @GetMapping("getDeviceByMonitorId")
+    public ResultBean<List<Map<String, Object>>> getDeviceByMonitorId() {
+        List<Map<String, Object>> devices = deviceMapper.getDevicesByMpId(563);
+        return new ResultBean<List<Map<String, Object>>>(devices);
+    }
+    
+    @PostMapping("save-or-update")
+    public ResultBean saveOrUpdate(@RequestBody String jsonString){
+    	Device device = JSONObject.parseObject(jsonString, Device.class);
+    	DeviceProperty deviceProperty = JSONObject.parseObject(jsonString, DeviceProperty.class);
+    	deviceService.saveOrUpdate(device,deviceProperty);
+        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
+        return resultBean;
+    }
+
+    @GetMapping("device-list")
+    public PageBean getDeviceList(PageBean pageBean) {
+        return deviceService.getDeviceList(pageBean);
+    }
+
 }

--
Gitblit v1.8.0