瀏覽代碼

研发打卡修改

anderx 2 年之前
父節點
當前提交
8cb4d1983b

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

@@ -243,5 +243,9 @@ public class ProjectTaskController extends BaseController {
         }
         return error("上传图片异常,请联系管理员");
     }
+    @GetMapping("/myDuration")
+    public AjaxResult myDuration(Long id){
 
+        return projectStaffRecordService.myDuration(id);
+    }
 }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/project/mapper/ProjectStaffRecordMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.mapper;
 import com.ruoyi.project.bo.ProjectStaffRecordInput;
 import com.ruoyi.project.bo.ProjectStaffRecordOut;
 import com.ruoyi.project.domain.ProjectStaffRecord;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -22,4 +23,7 @@ public interface ProjectStaffRecordMapper {
     List<ProjectStaffRecordOut> selectList(ProjectStaffRecordInput in);
 
     int selectById(Long id);
+
+
+    List<ProjectStaffRecord> selectByPidAndAid(@Param("pid") Long pid, @Param("aid") Long aid);
 }

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

@@ -17,4 +17,6 @@ public interface ProjectStaffRecordService {
     List<ProjectStaffRecordOut> listRecord(ProjectStaffRecordInput in);
 
     String importProject(List<ProjectStaffRecordOut> list, boolean isUpdateSupport, String operName);
+
+    AjaxResult myDuration(Long id);
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectTaskService.java

@@ -17,4 +17,5 @@ public interface ProjectTaskService {
     List<ProjectTaskListOut> list(ProjectListInput in);
 
     String importProject(List<ProjectTaskListOut> list, boolean updateSupport, String operName);
+
 }

+ 32 - 4
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -1,9 +1,12 @@
 package com.ruoyi.project.service.impl;
 
+import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.UserRolesType;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanValidators;
@@ -11,14 +14,13 @@ import com.ruoyi.project.bo.ProjectStaffRecordInput;
 import com.ruoyi.project.bo.ProjectStaffRecordOut;
 import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectStaffRecordLog;
-import com.ruoyi.project.domain.ProjectTask;
 import com.ruoyi.project.mapper.ProjectStaffRecordLogMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
 import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectStaffRecordService;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ISysDeptService;
-import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.system.service.impl.SysConfigServiceImpl;
 import com.ruoyi.weChat.service.WeChatService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.validation.Validator;
-import java.util.Arrays;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
@@ -52,6 +54,11 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     @Autowired
     private SysUserMapper userMapper;
 
+    @Autowired
+    private SysConfigServiceImpl configService;
+
+
+
     @Override
     public AjaxResult add(ProjectStaffRecord in) {
         Long userId = SecurityUtils.getUserId();
@@ -60,7 +67,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
-        Double maxDuration= user.getDept().getMaxDuration();
+//        Double maxDuration= user.getDept().getMaxDuration();
         boolean flag=false;
         if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
             in.setProcessStatus(2);
@@ -241,4 +248,25 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         }
         return successMsg.toString();
     }
+
+    @Override
+    public AjaxResult myDuration(Long id) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        SysDept dept = user.getDept();
+        Double maxDuration=dept.getMaxDuration();
+        String date=DateUtils.getDate();
+        String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
+        AtomicReference<Double> myDuration = new AtomicReference<>(0d);
+        Boolean flag = Boolean.parseBoolean(maxDurationProjectFlag);
+        if (!flag)id=null;
+        List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(id,user.getUserId());
+        projectStaffRecords.stream().forEach(e ->{
+            String eDate= DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, e.getRecordTime());
+            if (date.equals(eDate)){
+                myDuration.updateAndGet(v -> v + e.getDuration());
+            }
+        });
+        BigDecimal res = new BigDecimal(maxDuration).subtract(new BigDecimal(myDuration.toString()));
+        return AjaxResult.success(res);
+    }
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -140,4 +140,6 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         }
         return successMsg.toString();
     }
+
+
 }

+ 14 - 0
ruoyi-system/src/main/resources/mapper/project/ProjectStaffRecordMapper.xml

@@ -220,4 +220,18 @@
       where a.pid=ps.pid
       and ps.id = #{id}
     </select>
+  <select id="selectByPidAndAid"  resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from project_staff_record
+    where 1=1
+    <if test="pid !=null">
+      and a.pid= #{pid}
+    </if>
+    <if test="aid != null">
+      and a.aid = #{aid}
+    </if>
+
+  </select>
+
 </mapper>