Bladeren bron

通告管理

lizhenhao 2 jaren geleden
bovenliggende
commit
31a92a8a18
22 gewijzigde bestanden met toevoegingen van 787 en 46 verwijderingen
  1. 2 0
      jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/workClientInfo/service/CwWorkClientService.java
  2. 17 0
      jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/controller/OfficeController.java
  3. 7 0
      jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/OfficeMapper.java
  4. 9 0
      jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml
  5. 62 0
      jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/OfficeService.java
  6. 5 0
      jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java
  7. 6 0
      jeeplus-plugins/jeeplus-notify/pom.xml
  8. 29 10
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/controller/NotifyController.java
  9. 41 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/Notify.java
  10. 32 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/PluginNotifyOffices.java
  11. 31 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/PluginNotifyUser.java
  12. 2 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/NotifyMapper.java
  13. 17 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/PluginNotifyOfficesMapper.java
  14. 17 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/PluginNotifyUserMapper.java
  15. 141 28
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/NotifyMapper.xml
  16. 30 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/PluginNotifyOfficesMapper.xml
  17. 30 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/PluginNotifyUserMapper.xml
  18. 160 8
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/NotifyService.java
  19. 51 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/NotifyDTO.java
  20. 37 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/PluginNotifyOfficesDTO.java
  21. 41 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/PluginNotifyUserDTO.java
  22. 20 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/WorkAttachmentDto.java

+ 2 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/workClientInfo/service/CwWorkClientService.java

@@ -150,6 +150,8 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
                                 } else {
                                     parentId = byId.getOneUpCompany();
                                 }
+                            } else {
+                                break;
                             }
                         }
                     }

+ 17 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/controller/OfficeController.java

@@ -3,6 +3,8 @@
  */
 package com.jeeplus.sys.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.jeeplus.aop.demo.annotation.DemoMode;
 import com.jeeplus.aop.logging.annotation.ApiLog;
@@ -113,5 +115,20 @@ public class OfficeController {
         return ResponseEntity.ok (rootTree);
     }
 
+    /**
+     * 查询部门信息列表tree
+     * @param officeDTO
+     * @param page
+     * @return
+     * @throws Exception
+     */
+    @ApiLog("查询部门信息列表tree")
+    @GetMapping("list_tree")
+    public ResponseEntity<IPage<OfficeDTO>> dataTree(OfficeDTO officeDTO, Page<OfficeDTO> page) throws Exception {
+        IPage<OfficeDTO> result = new Page<OfficeDTO>();
+        result = officeService.findListTree (page,officeDTO);
+        return ResponseEntity.ok (result);
+    }
+
 
 }

+ 7 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/OfficeMapper.java

@@ -3,6 +3,10 @@
  */
 package com.jeeplus.sys.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.core.domain.TreeMapper;
 import com.jeeplus.sys.domain.Office;
 import com.jeeplus.sys.domain.SysParameter;
@@ -40,4 +44,7 @@ public interface OfficeMapper extends TreeMapper<Office> {
     SysParameterValue findValueByParameter(@Param("parameter")String parameter, @Param("branchOffice")String branchOffice);
 
     SysParameterValue findSysValue(String parameter);
+
+    IPage<OfficeDTO> findList(Page<OfficeDTO> page, @Param(Constants.WRAPPER) QueryWrapper<OfficeDTO> queryWrapper);
+
 }

+ 9 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml

@@ -90,4 +90,13 @@
             and a.del_flag = 0
         </where>
     </select>
+
+    <select id="findList" resultType="com.jeeplus.sys.service.dto.OfficeDTO">
+        select
+            so.parent_id,
+            so.name,
+            so.id
+        from sys_office so
+        ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 62 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/OfficeService.java

@@ -4,6 +4,10 @@
 package com.jeeplus.sys.service;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.jeeplus.core.service.TreeService;
@@ -25,6 +29,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * 机构Service
@@ -275,4 +280,61 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
     public OfficeDTO getOfficeById(String id){
         return officeMapper.getOfficeById(id);
     }
