Ver Fonte

通知公告管理

shudonghui há 1 ano atrás
pai
commit
d0627eb015
32 ficheiros alterados com 1305 adições e 76 exclusões
  1. 156 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/SysMessageExportDto.java
  2. 42 0
      sop-business/src/main/java/com/qmth/sop/business/bean/result/SysMessageCountResult.java
  3. 153 0
      sop-business/src/main/java/com/qmth/sop/business/bean/result/SysMessageResult.java
  4. 12 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysMessage.java
  5. 12 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysNotice.java
  6. 12 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBUserArchivesSupplier.java
  7. 30 8
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysMessageMapper.java
  8. 22 7
      sop-business/src/main/java/com/qmth/sop/business/mapper/SysNoticeMapper.java
  9. 5 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesSupplierMapper.java
  10. 48 7
      sop-business/src/main/java/com/qmth/sop/business/service/SysMessageService.java
  11. 43 7
      sop-business/src/main/java/com/qmth/sop/business/service/SysNoticeService.java
  12. 3 0
      sop-business/src/main/java/com/qmth/sop/business/service/SysUserService.java
  13. 3 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBServiceService.java
  14. 4 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesSupplierService.java
  15. 154 7
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysMessageServiceImpl.java
  16. 122 7
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysNoticeServiceImpl.java
  17. 7 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java
  18. 7 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBServiceServiceImpl.java
  19. 7 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesSupplierServiceImpl.java
  20. 79 0
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysMessageExportService.java
  21. 10 0
      sop-business/src/main/java/com/qmth/sop/business/templete/service/TaskLogicService.java
  22. 56 4
      sop-business/src/main/java/com/qmth/sop/business/templete/service/impl/TaskLogicServiceImpl.java
  23. 8 1
      sop-business/src/main/resources/db/log/shudonghui_update_log.sql
  24. 3 2
      sop-business/src/main/resources/mapper/SysDeviceMapper.xml
  25. 1 1
      sop-business/src/main/resources/mapper/SysDingGroupMapper.xml
  26. 38 1
      sop-business/src/main/resources/mapper/SysMessageMapper.xml
  27. 26 1
      sop-business/src/main/resources/mapper/SysNoticeMapper.xml
  28. 6 1
      sop-business/src/main/resources/mapper/TBUserArchivesSupplierMapper.xml
  29. 3 0
      sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java
  30. 3 1
      sop-common/src/main/java/com/qmth/sop/common/enums/TaskTypeEnum.java
  31. 133 10
      sop-server/src/main/java/com/qmth/sop/server/api/SysMessageController.java
  32. 97 11
      sop-server/src/main/java/com/qmth/sop/server/api/SysNoticeController.java

+ 156 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/SysMessageExportDto.java

