Ver código fonte

新闻公告添加时状态

phoenix 1 ano atrás
pai
commit
fd9e560eeb

+ 2 - 1
src/main/java/com/xjrsoft/module/oa/controller/NewsController.java

@@ -64,7 +64,8 @@ public class NewsController {
         Wrapper<News> wrapper = Wrappers.<News>query().lambda()
                 .eq(News::getTypeId, dto.getType())
                 .like(StrUtil.isNotBlank(dto.getKeyword()), News::getFullHead, dto.getKeyword())
-                .select(News.class, x -> VoToColumnUtil.fieldsToColumns(NewsPageVo.class).contains(x.getProperty()));
+                .select(News.class, x -> VoToColumnUtil.fieldsToColumns(NewsPageVo.class).contains(x.getProperty()))
+                .orderByDesc(News::getSendEndDate);
         IPage<News> page = newsService.page(ConventPage.getPage(dto), wrapper);
         PageOutput<NewsPageVo> pageOutput = ConventPage.getPageOutput(page, NewsPageVo.class);
         return RT.ok(pageOutput);

+ 27 - 1
src/main/java/com/xjrsoft/module/oa/service/impl/NewsServiceImpl.java

@@ -85,6 +85,28 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
         News news = BeanUtil.toBean(addNewsDto, News.class);
         news.setEnabledMark(EnabledMark.ENABLED.getCode());
 
+        //是新闻
+        //如果张贴开始时间小于等于发布时间,表示是实时发布的新闻,状态应该是2
+        if(news.getTypeId().equals(1)
+                && ObjectUtil.isNotNull(news.getSendStartDate())
+                && ObjectUtil.isNotNull(news.getReleaseTime())
+                && news.getSendStartDate().compareTo(news.getReleaseTime()) >= 0){
+            news.setStatus(2);
+        }
+
+        //是公告
+        if(news.getTypeId().equals(2)){
+            //如果没有张贴时间,表示是移动端实时发布的公告,状态应该是2
+            if(ObjectUtil.isNull(news.getSendStartDate())){
+                news.setStatus(2);
+            }
+            //如果张贴开始时间小于等于发布时间,表示是实时发布的公告,状态应该是2
+            if(ObjectUtil.isNull(news.getReleaseTime())
+                    && news.getSendStartDate().compareTo(news.getReleaseTime()) >= 0){
+                news.setStatus(2);
+            }
+        }
+
         newsMapper.insert(news);
         //添加附件子表
         if (addNewsDto.getAppendixList() != null) {
@@ -115,6 +137,9 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                             .eq(Department::getId,deptId);
                     List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
                     List<Long> userIdList = new ArrayList<>();
+                    for (XjrUser user: userList) {
+                        userIdList.add(user.getId());
+                    }
                     for (Long userId: userIdList) {
                         newsRelation.setUserId(userId);
                         newsRelationMapper.insert(newsRelation);
@@ -125,7 +150,8 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 }
             }
         }
-        //添加新闻和公告的时候,如果状态是2,表示新闻和公告实时发布了,需要发送消息
+
+        //添加新闻和公告的时候,如果状态是2,表示新闻和公告实时发布了,张贴开始时间就应该是发布时间需要发送消息
         if(ObjectUtil.isNotNull(addNewsDto.getStatus()) && addNewsDto.getStatus() == 2){
             SendMessage(news.getId());
         }

+ 12 - 26
src/main/java/com/xjrsoft/module/organization/controller/PostController.java

@@ -1,7 +1,6 @@
 package com.xjrsoft.module.organization.controller;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.lang.TypeReference;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -17,36 +16,17 @@ import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.TreeUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
-import com.xjrsoft.module.organization.dto.AddPostDto;
-import com.xjrsoft.module.organization.dto.PostPageDto;
-import com.xjrsoft.module.organization.dto.PostTreeDto;
-import com.xjrsoft.module.organization.dto.UpdatePostDto;
-import com.xjrsoft.module.organization.dto.UpdateUserPostDto;
+import com.xjrsoft.module.organization.dto.*;
 import com.xjrsoft.module.organization.entity.Post;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserPostRelation;
-import com.xjrsoft.module.organization.service.IDepartmentService;
-import com.xjrsoft.module.organization.service.IPostService;
-import com.xjrsoft.module.organization.service.IUserDeptRelationService;
-import com.xjrsoft.module.organization.service.IUserPostRelationService;
-import com.xjrsoft.module.organization.service.IUserService;
-import com.xjrsoft.module.organization.vo.PostListVo;
-import com.xjrsoft.module.organization.vo.PostPageVo;
-import com.xjrsoft.module.organization.vo.PostTreeVo;
-import com.xjrsoft.module.organization.vo.PostVo;
-import com.xjrsoft.module.organization.vo.UserPostVo;
+import com.xjrsoft.module.organization.service.*;
+import com.xjrsoft.module.organization.vo.*;
 import com.xjrsoft.module.system.dto.SwitchPostDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.ArrayList;