+
+    public IPage<OfficeDTO> findListTree(Page<OfficeDTO> page, OfficeDTO officeDTO) throws Exception{
+        QueryWrapper<OfficeDTO> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("so.del_flag","0");
+        queryWrapper.orderByAsc("so.create_date");
+        if (ObjectUtil.isNotEmpty(officeDTO)) {
+            if (StringUtils.isNotBlank(officeDTO.getName())) {
+                List<String> ids = new ArrayList<>();
+                List<Office> list = this.list(new QueryWrapper<Office>().lambda()
+                        .like(StringUtils.isNotBlank(officeDTO.getName()),Office::getName, officeDTO.getName())
+               );
+                list.stream().forEach(item->{
+                    ids.add(item.getId());
+                    if (StringUtils.isNotBlank(item.getParentId())) {
+                        String parentId = item.getParentId();
+                        while (true) {
+                            Office byId = this.getOne(new QueryWrapper<Office>().lambda().eq(Office::getId, parentId));
+                            if (ObjectUtil.isNotEmpty(byId)) {
+                                ids.add(byId.getId());
+                                if (StringUtils.isBlank(byId.getParentId())) {
+                                    break;
+                                } else {
+                                    parentId = byId.getParentId();
+                                }
+                            } else {
+                                break;
+                            }
+                        }
+                    }
+                    List<String> childIdList = this.list(new QueryWrapper<Office>().lambda().eq(Office::getParentId, item.getId())).stream().map(Office::getId).collect(Collectors.toList());
+                    while (true) {
+                        if (CollectionUtil.isNotEmpty(childIdList)) {
+                            childIdList.stream().forEach(childId->{
+                                ids.add(childId);
+                            });
+                            List<String> childIdS = this.list(new QueryWrapper<Office>().lambda().in(Office::getParentId, childIdList)).stream().map(Office::getId).collect(Collectors.toList());
+                            if (CollectionUtil.isNotEmpty(childIdS)) {
+                                childIdList = childIdS;
+                            } else {
+                                break;
+                            }
+                        } else {
+                            break;
+                        }
+                    }
+                });
+                List<String> lastIdList = ids.stream().distinct().collect(Collectors.toList());
+                if (CollectionUtil.isNotEmpty(lastIdList)){
+                    queryWrapper.in("so.id",lastIdList);
+                } else {
+                    return new Page<>();
+                }
+            }
+        }
+        return officeMapper.findList(page, queryWrapper);
+    }
+
 }

+ 5 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java

@@ -200,4 +200,9 @@ public class OfficeDTO extends TreeDTO <OfficeDTO> {
 	 */
 	private boolean typeFlag = false;
 
+	/**
+	 * 父级id
+	 */
+	private String parentId;
+
 }

+ 6 - 0
jeeplus-plugins/jeeplus-notify/pom.xml

