Browse Source

垃圾清运代码提交

wangqiang 8 months ago
parent
commit
363d84d9f4
17 changed files with 593 additions and 12 deletions
  1. 6 0
      jeeplus-modules/jeeplus-test/pom.xml
  2. 150 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/controller/LookOverController.java
  3. 43 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/domain/LookOver.java
  4. 19 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/mapper/LookOverMapper.java
  5. 11 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/mapper/xml/LookOverMapper.xml
  6. 39 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/service/LookOverService.java
  7. 106 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/utils/SnowFlake.java
  8. 74 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/domain/WorkAttachmentInfo.java
  9. 3 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/mapper/OssServiceMapper.java
  10. 42 9
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/mapper/xml/OssServiceMapper.xml
  11. 5 0
      jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/service/OssService.java
  12. 19 3
      jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/controller/FileController.java
  13. 53 0
      jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/service/OSSFileService.java
  14. 12 0
      jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/service/dto/FileUrlDto.java
  15. 5 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/Notify.java
  16. 1 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/NotifyMapper.xml
  17. 5 0
      jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/NotifyDTO.java

+ 6 - 0
jeeplus-modules/jeeplus-test/pom.xml

@@ -45,6 +45,12 @@
             <version>3.6.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-notify</artifactId>
+            <version>9.0</version>
+            <scope>compile</scope>
+        </dependency>
 
 
     </dependencies>

+ 150 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/controller/LookOverController.java

