xufenglei
2018-05-14 c0d88c1f82394c0374d2d592f4d2bca951d6334e
报表展示 增加行业筛选
8 files modified
61 ■■■■■ changed files
src/main/java/com/moral/controller/DeviceController.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/DeviceMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/DeviceService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/AlarmDailyMapper.xml 3 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/DeviceMapper.xml 32 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/HistoryMinutelyMapper.xml 3 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/SensorMapper.xml 3 ●●●●● patch | view | raw | blame | history
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);
    }
}
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);
}
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);
}
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);
    }
}
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,
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>
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>
        
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>