@@ -0,0 +1,156 @@
+package com.qmth.sop.business.bean.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.HeadFontStyle;
+import com.alibaba.excel.annotation.write.style.HeadStyle;
+import com.qmth.sop.business.util.excel.BasicExcelRow;
+import com.qmth.sop.common.enums.ProductTypeEnum;
+
+import java.io.Serializable;
+
+/**
+ * @Description:
+ * @Param:
+ * @return:
+ * @Author: dhshu
+ * @Date: 2023/7/31
+ */
+@ColumnWidth(value = 30)
+@HeadStyle(fillForegroundColor = 11)
+@HeadFontStyle(color = 1)
+public class SysMessageExportDto extends BasicExcelRow implements Serializable {
+
+    @ExcelProperty(value = "档案流水号")
+    private String code;
+
+    @ExcelProperty(value = "姓名")
+    private String name;
+
+    @ExcelProperty(value = "供应商")
+    private String supplier;
+
+
+    @ExcelProperty(value = "国家")
+    private String country;
+
+    @ExcelProperty(value = "常居省份")
+    private String province;
+
+    @ExcelProperty(value = "常居城市")
+    private String city;
+
+    @ExcelProperty(value = "服务单元")
+    private String service;
+
+    @ExcelProperty(value = "客户名称")
+    private String custom;
+
+    @ExcelProperty(value = "客户类型")
+    private String type;
+
+    @ExcelProperty(value = "消息查阅时间")
+    private String time;
+
+    @ExcelProperty(value = "联系电话")
+    private String mobileNumber;
+
+    @ExcelProperty(value = "回执状态")
+    private String status;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getSupplier() {
+        return supplier;
+    }
+
+    public void setSupplier(String supplier) {
+        this.supplier = supplier;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getService() {
+        return service;
+    }
+
+    public void setService(String service) {
+        this.service = service;
+    }
+
+    public String getCustom() {
+        return custom;
+    }
+
+    public void setCustom(String custom) {
+        this.custom = custom;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public String getMobileNumber() {
+        return mobileNumber;
+    }
+
+    public void setMobileNumber(String mobileNumber) {
+        this.mobileNumber = mobileNumber;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 42 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/SysMessageCountResult.java

@@ -0,0 +1,42 @@
+package com.qmth.sop.business.bean.result;
+
+import com.qmth.sop.business.entity.SysCustom;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+
+ * </p>
+ *
+ * @author dhshu
+ * @since 2023-08-01
+ */
+
+public class SysMessageCountResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "已阅")
+    private long reviewed;
+
+    @ApiModelProperty(value = "全部")
+    private long total;
+
+    public long getReviewed() {
+        return reviewed;
+    }
+
+    public void setReviewed(long reviewed) {
+        this.reviewed = reviewed;
+    }
+
+    public long getTotal() {
+        return total;
+    }
+
+    public void setTotal(long total) {
+        this.total = total;
+    }
+}

+ 153 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/SysMessageResult.java

@@ -0,0 +1,153 @@
+package com.qmth.sop.business.bean.result;
+
+import com.qmth.sop.common.enums.ProductTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+
+ * </p>
+ *
+ * @author dhshu
+ * @since 2023-08-01
+ */
+
+public class SysMessageResult implements Serializable {
+
+    @ApiModelProperty(value = "档案流水号")
+    private String code;
+
+    @ApiModelProperty(value = "姓名")
+    private String name;
+
+    @ApiModelProperty(value = "供应商")
+    private String supplier;
+
+
+    @ApiModelProperty(value = "国家")
+    private String country;
+
+    @ApiModelProperty(value = "常居省份")
+    private String province;
+
+    @ApiModelProperty(value = "常居城市")
+    private String city;
+
+    @ApiModelProperty(value = "服务单元")
+    private String service;
+
+    @ApiModelProperty(value = "客户名称")
+    private String custom;
+
+    @ApiModelProperty(value = "客户类型")
+    private ProductTypeEnum type;
+
+
+    @ApiModelProperty(value = "消息查阅时间")
+    private Long receiveTime;
+
+    @ApiModelProperty(value = "联系电话")
+    private String mobileNumber;
+
+    @ApiModelProperty(value = "回执状态")
+    private Boolean status;
+
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getSupplier() {
+        return supplier;
+    }
+
+    public void setSupplier(String supplier) {
+        this.supplier = supplier;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getService() {
+        return service;
+    }
+
+    public void setService(String service) {
+        this.service = service;
+    }
+
+    public String getCustom() {
+        return custom;
+    }
+
+    public void setCustom(String custom) {
+        this.custom = custom;
+    }
+
+    public ProductTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ProductTypeEnum type) {
+        this.type = type;
+    }
+
+    public Long getReceiveTime() {
+        return receiveTime;
+    }
+
+    public void setReceiveTime(Long receiveTime) {
+        this.receiveTime = receiveTime;
+    }
+
+    public String getMobileNumber() {
+        return mobileNumber;
+    }
+
+    public void setMobileNumber(String mobileNumber) {
+        this.mobileNumber = mobileNumber;
+    }
+
+    public Boolean getStatus() {
+        return status;
+    }
+
+    public void setStatus(Boolean status) {
+        this.status = status;
+    }
+}

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysMessage.java

@@ -39,6 +39,10 @@ public class SysMessage implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long serviceId;
 
+    @ApiModelProperty(value = "供应商id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long supplierId;
+
     @ApiModelProperty(value = "发送人id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long formUserId;
@@ -146,4 +150,12 @@ public class SysMessage implements Serializable {
     public void setStatus(Boolean status) {
         this.status = status;
     }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
 }

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysNotice.java

@@ -27,6 +27,10 @@ public class SysNotice extends BaseEntity implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long serviceId;
 
+    @ApiModelProperty(value = "供应商id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long supplierId;
+
     @ApiModelProperty(value = "标题")
     private String title;
 
@@ -100,4 +104,12 @@ public class SysNotice extends BaseEntity implements Serializable {
     public void setPublishTime(Long publishTime) {
         this.publishTime = publishTime;
     }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
 }

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBUserArchivesSupplier.java

@@ -40,6 +40,10 @@ public class TBUserArchivesSupplier implements Serializable {
     @ApiModelProperty(value = "认证有效时间")
     private Long authenticationValidTime;
 
+    @ApiModelProperty(value = "供应商id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long supplierId;
+
     @ApiModelProperty(value = "备注")
     private String remark;
 
@@ -98,4 +102,12 @@ public class TBUserArchivesSupplier implements Serializable {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
 }

+ 30 - 8
sop-business/src/main/java/com/qmth/sop/business/mapper/SysMessageMapper.java

@@ -1,16 +1,38 @@
 package com.qmth.sop.business.mapper;
 
-import com.qmth.sop.business.entity.SysMessage;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.result.SysMessageCountResult;
+import com.qmth.sop.business.bean.result.SysMessageResult;
+import com.qmth.sop.business.entity.SysMessage;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 /**
- * <p>
- * 系统消息 Mapper 接口
- * </p>
- *
- * @author wangliang
- * @since 2023-08-01
+ * 系统消息 Mapper 接口.
+ * 
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:28
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
 public interface SysMessageMapper extends BaseMapper<SysMessage> {
 
-}
+	/**
+	 * 查询列表
+	 * @param iPage
+	 * @return
+	 */
+	public IPage<SysMessageResult> query(IPage<Map> iPage, @Param("noticeId")  Long noticeId, @Param("city")  String city, @Param("supplierId")  Long supplierId, @Param("status")  Boolean status);
+	/**
+	 * 查询列表
+	 * @return
+	 */
+	public List<SysMessageResult> query(@Param("noticeId")  Long noticeId, @Param("city")  String city, @Param("supplierId")  Long supplierId, @Param("status")  Boolean status);
+
+	SysMessageCountResult count(@Param("noticeId") long noticeId);
+}

+ 22 - 7
sop-business/src/main/java/com/qmth/sop/business/mapper/SysNoticeMapper.java

@@ -1,16 +1,31 @@
 package com.qmth.sop.business.mapper;
 
-import com.qmth.sop.business.entity.SysNotice;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.common.enums.NoticeTypeEnum;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
 
 /**
- * <p>
- * 公告表 Mapper 接口
- * </p>
+ * 公告表 Mapper 接口.
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
 public interface SysNoticeMapper extends BaseMapper<SysNotice> {
 
-}
+    /**
+     * 查询列表
+     *
+     * @param iPage
+     * @return
+     */
+    public IPage<SysNotice> query(IPage<Map> iPage, @Param("query") String query, @Param("status") String status, @Param("type") String type, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
+
+}

+ 5 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesSupplierMapper.java

@@ -1,7 +1,11 @@
 package com.qmth.sop.business.mapper;
 
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBUserArchivesSupplier;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TBUserArchivesSupplierMapper extends BaseMapper<TBUserArchivesSupplier> {
 
+    List<SysUser> findUsersBySupplierId(@Param("supplierId") Long supplierId);
 }

+ 48 - 7
sop-business/src/main/java/com/qmth/sop/business/service/SysMessageService.java

@@ -1,16 +1,57 @@
 package com.qmth.sop.business.service;
 
-import com.qmth.sop.business.entity.SysMessage;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.result.SysMessageCountResult;
+import com.qmth.sop.business.bean.result.SysMessageResult;
+import com.qmth.sop.business.entity.SysMessage;
+import com.qmth.sop.business.entity.SysNotice;
+
+import java.util.List;
+import java.util.Map;
 
 /**
- * <p>
  * 系统消息 服务类
- * </p>
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
-public interface SysMessageService extends IService<SysMessage> {
+public interface SysMessageService extends IService<SysMessage>{
+
+    /**
+    * 查询列表
+    *
+    * @param iPage
+    * @return
+    */
+    IPage<SysMessageResult> query(IPage<Map> iPage, Long noticeId, String city, Long supplierId, Boolean status);
+
+    List<SysMessageResult> query(Long noticeId, String city, Long supplierId, Boolean status);
+//
+//    /**
+//    * 新增修改系统消息
+//    *
+//    * @param sysMessage
+//    */
+//    Boolean saveSysMessage(SysMessage sysMessage);
+//
+//
+//    /**
+//    * 删除系统消息
+//    *
+//    * @param id
+//    */
+//    Boolean delete(Long id);
+
+
+    SysMessageCountResult count(long noticeId);
+
+    void deleteByNoticeId(long id);
+
+    void publishByNotice(SysNotice sysNotice);
 
-}
+}

+ 43 - 7
sop-business/src/main/java/com/qmth/sop/business/service/SysNoticeService.java

@@ -1,16 +1,52 @@
 package com.qmth.sop.business.service;
 
-import com.qmth.sop.business.entity.SysNotice;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.common.enums.NoticeStatusEnum;
+import com.qmth.sop.common.enums.NoticeTypeEnum;
+
+import java.util.Map;
 
 /**
- * <p>
  * 公告表 服务类
- * </p>
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
-public interface SysNoticeService extends IService<SysNotice> {
+public interface SysNoticeService extends IService<SysNotice>{
+
+    /**
+    * 查询列表
+    *
+    * @param iPage
+    * @return
+    */
+    IPage<SysNotice> query(IPage<Map> iPage, String query, NoticeStatusEnum status, NoticeTypeEnum type, Long startTime, Long endTime);
+
+    /**
+    * 新增修改公告表
+    *
+    * @param sysNotice
+    */
+    Boolean saveSysNotice(SysNotice sysNotice);
+
+
+    /**
+    * 删除公告表
+    *
+    * @param id
+    */
+    Boolean delete(Long id);
+
+
+    boolean disable(long[] ids);
+
+    boolean publishOrUnpublish(long id);
+
 
-}
+}

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysUserService.java

@@ -93,4 +93,7 @@ public interface SysUserService extends IService<SysUser> {
      * @return
      */
     Boolean enable(SysUser sysUser) throws NoSuchAlgorithmException;
+
+    List<SysUser> listEnable();
+
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBServiceService.java

@@ -3,6 +3,8 @@ package com.qmth.sop.business.service;
 import com.qmth.sop.business.entity.TBService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 服务单元表 服务类
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TBServiceService extends IService<TBService> {
 
+    List<TBService> listEnable(Long id);
 }

+ 4 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesSupplierService.java

@@ -1,8 +1,11 @@
 package com.qmth.sop.business.service;
 
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBUserArchivesSupplier;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 人员档案与供应商表 服务类
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TBUserArchivesSupplierService extends IService<TBUserArchivesSupplier> {
 
+    List<SysUser> findUsers(Long supplierId);
 }

+ 154 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysMessageServiceImpl.java

@@ -1,20 +1,167 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.result.SysMessageCountResult;
+import com.qmth.sop.business.bean.result.SysMessageResult;
 import com.qmth.sop.business.entity.SysMessage;
+import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.business.entity.SysUser;
+import com.qmth.sop.business.entity.TBService;
 import com.qmth.sop.business.mapper.SysMessageMapper;
 import com.qmth.sop.business.service.SysMessageService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.service.SysUserService;
+import com.qmth.sop.business.service.TBServiceService;
+import com.qmth.sop.business.service.TBUserArchivesSupplierService;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
+import com.qmth.sop.common.enums.MessageTypeEnum;
+import com.qmth.sop.common.enums.NoticeTypeEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
- * <p>
- * 系统消息 服务实现类
- * </p>
+ * 系统消息 服务实现.
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
 @Service
 public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {
 
-}
+
+    @Resource
+    SysUserService sysUserService;
+
+
+    @Resource
+    TBUserArchivesSupplierService tbUserArchivesSupplierService;
+
+    @Resource
+    TBServiceService tbServiceService;
+
+//    /**
+//     * 查询列表
+//     *
+//     * @param iPage
+//     * @return
+//     */
+//    @Override
+//    public IPage<SysMessage> query(IPage<Map> iPage, String query) {
+//        return this.baseMapper.query(iPage, query);
+//    }
+//
+//    /**
+//     * 新增修改系统消息
+//     *
+//     * @param sysMessage
+//     */
+//    @Override
+//    @Transactional
+//    public Boolean saveSysMessage(SysMessage sysMessage) {
+//        try {
+//            SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+//            if (Objects.isNull(sysMessage.getId())) {// 新增
+//                //sysMessage.insertInfo(sysUser.getId());
+//            } else { // 修改
+//                //sysMessage.updateInfo(sysUser.getId());
+//            }
+//            return saveOrUpdate(sysMessage);
+//        } catch (Exception e) {
+//            if (e instanceof DuplicateKeyException) {
+//                String errorColumn = e.getCause().toString();
+//                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+//                throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+//            } else if (e instanceof ApiException) {
+//                ResultUtil.error((ApiException) e, e.getMessage());
+//            } else {
+//                ResultUtil.error(e.getMessage());
+//            }
+//        }
+//        return null;
+//
+//    }
+//
+//    /**
+//     * 删除系统消息
+//     *
+//     * @param id
+//     */
+//    @Override
+//    @Transactional
+//    public Boolean delete(Long id) {
+//        return this.removeById(id);
+//    }
+
+    @Override
+    public IPage<SysMessageResult> query(IPage<Map> iPage, Long noticeId, String city, Long supplierId, Boolean status) {
+        return this.baseMapper.query(iPage, noticeId,city,supplierId,status);
+    }
+
+    @Override
+    public List<SysMessageResult> query(Long noticeId, String city, Long supplierId, Boolean status) {
+        return this.baseMapper.query(noticeId,city,supplierId,status);
+    }
+
+    @Override
+    public SysMessageCountResult count(long noticeId) {
+        return this.baseMapper.count(noticeId);
+    }
+
+    @Override
+    @Transactional
+    public void deleteByNoticeId(long noticeId) {
+        this.remove(new QueryWrapper<SysMessage>().lambda().eq(SysMessage::getNoticeId, noticeId));
+    }
+
+    @Override
+    @Transactional
+    public void publishByNotice(SysNotice sysNotice) {
+        if (sysNotice.getType() == NoticeTypeEnum.SYSTEM) {
+            List<SysUser> sysUsers = sysUserService.listEnable();
+            sysUsers.forEach(s -> {
+                insertMessage(sysNotice, s.getId());
+            });
+        } else if (sysNotice.getType() == NoticeTypeEnum.SUPPLIER) {
+            List<SysUser> sysUsers = tbUserArchivesSupplierService.findUsers(sysNotice.getSupplierId());
+            sysUsers.forEach(s -> {
+                insertMessage(sysNotice, s.getId());
+            });
+        } else if (sysNotice.getType() == NoticeTypeEnum.SERVICE) {
+            List<TBService> tbServices = tbServiceService.listEnable(sysNotice.getServiceId());
+            tbServices.forEach(s -> {
+                insertMessage(sysNotice, s.getServiceLeadId());
+            });
+        }
+
+    }
+
+    private void insertMessage(SysNotice sysNotice, Long s) {
+        SysMessage sysMessage = new SysMessage();
+        sysMessage.setContent(sysNotice.getContent());
+        sysMessage.setCrmNo(null);
+        sysMessage.setFormUserId(sysNotice.getCreateId());
+        sysMessage.setNoticeId(sysNotice.getId());
+        sysMessage.setReceiveUserId(s);
+        sysMessage.setSendTime(System.currentTimeMillis());
+        sysMessage.setServiceId(sysNotice.getServiceId());
+        sysMessage.setStatus(false);
+        sysMessage.setSupplierId(sysNotice.getSupplierId());
+        sysMessage.setType(MessageTypeEnum.SYSTEM);
+        this.save(sysMessage);
+    }
+
+}

+ 122 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysNoticeServiceImpl.java

@@ -1,20 +1,135 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysNoticeMapper;
+import com.qmth.sop.business.service.SysMessageService;
 import com.qmth.sop.business.service.SysNoticeService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
+import com.qmth.sop.common.enums.NoticeStatusEnum;
+import com.qmth.sop.common.enums.NoticeTypeEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
- * <p>
- * 公告表 服务实现类
- * </p>
+ * 公告表 服务实现.
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
 @Service
 public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements SysNoticeService {
 
-}
+    @Resource
+    SysMessageService sysMessageService;
+    /**
+     * 查询列表
+     *
+     * @param iPage
+     * @return
+     */
+    @Override
+    public IPage<SysNotice> query(IPage<Map> iPage, String query, NoticeStatusEnum status, NoticeTypeEnum type, Long startTime, Long endTime) {
+        return this.baseMapper.query(iPage,query, Objects.nonNull(status) ? status.name() : null, Objects.nonNull(type) ? type.name() : null, startTime, endTime);
+    }
+
+
+    /**
+     * 新增修改公告表
+     *
+     * @param sysNotice
+     */
+    @Override
+    @Transactional
+    public Boolean saveSysNotice(SysNotice sysNotice) {
+        try {
+            sysNotice.setEnable(true);
+            sysNotice.setStatus(NoticeStatusEnum.UN_PUBLISH);
+            SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+            if (Objects.isNull(sysNotice.getId())) {// 新增
+                sysNotice.insertInfo(sysUser.getId());
+            } else { // 修改
+                sysNotice.updateInfo(sysUser.getId());
+            }
+            return saveOrUpdate(sysNotice);
+        } catch (Exception e) {
+            if (e instanceof DuplicateKeyException) {
+                String errorColumn = e.getCause().toString();
+                String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+                throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+            } else if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        }
+        return null;
+
+    }
+
+    /**
+     * 删除公告表
+     *
+     * @param id
+     */
+    @Override
+    @Transactional
+    public Boolean delete(Long id) {
+        return this.removeById(id);
+    }
+
+    @Override
+    @Transactional
+    public boolean disable(long[] ids) {
+//        List<SysNotice> sysNotices=new ArrayList<>();
+        for (long id : ids) {
+            SysNotice sysNotice = this.getById(id);
+            sysNotice.setEnable(false);
+            if(NoticeStatusEnum.PUBLISH == sysNotice.getStatus()) {
+                sysNotice.setStatus(NoticeStatusEnum.UN_PUBLISH);
+                // 需调用撤销发布SysMessage
+                sysMessageService.deleteByNoticeId(id);
+            }
+//            sysNotices.add(sysNotice);
+            this.saveOrUpdate(sysNotice);
+        }
+//        this.updateBatchById(sysNotices);
+        return true;
+    }
+
+    @Override
+    @Transactional
+    public boolean publishOrUnpublish(long id) {
+        SysNotice sysNotice = this.getById(id);
+        if (NoticeStatusEnum.PUBLISH == sysNotice.getStatus()) {
+            sysNotice.setStatus(NoticeStatusEnum.UN_PUBLISH);
+            // 需调用撤销发布删除SysMessage
+            sysMessageService.deleteByNoticeId(id);
+        }else {
+            sysNotice.setEnable(true);
+            sysNotice.setStatus(NoticeStatusEnum.PUBLISH);
+            sysNotice.setPublishTime(System.currentTimeMillis());
+            //需调发布插入表SysMessage
+            sysMessageService.publishByNotice(sysNotice);
+        }
+        return this.saveOrUpdate(sysNotice);
+    }
+
+}

+ 7 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -143,6 +143,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return this.baseMapper.findSysUserResultList(orgId);
     }
 