@@ -0,0 +1,150 @@
+package com.jeeplus.test.garbageClearance.controller;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.aop.logging.annotation.ApiLog;
+import com.jeeplus.notify.service.NotifyService;
+import com.jeeplus.notify.service.dto.NotifyDTO;
+import com.jeeplus.sys.service.OfficeService;
+import com.jeeplus.sys.service.dto.OfficeDTO;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.utils.StringUtils;
+import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.garbageClearance.domain.LookOver;
+import com.jeeplus.test.garbageClearance.service.LookOverService;
+import com.jeeplus.test.garbageClearance.utils.SnowFlake;
+import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.domain.WorkAttachmentInfo;
+import com.jeeplus.test.oss.service.OssService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * 巡视相关controller
+ * @author 王强
+ * @version 1.0
+ * @date 2024-08-29 10:40
+ */
+@Api(tags ="巡视")
+@RestController
+@RequestMapping(value = "/app/look/over")
+public class LookOverController {
+
+    @Autowired
+    private LookOverService overService;
+
+    @Autowired
+    private OfficeService officeService;
+
+    @Autowired
+    private OssService ossService;
+
+    @Autowired
+    private NotifyService notifyService;
+
+    /**
+     * 保存巡视信息
+     */
+    @ApiLog("保存巡视信息")
+    @ApiOperation(value = "保存巡视信息")
+    @PostMapping("save")
+    public  ResponseEntity <String> save(@Valid @RequestBody LookOver lookOver) {
+        //新增或编辑表单保存
+        String lookOverId = SnowFlake.getId();
+        UserDTO userDTO = UserUtils.getCurrentUserDTO();
+        lookOver.setId(lookOverId);
+
+        if (StringUtils.isNotBlank(lookOver.getNo())) {
+            // 剔除掉XJ-J 只保留纯数字
+            // 使用正则表达式替换掉所有非数字字符
+            String pureNumber = lookOver.getNo().replaceAll("\\D+", "");
+            lookOver.setNo(pureNumber);
+        }
+
+        if (null != lookOver.getFileList1() && lookOver.getFileList1().size() > 0 ) {
+            // 进行附件保存操作,保存到work_attachment 表中
+            for (WorkAttachmentInfo attachment : lookOver.getFileList1()) {
+                // 生成id
+                String detailId = SnowFlake.getId();
+                attachment.setId(detailId);
+                attachment.setAttachmentId(lookOverId);
+                attachment.setCreateTime(new Date());
+                attachment.setUpdateTime(new Date());
+                attachment.setDelFlag(0);
+                ossService.insertWorkAttachmentInfo(attachment,userDTO);
+            }
+        }
+
+        // 发送通知给 当前用户人所在 村庄的 村庄负责人(村支书)
+        UserDTO dto = overService.getUserInfoByOffId(userDTO.getOfficeDTO().getId());
+
+        NotifyDTO notifyDTO = new NotifyDTO();
+        notifyDTO.setContent(lookOver.getRemarks());
+        notifyDTO.setNotifyRecordIds(dto.getId());
+        notifyDTO.setStatus("1");
+        notifyDTO.setType("2");
+        notifyDTO.setTitle("垃圾清运通知");
+        notifyDTO.setLookOverId(lookOverId);
+
+        notifyService.saveOrUpdate ( notifyDTO );
+
+
+        overService.saveOrUpdate (lookOver);
+        return ResponseEntity.ok ( "保存成功" );
+    }
+
+    /**
+     * 查询最大的巡视工单
+     */
+    @ApiLog("查询最大的巡视工单")
+    @ApiOperation(value = "查询最大的巡视工单")
+    @GetMapping("getMaxNo")
+    public ResponseEntity<String> getMaxNo() {
+        String maxNo = overService.getMaxNo();
+        return ResponseEntity.ok( maxNo );
+    }
+
+    /**
+     * 查询处理单位
+     */
+    @ApiLog("查询处理单位")
+    @ApiOperation(value = "查询处理单位")
+    @GetMapping("getProcessingUnit")
+    public ResponseEntity<List<OfficeDTO>> getProcessingUnit() {
+        List <OfficeDTO> list = officeService.findList ( "" );
+        List <OfficeDTO> rootTree = officeService.getRootTree ( "", list, "", "", "1" );
+
+        rootTree.forEach(ro -> {
+            Iterator<OfficeDTO> iterator = ro.getChildren().iterator();
+            while (iterator.hasNext()) {
+                OfficeDTO ch = iterator.next();
+                if (!ch.getName().contains("村")) {
+                    iterator.remove();  // 使用迭代器删除子节点
+                }
+            }
+        });
+
+        return ResponseEntity.ok ( rootTree );
+    }
+
+    /**
+     * 根据组织ID获取角色为村负责人的用户信息
+     */
+    @ApiLog("根据组织ID获取角色为村负责人的用户信息")
+    @ApiOperation(value = "根据组织ID获取角色为村负责人的用户信息")
+    @GetMapping("getUserInfoByOffId")
+    public ResponseEntity<UserDTO> getUserInfo( String officeId ) {
+        UserDTO userDTO = overService.getUserInfoByOffId(officeId);
+        return ResponseEntity.ok( userDTO );
+    }
+
+}

+ 43 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/domain/LookOver.java

@@ -0,0 +1,43 @@
+package com.jeeplus.test.garbageClearance.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.domain.WorkAttachmentInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 垃圾清运-巡视工单
+ * </p>
+ *
+ * @author 王强
+ * @since 2024-08-29
+ */
+@TableName("garbage_clearance_look_over")
+@ApiModel(value = "GarbageClearanceLookOver对象", description = "垃圾清运-巡视工单")
+@Data
+public class LookOver extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("简介")
+    private String remarks;
+
+    @ApiModelProperty("巡视工单")
+    private String no;
+
+    @ApiModelProperty("处理单位")
+    private String processingUnit;
+
+    //附件信息
+    @TableField(exist = false)
+    List<WorkAttachmentInfo> fileList1;
+}

+ 19 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/mapper/LookOverMapper.java

@@ -0,0 +1,19 @@
+package com.jeeplus.test.garbageClearance.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.test.garbageClearance.domain.LookOver;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 垃圾清运-巡视工单 Mapper 接口
+ * </p>
+ *
+ * @author 王强
+ * @since 2024-08-29
+ */
+public interface LookOverMapper extends BaseMapper<LookOver> {
+
+    UserDTO getUserInfoByOffId(@Param("officeId") String officeId);
+}

+ 11 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/mapper/xml/LookOverMapper.xml

