|
@@ -0,0 +1,180 @@
|
|
|
+package com.jeeplus.flowable.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.jeeplus.core.domain.BaseEntity;
|
|
|
+import com.jeeplus.flowable.mapper.MyNoticeListMapper;
|
|
|
+import com.jeeplus.flowable.model.MyNoticeList;
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class MyNoticeService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FlowProcessService flowProcessService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private MyNoticeListMapper mapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待办任务列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Page<MyNoticeList> noticeList(Page<MyNoticeList> page, String type, String title, String taskName){
|
|
|
+ // 获取当前登录人名称查询出未查看通知列表
|
|
|
+ String userName = UserUtils.getCurrentUserDTO ().getName ();
|
|
|
+ QueryWrapper<MyNoticeList> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("a.notice_id", UserUtils.getCurrentUserDTO ().getId());
|
|
|
+ queryWrapper.orderByDesc("a.create_date");
|
|
|
+ if (StringUtils.isNotEmpty(type)) {
|
|
|
+ queryWrapper.eq("a.type", Integer.parseInt(type));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(title)) {
|
|
|
+ queryWrapper.like("a.title", title);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(taskName)) {
|
|
|
+ queryWrapper.eq("a.task_name", taskName);
|
|
|
+ }
|
|
|
+ Page<MyNoticeList> listPage = mapper.selectPage(page, queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(listPage.getRecords())) {
|
|
|
+ for (MyNoticeList notice : listPage.getRecords()) {
|
|
|
+ notice.setType("0".equals(notice.getType())? "未读":"已读");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String add(String taskId, String title, String defId, String taskName, String createName, String createDate, String noticeName, String noticeId) throws Exception{
|
|
|
+ MyNoticeList notice = new MyNoticeList();
|
|
|
+ //是否已保存
|
|
|
+ LambdaQueryWrapper<MyNoticeList> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(BaseEntity::getDelFlag, 0).eq(MyNoticeList::getTaskId, taskId).eq(MyNoticeList::getNoticeName, noticeName).eq(MyNoticeList::getType, 0);
|
|
|
+ MyNoticeList one = mapper.selectOne(wrapper);
|
|
|
+ if (one != null) {
|
|
|
+ one.setRepetitionCount(one.getRepetitionCount() + 1);
|
|
|
+ mapper.updateById(one);
|
|
|
+ }
|
|
|
+ //获取当前登录人信息
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ //生成id
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ notice.setId(id);
|
|
|
+ notice.setCreateById(userDTO.getId());
|
|
|
+ notice.setCreateTime(new Date());
|
|
|
+ notice.setUpdateById(userDTO.getId());
|
|
|
+ notice.setUpdateTime(new Date());
|
|
|
+ notice.setDelFlag(0);
|
|
|
+ notice.setTaskId(taskId);
|
|
|
+ notice.setTitle(title);
|
|
|
+ notice.setDefId(defId);
|
|
|
+ if (StringUtils.isNotEmpty(taskName)) {
|
|
|
+ notice.setTaskName(taskName);
|
|
|
+ } else {
|
|
|
+ Page<Map> page = flowProcessService.processList(new Page<Map>(), "");
|
|
|
+ List<Map> records = page.getRecords();
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ for (Map<String, String> map : records) {
|
|
|
+ if(defId.equals(map.get("id"))){
|
|
|
+ notice.setTaskName(map.get("name"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notice.setLink("结束");
|
|
|
+ if (StringUtils.isNotEmpty(createName)) {
|
|
|
+ notice.setCreateUser(createName);
|
|
|
+ }else {
|
|
|
+ notice.setCreateUser(userDTO.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(noticeName)) {
|
|
|
+ notice.setNoticeName(noticeName);
|
|
|
+ } else {
|
|
|
+ notice.setNoticeName(userDTO.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(noticeId)) {
|
|
|
+ notice.setNoticeId(noticeId);
|
|
|
+ } else {
|
|
|
+ notice.setNoticeId(userDTO.getId());
|
|
|
+ }
|
|
|
+ // 创建时间格式化处理
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ notice.setCreateTime(format.parse(createDate));
|
|
|
+ notice.setType("0");
|
|
|
+ notice.setRepetitionCount(1);
|
|
|
+ mapper.insert(notice);
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ public String update(String taskId, String noticeId) {
|
|
|
+ LambdaQueryWrapper<MyNoticeList> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(BaseEntity::getDelFlag, 0).eq(MyNoticeList::getTaskId, taskId).eq(MyNoticeList::getNoticeName, noticeId).eq(MyNoticeList::getType, 0);
|
|
|
+ MyNoticeList one = mapper.selectOne(wrapper);
|
|
|
+ if (one != null) {
|
|
|
+ one.setType("1");
|
|
|
+ mapper.updateById(one);
|
|
|
+ }
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ public String stockUpdate(MyNoticeList myNoticeList) {
|
|
|
+ myNoticeList.setType("1");
|
|
|
+ mapper.updateById(myNoticeList);
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ public String readAll() {
|
|
|
+ // 获取当前登录人信息
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ mapper.readAll(userDTO.getName());
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据通知信息查询数据
|
|
|
+ * @param myNoticeList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public MyNoticeList getRepetitionCountBymyNotice(MyNoticeList myNoticeList){
|
|
|
+ return mapper.getRepetitionCountBymyNotice(myNoticeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据通知信息查询数据
|
|
|
+ * @param myNoticeList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void insertMyNotice(MyNoticeList myNoticeList){
|
|
|
+ mapper.insertMyNotice(myNoticeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据通知信息查询数据
|
|
|
+ * @param myNoticeList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void updateMyNotice(MyNoticeList myNoticeList){
|
|
|
+ mapper.updateMyNotice(myNoticeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据通知信息查询数据
|
|
|
+ * @param idList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void portionRead(List<String> idList){
|
|
|
+ if(null != idList && idList.size()>0){
|
|
|
+ mapper.portionRead(idList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|