package cn.com.countrygarden.bi.main.service.twerp.hm.impl;

import cn.com.countrygarden.bi.main.core.AbstractService;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dao.twerp.hm.TbSysDepartmentMapper;
import cn.com.countrygarden.bi.main.dao.twerp.hm.TbSysUserMapper;
import cn.com.countrygarden.bi.main.exception.AuthorizeException;
import cn.com.countrygarden.bi.main.exception.ServiceException;
import cn.com.countrygarden.bi.main.model.AccessToken;
import cn.com.countrygarden.bi.main.model.AccessTokenConstant;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysDepartment;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysOrgan;
import cn.com.countrygarden.bi.main.model.twerp.hm.TbSysUser;
import cn.com.countrygarden.bi.main.service.AccessTokenService;
import cn.com.countrygarden.bi.main.service.twerp.hm.TbSysOrganService;
import cn.com.countrygarden.bi.main.service.twerp.hm.TbSysUserRoleService;
import cn.com.countrygarden.bi.main.service.twerp.hm.TbSysUserService;
import cn.com.countrygarden.bi.main.util.MD5;
import cn.com.countrygarden.bi.main.util.RedisCacheUtils;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageRowBounds;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
@Transactional
public class TbSysUserServiceImpl extends AbstractService<TbSysUser> implements TbSysUserService {

    @Autowired
    protected AccessTokenService accessTokenService;

    @Autowired
    private TbSysOrganService tbSysOrganService;

    @Autowired
    private TbSysUserRoleService tbSysUserRoleService;

    @Autowired
    private TbSysUserMapper tbSysUserMapper;

    @Autowired
    private TbSysDepartmentMapper tbSysDepartmentMapper;

    private ThreadLocal<AccessToken> accessToken=new ThreadLocal<AccessToken>();
    private ThreadLocal<TbSysUser> tbSysUser=new ThreadLocal<TbSysUser>();
    private ThreadLocal<TbSysOrgan> sysOrgan=new ThreadLocal<TbSysOrgan>();


