浏览代码

Merge branch 'huangyuan-user' of lift-manager/lift-server into develop

huangyuan 5 年之前
父节点
当前提交
a777edf2d6

+ 10 - 4
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -51,6 +51,11 @@ public class ApiConstants {
      */
     public static final String CURRENT_ROLE_ID = "currentRoleId";
 
+    /**
+     * 当前角色编码
+     */
+    public static final String CURRENT_ROLE_CODE = "currentRoleCode";
+
     /**
      * 当前权限路径
      */
@@ -150,6 +155,11 @@ public class ApiConstants {
          */
         int TYPE_USER = 3;
 
+        /**
+         * 物管端用户
+         */
+        int PUBLIC_TYPE_USER = 4;
+
         /**
          * 专家标识-是
          */
@@ -279,10 +289,6 @@ public class ApiConstants {
          */
         int CLERK_WORK_ADD = 2;
 
-        /**
-         * 全局设置编码常量
-         */
-
         /**
          * 项目组维保工是否能查看到项目的所有电梯,并接收该项目所有维保任务
          */

+ 6 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/DefaultMenuConstants.java

@@ -40,6 +40,10 @@ public class DefaultMenuConstants {
      * 高级主管默认菜单
      */
     public static final long[] HIGH_DIRECTOR_MENUIDS = {1L, 2L, 3L};
+    /**
+     * 企业管理员默认菜单
+     */
+    public static final long[] ENTERPRISE_MENUIDS = {};
     /**
      * 默认角色对应菜单信息
      */
@@ -56,5 +60,7 @@ public class DefaultMenuConstants {
         DEFAULT_ROLE_MENUIDS.put(CommonEnum.DefaultRole.REGION_DIRECTOR.getCode(), REGION_DIRECTOR_MENUIDS);
         //设置高级主管默认菜单
         DEFAULT_ROLE_MENUIDS.put(CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode(), HIGH_DIRECTOR_MENUIDS);
+        //企业管理员默认菜单
+        DEFAULT_ROLE_MENUIDS.put(CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode(), ENTERPRISE_MENUIDS);
     }
 }

+ 37 - 1
lift-common/src/main/java/cn.com.ty.lift.common/utils/ProjectUtils.java

@@ -31,6 +31,42 @@ public class ProjectUtils {
         return longIdList;
     }
 
+    /**
+     * @param ids id连接的字符串
+     * @return long型id数组
+     * @description 从id连接数组中获取id数组
+     * @date 2020/4/26 1:10 下午
+     */
+    public static long[] getLongIdArrayFromIds(String ids) {
+        long[] idArray = new long[0];
+        if (StrUtil.isNotBlank(ids)) {
+            String[] idStrArray = ids.split(",");
+            idArray = new long[idStrArray.length];
+            int i = 0;
+            for (String id : idStrArray) {
+                idArray[i++] = Long.parseLong(id);
+            }
+        }
+        return idArray;
+    }
+
+    /**
+     * @param array 数组
+     * @return 通过","连接的字符串
+     * @description 将数组值通过","连接
+     * @date 2020/4/26 11:39 上午
+     */
+    public static String arrayToStrByComma(long[] array) {
+        if (array != null && array.length > 0) {
+            StringBuilder sb = new StringBuilder();
+            for (Object o : array) {
+                sb.append(o.toString()).append(",");
+            }
+            return sb.toString();
+        }
+        return null;
+    }
+
     /**
      * 将对象集合转化为attr->List<Obj>的map形式,通过特定属性给对象归类
      *
@@ -185,7 +221,7 @@ public class ProjectUtils {
             ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
             ObjectInputStream in = new ObjectInputStream(byteIn);
             dest = (List<T>) in.readObject();
-        } catch (IOException | ClassNotFoundException e){
+        } catch (IOException | ClassNotFoundException e) {
             e.printStackTrace();
         }
         return dest;

+ 21 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/dao/dto/request/TodoRequest.java

@@ -10,6 +10,27 @@ import lombok.Data;
  */
 @Data
 public class TodoRequest {
+
+    /**
+     * 待办角色编码
+     */
+    private String currentRoleCode;
+
+    /**
+     * 当前用户id
+     */
+    private Long userId;
+
+    /**
+     * 区域主管idC
+     */
+    private Long regionChargeId;
+
+    /**
+     * 文员id
+     */
+    private String clerkId;
+
     /**
      * 公司id
      */

+ 20 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/service/TodoService.java

@@ -1,6 +1,7 @@
 package cn.com.ty.lift.system.homepage.service;
 
 import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.utils.ProjectUtils;
 import cn.com.ty.lift.system.constants.CommonConstants;
 import cn.com.ty.lift.system.homepage.dao.dto.request.TodoRequest;
@@ -48,6 +49,7 @@ public class TodoService {
      * @date 2020/2/14 10:55 上午
      */
     public RestResponse todoNum(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         Map<Integer, Long> todoTypeToNum = CommonConstants.TODO_TYPE_TO_NUM;
         //1.设置行政待办事项数量
         //团队成员申请待办
@@ -85,6 +87,7 @@ public class TodoService {
      * @date 2020/2/14 12:20 下午
      */
     public RestResponse getEmergencyTodo(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         List<EmergencyResponse> emergencyTodoResponseList = todoDataMapper.getEmergencyTodoData(todoRequest);
         return RestResponse.success(emergencyTodoResponseList, ApiConstants.RESULT_SUCCESS, "获取待办数据成功");
     }
@@ -96,6 +99,7 @@ public class TodoService {
      * @date 2020/2/14 12:21 下午
      */
     public RestResponse getMaintenanceTodo(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         List<MaintenanceTodoResponse> maintenanceTodoResponseList = todoDataMapper.getMaintenanceTodoData(todoRequest);
         return RestResponse.success(maintenanceTodoResponseList, ApiConstants.RESULT_SUCCESS, "获取待办数据成功");
     }
@@ -107,6 +111,7 @@ public class TodoService {
      * @date 2020/2/14 12:22 下午
      */
     public RestResponse getCapitalRepairTodo(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         List<CapitalRepairResponse> capitalRepairResponseList = todoDataMapper.getCapitalRepairTodoData(todoRequest);
         return RestResponse.success(capitalRepairResponseList, ApiConstants.RESULT_SUCCESS, "获取待办数据成功");
     }
@@ -118,6 +123,7 @@ public class TodoService {
      * @date 2020/2/14 12:24 下午
      */
     public RestResponse getAnnualInspectionTodo(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         List<AnnualInspectionResponse> annualInspectionResponseList = todoDataMapper
                 .getAnnualInspectionTodoData(todoRequest);
         return RestResponse.success(annualInspectionResponseList, ApiConstants.RESULT_SUCCESS, "获取待办数据成功");
@@ -166,6 +172,20 @@ public class TodoService {
         }
     }
 
+    /**
+     * @param todoRequest 角色编码
+     * @description 通过角色来设置id值
+     * @date 2020/4/25 10:01 上午
+     */
+    private void handleTodoRequest(TodoRequest todoRequest) {
+        if (CommonEnum.DefaultRole.REGION_DIRECTOR.getCode().equals(todoRequest.getCurrentRoleCode())) {
+            todoRequest.setRegionChargeId(todoRequest.getUserId());
+        }
+        if(CommonEnum.DefaultRole.CLERK.getCode().equals(todoRequest.getCurrentRoleCode())) {
+            todoRequest.setClerkId(todoRequest.getUserId().toString());
+        }
+    }
+
     /**
      * @param
      * @return

+ 6 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/settings/dao/entity/model/CompanyAttestationRequest.java

@@ -124,6 +124,12 @@ public class CompanyAttestationRequest {
      */
     private Integer isCertificated;
 
+    /**
+     * 默认分配标识 0 默认分配 1 手动分配
+     * 默认值 默认分配方式
+     */
+    private int defaultAssign = 0;
+
     /**
      * 每页的条数
      */

+ 60 - 6
lift-system-service/src/main/java/cn/com/ty/lift/system/settings/service/impl/MtCompanyAttestationServiceImpl.java

@@ -1,6 +1,8 @@
 package cn.com.ty.lift.system.settings.service.impl;
 
 import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.constants.CommonEnum;
+import cn.com.ty.lift.common.constants.DefaultMenuConstants;
 import cn.com.ty.lift.common.utils.PojoUtils;
 import cn.com.ty.lift.common.utils.ProjectUtils;
 import cn.com.ty.lift.system.constants.CommonConstants;
@@ -12,6 +14,7 @@ import cn.com.ty.lift.system.settings.dao.mapper.MtCompanyAttestationMapper;
 import cn.com.ty.lift.system.settings.service.GlobalSetService;
 import cn.com.ty.lift.system.settings.service.IMaintenanceCompanyService;
 import cn.com.ty.lift.system.settings.service.IMtCompanyAttestationService;
+import cn.com.ty.lift.system.user.dao.entity.Role;
 import cn.com.ty.lift.system.user.dao.entity.UserAccount;
 import cn.com.ty.lift.system.user.dao.entity.UserInfo;
 import cn.com.ty.lift.system.user.dao.entity.model.ApplyPageResponse;
@@ -55,6 +58,9 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
     @Resource
     private IMenuService menuService;
 
+    @Resource
+    private IRoleMenuService roleMenuService;
+
     @Resource
     private GlobalSetService globalSetService;
 
@@ -124,18 +130,18 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
         if (!this.updateById(mtCompanyAttestation)) {
             return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
         }
-        //4.给企业分配默认角色,并绑定角色默认菜单
-        if (!roleService.saveDefaultMessage(companyId)) {
+        //4.分配角色和菜单
+        RestResponse restResponse = assignRoleAndMenu(companyAttestationRequest, companyId);
+        if (restResponse != null) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
+            return restResponse;
         }
-        //5.保存给企业分配的菜单
-        menuService.companyMenu(new MenuRequest(companyId, companyAttestationRequest.getMenuIds()));
-        //6.生成企业设置数据
+        //5.生成企业设置数据
         if (!globalSetService.teamInitSetting(companyId)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
         }
+        //保存公司消息
         if (!maintenanceCompanyService.updateById(maintenanceCompany)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
@@ -305,4 +311,52 @@ public class MtCompanyAttestationServiceImpl extends ServiceImpl<MtCompanyAttest
         maintenanceCompany.setIsCertificated(auditResult);
         return maintenanceCompany;
     }
+
+    /**
+     * @param companyAttestationRequest 请求信息
+     * @param companyId                 公司id
+     * @description 分配菜单和角色
+     * @date 2020/4/26 10:57 上午
+     */
+    private RestResponse assignRoleAndMenu(CompanyAttestationRequest companyAttestationRequest, Long companyId) {
+        int defaultAssign = companyAttestationRequest.getDefaultAssign();
+        //1.分配默认角色
+        List<Role> defaultRoleList = new ArrayList<>();
+        for (CommonEnum.DefaultRole defaultRole : DefaultMenuConstants.DEFAULT_ROLE) {
+            Role newRole = new Role(defaultRole);
+            newRole.setCompanyId(companyId);
+            newRole.setDescription(defaultRole.getLabel());
+            defaultRoleList.add(newRole);
+        }
+        if (!roleService.saveBatch(defaultRoleList)) {
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败-分配默认角色失败");
+        }
+
+        //2.给企业分配菜单
+        String menuIds = companyAttestationRequest.getMenuIds();
+        if (0 == defaultAssign) {
+            menuIds = ProjectUtils.arrayToStrByComma(DefaultMenuConstants.ENTERPRISE_MENUIDS);
+        }
+        RestResponse restResponse = menuService.companyMenu(new MenuRequest(companyId, menuIds));
+        if (restResponse != null) {
+            return restResponse;
+        }
+        //3.设置企业管理员菜单
+        //获取当前企业的企业管理员
+        Role enterpriseAdminRole = roleService.getOne(new QueryWrapper<Role>()
+                .eq("company_id", companyId)
+                .eq("code", CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode()));
+        if (enterpriseAdminRole == null) {
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, "企业管理员不存在,无法通过审核");
+        }
+        long[] enterpriseMenuIds = ProjectUtils.getLongIdArrayFromIds(menuIds);
+        DefaultMenuConstants.DEFAULT_ROLE_MENUIDS.put(CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode(),
+                enterpriseMenuIds);
+        //4.角色菜单分配
+        if(!roleService.assignDefaultMenu(defaultAssign, defaultRoleList, enterpriseAdminRole)){
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, "分配默认角色菜单失败");
+        }
+        return null;
+    }
+
 }

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/user/controller/LoginController.java

@@ -224,7 +224,7 @@ public class LoginController {
             if (StringUtils.isNotBlank(inputSmsCode) && inputSmsCode.equals(smsCode)) {
                 return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "短信验证码校验成功");
             } else {
-                RestResponse.fail(ApiConstants.RESULT_ERROR, "短信验证码输入有误");
+                return RestResponse.fail(ApiConstants.RESULT_ERROR, "短信验证码输入有误");
             }
         }
         return RestResponse.fail(ApiConstants.RESULT_ERROR, "短信验证码已经过期,请重新获取");

+ 9 - 8
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/IRoleService.java

@@ -64,14 +64,6 @@ public interface IRoleService extends IService<Role> {
      */
     Role getRoleByUserIdAndCompanyId(Long userId, Long companyId);
 
-    /***
-     * @description 给其分配默认角色
-     * @date 2019-12-12 16:38
-     * @param companyId 公司id
-     * @return 是否成功
-     */
-    boolean saveDefaultMessage(Long companyId);
-
     /**
      * @param
      * @return
@@ -95,4 +87,13 @@ public interface IRoleService extends IService<Role> {
      * @date 2019-12-23 22:55
      */
     RestResponse companyRoleList(RoleRequest roleRequest);
+
+    /**
+     * @param defaultAssign 默认分配标识
+     * @param defaultRoleList 默认角色列表
+     * @param enterpriseAdminRole  企业管理员角色
+     * @description
+     * @date 2020/4/26 1:26 下午
+     */
+    boolean assignDefaultMenu(int defaultAssign, List<Role> defaultRoleList, Role enterpriseAdminRole);
 }

+ 16 - 7
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/LoginService.java

@@ -112,6 +112,14 @@ public class LoginService implements ILoginService {
         if (userAccount == null) {
             return RestResponse.fail(ApiConstants.RESULT_ERROR, "手机号尚未注册");
         }
+        //判断用户是否为物管端用户
+        if (ApiConstants.UserConstants.PUBLIC_TYPE_USER == userAccount.getType()) {
+            //物管端用户,查看登录端
+            if (ApiConstants.ACCESS_TYPE_APPLETS == userRequest.getMobileType()
+                    || ApiConstants.ACCESS_TYPE_PC == userRequest.getMobileType()) {
+                return RestResponse.fail(ApiConstants.RESULT_ERROR, "没有登录权限");
+            }
+        }
         //校验密码是否正确
         String inputPassword = PasswordUtils.generatePassword(password, userAccount.getSalt());
         if (!inputPassword.equals(userAccount.getPassword())) {
@@ -267,6 +275,7 @@ public class LoginService implements ILoginService {
         Role role = userResponse.getRole();
         if (role != null) {
             currentUserInfoMap.put(ApiConstants.CURRENT_ROLE_ID, role.getId());
+            currentUserInfoMap.put(ApiConstants.CURRENT_ROLE_CODE, role.getCode());
         }
         //用户权限信息
         String permissionUrl = menuService.menuToUrl(ProjectUtils.deepCopy(userResponse.getMenus()));
@@ -285,7 +294,7 @@ public class LoginService implements ILoginService {
         //校验团队信息
         MaintenanceCompany maintenanceCompany = maintenanceCompanyService.getById(userRequest.getCompanyId());
         if (maintenanceCompany == null) {
-            return RestResponse.success(ApiConstants.RESULT_SUCCESS, "要切换的团队不存在");
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, "要切换的团队不存在");
         }
         maintenanceCompany.setCurrentTeamFlag(true);
         userResponse.setMaintenanceCompany(maintenanceCompany);
@@ -301,10 +310,6 @@ public class LoginService implements ILoginService {
                 userResponse.setRole(role);
                 //获取角色对应的菜单信息
                 List<Menu> menuTree = roleMenuService.getMenuTree(role.getId());
-                //校验菜单信息
-                if (menuTree == null || menuTree.size() <= 0) {
-                    return RestResponse.success(ApiConstants.RESULT_ERROR, "切换团队中用户没有任何菜单,无法切换");
-                }
                 userResponse.setMenus(menuTree);
             }
         }
@@ -352,8 +357,12 @@ public class LoginService implements ILoginService {
         //从redis中获取用户信息
         String mobileUserInfo = (String) redisTemplate.opsForValue().get(userResponse.getToken());
         Map<String, Object> userInfoMap = JSONUtil.parseObj(redisTemplate.opsForValue().get(mobileUserInfo));
-        //设置用户角色id
-        userInfoMap.put(ApiConstants.CURRENT_ROLE_ID, userResponse.getRole().getId());
+        if (userResponse.getRole() != null) {
+            //设置用户角色id
+            userInfoMap.put(ApiConstants.CURRENT_ROLE_ID, userResponse.getRole().getId());
+            //设置角色编码信息
+            userInfoMap.put(ApiConstants.CURRENT_ROLE_CODE, userResponse.getRole().getCode());
+        }
         //设置用户公司id
         userInfoMap.put(ApiConstants.CURRENT_COMPANY_ID, userResponse.getMaintenanceCompany().getId());
         //设置用户菜单信息

+ 9 - 3
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/MenuService.java

@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -106,7 +107,9 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> implements IMenuS
         );
         List<Long> companyMenuIds = ProjectUtils.getAttrList(needDeleteCompanyMenuList, "id", null);
         if (companyMenuIds.size() > 0) {
-            companyMenuService.removeByIds(companyMenuIds);
+            if(!companyMenuService.removeByIds(companyMenuIds)){
+               return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
+            }
         }
         //获取菜单id列表
         List<Long> menuIdList = ProjectUtils.getLongIdFromIds(menuRequest.getMenuIds());
@@ -121,9 +124,12 @@ public class MenuService extends ServiceImpl<MenuMapper, Menu> implements IMenuS
         }
         //保存公司菜单关联关系
         if (needSaveCompanyMenuList.size() > 0) {
-            companyMenuService.saveBatch(needSaveCompanyMenuList);
+            if(!companyMenuService.saveBatch(needSaveCompanyMenuList)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return RestResponse.fail(ApiConstants.RESULT_ERROR, "操作失败");
+            }
         }
-        return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "分配菜单成功");
+        return null;
     }
 
     @Override

+ 21 - 36
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/RoleService.java

@@ -1,7 +1,6 @@
 package cn.com.ty.lift.system.user.service.impl;
 
 import cn.com.ty.lift.common.constants.ApiConstants;
-import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.constants.DefaultMenuConstants;
 import cn.com.ty.lift.common.utils.ProjectUtils;
 import cn.com.ty.lift.system.user.dao.entity.*;
@@ -160,41 +159,6 @@ public class RoleService extends ServiceImpl<RoleMapper, Role> implements IRoleS
         return null;
     }
 
-    @Override
-    @Transactional
-    public boolean saveDefaultMessage(Long companyId) {
-        //默认角色列表
-        List<Role> defaultRoleList = new ArrayList<>();
-        for (CommonEnum.DefaultRole defaultRole : DefaultMenuConstants.DEFAULT_ROLE) {
-            Role newRole = new Role(defaultRole);
-            newRole.setCompanyId(companyId);
-            newRole.setDescription(defaultRole.getLabel());
-            defaultRoleList.add(newRole);
-        }
-        //保存默认角色
-        if (!this.saveBatch(defaultRoleList)) {
-            return false;
-        }
-        //关联关系列表
-        List<RoleMenu> needSaveRoleMenuList = new ArrayList<>();
-        //生成角色菜单关联关系
-        for (Role role : defaultRoleList) {
-            long[] menuIds = DefaultMenuConstants.DEFAULT_ROLE_MENUIDS.get(role.getCode());
-            for (Long menuId : menuIds) {
-                RoleMenu roleMenu = new RoleMenu();
-                roleMenu.setMenuId(menuId);
-                roleMenu.setRoleId(role.getId());
-                needSaveRoleMenuList.add(roleMenu);
-            }
-        }
-        //需要保存角色菜单信息
-        if (!roleMenuService.saveBatch(needSaveRoleMenuList)) {
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-            return false;
-        }
-        return true;
-    }
-
     @Override
     public Map<Long, Role> getUserIdToRoleByUserIdsAndCompanyId(List<Long> userIdList, Long companyId) {
         Map<Long, Role> userIdToRole = new HashMap<>();
@@ -248,4 +212,25 @@ public class RoleService extends ServiceImpl<RoleMapper, Role> implements IRoleS
         );
         return RestResponse.success(roleList, ApiConstants.RESULT_SUCCESS, "获取角色信息成功");
     }
+
+    @Override
+    public boolean assignDefaultMenu(int defaultAssign, List<Role> defaultRoleList, Role enterpriseAdminRole) {
+        List<RoleMenu> needSaveRoleMenuList = new ArrayList<>();
+        if (1 == defaultAssign) {
+            //如果是手动方式,则只给企业管理员分配菜单
+            defaultRoleList = new ArrayList<>();
+        }
+        defaultRoleList.add(enterpriseAdminRole);
+        for (Role role : defaultRoleList) {
+            long[] defaultRoleMenuIds = DefaultMenuConstants.DEFAULT_ROLE_MENUIDS.get(role.getCode());
+            for (Long menuId : defaultRoleMenuIds) {
+                RoleMenu roleMenu = new RoleMenu();
+                roleMenu.setMenuId(menuId);
+                roleMenu.setRoleId(role.getId());
+                needSaveRoleMenuList.add(roleMenu);
+            }
+        }
+        return roleMenuService.saveBatch(needSaveRoleMenuList);
+    }
+
 }

+ 6 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/UserService.java

@@ -76,6 +76,11 @@ public class UserService implements IUserService {
         userAccount.setCreateDate(LocalDateTime.now());
         //设置用户类型
         userAccount.setType(ApiConstants.UserConstants.TYPE_USER);
+        //判断用户是否为物管端注册用户
+        if (ApiConstants.ACCESS_TYPE_PUBLIC == userRequest.getMobileType()) {
+            //用户类型设置为物管端用户
+            userAccount.setType(ApiConstants.UserConstants.PUBLIC_TYPE_USER);
+        }
         //设置用户微信openId
         userAccount.setWechatOpenId(userRequest.getWeChatOpenId());
         UserInfo userInfo = new UserInfo();
@@ -381,7 +386,7 @@ public class UserService implements IUserService {
         }
         //设置团队信息
         personalCenterResponse.setMaintenanceCompanyList(maintenanceCompanyList);
-        return RestResponse.success(personalCenterResponse,"获取用户信息成功");
+        return RestResponse.success(personalCenterResponse, "获取用户信息成功");
     }
 
     @Override

+ 86 - 8
lift-system-service/src/main/resources/mapper/TodoDataMapper.xml

@@ -11,24 +11,51 @@
     <sql id="maintenanceTodoQuerySql">
         where
             mp.mt_company_id = #{mtCompanyId}
+        and
+            mp.status <![CDATA[ != ]]> 1
     </sql>
 
     <!-- 急修记录查询条件sql -->
     <sql id="emergencyTodoQuerySql">
         where
             er.mt_company_id = #{mtCompanyId}
+        and
+            er.status <![CDATA[ != ]]> 2
+        and
+            er.status <![CDATA[ != ]]> 3
+
     </sql>
 
     <!-- 大修记录查询条件sql -->
     <sql id="capitalTodoQuerySql">
         where
             cr.mt_company_id = #{mtCompanyId}
+        and
+            cr.project_status <![CDATA[ != ]]> 4
     </sql>
 
     <!-- 年检记录查询条件sql -->
     <sql id="annualInspectionTodoSql">
         where
             ai.mt_company_id = #{mtCompanyId}
+        and
+            ai.status = 1
+    </sql>
+
+    <!-- 区域项目查询 -->
+    <sql id="regionProjectSql">
+        <if test="clerkId != null || regionChargeId != null">
+            and p.region_id in (
+            select id from region r
+            where true
+            <if test="clerkId != null">
+                and find_in_set(#{clerkId}, r.clerk)
+            </if>
+            <if test="regionChargeId != null">
+                and r.user_id = #{regionChargeId}
+            </if>
+            )
+        </if>
     </sql>
 
 
@@ -50,11 +77,21 @@
             lift l
         on
             mp.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            l.id = plr.lift_id
+        left join
+            project p
+        on 
+            plr.project_id = p.id
         left join
             user_info ui
         on
             mp.worker_id = ui.user_id
         <include refid="maintenanceTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by plan_date
         <include refid="pageQuerySql"/>
     </select>
 
@@ -89,6 +126,8 @@
         on
             er.worker_id = ui.user_id
         <include refid="emergencyTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by er.assign_time
         <include refid="pageQuerySql"/>
     </select>
 
@@ -97,15 +136,17 @@
             parameterType="cn.com.ty.lift.system.homepage.dao.dto.request.TodoRequest"
             resultType="cn.com.ty.lift.system.homepage.dao.dto.response.CapitalRepairResponse">
         select
-            cr.id as capitalRepairId,
-            cr.project_name as projectName,
-            cr.project_address as projectAddress,
-            cr.start_date as startDate,
-            cr.end_date as endDate,
-            cr.push_flag as pushFlag
+            p.id as capitalRepairId,
+            p.project_name as projectName,
+            p.project_address as projectAddress,
+            p.start_date as startDate,
+            p.end_date as endDate,
+            p.push_flag as pushFlag
         from
-            capital_repair cr
+            capital_repair p
         <include refid="capitalTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by p.create_date
         <include refid="pageQuerySql"/>
     </select>
 
@@ -142,6 +183,7 @@
         on
             ui.user_id = plr.worker_id
         <include refid="annualInspectionTodoSql"/>
+        <include refid="regionProjectSql"/>
         <include refid="pageQuerySql"/>
     </select>
 
@@ -199,7 +241,16 @@
             count(1)
         from
             emergency_repair er
+        left join
+            lift l
+        on
+            er.lift_id = l.id
+        left join
+            project p
+        on
+            er.project_id = p.id
         <include refid="emergencyTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取维保待办条数 -->
@@ -210,7 +261,20 @@
             count(1)
         from
             maintenance_plan mp
+        left join
+            lift l
+        on
+            mp.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            l.id = plr.lift_id
+        left join
+            project p
+        on
+            plr.project_id = p.id
         <include refid="maintenanceTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取大修待办条数 -->
@@ -220,8 +284,9 @@
         select
             count(1)
         from
-            capital_repair cr
+            capital_repair p
         <include refid="capitalTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取年检待办条数 -->
@@ -232,7 +297,20 @@
             count(1)
         from
             annual_inspection ai
+        left join
+            lift l
+        on
+            ai.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            plr.lift_id = l.id
+        left join
+            project p
+        on
+            plr.project_id = p.id
         <include refid="annualInspectionTodoSql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
 </mapper>