Pārlūkot izejas kodu

优化项目导出性能
获取考勤针对过往日期也开放

seyason 1 gadu atpakaļ
vecāks
revīzija
0233bca5ec
15 mainītis faili ar 255 papildinājumiem un 76 dzēšanām
  1. BIN
      fhKeeper/formulahousekeeper/management-platform/20230302项目导入模板.xlsx
  2. 37 17
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserCorpwxTimeController.java
  3. 6 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Participation.java
  4. 38 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ParticipationUser.java
  5. 3 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectVO.java
  6. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ParticipationMapper.java
  7. 104 30
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  8. 49 15
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java
  9. 3 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml
  10. 5 2
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ParticipationMapper.xml
  11. 4 6
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  12. 1 1
      fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue
  13. 1 1
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue
  14. 1 1
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/count/count.vue
  15. 1 1
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

BIN
fhKeeper/formulahousekeeper/management-platform/20230302项目导入模板.xlsx


+ 37 - 17
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserCorpwxTimeController.java

@@ -411,27 +411,47 @@ public class UserCorpwxTimeController {
         }
 
         Map<String,Object> resultMap =new HashMap<>();
-        List<UserCorpwxTime> oldCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
-                .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate localDate = LocalDate.parse(date, df);
-        if(!localDate.isEqual(LocalDate.now())&&oldCorpwxTimes.size()>0 && oldCorpwxTimes.get(0).getWorkHours() > 0){
-            UserCorpwxTime time = oldCorpwxTimes.get(0);
-            resultMap.put("time", time);
+        //如果是今天,取日打卡记录接口,如果是过往其他日期,取考勤记录接口
+        if (localDate.isEqual(LocalDate.now())) {
+            List<UserCorpwxTime> oldCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                    .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+            if(oldCorpwxTimes.size()>0 && oldCorpwxTimes.get(0).getWorkHours() > 0){
+                UserCorpwxTime time = oldCorpwxTimes.get(0);
+                resultMap.put("time", time);
+                msg.data=resultMap;
+                return msg;
+            }
+            LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
+            LocalDateTime end = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
+            wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start,end,false);
+            List<UserCorpwxTime> changedCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                    .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+
+            if (changedCorpwxTimes.size() > 0) {
+                UserCorpwxTime time = changedCorpwxTimes.get(0);
+                resultMap.put("time", time);
+            }
             msg.data=resultMap;
-            return msg;
-        }
-        LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
-        LocalDateTime end = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
-        wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start,end,false);
-        List<UserCorpwxTime> chengedCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
-                .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
-
-        if (chengedCorpwxTimes.size() > 0) {
-            UserCorpwxTime time = chengedCorpwxTimes.get(0);
-            resultMap.put("time", time);
+        } else if (localDate.isBefore(LocalDate.now())) {
+            LocalDateTime start = localDate.atTime(0,0,0);
+            LocalDateTime end = localDate.atTime(0,0,0);
+            wxCorpInfoService.getUserCheckInDayData(user.getCompanyId(),user.getId(),start, end, false);
+            List<UserCorpwxTime> changedCorpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                    .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+
+            if (changedCorpwxTimes.size() > 0) {
+                UserCorpwxTime time = changedCorpwxTimes.get(0);
+                resultMap.put("time", time);
+            }
+            msg.data=resultMap;
+        } else {
+            //未来的不可获取
+            msg.setError("未来考勤打卡不可获取");
         }
-        msg.data=resultMap;
+
         return msg;
     }
 

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Participation.java

