anderx лет назад: 2
Родитель
Сommit
2622dc87f0

+ 48 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -1,8 +1,12 @@
 package com.ruoyi.web.controller.project;
 
+import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.MimeTypeUtils;
 import com.ruoyi.project.bo.ProjectListInput;
 import com.ruoyi.project.bo.ProjectTaskListOut;
 import com.ruoyi.project.domain.ProjectStaff;
@@ -14,6 +18,7 @@ import com.ruoyi.project.service.ProjectTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -67,6 +72,31 @@ public class ProjectTaskController extends BaseController {
         return projectStaffRecordService.add(in);
     }
 
+
+    /**
+     * 修改成员打卡
+     * @param in
+     * @return
+     */
+    @PostMapping("/updateRecord")
+    public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
+        return projectStaffRecordService.update(in);
+    }
+
+
+    /**
+     * 审核成员打卡
+     * @param in
+     * @return
+     */
+    @PostMapping("/examineRecord")
+    public AjaxResult examineRecord( @RequestBody ProjectStaffRecord in){
+        if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
+            return AjaxResult.error("审核状态错误");
+        }
+        return projectStaffRecordService.examineRecord(in);
+    }
+
     /**
      * 删除项目成员
      * @param in
@@ -120,4 +150,22 @@ public class ProjectTaskController extends BaseController {
         return getDataTable(list);
     }
 
+
+    /**
+     * 上传项目文件
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/upload")
+    public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception{
+        if (!file.isEmpty()){
+            String avatar = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("imgUrl", avatar);
+            return ajax;
+        }
+        return error("上传图片异常,请联系管理员");
+    }
+
 }

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -9,7 +9,7 @@ ruoyi:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: D:/ruoyi/uploadPath
+  profile: F:/ruoyi/uploadPath
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数字计算 char 字符验证

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectStaffRecordService.java

@@ -5,4 +5,8 @@ import com.ruoyi.project.domain.ProjectStaffRecord;
 
 public interface ProjectStaffRecordService {
     AjaxResult add(ProjectStaffRecord in);
+
+    AjaxResult update(ProjectStaffRecord in);
+
+    AjaxResult examineRecord(ProjectStaffRecord in);
 }

+ 57 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -3,6 +3,8 @@ package com.ruoyi.project.service.impl;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.project.domain.ProjectStaffRecord;
+import com.ruoyi.project.domain.ProjectStaffRecordLog;
+import com.ruoyi.project.mapper.ProjectStaffRecordLogMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
 import com.ruoyi.project.service.ProjectStaffRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,14 +14,68 @@ import org.springframework.stereotype.Service;
 public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService {
     @Autowired
     private ProjectStaffRecordMapper projectStaffRecordMapper;
+    @Autowired
+    private ProjectStaffRecordLogMapper projectStaffRecordLogMapper;
 
     @Override
     public AjaxResult add(ProjectStaffRecord in) {
         Long userId = SecurityUtils.getUserId();
-        String username = SecurityUtils.getUsername();
+        String username = SecurityUtils.getLoginUser().getUser().getNickName();
         in.setAid(userId);
         in.setName(username);
+        if(in.getProcessStatus()>1)in.setProcessStatus(1);
         projectStaffRecordMapper.insertSelective(in);
+        addRecordLog(in);
+        return AjaxResult.success();
+    }
+
+    private void addRecordLog(ProjectStaffRecord in) {
+        ProjectStaffRecordLog log = new ProjectStaffRecordLog();
+        log.setPsrId(in.getId());
+        log.setProcessStatus(in.getProcessStatus());
+        if (in.getProcessStatus()<2){
+            log.setAid(in.getAid());
+            log.setName(in.getName());
+            log.setContent(getContent(in.getProcessStatus()));
+        }else {
+            log.setAid(SecurityUtils.getUserId());
+            log.setName(SecurityUtils.getLoginUser().getUser().getNickName());
+            log.setContent(getContent(in.getProcessStatus())+in.getContent());
+        }
+
+
+        projectStaffRecordLogMapper.insertSelective(log);
+    }
+
+    private String getContent(Integer processStatus) {
+        switch (processStatus) {
+            case 0: return "修改了内容!";
+            case 1: return "发起了审核!";
+            case 2: return "完成了审核!";
+            case 3: return "驳回了审核!";
+        }
+        return "";
+    }
+
+    @Override
+    public AjaxResult update(ProjectStaffRecord in) {
+        Long userId = SecurityUtils.getUserId();
+        String username = SecurityUtils.getLoginUser().getUser().getNickName();
+        in.setAid(userId);
+        in.setName(username);
+        if(in.getProcessStatus()>1)in.setProcessStatus(1);
+        projectStaffRecordMapper.updateByPrimaryKeySelective(in);
+        addRecordLog(in);
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult examineRecord(ProjectStaffRecord in) {
+        ProjectStaffRecord newP = new ProjectStaffRecord();
+        newP.setId(in.getId());
+        newP.setProcessStatus(in.getProcessStatus());
+        projectStaffRecordMapper.updateByPrimaryKeySelective(newP);
+        addRecordLog(in);
         return AjaxResult.success();
     }
 }