Browse Source

自定义数值的数据导出

seyason 2 years ago
parent
commit
779224edbf

+ 16 - 16
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -751,7 +751,6 @@ public class ReportController {
             httpRespMsg.setError("验证失败");
             return httpRespMsg;
         }
-        System.out.println("reportList===size===="+reportList.size());
         //校验工作时长
         for (Report report : reportList) {
             if (report.getWorkingTime() == null || report.getWorkingTime() <= 0.0) {
@@ -895,22 +894,23 @@ public class ReportController {
                             }
                         }
                     } else {
-                        List<LocalDate> collect = oldReportList.stream().map(Report::getCreateDate).collect(Collectors.toList());
-                        for (Report report : reportList) {
-                            if (report.getId() == null) {
-                                if (collect.stream().anyMatch(oldDate->oldDate.isEqual(report.getCreateDate()))) {
-                                    sb.append(mdFormatter.format(report.getCreateDate())).append(",");
-                                }
-                            }
-                        }
+                        //按周填报时不校验已填的工时日报了
+//                        List<LocalDate> collect = oldReportList.stream().map(Report::getCreateDate).collect(Collectors.toList());
+//                        for (Report report : reportList) {
+//                            if (report.getId() == null) {
+//                                if (collect.stream().anyMatch(oldDate->oldDate.isEqual(report.getCreateDate()))) {
+//                                    sb.append(mdFormatter.format(report.getCreateDate())).append(",");
+//                                }
+//                            }
+//                        }
 
-                        String s = sb.toString();
-                        if (s.length() > 0) {
-                            s = s.substring(0, s.length() -1);
-                            HttpRespMsg msg = new HttpRespMsg();
-                            msg.setError("已存在填写日报: " + s+", 请先删除后再填报。");
-                            return msg;
-                        }
+//                        String s = sb.toString();
+//                        if (s.length() > 0) {
+//                            s = s.substring(0, s.length() -1);
+//                            HttpRespMsg msg = new HttpRespMsg();
+//                            msg.setError("已存在填写日报: " + s+", 请先删除后再填报。");
+//                            return msg;
+//                        }
                     }
                 }
             }

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -32,7 +32,9 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
     List<Map<String, Object>> getProjectCost(@Param("companyId")Integer companyId,@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId,@Param("stateKey")Integer stateKey, @Param("userId") String userId,@Param("deptIds")List<Integer> deptIds,@Param("filterDeptIds")List<Integer> filterDeptIds);
 
-    List<Map<String, Object>> getProjectCusDataSumItem(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId, @Param("userId") String userId);
+    List<Map<String, Object>> getProjectCusDataSumItem(@Param("companyId") Integer companyId, @Param("startDate") String startDate,
+                                                       @Param("endDate") String endDate, @Param("projectId") Integer projectId,
+                                                       @Param("userId") String userId, List<Integer> deptIds);
     List<Map<String, Object>> getProjectCusDataDetailItem(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId, @Param("userId") String userId);
 
     @Update("update project set status = 1, finish_date = null where id = #{id}")

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -844,9 +844,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             //检查是否有查看全公司数值的权限
             User curUser = userMapper.selectById(request.getHeader("TOKEN"));
             List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(curUser.getRoleId(), "查看全公司数值");
+            System.out.println("functionList=="+functionList.size());
             if (functionList.size() == 0) {
                 //检查是否有负责的部门
                 deptIds = getAllManagedDeptIdList(curUser, allDeptList);
+                System.out.println("负责的部门:"+deptIds);
                 if (deptIds.size() == 0) {
                     deptIds.add(-1);//没有负责的部门,无权查看
                 }

+ 14 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -80,6 +80,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     @Resource
     private ReportMapper reportMapper;
     @Resource
+    private DepartmentService departmentService;
+    @Resource
     private SubProjectMapper subProjectMapper;
     @Resource
     private ParticipationMapper participationMapper;
@@ -3578,7 +3580,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
             TimeType timeType = timeTypeMapper.selectById(companyId);
-            List<Map<String, Object>> list = projectMapper.getCustomDataSum(companyId, startDate, endDate, projectId, userId);
             List<String> headList = new ArrayList<String>();
             headList.add("序号");
             headList.add("姓名");
@@ -3594,7 +3595,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 
             //计算合计的费用
-            List<Map<String, Object>> membList = projectMapper.getProjectCusDataSumItem(companyId, startDate, endDate, projectId, userId);
+            //检查是否有查看全公司数值的权限
+            User curUser = userMapper.selectById(request.getHeader("TOKEN"));
+            List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(curUser.getRoleId(), "查看全公司数值");
+            List<Integer> deptIds = null;
+            if (functionList.size() == 0) {
+                //检查是否有负责的部门
+                deptIds = departmentService.getAllManagedDeptIdList(curUser, null);
+                if (deptIds.size() == 0) {
+                    deptIds.add(-1);//没有负责的部门,无权查看
+                }
+            }
+            List<Map<String, Object>> membList = projectMapper.getProjectCusDataSumItem(companyId, startDate, endDate, projectId, userId, deptIds);
             List<Map<String, Object>> membDetailList = projectMapper.getProjectCusDataDetailItem(companyId, startDate, endDate, projectId, userId);
             for (Map<String, Object> membMap : membList) {
                 List<String> membRowData = new ArrayList<String>();

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/DepartmentMapper.xml

@@ -90,6 +90,7 @@
             AND b.create_date between #{startDate} and #{endDate}
         </if>
         GROUP BY b.project_id, a.id
+        having IFNULL(SUM(b.custom_data),0) > 0
     </select>
     <!-- 根据部门获取自定义的日报数值 -->
     <select id="getDeptCustomDataStatistic" resultType="java.util.Map">
@@ -111,5 +112,6 @@
             AND b.create_date between #{startDate} and #{endDate}
         </if>
         GROUP BY b.project_id, a.department_id
+        having IFNULL(SUM(b.custom_data),0) > 0
     </select>
 </mapper>

+ 7 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -234,6 +234,7 @@
         </if>
         AND b.state = 1
         GROUP BY a.id
+        having IFNULL(SUM(b.custom_data), 0) > 0
         ORDER BY SUM(b.custom_data) DESC
     </select>
 
@@ -408,6 +409,12 @@
         <if test="userId != null">
             AND a.creator_id = #{userId}
         </if>
+        <if test="deptIds != null">
+            AND department.department_id in
+            <foreach collection="deptIds" separator="," index="index" close=")" open="(" item="item">
+                #{item}
+            </foreach>
+        </if>
         group by b.id
         ORDER BY b.id ASC
     </select>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/project/custom_data.vue

@@ -193,7 +193,7 @@
                  if (this.exportParam.dateRange != null) {
                     param = {startDate:this.exportParam.dateRange[0], endDate: this.exportParam.dateRange[1]};
                  }
-                 var url = this.permissions.customDataAll? "/project/exportCustomDataSum":"/department/exportCustomDataSum";
+                 var url = "/project/exportCustomDataSum";
                  var fileName = this.user.timeType.customDataName + '统计.xls';
                 //  if (this.radio == '人员' ) {
                 //      console.log(this.exportParam.userIds);