@@ -43,6 +43,12 @@ public class Participation extends Model<Participation> {
     private Integer projectId;
 
 
+    @TableField(exist = false)
+    private String corpwxUserId;
+
+    @TableField(exist = false)
+    private String name;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 38 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ParticipationUser.java

@@ -0,0 +1,38 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 人员参与项目的情况
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2020-02-12
+ */
+@Data
+public class ParticipationUser {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 项目表主键
+     */
+    private Integer projectId;
+
+
+    private String corpwxUserId;
+
+    private String name;
+}

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/ProjectVO.java

@@ -1,5 +1,7 @@
 package com.management.platform.entity.vo;
 
+import com.management.platform.entity.Participation;
+import com.management.platform.entity.ParticipationUser;
 import com.management.platform.entity.Project;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -12,7 +14,7 @@ import java.util.Map;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 public class ProjectVO extends Project {
-    List<Map<String, Object>> participator;
+    List<ParticipationUser> participator;
     String inchargerName;
     String inchargerPhone;
     String statusName;

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ParticipationMapper.java

@@ -2,6 +2,7 @@ package com.management.platform.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.Participation;
+import com.management.platform.entity.ParticipationUser;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -18,5 +19,5 @@ import java.util.Map;
 public interface ParticipationMapper extends BaseMapper<Participation> {
     List<Map<String, Object>> getParticipator(@Param("projectId") Integer projectId);
 
-    List<Map<String, Object>> getAllParticipator(@Param("projectIdList") List<Integer> projectIdList);
+    List<ParticipationUser> getAllParticipator(@Param("projectIdList") List<Integer> projectIdList, Integer companyId);
 }

+ 104 - 30
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -255,6 +255,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     //分页获取项目列表
     @Override
+    @Transactional(readOnly = true)
     public HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
                                       Integer status, Integer category, Integer projectId,Integer projectMainId,Integer deptId,  String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -262,7 +263,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             //通过公司id获取该公司所有的项目列表
             User user = userMapper.selectById(request.getHeader("Token"));
             Integer companyId = user.getCompanyId();
-            List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
+            boolean canViewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目");
             //判断用户的角色,如果是管理员和负责人,查看全部的。如果是普通员工,只能是看到参与的项目
             QueryWrapper<Project> queryWrapper = null;
             List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
@@ -278,7 +279,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             }
             //本人所在部门
             deptIds.add(user.getDepartmentId());
-            if (functionList.size() == 0) {
+            if (!canViewAll) {
                 //普通员工
                 List<Participation> pList = participationMapper.selectList(new QueryWrapper<Participation>().eq("user_id", user.getId()));
                 List<Integer> projectIds = new ArrayList<>();
@@ -351,6 +352,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }
             }
             IPage<Project> projectIPage;
+            LocalDateTime d1 = LocalDateTime.now();
             if(pageIndex!=null && pageSize!=null){
                 projectIPage= projectMapper.selectPage(new Page<>(pageIndex, pageSize),
                         queryWrapper);
@@ -358,14 +360,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 projectIPage= projectMapper.selectPage(new Page<>(-1,-1),
                         queryWrapper);
             }
-            List<Project> projectList = projectIPage.getRecords();
-            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+            LocalDateTime d2 = LocalDateTime.now();
+            Project[] projectList = projectIPage.getRecords().toArray(new Project[0]);
+            List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, phone").eq("company_id", companyId));
             List<ProviderInfo> providerInfoList = providerInfoMapper.selectList(new QueryWrapper<ProviderInfo>().eq("company_id", companyId));
             List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
             List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
             List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
             TimeType timeType = timeTypeMapper.selectById(companyId);
-            List<Integer> projectIds = projectList.stream().map(pl -> pl.getId()).distinct().collect(Collectors.toList());
+            List<Integer> projectIds = new ArrayList<>();
+            for (Project p : projectList) {
+                projectIds.add(p.getId());
+            }
+
             List<ProjectSeparate> projectSeparateList=new ArrayList<>();
             if(companyId==936){
                 if (projectIds.size() > 0) {
@@ -385,8 +392,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             if(projectIds.size()==0){
                 projectIds.add(-1);
             }
-            List<Map<String,Object>> particpationList=participationMapper.getAllParticipator(projectIds);
-            List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id",projectIds).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
+
+            List<ParticipationUser> particpationList;
+            if (canViewAll && pageIndex == null) {
+                particpationList = participationMapper.getAllParticipator(null, companyId);
+            } else {
+                particpationList = participationMapper.getAllParticipator(projectIds, companyId);
+            }
+
+            List<Report> reportList = new ArrayList<>();
+            //检测是否开启项目人天预估工时的功能
+            if (timeType.getProjectManDay() == 1) {
+                if (canViewAll && pageIndex == null) {
+                    reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id, create_date, project_id, working_time").eq("company_id",companyId).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
+                } else {
+                    reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id, create_date, project_id, working_time").in("project_id",projectIds).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
+                }
+            }
+            System.out.println("开始处理项目内数据");
             for (Project project : projectList) {
                 //todo:计算项目预算工时
                 if(project.getManDay()!=null){
@@ -408,20 +431,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     project.setResidueEstimatedWorkTime(format1);
                 }
                 ProjectVO projectVO = new ProjectVO();
+
                 if(timeType.getProjectLevelState()==1){
                     Optional<ProjectLevel> first = projectLevelList.stream().filter(pl -> pl.getId().equals(project.getLevel())).findFirst();
                     if(first.isPresent()){
                         projectVO.setLevelName(first.get().getProjectLevelName());
                     }
                 }
+
                 BeanUtils.copyProperties(project, projectVO);
+                long dt0 = System.currentTimeMillis();
                 Optional<Department> optional = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(projectVO.getDeptId())).findFirst();
                 if(optional.isPresent()){
                     projectVO.setDepartmentName(optional.get().getDepartmentName());
                 }
-                /**/
-                List<Map<String, Object>> maps = particpationList.stream().filter(pl ->Integer.valueOf(String.valueOf(pl.get("projectId"))).equals(project.getId())).collect(Collectors.toList());
-                projectVO.setParticipator(maps);
+                /*此处性能很差, 需要优化*/
+//                List<Map<String, Object>> maps = particpationList.stream().filter(pl ->Integer.valueOf(String.valueOf(pl.get("projectId"))).equals(project.getId())).collect(Collectors.toList());
+//                List<ParticipationUser> maps = particpationList.stream().filter(pl ->pl.getProjectId().equals(project.getId())).collect(Collectors.toList());
+                List<ParticipationUser> thisProParticipator = new ArrayList<>();
+                for (int i=0;i<particpationList.size(); i++) {
+                    ParticipationUser p = particpationList.get(i);
+                    if (p.getProjectId().equals(project.getId())) {
+                        thisProParticipator.add(p);
+                        particpationList.remove(i);
+                        i--;
+                    }
+                }
+                projectVO.setParticipator(thisProParticipator);
+
                 Optional<User> first = userList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
                 if (first.isPresent()) {
                     User incharger = first.get();
@@ -487,8 +524,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     totalProgress = totalProgress/100/100;
                     projectVO.setProgress(totalProgress);
                 }
+
                 list.add(projectVO);
             }
+            long end = System.currentTimeMillis();
             List<String> stringList = providerCategoryList.stream().map(ProviderCategory::getProviderCategoryName).distinct().collect(Collectors.toList());
             //stringList.add("未分类");
             stringList.add(MessageUtils.message("excel.unclassified"));
@@ -5405,13 +5444,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         for (Department department : departmentList) {
             department.setDepartmentName(getSupDepartment(department));
         }
-        String userId = null;
-        List<SysRoleFunction> functionList = sysRoleFunctionMapper.getRoleFunctionNames(user.getRoleId());
-        if(!functionList.stream().anyMatch(fun->fun.getFunctionName().equals("查看全部项目"))) {
-            //无全部项目权限,只能导出自己相关的(创建或参与)
-            userId = user.getId();
-        }
+        LocalDateTime d1 = LocalDateTime.now();
         HttpRespMsg projectPage = getProjectPage(null, null, keyword, searchField, status, category, projectId, projectMainId,deptId, null, null,inchagerId,participation,null,null, request);
+        LocalDateTime d2 = LocalDateTime.now();
+        System.out.println("查询项目耗时:" + Duration.between(d1, d2).toMillis());
         List<ProjectKeyNodesSetting> projectKeyNodesSettingList = projectKeyNodesSettingMapper.selectList(new QueryWrapper<ProjectKeyNodesSetting>().eq("company_id", user.getCompanyId()));
         Map<String,Object> resultMap= (Map<String, Object>) projectPage.data;
         List<ProjectVO> projectVOList= (List<ProjectVO>) resultMap.get("records");
@@ -5421,7 +5457,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<ProjectCustom> projectCustomList = projectCustomMapper.selectList(new QueryWrapper<ProjectCustom>().eq("company_id", company.getId()));
         List<ProjectCustom> customList = projectCustomList.stream().filter(pl -> pl.getCustomType() != 1).collect(Collectors.toList());
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", company.getId()));
+        List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, corpwx_userid").eq("company_id", company.getId()));
         List<String> headList = new ArrayList<String>();
 //        headList.add("项目编号");
 //        headList.add("项目分类");
@@ -5548,20 +5584,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             }else {
                 rowData.add(projectVO.getInchargerName());
             }
-            List<Map<String, Object>> participator = projectVO.getParticipator();
+            List<ParticipationUser> participator = projectVO.getParticipator();
             String names="";
             for (int i = 0; i < participator.size(); i++) {
                 if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                     if(i==participator.size()-1){
-                        names+="$userName="+(participator.get(i).get("corpwxUserId"))+"$";
+                        names+="$userName="+(participator.get(i).getCorpwxUserId())+"$";
                     }else {
-                        names+="$userName="+(participator.get(i).get("corpwxUserId"))+"$"+",";
+                        names+="$userName="+(participator.get(i).getCorpwxUserId())+"$"+",";
                     }
                 }else {
                     if(i==participator.size()-1){
-                        names+=participator.get(i).get("name");
+                        names+=participator.get(i).getName();
                     }else {
-                        names+=participator.get(i).get("name")+",";
+                        names+=participator.get(i).getName()+",";
                     }
                 }
             }