+
     /**
      * 强行过期用户手机号验证码(过期时间改为验证码发送时间)
      *
@@ -317,4 +318,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         }
         return true;
     }
+
+    @Override
+    public List<SysUser> listEnable() {
+        return this.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getEnable, true));
+
+    }
 }

+ 7 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBServiceServiceImpl.java

@@ -1,11 +1,14 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.entity.TBService;
 import com.qmth.sop.business.mapper.TBServiceMapper;
 import com.qmth.sop.business.service.TBServiceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 服务单元表 服务实现类
@@ -17,4 +20,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBServiceServiceImpl extends ServiceImpl<TBServiceMapper, TBService> implements TBServiceService {
 
+    @Override
+    public List<TBService> listEnable(Long id) {
+        return this.list(new QueryWrapper<TBService>().lambda().eq(TBService::getEnable,true).eq(TBService::getId,id));
+    }
 }

+ 7 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesSupplierServiceImpl.java

@@ -1,11 +1,14 @@
 package com.qmth.sop.business.service.impl;
 
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBUserArchivesSupplier;
 import com.qmth.sop.business.mapper.TBUserArchivesSupplierMapper;
 import com.qmth.sop.business.service.TBUserArchivesSupplierService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 人员档案与供应商表 服务实现类
@@ -17,4 +20,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBUserArchivesSupplierServiceImpl extends ServiceImpl<TBUserArchivesSupplierMapper, TBUserArchivesSupplier> implements TBUserArchivesSupplierService {
 
+    @Override
+    public List<SysUser> findUsers(Long supplierId) {
+        return this.baseMapper.findUsersBySupplierId(supplierId) ;
+    }
 }

+ 79 - 0
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncSysMessageExportService.java

@@ -0,0 +1,79 @@
+package com.qmth.sop.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.dto.SysMessageExportDto;
+import com.qmth.sop.business.entity.BasicAttachment;
+import com.qmth.sop.business.entity.TBTask;
+import com.qmth.sop.business.service.TBTaskService;
+import com.qmth.sop.business.templete.export.AsyncExportTaskTemplete;
+import com.qmth.sop.business.templete.service.TaskLogicService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.TaskResultEnum;
+import com.qmth.sop.common.enums.TaskStatusEnum;
+import com.qmth.sop.common.enums.TaskTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * @Description: 回执明细导出
+ * @Param:
+ * @return:
+ * @Author: dhshu
+ * @Date: 2023/8/7
+ */
+@Service
+public class AsyncSysMessageExportService extends AsyncExportTaskTemplete {
+    private final static Logger log = LoggerFactory.getLogger(AsyncSysMessageExportService.class);
+    public static final String OBJ_TITLE = "回执明细导出";
+
+    @Resource
+    TaskLogicService taskLogicService;
+
+    @Resource
+    TBTaskService tbTaskService;
+
+    @Override
+    public Result exportTask(Map<String, Object> map) throws Exception {
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
+        tbTask.setStatus(TaskStatusEnum.RUNNING);
+        tbTask.setSummary(stringJoinerSummary.toString());
+        tbTaskService.updateById(tbTask);
+        try {
+            Map<String, Object> result = taskLogicService.executeExportSysMessageLogic(map);
+            List<SysMessageExportDto> archivesImportDtoList = (List<SysMessageExportDto>) result.get(SystemConstant.EXCEL_DATA);
+            BasicAttachment basicAttachment = (BasicAttachment) result.get(SystemConstant.EXCEL_ATTACHMENT);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, !CollectionUtils.isEmpty(archivesImportDtoList) ? archivesImportDtoList.size() : 0, FINISH_SIZE));
+
+            tbTask.setImportFileName(TaskTypeEnum.MESSAGE_IMPORT.getTitle());
+            tbTask.setResultFilePath(basicAttachment.getPath());
+            tbTask.setResult(TaskResultEnum.SUCCESS);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
+            tbTask.setResult(TaskResultEnum.ERROR);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {//生成txt文件
+            tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
+        }
+        return ResultUtil.ok();
+    }
+}

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/templete/service/TaskLogicService.java

