Kaynağa Gözat

停水公告 新增列表添加额外信息 新增时额外处理 新增通过泵站ID或者小区ID查询对应的泵站-小区数据

王苗苗 1 hafta önce
ebeveyn
işleme
2cfbd5e673

+ 15 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/TCutOffWaterController.java

@@ -2,6 +2,10 @@ package com.slibra.web.controller.business;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.slibra.business.res.CutOffExtraRes;
+import com.slibra.common.core.domain.R;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -27,6 +31,7 @@ import com.slibra.common.core.page.TableDataInfo;
  * @author slibra
  * @date 2024-11-05
  */
+@Slf4j
 @RestController
 @RequestMapping("/business/water")
 public class TCutOffWaterController extends BaseController
@@ -103,4 +108,14 @@ public class TCutOffWaterController extends BaseController
     {
         return toAjax(tCutOffWaterService.deleteTCutOffWaterByIds(ids));
     }
+
+    /**
+     * 根据类型和小区ID/泵站ID 获取要添加停水公告明细的额外信息
+     * @return
+     */
+    @GetMapping("/getExtraListByType")
+    public R<List<CutOffExtraRes>> getExtraListByType(int type, String id){
+        log.info("进入了 根据类型和小区ID/泵站ID 获取要添加停水公告明细的额外信息 接口,请求参数为:类型{}\nID:{}", type, id);
+        return R.ok(this.tCutOffWaterService.getExtraListByType(type, id));
+    }
 }

+ 19 - 4
slibra-admin/src/main/java/com/slibra/web/controller/business/TPumpingStationController.java

@@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.alibaba.fastjson2.JSON;
 import com.slibra.business.domain.TNeighborhood;
 import com.slibra.business.mapper.TNeighborhoodMapper;
+import com.slibra.business.mapper.TPumpingStationMapper;
 import com.slibra.business.req.NeighbourhoodNumberAndAddFlagReq;
 import com.slibra.business.res.NeighbourhoodNumberAndAddFlag;
 import com.slibra.business.service.ITNeighborhoodService;
@@ -48,6 +49,9 @@ public class TPumpingStationController extends BaseController
     @Autowired
     private TNeighborhoodMapper tNeighborhoodMapper;
 
+    @Autowired
+    private TPumpingStationMapper tPumpingStationMapper;
+
     /**
      * 查询泵站列表
      */
@@ -119,13 +123,24 @@ public class TPumpingStationController extends BaseController
     }
 
     /**
-     * 获取所有的小区
+     * 获取所有的小区(简单信息 没有查询复杂数据)
      * @return
      */
-    @GetMapping("/getNeighbourhoodList")
-    public R<List<TNeighborhood>> getNeighbourhoodList(){
+    @GetMapping("/getSimpleNeighbourhoodList")
+    public R<List<TNeighborhood>> getSimpleNeighbourhoodList(TNeighborhood tNeighborhood){
         log.info("进入了 获取小区列表基本信息 接口");
-        return R.ok(this.tNeighborhoodMapper.selectTNeighborhoodList(null));
+        return R.ok(this.tNeighborhoodMapper.selectTNeighborhoodList(tNeighborhood));
+    }
+
+
+    /**
+     * 获取所有的泵站(简单信息 没有查询复杂数据)
+     * @return
+     */
+    @GetMapping("/getSimplePumpingStationList")
+    public R<List<TPumpingStation>> getSimplePumpingStationList(TPumpingStation tPumpingStation){
+        log.info("进入了 获取所有的泵站基本信息 接口");
+        return R.ok(this.tPumpingStationMapper.selectTPumpingStationList(tPumpingStation));
     }
 
 

+ 14 - 4
slibra-system/src/main/java/com/slibra/business/domain/TCutOffWater.java

@@ -1,7 +1,10 @@
 package com.slibra.business.domain;
 
 import java.util.Date;
+import java.util.List;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.slibra.business.res.CutOffExtraRes;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -29,13 +32,13 @@ public class TCutOffWater extends BaseEntity
     private Long id;
 
     /** 停水开始时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "停水开始时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "停水开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date timeBegin;
 
     /** 停水截止时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "停水截止时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "停水截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date timeEnd;
 
     /** 停水原因 */
@@ -59,4 +62,11 @@ public class TCutOffWater extends BaseEntity
     /** 小区的名字 */
     private String neighbourhoodName;
 
+    //停水状态
+    private int status;//0未知 1待停水  2停水中  3已恢复
+
+    //绑定的小区-泵站信息列表
+    private List<CutOffExtraRes> extraResList;
+
+
 }

+ 3 - 3
slibra-system/src/main/java/com/slibra/business/domain/TCutOffWaterExtra.java

