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

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

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.MimeTypeUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -75,6 +76,8 @@ public class ProjectTaskController extends BaseController {
      */
     @PostMapping("/addRecord")
     public AjaxResult addRecord( @RequestBody ProjectStaffRecord in){
+        Long userId = SecurityUtils.getUserId();
+        in.setAid(userId);
         if (projectStaffRecordService.addCheckMaxDuation(in)){
             return AjaxResult.error("每天工时超出最大限制");
         }
@@ -89,6 +92,8 @@ public class ProjectTaskController extends BaseController {
      */
     @PostMapping("/updateRecord")
     public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
+        Long userId = SecurityUtils.getUserId();
+        in.setAid(userId);
         if (projectStaffRecordService.updateCheckMaxDuation(in)){
             return AjaxResult.error("每天工时超出最大限制");
         }

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

@@ -61,18 +61,15 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
 
     @Override
     public AjaxResult add(ProjectStaffRecord in) {
-        Long userId = SecurityUtils.getUserId();
         SysUser user = SecurityUtils.getLoginUser().getUser();
         String username = user.getNickName();
-        in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
 
-
         boolean flag=false;
         if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
             in.setProcessStatus(2);
-            sysUserMapper.userAddDuration(userId,in.getDuration());
+            sysUserMapper.userAddDuration(in.getAid(),in.getDuration());
             projectTaskMapper.projectAddDuration(in.getPid(),in.getDuration());
         }else {
             flag=true;
@@ -180,13 +177,11 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
 
     @Override
     public AjaxResult update(ProjectStaffRecord in) {
-        Long userId = SecurityUtils.getUserId();
         ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(in.getId());
         if (projectStaffRecord.getProcessStatus()!=0&&projectStaffRecord.getProcessStatus()!=3){
             AjaxResult.success("打卡只有草稿和驳回状态才可以修改!");
         }
         String username = SecurityUtils.getLoginUser().getUser().getNickName();
-        in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
         projectStaffRecordMapper.updateByPrimaryKeySelective(in);