@@ -36,4 +36,14 @@ public interface TaskLogicService {
      * @throws Exception 异常
      */
     Map<String, Object> executeImportCustomLogic(Map<String, Object> map) throws Exception;
+
+
+    /**
+     * 处理回执明细导出
+     *
+     * @param map 数据源
+     * @return 结果
+     * @throws Exception 异常
+     */
+    Map<String, Object> executeExportSysMessageLogic(Map<String, Object> map) throws Exception;
 }

+ 56 - 4
sop-business/src/main/java/com/qmth/sop/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -3,12 +3,11 @@ package com.qmth.sop.business.templete.service.impl;
 import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.bean.dto.CustomImportDto;
+import com.qmth.sop.business.bean.dto.SysMessageExportDto;
 import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
+import com.qmth.sop.business.bean.result.SysMessageResult;
 import com.qmth.sop.business.entity.*;
-import com.qmth.sop.business.service.BasicAttachmentService;
-import com.qmth.sop.business.service.SysCustomService;
-import com.qmth.sop.business.service.SysLevelService;
-import com.qmth.sop.business.service.SysUserService;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.business.templete.service.TaskLogicService;
 import com.qmth.sop.business.util.ImportExportUtil;
 import com.qmth.sop.business.util.excel.BasicExcelListener;