@@ -0,0 +1,11 @@
+<?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.test.garbageClearance.mapper.LookOverMapper">
+    <select id="getUserInfoByOffId" resultType="com.jeeplus.sys.service.dto.UserDTO">
+        select su.id, su.name, su.mobile from sys_user su
+        left join sys_office so on su.office_id = so.id
+        left join sys_user_role sur on su.id = sur.user_id
+        left join sys_role sr on sur.role_id = sr.id
+        where su.office_id = #{officeId} and sr.name = '村负责人'
+    </select>
+</mapper>

+ 39 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/service/LookOverService.java

@@ -0,0 +1,39 @@
+package com.jeeplus.test.garbageClearance.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.test.garbageClearance.domain.LookOver;
+import com.jeeplus.test.garbageClearance.mapper.LookOverMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author 王强
+ * @version 1.0
+ * @date 2024-08-29 10:51
+ */
+@Service
+@Transactional
+public class LookOverService extends ServiceImpl<LookOverMapper, LookOver> {
+
+
+    public String getMaxNo() {
+        // 创建查询条件构造器
+        QueryWrapper<LookOver> queryWrapper = new QueryWrapper<>();
+
+        // 按no字段降序排列
+        queryWrapper.select("MAX(no) as no");
+
+        // 只获取第一条记录
+        LookOver lookOver = baseMapper.selectOne(queryWrapper);
+
+        // 返回最大的no值
+        return lookOver != null ? lookOver.getNo() : null;
+    }
+
+    public UserDTO getUserInfoByOffId(String officeId) {
+        return baseMapper.getUserInfoByOffId(officeId);
+    }
+}

+ 106 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/garbageClearance/utils/SnowFlake.java

@@ -0,0 +1,106 @@
+package com.jeeplus.test.garbageClearance.utils;
+
+/**
+ * @author: 徐滕
+ * @version: 2023-12-12 18:27
+ */
+public final class SnowFlake {
+
+    // 起始的时间戳
+    private final static long START_TIMESTAMP = 1480166465631L;
+
+    // 每一部分占用的位数,符号位不算在内
+    private final static long SEQUENCE_BIT = 12; // 序列号占用的位数
+    private final static long MACHINE_BIT = 5; // 机器标识占用的位数
+    private final static long DATACENTER_BIT = 5; // 数据中心占用的位数
+
+    // 每一部分的最大值
+    private final static long MAX_SEQUENCE = ~(-1L << SEQUENCE_BIT);
+    private final static long MAX_MACHINE_NUM = ~(-1L << MACHINE_BIT);
+    private final static long MAX_DATACENTER_NUM = ~(-1L << DATACENTER_BIT);
+
+    // 每一部分向左的位移
+    private final static long MACHINE_LEFT = SEQUENCE_BIT;
+    private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
+    private final static long TIMESTAMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
+
+    private long datacenterId; // 数据中心
+    private long machineId; // 机器标识
+    private long sequence = 0L; // 序列号
+    private long lastTimestamp = -1L;// 上一次时间戳
+
+    public SnowFlake(long datacenterId, long machineId) {
+        if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) {
+            throw new IllegalArgumentException("Datacenter ID can't be greater than MAX_DATACENTER_NUM or less than 0");
+        }
+        if (machineId > MAX_MACHINE_NUM || machineId < 0) {
+            throw new IllegalArgumentException("Machine ID can't be greater than MAX_MACHINE_NUM or less than 0");
+        }
+        this.datacenterId = datacenterId;
+        this.machineId = machineId;
+    }
+
+    /**
+     * 产生下一个ID
+     *
+     * @return 下一个ID
+     */
+    public synchronized long nextId() {
+        long currTimestamp = getTimestamp();
+        if (currTimestamp < lastTimestamp) {
+            throw new RuntimeException("Clock moved backwards. Refusing to generate id");
+        }
+
+        // 如果是同一时间生成的,则进行毫秒内序列
+        if (currTimestamp == lastTimestamp) {
+            sequence = (sequence + 1) & MAX_SEQUENCE;
+            // 序列号已经达到最大值,下一个毫秒
+            if (sequence == 0L) {
+                currTimestamp = getNextTimestamp();
+            }
+        } else {
+            // 时间戳改变,毫秒内序列重置
+            sequence = 0L;
+        }
+
+        // 上次生成ID的时间截
+        lastTimestamp = currTimestamp;
+
+        // 移位并通过或运算拼到一起组成64位的ID
+        return (currTimestamp - START_TIMESTAMP) << TIMESTAMP_LEFT // 时间戳部分
+                | datacenterId << DATACENTER_LEFT // 数据中心部分
+                | machineId << MACHINE_LEFT // 机器标识部分
+                | sequence; // 序列号部分
+    }
+
+    /**
+     * 获取下一个毫秒数
+     *
+     * @return 下一个毫秒数
+     */
+    private long getNextTimestamp() {
+        long timestamp = getTimestamp();
+        while (timestamp <= lastTimestamp) {
+            timestamp = getTimestamp();
+        }
+        return timestamp;
+    }
+
+    /**
+     * 获取当前的时间戳
+     *
+     * @return 当前的时间戳
+     */
+    private long getTimestamp() {
+        return System.currentTimeMillis();
+    }
+
+    /**
+     * 生成id
+     * @return
+     */
+    public static String getId() {
+        SnowFlake snowFlake = new SnowFlake(1, 1);
+        return String.valueOf(snowFlake.nextId());
+    }
+}

