преди 5 години
родител
ревизия
b64f58a155

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/constant/Constant.java

@@ -18,6 +18,7 @@ public class Constant {
     public static final String EXAMINE_PASS= "审核通过,任务已完成";
     public static final String EXAMINE_NO_PASS= "审核未通过";
     public static final String EXAMINE_SUBMIT= "已提交任务";
+    public static final String TASK_SUBMIT= "提交任务";
     public static final String TASK_DELAY= "将任务延期至";
     public static final String TASK_DISTRIBUTE= "将任务派发给";
     public static final String TO_BE_DISTRIBUTE= "待派发";

+ 5 - 4
pcbms/src/main/java/com/hssx/pcbms/controller/TaskFileController.java

@@ -1,6 +1,7 @@
 package com.hssx.pcbms.controller;
 
 
+import com.hssx.pcbms.entity.TaskFile;
 import com.hssx.pcbms.service.TaskFileService;
 import com.hssx.pcbms.util.HttpRespMsg;
 import com.hssx.pcbms.util.PageUtil;
@@ -43,9 +44,9 @@ public class TaskFileController {
     @ApiOperation(value = "任务资料上传通用接口", notes = "任务资料上传通用接口方法")
     @RequestMapping("/uploadFile")
     @ResponseBody
-    public HttpRespMsg uploadFile(MultipartFile file, String taskId) {
+    public HttpRespMsg uploadFile(MultipartFile file, TaskFile taskFile) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg = taskFileService.updateFile(file,taskId);
+        msg = taskFileService.updateFile(file,taskFile);
         return msg;
     }
 
@@ -60,9 +61,9 @@ public class TaskFileController {
     @ApiOperation(value = "任务资料删除接口", notes = "任务资料删除方法")
     @RequestMapping("/delFile")
     @ResponseBody
-    public HttpRespMsg delFile(Integer id) {
+    public HttpRespMsg delFile(TaskFile taskFile) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data = taskFileService.removeById(id);
+        msg = taskFileService.delById(taskFile);
         return msg;
     }
 

+ 13 - 4
pcbms/src/main/java/com/hssx/pcbms/entity/TaskFile.java

@@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -18,7 +16,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author 吴涛涛
- * @since 2019-11-11
+ * @since 2019-11-12
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -55,9 +53,20 @@ public class TaskFile extends Model<TaskFile> {
      * 文件保存的日期
      */
     @TableField("indate")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime indate;
 
+    /**
+     * 上传人id
+     */
+    @TableField("uploader_id")
+    private Integer uploaderId;
+
+    /**
+     * 上传人姓名
+     */
+    @TableField("uploader")
+    private String uploader;
+
 
     @Override
     protected Serializable pkVal() {

+ 3 - 1
pcbms/src/main/java/com/hssx/pcbms/service/TaskFileService.java

@@ -16,7 +16,9 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface TaskFileService extends IService<TaskFile> {
 
-    HttpRespMsg updateFile(MultipartFile file, String taskId);
+    HttpRespMsg updateFile(MultipartFile file,TaskFile taskFile);
 
     HttpRespMsg getList(PageUtil page, String taskId);
+
+    HttpRespMsg delById(TaskFile taskFile);
 }

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/service/impl/TaskExamineServiceImpl.java

@@ -53,7 +53,7 @@ public class TaskExamineServiceImpl extends ServiceImpl<TaskExamineMapper, TaskE
             //添加动态
             dynamic.setTaskState(3);
             dynamic.setContent(taskExamine.getPublisher()+Constant.EXAMINE_SUBMIT);
-            dynamic.setStateContent(Constant.TASK_PULISH);
+            dynamic.setStateContent(Constant.TASK_SUBMIT);
             taskDynamicMapper.insert(dynamic);
             task.setId(taskExamine.getTaskId());
             task.setState(3);

+ 18 - 3
pcbms/src/main/java/com/hssx/pcbms/service/impl/TaskFileServiceImpl.java

@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.hssx.pcbms.entity.TaskFile;
 import com.hssx.pcbms.mapper.TaskFileMapper;
+import com.hssx.pcbms.mapper.UserMapper;
 import com.hssx.pcbms.service.TaskFileService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.pcbms.util.HttpRespMsg;
@@ -32,8 +33,10 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
     private TaskFileMapper taskFileMapper;
     @Value("${upload.path}")
     private String path;
+    @Resource
+    private UserMapper userMapper;
     @Override
-    public HttpRespMsg updateFile(MultipartFile file, String taskId) {
+    public HttpRespMsg updateFile(MultipartFile file,TaskFile taskFile) {
         HttpRespMsg msg = new HttpRespMsg();
         String filePath = "";
         if (file != null) {
@@ -43,10 +46,10 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
             msg.setError("上传图片失败了");
             return msg;
         }
-        TaskFile taskFile = new TaskFile();
+        taskFile.setUploader(userMapper.selectById(taskFile.getUploaderId()).getName());
         taskFile.setName(file.getOriginalFilename());
         taskFile.setUrl(filePath);
-        taskFile.setTaskId(taskId);
+        taskFile.setTaskId(taskFile.getTaskId());
         taskFileMapper.insert(taskFile);
         msg.data = filePath;
         return msg;
@@ -61,4 +64,16 @@ public class TaskFileServiceImpl extends ServiceImpl<TaskFileMapper, TaskFile> i
         msg.data = info;
         return msg;
     }
+
+    @Override
+    public HttpRespMsg delById(TaskFile taskFile) {
+        HttpRespMsg msg = new HttpRespMsg();
+        TaskFile oldtaskFile = taskFileMapper.selectById(taskFile.getId());
+        if(taskFile.getUploaderId().equals(oldtaskFile.getUploaderId())){
+            taskFileMapper.deleteById(oldtaskFile.getId());
+        }else{
+            msg.setError("您不具备删除该文件的");
+        }
+        return msg;
+    }
 }

+ 1 - 0
pcbms/src/main/java/com/hssx/pcbms/service/impl/TaskServiceImpl.java

@@ -183,6 +183,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         taskMapper.updateById(task);
         TaskDynamic dynamic = new TaskDynamic();
         dynamic.setTaskId(task.getId());
+        dynamic.setTaskState(2);
         dynamic.setStateContent(Constant.ALREADY_ACCEPT);
         dynamic.setContent(userMapper.selectById(task.getRecipientId()).getName() + Constant.TASK_ACCEPTED);
         taskDynamicMapper.insert(dynamic);

+ 1 - 1
pcbms/src/main/java/com/hssx/pcbms/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("task");
+        strategy.setInclude("task_file");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 3 - 1
pcbms/src/main/resources/mapper/TaskFileMapper.xml

@@ -9,11 +9,13 @@
         <result column="name" property="name" />
         <result column="url" property="url" />
         <result column="indate" property="indate" />
+        <result column="uploader_id" property="uploaderId" />
+        <result column="uploader" property="uploader" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, task_id, name, url, indate
+        id, task_id, name, url, indate, uploader_id, uploader
     </sql>
 
 </mapper>

+ 1 - 1
pcbms/src/main/resources/mapper/TaskMapper.xml

@@ -140,7 +140,7 @@
         select
         t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.indate,
         t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
-        u.name publishName,tt.name tag_name,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
+        u.name publishName,tt.name tagname,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
         from
         task t
         left join user u