Browse Source

feat(杆塔查询模板): 添加对接两个接口

gjs 3 years ago
parent
commit
cebfa70860

+ 18 - 0
src/main/java/com/macro/mall/tiny/modules/business/controller/KrBLineController.java

@@ -38,6 +38,14 @@ public class KrBLineController {
         return CommonResult.success(line);
     }
 
+    @ApiOperation("按照ID获取线路(含杆塔)")
+    @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
+    @ResponseBody
+    public CommonResult<KrBLine> getItemDetail(@PathVariable Long id) {
+        KrBLine line = krBLineService.findById(id);
+        return CommonResult.success(line);
+    }
+
     @ApiOperation("获取线路列表")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @ResponseBody
@@ -56,6 +64,16 @@ public class KrBLineController {
         return CommonResult.success(lineList);
     }
 
+    @ApiOperation("按照关键字查询线路列表(不含杆塔)")
+    @RequestMapping(value = "/findByKeySimple", method = RequestMethod.GET)
+    @ResponseBody
+    public CommonResult<List<KrBLine>> findByKeySimple(@RequestParam @PathParam(value = "key") String key,
+                                                 @RequestParam @PathParam(value = "provinceId") String provinceId,
+                                                 @RequestParam @PathParam(value = "cityId") String cityId) {
+        List<KrBLine> lineList = krBLineService.findByKeySimple(key, provinceId, cityId);
+        return CommonResult.success(lineList);
+    }
+
     @ApiOperation("获取线路文件资料")
     @RequestMapping(value = "/getFile/{id}", method = RequestMethod.GET)
     @ResponseBody

+ 4 - 0
src/main/java/com/macro/mall/tiny/modules/business/mapper/KrBLineMapper.java

@@ -16,7 +16,11 @@ import java.util.List;
  */
 public interface KrBLineMapper extends BaseMapper<KrBLine> {
 
+    KrBLine findById(@Param("id") Long id);
+
     List<KrBLine> findListMulti();
 
     List<KrBLine> findListByKey(@Param("key") String key, @Param("provinceId") String provinceId, @Param("cityId") String cityId);
+
+    List<KrBLine> findByKeySimple(@Param("key") String key, @Param("provinceId") String provinceId, @Param("cityId") String cityId);
 }

+ 4 - 0
src/main/java/com/macro/mall/tiny/modules/business/service/KrBLineService.java

@@ -16,9 +16,13 @@ import java.util.List;
  */
 public interface KrBLineService extends IService<KrBLine> {
 
+    KrBLine findById(Long id);
+
     List<KrBLine> getLineList();
 
     List<KrBLine> findByKey(String key, String provinceId, String cityId);
 
+    List<KrBLine> findByKeySimple(String key, String provinceId, String cityId);
+
     List<BFile> getFile(Long id);
 }

+ 22 - 0
src/main/java/com/macro/mall/tiny/modules/business/service/impl/KrBLineServiceImpl.java

@@ -46,6 +46,11 @@ public class KrBLineServiceImpl extends ServiceImpl<KrBLineMapper, KrBLine> impl
     KrBRegionProvinceMapper krBRegionProvinceMapper;
 
     @Override