@@ -28,15 +28,15 @@ public class TCutOffWaterExtra extends BaseEntity
 
     /** 停水信息表ID */
     @Excel(name = "停水信息表ID")
-    private String cutOffWaterId;
+    private Long cutOffWaterId;
 
     /** 小区ID */
     @Excel(name = "小区ID")
-    private String neighborhoodId;
+    private Long neighborhoodId;
 
     /** 泵站ID */
     @Excel(name = "泵站ID")
-    private String pumpingStationId;
+    private Long pumpingStationId;
 
     /** 删除标志(0代表存在 2代表删除) */
     private Long delFlag;

+ 10 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TCutOffWaterMapper.java

@@ -2,6 +2,8 @@ package com.slibra.business.mapper;
 
 import java.util.List;
 import com.slibra.business.domain.TCutOffWater;
+import com.slibra.business.res.CutOffExtraRes;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 停水信息Mapper接口
@@ -72,4 +74,12 @@ public interface TCutOffWaterMapper
      * @return
      */
     List<TCutOffWater> getCutOffWaterByNeighbourhoodName(String asrText);
+
+    List<CutOffExtraRes> selectgetExtraListByPumpingStationId(String id);
+
+    List<CutOffExtraRes> selectgetExtraListByNeighbourhoodId(String id);
+
+    List<CutOffExtraRes> selectgetExtraListByPumpingStationIdAndNeighbourhoodId(@Param("pumpingStationId") Long pumpingStationId, @Param("neighborhoodId") Long neighborhoodId);
+
+    String getDistinctNamesUnionById(Long id);
 }

+ 24 - 0
slibra-system/src/main/java/com/slibra/business/req/CutOffExtraReq.java

@@ -0,0 +1,24 @@
+package com.slibra.business.req;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class CutOffExtraReq {
+
+
+    //泵站ID
+    private Long pumpingStationId;
+
+    //小区ID
+    private Long neighbourhoodId;
+
+
+
+}

+ 38 - 0
slibra-system/src/main/java/com/slibra/business/res/CutOffExtraRes.java

@@ -0,0 +1,38 @@
+package com.slibra.business.res;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class CutOffExtraRes {
+
+
+    //泵站ID
+    private Long pumpingStationId;
+
+    //泵站名称
+    private String pumpingStationName;
+
+    //泵站地址
+    private String pumpingStationAddress;
+
+    //小区ID
+    private Long neighbourhoodId;
+
+    //小区名称
+    private String neighbourhoodName;
+
+    //小区地址
+    private String neighbourhoodAddress;
+
+    //楼号
+    private String neighbourhoodNumberNames;
+
+
+}

+ 3 - 0
slibra-system/src/main/java/com/slibra/business/service/ITCutOffWaterService.java

@@ -2,6 +2,7 @@ package com.slibra.business.service;
 
 import java.util.List;
 import com.slibra.business.domain.TCutOffWater;
+import com.slibra.business.res.CutOffExtraRes;
 
 /**
  * 停水信息Service接口
@@ -58,4 +59,6 @@ public interface ITCutOffWaterService
      * @return 结果
      */
     public int deleteTCutOffWaterById(Long id);
+
+    List<CutOffExtraRes> getExtraListByType(int type, String id);
 }

+ 111 - 4
slibra-system/src/main/java/com/slibra/business/service/impl/TCutOffWaterServiceImpl.java

