USER-20250308PZ\Administrator 8 ay önce
ebeveyn
işleme
c43ab40b34

+ 8 - 0
bus-biz/src/main/java/bus/mapper/BNoticeInfoMapper.java

@@ -5,6 +5,7 @@ import bus.model.dto.page.BNoticeInfoPageDto;
 import bus.model.vo.BNoticeInfoVo;
 import bus.model.po.*;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import java.util.List;
 
@@ -18,4 +19,11 @@ import java.util.List;
 public interface BNoticeInfoMapper extends BaseMapper<BNoticeInfoPo> {
 
     List<BNoticeInfoDto> list(BNoticeInfoPageDto dto);
+
+    /**
+     * 获取公告列表(包含已读状态)
+     * @param userId 用户ID
+     * @return 公告列表
+     */
+    List<BNoticeInfoDto> getNoticeInfoList(@Param("userId") String userId);
 }

+ 8 - 1
bus-biz/src/main/java/bus/service/BNoticeUserService.java

@@ -1,5 +1,6 @@
 package bus.service;
 
+import bus.model.dto.BNoticeInfoDto;
 import bus.model.dto.BNoticeUserDto;
 import bus.model.dto.BNoticeUserPageDto;
 import bus.model.vo.BNoticeUserVo;
@@ -27,7 +28,13 @@ public interface BNoticeUserService extends IService<BNoticeUserPo> {
     /**
      *
      * 当前用户设置所有已读
-     * @param dto
+     * @param
      */
     void addNoticeUserAll();
+
+    /**
+     * 查询 公告(包括是否已读)
+     * @return 公告列表,包含已读状态
+     */
+    List<BNoticeInfoDto> getNoticeInfoList();
 }

+ 2 - 2
bus-biz/src/main/java/bus/service/impl/BBusInfoServiceImpl.java

@@ -196,7 +196,7 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
     public BBusTrackInfoDto getTrackInfo(String busId) {
         BBusTrackInfoDto dto = new BBusTrackInfoDto();
         // 1. 查询车辆所在路线,获取最新分配的路线
-        QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper<>();
+       QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("bus_id", busId)
                 .eq("is_delete", 0)
                 .orderByDesc("create_time")  // 按创建时间倒序
@@ -423,7 +423,7 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
      */
     private BStationInfoPo findNearestStation(double lat, double lon, List<BStationInfoPo> stations) {
         if (CollectionUtil.isEmpty(stations)) {
-            return null;
+        return null;
         }
         
         BStationInfoPo nearest = null;

+ 15 - 0
bus-biz/src/main/java/bus/service/impl/BNoticeUserServiceImpl.java

@@ -1,11 +1,14 @@
 package bus.service.impl;
 
 import bus.model.SnowflakeUtil;
+import bus.model.dto.BNoticeInfoDto;
 import bus.model.dto.BNoticeUserDto;
 import bus.model.dto.BNoticeUserPageDto;
+import bus.model.po.BNoticeInfoPo;
 import bus.model.vo.BNoticeUserVo;
 import bus.model.po.BNoticeUserPo;
 import bus.mapper.BNoticeUserMapper;
+import bus.mapper.BNoticeInfoMapper;
 
 import bus.service.BNoticeUserService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -16,6 +19,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.BeanUtils;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * @Program: bus
@@ -30,6 +34,8 @@ public class BNoticeUserServiceImpl extends ServiceImpl<BNoticeUserMapper,BNotic
     private BNoticeUserMapper bNoticeUserMapper;
     @Autowired
     private SnowflakeUtil snowflakeUtil;
+    @Autowired
+    private BNoticeInfoMapper bNoticeInfoMapper;
 
 
     @Override
@@ -71,4 +77,13 @@ public class BNoticeUserServiceImpl extends ServiceImpl<BNoticeUserMapper,BNotic
             }
         }
     }
+
+    @Override
+    public List<BNoticeInfoDto> getNoticeInfoList() {
+        // 获取当前用户信息
+        ExtInfo extInfo = CurrentUserHolder.get();
+        String userId = extInfo.getUserId();
+        // 使用SQL直接查询带有已读状态的公告列表
+        return bNoticeInfoMapper.getNoticeInfoList(userId);
+    }
 }