@@ -28,5 +28,11 @@
             <artifactId>jeeplus-admin</artifactId>
             <version>${project.parent.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-test</artifactId>
+            <version>9.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 29 - 10
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/controller/NotifyController.java

@@ -8,12 +8,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.notify.service.NotifyService;
 import com.jeeplus.notify.service.dto.NotifyDTO;
 import com.jeeplus.notify.service.dto.NotifyRecordDTO;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -58,22 +61,38 @@ public class NotifyController {
         return ResponseEntity.ok ( notifyDTO);
     }
 
+    @PostMapping("pushNotifyRecord")
+    public ResponseEntity pushNotifyRecord(String id) {
+        String s = notifyService.pushNotifyRecord(id);
+        return ResponseEntity.ok ( s );
+    }
+
     @PreAuthorize ("hasAnyAuthority('notify:add','notify:edit')")
     @PostMapping("save")
     public ResponseEntity save(@Valid @RequestBody NotifyDTO notifyDTO) {
-        // 如果是修改,则状态为已发布,则不能再进行操作
-        if ( StrUtil.isNotBlank ( notifyDTO.getId ( ) ) ) {
-            NotifyDTO e = notifyService.getById ( notifyDTO.getId ( ) );
-            if ( CommonConstants.YES.equals ( e.getStatus ( ) ) ) {
-                return ResponseEntity.badRequest ( ).body ( "已发布,不能操作!" );
-            }else if(!UserUtils.getCurrentUserDTO ().getId ().equals ( e.getCreateBy ().getId () )){
-                return ResponseEntity.badRequest ().body ( "你只能编辑自己的公告!" );
-            }
-        }
-        notifyService.saveOrUpdate ( notifyDTO );
+        notifyService.saveForm ( notifyDTO );
         return ResponseEntity.ok ( "保存通知'" + notifyDTO.getTitle ( ) + "'成功" );
     }
 
+    @PreAuthorize ("hasAnyAuthority('notify:add','notify:edit')")
+    @PostMapping("saveForm")
+    public ResponseEntity saveForm(@Valid @RequestBody NotifyDTO notifyDTO) {
+        String id = notifyService.saveForm(notifyDTO);
+        return ResponseUtil.newInstance().add("businessTable", "plugin_notify").add("businessId", id).ok ("操作成功");
+    }
+
+    /**
+     * 根据id修改状态值status
+     * @param dto
+     * @return
+     */
+    @ApiOperation(value = "根据id修改状态值status")
+    @PostMapping(value = "/updateStatusById")
+    public ResponseEntity<String> updateStatusById(@RequestBody NotifyDTO dto) {
+        String s = notifyService.updateStatusById(dto);
+        return ResponseEntity.ok(s);
+    }
+
     @PreAuthorize("hasAuthority('notify:del')")
     @DeleteMapping("delete")
     public ResponseEntity <String> delete(String ids) {

+ 41 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/Notify.java

@@ -3,11 +3,15 @@
  */
 package com.jeeplus.notify.domain;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.jeeplus.core.domain.BaseEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * 通知通告Entity
  *
@@ -46,5 +50,42 @@ public class Notify extends BaseEntity {
      */
     private String remarks;
 
+    /**
+     * 通告状态
+     */
+    private String notifyType;
+
+    /**
+     * 文号
+     */
+    private String no;
+
+    /**
+     * 开始时间
+     */
+    @TableField(fill = FieldFill.UPDATE)
+    private Date beginDate;
+
+    /**
+     * 结束时间
+     */
+    @TableField(fill = FieldFill.UPDATE)
+    private Date endDate;
+
+    /**
+     * 所属部门id
+     */
+    private String officeId;
+
+    /**
+     * 流程id
+     */
+    protected String procInsId;
+
+    /**
+     * 流程信息
+     */
+    protected String processDefinitionId;
+
 
 }

+ 32 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/PluginNotifyOffices.java

@@ -0,0 +1,32 @@
+package com.jeeplus.notify.domain;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 通知通告-通告范围-部门
+ * @TableName plugin_notify_offices
+ */
+@TableName(value ="plugin_notify_offices")
+@Data
+public class PluginNotifyOffices extends BaseEntity {
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 部门id
+     */
+    private String officeId;
+
+    /**
+     * 通知id
+     */
+    private String notifyId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 31 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/PluginNotifyUser.java

@@ -0,0 +1,31 @@
+package com.jeeplus.notify.domain;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 通知通告-通告范围-用户
+ * @TableName plugin_notify_user
+ */
+@TableName(value ="plugin_notify_user")
+@Data
+public class PluginNotifyUser extends BaseEntity{
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 用户id
+     */
+    private String userId;
+
+    /**
+     * 通知id
+     */
+    private String notifyId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 2 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/NotifyMapper.java

@@ -45,4 +45,6 @@ public interface NotifyMapper extends BaseMapper <Notify> {
                                @Param("readFlag") String readFlag,
                                @Param(Constants.WRAPPER) QueryWrapper queryWrapper);
 
+    void updateStatusById(@Param ( "id" ) String id, @Param ( "status" ) String status);
+
 }

+ 17 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/PluginNotifyOfficesMapper.java

@@ -0,0 +1,17 @@
+package com.jeeplus.notify.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.notify.domain.PluginNotifyOffices;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity generator.domain.PluginNotifyOffices
+ */
+@Mapper
+public interface PluginNotifyOfficesMapper extends BaseMapper<PluginNotifyOffices> {
+
+}
+
+
+
+

+ 17 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/PluginNotifyUserMapper.java

@@ -0,0 +1,17 @@
+package com.jeeplus.notify.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.notify.domain.PluginNotifyUser;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity generator.domain.PluginNotifyUser
+ */
+@Mapper
+public interface PluginNotifyUserMapper extends BaseMapper<PluginNotifyUser> {
+
+}
+
+
+
+

+ 141 - 28
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/NotifyMapper.xml

@@ -1,26 +1,136 @@
 <?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.notify.mapper.NotifyMapper">
-
+    <resultMap id="BaseResultMap" type="com.jeeplus.notify.service.dto.NotifyDTO">
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+        <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+        <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+        <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+        <result property="type" column="type" jdbcType="VARCHAR"/>
+        <result property="title" column="title" jdbcType="VARCHAR"/>
+        <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
+        <result property="notifyType" column="notify_type" jdbcType="VARCHAR"/>
+        <result property="no" column="no" jdbcType="VARCHAR"/>
+        <result property="beginDate" column="begin_date" jdbcType="TIMESTAMP"/>
+        <result property="endDate" column="end_date" jdbcType="TIMESTAMP"/>
+        <result property="officeId" column="office_id" jdbcType="VARCHAR"/>
+        <result property="procInsId" column="proc_ins_id" jdbcType="VARCHAR"/>
+        <result property="processDefinitionId" column="process_definition_id" jdbcType="VARCHAR"/>
+        <result property="readNum" column="read_num" jdbcType="VARCHAR"/>
+        <result property="unReadNum" column="un_read_num" jdbcType="VARCHAR"/>
+        <result property="createBy.name" column="name" jdbcType="VARCHAR"/>
+        <result property="createBy.photo" column="photo" jdbcType="VARCHAR"/>
+        <result property="readFlag" column="read_flag" jdbcType="VARCHAR"/>
+        <collection property="workAttachmentDtoList" ofType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto" column="id" select="getFileList"></collection>
+        <collection property="pluginNotifyOfficesDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO" column="id" select="getOfficeList"></collection>
+        <collection property="pluginNotifyUserDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyUserDTO" column="id" select="getUserList"></collection>
+    </resultMap>
+    <resultMap id="AttachmentMap" type="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+        <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+        <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+        <result property="createBy.name" column="create_name" jdbcType="VARCHAR"/>
+        <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+        <result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
+        <result property="url" column="url" jdbcType="VARCHAR"/>
+        <result property="name" column="attachment_name" jdbcType="VARCHAR"/>
+        <result property="size" column="file_size" jdbcType="VARCHAR"/>
+    </resultMap>
     <sql id="notifyColumns">
-        a.id AS "id",
-        a.type AS "type",
-        a.title AS "title",
-        a.content AS "content",
-        a.files AS "files",
-        a.status AS "status",
-        a.create_by AS "createBy.id",
-        a.create_date AS "createDate",
-        a.update_by AS "updateBy.id",
-        a.update_date AS "updateDate",
-        a.remarks AS "remarks",
-        a.del_flag AS "delFlag",
-        b.read_num AS "readNum",
-        b.un_read_num AS "unReadNum",
-        u.name AS "createBy.name",
-        u.photo AS "createBy.photo"
-
+        a.id,
+        a.type,
+        a.title,
+        a.content,
+        a.files,
+        a.status,
+        a.create_by,
+        a.create_date,
+        a.update_by,
+        a.update_date,
+        a.remarks,
+        a.del_flag,
+        a.notify_type,
+        a.no,
+        a.begin_date,
+        a.end_date,
+        a.office_id,
+        a.proc_ins_id,
+        a.process_definition_id,
+        u.name,
+        u.photo,
+        b.read_num,
+        b.un_read_num
+    </sql>
+    <sql id="File_Column_List">
+        wa.id,
+        wa.create_by,
+        wa.create_date,
+        wa.update_by,
+        wa.update_date,
+        wa.remarks,
+        wa.del_flag,
+        wa.url,
+        wa.type,
+        wa.attachment_id,
+        wa.attachment_name,
+        wa.attachment_flag,
+        wa.module_type,
+        wa.attachment_type,
+        wa.file_size,
+        wa.sort,
+        wa.description
+    </sql>
+    <sql id="Users_Column_List">
+        pnu.id,
+        pnu.create_by,
+        pnu.create_date,
+        pnu.update_by,
+        pnu.update_date,
+        pnu.del_flag,
+        pnu.remarks,
+        pnu.user_id,
+        pnu.notify_id
     </sql>
+    <sql id="Offices_Column_List">
+        pno.id,
+        pno.create_by,
+        pno.create_date,
+        pno.update_by,
+        pno.update_date,
+        pno.del_flag,
+        pno.remarks,
+        pno.office_id,
+        pno.notify_id
+    </sql>
+    <select id="getOfficeList" resultType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO">
+        select
+        <include refid="Offices_Column_List"></include>,
+        so.name as office_name
+        from plugin_notify_offices pno
+        left join sys_office so on so.id = pno.office_id and so.del_flag = '0'
+        where pno.del_flag = '0' and pno.notify_id = #{id}
+    </select>
+    <select id="getUserList" resultType="com.jeeplus.notify.service.dto.PluginNotifyUserDTO">
+        select
+        <include refid="Users_Column_List"></include>,
+        su.name as user_name,
+        so.name as office_name
+        from plugin_notify_user pnu
+        left join sys_user su on su.id = pnu.user_id and su.del_flag = '0'
+        left join sys_office so on so.id = su.office_id and so.del_flag = '0'
+        where pnu.del_flag = '0' and pnu.notify_id = #{id}
+    </select>
+    <select id="getFileList" resultMap="AttachmentMap">
+        select
+        <include refid="File_Column_List"></include>,
+        su.name as create_name
+        from work_attachment wa
+        left join sys_user su on su.id = wa.create_by and su.del_flag = '0'
+        where wa.del_flag = '0' and wa.attachment_id = #{id}
+    </select>
 
     <sql id="notifyJoins">
         <!-- 查询已读和未读条数 -->
@@ -30,34 +140,38 @@
         sum(case when r.del_flag = 0 and r.read_flag != '1' then 1 else 0 end) un_read_num
         FROM plugin_notify_record r GROUP BY r.notify_id
         ) b ON b.notify_id = a.id
-
-        JOIN sys_user u ON u.id = a.CREATE_BY
     </sql>
 
-    <select id="getById" resultType="com.jeeplus.notify.service.dto.NotifyDTO">
+    <select id="getById" resultMap="BaseResultMap">
         SELECT
         <include refid="notifyColumns"/>
         FROM plugin_notify a
+        LEFT JOIN sys_user u ON u.id = a.CREATE_BY AND u.del_flag = '0'
         <include refid="notifyJoins"/>
         WHERE a.id = #{id} and a.del_flag = 0
     </select>
 
-    <select id="findList" resultType="com.jeeplus.notify.service.dto.NotifyDTO">
+    <select id="findList" resultMap="BaseResultMap">
         SELECT
         <include refid="notifyColumns"/>
         <if test="isSelf">,
-            r.read_flag AS "readFlag"
+            r.read_flag
         </if>
         FROM plugin_notify a
+        LEFT JOIN sys_user u ON u.id = a.CREATE_BY AND u.del_flag = '0'
         <include refid="notifyJoins"/>
         <!-- 我的通知 -->
         <if test="isSelf">
-            JOIN plugin_notify_record r ON r.notify_id = a.id AND a.status = '1' AND r.user_id = #{currentUserId} AND r.del_flag = 0
+            JOIN plugin_notify_record r ON r.notify_id = a.id AND r.user_id = #{currentUserId} AND r.del_flag = 0
             <if test="readFlag != null and readFlag != ''">
                 AND r.read_flag = #{readFlag}
             </if>
         </if>
         ${ew.customSqlSegment}
+        <if test="isSelf">
+            and ((a.notify_type = 0 and NOW() >= a.begin_date and NOW() &lt;= a.end_date) or a.notify_type = 1)
+        </if>
+        order by a.create_date desc
     </select>
 
 
@@ -73,11 +187,10 @@
             </if>
         </if>
         WHERE a.del_flag = 0
-        <if test="isSelf">
-            AND a.STATUS = '1'
-        </if>
     </select>
 
-
+    <update id="updateStatusById">
+        update plugin_notify set status = #{status} where id = #{id}
+    </update>
 
 </mapper>

+ 30 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/PluginNotifyOfficesMapper.xml

@@ -0,0 +1,30 @@
+<?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.notify.mapper.PluginNotifyOfficesMapper">
+
+    <resultMap id="BaseResultMap" type="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+            <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+            <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
+            <result property="officeId" column="office_id" jdbcType="VARCHAR"/>
+            <result property="notifyId" column="notify_id" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="Offices_Column_List">
+        pno.id,
+        pno.create_by,
+        pno.create_date,
+        pno.update_by,
+        pno.update_date,
+        pno.del_flag,
+        pno.remarks,
+        pno.office_id,
+        pno.notify_id
+    </sql>
+</mapper>

+ 30 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/PluginNotifyUserMapper.xml

@@ -0,0 +1,30 @@
+<?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.notify.mapper.PluginNotifyUserMapper">
+
+    <resultMap id="BaseResultMap" type="com.jeeplus.notify.service.dto.PluginNotifyUserDTO">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+            <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+            <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
+            <result property="userId" column="user_id" jdbcType="VARCHAR"/>
+            <result property="notifyId" column="notify_id" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="Users_Column_List">
+        pnu.id,
+        pnu.create_by,
+        pnu.create_date,
+        pnu.update_by,
+        pnu.update_date,
+        pnu.del_flag,
+        pnu.remarks,
+        pnu.user_id,
+        pnu.notify_id
+    </sql>
+</mapper>

+ 160 - 8
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/NotifyService.java

@@ -3,24 +3,46 @@
  */
 package com.jeeplus.notify.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jeeplus.notify.domain.Notify;
 import com.jeeplus.notify.domain.NotifyRecord;
+import com.jeeplus.notify.domain.PluginNotifyOffices;
+import com.jeeplus.notify.domain.PluginNotifyUser;
 import com.jeeplus.notify.mapper.NotifyMapper;
+import com.jeeplus.notify.mapper.PluginNotifyOfficesMapper;
+import com.jeeplus.notify.mapper.PluginNotifyUserMapper;
 import com.jeeplus.notify.service.dto.NotifyDTO;
+import com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO;
 import com.jeeplus.notify.service.mapstruct.NotifyRecordWrapper;
 import com.jeeplus.notify.service.mapstruct.NotifyWrapper;
 import com.jeeplus.sys.constant.CommonConstants;
+import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.mapper.UserMapper;
+import com.jeeplus.sys.utils.StringUtils;
 import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
+import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
+import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientBaseWrapper;
+import com.jeeplus.test.editor.domain.EditorFiles;
+import com.jeeplus.test.editor.service.EditorFilesService;
+import com.jeeplus.test.editor.service.dto.EditorFilesDTO;
+import com.jeeplus.test.oss.service.OssService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 通知通告Service
@@ -35,6 +57,21 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
     @Autowired
     private NotifyRecordService notifyRecordService;
 
+    @Resource
+    private OssService ossService;
+
+    @Resource
+    private PluginNotifyOfficesMapper pluginNotifyOfficesMapper;
+
+    @Resource
+    private PluginNotifyUserMapper pluginNotifyUserMapper;
+
+    @Resource
+    private EditorFilesService editorFilesService;
+
+    @Resource
+    private UserMapper userMapper;
+
     /**
      * 根据id获取通知
      */
@@ -62,9 +99,80 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
      */
     public NotifyDTO getDetail(String id) {
         NotifyDTO notifyDTO = baseMapper.getById ( id );
-        List notifyRecordList = notifyRecordService.findListByNotifyId ( id );
-        notifyDTO.setNotifyRecordDTOList ( notifyRecordList );
-        return notifyDTO;
+        if (ObjectUtil.isNotEmpty(notifyDTO)) {
+            List notifyRecordList = notifyRecordService.findListByNotifyId ( id );
+            if (CollectionUtil.isNotEmpty(notifyRecordList)) {
+                notifyDTO.setNotifyRecordDTOList ( notifyRecordList );
+            }
+            // 1. 将富文本中的临时图片地址更换为新的
+            // 2. 获取富文本中的图片信息
+            if(StringUtils.isNotBlank(notifyDTO.getContent())){
+                notifyDTO.setContent(editorFilesService.getNewContent(notifyDTO.getContent(), id));
+                List<EditorFiles> list = editorFilesService.list(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId, id));
+                List<EditorFilesDTO> editorFilesDTOList = new ArrayList<>();
+                list.stream().forEach(item->{
+                    EditorFilesDTO editorFilesDTO = new EditorFilesDTO();
+                    editorFilesDTO.setSourceId(item.getSourceId());
+                    editorFilesDTO.setTemporaryUrl(item.getTemporaryUrl());
+                    editorFilesDTO.setUrl(item.getUrl());
+                    editorFilesDTOList.add(editorFilesDTO);
+                });
+                notifyDTO.setEditorFilesDTOList(editorFilesDTOList);
+            }
+            return notifyDTO;
+        } else {
+            return new NotifyDTO();
+        }
+    }
+
+    // 通知审核通过时,向通知接收人发送通知
+    // 根据所选接收部门以及所选接收用户,获取通知的接收人
+    public String pushNotifyRecord(String id) {
+        NotifyDTO detail = this.getDetail(id);
+        List<String> uIds = new ArrayList<>();
+        List<NotifyRecord> notifyRecordList = new ArrayList<>();
+        if (ObjectUtil.isNotEmpty(detail)) {
+            if (CollectionUtil.isNotEmpty(detail.getPluginNotifyOfficesDTOList())){
+                List<String> officeIds = detail.getPluginNotifyOfficesDTOList().stream().filter(item -> {
+                    if (StringUtils.isNotBlank(item.getOfficeId())) {
+                        return true;
+                    }
+                    return false;
+                }).map(PluginNotifyOfficesDTO::getOfficeId).collect(Collectors.toList());
+                if (CollectionUtil.isNotEmpty(officeIds)) {
+                    List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getOfficeId, officeIds));
+                    if (CollectionUtil.isNotEmpty(userList)) {
+                        userList.stream().forEach(user -> {
+                            if(StringUtils.isNotBlank(user.getId())){
+                                uIds.add(user.getId());
+                            }
+                        });
+                    }
+                }
+            }
+            if (CollectionUtil.isNotEmpty(detail.getPluginNotifyUserDTOList())){
+                detail.getPluginNotifyUserDTOList().stream().forEach(userDTO -> {
+                    if (StringUtils.isNotBlank(userDTO.getUserId())) {
+                        uIds.add(userDTO.getUserId());
+                    }
+                });
+            }
+        }
+        if (CollectionUtil.isNotEmpty(uIds)) {
+            List<String> userIds = uIds.stream().distinct().collect(Collectors.toList());
+            userIds.stream().forEach(userId -> {
+                NotifyRecord notifyRecord = new NotifyRecord();
+                notifyRecord.setUserId(userId);
+                notifyRecord.setNotifyId(id);
+                notifyRecord.setReadFlag("0");
+                notifyRecordList.add(notifyRecord);
+            });
+        }
+        notifyRecordService.remove(new LambdaQueryWrapper<NotifyRecord>().eq(NotifyRecord::getNotifyId,id));
+        if (CollectionUtil.isNotEmpty(notifyRecordList)) {
+            notifyRecordService.saveBatch(notifyRecordList);
+        }
+        return "通知发送完成";
     }
 
 
