suntianwu 3 lat temu
rodzic
commit
4857e1c6fc

+ 23 - 5
src/main/java/com/care/bigscreen/controller/StStationController.java

@@ -12,8 +12,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.List;
 
 
 /**
@@ -79,9 +77,7 @@ public class StStationController {
     )
     public Result<BigScreenStatisticsVO> selectBigScreenStatisticsByStation(Long stationId) {
         try {
-            List<Long> stationIds = new ArrayList<>();
-            stationIds.add(stationId);
-            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatistics(stationIds,null);
+            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatistics(stationId,null);
             return Result.success(bigScreenStatisticsVO);
         } catch (Exception e) {
             log.error("站点统计查询出现异常",e);
@@ -89,5 +85,27 @@ public class StStationController {
         }
     }
 
+    /**
+     * 根据经纬度查询
+     */
+    @ApiOperation(value = "根据经纬度查询", notes = "根据经纬度查询")
+    @GetMapping("/selectBigScreenStatisticsByLongitudeLatitude")
+    @ApiImplicitParams(
+            {
+                    @ApiImplicitParam(name = "longitudeLeftUp", value = "左上经度", dataTypeClass = String.class),
+                    @ApiImplicitParam(name = "latitudeLeftUp", value = "左上维度", dataTypeClass = String.class),
+                    @ApiImplicitParam(name = "longitudeRightDown", value = "右下经度", dataTypeClass = String.class),
+                    @ApiImplicitParam(name = "latitudeRightDown", value = "右下维度", dataTypeClass = String.class)
+            }
+    )
+    public Result<BigScreenStatisticsVO> selectBigScreenStatisticsByLongitudeLatitude(String longitudeLeftUp, String latitudeLeftUp,String longitudeRightDown,String latitudeRightDown) {
+        try {
+            BigScreenStatisticsVO bigScreenStatisticsVO =  stStationService.selectBigScreenStatisticsByLongitudeLatitude(longitudeLeftUp,latitudeLeftUp,longitudeRightDown,latitudeRightDown);
+            return Result.success(bigScreenStatisticsVO);
+        } catch (Exception e) {
+            log.error("站点统计查询出现异常",e);
+            return Result.error("系统错误,站点统计查询失败");
+        }
+    }
 
 }

+ 6 - 1
src/main/java/com/care/bigscreen/mapper/StStationMapper.java

@@ -21,7 +21,12 @@ public interface StStationMapper extends BaseMapper<StStation> {
      * 大屏统计查询
      * @return 搜索符合条件的大屏统计数据
      */
-    BigScreenStatisticsVO selectBigScreenStatistics(@Param("stationIds") List<Long> stationIds, @Param("orgId") Long orgId);
+    BigScreenStatisticsVO selectBigScreenStatistics(@Param("stationId") Long stationId, @Param("orgId") Long orgId);
 
+    /**
+     * 大屏统计查询
+     * @return 根据经纬度范围搜索符合条件的大屏统计数据
+     */
+    BigScreenStatisticsVO selectBigScreenStatisticsByLongitudeLatitude(@Param("longitudeLeftUp") String longitudeLeftUp,@Param("latitudeLeftUp") String latitudeLeftUp,@Param("longitudeRightDown") String longitudeRightDown,@Param("latitudeRightDown")String latitudeRightDown);
 
 }

+ 6 - 7
src/main/java/com/care/bigscreen/service/StStationService.java

@@ -1,13 +1,7 @@
 package com.care.bigscreen.service;
 
 import com.care.bigscreen.vo.BigScreenStatisticsVO;
-import com.care.common.vo.PageResVO;
-import com.care.dic.entity.RimsDictionaries;
-import com.care.util.PageUtil;
-import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
-import java.util.Map;
 
 
 /**
@@ -22,6 +16,11 @@ public interface StStationService {
      * 大屏统计查询
      * @return 搜索符合条件的大屏统计数据
      */
-    BigScreenStatisticsVO selectBigScreenStatistics(List<Long> stationIds, Long orgId);
+    BigScreenStatisticsVO selectBigScreenStatistics(Long stationId, Long orgId);
+    /**
+     * 大屏统计查询
+     * @return 根据经纬度范围搜索符合条件的大屏统计数据
+     */
+    BigScreenStatisticsVO selectBigScreenStatisticsByLongitudeLatitude(String longitudeLeftUp,String latitudeLeftUp,String longitudeRightDown,String latitudeRightDown);
 
 }

+ 11 - 3
src/main/java/com/care/bigscreen/service/impl/StStationServiceImpl.java