@@ -24,7 +23,9 @@ import org.springframework.util.LinkedMultiValueMap;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.InputStream;
+import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 任务处理逻辑impl
@@ -54,6 +55,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     SysLevelService sysLevelService;
 
+    @Resource
+    SysMessageService sysMessageService;
+
 
     /**
      * 处理导入人员档案数据
@@ -154,6 +158,54 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
+
+    /**
+     * 处理回执明细导出
+     *
+     * @param map 数据源
+     * @return 结果
+     * @throws Exception 异常
+     */
+    @Override
+    public Map<String, Object> executeExportSysMessageLogic(Map<String, Object> map) throws Exception {
+        File fileTemp = null;
+        try {
+            fileTemp = SystemConstant.getFileTempVar(SystemConstant.XLSX_PREFIX);
+
+            List<SysMessageResult> lists = sysMessageService.query((Long) map.get("noticeId"), (String) map.get("city"), (Long) map.get("supplierId"), (Boolean) map.get("status"));
+          //List<SysMessageResult> 转化成 List<SysMessageExportDto>
+
+            List<SysMessageExportDto> sysMessageExportDtoList = lists.stream().map(e->{
+                SysMessageExportDto dto=new SysMessageExportDto();
+                dto.setCity(e.getCity());
+                dto.setCode(e.getCode());
+                dto.setCountry(e.getCountry());
+                dto.setCustom(e.getCustom());
+                dto.setMobileNumber(e.getMobileNumber());
+                dto.setName(e.getName());
+                dto.setProvince(e.getProvince());
+                dto.setService(e.getService());
+                dto.setStatus(e.getStatus()?"已阅":"未阅");
+                dto.setSupplier(e.getSupplier());
+                //时间戳转化为日期字符串
+                dto.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(e.getReceiveTime()));
+                dto.setType(e.getType().getTitle());
+                return  dto;
+            }).collect(Collectors.toList());
+
+            EasyExcel.write(fileTemp, SysMessageExportDto.class).sheet("回执明细导出").doWrite(sysMessageExportDtoList);
+
+            BasicAttachment basicAttachment = basicAttachmentService.saveAttachment(fileTemp, UploadFileEnum.FILE);
+            map.computeIfAbsent(SystemConstant.EXCEL_DATA, v -> sysMessageExportDtoList);
+            map.computeIfAbsent(SystemConstant.EXCEL_ATTACHMENT, v -> basicAttachment);
+        } finally {
+            if (Objects.nonNull(fileTemp)) {
+                fileTemp.delete();
+            }
+        }
+        return map;
+    }
+
     /**
      * 处理导出人员档案数据
      *

+ 8 - 1
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -30,4 +30,11 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (280, '考勤查询', '/api/sys/ding/group/list', 'URL', 7, 4, 'AUTH', NULL, 1, 1, 0);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (281, '考勤查询条件', '/api/sys/ding/group/query', 'URL', 7, 5, 'AUTH', '106', 1, 1, 0);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (282, '考勤修改', '/api/sys/ding/group/update', 'URL', 7, 6, 'AUTH', '95', 1, 1, 0);
--------------------------------------------------------------------------------------
+-------------------------------------------------------------------------------------
+
+ALTER TABLE `t_b_user_archives_supplier`
+    ADD COLUMN `supplier_id` bigint NULL COMMENT '供应商ID' AFTER `user_archives_id`;
+ALTER TABLE `sys_message`
+    ADD COLUMN `supplier_id` bigint NULL COMMENT '供应商ID' AFTER `service_id`;
+ALTER TABLE `sys_notice`
+    ADD COLUMN `supplier_id` bigint NULL COMMENT '供应商ID' AFTER `service_id`;

+ 3 - 2
sop-business/src/main/resources/mapper/SysDeviceMapper.xml

@@ -6,8 +6,9 @@
         select * from sys_device a
         <where>
             <if test="query != null and query != ''">
-                and a.name like #{query} and a.serial_no like #{query}
-                and a.brand like #{query} and a.supplier like #{query} and a.buy_time like #{query}
+                and ( a.name like concat('%', #{query} , '%') or a.serial_no like concat('%', #{query} , '%')
+                or a.brand like concat('%', #{query} , '%') or
+                a.supplier like #{query} or a.buy_time like concat('%', #{query} , '%'))
             </if>
         </where>
         order by a.create_time desc

+ 1 - 1
sop-business/src/main/resources/mapper/SysDingGroupMapper.xml

@@ -11,7 +11,7 @@
                 and a.service_id = #{serviceId}
             </if>
             <if test="query != null and query != ''">
-                and (a.name like #{query})
+                and (a.name like concat('%', #{query} , '%'))
             </if>
         </where>
         order by a.create_time desc

+ 38 - 1
sop-business/src/main/resources/mapper/SysMessageMapper.xml

@@ -2,4 +2,41 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.SysMessageMapper">
 
-</mapper>
+    <select id="query" resultType="com.qmth.sop.business.bean.result.SysMessageResult">
+        SELECT
+        m.receive_time,
+        ua.CODE,
+        ua.NAME,
+        ua.province,
+        ua.city,
+        ua.mobile_number,
+        s.NAME supplier,
+        bs.NAME service,
+        c.NAME custom,
+        c.type
+        FROM
+        sys_message m
+        LEFT JOIN sys_user u ON u.id = m.receive_user_id
+        LEFT JOIN sys_custom c ON c.manager_id = u.id
+        LEFT JOIN t_b_user_archives ua ON u.mobile_number = ua.mobile_number
+        LEFT JOIN sys_supplier s ON s.id = m.supplier_id
+        LEFT JOIN t_b_service bs ON bs.id = m.service_id
+        WHERE
+        m.notice_id = #{noticeId}
+        <where>
+            <if test="city != null and city != ''">
+                and ua.city = #{city}
+            </if>
+            <if test="supplierId != null and supplierId != ''">
+                and m.supplier_id = #{supplierId}
+            </if>
+            <if test="status != null and status != ''">
+                and m.status = #{status}
+            </if>
+        </where>
+    </select>
+
+    <select id="count" resultType="com.qmth.sop.business.bean.result.SysMessageCountResult">
+        SELECT count(a.id) total,sum(a.`status`) reviewed FROM sys_message a where a.notice_id=#{noticeId}
+    </select>
+</mapper>

+ 26 - 1
sop-business/src/main/resources/mapper/SysNoticeMapper.xml

@@ -2,4 +2,29 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.SysNoticeMapper">
 
-</mapper>
+    <select id="query" resultType="com.qmth.sop.business.entity.SysNotice">
+        select * from sys_notice a
+        <where>
+            <if test="query != null and query != ''">
+                and a.name like concat('%', #{query} , '%')
+            </if>
+            <if test="status != null and status != ''">
+                and a.status = #{status}
+            </if>
+            <if test="type != null and type != ''">
+                and a.type = #{type}
+            </if>
+            <if test="startTime != null and startTime != '' ">
+                <![CDATA[
+               and a.publish_time >= #{startTime}
+               ]]>
+            </if>
+            <if test="endTime != null and endTime != ''">
+                <![CDATA[
+                and a.publish_time <= #{endTime}
+                ]]>
+            </if>
+        </where>
+        order by a.publish_time desc
+    </select>
+</mapper>

+ 6 - 1
sop-business/src/main/resources/mapper/TBUserArchivesSupplierMapper.xml

@@ -1,5 +1,10 @@
 <?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.qmth.sop.business.mapper.TBUserArchivesSupplierMapper">
-
+    <select id="findUsers" resultType="com.qmth.sop.business.entity.SysUser">
+        SELECT u.* from t_b_user_archives_supplier us
+        left join t_b_user_archives ua on ua.id=us.user_archives_id
+        left join sys_user u on u.mobile_number=ua.mobile_number
+        where us.supplier_id=#{supplierId}
+    </select>
 </mapper>

+ 3 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -26,6 +26,7 @@ import java.util.StringJoiner;
  * @Date: 2019/10/11
  */
 public class SystemConstant {
+
     private final static Logger log = LoggerFactory.getLogger(SystemConstant.class);
 
     /**
@@ -126,6 +127,8 @@ public class SystemConstant {
     public static final String PREFIX_URL_DING_GROUP = "/sys/ding/group";
     public static final String PREFIX_URL_SUPPLIER = "/sys/supplier";
     public static final String PREFIX_URL_LOG = "/sys/log";
+    public static final String PREFIX_URL_NOTICE = "/sys/notice";
+    public static final String PREFIX_URL_MESSAGE = "/sys/message";
 
     /**
      * 缓存配置

+ 3 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/TaskTypeEnum.java

@@ -15,7 +15,9 @@ public enum TaskTypeEnum {
 
     USER_ARCHIVES_EXPORT("人员档案导出"),
 
-    CUSTOM_IMPORT("客户导入");
+    CUSTOM_IMPORT("客户导入"),
+
+    MESSAGE_IMPORT("回执明细导出");
 
     private String title;
 

+ 133 - 10
sop-server/src/main/java/com/qmth/sop/server/api/SysMessageController.java

@@ -1,20 +1,143 @@
 package com.qmth.sop.server.api;
 
-
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.result.SysMessageCountResult;
+import com.qmth.sop.business.bean.result.SysMessageResult;
+import com.qmth.sop.business.entity.TBTask;
+import com.qmth.sop.business.service.SysMessageService;
+import com.qmth.sop.business.service.TBTaskService;
+import com.qmth.sop.business.templete.execute.AsyncSysMessageExportService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.TaskTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
-
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.util.Map;
+import java.util.Objects;
+
 /**
- * <p>
- * 系统消息 前端控制器
- * </p>
- *
- * @author wangliang
- * @since 2023-08-01
+ * 系统消息 控制器
+ * 
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
+@Api(tags = "系统消息 Controller")
 @RestController
-@RequestMapping("/sys-message")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX+SystemConstant.PREFIX_URL_MESSAGE)
+@Validated
 public class SysMessageController {
 
-}
+
+    @Resource
+    SysMessageService sysMessageService;
+
+    @Resource
+    TBTaskService tbTaskService;
+
+    @Resource
+    AsyncSysMessageExportService asyncSysMessageExportService;
+
+    @Aac(auth= BOOL.FALSE)
+    @ApiOperation(value = "回执查询接口")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "回执查询结果", response = SysMessageResult.class)})
+    public Result query(
+                @ApiParam(value = "公告表id", required = true) @RequestParam(required = true) Long noticeId,
+                @ApiParam(value = "区域城市", required = false) @RequestParam(required = false) String city,
+                @ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId,
+                @ApiParam(value = "回执状态", required = false) @RequestParam(required = false) Boolean status,
+                @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        IPage<SysMessageResult> resultIPage = sysMessageService.query(new Page<>(pageNumber, pageSize),noticeId,city,supplierId,status);
+        return ResultUtil.ok(resultIPage);
+    }
+
+    @Aac(auth = BOOL.FALSE)
+    @ApiOperation(value = "回执查询导出")
+    @RequestMapping(value = "/export", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result export(@ApiParam(value = "公告表id", required = true) @RequestParam(required = true) Long noticeId,
+                         @ApiParam(value = "区域城市", required = false) @RequestParam(required = false) String city,
+                         @ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId,
+                         @ApiParam(value = "回执状态", required = false) @RequestParam(required = false) Boolean status) throws Exception {
+        Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.MESSAGE_IMPORT);
+        map.put("noticeId", noticeId);
+        map.put("city", Objects.nonNull(city) ?city: null);
+        map.put("supplierId", Objects.nonNull(supplierId) ?supplierId: null);
+        map.put("status", Objects.nonNull(status) ?status: null);
+        asyncSysMessageExportService.exportTask(map);
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        return ResultUtil.ok(tbTask.getId());
+    }
+
+    /*
+        统计已读和未读系统消息
+     */
+    @Aac(auth= BOOL.FALSE)
+    @ApiOperation(value = "回执统计已读和未读")
+    @RequestMapping(value = "/count", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = SysMessageCountResult.class)})
+    public Result count(@ApiParam(value = "公告表id", required = true) @RequestParam(required = true) long noticeId) throws Exception {
+        return ResultUtil.ok(sysMessageService.count(noticeId));
+    }
+
+
+
+
+
+//    @Aac(auth= BOOL.FALSE)
+//    @ApiOperation(value = "系统消息查询接口")
+//    @RequestMapping(value = "/query", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "系统消息查询结果", response = SysMessage.class)})
+//    public Result query(
+//            @ApiParam(value = "模糊查询条件", required = false) @RequestParam(required = false) String query,
+//            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+//            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+//        IPage<SysMessage> resultIPage = sysMessageService.query(new Page<>(pageNumber, pageSize),query);
+//
+//        return ResultUtil.ok(resultIPage);
+//    }
+//
+//    @Aac(auth= BOOL.FALSE)
+//    @ApiOperation(value = "系统消息新增修改接口")
+//    @RequestMapping(value = "/save", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+//    public Result save(@ApiParam(value = "系统消息信息", required = true) @RequestBody(required = true) SysMessage sysMessage) {
+//        return ResultUtil.ok(sysMessageService.saveSysMessage(sysMessage));
+//    }
+//
+//
+//    @Aac(auth= BOOL.FALSE)
+//    @ApiOperation(value = "系统消息删除接口")
+//    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+//    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+//    public Result delete(@ApiParam(value = "系统消息id", required = true) @RequestParam(required = true) long id) {
+//        return ResultUtil.ok(sysMessageService.delete(id));
+//    }
+//
+//
+//    @ApiOperation(value = "系统消息获取单个接口")
+//    @RequestMapping(value = "/get", method = RequestMethod.GET)
+//    @ApiResponses({@ApiResponse(code = 200, message = "系统消息信息", response = SysMessage.class)})
+//    public Result get(@ApiParam(value = "系统消息id", required = true) @RequestParam long id) {
+//        return ResultUtil.ok(sysMessageService.getById(id));
+//    }
+
+
+}