+    public KrBLine findById(Long id) {
+        return krBLineMapper.findById(id);
+    }
+
+    @Override
     public List<KrBLine> getLineList() {
         List<KrBLine> lineList = krBLineCacheService.getLineList();
         if (CollUtil.isNotEmpty(lineList)) {
@@ -78,6 +83,23 @@ public class KrBLineServiceImpl extends ServiceImpl<KrBLineMapper, KrBLine> impl
     }
 
     @Override
+    public List<KrBLine> findByKeySimple(String key, String provinceId, String cityId) {
+        List<KrBLine> lineList = krBLineMapper.findByKeySimple(key, provinceId, cityId);
+        if (StringUtils.isNotBlank(key)) {
+            lineList.forEach(line -> {
+                if (!line.getProvince().contains(key) && !line.getLineName().contains(key)) {
+                    String keyLow = key.toLowerCase();
+                    Set<String> matchShapeList = line.getTowerList().stream()
+                            .filter(tower -> tower.getTowerNumber().toLowerCase().contains(keyLow))
+                            .map(KrBTower::getTowerNumber).collect(Collectors.toSet());
+                    line.setMatchShapeList(matchShapeList);
+                }
+            });
+        }
+        return lineList;
+    }
+
+    @Override
     public List<BFile> getFile(Long id) {
         boolean auth = AuthUtil.checkAccess(AuthUtil.ACCESS);
         KrBLine line = krBLineMapper.selectById(id);

+ 2 - 0
src/main/resources/application.yml

@@ -60,6 +60,8 @@ secure:
       - /admin/logout
       - /
       - /index.html
+      - /line/findByKeySimple
+      - /line/detail/**
 upload:
   temp-path: ./temp/
   path: ./upload/ #文件上传路径

+ 71 - 0
src/main/resources/mapper/business/KrBLineMapper.xml

@@ -2,6 +2,49 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.macro.mall.tiny.modules.business.mapper.KrBLineMapper">
 
+    <select id="findById" resultMap="BaseResultMap">
+        SELECT l.id,
+               l.province_id,
+               p.name province,
+               l.city_id,
+               c.name city,
+               l.line_name,
+               l.voltage,
+               l.line_status,
+               l.service_begintime,
+               l.begin_tower,
+               l.end_tower,
+               l.creator_id,
+               l.create_time,
+               t.id                t_id,
+               t.line_id           t_line_id,
+               t.tower_index       t_tower_index,
+               t.tower_name        t_tower_name,
+               t.tower_number      t_tower_number,
+               t.hardware_type     t_hardware_type,
+               t.longitude         t_longitude,
+               t.latitude          t_latitude,
+               t.type              t_type,
+               t.is_station        t_is_station,
+               t.is_weather        t_is_weather,
+               t.circuit           t_circuit,
+               t.height            t_height,
+               t.practical_height  t_practical_height,
+               t.corner_direction  t_corner_direction,
+               t.corner_number     t_corner_number,
+               t.span              t_span,
+               t.service_begintime t_service_begintime,
+               t.remark            t_remark,
+               t.has_file          t_has_file,
+               t.create_time       t_create_time
+        FROM kr_b_line l
+                 LEFT JOIN kr_b_region_province p ON l.province_id = p.province_id
+                 LEFT JOIN kr_b_region_city c ON l.city_id = c.city_id
+                 LEFT JOIN kr_b_tower t ON l.id = t.line_id
+        WHERE  l.id = #{id}
+        ORDER BY tower_index;
+    </select>
+
     <select id="findListMulti" resultMap="BaseResultMap">
         SELECT l.id,
                l.province_id,
@@ -96,6 +139,34 @@
 
     </select>
 
+    <select id="findByKeySimple" resultMap="BaseResultMap">
+        SELECT l.id,
+        l.province_id,
+        p.name province,
+        l.city_id,
+        c.name city,
+        l.line_name,
+        l.voltage,
+        l.line_status,
+        l.service_begintime,
+        l.begin_tower,
+        l.end_tower,
+        l.creator_id,
+        l.create_time,
+        FROM kr_b_line l
+        LEFT JOIN kr_b_region_province p ON l.province_id = p.province_id
+        LEFT JOIN kr_b_region_city c ON l.city_id = c.city_id
+        WHERE l.line_name LIKE concat('%', #{key}, '%')
+        OR p.name like concat('%', #{key}, '%')
+        <if test="provinceId != null and provinceId != ''">
+            AND l.province_id = #{provinceId}
+        </if>
+        <if test="cityId != null and cityId != ''">
+            AND l.city_id = #{cityId}
+        </if>
+
+    </select>
+
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.macro.mall.tiny.modules.business.model.KrBLine">
         <id column="id" property="id"/>