@@ -7,7 +7,7 @@ import com.care.bigscreen.vo.BigScreenStatisticsVO;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.*;
+
 
 
 /**
@@ -27,8 +27,16 @@ public class StStationServiceImpl implements StStationService {
      * @return 搜索符合条件的大屏统计数据
      */
     @Override
-    public BigScreenStatisticsVO selectBigScreenStatistics(List<Long> stationIds, Long orgId){
-        return stStationMapper.selectBigScreenStatistics(stationIds,orgId);
+    public BigScreenStatisticsVO selectBigScreenStatistics(Long stationId, Long orgId){
+        return stStationMapper.selectBigScreenStatistics(stationId,orgId);
     }
 
+    /**
+     * 大屏统计查询
+     * @return 根据经纬度范围搜索符合条件的大屏统计数据
+     */
+    @Override
+    public BigScreenStatisticsVO selectBigScreenStatisticsByLongitudeLatitude(String longitudeLeftUp,String latitudeLeftUp,String longitudeRightDown,String latitudeRightDown) {
+        return stStationMapper.selectBigScreenStatisticsByLongitudeLatitude(longitudeLeftUp,latitudeLeftUp,longitudeRightDown,latitudeRightDown);
+    }
 }

+ 6 - 0
src/main/java/com/care/bigscreen/vo/BigScreenStatisticsVO.java

@@ -24,9 +24,15 @@ public class BigScreenStatisticsVO {
     @ApiModelProperty(value = "60至80岁用户数")
     private Long older6080Amount;
 
+    @ApiModelProperty(value = "60至80岁用户数占比")
+    private BigDecimal older6080Rate;
+
     @ApiModelProperty(value = "80岁以上用户数")
     private Long older80AboveAmount;
 
+    @ApiModelProperty(value = "80岁以上用户数占比")
+    private BigDecimal older80AboveRate;
+
     @ApiModelProperty(value = "独居人数")
     private Long aloneLivingAmount;
 

+ 23 - 10
src/main/resources/mybatis/StStationMapper.xml

@@ -2,12 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.care.bigscreen.mapper.StStationMapper">
 
-    <!--多条件分页查询-->
+    <!--查询-->
     <select id="selectBigScreenStatistics" resultType="com.care.bigscreen.vo.BigScreenStatisticsVO">
         SELECT
         sum(older_amount) olderAmount,
         sum(older_60_80_amount) older6080Amount,
+        convert(sum(older_60_80_amount)/sum(older_amount),decimal(20,2)) older6080Rate,
         sum(older_80_above_amount) older80AboveAmount,
+        convert(sum(older_80_above_amount)/sum(older_amount),decimal(20,2)) older80AboveRate,
         sum(alone_living_amount) aloneLivingAmount,
         convert(sum(alone_living_amount)/sum(older_amount),decimal(20,2)) aloneLivingRate,
         sum(no_alone_living_amount) noAloneLivingAmount,
@@ -42,21 +44,32 @@
         sum(seats_amount) seatsAmount,
         convert(sum(seats_online_duration)/3600,decimal(20,2)) seatsOnlineDuration
         FROM st_station t
-
         <where>
             1 = 1
+            <if test="stationId != null and stationId != ''">
+                AND t.station_id = #{stationId}
+            </if>
             <if test="orgId != null and orgId != ''">
                 AND t.org_id = #{orgId}
             </if>
-            <if test="stationIds != null and stationIds.size()>0" >
-                AND t.station_id in
-                <foreach collection="stationIds" item="item" open="(" close=")" separator="," >
-                    #{item}
-                </foreach>
-            </if>
         </where>
-
     </select>
 
-
+    <!--根据经纬度查询-->
+    <select id="selectBigScreenStatisticsByLongitudeLatitude" resultType="com.care.bigscreen.vo.BigScreenStatisticsVO">
+        SELECT
+        sum(older_amount) olderAmount,
+        sum(older_60_80_amount) older6080Amount,
+        convert(sum(older_60_80_amount)/sum(older_amount),decimal(20,2)) older6080Rate,
+        sum(older_80_above_amount) older80AboveAmount,
+        convert(sum(older_80_above_amount)/sum(older_amount),decimal(20,2)) older80AboveRate
+        FROM st_station t
+        <where>
+            t.longitude >= #{longitudeLeftUp} and t.longitude &lt;= #{longitudeRightDown}
+            AND t.latitude &lt;= #{latitudeLeftUp} and t.longitude >= #{latitudeRightDown}
+            <if test="orgId != null and orgId != ''">
+                AND t.org_id = #{orgId}
+            </if>
+        </where>
+    </select>
 </mapper>