@@ -5744,6 +5780,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        //获取全部用户
+        List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, corpwx_userid").eq("company_id", user.getCompanyId()));
         List<HashMap<String, Object>> list = projectMapper.getExportGroupData(user.getCompanyId());
         List<List<String>> allList = new ArrayList<>();
         List<String> headList = new ArrayList<String>();
@@ -5764,21 +5802,57 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             item.add((String) map.get("projectName")==null?"":(String)map.get("projectName"));
             item.add((String) map.get("groupName")==null?"":(String)map.get("groupName"));
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                item.add((String) map.get("corpwxUserId")==null?"":("$userName="+(String)map.get("corpwxUserId")+"$"));
-                if(map.get("participatorsCorp")!=null&&!map.get("participatorsCorp").equals("")){
-                    String participatorsCorp = (String) map.get("participatorsCorp");
-                    List<String> asList = Arrays.asList(participatorsCorp.split(","));
+                String inchargerId = (String)map.get("inchargerId");
+                if (inchargerId!=null&&!inchargerId.equals("")) {
+                    Optional<User> incharger = userList.stream().filter(u -> u.getId().equals(inchargerId)).findFirst();
+                    if(incharger.isPresent()){
+                        item.add("$userName="+incharger.get().getCorpwxUserid()+"$");
+                    }else {
+                        item.add("");
+                    }
+                }
+                String participatorIds = (String)map.get("participatorIds");
+                if (participatorIds!=null&&!participatorIds.equals("")) {
+                    List<String> asList = Arrays.asList(participatorIds.split(","));
                     List<String> thisList=new ArrayList<>();
                     asList.forEach(al->{
-                        thisList.add("$userName="+al+"$");
+                        Optional<User> participator = userList.stream().filter(u -> u.getId().equals(al)).findFirst();
+                        if(participator.isPresent()){
+                            thisList.add("$userName="+participator.get().getCorpwxUserid()+"$");
+                        }
                     });
                     item.add(thisList.toString().replaceAll("\\[","").replaceAll("]",""));
-                }else {
+                } else {
                     item.add("");
                 }
             }else {
-                item.add((String) map.get("inchargerName")==null?"":(String)map.get("inchargerName"));
-                item.add((String) map.get("participators")==null?"":(String)map.get("participators"));
+                String inchargerId = (String)map.get("inchargerId");
+                if (inchargerId!=null&&!inchargerId.equals("")) {
+                    Optional<User> incharger = userList.stream().filter(u -> u.getId().equals(inchargerId)).findFirst();
+                    if (incharger.isPresent()) {
+                        User user1 = incharger.get();
+                        item.add(user1.getName());
+                    } else {
+                        item.add("");
+                    }
+                }else {
+                    item.add("");
+                }
+                String participatorIds = (String)map.get("participatorIds");
+                if (participatorIds!=null&&!participatorIds.equals("")) {
+                    List<String> asList = Arrays.asList(participatorIds.split(","));
+                    List<String> thisList=new ArrayList<>();
+                    asList.forEach(al->{
+                        Optional<User> participator = userList.stream().filter(u -> u.getId().equals(al)).findFirst();
+                        if (participator.isPresent()) {
+                            User user1 = participator.get();
+                            thisList.add(user1.getName());
+                        }
+                    });
+                    item.add(thisList.stream().collect(Collectors.joining(",")));
+                }else {
+                    item.add("");
+                }
             }
             allList.add(item);
         }