+ 18 - 0
bus-biz/src/main/resources/mapper/BNoticeInfoMapper.xml

@@ -32,7 +32,25 @@
     </if>
   </where>
    order by pub_time desc
+ </select>
 
+ <select id="getNoticeInfoList" resultType="bus.model.dto.BNoticeInfoDto">
+   SELECT 
+     a.id,
+     a.title,
+     a.content,
+     a.type,
+     a.pub_time,
+     a.status,
+     CASE WHEN b.id IS NOT NULL THEN '1' ELSE '0' END as is_read
+   FROM 
+     b_notice_info a
+     LEFT JOIN b_notice_user b ON a.id = b.notice_id AND b.user_id = #{userId}
+   WHERE 
+     a.status = '1' 
+     AND a.is_delete = 0
+   ORDER BY 
+     a.pub_time DESC
  </select>
 
 </mapper>

+ 2 - 0
bus-common/src/main/java/bus/model/dto/BNoticeInfoDto.java

@@ -31,5 +31,7 @@ public class BNoticeInfoDto{
     @ApiModelProperty("状态 0警用 1启用")
     @NotNull(message = "状态不能为空")
     private String status;
+    @NotNull(message = "是否已读 0未读 1已读")
+    private String isRead;
 
 }

+ 0 - 39
bus-web/src/main/java/bus/controller/biz/BBusLocationController.java

@@ -1,39 +0,0 @@
-package bus.controller.biz;
-
-import bus.model.dto.BBusTrackByBusDto;
-import bus.model.dto.BTrackLocalDto;
-import bus.model.dto.req.BTrackLocalReqDto;
-import bus.service.BBusInfoService;
-import com.qzwisdom.qzframework.core.tool.base.controller.BaseController;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.math.BigDecimal;
-
-/**
- * @Program: bus
- * @Description: 车辆位置追踪接口
- * @Author: zy
- * @Date: 2025-03-01 10:04:08
- **/
-@Slf4j
-@CrossOrigin
-@RestController
-@Api(tags = "车辆位置追踪接口")
-@RequestMapping(value="/bBusLocation")
-public class BBusLocationController implements BaseController {
-
-    @Autowired
-    private BBusInfoService bBusInfoService;
-
-
-
-    @ApiOperation("获取车辆实时追踪信息")
-    @PostMapping(value = "getLocalBusInfo")
-    public BTrackLocalDto getLocalBusInfo(@RequestBody BTrackLocalReqDto reqDto) {
-        return bBusInfoService.getLocalBusInfo(reqDto);
-    }
-} 

+ 18 - 2
bus-web/src/main/java/bus/controller/biz/BNoticeUserController.java

@@ -1,5 +1,8 @@
 package bus.controller.biz;
 
+import bus.model.BaseEntity;
+import bus.model.dto.BNoticeInfoDto;
+import bus.model.dto.page.BNoticeInfoPageDto;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageSerializable;
 import bus.model.dto.BNoticeUserDto;
@@ -13,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import com.qzwisdom.qzframework.core.tool.base.controller.BaseController;
 
+import java.util.List;
 
 
 /**
@@ -31,17 +35,29 @@ public class BNoticeUserController implements BaseController {
     @Autowired
     private BNoticeUserService bNoticeUserService;
 
-    @ApiOperation("添加通知用户")
+    @ApiOperation("查看后已读")
     @PostMapping("/add")
     public void add(@RequestBody BNoticeUserDto dto) {
         bNoticeUserService.addNoticeUser(dto);
     }
 
-    @ApiOperation("批量添加通知用户")
+    @ApiOperation("一键已读")
     @PostMapping("/addAll")
     public void addAll() {
         bNoticeUserService.addNoticeUserAll();
     }
 
+    /**
+     * 查询 公告(包括是否已读)
+     * @return 公告列表,包含已读状态
+     */
+    @ApiOperation("小程序公告")
+    @PostMapping("/getNoticeInfoList")
+    public PageSerializable<BNoticeInfoDto> getNoticeInfoList(@RequestBody BaseEntity dto){
+        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
+        List<BNoticeInfoDto> noticeInfoList = bNoticeUserService.getNoticeInfoList();
+        return new PageSerializable<>(noticeInfoList);
+    }
+
 
 }