Min 1 年之前
父节点
当前提交
772f1c523b

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

@@ -12,6 +12,7 @@ import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.service.DepartmentService;
 import com.management.platform.service.ExcelExportService;
+import com.management.platform.service.PlanService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
@@ -73,6 +74,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     private WxCorpInfoService wxCorpInfoService;
     @Resource
     private UserWorkTypeMapper userWorkTypeMapper;
+    @Resource
+    private PlanService planService;
 
     @Value("${corpId}")
     private String corpId;
@@ -189,6 +192,30 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                                 }
                             }
                         }
+                        //修改计划中的部门数据
+                        List<Plan> planList = planService.list(new LambdaQueryWrapper<Plan>().eq(Plan::getStationId, departmentId));
+                        List<Integer> planIds = planList.stream().map(Plan::getId).distinct().collect(Collectors.toList());
+                        List<Map<String, Object>> planRealTimeProgressList = reportMapper.getPlanRealTimeProgressList(companyId, null, null, null, null, null, null, null, planIds);
+                        if(planList.size()>0){
+                            planList.forEach(p->{
+                                boolean match=false;
+                                Optional<Map<String, Object>> planId = planRealTimeProgressList.stream().filter(plan -> plan.get("planId").equals(p.getId())).findFirst();
+                                Map<String, Object> map = planId.get();
+                                BigDecimal planWorkTime = new BigDecimal(map.get("planWorkTime") == null ? 0 : Double.valueOf(String.valueOf(map.get("planWorkTime"))));
+                                BigDecimal nowWorkTime = new BigDecimal(map.get("nowWorkTime") == null ? 0 : Double.valueOf(String.valueOf(map.get("nowWorkTime"))));
+                                if(nowWorkTime.compareTo(BigDecimal.ZERO)!=0){
+                                    BigDecimal divide = nowWorkTime.divide(planWorkTime, 4, RoundingMode.HALF_UP);
+                                    if(divide.doubleValue()>1){
+                                        match=false;
+                                    }
+                                }
+                                if(match){
+                                    p.setForemanName(manager.getName());
+                                    p.setForemanId(manager.getId());
+                                }
+                            });
+                            planService.updateBatchById(planList);
+                        }
                     } else {
                         //取消了部门管理员
                         departmentMapper.updateNullManager(departmentId);

+ 9 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -3,6 +3,7 @@ package com.management.platform.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -245,6 +246,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
                 userVO.setTimeType(timeTypeMapper.selectById(company.getId()));
                 List<Department> manageDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", userVO.getId()));
+                //获取作为次要负责人的列表
+                List<DepartmentOtherManager> departmentOtherManagers = departmentOtherManagerMapper.selectList(new LambdaQueryWrapper<DepartmentOtherManager>().eq(DepartmentOtherManager::getOtherManagerId, userVO.getId()));
+                List<Integer> otherManagerIds = departmentOtherManagers.stream().map(DepartmentOtherManager::getDepartmentId).distinct().collect(Collectors.toList());
+                otherManagerIds.add(-1);
+                List<Department> otherDpetList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().in(Department::getDepartmentId, otherManagerIds));
+                if(otherDpetList.size()>0){
+                    manageDeptList.addAll(otherDpetList);
+                }
                 userVO.setBeDeptList(manageDeptList);
                 //检查登录权限
                 Integer roleId = userVO.getRoleId();