+ 49 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1205,6 +1205,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     int regular_work_sec = summary_info.getIntValue("regular_work_sec");//秒
                     ct.setStartTime(DateTimeUtil.getTimeFromSeconds(sTime));
                     ct.setEndTime(DateTimeUtil.getTimeFromSeconds(eTime));
+                    if (showLog) System.out.println("初始startTime="+ct.getStartTime()+", endTime="+ct.getEndTime());
                     //下班时间和上班时间不一样,正常应该有regular_work_sec,但是企业微信存在问题,传过来的是0,需要校正
                     if (regular_work_sec == 0 && ct.getEndTime() != null && !ct.getEndTime().equals(ct.getStartTime())) {
                         ct.setEndTime(ct.getStartTime());
@@ -1245,6 +1246,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                     //请假开始的日期和结束的日期
                                     String dateStart = localDate.getYear() + "/" + s[0];
                                     String dateEnd = localDate.getYear() + "/" + (isOldFormat ? s[2] : s[3]);
+                                    if (showLog) System.out.println(dateStart+" "+leaveStart+"---"+dateEnd+" "+leaveEnd);
                                     LocalDate sDate = LocalDate.parse(dateStart, mdFormat);
                                     LocalDate eDate = LocalDate.parse(dateEnd, mdFormat);
                                     //跨年情况的校验
@@ -1259,7 +1261,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                                 leaveStart = baseMorningStart;
                                             } else {
                                                 leaveStart = "14:00";
-                                                leaveEnd = baseAfternoonEnd;//请假的下班打卡时间,算上结束的时间
+                                                leaveEnd = baseAfternoonEnd;//请假的下班打卡时间,算上结束的时间
                                             }
                                         } else if (leaveEnd.equals("上午")) {
                                             //上午请假
@@ -1328,6 +1330,37 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                         ct.setEndTime(leaveEnd);
                                         needRecaculate = true;
                                     }
