Bläddra i källkod

定时任务处理维护资产(0)

5 år sedan
förälder
incheckning
386d98fc07

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/constant/Constant.java

@@ -11,5 +11,6 @@ public class Constant {
     public static final String APP_ID = "";//appid
     public static final String SCORING_DEADLINE_CODE = "scoringDeadline";//打分日期截止
     public static final String GOODS_MATAIN_CONTENT = "资产: name,num 需要维护。";
+    public static final String SCORING_NEWS = "上月打分截止日期快到了,请尽快为未打分的成员打分。";
 
 }

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/controller/IdeaController.java

@@ -102,7 +102,7 @@ public class IdeaController {
      * 获取建议得分
      * 有两种情况
      * 参数:
-     * 1.打分:time:建议时间如:2019-11 ,uid:发表建议人的id
+     * 1.打分:time:建议时间如:2019-11 ,uid:发表建议人的id,scoreId:打分的数据的id
      * 2.修改打分:scoreId:打分的数据的id,time:建议时间如:2019-11,uid:发表建议人的id
      * @return
      */

+ 32 - 2
pcbms/src/main/java/com/hssx/pcbms/controller/NewsNoticeController.java

@@ -1,8 +1,17 @@
 package com.hssx.pcbms.controller;
 
 
+import com.hssx.pcbms.entity.NewsNotice;
+import com.hssx.pcbms.entity.Score;
+import com.hssx.pcbms.service.NewsNoticeService;
+import com.hssx.pcbms.util.HttpRespMsg;
+import com.hssx.pcbms.util.PageUtil;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -13,9 +22,30 @@ import org.springframework.web.bind.annotation.RestController;
  * @author 吴涛涛
  * @since 2019-11-06
  */
-@RestController
-@RequestMapping("/news-notice")
+@Controller
+@RequestMapping("/newsnotice")
 public class NewsNoticeController {
+    @Autowired
+    private NewsNoticeService newsNoticeService;
+
+    /**
+     * 根据日期获取评分详情
+     * 参数:
+     *      uid:用户id,pageNum:当前页,pageSize:每页多少条
+     * @return
+     */
+    @ApiOperation(value = "评分详情", notes = "评分详情方法")
+    @RequestMapping("/getNewsList")
+    @ResponseBody
+    public HttpRespMsg getNewsList(Integer uid, PageUtil page) {
+        HttpRespMsg msg = new HttpRespMsg();
+        try {
+            msg = newsNoticeService.getNewsList(uid,page);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return msg;
+    }
 
 }
 

+ 0 - 21
pcbms/src/main/java/com/hssx/pcbms/controller/NewsNoticeUserController.java

@@ -1,21 +0,0 @@
-package com.hssx.pcbms.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author 吴涛涛
- * @since 2019-11-06
- */
-@RestController
-@RequestMapping("/news-notice-user")
-public class NewsNoticeUserController {
-
-}
-

+ 22 - 1
pcbms/src/main/java/com/hssx/pcbms/controller/ScoreController.java

@@ -9,6 +9,8 @@ import com.hssx.pcbms.util.HttpRespMsg;
 import com.hssx.pcbms.util.PageUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -27,7 +29,7 @@ import java.text.ParseException;
  */
 @Controller
 @RequestMapping("/score")
-
+@EnableScheduling
 public class ScoreController {
     @Autowired
     private ScoreService scoreService;
@@ -106,6 +108,25 @@ public class ScoreController {
         }
         return msg;
     }
+    /**
+     * 打分通知定时任务
+     * 参数:
+     * @return
+     */
+    @ApiOperation(value = "打分通知定时任务", notes = "打分通知定时任务")
+    @RequestMapping("/scoringTaskNotice")
+    @ResponseBody
+    @Scheduled(cron = "0 23 0 1 * ?")//配置时间点触发(每月1号的23点执行)
+    public HttpRespMsg scoringTaskNotice() {
+        HttpRespMsg msg = new HttpRespMsg();
+        try {
+             msg = scoreService.scoringTaskNotice();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return msg;
+    }
+
 
 
 

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/mapper/UserMapper.java

@@ -25,4 +25,6 @@ public interface UserMapper extends BaseMapper<User> {
     List<DepartmentVO> selectDeptUserListByCondition(UserVO userVO);
 
     List<User> selectOperateUsersListByCondition();
+
+    List<User> selectLeaderUsersListByCondition();
 }

+ 3 - 0
pcbms/src/main/java/com/hssx/pcbms/service/NewsNoticeService.java

@@ -2,6 +2,8 @@ package com.hssx.pcbms.service;
 
 import com.hssx.pcbms.entity.NewsNotice;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.pcbms.util.HttpRespMsg;
+import com.hssx.pcbms.util.PageUtil;
 
 /**
  * <p>
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface NewsNoticeService extends IService<NewsNotice> {
 
+    HttpRespMsg getNewsList(Integer uid, PageUtil page);
 }

+ 2 - 0
pcbms/src/main/java/com/hssx/pcbms/service/ScoreService.java

@@ -24,4 +24,6 @@ public interface ScoreService extends IService<Score> {
     HttpRespMsg detail(Score score);
 
     HttpRespMsg getDetailByTimeAndUid(Score score,String time);
+
+    HttpRespMsg scoringTaskNotice();
 }

+ 19 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/NewsNoticeServiceImpl.java

@@ -1,11 +1,19 @@
 package com.hssx.pcbms.service.impl;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
 import com.hssx.pcbms.entity.NewsNotice;
 import com.hssx.pcbms.mapper.NewsNoticeMapper;
+import com.hssx.pcbms.mapper.NewsNoticeUserMapper;
 import com.hssx.pcbms.service.NewsNoticeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.pcbms.util.HttpRespMsg;
+import com.hssx.pcbms.util.PageUtil;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +25,15 @@ import org.springframework.stereotype.Service;
 @Service
 public class NewsNoticeServiceImpl extends ServiceImpl<NewsNoticeMapper, NewsNotice> implements NewsNoticeService {
 
+    @Resource
+    private NewsNoticeMapper newsNoticeMapper;
+    @Resource
+    private NewsNoticeUserMapper newsNoticeUserMapper;
+
+    @Override
+    public HttpRespMsg getNewsList(Integer uid, PageUtil page) {
+        PageHelper.startPage(page.getPageNum(),page.getPageSize());
+//        List<NewsNotice> notices = newsNoticeMapper
+        return null;
+    }
 }

+ 25 - 4
pcbms/src/main/java/com/hssx/pcbms/service/impl/ScoreServiceImpl.java

@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.hssx.pcbms.constant.Constant;
-import com.hssx.pcbms.entity.Idea;
-import com.hssx.pcbms.entity.Parameter;
-import com.hssx.pcbms.entity.Score;
-import com.hssx.pcbms.entity.User;
+import com.hssx.pcbms.entity.*;
 import com.hssx.pcbms.entity.vo.IdeaVO;
 import com.hssx.pcbms.entity.vo.ScoreVO;
 import com.hssx.pcbms.mapper.*;
@@ -43,6 +40,10 @@ public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements
     private IdeaMapper ideaMapper;
     @Resource
     private IdeaCommentMapper ideaCommentMapper;
+    @Resource
+    private NewsNoticeMapper newsNoticeMapper;
+    @Resource
+    private NewsNoticeUserMapper newsNoticeUserMapper;
 
     @Override
     public HttpRespMsg add(Score score) throws ParseException {
@@ -129,6 +130,26 @@ public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements
         return msg;
     }
 
+    @Override
+    public HttpRespMsg scoringTaskNotice() {
+        HttpRespMsg msg = new HttpRespMsg();
+        //条件通知消息
+        NewsNotice newsNotice = new NewsNotice();
+        newsNotice.setNoticeType(1);
+        String content = Constant.SCORING_NEWS;
+        newsNotice.setContent(content);
+        newsNoticeMapper.insert(newsNotice);
+        List<User> users = userMapper.selectLeaderUsersListByCondition();
+        //通知所有领导
+        for (User user : users) {
+            NewsNoticeUser noticeUser = new NewsNoticeUser();
+            noticeUser.setNewsId(newsNotice.getId());
+            noticeUser.setUserId(user.getId());
+            newsNoticeUserMapper.insert(noticeUser);
+        }
+        return msg;
+    }
+
     private HttpRespMsg addScore(Date yearMonth, Date nowDate, Integer type, Score score,Score oldScore) {
         HttpRespMsg msg = new HttpRespMsg();
         //评分上个月

+ 11 - 0
pcbms/src/main/resources/mapper/UserMapper.xml

@@ -89,4 +89,15 @@
         ON sr.id = ur.role_id
         where sr.id=2
     </select>
+    <select id="selectLeaderUsersListByCondition" resultMap="BaseResultMap">
+        select
+            u.id,u.head_url,u.name
+        from
+            USER u
+        LEFT JOIN user_role ur
+        ON u.id = ur.user_id
+        LEFT JOIN sys_role sr
+        ON sr.id = ur.role_id
+        where sr.id=1
+    </select>
 </mapper>