+ 97 - 11
sop-server/src/main/java/com/qmth/sop/server/api/SysNoticeController.java

@@ -1,20 +1,106 @@
 package com.qmth.sop.server.api;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.business.service.SysNoticeService;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.NoticeStatusEnum;
+import com.qmth.sop.common.enums.NoticeTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 
 /**
- * <p>
- * 公告表 前端控制器
- * </p>
- *
- * @author wangliang
- * @since 2023-08-01
+ * 公告表 控制器
+ * 
+ * @author: shudonghui
+ * @date: 2023-08-07 13:53:29
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
+@Api(tags = "公告表 Controller")
 @RestController
-@RequestMapping("/sys-notice")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX+SystemConstant.PREFIX_URL_NOTICE)
+@Validated
 public class SysNoticeController {
 
-}
+
+    @Resource
+    SysNoticeService sysNoticeService;
+
+   
+    @ApiOperation(value = "公告表查询接口")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "公告表查询结果", response = SysNotice.class)})
+    public Result query(
+                @ApiParam(value = "模糊查询条件", required = false) @RequestParam(required = false) String query,
+                @ApiParam(value = "发布状态", required = false) @RequestParam(required = false) NoticeStatusEnum status,
+                @ApiParam(value = "发布类型", required = false) @RequestParam(required = false) NoticeTypeEnum type,
+                @ApiParam(value = "发布时间开始", required = false) @RequestParam(required = false) Long startTime,
+                @ApiParam(value = "发布时间结束", required = false) @RequestParam(required = false) Long endTime,
+                @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        IPage<SysNotice> resultIPage = sysNoticeService.query(new Page<>(pageNumber, pageSize),query,status,type,startTime,endTime);
+
+        return ResultUtil.ok(resultIPage);
+    }
+
+   
+    @ApiOperation(value = "公告表新增修改接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result save(@ApiParam(value = "公告表信息", required = true) @RequestBody(required = true) SysNotice sysNotice) {
+        return ResultUtil.ok(sysNoticeService.saveSysNotice(sysNotice));
+    }
+
+
+   
+    @ApiOperation(value = "公告表删除接口")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result delete(@ApiParam(value = "公告表id", required = true) @RequestParam(required = true) long id) {
+        return ResultUtil.ok(sysNoticeService.delete(id));
+    }
+    /*
+        批量禁用
+     */
+   
+    @ApiOperation(value = "公告表批量禁用接口")
+    @RequestMapping(value = "/disable", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public  Result disable(@ApiParam(value = "公告表id", required = true) @RequestParam(required = true) long[] ids) {
+        return ResultUtil.ok(sysNoticeService.disable(ids));
+    }
+
+    /*
+        发布或者撤销发布
+     */
+   
+    @ApiOperation(value = "公告表发布或者撤销发布接口")
+    @RequestMapping(value = "/publishOrUnpublish", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public  Result publishOrUnpublish(@ApiParam(value = "公告表id", required = true) @RequestParam(required = true) long id) {
+        return ResultUtil.ok(sysNoticeService.publishOrUnpublish(id));
+    }
+
+   
+    @ApiOperation(value = "公告表获取单个接口")
+    @RequestMapping(value = "/get", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "公告表信息", response = SysNotice.class)})
+    public Result get(@ApiParam(value = "公告表id", required = true) @RequestParam long id) {
+        return ResultUtil.ok(sysNoticeService.getById(id));
+    }
+
+
+}