Kaynağa Gözat

打卡月份获取从创建时间获取修改为打卡时间获取

anderx 1 yıl önce
ebeveyn
işleme
58034387a6

+ 11 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java

@@ -3,6 +3,7 @@ package com.ruoyi.framework.web.exception;
 import javax.servlet.http.HttpServletRequest;
 
 import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
+import org.mybatis.spring.MyBatisSystemException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.access.AccessDeniedException;
@@ -149,4 +150,14 @@ public class GlobalExceptionHandler
     {
         return AjaxResult.error("演示模式,不允许操作");
     }
+
+    /**
+     * sql查询异常
+     */
+    @ExceptionHandler(MyBatisSystemException.class)
+    public AjaxResult myBatisSystemException(MyBatisSystemException e)
+    {
+        return AjaxResult.error("数据操作异常。");
+    }
+
 }

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

@@ -34,4 +34,8 @@ public interface ProjectStaffRecordMapper {
     ProjectStaffRecordOut selectDetailsById(Long id);
 
     void updateNameByAid(SysUser user);
+
+    void updateSumDurationProject(Long pid);
+
+    void updateSumDurationStaff(Long pid);
 }

+ 11 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -499,10 +499,12 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
         Long companyId = deptService.selectCompanyByDeptId();
-        List<Integer> pids=new ArrayList<Integer>();
+        List<Long> pids=new ArrayList<>();
         for (ProjectStaffRecordOut p : list){
-            try
-            {
+            try {
+                if (pids.contains(p.getPid())){
+                    pids.add(p.getPid());
+                }
                 // 验证是否存在
                 ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(p.getId());
                 if (StringUtils.isNull(projectStaffRecord)){
@@ -574,6 +576,12 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
+        if (!pids.isEmpty()){
+            for (Long pid : pids) {
+                projectStaffRecordMapper.updateSumDurationProject(pid);
+                projectStaffRecordMapper.updateSumDurationStaff(pid);
+            }
+        }
         return successMsg.toString();
     }
 

+ 11 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Validator;
 import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.zip.ZipOutputStream;
@@ -78,7 +79,6 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
     public AjaxResult details(Long id) {
         ProjectTask projectTask = projectTaskMapper.selectByPrimaryKey(id);
         ProjectTaskOut out=  new ProjectTaskOut();
-
         if (projectTask!=null){
             BeanUtils.copyBeanProp(out, projectTask);
             List<ProjectStaff> projectStaffs = projectStaffMapper.selectByPid(id);
@@ -131,6 +131,7 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
         Long company = deptService.selectCompanyByDeptId();
+        List<Long> pids = new ArrayList<Long>();
         for (ProjectTaskListOut p : list)
         {
             try
@@ -179,6 +180,9 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
                         p.setAdminName(sysUser.getNickName());
                     }
                     projectTaskMapper.updateByPrimaryKeySelective(p);
+                    if (pids.contains(p.getId())){
+                        pids.add(p.getId());
+                    }
                     successNum++;
                     successMsg.append("<br/>" + successNum + "、项目: " + projectTask.getName() + " 更新成功");
                 }
@@ -205,6 +209,12 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
+        if (!pids.isEmpty()){
+            for (Long pid : pids) {
+                projectStaffRecordMapper.updateSumDurationProject(pid);
+                projectStaffRecordMapper.updateSumDurationStaff(pid);
+            }
+        }
         return successMsg.toString();
     }
 

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

@@ -278,5 +278,17 @@
     set name= #{nickName}
     where aid= #{userId}
   </update>
+  <update id="updateSumDurationProject">
+    update  project_task x,(select pid  ,sum(duration)duration
+      from project_staff_record  where pid =#{pid} group by pid )y
+    set x.duration =y.duration
+    where x.id =y.pid
+  </update>
+  <update id="updateSumDurationStaff">
+    update sys_user x,(select aid ,sum(duration)duration
+      from project_staff_record  where pid = #{pid} group by aid)y
+    set x.duration=y.duration
+    where x.user_id =y.aid
+  </update>
 
 </mapper>