Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

wangqiang 2 yıl önce
ebeveyn
işleme
0e52a624ff

+ 5 - 0
jeeplus-modules/jeeplus-flowable/pom.xml

@@ -84,6 +84,11 @@
         </dependency>
         <dependency>
             <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-system</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
             <artifactId>jeeplus-common-log</artifactId>
             <version>${project.parent.version}</version>
         </dependency>

+ 49 - 0
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/MyNoticeListMapper.java

@@ -0,0 +1,49 @@
+package com.jeeplus.flowable.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.flowable.model.MyNoticeList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface MyNoticeListMapper extends BaseMapper<MyNoticeList> {
+
+    void readAll(@Param("name") String name);
+
+    /**
+     * 查询通知信息
+     *
+     * @param myNotice
+     * @return
+     */
+    public IPage<MyNoticeList> selectPage(Page<MyNoticeList> page, @Param("myNotice") MyNoticeList myNotice);
+
+    /**
+     * 根据通知信息查询详情
+     * @param myNoticeList
+     * @return
+     */
+    MyNoticeList getRepetitionCountBymyNotice(MyNoticeList myNoticeList);
+
+    /**
+     * 保存通知信息
+     * @param myNoticeList
+     */
+    void insertMyNotice(MyNoticeList myNoticeList);
+
+    /**
+     * 修改通知信息
+     * @param myNoticeList
+     */
+    void updateMyNotice(MyNoticeList myNoticeList);
+
+    /**
+     * 部分通知变更为已读
+     * @param idList
+     * @return
+     */
+    void portionRead(List idList);
+
+}

+ 126 - 0
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/xml/MyNoticeListMapper.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeeplus.flowable.mapper.MyNoticeListMapper">
+
+	<update id="readAll">
+		UPDATE my_notice_list
+			SET type = 1
+		WHERE
+			del_flag = 0
+			AND create_user = #{name}
+	</update>
+
+	<select id="selectPage" resultType="com.jeeplus.flowable.model.MyNoticeList">
+		select
+		  a.id,
+		  a.create_by,
+		  a.create_date,
+		  a.update_by,
+		  a.update_date,
+		  a.del_flag,
+		  a.task_id,
+		  a.title,
+		  a.def_id,
+		  a.task_name,
+		  a.link,
+		  a.create_user,
+		  a.create_time,
+		  a.type,
+		  a.repetition_count,
+		  a.notice_id,
+		  su.name as "noticeName"
+		from
+		  my_notice_list a
+		left join sys_user su on a.notice_id = su.id
+		${ew.customSqlSegment}
+	</select>
+
+	<select id="getRepetitionCountBymyNotice" resultType="com.jeeplus.flowable.model.MyNoticeList">
+		select
+		  a.id,
+		  a.create_by,
+		  a.create_date,
+		  a.update_by,
+		  a.update_date,
+		  a.del_flag,
+		  a.task_id,
+		  a.title,
+		  a.def_id,
+		  a.task_name,
+		  a.link,
+		  a.create_user,
+		  a.create_time,
+		  a.type,
+		  a.repetition_count,
+		  a.notice_id
+		from
+		  my_notice_list a
+		<where>
+			a.del_flag = 0
+			and a.notice_id = #{noticeId}
+			and a.task_name = #{taskName}
+		</where>
+	</select>
+
+	<insert id="insertMyNotice">
+		insert into my_notice_list (
+		  id,
+		  create_by,
+		  create_date,
+		  update_by,
+		  update_date,
+		  del_flag,
+		  task_id,
+		  title,
+		  def_id,
+		  task_name,
+		  link,
+		  create_user,
+		  create_time,
+		  notice_name,
+		  notice_id,
+		  `type`,
+		  repetition_count
+		)
+		values
+		  (
+			#{id},
+			#{createBy},
+			#{createDate},
+			#{updateBy},
+			#{updateDate},
+			#{delFlag},
+			#{taskId},
+			#{title},
+			#{defId},
+			#{taskName},
+			#{link},
+			#{createUser},
+			#{createTime},
+			#{noticeName},
+			#{noticeId},
+			#{type},
+			#{repetitionCount}
+		  ) ;
+	</insert>
+
+	<update id="updateMyNotice">
+		update my_notice_list
+		set `type` = 0,
+		repetition_count = #{repetitionCount}
+		where id = #{id}
+	</update>
+
+
+	<update id="portionRead">
+		UPDATE my_notice_list
+			SET type = 1
+		<where>
+			del_flag = 0
+			and id in
+			<foreach collection="idList" open="(" close=")" separator="," item="id">
+				#{id}
+			</foreach>
+		</where>
+	</update>
+</mapper>

+ 70 - 0
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/MyNoticeList.java

@@ -0,0 +1,70 @@
+package com.jeeplus.flowable.model;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName(value = "my_notice_list")
+public class MyNoticeList extends BaseEntity {
+
+    /**
+     * 流程id
+     */
+    private String taskId;
+
+    /**
+     * 实例标题
+     */
+    private String title;
+
+    /**
+     * 流程id
+     */
+    private String defId;
+
+    /**
+     * 流程名称
+     */
+    private String taskName;
+
+    /**
+     * 当前环节
+     */
+    private String link;
+
+    /**
+     * 创建人名称
+     */
+    private String createUser;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 通知人名称
+     */
+    private String noticeName;
+
+    /**
+     * 通知人id
+     */
+    private String noticeId;
+
+    /**
+     * 读取状态
+     */
+    private String type;
+
+    /**
+     * 重复数量
+     */
+    private Integer repetitionCount;
+
+}

+ 180 - 0
jeeplus-modules/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/MyNoticeService.java

@@ -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);
+        }
+    }
+}