@@ -83,14 +191,58 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
      * @param notifyDTO
      * @return
      */
-    public boolean saveOrUpdate(NotifyDTO notifyDTO) {
+    public String saveForm(NotifyDTO notifyDTO) {
         Notify notify = NotifyWrapper.INSTANCE.toEntity ( notifyDTO );
         super.saveOrUpdate ( notify );
         notifyDTO.setId ( notify.getId () );
-        // 更新发送接受人记录
-        notifyRecordService.lambdaUpdate ( ).eq ( NotifyRecord::getNotifyId, notify.getId ( ) ).remove ( );
-        notifyRecordService.saveBatch ( NotifyRecordWrapper.INSTANCE.toEntity ( notifyDTO.getNotifyRecordDTOList ( ) ) );
-        return true;
+        if (ObjectUtil.isNotEmpty(notifyDTO)) {
+            //富文本内容
+            editorFilesService.remove(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId,notify.getId ()));
+            if (CollectionUtil.isNotEmpty(notifyDTO.getEditorFilesDTOList())) {
+                notifyDTO.getEditorFilesDTOList().stream().forEach(item->{
+                    editorFilesService.saveUrl(item.getTemporaryUrl(),item.getUrl(),notify.getId());
+                });
+            }
+            // 附件
+            ossService.saveOrUpdateFileList(notifyDTO.getWorkAttachmentDtoList(),notify.getId(),"plugin_notify");
+            // 部门信息
+            pluginNotifyOfficesMapper.delete(new QueryWrapper<PluginNotifyOffices>().lambda().eq(PluginNotifyOffices::getNotifyId,notify.getId()));
+            if (ObjectUtil.isNotEmpty(notifyDTO.getPluginNotifyOfficesDTOList())){
+                notifyDTO.getPluginNotifyOfficesDTOList().stream().forEach(item->{
+                    PluginNotifyOffices pluginNotifyOffices = new PluginNotifyOffices();
+                    pluginNotifyOffices.setOfficeId(item.getOfficeId());
+                    pluginNotifyOffices.setNotifyId(notify.getId());
+                    pluginNotifyOfficesMapper.insert(pluginNotifyOffices);
+                });
+            }
+            // 用户信息
+            pluginNotifyUserMapper.delete(new QueryWrapper<PluginNotifyUser>().lambda().eq(PluginNotifyUser::getNotifyId,notify.getId()));
+            if (ObjectUtil.isNotEmpty(notifyDTO.getPluginNotifyUserDTOList())){
+                notifyDTO.getPluginNotifyUserDTOList().stream().forEach(item->{
+                    PluginNotifyUser pluginNotifyUser = new PluginNotifyUser();
+                    pluginNotifyUser.setUserId(item.getUserId());
+                    pluginNotifyUser.setNotifyId(notify.getId());
+                    pluginNotifyUserMapper.insert(pluginNotifyUser);
+                });
+            }
+            // 审核通过的时候,向用户发送通知
+            if (StringUtils.isNotBlank(notifyDTO.getStatus())) {
+                if ("5".equals(notifyDTO.getStatus())) {
+                    this.pushNotifyRecord(notify.getId());
+                }
+            }
+        }
+        return notify.getId ();
+    }
+
+    public ResponseEntity saveNotify(NotifyDTO notifyDTO){
+        this.saveForm(notifyDTO);
+        return ResponseEntity.ok("保存成功");
+    }
+
+    public String updateStatusById(NotifyDTO notifyDTO) {
+        baseMapper.updateStatusById(notifyDTO.getId(),notifyDTO.getStatus());
+        return "操作成功";
     }
 
     /**

+ 51 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/NotifyDTO.java

@@ -4,16 +4,21 @@
 package com.jeeplus.notify.service.dto;
 
 import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.google.common.collect.Lists;
 import com.jeeplus.core.query.Query;
 import com.jeeplus.core.query.QueryType;
 import com.jeeplus.core.service.dto.BaseDTO;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.test.editor.service.dto.EditorFilesDTO;
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import javax.validation.constraints.Size;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -68,11 +73,57 @@ public class NotifyDTO extends BaseDTO {
      */
     private boolean isSelf;
     /**
+     * 备注
+     */
+    private String remarks;
+    /**
+     * 通告状态
+     */
+    private String notifyType;
+    /**
+     * 文号
+     */
+    private String no;
+    /**
+     * 开始时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date beginDate;
+    /**
+     * 结束时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date endDate;
+    /**
+     * 所属部门id
+     */
+    private String officeId;
+
+    /**
      * 本人阅读状态
      */
     @Query(type = QueryType.EQ)
     private String readFlag;
 