+                                    //计算请假时长, 企业微信的请假时长不准
+                                    if (needRecaculate) {
+
+                                        String[] endSplit = leaveEnd.split(":");
+                                        String[] startSplit = leaveStart.split(":");
+                                        int endHour = Integer.parseInt(endSplit[0]);
+                                        int endMin = Integer.parseInt(endSplit[1]);
+                                        int startHour = Integer.parseInt(startSplit[0]);
+                                        int startMin = Integer.parseInt(startSplit[1]);
+                                        double leaveHour = endHour - startHour;
+                                        //请假这天是全天请假,则需要减去中间的午休时间
+                                        if (leaveStart.compareTo(baseMorningEnd) < 0 && leaveEnd.compareTo(baseAfternoonStart) > 0) {
+                                            leaveHour = leaveHour - restTime;
+                                        }
+                                        int leaveMin = endMin - startMin;
+                                        double leaveTotalMin = leaveHour * 60 + leaveMin;
+                                        if (leaveTotalMin < 0) {
+                                            leaveTotalMin = 0;
+                                        }
+                                        double leaveTotalHour = leaveTotalMin / 60;
+                                        if (showLog) System.out.println("重新计算请假时长:"+leaveStart+"--"+leaveEnd+", 时间间隔="+leaveTotalHour);
+                                        if (ct.getAskLeaveTime() != null && ct.getAskLeaveTime() > 0) {
+                                            //可能一天有多个请假单
+                                            ct.setAskLeaveTime(ct.getAskLeaveTime() + leaveTotalHour);
+                                        } else {
+                                            ct.setAskLeaveTime(leaveTotalHour);
+                                        }
+
+                                        if (showLog) System.out.println("请假时长为:"+ct.getAskLeaveTime()+"小时");
+                                    }
+
                                 } else if (leaveText.startsWith("外出") || leaveText.startsWith("出差") || leaveText.startsWith("外勤")) {
                                     //格式 "10/17 09:00 / 10/19 18:00", "10/17 上午 / 10/17 下午"
                                     String string = holiday.getJSONObject("sp_description").getJSONArray("data").getJSONObject(m).getString("text");
@@ -1440,20 +1473,21 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                             JSONObject spItem = sp_items.getJSONObject(j);
                             switch (spItem.getInteger("type")) {
                                 case 1://请假
-                                    Double leaveTime = ct.getAskLeaveTime();
-                                    if (leaveTime == null) {
-                                        leaveTime = 0.0;
-                                    }
-                                    int wxDuration = spItem.getInteger("duration");
-                                    int seconds = 0;
-                                    if (betweenNonWorkDays.size() > 0) {
-                                        //跨天请假中含有非工作日的情况,要减去非工作日来重新计算实际工作日的每天请假时长。
-                                        seconds = wxDuration * betweenTotalDays/(betweenTotalDays - betweenNonWorkDays.size());
-                                    } else {
-                                        seconds = wxDuration;
-                                    }
-                                    double curLeaveTime = convertDayTimeToHours(DateTimeUtil.getHoursFromSeconds(seconds));
-                                    ct.setAskLeaveTime(leaveTime + curLeaveTime);
+//                                    Double leaveTime = ct.getAskLeaveTime();
+//                                    if (leaveTime == null) {
+//                                        leaveTime = 0.0;
+//                                    }
+//                                    int wxDuration = spItem.getInteger("duration");
+//                                    int seconds = 0;
+//                                    if (betweenNonWorkDays.size() > 0) {
+//                                        //跨天请假中含有非工作日的情况,要减去非工作日来重新计算实际工作日的每天请假时长。
+//                                        seconds = wxDuration * betweenTotalDays/(betweenTotalDays - betweenNonWorkDays.size());
+//                                    } else {
+//                                        seconds = wxDuration;
+//                                    }
+//                                    double curLeaveTime = convertDayTimeToHours(DateTimeUtil.getHoursFromSeconds(seconds));
+//                                    System.out.println("curLeaveTime============="+curLeaveTime);
+//                                    ct.setAskLeaveTime(leaveTime + curLeaveTime);
                                     break;
                                 case 2://补卡
                                 case 3://出差

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -18,6 +18,9 @@ spring:
     url: jdbc:mysql://47.101.180.183:3306/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&useSSL=false
     username: root
     password: HuoshiDB@2022
+#    url: jdbc:mysql://127.0.0.1:3306/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&useSSL=false
+#    username: root
+#    password: P011430seya
     hikari:
       maximum-pool-size: 60
       minimum-idle: 10

+ 5 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ParticipationMapper.xml

@@ -23,14 +23,17 @@
     </select>
 
 
-    <select id="getAllParticipator" resultType="java.util.Map">
+    <select id="getAllParticipator" resultType="com.management.platform.entity.ParticipationUser">
         SELECT a.user_id AS id,b.corpwx_userid as corpwxUserId, b.name,a.project_id as projectId
         FROM participation a
         LEFT JOIN user b ON a.user_id = b.id
-        WHERE a.project_id in
+        WHERE b.company_id = #{companyId}
+        <if test="projectIdList != null">
+            and a.project_id in
             <foreach collection="projectIdList" open="(" close=")" separator="," item="item">
                 #{item}
             </foreach>
+        </if>
     </select>
 
 </mapper>

+ 4 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -903,13 +903,11 @@
 
     <!--按项目分组导出数据-->
     <select id="getExportGroupData" resultType="java.util.Map" >
-        SELECT project_code as projectCode,project_name as projectName,task_group.`name` AS groupName,`user`.`name` AS inchargerName,`user`.corpwx_userid as corpwxUserId,`user`.corpwx_userid as corpwxUserId,
-        (SELECT GROUP_CONCAT(name) FROM group_participator g LEFT JOIN `user` ON `user`.id = g.user_id WHERE g.group_id = group_participator.group_id GROUP BY g.group_id) AS participators,
-        (SELECT GROUP_CONCAT(corpwx_userid) FROM group_participator g LEFT JOIN `user` ON `user`.id = g.user_id WHERE g.group_id = group_participator.group_id GROUP BY g.group_id) AS participatorsCorp
+        SELECT project_code AS projectCode,project_name AS projectName,task_group.`name` AS groupName,task_group.`incharger_id` AS inchargerId,
+               GROUP_CONCAT(group_participator.`user_id`) AS participatorIds
         FROM task_group
-        LEFT JOIN group_participator ON task_group.id = group_participator.group_id
-        LEFT JOIN project on task_group.project_id = project.id
-        LEFT JOIN `user` ON task_group.incharger_id = `user`.id
+                 LEFT JOIN group_participator ON task_group.id = group_participator.group_id
+                 LEFT JOIN project ON task_group.project_id = project.id
         where project.company_id = #{companyId}
         GROUP BY task_group.id
         ORDER BY project_id

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -412,7 +412,7 @@
                       <el-cascader v-model="insertForm.departmentId" :placeholder="$t('qing-xuan-ze-bu-men')" style="width: 100%"
                       :options="option" :props="{ checkStrictly: true,expandTrigger: 'hover' }" :show-all-levels="false"  clearable v-if="user.userNameNeedTranslate != 1"></el-cascader>
 
-                      <vueCascader :size="'medium'" :widthStr="'430'" :clearable="true && user.userNameNeedTranslate != 1" :subject="option" :subjectId="insertForm.departmentId" :radios="true" :distinction="'2'" @vueCasader="vueCasader" v-if="user.userNameNeedTranslate == 1" :disabled="user.userNameNeedTranslate == 1"></vueCascader>
+                      <vueCascader :size="'medium'" :widthStr="'430'" :clearable="true && user.userNameNeedTranslate != 1" :subject="option" :subjectId="insertForm.departmentId" :radios="true" :distinction="'2'" @vueCasader="vueCasader" v-if="user.userNameNeedTranslate == 1" ></vueCascader>
 
                   </el-form-item>
                   <el-form-item v-if="user.timeType.reportAuditType == 5">

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -360,7 +360,7 @@
                         <!--批量填报和批量代填不显示考勤记录-->
                         <span v-if="!isBatch && (user.timeType.syncDingding==1 || user.timeType.syncCorpwxTime==1)&&!workForm.time" >{{$t('other.noAttendanceRecord')}}</span>
                         <el-button type="default" style="margin-left:5px;" size="small" :loading="syncTimeLoading" 
-                        v-if="!isBatch && user.timeType.syncCorpwxTime==1 && (workForm.createDate == today || !workForm.time || workForm.time.workHours <= 0)" icon="el-icon-refresh" 
+                        v-if="!isBatch && user.timeType.syncCorpwxTime==1" icon="el-icon-refresh" 
                                 @click="refreshWXCardTime(workForm.createDate)"></el-button>
                         <!-- AI智能填报 -->
                         <el-button type="primary" @click="getAIReport()" v-if="!hasWrittenReport" style="margin-left:5px;" >智能填报</el-button>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/views/count/count.vue

@@ -91,7 +91,7 @@
             <van-cell v-for="item in showList" :key="item.id" title-style="color:#666">
                 <template #title>
                     <div style="text-align:left;margin-left:0.42667rem;" v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='userName' :openid='item.name'></ww-open-data></div>
-                    <div style="text-align:left;margin-left:0.42667rem;" v-else>{{item.name}}123</div>
+                    <div style="text-align:left;margin-left:0.42667rem;" v-else>{{item.name}}</div>
                 </template>
                 <template #default>
                     <div style="text-align:right;margin-right:0.42667rem;" v-if="user.userNameNeedTranslate == '1'"><ww-open-data type='departmentName' :openid='item.department'></ww-open-data></div>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

@@ -19,7 +19,7 @@
                     </div> 
                 </template>
                 <template #right-icon>
-                    <van-button icon="replay" native-type="button" type="default" size="mini" style="height:0.6rem;padding:0 0.16667rem;" :loading="cardRefLoading" loading-size="0.26667rem" @click.stop.native="cardtimeRefresh(form.createDate)" v-if="user.timeType.syncCorpwxTime==1 && (form.createDate == today || !report.time || report.time.workHours <= 0) && (user.timeType.syncDingding == 1 || user.timeType.syncCorpwxTime == 1)"></van-button>
+                    <van-button icon="replay" native-type="button" type="default" size="mini" style="height:0.6rem;padding:0 0.16667rem;" :loading="cardRefLoading" loading-size="0.26667rem" @click.stop.native="cardtimeRefresh(form.createDate)" v-if="user.timeType.syncCorpwxTime==1 && (user.timeType.syncDingding == 1 || user.timeType.syncCorpwxTime == 1)"></van-button>
                 </template>
             </van-cell>
                 <!-- <div v-if="report.time" class="attendanceRecord">