+ 74 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/domain/WorkAttachmentInfo.java

@@ -0,0 +1,74 @@
+package com.jeeplus.test.oss.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * @author 王强
+ * @version 1.0
+ * @date 2024-08-30 9:57
+ */
+@Data
+@TableName("work_attachment")
+public class WorkAttachmentInfo extends BaseEntity {
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 文件类型(文件后缀名)
+     */
+    private String type;
+
+    /**
+     * 附件对应父节点id(记录是谁的id)
+     */
+    private String attachmentId;
+
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+
+    /**
+     * 文件所属业务模块(数据字典配置)
+     */
+    private String attachmentFlag;
+
+    /**
+     * 所属模块子模块
+     */
+    private String moduleType;
+
+    /**
+     * 附件类型
+     */
+    private String attachmentType;
+
+    /**
+     * 附件大小
+     */
+    private String fileSize;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 文件描述
+     */
+    private String description;
+
+    /**
+     * 附件临时地址
+     *该属性不是实体字段
+     */
+    @TableField(exist = false)
+    private String temporaryUrl;
+
+}

+ 3 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/mapper/OssServiceMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.domain.WorkAttachmentInfo;
 import org.apache.ibatis.annotations.Param;
 import org.flowable.spring.security.UserDto;
 
@@ -21,6 +22,8 @@ public interface OssServiceMapper extends BaseMapper<WorkAttachment> {
 
     void insertWorkAttachment (@Param("workAttachment") WorkAttachment workAttachment, @Param("userDto") UserDTO userDto);
 
+    void insertWorkAttachmentInfo (@Param("workAttachment") WorkAttachmentInfo workAttachment, @Param("userDto") UserDTO userDto);
+
     /**
      * 根据关联id和url查询数据信息
      * @param workAttachment

+ 42 - 9
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/mapper/xml/OssServiceMapper.xml

@@ -34,9 +34,9 @@
     <select id="findList" resultType="com.jeeplus.test.oss.domain.WorkAttachment">
         SELECT a.id, a.url, a.type, a.attachment_id, a.attachment_name, a.attachment_flag,
         a.module_type, a.attachment_type, a.file_size, a.sort, a.description,
-        a.create_date, a.create_by as "create_by.id", su.name as "createBy.name" , a.update_date, a.update_by as "updateBy.id", a.del_flag
+        a.create_date, a.create_by_id as "create_by.id", su.name as "createBy.name" , a.update_time, a.update_by_id as "updateBy.id", a.del_flag
          FROM work_attachment a
-         left join sys_user su on su.id = a.create_by
+         left join sys_user su on su.id = a.create_by_id
          ${ew.customSqlSegment}
          ORDER BY a.sort ASC;
     </select>
@@ -44,10 +44,10 @@
     <insert id="insertWorkAttachment">
         INSERT INTO work_attachment (
             id,
-            create_by,
-            create_date,
-            update_by,
-            update_date,
+            create_by_id,
+            create_time,
+            update_by_id,
+            update_time,
             del_flag,
             url,
             type,
@@ -74,12 +74,45 @@
             )
     </insert>
 
+    <insert id="insertWorkAttachmentInfo">
+        INSERT INTO work_attachment (
+            id,
+            create_by_id,
+            create_time,
+            update_by_id,
+            update_time,
+            del_flag,
+            url,
+            type,
+            attachment_id,
+            attachment_name,
+            attachment_flag,
+            file_size,
+            sort
+            )
+        VALUES(
+            #{workAttachment.id},
+            #{userDto.id},
+            #{workAttachment.createTime},
+            #{userDto.id},
+            #{workAttachment.updateTime},
+            #{workAttachment.delFlag},
+            #{workAttachment.url},
+            #{workAttachment.type},
+            #{workAttachment.attachmentId},
+            #{workAttachment.attachmentName},
+            #{workAttachment.attachmentFlag},
+            #{workAttachment.fileSize},
+            #{workAttachment.sort}
+            )
+    </insert>
+
     <select id="getByAttachmentIdAndUrlAndAttachmentFlag" resultType="com.jeeplus.test.oss.domain.WorkAttachment">
         SELECT a.id, a.url, a.type, a.attachment_id, a.attachment_name, a.attachment_flag,
         a.module_type, a.attachment_type, a.file_size, a.sort, a.description,
-        a.create_date, a.create_by as "create_by.id", su.name as "createBy.name" , a.update_date, a.update_by as "updateBy.id", a.del_flag
+        a.create_time, a.create_by_id as "create_by.id", su.name as "createBy.name" , a.update_time, a.update_by_id as "updateBy.id", a.del_flag
          FROM work_attachment a
-         left join sys_user su on su.id = a.create_by
+         left join sys_user su on su.id = a.create_by_id
          <where>
              a.del_flag = 0
              <if test="attachmentId != null and attachmentId != ''">
@@ -93,4 +126,4 @@
              </if>
          </where>
     </select>
-</mapper>
+</mapper>

+ 5 - 0
jeeplus-modules/jeeplus-test/src/main/java/com/jeeplus/test/oss/service/OssService.java

@@ -13,6 +13,7 @@ import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.domain.WorkAttachmentInfo;
 import com.jeeplus.test.oss.mapper.OssServiceMapper;
 import com.jeeplus.test.oss.service.dto.FileDetailDTO;
 import com.jeeplus.test.oss.service.dto.OssServiceDto;
@@ -66,6 +67,10 @@ public class OssService extends ServiceImpl<OssServiceMapper,WorkAttachment> {
     @Resource
     private OSSClientService ossClientService;
 
+    public void insertWorkAttachmentInfo (WorkAttachmentInfo workAttachment, UserDTO userDto){
+        ossServiceMapper.insertWorkAttachmentInfo(workAttachment, userDto);
+    }
+
     /**
      * 保存数据
      * @param workAttachments

+ 19 - 3
jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/controller/FileController.java

@@ -7,14 +7,15 @@ import cn.hutool.core.util.StrUtil;
 import com.jeeplus.file.config.FileProperties;
 import com.jeeplus.file.repository.AccessoryRepository;
 import com.jeeplus.file.service.OSSFileService;
+import com.jeeplus.file.service.dto.FileUrlDto;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.util.StreamUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
 
@@ -61,6 +62,21 @@ public class FileController {
     private OSSFileService oSSFileService;
 
     /**
+     * 上传文件
+     * @return
+     * @throws IOException
+     */
+    @ApiOperation("上传文件")
+    @PostMapping("webUpload/fileUpload")
+    public ResponseEntity<FileUrlDto> fileUpload(MultipartFile file, @RequestParam(required = false) String dir) throws IOException {
+        if(StringUtils.isBlank(dir)){
+            dir = "oss";
+        }
+        FileUrlDto dto = oSSFileService.webUpload(file,dir);
+        return ResponseEntity.ok(dto);
+    }
+
+    /**
      * 获取文件网络地址
      *
      * @return

+ 53 - 0
jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/service/OSSFileService.java

@@ -4,10 +4,12 @@ import com.aliyun.oss.OSSClient;
 import com.aliyun.oss.model.OSSObject;
 import com.aliyun.oss.model.PutObjectResult;
 import com.aliyun.oss.model.SimplifiedObjectMeta;
+import com.jeeplus.file.service.dto.FileUrlDto;
 import com.jeeplus.sys.utils.Global;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
 import java.net.URL;
@@ -40,6 +42,57 @@ public class OSSFileService {
     private String accessKeySecret;
 
     /**
+     * 上传文件
+     * @param file
+     * @param dir 存放文件夹名称
+     * @return
+     * @throws Exception
+     */
+    public FileUrlDto webUpload(MultipartFile file, String dir) throws IOException {
+        FileUrlDto dto = new FileUrlDto();
+        // 文件保存路径
+        String fileDir = "attachment-file/wdterp" + "/"+dir + this.datePath() + "/"+ System.currentTimeMillis();
+        // 判断文件是否为空
+        if (!file.isEmpty()) {
+            String name = file.getOriginalFilename ();
+            this.uploadFile2OSS(file.getInputStream(), fileDir, name);
+            String url = fileDir +name;
+            String lsUrl = this.getFileTemporaryLookUrl(aliyunUrl + "/" + fileDir +name);
+            dto.setUrl(url);
+            dto.setLsUrl(lsUrl);
+        }
+        return dto;
+    }
+
+    /**
+     * 阿里云获取临时文件查看url
+     * @param url
+     */
+    public String getFileTemporaryLookUrl(String url){
+        url = url.replace("amp;","");
+        String cons = "";
+        if (url.contains(aliyunUrl)){
+            cons = aliyunUrl;
+        }else if (url.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
+            cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+        }else {
+            cons = aliyunDownloadUrl;
+        }
+        String key = "";
+        String[] split = url.split(cons + "/");
+        if(split.length>1){
+            key = split[1];
+        }else{
+            key = url;
+        }
+        // 指定过期时间为24小时。
+        Date expiration = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 );
+        //初始化OSSClient
+        OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
+        return ossClient.generatePresignedUrl(bucketName, key, expiration).toString();
+    }
+
+    /**
      * 上传到OSS服务器  如果同名文件会覆盖服务器上的
      *
      * @param fileName 文件名称 包括后缀名

+ 12 - 0
jeeplus-plugins/jeeplus-file/src/main/java/com/jeeplus/file/service/dto/FileUrlDto.java

@@ -0,0 +1,12 @@
+package com.jeeplus.file.service.dto;
+
+import lombok.Data;
+
+@Data
+public class FileUrlDto {
+
+    private String url;
+
+    private String lsUrl;
+
+}

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

@@ -46,5 +46,10 @@ public class Notify extends BaseEntity {
      */
     private String remarks;
 
+    /**
+     * 垃圾清运id
+     */
+    private String lookOverId;
+
 
 }

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

@@ -15,6 +15,7 @@
         a.update_time AS "updateTime",
         a.remarks AS "remarks",
         a.del_flag AS "delFlag",
+        a.look_over_id AS "lookOverId",
         b.read_num AS "readNum",
         b.un_read_num AS "unReadNum",
         u.name AS "createBy.name",

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

@@ -28,6 +28,11 @@ import java.util.stream.Collectors;
 public class NotifyDTO extends BaseDTO {
 
     private static final long serialVersionUID = 1L;
+
+    /**
+     * 垃圾清运id
+     */
+    private String lookOverId;
     /**
      * 类型
      */