@@ -180,9 +160,15 @@ public class PostController {
     public R delete(@Valid @RequestBody List<Long> ids) {
         //删除岗位时,需要判断,此岗位下是不是存在人员,存在人员就不能删除
         //查询到所有的用户数据
-        List<UserPostRelation> userPostRelationList = redisUtil.get(GlobalConstant.USER_POST_RELATION_CACHE_KEY, new TypeReference<List<UserPostRelation>>() {
-        });
+//        List<UserPostRelation> userPostRelationList = redisUtil.get(GlobalConstant.USER_POST_RELATION_CACHE_KEY, new TypeReference<List<UserPostRelation>>() {
+//        });
         //拿ids进行过滤,如果存在,就不能删除
+//        List<UserPostRelation> users = userPostRelationList.stream().filter(u -> ids.contains(u.getPostId())).collect(Collectors.toList());
+
+        LambdaQueryWrapper<UserPostRelation> queryWrapperUserPostRelation = new LambdaQueryWrapper<>();
+        queryWrapperUserPostRelation
+                .in(UserPostRelation::getPostId,ids);
+        List<UserPostRelation> userPostRelationList = userPostRelationService.list(queryWrapperUserPostRelation);
         List<UserPostRelation> users = userPostRelationList.stream().filter(u -> ids.contains(u.getPostId())).collect(Collectors.toList());
 
         if (users.size()>0){

+ 33 - 0
src/main/java/com/xjrsoft/module/room/controller/RoomStudentAppointController.java

@@ -2,6 +2,8 @@ package com.xjrsoft.module.room.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
@@ -11,6 +13,7 @@ import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
 import com.xjrsoft.module.room.dto.UpdateRoomStudentAppointDto;
 import com.xjrsoft.module.room.entity.RoomStudentAppoint;
 import com.xjrsoft.module.room.service.IRoomStudentAppointService;
+import com.xjrsoft.module.room.vo.AppointPageRoomBedVo;
 import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 import com.xjrsoft.module.room.vo.RoomStudentAppointVo;
 import io.swagger.annotations.Api;
@@ -46,6 +49,14 @@ public class RoomStudentAppointController {
         return RT.ok(pageOutput);
     }
 
+    @GetMapping(value = "/getStuByRoomId")
+    @ApiOperation(value="根据寝室id获取该寝室的所有已入住人员(不分页)")
+    @SaCheckPermission("roomstudentappoint:detail")
+    public RT<List<AppointPageRoomBedVo>> getStuByRoomId(@Valid RoomStudentAppointPageDto dto){
+        List<AppointPageRoomBedVo> appointPageRoomBedVoList = roomStudentAppointService.getStuByRoomId(dto);
+        return RT.ok(appointPageRoomBedVoList);
+    }
+
     @GetMapping(value = "/info")
     @ApiOperation(value="根据id查询寝室干部信息")
     @SaCheckPermission("roomstudentappoint:detail")
@@ -77,6 +88,28 @@ public class RoomStudentAppointController {
 
     }
 
+    @PutMapping("/appoint")
+    @ApiOperation(value = "任命寝室干部,寝室干部记录中存在更新,不存在新增")
+    @SaCheckPermission("roomstudentappoint:edit")
+    public RT<Boolean> appoint(@Valid @RequestBody UpdateRoomStudentAppointDto dto){
+        LambdaQueryWrapper<RoomStudentAppoint> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper
+                .eq(RoomStudentAppoint::getRoomId,dto.getRoomId())
+                .eq(RoomStudentAppoint::getPostId,dto.getPostId());
+        RoomStudentAppoint roomStudentAppoint = roomStudentAppointService.getOne(queryWrapper);
+        //为空,表示该寝室该职位没有安排人
+        if(ObjectUtil.isNull(roomStudentAppoint)){
+            dto.setId(null);
+            RoomStudentAppoint roomStudentAppointInsert = BeanUtil.toBean(dto, RoomStudentAppoint.class);
+            boolean isSuccess = roomStudentAppointService.save(roomStudentAppointInsert);
+            return RT.ok(isSuccess);
+        }else{
+            RoomStudentAppoint roomStudentAppointUpdate = BeanUtil.toBean(dto, RoomStudentAppoint.class);
+            roomStudentAppointUpdate.setId(roomStudentAppoint.getId());
+            return RT.ok(roomStudentAppointService.updateById(roomStudentAppointUpdate));
+        }
+    }
+
     @DeleteMapping
     @ApiOperation(value = "删除寝室干部任命")
     @SaCheckPermission("roomstudentappoint:delete")

+ 2 - 2
src/main/java/com/xjrsoft/module/room/dto/RoomStudentAppointPageDto.java

@@ -27,8 +27,8 @@ public class RoomStudentAppointPageDto extends PageInput {
     private Long roomId;
 
     /**
-     * 当前班主任Id
+     * 班主任用户主键编号Id
      */
-    @ApiModelProperty(value = "寝室主键编号",hidden = true)
+    @ApiModelProperty(value = "班主任用户主键编号Id",hidden = true)
     private Long teacherId;
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/room/service/IRoomStudentAppointService.java

@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
 import com.xjrsoft.module.room.entity.RoomStudentAppoint;
+import com.xjrsoft.module.room.vo.AppointPageRoomBedVo;
 import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 
+import java.util.List;
+
 /**
  * @title: 寝室长任命
  * @Author dzx
@@ -16,4 +19,6 @@ import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 public interface IRoomStudentAppointService extends MPJBaseService<RoomStudentAppoint> {
 
     IPage<HeadTeaRoomCadreAppointPageVo> getPage(RoomStudentAppointPageDto dto);
+
+    List<AppointPageRoomBedVo> getStuByRoomId(RoomStudentAppointPageDto dto);
 }

+ 21 - 9
src/main/java/com/xjrsoft/module/room/service/impl/RoomStudentAppointServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.room.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseServiceImpl;
@@ -39,18 +40,11 @@ public class RoomStudentAppointServiceImpl extends MPJBaseServiceImpl<RoomStuden
 
     @Override
     public IPage<HeadTeaRoomCadreAppointPageVo> getPage(RoomStudentAppointPageDto dto) {
+        dto.setTeacherId(StpUtil.getLoginIdAsLong());
         IPage<HeadTeaRoomCadreAppointPageVo> headTeaRoomCadreAppointPageVoIPage = roomStudentAppointMapper.getPage(ConventPage.getPage(dto), dto);
         //找到每个寝室的每个床位的人
         for (HeadTeaRoomCadreAppointPageVo headTeaRoomCadreAppointPageVo : headTeaRoomCadreAppointPageVoIPage.getRecords()) {
-            MPJLambdaWrapper<RoomBed> queryRoomBed = new MPJLambdaWrapper<>();
-            queryRoomBed
-                    .selectAs(RoomBed::getId,AppointPageRoomBedVo::getRoomBedId)
-                    .selectAs(XjrUser::getName, AppointPageRoomBedVo::getStudentUserIdCN)
-                    .select(RoomBed.class, x -> VoToColumnUtil.fieldsToColumns(AppointPageRoomBedVo.class).contains(x.getProperty()))
-                    .leftJoin(XjrUser.class,XjrUser::getId,RoomBed::getStudentUserId)
-                    .eq(RoomBed::getRoomId,headTeaRoomCadreAppointPageVo.getRoomId())
-                    .eq(RoomBed::getIsCheckIn,1);
-            List<AppointPageRoomBedVo> appointPageRoomBedVoList = roomBedMapper.selectJoinList(AppointPageRoomBedVo.class,queryRoomBed);
+            List<AppointPageRoomBedVo> appointPageRoomBedVoList = this.getStuByRoomId(Long.parseLong(headTeaRoomCadreAppointPageVo.getRoomId()));
             if (ObjectUtil.isNotNull(appointPageRoomBedVoList) && appointPageRoomBedVoList.size() > 0){
                 //找到每个人的职位
                 for (AppointPageRoomBedVo appointPageRoomBedVo : appointPageRoomBedVoList) {
@@ -76,4 +70,22 @@ public class RoomStudentAppointServiceImpl extends MPJBaseServiceImpl<RoomStuden
         }
         return headTeaRoomCadreAppointPageVoIPage;
     }
+
+    @Override
+    public List<AppointPageRoomBedVo> getStuByRoomId(RoomStudentAppointPageDto dto) {
+        return this.getStuByRoomId(dto.getRoomId());
+    }
+
+    private List<AppointPageRoomBedVo> getStuByRoomId(Long roomId) {
+        MPJLambdaWrapper<RoomBed> queryRoomBed = new MPJLambdaWrapper<>();
+        queryRoomBed
+                .selectAs(RoomBed::getId,AppointPageRoomBedVo::getRoomBedId)
+                .selectAs(XjrUser::getName, AppointPageRoomBedVo::getStudentUserIdCN)
+                .select(RoomBed.class, x -> VoToColumnUtil.fieldsToColumns(AppointPageRoomBedVo.class).contains(x.getProperty()))
+                .leftJoin(XjrUser.class,XjrUser::getId,RoomBed::getStudentUserId)
+                .eq(RoomBed::getRoomId,roomId)
+                .eq(RoomBed::getIsCheckIn,1);
+        List<AppointPageRoomBedVo> appointPageRoomBedVoList = roomBedMapper.selectJoinList(AppointPageRoomBedVo.class,queryRoomBed);
+        return appointPageRoomBedVoList;
+    }
 }

+ 1 - 1
src/main/resources/mapper/oa/NewsMapper.xml

@@ -56,6 +56,6 @@
             and t.keyword LIKE CONCAT('%',#{dto.keyword},'%')
         </if>
         order by
-        t.send_start_date desc
+        t.send_start_date desc,t.release_time desc
     </select>
 </mapper>