+    /**
+     * 附件
+     */
+    private List<WorkAttachmentDto> workAttachmentDtoList;
+    /**
+     * 接收部门集合
+     */
+    private List<PluginNotifyOfficesDTO> pluginNotifyOfficesDTOList;
+    /**
+     * 接收用户集合
+     */
+    private List<PluginNotifyUserDTO> pluginNotifyUserDTOList;
+    /**
+     * 富文本图片集合
+     */
+    private List<EditorFilesDTO> editorFilesDTOList;
+
     private List<NotifyRecordDTO> notifyRecordDTOList = Lists.newArrayList();
 
 

+ 37 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/PluginNotifyOfficesDTO.java

@@ -0,0 +1,37 @@
+package com.jeeplus.notify.service.dto;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+/**
+ * 通知通告-通告范围-部门
+ * @TableName plugin_notify_offices
+ */
+@Data
+public class PluginNotifyOfficesDTO extends BaseDTO {
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 部门id
+     */
+    private String officeId;
+
+    /**
+     * 通知id
+     */
+    private String notifyId;
+
+    /**
+     * 部门名称
+     */
+    private String officeName;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 41 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/PluginNotifyUserDTO.java

@@ -0,0 +1,41 @@
+package com.jeeplus.notify.service.dto;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+/**
+ * 通知通告-通告范围-用户
+ * @TableName plugin_notify_user
+ */
+@Data
+public class PluginNotifyUserDTO extends BaseDTO {
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 用户id
+     */
+    private String userId;
+
+    /**
+     * 通知id
+     */
+    private String notifyId;
+
+    /**
+     * 用户名称
+     */
+    private String userName;
+
+    /**
+     * 所属部门
+     */
+    private String officeName;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 20 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/WorkAttachmentDto.java

@@ -0,0 +1,20 @@
+package com.jeeplus.notify.service.dto;
+
+import com.jeeplus.core.service.dto.BaseDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
+import lombok.Data;
+
+@Data
+public class WorkAttachmentDto extends BaseDTO {
+
+    private String name;
+
+    private String size;
+
+    private String url;
+
+    private UserDTO createBy;
+
+    private String by;
+
+}