    /**
     * 用户登录
     * TODO 模拟数据
     *
     * @param loginCode
     * @param password
     * @return
     */
    public Map<String, Object> login(String loginCode, String password) {
        Map<String, Object> user = JSON.parseObject("{\"OrganId\":\"01\",\"sysOrgan\":{\"OrganName\":\"广州东/莞深区域\",\"OrganCode\":\"01DO\"},\"UserName\":\"刘吉\",\"CommID\":0,\"sysMenus\":[{\"id\":168,\"code\":\"emplofficer\",\"name\":\"体验官\",\"icon\":\"/\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1601035602000,\"updatedBy\":\"000001\",\"subMenus\":[{\"id\":169,\"code\":\"emplManage\",\"name\":\"员工用户管理\",\"icon\":\"/\",\"url\":\"/emplManage\",\"description\":\"\",\"enable\":true,\"parentCode\":\"emplofficer\",\"orderNum\":1,\"updatedDate\":1601036238000,\"updatedBy\":\"000001\",\"subMenus\":[]},{\"id\":170,\"code\":\"custManage\",\"name\":\"客户用户管理\",\"icon\":\"/\",\"url\":\"/custManage\",\"description\":\"\",\"enable\":true,\"parentCode\":\"emplofficer\",\"orderNum\":1,\"updatedDate\":1601035900000,\"updatedBy\":\"000001\",\"subMenus\":[]},{\"id\":171,\"code\":\"experience\",\"name\":\"体验内容查询\",\"icon\":\"/\",\"url\":\"/experience\",\"description\":\"\",\"enable\":true,\"parentCode\":\"emplofficer\",\"orderNum\":1,\"updatedDate\":1601035995000,\"updatedBy\":\"000001\",\"subMenus\":[]},{\"id\":173,\"code\":\"experienceOfficerAnnouncement\",\"name\":\"公告消息发布\",\"icon\":\"/\",\"url\":\"/experienceOfficerAnnouncement\",\"description\":\"\",\"enable\":true,\"parentCode\":\"emplofficer\",\"orderNum\":4,\"updatedDate\":1605756522000,\"updatedBy\":\"012149\",\"subMenus\":[]},{\"id\":174,\"code\":\"experienceOfficerTemplateMessage\",\"name\":\"公众号模板消息发布\",\"icon\":\"/\",\"url\":\"/experienceOfficerTemplateMessage\",\"description\":\"\",\"enable\":true,\"parentCode\":\"emplofficer\",\"orderNum\":5,\"updatedDate\":1605840058000,\"updatedBy\":\"012149\",\"subMenus\":[]}]},{\"id\":159,\"code\":\"ckCleaner\",\"name\":\"数据上报\",\"icon\":\"none\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1588902006000,\"updatedBy\":\"012149\",\"subMenus\":[{\"id\":172,\"code\":\"ckRecording\",\"name\":\"数据上报操作记录\",\"icon\":\"/\",\"url\":\"/ckRecording\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":1,\"updatedDate\":1601194201000,\"updatedBy\":\"000002\",\"whiteUrl\":\"\",\"subMenus\":[]},{\"id\":161,\"code\":\"ckCleanerFieldList\",\"name\":\"字段配置\",\"icon\":\"/ckCleanerFieldList\",\"url\":\"/ckCleanerFieldList\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":1,\"updatedDate\":1601023000000,\"updatedBy\":\"000006\",\"whiteUrl\":\"\",\"subMenus\":[]},{\"id\":160,\"code\":\"ckCleanerListCleaning\",\"name\":\"保洁数据维护\",\"icon\":\"/ckCleanerList\",\"url\":\"/ckCleanerListCleaning?role=ck_data_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":1,\"updatedDate\":1600349445000,\"updatedBy\":\"012149\",\"subMenus\":[]},{\"id\":183,\"code\":\"keshihua\",\"name\":\"可视化数据维护\",\"icon\":\"/\",\"url\":\"keshihua\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":1,\"updatedDate\":1624156901000,\"updatedBy\":\"035194\",\"whiteUrl\":\"\",\"subMenus\":[{\"id\":165,\"code\":\"ck_ksh\",\"name\":\"服务可视化数据管理\",\"icon\":\"/\",\"url\":\"/ckCleanerListTwo?role=ck_ksh_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"keshihua\",\"orderNum\":6,\"updatedDate\":1622704847000,\"updatedBy\":\"035194\",\"subMenus\":[]},{\"id\":182,\"code\":\"fillinckCleanerListTwo\",\"name\":\"填报服务可视化数据\",\"icon\":\"/\",\"url\":\"/fillinckCleanerListTwo?role=ck_ksh_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"keshihua\",\"orderNum\":7,\"updatedDate\":1622901284000,\"updatedBy\":\"035194\",\"subMenus\":[]}]},{\"id\":184,\"code\":\"security\",\"name\":\"安防数据维护\",\"icon\":\"/\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":1,\"updatedDate\":1624609277000,\"updatedBy\":\"035194\",\"whiteUrl\":\"\",\"subMenus\":[{\"id\":185,\"code\":\"ckSecurity\",\"name\":\"安防数据管理\",\"icon\":\"/\",\"url\":\"/ckSecurity?role=ck_security_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"security\",\"orderNum\":1,\"updatedDate\":1624609467000,\"updatedBy\":\"035194\",\"whiteUrl\":\"\",\"subMenus\":[]},{\"id\":186,\"code\":\"addCkSecurity\",\"name\":\"填报安防数据\",\"icon\":\"/\",\"url\":\"/addCkSecurity?role=ck_security_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"security\",\"orderNum\":2,\"updatedDate\":1624609555000,\"updatedBy\":\"035194\",\"subMenus\":[]}]},{\"id\":163,\"code\":\"ckFieldRole\",\"name\":\"权限维护\",\"icon\":\"/\",\"url\":\"/ckFieldRole\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":3,\"updatedDate\":1589877419000,\"updatedBy\":\"012149\",\"whiteUrl\":\"\",\"subMenus\":[]},{\"id\":164,\"code\":\"ck_afforest\",\"name\":\"绿化数据维护\",\"icon\":\"/\",\"url\":\"/ckCleanerListLvTwo?role=ck_afforest_admin\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":5,\"updatedDate\":1601172631000,\"updatedBy\":\"000002\",\"subMenus\":[]},{\"id\":188,\"code\":\"ckSatisfaction\",\"name\":\"满意度数据维护\",\"icon\":\"/\",\"url\":\"/ckSatisfaction\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":6,\"updatedDate\":1629362041000,\"updatedBy\":\"000002\",\"subMenus\":[]},{\"id\":190,\"code\":\"ckPublicBenefits\",\"name\":\"公共收益数据\",\"icon\":\"/\",\"url\":\"/ckPublicBenefits\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":11,\"updatedDate\":1639058756000,\"updatedBy\":\"035194\",\"subMenus\":[]},{\"id\":191,\"code\":\"ckPublicZation\",\"name\":\"公共收益期初值\",\"icon\":\"/\",\"url\":\"/ckPublicZation\",\"description\":\"\",\"enable\":true,\"parentCode\":\"ckCleaner\",\"orderNum\":12,\"updatedDate\":1639058766000,\"updatedBy\":\"035194\",\"whiteUrl\":\"\",\"subMenus\":[]}]},{\"id\":41,\"code\":\"sysmanager\",\"name\":\"系统管理\",\"icon\":\"static/icon/menu/statistics.png\",\"url\":\"sysmanager\",\"description\":\"系统管理\",\"enable\":true,\"orderNum\":1,\"updatedDate\":1556198970000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":43,\"code\":\"resmanager\",\"name\":\"资源管理\",\"icon\":\"static/icon/menu/statistics.png\",\"url\":\"resmanager\",\"description\":\"资源管理\",\"enable\":true,\"parentCode\":\"sysmanager\",\"orderNum\":1,\"createdDate\":1506755443000,\"createdBy\":\"sys\",\"updatedDate\":1506755443000,\"updatedBy\":\"sys\",\"subMenus\":[{\"id\":44,\"code\":\"menusmanager\",\"name\":\"菜单管理\",\"icon\":\"static/icon/menu/statistics.png\",\"url\":\"menusmanager\",\"description\":\"菜单管理\",\"enable\":true,\"parentCode\":\"resmanager\",\"orderNum\":1,\"createdDate\":1506755443000,\"createdBy\":\"sys\",\"updatedDate\":1506755443000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/menu\",\"subMenus\":[]},{\"id\":45,\"code\":\"functionsmanager\",\"name\":\"操作管理\",\"icon\":\"static/icon/menu/statistics.png\",\"url\":\"functionsmanager\",\"description\":\"操作管理\",\"enable\":true,\"parentCode\":\"resmanager\",\"orderNum\":1,\"createdDate\":1506755443000,\"createdBy\":\"sys\",\"updatedDate\":1506755443000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/functions\",\"subMenus\":[]}]},{\"id\":42,\"code\":\"rolemanager\",\"name\":\"角色管理\",\"icon\":\"static/icon/menu/statistics.png\",\"url\":\"rolemanager\",\"description\":\"角色管理\",\"enable\":true,\"parentCode\":\"sysmanager\",\"orderNum\":2,\"updatedDate\":1556198328000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/role,DPshow_depart/api/user,DPshow_depart/api/menu/roleTreea\",\"subMenus\":[]},{\"id\":39,\"code\":\"projectTypeManagement\",\"name\":\"分类管理\",\"icon\":\"static/icon/menu/weeklySummary.png\",\"url\":\"projectTypeManagement\",\"description\":\"分类管理\",\"enable\":true,\"parentCode\":\"sysmanager\",\"orderNum\":7,\"updatedDate\":1593487488000,\"updatedBy\":\"012149\",\"whiteUrl\":\"DPshow_depart/api/project/menu\",\"subMenus\":[]}]},{\"id\":158,\"code\":\"propertyAgreement\",\"name\":\"物业协议列表\",\"icon\":\"/\",\"url\":\"propertyAgreement\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1579180614000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/service/propertyAgreement/pageList\",\"subMenus\":[]},{\"id\":6,\"code\":\"fenghuang_manager\",\"name\":\"品质\",\"icon\":\"static/icon/menu/fenghuang_manager.png\",\"url\":\"/\",\"description\":\"品质\",\"enable\":true,\"orderNum\":1,\"updatedDate\":1556198961000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":7,\"code\":\"fenghuang_manager_data\",\"name\":\"管家服务数据\",\"icon\":\"static/icon/menu/fenghuang_manager_data.png\",\"url\":\"fenghuang_manager_data\",\"description\":\"管家服务数据\",\"enable\":true,\"parentCode\":\"fenghuang_manager\",\"orderNum\":1,\"createdDate\":1505721031000,\"createdBy\":\"sys\",\"updatedDate\":1505721031000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/manager,DPshow_depart/api/fenghuang/common\",\"subMenus\":[]},{\"id\":55,\"code\":\"emergencies\",\"name\":\"BIP突发事件\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/emergencies\",\"enable\":true,\"parentCode\":\"fenghuang_manager\",\"orderNum\":1,\"updatedDate\":1557196029000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/biEmergency\",\"subMenus\":[]},{\"id\":12,\"code\":\"fenghuang_comm\",\"name\":\"品质项目\",\"icon\":\"static/icon/menu/fenghuang_manager_data.png\",\"url\":\"fenghuang_comm\",\"description\":\"管家上报项目管理\",\"enable\":true,\"parentCode\":\"fenghuang_manager\",\"orderNum\":2,\"createdDate\":1511332835000,\"createdBy\":\"sys\",\"updatedDate\":1511332835000,\"updatedBy\":\"sys\",\"subMenus\":[]},{\"id\":90,\"code\":\"managermap_index\",\"name\":\"管家地图\",\"icon\":\"/\",\"url\":\"managermap_index\",\"description\":\"管家地图首页\",\"enable\":true,\"parentCode\":\"fenghuang_manager\",\"orderNum\":4,\"updatedDate\":1557407248000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/manager/map,DPshow_depart/api/manager/houseKeeper/garden,DPshow_depart/api/manager/houseKeeper/list,DPshow_depart/api/manager/houseKeeper,DPshow_depart/api/manager/map/cache/houseKeeper,DPshow_depart/api/manager/map/cache/map\",\"subMenus\":[]},{\"id\":91,\"code\":\"houseKeeper_follow\",\"name\":\"我的关注\",\"icon\":\"/\",\"url\":\"/houseKeeper_follow\",\"description\":\"我的关注\",\"enable\":true,\"parentCode\":\"fenghuang_manager\",\"orderNum\":5,\"updatedDate\":1538236793000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/manager/houseKeeper/follow,DPshow_depart/api/manager/map/organ,DPshow_depart/api/manager/houseKeeper/development,DPshow_depart/api/manager/houseKeeper/follow/list\",\"subMenus\":[]}]},{\"id\":149,\"code\":\"districtReport\",\"name\":\"区域管理报表\",\"icon\":\"/\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1568724662000,\"updatedBy\":\"013058\",\"whiteUrl\":\"\",\"subMenus\":[{\"id\":148,\"code\":\"rdDistrictInfo\",\"name\":\"片区管理\",\"icon\":\"/\",\"url\":\"/rdDistrictInfo\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":1,\"updatedDate\":1570612258000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdDistrictInfo,DPshow_depart/api/rdDistrictProjectMp,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictProjectMp/checkMp\",\"subMenus\":[]},{\"id\":150,\"code\":\"settledProject\",\"name\":\"项目进驻计划\",\"icon\":\"/\",\"url\":\"/settledProject\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":2,\"updatedDate\":1570612788000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdDistrictSettled,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictInfo/projectMp,DPshow_depart/api/rdDistrictInfo/rdDistrictInfoBown,DPshow_depart/api/rdDistrictSettled/settledDTOAddone\",\"subMenus\":[]},{\"id\":151,\"code\":\"pendingbuildingproject\",\"name\":\"项目交付计划\",\"icon\":\"/\",\"url\":\"/pendingbuildingproject\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":3,\"updatedDate\":1570628545000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdPendingBuildingProject,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictInfo/rdDistrictInfoBown,DPshow_depart/api/rdDistrictInfo/projectMp,DPshow_depart/api/rdPendingBuildingProject/buildingProjectAddone\",\"subMenus\":[]},{\"id\":152,\"code\":\"rdNewProject\",\"name\":\"未开盘项目信息\",\"icon\":\"/\",\"url\":\"/rdNewProject\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":4,\"updatedDate\":1570628117000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdNewProject,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdNewProject/synchronousDataAll,DPshow_depart/api/rdNewProject/synchronousData,DPshow_depart/api/rdDistrictInfo\",\"subMenus\":[]},{\"id\":153,\"code\":\"unopenedProject\",\"name\":\"未收楼项目信息\",\"icon\":\"/\",\"url\":\"/unopenedProject\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":5,\"updatedDate\":1570628241000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdUncollectedBuildingProjects,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictInfo/rdDistrictInfoBown,DPshow_depart/api/rdDistrictInfo/projectMp,DPshow_depart/api/rdUncollectedBuildingProjects\",\"subMenus\":[]},{\"id\":154,\"code\":\"rdClosedBuildingProject\",\"name\":\"已收楼项目信息\",\"icon\":\"/\",\"url\":\"/rdClosedBuildingProject\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":6,\"updatedDate\":1570632345000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/rdClosedBuildingProject,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictInfo/rdDistrictInfoBown,DPshow_depart/api/rdDistrictInfo/projectMp,DPshow_depart/api/rdClosedBuildingProject\",\"subMenus\":[]},{\"id\":155,\"code\":\"projectInformationSummary\",\"name\":\"项目信息汇总\",\"icon\":\"/\",\"url\":\"/projectInformationSummary\",\"description\":\"\",\"enable\":true,\"parentCode\":\"districtReport\",\"orderNum\":7,\"updatedDate\":1570628427000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/rdprojectInformationSummary,DPshow_depart/api/rdDistrictInfo/findRoleregionName,DPshow_depart/api/rdDistrictInfo/rdDistrictInfoBown,DPshow_depart/api/rdDistrictInfo/projectMp\",\"subMenus\":[]}]},{\"id\":156,\"code\":\"publicResource\",\"name\":\"公共资源\",\"icon\":\"/\",\"url\":\"/publicResource\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1571916129000,\"updatedBy\":\"013058\",\"subMenus\":[{\"id\":157,\"code\":\"operatingSummary\",\"name\":\"公共资源意见征询上报\",\"icon\":\"/\",\"url\":\"/operatingSummary\",\"description\":\"\",\"enable\":true,\"parentCode\":\"publicResource\",\"orderNum\":1,\"updatedDate\":1571916158000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/biapp/caseField/findCaseFieldCommByOrganCode,DPshow_depart/api/biapp/caseField/findCaseFieldOrgans\",\"subMenus\":[]},{\"id\":187,\"code\":\"incomeStatement\",\"name\":\"公共资源收益\",\"icon\":\"/\",\"url\":\"/incomeStatement\",\"description\":\"\",\"enable\":true,\"parentCode\":\"publicResource\",\"orderNum\":2,\"updatedDate\":1624958511000,\"updatedBy\":\"000002\",\"subMenus\":[]}]},{\"id\":144,\"code\":\"suggestions\",\"name\":\"建言反馈\",\"icon\":\"/\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":1,\"updatedDate\":1560429480000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/afAdviseNotice,DPshow_depart/api/afAdviseType,DPshow_depart/api/afAdviseConfig,DPshow_depart/api/afAdviseFeedback,DPshow_depart/api/afAdviseResponsibler,DPshow_depart/api/sys/user,DPshow_depart/api/afAdviseProcess/addOrEdit\",\"subMenus\":[{\"id\":145,\"code\":\"suggestionsInfo\",\"name\":\"建言\",\"icon\":\"/\",\"url\":\"/adviseInfo\",\"description\":\"\",\"enable\":true,\"parentCode\":\"suggestions\",\"orderNum\":1,\"updatedDate\":1560429557000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/afAdviseNotice,DPshow_depart/api/afAdviseProcess,DPshow_depart/api/afAdviseType/selectList,DPshow_depart/api/afAdviseFeedback,\",\"subMenus\":[]},{\"id\":146,\"code\":\"suggestionsSet\",\"name\":\"设置\",\"icon\":\"/\",\"url\":\"/suggestionsSet\",\"description\":\"\",\"enable\":true,\"parentCode\":\"suggestions\",\"orderNum\":2,\"updatedDate\":1560429701000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/afAdviseConfig,DPshow_depart/api/afAdviseType,DPshow_depart/api/afAdviseProcess,DPshow_depart/api/afAdviseBranchType,DPshow_depart/api/afAdviseResponsibler,\",\"subMenus\":[]},{\"id\":147,\"code\":\"publicNotice\",\"name\":\"公告栏\",\"icon\":\"/\",\"url\":\"/publicNotice\",\"description\":\"\",\"enable\":true,\"parentCode\":\"suggestions\",\"orderNum\":3,\"updatedDate\":1560429595000,\"updatedBy\":\"013057\",\"whiteUrl\":\"DPshow_depart/api/afAdviseNotice,DPshow_depart/api/afAdviseFeedback\",\"subMenus\":[]}]},{\"id\":8,\"code\":\"fenghuang_buoy\",\"name\":\"浮标\",\"icon\":\"static/icon/menu/fenghuang_buoy.png\",\"url\":\"/\",\"description\":\"浮标\",\"enable\":true,\"orderNum\":2,\"updatedDate\":1556199293000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":9,\"code\":\"fenghuang_buoy_data\",\"name\":\"核心触点\",\"icon\":\"static/icon/menu/fenghuang_buoy_data.png\",\"url\":\"fenghuang_buoy_data\",\"description\":\"核心触点\",\"enable\":true,\"parentCode\":\"fenghuang_buoy\",\"orderNum\":1,\"createdDate\":1505721031000,\"createdBy\":\"sys\",\"updatedDate\":1505721031000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/buoy,DPshow_depart/api/fenghuang/common\",\"subMenus\":[]}]},{\"id\":13,\"code\":\"caseFieldManage\",\"name\":\"案场管理\",\"icon\":\"static/icon/menu/projectlist.png\",\"url\":\"/\",\"description\":\"案场管理\",\"enable\":true,\"orderNum\":3,\"updatedDate\":1530168248000,\"updatedBy\":\"008160\",\"subMenus\":[{\"id\":15,\"code\":\"caseFieldNameManager\",\"name\":\"案场名称管理\",\"icon\":\"static/icon/menu/projectlist.png\",\"url\":\"caseFieldNameManager\",\"description\":\"案场名称管理\",\"enable\":true,\"parentCode\":\"caseFieldManage\",\"orderNum\":1,\"createdDate\":1518158555000,\"createdBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/biapp/caseField,DPshow_depart/api/biapp/caseFieldInfo\",\"subMenus\":[]},{\"id\":14,\"code\":\"caseFieldBasicInfo\",\"name\":\"案场基础信息\",\"icon\":\"static/icon/menu/projectlist.png\",\"url\":\"caseFieldBasicInfo\",\"description\":\"案场基础信息\",\"enable\":true,\"parentCode\":\"caseFieldManage\",\"orderNum\":2,\"updatedDate\":1557133780000,\"updatedBy\":\"012149\",\"whiteUrl\":\"DPshow_depart/api/biapp/caseField,DPshow_depart/api/biapp/approvalInfo\",\"subMenus\":[]}]},{\"id\":32,\"code\":\"marketing\",\"name\":\"市场拓展\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"市场拓展\",\"enable\":true,\"orderNum\":4,\"updatedDate\":1556199262000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":140,\"code\":\"cityCompanyDataReport\",\"name\":\"城市公司数据上报\",\"icon\":\"/\",\"url\":\"cityCompanyDataReport\",\"description\":\"城市公司数据上报\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":1,\"updatedDate\":1551355320000,\"updatedBy\":\"000001\",\"whiteUrl\":\"DPshow_depart/cityCompanyDataMrg\",\"subMenus\":[]},{\"id\":66,\"code\":\"projectProgressList\",\"name\":\"项目进度一览\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"projectProgressList\",\"description\":\"项目进度一览\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":1,\"updatedDate\":1535074177000,\"updatedBy\":\"4718\",\"subMenus\":[]},{\"id\":141,\"code\":\"expansionMatch\",\"name\":\"外拓项目台账信息\",\"icon\":\"/\",\"url\":\"expansionMatch\",\"description\":\"外拓项目台账信息\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":1,\"updatedDate\":1551355320000,\"updatedBy\":\"000001\",\"whiteUrl\":\"DPshow_depart/api/extension,DPshow_depart/api/fenghuang,DPshow_depart/api/fenghuang\",\"subMenus\":[]},{\"id\":139,\"code\":\"reportForms\",\"name\":\"拓后管理报表\",\"icon\":\"/\",\"url\":\"reportForms\",\"description\":\"拓后管理报表\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":1,\"updatedDate\":1551355320000,\"updatedBy\":\"000001\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/WeekIncomeController,DPshow_depart/api/extension/v1/report,DPshow_depart/api/fenghuang/WeekIncomeController,DPshow_depart/api/fenghuang/common\",\"subMenus\":[]},{\"id\":33,\"code\":\"myprojects\",\"name\":\"我的项目\",\"icon\":\"static/icon/menu/myprojects.png\",\"url\":\"projects\",\"description\":\"我的项目\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":1,\"updatedDate\":1530494863000,\"updatedBy\":\"012149\",\"whiteUrl\":\"DPshow_depart/api/user/functions,DPshow_depart/api/biapp/marketing/backend/project,DPshow_depart/api/fenghuang/common,DPshow_depart/api/biapp/contractStatistical\",\"subMenus\":[]},{\"id\":35,\"code\":\"projectlist\",\"name\":\"项目列表\",\"icon\":\"static/icon/menu/projectlist.png\",\"url\":\"projectList\",\"description\":\"项目列表\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":3,\"updatedDate\":1530495170000,\"updatedBy\":\"012149\",\"whiteUrl\":\"DPshow_depart/api/biapp/contractStatistical/findOrderCoder,DPshow_depart/api/biapp/marketing/backend/project\",\"subMenus\":[]},{\"id\":37,\"code\":\"sign\",\"name\":\"签约明细\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"sign\",\"description\":\"签约明细\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":6,\"updatedDate\":1531965426000,\"updatedBy\":\"008160\",\"whiteUrl\":\"DPshow_depart/api/project,DPshow_depart/api/biapp\",\"subMenus\":[]},{\"id\":38,\"code\":\"signStatistics\",\"name\":\"签约明细统计\",\"icon\":\"static/icon/menu/resident_contract.png\",\"url\":\"signStatistics\",\"description\":\"签约明细统计\",\"enable\":true,\"parentCode\":\"marketing\",\"orderNum\":8,\"updatedDate\":1531965458000,\"updatedBy\":\"008160\",\"whiteUrl\":\"DPshow_depart/api/project/sign/infoFrom\",\"subMenus\":[]}]},{\"id\":48,\"code\":\"sqfz_root\",\"name\":\"社区发展\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":6,\"updatedDate\":1556199036000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":22,\"code\":\"community_developing\",\"name\":\"社区增值\",\"icon\":\"static/icon/menu/house.png\",\"url\":\"/\",\"description\":\"社区发展\",\"enable\":true,\"parentCode\":\"sqfz_root\",\"orderNum\":1,\"updatedDate\":1529579392000,\"updatedBy\":\"008160\",\"subMenus\":[{\"id\":20,\"code\":\"ConstrackStatistics\",\"name\":\"合同录入统计\",\"icon\":\"static/icon/menu/contract.png\",\"url\":\"community_developing\",\"description\":\"合同录入统计\",\"enable\":true,\"parentCode\":\"community_developing\",\"orderNum\":1,\"createdDate\":1523521270000,\"createdBy\":\"sys\",\"updatedDate\":1523521270000,\"updatedBy\":\"sys\",\"subMenus\":[]},{\"id\":21,\"code\":\"siteResources\",\"name\":\"场地资源\",\"icon\":\"static/icon/menu/home\",\"url\":\"blanks\",\"description\":\"场地资源\",\"enable\":true,\"parentCode\":\"community_developing\",\"orderNum\":1,\"updatedDate\":1563903356000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/SiteResourcesController,DPshow_depart/api/microSatisfyController,DPshow_depart/api/media/advertising/singleUpload\",\"subMenus\":[]}]},{\"id\":23,\"code\":\"community_media\",\"name\":\"社区传媒\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"社区传媒\",\"enable\":true,\"parentCode\":\"sqfz_root\",\"orderNum\":2,\"updatedDate\":1530168451000,\"updatedBy\":\"008160\",\"subMenus\":[{\"id\":24,\"code\":\"media_resources\",\"name\":\"媒体资源\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"community_media\",\"description\":\"媒体资源\",\"enable\":true,\"parentCode\":\"community_media\",\"orderNum\":1,\"createdDate\":1526435732000,\"createdBy\":\"sys\",\"updatedDate\":1526435738000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/MediaResourcesController\",\"subMenus\":[]}]},{\"id\":25,\"code\":\"secondhand_rentandsell\",\"name\":\"房产经营\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"二手租售\",\"enable\":true,\"parentCode\":\"sqfz_root\",\"orderNum\":3,\"updatedDate\":1530168460000,\"updatedBy\":\"008160\",\"subMenus\":[{\"id\":27,\"code\":\"oneWeek_income\",\"name\":\"周收入统计表\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"oneWeek_incomes\",\"description\":\"周收入统计表\",\"enable\":true,\"parentCode\":\"secondhand_rentandsell\",\"orderNum\":1,\"createdDate\":1526614376000,\"createdBy\":\"sys\",\"updatedDate\":1526614382000,\"updatedBy\":\"sys\",\"subMenus\":[]},{\"id\":26,\"code\":\"divertStatical\",\"name\":\"转名统计表\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"secondhand_rentandsell\",\"description\":\"转名统计表\",\"enable\":true,\"parentCode\":\"secondhand_rentandsell\",\"orderNum\":1,\"createdDate\":1526614221000,\"createdBy\":\"sys\",\"updatedDate\":1526614226000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/biapp/DivertStatisticalController,DPshow_depart/api/biapp/contractStatistical\",\"subMenus\":[]}]},{\"id\":28,\"code\":\"resident_amused\",\"name\":\"居者乐\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"居者乐\",\"enable\":true,\"parentCode\":\"sqfz_root\",\"orderNum\":4,\"updatedDate\":1530168468000,\"updatedBy\":\"008160\",\"subMenus\":[{\"id\":31,\"code\":\"parkingSpace_transfer_details\",\"name\":\"车位移交明细\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"parkingSpace_transfer_details\",\"description\":\"车位移交明细\",\"enable\":true,\"parentCode\":\"resident_amused\",\"orderNum\":1,\"createdDate\":1526623433000,\"createdBy\":\"sys\",\"updatedDate\":1526623438000,\"updatedBy\":\"sys\",\"whiteUrl\":\"Pshow_depart/api/biapp/ParkingSpacesTransferDetailController\",\"subMenus\":[]},{\"id\":29,\"code\":\"sell_data_management\",\"name\":\"营销数据管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"sell_data_management\",\"description\":\"营销数据管理\",\"enable\":true,\"parentCode\":\"resident_amused\",\"orderNum\":1,\"createdDate\":1526623082000,\"createdBy\":\"sys\",\"updatedDate\":1526623088000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/fenghuang/SellDataManagementController\",\"subMenus\":[]},{\"id\":30,\"code\":\"last_merchandise_transfer_details\",\"name\":\"尾盘货量移交明细\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"last_merchandise_transfer_details\",\"description\":\"尾盘货量移交明细\",\"enable\":true,\"parentCode\":\"resident_amused\",\"orderNum\":1,\"createdDate\":1526623294000,\"createdBy\":\"sys\",\"updatedDate\":1526623298000,\"updatedBy\":\"sys\",\"whiteUrl\":\"DPshow_depart/api/biapp/contractStatistical,DPshow_depart/api/biapp/LastTransferDetailController\",\"subMenus\":[]}]}]},{\"id\":50,\"code\":\"wcxManagement\",\"name\":\"微创新管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"/\",\"description\":\"微创新管理\",\"enable\":true,\"orderNum\":9,\"updatedDate\":1556199013000,\"updatedBy\":\"013058\",\"whiteUrl\":\"DPshow_depart/api/user/logout\",\"subMenus\":[{\"id\":49,\"code\":\"wcxRoleManagement\",\"name\":\"角色管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxRoleManagement\",\"description\":\"微创新角色管理\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":1,\"createdDate\":1529661364000,\"updatedDate\":1529661349000,\"whiteUrl\":\"DPshow_depart/api/wcx/role,DPshow_depart/api/wcx/user\",\"subMenus\":[]},{\"id\":61,\"code\":\"wcxReprotManagement\",\"name\":\"报表管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxReportManagement\",\"description\":\"微创新报表管理\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":1,\"createdDate\":1534415521000,\"whiteUrl\":\"DPshow_depart/api/wcx/report/region,DPshow_depart/api/wcx/report/project,DPshow_depart/api/wcx/report/baseline\",\"subMenus\":[]},{\"id\":71,\"code\":\"wcxFeedbackManagement\",\"name\":\"用户反馈\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxFeedbackManagement\",\"description\":\"微创新用户反馈\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":1,\"createdDate\":1529663524000,\"whiteUrl\":\"DPshow_depart/api/wcx/wcxFeedback\",\"subMenus\":[]},{\"id\":72,\"code\":\"wcxInfoReportManagement\",\"name\":\"用户投诉\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxInfoReportManagement\",\"description\":\"微创新用户投诉\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":1,\"createdDate\":1536575524000,\"whiteUrl\":\"DPshow_depart/api/wcx/wcxInfoReportManagement/wcxInnovationOther,DPshow_depart/api/wcx/wcxInfoReportManagement/wcxReviewOther\",\"subMenus\":[]},{\"id\":51,\"code\":\"wcxInnManagement\",\"name\":\"数据管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxInnManagement\",\"description\":\"微创新数据管理\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":2,\"updatedDate\":1531965516000,\"updatedBy\":\"008160\",\"whiteUrl\":\"DPshow_depart/api/wcx/regionProject,DPshow_depart/api/wcx/wcxInnovation,DPshow_depart/api/wcx/review\",\"subMenus\":[]},{\"id\":52,\"code\":\"wcxPrizeManagement\",\"name\":\"奖单管理\",\"icon\":\"static/icon/menu/marketing.png\",\"url\":\"wcxPrizeManagement\",\"description\":\"微创新奖单管理\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":3,\"updatedDate\":1531965529000,\"updatedBy\":\"008160\",\"whiteUrl\":\"DPshow_depart/api/wcx/prize\",\"subMenus\":[]},{\"id\":142,\"code\":\"wcxSuggestManagement\",\"name\":\"提议管理\",\"icon\":\"static/icon/menu/marketing.png\",\"style\":\"\",\"url\":\"wcxSuggestManagement\",\"description\":\"微创新提议管理\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":5,\"createdDate\":1551355385000,\"createdBy\":\"\",\"updatedBy\":\"\",\"whiteUrl\":\"DPshow_depart/api/wcx/suggest\",\"subMenus\":[]},{\"id\":181,\"code\":\"userManagement\",\"name\":\"用户管理\",\"icon\":\"/\",\"url\":\"/userManagement\",\"description\":\"\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":5,\"updatedDate\":1621264522000,\"updatedBy\":\"035194\",\"subMenus\":[]},{\"id\":179,\"code\":\"noticeManagement\",\"name\":\"公告管理\",\"icon\":\"/\",\"url\":\"noticeManagement\",\"description\":\"\",\"enable\":true,\"parentCode\":\"wcxManagement\",\"orderNum\":8,\"updatedDate\":1618474803000,\"updatedBy\":\"000002\",\"subMenus\":[]}]},{\"id\":177,\"code\":\"insuranceOrderHear\",\"name\":\"保险订单菜单\",\"icon\":\"/\",\"url\":\"/\",\"description\":\"\",\"enable\":true,\"parentCode\":\"\",\"orderNum\":9,\"updatedDate\":1613701590000,\"updatedBy\":\"000002\",\"whiteUrl\":\"\",\"subMenus\":[{\"id\":167,\"code\":\"insuranceOrder\",\"name\":\"保险订单\",\"icon\":\"/\",\"url\":\"/insuranceOrder\",\"description\":\"\",\"enable\":true,\"parentCode\":\"insuranceOrderHear\",\"orderNum\":1,\"updatedDate\":1613701630000,\"updatedBy\":\"000002\",\"whiteUrl\":\"DPshow_depart/api/insuranceOrder,,DPshow_depart/api/insuranceOrder/list,DPshow_depart/api/insuranceOrder/findRoleregionName\",\"subMenus\":[]},{\"id\":178,\"code\":\"organization\",\"name\":\"组织权限\",\"icon\":\"/\",\"url\":\"/organization\",\"description\":\"\",\"enable\":true,\"parentCode\":\"insuranceOrderHear\",\"orderNum\":2,\"updatedDate\":1613702657000,\"updatedBy\":\"000002\",\"whiteUrl\":\"\",\"subMenus\":[]}]}],\"LoginCode\":\"liuji\",\"UserCode\":\"012149\",\"accessToken\":\"B9BD8B927B25424E38EF6BD7F2B290F6\",\"PassWord\":\"bgy2022@\",\"logoutUrl\":\"https://login-test.bgyfw.com/api/sso/logout\",\"DepCode\":\"e02bd001-6f4c-4850-8405-af6bd84d1e26\",\"userRole\":{\"RoleName\":\"科技研发中心查询岗\",\"CommID\":\"0\",\"RoleDescribe\":null,\"SysRoleCode\":\"008697\",\"IsSysRole\":\"0\",\"RoleCode\":\"000015\"},\"Memo\":\"\",\"userFunctions\":[{\"id\":10,\"code\":\"resident_modify_expire\",\"name\":\"居民公司作废协议\",\"enable\":true,\"createdDate\":1512459060000,\"createdBy\":\"sys\",\"updatedDate\":1512459064000,\"updatedBy\":\"sys\"},{\"id\":8,\"code\":\"resident_modify_invoice\",\"name\":\"居民公司开票\",\"enable\":true,\"createdDate\":1510742293000,\"createdBy\":\"sys\",\"updatedDate\":1510742293000,\"updatedBy\":\"sys\"},{\"id\":9,\"code\":\"resident_modify_terminated\",\"name\":\"居民公司终止协议\",\"enable\":true,\"createdDate\":1512459060000,\"createdBy\":\"sys\",\"updatedDate\":1512459064000,\"updatedBy\":\"sys\"},{\"id\":31,\"code\":\"1111123\",\"name\":\"1111123\",\"description\":\"查看权限1\",\"enable\":true,\"updatedDate\":1546849374000,\"updatedBy\":\"000002\"},{\"id\":68,\"code\":\"123123\",\"name\":\"123123\",\"description\":\"123123\",\"enable\":true,\"createdDate\":1551944323000,\"createdBy\":\"000002\"},{\"id\":69,\"code\":\"234243\",\"name\":\"234\",\"description\":\"234\",\"enable\":true,\"createdDate\":1551944423000,\"createdBy\":\"000002\"},{\"id\":30,\"code\":\"aabbcc\",\"name\":\"测试新增按钮\",\"description\":\"测试新增按钮测试新增按钮测试新增按钮测试新增按钮\",\"enable\":true,\"updatedDate\":1550803601000,\"updatedBy\":\"4718\"},{\"id\":67,\"code\":\"advertising_create_order\",\"name\":\"MR-预定单管理-新建预定单\",\"description\":\"媒体资源排期-预定单管理-新建预定单\",\"enable\":true,\"updatedDate\":1554468533000,\"updatedBy\":\"100003\"},{\"id\":54,\"code\":\"advertising_print\",\"name\":\"MR-广告位预定-打印\",\"description\":\"媒体资源排期-广告位预定-打印\",\"enable\":true,\"updatedDate\":1554469043000,\"updatedBy\":\"100003\"},{\"id\":55,\"code\":\"advertising_reserve_cancel\",\"name\":\"MR-广告位预订-取消预定\",\"description\":\"媒体资源排期-广告位预订-取消预定\",\"enable\":true,\"updatedDate\":1554468901000,\"updatedBy\":\"100003\"},{\"id\":23,\"code\":\"approval_input\",\"name\":\"案场基本信息审核权限\",\"description\":\"案场基本信息审核权限\",\"enable\":true,\"updatedDate\":1530701882000,\"updatedBy\":\"4718\"},{\"id\":37,\"code\":\"basic_edit\",\"name\":\"MR-项目基础数据-修改\",\"description\":\"媒体资源排期-项目基础数据-修改\",\"enable\":true,\"updatedDate\":1554468637000,\"updatedBy\":\"100003\"},{\"id\":61,\"code\":\"basic_export\",\"name\":\"MR-项目基础数据-导出\",\"description\":\"媒体资源排期-项目基础数据-导出\",\"enable\":true,\"updatedDate\":1554468944000,\"updatedBy\":\"100003\"},{\"id\":38,\"code\":\"basic_import\",\"name\":\"MR-项目基础数据-批量修改\",\"description\":\"媒体资源排期-项目基础数据-批量修改\",\"enable\":true,\"updatedDate\":1554468652000,\"updatedBy\":\"100003\"},{\"id\":15,\"code\":\"casefield_modify_casefieldname\",\"name\":\"案场名称管理之修改名称\",\"enable\":true,\"createdDate\":1518161059000,\"createdBy\":\"sys\"},{\"id\":14,\"code\":\"casefield_modify_detail\",\"name\":\"案场修改案场详情\",\"enable\":true,\"createdDate\":1518161007000,\"createdBy\":\"sys\"},{\"id\":16,\"code\":\"casefield_modify_header\",\"name\":\"总部人员修改满意度\",\"enable\":true,\"updatedDate\":1565224115000,\"updatedBy\":\"321413\"},{\"id\":73,\"code\":\"ck_clear_delete\",\"name\":\"数据上报-数据维护列表-删除\",\"enable\":true,\"createdDate\":1590480960000,\"createdBy\":\"007796\"},{\"id\":47,\"code\":\"client_add\",\"name\":\"MR-客户管理-新增\",\"description\":\"媒体资源排期-客户管理-新增\",\"enable\":true,\"updatedDate\":1554468721000,\"updatedBy\":\"100003\"},{\"id\":48,\"code\":\"client_edit\",\"name\":\"MR-客户管理-修改\",\"description\":\"媒体资源排期-客户管理-修改\",\"enable\":true,\"updatedDate\":1554469412000,\"updatedBy\":\"100003\"},{\"id\":49,\"code\":\"client_import\",\"name\":\"MR-客户管理-导入\",\"description\":\"媒体资源排期-客户管理-导入\",\"enable\":true,\"updatedDate\":1554468839000,\"updatedBy\":\"100003\"},{\"id\":17,\"code\":\"community\",\"name\":\"社区发展\",\"enable\":true,\"updatedDate\":1530837977000,\"updatedBy\":\"000002\"},{\"id\":24,\"code\":\"deleteBtnRight\",\"name\":\"市场拓展项目删除\",\"enable\":true,\"updatedDate\":1530788141000,\"updatedBy\":\"000002\"},{\"id\":70,\"code\":\"due_paid_audit\",\"name\":\"MR-应收费用处理-审核\",\"description\":\"媒体资源-应收费用处理-审核\",\"enable\":true,\"updatedDate\":1554707776000,\"updatedBy\":\"100003\"},{\"id\":62,\"code\":\"employee_edit\",\"name\":\"MR-员工档案-修改\",\"description\":\"媒体资源排期-员工档案-修改\",\"enable\":true,\"updatedDate\":1554467034000,\"updatedBy\":\"100003\"},{\"id\":65,\"code\":\"employee_exprot\",\"name\":\"MR-员工档案-导出\",\"description\":\"媒体资源排期-员工档案-导出\",\"enable\":true,\"updatedDate\":1554468563000,\"updatedBy\":\"100003\"},{\"id\":2,\"code\":\"fenghuang_buoy_input\",\"name\":\"浮标数据录入权限\",\"description\":\"\",\"enable\":true,\"createdDate\":1505119012000,\"createdBy\":\"sys\",\"updatedDate\":1505119012000,\"updatedBy\":\"sys\"},{\"id\":21,\"code\":\"fenghuang_manager_input\",\"name\":\"管家服务数据新增\",\"enable\":true,\"createdDate\":1529651034000,\"createdBy\":\"4718\"},{\"id\":32,\"code\":\"investExcelImportAdmin\",\"name\":\"同心共享Excel数据导入\",\"description\":\"能操作同心共享的EXCEL数据导入\",\"enable\":true,\"updatedDate\":1544512225000,\"updatedBy\":\"4720\"},{\"id\":29,\"code\":\"investigationdetails\",\"name\":\"调查详情\",\"description\":\"调查详情\",\"enable\":true,\"updatedDate\":1531988462000,\"updatedBy\":\"4720\"},{\"id\":4,\"code\":\"marketing\",\"name\":\"市场拓展\",\"description\":\"\",\"enable\":true,\"createdDate\":1505697631000,\"createdBy\":\"sys\",\"updatedDate\":1505697631000,\"updatedBy\":\"sys\"},{\"id\":5,\"code\":\"marketing_manager\",\"name\":\"市场拓展\",\"enable\":true,\"updatedDate\":1536827352000,\"updatedBy\":\"008114\"},{\"id\":66,\"code\":\"order_creating\",\"name\":\"MR-订单管理-新建订单\",\"description\":\"媒体资源排期-订单管理-新建订单\",\"enable\":true,\"updatedDate\":1554467011000,\"updatedBy\":\"100003\"},{\"id\":57,\"code\":\"order_del\",\"name\":\"MR-订单管理-删除\",\"description\":\"媒体资源排期-订单管理-删除\",\"enable\":true,\"updatedDate\":1554469009000,\"updatedBy\":\"100003\"},{\"id\":59,\"code\":\"order_execute\",\"name\":\"MR-订单管理-订单执行\",\"description\":\"媒体资源排期-订单管理-订单执行\",\"enable\":true,\"updatedDate\":1554468582000,\"updatedBy\":\"100003\"},{\"id\":58,\"code\":\"order_import\",\"name\":\"MR-订单管理-导出\",\"description\":\"媒体资源排期-订单管理-导出\",\"enable\":true,\"updatedDate\":1554468927000,\"updatedBy\":\"100003\"},{\"id\":63,\"code\":\"order_lock\",\"name\":\"MR-订单管理-锁定\",\"description\":\"媒体资源排期-订单管理-锁定\",\"enable\":true,\"updatedDate\":1554468983000,\"updatedBy\":\"100003\"},{\"id\":64,\"code\":\"order_lock_cancel\",\"name\":\"MR-订单管理-取消锁定\",\"description\":\"媒体资源排期-订单管理-取消锁定\",\"enable\":true,\"updatedDate\":1554468967000,\"updatedBy\":\"100003\"},{\"id\":60,\"code\":\"order_termination\",\"name\":\"MR-订单管理-订单终止\",\"description\":\"媒体资源排期-订单管理-订单终止\",\"enable\":true,\"updatedDate\":1554466971000,\"updatedBy\":\"100003\"},{\"id\":20,\"code\":\"performance_quota_authority\",\"name\":\"绩效指标审核权限\",\"description\":\"绩效指标审核权限\",\"enable\":true,\"updatedDate\":1531275972000,\"updatedBy\":\"4719\"},{\"id\":89,\"code\":\"public_zation_edit\",\"name\":\"公共收益期初值编辑操作\",\"enable\":true,\"createdDate\":1637804527000,\"createdBy\":\"035194\"},{\"id\":71,\"code\":\"rd_manager_principalAdmin\",\"name\":\"项目进度片区管理员负责人\",\"description\":\"添加负责人\",\"enable\":true,\"updatedDate\":1580733336000,\"updatedBy\":\"007809\"},{\"id\":13,\"code\":\"resident_approve_expire\",\"name\":\"居民公司作前台废协议\",\"enable\":true,\"createdDate\":1512459060000,\"createdBy\":\"sys\",\"updatedDate\":1512459064000,\"updatedBy\":\"sys\"},{\"id\":12,\"code\":\"resident_approve_terminated\",\"name\":\"居民公司前台终止协议\",\"enable\":true,\"createdDate\":1512459060000,\"createdBy\":\"sys\",\"updatedDate\":1512459064000,\"updatedBy\":\"sys\"},{\"id\":6,\"code\":\"resident_modify_agreement\",\"name\":\"居民公司添加修改协议\",\"enable\":true,\"createdDate\":1510742293000,\"createdBy\":\"sys\",\"updatedDate\":1510742293000,\"updatedBy\":\"sys\"},{\"id\":7,\"code\":\"resident_modify_charge\",\"name\":\"居民公司修改收费\",\"enable\":true,\"createdDate\":1510742293000,\"createdBy\":\"sys\",\"updatedDate\":1510742293000,\"updatedBy\":\"sys\"},{\"id\":11,\"code\":\"resident_modify_quota\",\"name\":\"居民公司目标导入\",\"enable\":true,\"createdDate\":1512459060000,\"createdBy\":\"sys\",\"updatedDate\":1512459064000,\"updatedBy\":\"sys\"},{\"id\":39,\"code\":\"resource_add\",\"name\":\"MR-社区媒体基础信息-新增\",\"description\":\"媒体资源排期-社区媒体基础信息-新增\",\"enable\":true,\"updatedDate\":1554468688000,\"updatedBy\":\"100003\"},{\"id\":41,\"code\":\"resource_del\",\"name\":\"MR-媒体资源基础信息-删除\",\"description\":\"媒体资源排期-媒体资源基础信息-删除\",\"enable\":true,\"updatedDate\":1554469398000,\"updatedBy\":\"100003\"},{\"id\":45,\"code\":\"resource_disabled\",\"name\":\"MR-媒体资源基础信息-禁用\",\"description\":\"媒体资源排期-媒体资源基础信息-禁用\",\"enable\":true,\"updatedDate\":1554469259000,\"updatedBy\":\"100003\"},{\"id\":40,\"code\":\"resource_edit\",\"name\":\"MR-媒体资源基础信息-修改\",\"description\":\"媒体资源排期-媒体资源基础信息-修改\",\"enable\":true,\"updatedDate\":1554469241000,\"updatedBy\":\"100003\"},{\"id\":44,\"code\":\"resource_enabled\",\"name\":\"MR-媒体资源基础信息-启用\",\"description\":\"媒体资源排期-媒体资源基础信息-启用\",\"enable\":true,\"updatedDate\":1554469303000,\"updatedBy\":\"100003\"},{\"id\":43,\"code\":\"resource_export\",\"name\":\"MR-社区媒体基础信息-导出\",\"description\":\"媒体资源排期-社区媒体基础信息-导出\",\"enable\":true,\"updatedDate\":1554468800000,\"updatedBy\":\"100003\"},{\"id\":42,\"code\":\"resource_import\",\"name\":\"MR-媒体资源基础信息-导入\",\"description\":\"媒体资源排期-媒体资源基础信息-导入\",\"enable\":true,\"updatedDate\":1554469388000,\"updatedBy\":\"100003\"},{\"id\":18,\"code\":\"submission\",\"name\":\"公共资源意见征询\",\"enable\":true,\"updatedDate\":1570819438000,\"updatedBy\":\"007810\"},{\"id\":72,\"code\":\"submission_del\",\"name\":\"公共资源-删除权限\",\"description\":\"删除权限\",\"enable\":true,\"updatedDate\":1571096968000,\"updatedBy\":\"4719\"},{\"id\":81,\"code\":\"wcxInnovateDataMangeTab\",\"name\":\"微创新数据管理Tab\",\"description\":\"微创新管理-数据管理-微创新数据管理tab1\",\"enable\":true,\"updatedDate\":1599027799000,\"updatedBy\":\"000002\"},{\"id\":80,\"code\":\"wcxInnovateDataTab\",\"name\":\"数据管理-微创新创新数据tab\",\"enable\":true},{\"id\":35,\"code\":\"www\",\"name\":\"www\",\"description\":\"zz\",\"enable\":true,\"updatedDate\":1550818197000,\"updatedBy\":\"000002\"},{\"id\":85,\"code\":\"ck_isRemind\",\"name\":\"安防提醒功能\",\"enable\":true,\"createdDate\":1624611273000,\"createdBy\":\"035194\"},{\"id\":84,\"code\":\"ck_ksh_unlocking\",\"name\":\"可视化解锁操作\",\"enable\":true,\"createdDate\":1623891342000,\"createdBy\":\"035194\"},{\"id\":83,\"code\":\"public_benefit_add\",\"name\":\"公共收益添加编辑操作\",\"enable\":true,\"createdDate\":1623808525000,\"createdBy\":\"035194\"}]}");
        String userCode = (String) user.get("UserCode");
        AccessToken oldToken = accessTokenService.findByUserCode(userCode);
        if(oldToken!=null){
            Map<String,String> pa = new HashMap<String,String>();
            pa.put("token",oldToken.getAccessToken());
            RedisCacheUtils.removeCacheByKey(AccessTokenConstant.CACHEKEY,pa);
        }
        // 生成身份令牌
        String accessToken = genAccessToken(
                userCode,
                user.get("LoginCode").toString(),
                user.get("LoginCode").toString(),
                userCode
        );

        accessTokenService.insertOrUpdate(new HashMap<String, String>() {{
            put("userCode", userCode);
            put("accessToken", accessToken);
            put("salt", userCode);
        }});

        user.put("assessToken", accessToken);
        user.put("accessToken", accessToken);
        return user;
    }

