Parcourir la source

新增获取公司部门数据

anderx il y a 4 mois
Parent
commit
9cf593d6bb

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

@@ -552,9 +552,9 @@ public class ProjectTaskController extends BaseController {
     /**
      * 获取公司打卡数据
      */
-    @GetMapping("/getCompanyDep")
-    public AjaxResult getCompanyDep(Integer deptId){
+    @GetMapping("/getCompanyData")
+    public AjaxResult getCompanyData(Integer deptId){
 
-        return AjaxResult.success(projectStaffRecordService.getCompanyClock(deptId));
+        return AjaxResult.success(projectTaskService.getCompanyData(deptId));
     }
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/project/mapper/ProjectTaskMapper.java

@@ -8,6 +8,7 @@ import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectTask;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -50,4 +51,6 @@ public interface ProjectTaskMapper {
 
 
     List<ProjectTaskAllBo> getAllProjectMonth(@Param("companyId")Long companyId);
+
+    List<ProjectTask> selectByUserId(Long userId);
 }

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

@@ -58,4 +58,5 @@ public interface ProjectStaffRecordService {
     Object getNewMonthClock(Integer id, String yearMonth, String duration);
 
     List<CompanyClockBo> getCompanyClock(Integer deptId);
+
 }

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

@@ -30,4 +30,6 @@ public interface ProjectTaskService {
     void saveProjectStaffRecordTianhe(String id);
 
     void saveText(String content) ;
+
+    Object getCompanyData(Integer deptId);
 }

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

@@ -1188,4 +1188,6 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     }
 
 
+
+
 }

+ 38 - 7
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 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;
@@ -23,6 +24,7 @@ import com.ruoyi.project.mapper.ProjectStaffMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
 import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectTaskService;
+import com.ruoyi.system.mapper.SysDeptMapper;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ISysDeptService;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -36,6 +38,7 @@ import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Validator;
 import java.io.ByteArrayOutputStream;
@@ -51,19 +54,21 @@ import static java.lang.Thread.sleep;
 public class ProjectTaskServiceImpl   implements ProjectTaskService {
 
     private static final Logger log = LoggerFactory.getLogger(ProjectTaskServiceImpl.class);
-    @Autowired
+    @Resource
     private ProjectTaskMapper projectTaskMapper;
-    @Autowired
+    @Resource
     private ProjectStaffMapper projectStaffMapper;
-    @Autowired
+    @Resource
     private ISysDeptService deptService;
-    @Autowired
+    @Resource
     private Validator validator;
-    @Autowired
+    @Resource
     private SysUserMapper userMapper;
-    @Autowired
+    @Resource
     private ProjectStaffRecordMapper projectStaffRecordMapper;
-    @Autowired
+    @Resource
+    private SysDeptMapper sysDeptMapper;
+    @Resource
     private TianheService tianheService;
     @Value("${ruoyi.profile}")
     private  String profile=null;
@@ -403,6 +408,8 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         }
     }
 
+
+
     public void saveRecordsText(Long id) throws InterruptedException {
         ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(Long.valueOf(id));
         Map<String,Object> map=new HashMap<>();
@@ -549,4 +556,28 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         return address;
     }
 
+
+    @Override
+    public Object getCompanyData(Integer deptId) {
+        //获取部门信息
+        SysDept sysDept = new SysDept();
+        sysDept.setAncestors(deptId.toString());
+        List<SysDept> sysDepts = sysDeptMapper.selectDeptList(sysDept);
+        sysDepts.stream().forEach(System.out::println);
+        //获取部门下的用户信息
+        List<SysUser> sysUsers = new ArrayList<>();
+        List<ProjectTask> projectTasks=new ArrayList<>();
+        sysDepts.stream().forEach(sysDept1 -> {
+            sysUsers.addAll(userMapper.selectByDeptId(sysDept1.getDeptId()));
+        });
+        sysUsers.stream().forEach(sysUser -> {
+            projectTasks.addAll(projectTaskMapper.selectByUserId(sysUser.getUserId()));
+        });
+        Map<String,Object> map=new HashMap();
+        map.put("projectTasks",projectTasks);
+        map.put("sysUsers",sysUsers);
+        map.put("sysDepts",sysDepts);
+        return map;
+    }
+
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.mapper;
 
+import java.util.Collection;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -144,4 +145,6 @@ public interface SysUserMapper
     int selectParticipateProjectSum(Long userId);
 
     SysUser selectDDUserId(Long ddUserId);
+
+    List<SysUser> selectByDeptId(Long deptId);
 }

+ 7 - 1
ruoyi-system/src/main/resources/mapper/project/ProjectTaskMapper.xml

@@ -323,11 +323,17 @@
         group by x.id,x.name,x.recordTime,x.company_name
     </select>
 
-
     <update id="updateStaffName"  >
         update project_task
         set staff_name=(select group_concat(name)name from project_staff
                         where pid = #{pid} group by  pid)
         where id= #{pid}
     </update>
+
+    <select id="selectByUserId"  resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from project_task
+    where aid =#{aid}
+    </select>
 </mapper>

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -375,7 +375,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
 
-	<update id="userAddDuration">
+    <update id="userAddDuration">
 		update sys_user set duration = round(duration+#{duration},2)
 		where user_id = #{userId}
 	</update>
@@ -396,4 +396,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 					  where a.aid = #{aid})
 		where user_id = #{aid}
 	</update>
+
+	<select id="selectByDeptId" resultMap="SysUserResult">
+		<include refid="selectUserVo"/>
+		where u.dept_id = #{deptId} and u.del_flag = '0'
+	</select>
 </mapper>