@@ -1,12 +1,20 @@
 package com.slibra.business.service.impl;
 
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import com.slibra.business.domain.TCutOffWaterExtra;
+import com.slibra.business.domain.TNeighborhood;
+import com.slibra.business.domain.TPumpingStation;
+import com.slibra.business.mapper.*;
+import com.slibra.business.res.CutOffExtraRes;
 import com.slibra.common.utils.DateUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.slibra.business.mapper.TCutOffWaterMapper;
 import com.slibra.business.domain.TCutOffWater;
 import com.slibra.business.service.ITCutOffWaterService;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 /**
@@ -21,6 +29,18 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
     @Autowired
     private TCutOffWaterMapper tCutOffWaterMapper;
 
+    @Autowired
+    private TNeighborhoodMapper tNeighborhoodMapper;
+
+    @Autowired
+    private TPumpingStationMapper tPumpingStationMapper;
+
+    @Autowired
+    private TPumpingStationNeighbourhoodNumberMapper tPumpingStationNeighbourhoodNumberMapper;
+
+    @Autowired
+    private TCutOffWaterExtraMapper tCutOffWaterExtraMapper;
+
     /**
      * 查询停水信息
      * 
@@ -44,11 +64,54 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
     {
         List<TCutOffWater> tCutOffWaters = tCutOffWaterMapper.selectTCutOffWaterList(tCutOffWater);
         if(!CollectionUtils.isEmpty(tCutOffWaters)){
-            //额外返回 停水范围(小区)和 停水状态字段
+            for (TCutOffWater cutOffWater : tCutOffWaters) {
+                //额外返回 停水范围(小区)和 停水状态字段
+                this.addExtra(cutOffWater);
+            }
         }
         return tCutOffWaters;
     }
 
+    /**
+     * 额外返回 泵站-小区列表 停水范围(小区)和 停水状态字段
+     * @param tCutOffWater
+     */
+    private void addExtra(TCutOffWater tCutOffWater) {
+        Long id = tCutOffWater.getId();
+        // 停水状态
+        Date nowDate = DateUtils.getNowDate();
+        Date timeBegin = tCutOffWater.getTimeBegin();
+        Date timeEnd = tCutOffWater.getTimeEnd();
+        if(nowDate.after(timeEnd))
+            tCutOffWater.setStatus(3);
+        if(nowDate.before(timeBegin))
+            tCutOffWater.setStatus(1);
+        if(nowDate.after(timeBegin) && nowDate.before(timeEnd))
+            tCutOffWater.setStatus(2);
+        //停水的所有的小区的名字
+        tCutOffWater.setNeighbourhoodName(this.tCutOffWaterMapper.getDistinctNamesUnionById(id));
+        //泵站-小区列表
+        //获取配置的关联表
+        List<CutOffExtraRes> extraResList = new ArrayList<>();
+        List<TCutOffWaterExtra> tCutOffWaterExtras = this.tCutOffWaterExtraMapper.selectTCutOffWaterExtraList(TCutOffWaterExtra.builder().cutOffWaterId(id).build());
+        if(!CollectionUtils.isEmpty(tCutOffWaterExtras)){
+            for (TCutOffWaterExtra tCutOffWaterExtra : tCutOffWaterExtras) {
+                List<CutOffExtraRes> tempResult = this.tCutOffWaterMapper.selectgetExtraListByPumpingStationIdAndNeighbourhoodId(tCutOffWaterExtra.getPumpingStationId(), tCutOffWaterExtra.getNeighborhoodId());
+                //合并数据(安装小区或者泵站一个维度即可)
+                Map<Long, List<CutOffExtraRes>> collect = tempResult.stream().collect(Collectors.groupingBy(CutOffExtraRes::getPumpingStationId));
+                collect.forEach((key, value) ->{
+                    CutOffExtraRes cutOffExtraResTemp = value.get(0);
+                    CutOffExtraRes cutOffExtraRes = new CutOffExtraRes();
+                    BeanUtils.copyProperties(cutOffExtraResTemp, cutOffExtraRes);
+                    cutOffExtraRes.setNeighbourhoodNumberNames(value.stream().map(CutOffExtraRes::getNeighbourhoodNumberNames).collect(Collectors.joining("、")));
+                    extraResList.add(cutOffExtraRes);
+                });
+            }
+        }
+
+        tCutOffWater.setExtraResList(extraResList);
+    }
+
     /**
      * 新增停水信息
      * 
@@ -56,10 +119,23 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
      * @return 结果
      */
     @Override