    /**
     * 退出登录
     *
     * @return
     */
    public void logout() {
        try {
            Map<String, String> param = new HashMap<String, String>();
            param.put("token", accessToken.get().getAccessToken());
            RedisCacheUtils.removeCacheByKey(AccessTokenConstant.CACHEKEY, param);
            accessTokenService.updateAccessToken(new HashMap<String, String>() {{
                put("userCode", tbSysUser.get().getUserCode());
                put("accessToken", accessToken.get().getAccessToken());
            }});
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 查找登录用户
     *
     * @param loginCode
     * @param passWord
     * @return
     */
    public TbSysUser findByLogin(String loginCode, String passWord) {
        TbSysUser tbSysUser = tbSysUserMapper.findByLogin(genFindByLoginParam(loginCode, passWord));
        if (tbSysUser == null) {
//            throw new ServiceException("用户不存在，或账户、密码错误。");
        }
        return tbSysUser;
    }

    /**
     * 根据 pk 查找用户
     *
     * @param userCode
     * @return
     */
    public TbSysUser findByUserCode(String userCode) {
        TbSysUser tbSysUser = tbSysUserMapper.findByUserCode(userCode);
        if (tbSysUser == null) {
            System.out.println(userCode);
            throw new ServiceException("用户不存在，或账户、密码错误。");
        }
        return tbSysUser;
    }

    /**
     * 不区分
     * @param userCode
     * @return
     */
    public TbSysUser findByUserCodeNew(String userCode) {
        TbSysUser tbSysUser = tbSysUserMapper.findByUserCodeNew(userCode);
        if (tbSysUser == null) {
            System.out.println(userCode);
//            throw new ServiceException("用户不存在，或账户、密码错误。");
        }
        return tbSysUser;
    }


    /**
     * 校验身份令牌
     *
     * @param accessToken
     * @return
     */
    public boolean validateAccessToken(String accessToken) {
        if (accessToken == null || "null".equals(accessToken) || "".equals(accessToken)) {
            throw new AuthorizeException("缺少身份令牌");
        }

        AccessToken userAccessToken = accessTokenService.findByToken(accessToken);
        if (userAccessToken == null) {
            throw new AuthorizeException("无效的身份令牌");
        }

        TbSysUser tbSysUser = findByUserCode(userAccessToken.getUserCode());

        String sign = genAccessToken(
                userAccessToken.getUserCode(),
                tbSysUser.getLoginCode(),
                tbSysUser.getPassWord(),
                userAccessToken.getSalt()
        );

        if (!sign.equals(accessToken)) {
            throw new AuthorizeException("身份令牌校验失败");
        }

        // TODO 失效时间检查

        this.accessToken.set(userAccessToken);
        this.tbSysUser.set(tbSysUser);
        this.sysOrgan.set(tbSysOrganService.findByUserCode(userAccessToken.getUserCode()));

        return true;
    }

    /**
     * 获取当前用户 access token
     *
     * @return
     */
    public AccessToken getCurrentAccessToken() {
        return accessToken.get();
    }

    /**
     * 获取当前用户
     *
     * @return
     */
    public TbSysUser getCurrentSysUser() {
        return tbSysUser.get();
    }

    /**
     * 获取当前用户 sys organ
     *
     * @return
     */
    public TbSysOrgan getSysOrgan() {
        return sysOrgan.get();
    }

    /**
     * 为 url 后缀当前用户 accessToken
     *
     * @param url
     * @param basePath
     * @return
     */
    public String suffixAccesstoken(String url, String basePath) {
        if (url == null || "".equals(url)) {
            return "";
        }

        if (!url.contains("?")) {
            url += "?";
        }
        url += "&AccessToken=" + accessToken.get().getAccessToken();
        if (!url.substring(0, 7).equals("http://")) {
            url = basePath + url.trim();
        }
        return url;
    }

    /**
     * 为 url 后缀当前用户 accessToken
     *
     * @param url
     * @return
     */
    public String suffixAccesstoken(String url) {
        if (url == null || "".equals(url)) {
            return "";
        }

        if (!url.contains("?")) {
            url += "?";
        }
        url += "&AccessToken=" + accessToken.get().getAccessToken();
        return url;
    }

    /**
     * 组织登录参数
     *
     * @param loginCode
     * @param passWord
     * @return
     */
    private Map<String, Object> genFindByLoginParam(String loginCode, String passWord) {
        Map<String, Object> param = new HashMap<>();
        param.put("loginCode", loginCode);
        param.put("passWord", passWord);
        return param;
    }

    /**
     * 生成盐值
     *
     * @return
     */
    private String genSalt() {
        return UUID.randomUUID().toString().replace("-", "").substring(0, 16).toUpperCase();
    }

    /**
     * 生成身份令牌 accessToken
     *
     * @param userCode
     * @param loginCode
     * @param password
     * @param salt
     * @return
     */
    private String genAccessToken(String userCode, String loginCode, String password, String salt) {
        String accessToken = "" + userCode + loginCode + password + salt;
        String hashAccessToken = MD5.GetMD5Code(accessToken).toUpperCase();
        return hashAccessToken;
    }

    @Override
    public List<TbSysDepartment> listDepartments(){
        return tbSysDepartmentMapper.findAll();
    }

    @Override
    public PageData findByDepartmentOrKey(String depCode, String searchKey,int page,int size){
        PageRowBounds pageRowBounds = new PageRowBounds(page,size);
        List<TbSysUser> result= tbSysUserMapper.findByDepartmentOrKey(depCode,searchKey,pageRowBounds);
        return new PageData(result,pageRowBounds);
    }

    public List<TbSysUser> findByUserCodes(List<String> userCodes){
        if(userCodes == null || userCodes.size()==0){
            return new ArrayList<TbSysUser>();
        }
        String join = StringUtils.join(userCodes, ",");
        return tbSysUserMapper.findByUserCodes(join);
    }

    @Override
    public List<String> findByUserCodesOfEnable(List<String> userCodes) {
        if (userCodes == null || userCodes.size() <= 0) {
            return new ArrayList<String>();
        }
        String join = StringUtils.join(userCodes, ",");
        List<String> userCodesOfDisable = tbSysUserMapper.findByUserCodesOfEnable(join);
        return userCodesOfDisable;
    }

    @Override
    public List<TbSysUser> searchUser(String userName,List<String> userCodes,int pageCurrent,int pageSize){
        return tbSysUserMapper.searchUser(userName,userCodes,pageCurrent,pageSize);
    }

    @Override
    public Long countSearchUser(String userName, List<String> userCodes) {
        return tbSysUserMapper.countSearchUser(userName,userCodes);
    }

    @Override
    public Result queryByUid(String search) {
        List<TbSysUser> tbSysUsersList=tbSysUserMapper.tbSysUsersList(search);
        List<String> result=new LinkedList<>();
        for (TbSysUser psndoc : tbSysUsersList) {
            result.add(psndoc.getUserCode()+" - "+psndoc.getLoginCode()+" - "+psndoc.getUserName());
        }
        return Response.response(result);
    }
}
