From c0d88c1f82394c0374d2d592f4d2bca951d6334e Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Mon, 14 May 2018 15:58:07 +0800 Subject: [PATCH] 报表展示 增加行业筛选 --- src/main/java/com/moral/controller/DeviceController.java | 10 +++++ src/main/java/com/moral/service/DeviceService.java | 2 + src/main/resources/mapper/DeviceMapper.xml | 32 ++++++++++++++++ src/main/resources/mapper/HistoryMinutelyMapper.xml | 3 + src/main/resources/mapper/SensorMapper.xml | 3 + src/main/resources/mapper/AlarmDailyMapper.xml | 3 + src/main/java/com/moral/mapper/DeviceMapper.java | 2 + src/main/java/com/moral/service/impl/DeviceServiceImpl.java | 6 +++ 8 files changed, 61 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/moral/controller/DeviceController.java b/src/main/java/com/moral/controller/DeviceController.java index 468425f..1fad118 100644 --- a/src/main/java/com/moral/controller/DeviceController.java +++ b/src/main/java/com/moral/controller/DeviceController.java @@ -6,11 +6,14 @@ 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; @RestController @RequestMapping("device") @@ -49,4 +52,11 @@ 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); + } } diff --git a/src/main/java/com/moral/mapper/DeviceMapper.java b/src/main/java/com/moral/mapper/DeviceMapper.java index b0a8ae8..bf67ff6 100644 --- a/src/main/java/com/moral/mapper/DeviceMapper.java +++ b/src/main/java/com/moral/mapper/DeviceMapper.java @@ -26,4 +26,6 @@ List<Integer> getDeviceVersionIdByAreaCode(Map<String, Object> parameters); Integer getDeviceCountByRegion(Map<String, Object> parameters); List<Map> countByTimes(@Param("start")Date start,@Param("end")Date end,@Param("format")String format); + + List<Device> getDevicesByProfession(Map<String, Object> parameters); } \ No newline at end of file diff --git a/src/main/java/com/moral/service/DeviceService.java b/src/main/java/com/moral/service/DeviceService.java index 0074580..e05acea 100644 --- a/src/main/java/com/moral/service/DeviceService.java +++ b/src/main/java/com/moral/service/DeviceService.java @@ -40,4 +40,6 @@ List<Map<String,String>> queryDevicesState(List<String> macList,Boolean withData); Device queryById(Integer id); + + List<Device> getDevicesByProfessionId(Map<String, Object> parameters); } diff --git a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java index f85a95b..f6b20ef 100644 --- a/src/main/java/com/moral/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/moral/service/impl/DeviceServiceImpl.java @@ -418,4 +418,10 @@ return deviceMapper.selectByPrimaryKey(id); } + @Override + public List<Device> getDevicesByProfessionId(Map<String, Object> parameters) { + + return deviceMapper.getDevicesByProfession(parameters); + } + } diff --git a/src/main/resources/mapper/AlarmDailyMapper.xml b/src/main/resources/mapper/AlarmDailyMapper.xml index b29f1c5..10b3bbd 100644 --- a/src/main/resources/mapper/AlarmDailyMapper.xml +++ b/src/main/resources/mapper/AlarmDailyMapper.xml @@ -64,6 +64,9 @@ <if test="level != null"> AND h.state = #{level} </if> + <if test="professionId != null"> + AND d.profession_id = #{professionId} + </if> GROUP BY <if test="dimension=='monitorPoint'"> mp.id, diff --git a/src/main/resources/mapper/DeviceMapper.xml b/src/main/resources/mapper/DeviceMapper.xml index 795e325..4905b25 100644 --- a/src/main/resources/mapper/DeviceMapper.xml +++ b/src/main/resources/mapper/DeviceMapper.xml @@ -248,5 +248,37 @@ AND mp.area_code = #{areaCode} </if> ) + <if test="professionId != null"> + AND d.profession_id = #{professionId} + </if> + </select> + + <select id="getDevicesByProfession" resultType="com.moral.entity.Device"> + SELECT + * + FROM + device d + WHERE + d.is_delete = 0 + AND d.monitor_point_id IN ( + SELECT + mp.id + FROM + monitor_point mp + WHERE + mp.is_delete = 0 + <if test="provinceCode != null"> + AND mp.province_code = #{provinceCode} + </if> + <if test="cityCode != null"> + AND mp.city_code = #{cityCode} + </if> + <if test="areaCode != null"> + AND mp.area_code = #{areaCode} + </if> + ) + <if test="professionId != null"> + AND d.profession_id = #{professionId} + </if> </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/HistoryMinutelyMapper.xml b/src/main/resources/mapper/HistoryMinutelyMapper.xml index 4b1ea6e..1ba659a 100644 --- a/src/main/resources/mapper/HistoryMinutelyMapper.xml +++ b/src/main/resources/mapper/HistoryMinutelyMapper.xml @@ -53,6 +53,9 @@ <if test="monitorPointId != null"> AND mp.id = #{monitorPointId} </if> + <if test="professionId != null"> + AND d.profession_id = #{professionId} + </if> ) </if> diff --git a/src/main/resources/mapper/SensorMapper.xml b/src/main/resources/mapper/SensorMapper.xml index 00e3a23..88cb11d 100644 --- a/src/main/resources/mapper/SensorMapper.xml +++ b/src/main/resources/mapper/SensorMapper.xml @@ -62,6 +62,9 @@ <if test="mac != null"> AND d.mac = #{mac} </if> + <if test="professionId != null"> + AND d.profession_id = #{professionId} + </if> </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0