+    @Transactional
     public int insertTCutOffWater(TCutOffWater tCutOffWater)
     {
         tCutOffWater.setCreateTime(DateUtils.getNowDate());
-        return tCutOffWaterMapper.insertTCutOffWater(tCutOffWater);
+        int i = tCutOffWaterMapper.insertTCutOffWater(tCutOffWater);
+        //保存关联表
+        List<CutOffExtraRes> extraResList = tCutOffWater.getExtraResList();
+        if(!CollectionUtils.isEmpty(extraResList)){
+            for (CutOffExtraRes cutOffExtraRes : extraResList) {
+                TCutOffWaterExtra tCutOffWaterExtra = new TCutOffWaterExtra();
+                tCutOffWaterExtra.setCutOffWaterId(tCutOffWater.getId());
+                tCutOffWaterExtra.setPumpingStationId(cutOffExtraRes.getPumpingStationId());
+                tCutOffWaterExtra.setNeighborhoodId(cutOffExtraRes.getNeighbourhoodId());
+                this.tCutOffWaterExtraMapper.insertTCutOffWaterExtra(tCutOffWaterExtra);
+            }
+        }
+        return i;
     }
 
     /**
@@ -98,4 +174,35 @@ public class TCutOffWaterServiceImpl implements ITCutOffWaterService
     {
         return tCutOffWaterMapper.deleteTCutOffWaterById(id);
     }
+
+    @Override
+    public List<CutOffExtraRes> getExtraListByType(int type, String id) {
+        List<CutOffExtraRes> result = new ArrayList<>();
+        List<CutOffExtraRes> tempResult = new ArrayList<>();
+        //判断类型
+        if(0 == type){//根据泵站添加
+            tempResult = this.tCutOffWaterMapper.selectgetExtraListByPumpingStationId(id);
+            //按照小区分组合并
+            Map<Long, List<CutOffExtraRes>> collect = tempResult.stream().collect(Collectors.groupingBy(CutOffExtraRes::getNeighbourhoodId));
+            collect.forEach((key, value) ->{
+                CutOffExtraRes cutOffExtraResTemp = value.get(0);
+                CutOffExtraRes cutOffExtraRes = new CutOffExtraRes();
+                BeanUtils.copyProperties(cutOffExtraResTemp, cutOffExtraRes);
+                cutOffExtraRes.setNeighbourhoodNumberNames(value.stream().map(CutOffExtraRes::getNeighbourhoodNumberNames).collect(Collectors.joining("、")));
+                result.add(cutOffExtraRes);
+            });
+        }else{//根据小区添加
+            tempResult = this.tCutOffWaterMapper.selectgetExtraListByNeighbourhoodId(id);
+            //按照泵站分组合并
+            Map<Long, List<CutOffExtraRes>> collect = tempResult.stream().collect(Collectors.groupingBy(CutOffExtraRes::getPumpingStationId));
+            collect.forEach((key, value) ->{
+                CutOffExtraRes cutOffExtraResTemp = value.get(0);
+                CutOffExtraRes cutOffExtraRes = new CutOffExtraRes();
+                BeanUtils.copyProperties(cutOffExtraResTemp, cutOffExtraRes);
+                cutOffExtraRes.setNeighbourhoodNumberNames(value.stream().map(CutOffExtraRes::getNeighbourhoodNumberNames).collect(Collectors.joining("、")));
+                result.add(cutOffExtraRes);
+            });
+        }
+        return result;
+    }
 }

+ 60 - 0
slibra-system/src/main/resources/mapper/business/TCutOffWaterMapper.xml

@@ -128,4 +128,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND NOW() BETWEEN time_begin
             AND time_end
     </select>
+    
+    <select id="selectgetExtraListByPumpingStationId" resultType="com.slibra.business.res.CutOffExtraRes">
+        SELECT
+            b.id pumpingStationId,
+            b.`name` pumpingStationName,
+            b.address pumpingStationAddress,
+            c.id neighbourhoodId,
+            c.`name` neighbourhoodName,
+            c.address neighbourhoodAddress,
+            d.`name` neighbourhoodNumberNames
+        FROM
+            ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE pumping_station_id = #{id} AND del_flag = 0 ) a
+                INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
+                INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
+                INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
+    </select>
+
+
+    <select id="selectgetExtraListByNeighbourhoodId" resultType="com.slibra.business.res.CutOffExtraRes">
+        SELECT
+            b.id pumpingStationId,
+            b.`name` pumpingStationName,
+            b.address pumpingStationAddress,
+            c.id neighbourhoodId,
+            c.`name` neighbourhoodName,
+            c.address neighbourhoodAddress,
+            d.`name` neighbourhoodNumberNames
+        FROM
+            ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE neighborhood_id = #{id} AND del_flag = 0 ) a
+                INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
+                INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
+                INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
+    </select>
+
+    <select id="selectgetExtraListByPumpingStationIdAndNeighbourhoodId" resultType="com.slibra.business.res.CutOffExtraRes">
+        SELECT
+            b.id pumpingStationId,
+            b.`name` pumpingStationName,
+            b.address pumpingStationAddress,
+            c.id neighbourhoodId,
+            c.`name` neighbourhoodName,
+            c.address neighbourhoodAddress,
+            d.`name` neighbourhoodNumberNames
+        FROM
+            ( SELECT * FROM t_pumping_station_neighbourhood_number WHERE pumping_station_id = #{pumpingStationId} AND neighborhood_id = #{neighborhoodId} AND del_flag = 0 ) a
+                INNER JOIN t_pumping_station b ON a.pumping_station_id = b.id AND b.del_flag = 0
+                INNER JOIN t_neighborhood c ON a.neighborhood_id = c.id AND c.del_flag = 0
+                INNER JOIN t_neighborhood_building d on a.neighborhood_building_id = d.id AND d.del_flag = 0
+    </select>
+
+
+    <select id="getDistinctNamesUnionById" resultType="string">
+        SELECT GROUP_CONCAT(DISTINCT b.`name`  SEPARATOR ', ')
+        FROM
+            t_cut_off_water_extra a
+                INNER JOIN t_neighborhood b ON a.neighborhood_id = b.id
+                AND a.del_flag = 0
+                AND b.del_flag = 0
+        WHERE a.cut_off_water_id = #{id}
+    </select>
 </mapper>