huangzqa 4 years ago
parent
commit
f25fae50dd

+ 193 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/controller/ApiController.java

@@ -0,0 +1,193 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.api.controller;
+
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.entity.ManufacturerInfo;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
+import com.dragoninfo.dcuc.app.facade.IManufacturerInfoFacade;
+import com.dragoninfo.dcuc.user.user.entity.PostInfo;
+import com.dragoninfo.dcuc.user.user.entity.UserInfo;
+import com.dragoninfo.dcuc.user.user.enumresources.UserTypeEnum;
+import com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum;
+import com.dragoninfo.dcuc.user.user.facade.IAccountFacade;
+import com.dragoninfo.dcuc.user.user.facade.IPostInfoFacade;
+import com.dragoninfo.dcuc.user.user.facade.IUserFacade;
+import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
+import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.commons.util.ObjectUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.lang.reflect.Field;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Administrator
+ * @date 2018/6/25
+ */
+@Controller
+@RequestMapping(value = "/api/")
+public class ApiController {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private static final String SERIAL_VERSION_UID = "serialVersionUID";
+    private static final String ALIAS = "ALIAS";
+
+    @Autowired
+    private IUserFacade userFacade;
+
+    @Autowired
+    private IAccountFacade accountFacade;
+
+
+    @Autowired
+    private IManufacturerInfoFacade manufacturerInfoFacade;
+
+    @Autowired
+    private IApplyInfoFacade applyInfoFacade;
+
+    @Autowired
+    private IUserInfoFacade userInfoFacade;
+
+    @Autowired
+    private IPostInfoFacade postInfoFacade;
+
+
+
+
+    /**
+     * 查询用户
+     * DcucLoginService 调用
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "users/id/{id}", method = RequestMethod.GET)
+    @ResponseBody
+    public Map userbyid(@PathVariable("id") String id) {
+        UserInfo userInfo = userFacade.detailById(id);
+        if (userInfo == null) {
+            return null;
+        }
+        if (StringUtils.isBlank(userInfo.getId())) {
+            return new HashMap();
+        }
+        String pSortNo = "0";
+        if (StringUtils.equals(userInfo.getUserType(), "10")) {
+            pSortNo = this.getPSortNo(userInfo.getId());
+        }
+        userInfo.setPSortNo(pSortNo);
+        UserInfo user = userInfoFacade.userDetail(userInfo.getId());
+        if (StringUtils.isNotEmpty(userInfo.getOrgId()) &&
+                (UserTypeEnum.POLICE.getValue().equals(user.getUserType()) || userInfoFacade.getRootUser().equals(userInfo.getName()))) {
+            SearchDTO searchDTO = new SearchDTO();
+            Searchable searchable = Searchable.toSearchable(searchDTO);
+            searchable.addSearchFilter("org_id", SearchOperator.eq, userInfo.getOrgId());
+            searchDTO = searchable.toSearchDTO();
+            searchDTO.setPage("1");
+            searchDTO.setSize("2");
+            Page<ApplyInfo> appPage = applyInfoFacade.applyInfoPage(searchDTO);
+            userInfo.setCompany(CollectionUtils.isNotEmpty(appPage.getContent()) ? appPage.getContent().get(0).getManufacturerId() : "");
+            ManufacturerInfo manufacturerInfo = manufacturerInfoFacade.manufacturerInfoDetail(userInfo.getCompany());
+            userInfo.setCompanyCode(manufacturerInfo != null ? manufacturerInfo.getCode() : "");
+        }
+        Map map = resultMap(userInfo, user);
+        return map;
+    }
+
+
+    /**
+     * 校验登录
+     * DcucLoginService.class 调用
+     * @param account
+     * @param password
+     * @return
+     */
+    @RequestMapping(value = "/checklogin", method = RequestMethod.POST)
+    @ResponseBody
+    public ResponseDTO checklogin(String account, String password) {
+        return accountFacade.checkLogin(account, password);
+    }
+
+
+    private String getPSortNo(String userId) {
+        //获取t_post_info中的sortNo
+        if (StringUtils.isEmpty(userId)){
+            return "";
+        }
+        List<PostInfo> postInfos = postInfoFacade.postInfos(userId);
+        if (postInfos != null && postInfos.size() > 0) {
+            return postInfos.get(0).getSortNo().toString();
+        } else {
+            return "";
+        }
+    }
+
+
+    private Map<String, Object> resultMap(UserInfo userInfo, UserInfo user) {
+        Map<String, Object> map = this.beanToMapGD(userInfo);
+        if (isParentOrg(userInfo, user)) {
+            map.put("isParentOrg", YesNotEnum.YES.getValue());
+        } else if (isParentOrg(userInfo, user) && !UserTypeEnum.POLICE.getValue().equals(userInfo.getUserType())) {
+            map.put("isParentOrg", null);
+        } else {
+            map.put("isParentOrg", YesNotEnum.NO.getValue());
+        }
+        if (!ObjectUtils.isNullOrEmptyString(map.get("birth"))) {
+            String birth = userInfo.getBirth();
+            map.put("birth", birth);
+        }
+        if (!ObjectUtils.isNullOrEmptyString(map.get("createTime"))) {
+            DateFormat bf = new SimpleDateFormat("yyyyMMdd");
+            Date createTime = userInfo.getCreateTime();
+            map.put("createTime", bf.format(createTime));
+        }
+        return map;
+    }
+
+    private boolean isParentOrg(UserInfo userInfo, UserInfo user) {
+        return StringUtils.isNotEmpty(userInfo.getOrgId()) && userInfo.getOrgId().equals(user.getOrgId());
+    }
+
+
+
+    /**
+     * api返回值为null时不转为""
+     * @param obj
+     * @param <T>
+     * @return
+     */
+    public  <T> Map<String,Object> beanToMapGD(T obj){
+        Map<String, Object> map = new HashMap<String, Object>();
+        try {
+            Class<?> clazz = obj.getClass();
+            for (Field field : clazz.getDeclaredFields()) {
+                field.setAccessible(true);
+                String fieldName = field.getName();
+                Object value = field.get(obj);
+                if (!SERIAL_VERSION_UID.equals(fieldName) && !fieldName.startsWith(ALIAS) && !fieldName.endsWith(ALIAS)){
+                    map.put(fieldName, (value != null) ? String.valueOf(value) : null);
+                }
+            }
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        }
+        return map;
+    }
+}

+ 231 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/GovernmentInfoController.java

@@ -0,0 +1,231 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org;
+
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.GovOrgVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.SortVo;
+import com.dragoninfo.dcuc.org.entity.GovInfo;
+import com.dragoninfo.dcuc.org.facade.IGovInfoFacade;
+import com.dragoninfo.dcuc.user.entity.GovUserInfo;
+import com.dragoninfo.dcuc.user.facade.IGovUserInfoFacade;
+import com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum;
+import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
+import com.dragoninfo.duceap.core.enums.ResultEnum;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.base.entity.security.SecurityUser;
+import com.dragonsoft.duceap.commons.util.bean.BeanUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import com.dragonsoft.duceap.core.context.ContextUtils;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 勿删权限政务机构列表
+ * Created by Administrator on 2020/6/30.
+ */
+@Api(tags = {"政务机构管理接口"})
+@RestController
+@RequestMapping(value = "/orgsvr/")
+public class GovernmentInfoController {
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private IGovInfoFacade iGovInfoFacade;
+    @Autowired
+    private IUserInfoFacade iUserInfoFacade;
+    @Autowired
+    private IGovUserInfoFacade iGovUserInfoFacade;
+
+    @ApiOperation(value="政务机构新增")
+    @PostMapping("govOrg")
+    public Result save(@RequestBody GovOrgVo vo){
+        try{
+            GovInfo government = new GovInfo();
+            BeanUtils.copyProperties(government,vo);
+            if(StringUtils.isBlank(government.getUpGovId())){
+                government.setIsRoot("0");
+            }else{
+                government.setIsRoot("1");
+            }
+            SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
+            if (iGovInfoFacade.checkCode("", government.getCode()))
+                return Result.fail(ResultEnum.FAIL.getKey(), "政务机构代码已存在");
+            if (iGovInfoFacade.checkName("", government.getFullName(), ""))
+                return Result.fail(ResultEnum.FAIL.getKey(), "政务机构名称已存在");
+            if (!iUserInfoFacade.getRootUser().equals(user.getUserName()) && StringUtils.isEmpty(government.getUpGovId()))
+                return Result.fail(ResultEnum.FAIL.getKey(), "请选择机构后再新增!");
+            iGovInfoFacade.addGov(government);
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"新增异常");
+        }
+        return Result.success();
+    }
+
+    @ApiOperation(value="政务机构修改")
+    @PutMapping("govOrg/{id}")
+    public Result update(@RequestBody GovOrgVo vo){
+        try{
+            GovInfo government = new GovInfo();
+            BeanUtils.copyProperties(government,vo);
+            government = setUpdateProperties(government);
+            iGovInfoFacade.updateGov(government);
+        }catch(Exception e){
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"修改异常");
+        }
+        return Result.success();
+    }
+
+    @ApiOperation(value = "删除政务机构")
+    @DeleteMapping("govOrg/{id}")
+    public Result delete(@PathVariable("id") String id){
+        Searchable searchable = Searchable.newSearchable();
+        searchable.addSearchFilter("gov_id", SearchOperator.eq,id);
+        searchable.addSearchFilter("deleted",SearchOperator.eq, YesNotEnum.NO.getValue());
+        SearchDTO searchDTO = searchable.toSearchDTO();
+        Page<GovUserInfo> page = iGovUserInfoFacade.govUserInfoPage(searchDTO);
+        if (page.getContent().size() > 0)
+            return Result.fail("该机构有人员存在,不可删除");
+        iGovInfoFacade.deleteOrg(id);
+        return Result.success();
+    }
+
+    @ApiOperation(value="获取政务机构")
+    @GetMapping(value = "govOrg/{id}")
+    public Result get(@PathVariable("id") String id){
+        GovInfo government = new GovInfo();
+        government = iGovInfoFacade.getGovInfoById(id);
+        GovOrgVo vo = new GovOrgVo();
+        try {
+            BeanUtils.copyProperties(vo,government);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+            return Result.fail("属性复制异常");
+        }
+        return Result.success(vo);
+    }
+
+
+    @ApiOperation(value="政务机构树")
+    @ApiImplicitParam(name = "id",value = "id")
+    @PostMapping(value = "govOrg/tree/full")
+    public Result fullGovTree(@RequestBody Map params) {
+        String id = (String) params.get("id");
+        if (StringUtils.isEmpty(id)){
+            //根节点
+            GovInfo root = iGovInfoFacade.getRootGov();
+            List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
+            resultList.add(treeMapFilter(root,null,""));
+            return Result.success(resultList);
+        }
+        return  Result.success(getChildTreeNode(id, YesNotEnum.NO.getValue()));
+    }
+
+    @ApiOperation(value = "政务机构拖动排序")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "startId", value = "需要拖动的机构", required = true),
+            @ApiImplicitParam(name = "endId", value = "拖动到目标机构", required = true),
+            @ApiImplicitParam(name = "moveType", value = "prev:目标机构前,next: 目标机构后", required = true)
+    })
+    @PostMapping(value = "govOrg/sort")
+    public Result reSort(@RequestBody SortVo sortVo){
+        try{
+            iGovInfoFacade.reSort(sortVo.getStartId(), sortVo.getEndId(), sortVo.getMoveType());
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"排序异常");
+        }
+
+        return Result.success();
+    }
+
+    @ApiOperation(value = "政务机构树匹配查询")
+    @ApiImplicitParams({@ApiImplicitParam(name = "name", value = "机构名称", required = true),
+            @ApiImplicitParam(name = "pageNum", value = "条数", required = true),
+            @ApiImplicitParam(name = "pageSize", value = "页数", required = true)
+    })
+    @PostMapping(value = "govOrg/tree/match")
+    public Result govMatch( @RequestBody Map map){
+        String name =map.get("name").toString();
+        Integer pageNum =Integer.valueOf(map.get("pageNum").toString());
+        Integer pageSize =Integer.valueOf(map.get("pageSize").toString());
+        return Result.success(iGovInfoFacade.govMatch(name,pageNum,pageSize).getResult());
+    }
+
+    private GovInfo setUpdateProperties(GovInfo government){
+        GovInfo oldGov = new GovInfo();
+        if(StringUtils.isNotBlank(government.getId())){
+            oldGov = iGovInfoFacade.getGovInfoById(government.getId());
+        }
+        oldGov.setId(government.getId());
+        oldGov.setCode(government.getCode());
+        oldGov.setShortName(government.getShortName());
+        oldGov.setFullName(government.getFullName());
+        oldGov.setUpGovName(government.getUpGovName());
+        oldGov.setUpGovId(government.getUpGovId());
+        return oldGov;
+    }
+
+    /**
+     * 组装树节点
+     *
+     * @param government
+     * @param orgNums
+     * @param state   节点勾选状态
+     * @return
+     */
+    private Map<String, Object> treeMapFilter(GovInfo government, Map<String, Long> orgNums, String state) {
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("id", government.getId());
+        map.put("code", government.getCode());
+        map.put("name", StringEscapeUtils.unescapeHtml4(government.getFullName()));
+        map.put("pid", government.getUpGovId());
+        map.put("isParent", true);
+        if (null == orgNums){
+            map.put("isParent", true);
+            return map;
+        }
+        if ("0".equals(state) || null == orgNums.get(government.getId()) || 0 == orgNums.get(government.getId())) {
+            map.put("isParent", false);
+        } else {
+            map.put("isParent", true);
+        }
+        return map;
+    }
+
+
+    /**
+     * 异步获取子节点
+     *
+     * @param parentId
+     * @param state    机构状态:0:未删除,1:已删除,null:全部
+     * @return
+     */
+    public List<Map<String, Object>> getChildTreeNode(String parentId, String state) {
+        List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
+        //子级机构
+        List<GovInfo> childList = iGovInfoFacade.findChildGovList(parentId);
+        //子级和自身的子级个数
+        Map<String, Long> orgNums = iGovInfoFacade.countGovByUpGovId(parentId);
+        for (GovInfo government : childList) {
+            Map<String, Object> map = treeMapFilter(government, orgNums, null);
+            resultList.add(map);
+        }
+        return resultList;
+    }
+}

+ 816 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/OrgInfoController.java

@@ -0,0 +1,816 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org;
+
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
+import com.dragoninfo.dcuc.authweb.common.MtAuthService;
+import com.dragoninfo.dcuc.authweb.common.SysConstants;
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.MergersVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.OrgRangeVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.OrgVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.SortVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.statisics.vo.OrgTreeNodeVo;
+
+import com.dragoninfo.dcuc.authweb.util.UserUtils;
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
+import com.dragoninfo.dcuc.org.entity.OrgInfo;
+import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
+
+import com.dragoninfo.dcuc.org.vo.OrgTreeNode;
+import com.dragoninfo.dcuc.user.admin.entity.OrgMtAuth;
+import com.dragoninfo.dcuc.user.admin.facade.*;
+import com.dragoninfo.dcuc.user.admin.vo.NoticeUserVO;
+import com.dragoninfo.dcuc.user.user.entity.UserInfo;
+import com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum;
+import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
+import com.dragoninfo.duceap.commons.util.server.OrgInfoUtil;
+import com.dragoninfo.duceap.core.enums.ResultEnum;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.base.entity.security.SecurityUser;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import com.dragonsoft.duceap.commons.util.tree.SimpleTreeNodeItemResolver;
+import com.dragonsoft.duceap.commons.util.tree.TreeNodeUtils;
+import com.dragonsoft.duceap.core.context.ContextUtils;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
+import com.dragonsoft.duceap.web.utils.SessionUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+/**
+ * 勿删权限机构列表
+ */
+
+
+@Api(tags = {"机构管理接口"})
+@RestController
+@RequestMapping(value = "/orgsvr/"+ VersionUtils.VERSION_UID+"/")
+public class OrgInfoController {
+    @Autowired
+    private IOrgInfoFacade iOrgInfoFacade;
+    @Autowired
+    private IOrgMtAuthFacade iOrgMtAuthFacade;
+    @Autowired
+    private IUserInfoFacade iUserInfoFacade;
+    @Autowired
+    private IManageInfoFacade iManageInfoFacade;
+    @Autowired
+    private IUserMtAuthFacade iUserMtAuthFacade;
+    @Autowired
+    private IAppMtAuthFacade iAppMtAuthFacade;
+    @Autowired
+    private IApplyInfoFacade applyInfoFacade;
+    @Autowired
+    private MtAuthService mtAuthService;
+    @Autowired
+    private IMgeMtAuthFacade iMgeMtAuthFacade;
+
+    Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    /**
+     * 当前用户的管理范围机构树
+     * @param params type:机构树类型 (ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围 ), id:异步加载的树节点
+     * @return
+     */
+    @ApiOperation(value = "机构树")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id"),
+            @ApiImplicitParam(name = "type", value = "type:机构树类型(ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围)")})
+    @PostMapping(value = "org/tree/catalog")
+    public Result orgMtTreeYB(@RequestBody Map params) {
+        String id = (String) params.get("id");
+        String type = (String) params.get("type");
+        //获取管理范围ids
+        SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
+        String mtAuthIds = mtAuthService.getMtAuth(curUser.getId(), type);
+        if (StringUtils.isEmpty(id)) {
+            //获取机构树根节点列表
+            List<Map<String, Object>> result = this.treeRootList(mtAuthIds);
+            return Result.success(result);
+        } else {
+            List<Map<String, Object>> result = this.getChildTreeNode(id, YesNotEnum.NO.getValue(), mtAuthIds);
+            return Result.success(result);
+        }
+    }
+
+    /**
+     * 获取单个树节点机构信息
+     */
+    @ApiOperation(value = "单个树节点信息")
+    @ApiImplicitParam(name = "id", value = "id")
+    @GetMapping(value = "org/tree/node/{id}")
+    public Result<OrgTreeNodeVo> orgTreeNode(@PathVariable("id")String id) {
+        OrgTreeNode orgTreeNode = iOrgInfoFacade.getOrgTreeNode(id);
+        OrgTreeNodeVo vo = new OrgTreeNodeVo();
+        BeanUtils.copyProperties(orgTreeNode,vo);
+        vo.setName(orgTreeNode.getLabel());
+        return Result.success(vo);
+    }
+
+
+    /**
+     * 管理员管理—管理范围—分配树
+     * @return
+     */
+    @ApiOperation(value = "管理员管理—管理范围—分配树")
+    @PostMapping(value = "org/tree/admin")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id"),
+            @ApiImplicitParam(name = "userId", value = "用户ID", required = true),
+            @ApiImplicitParam(name = "mtType", value = "type:机构树类型(ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围)", required = true)
+    })
+    public Result orgMtTreeWithChecked(@RequestBody OrgRangeVo orgRangeVo) {
+        String id = orgRangeVo.getId();
+        String mtType = orgRangeVo.getMtType();
+        String userId = orgRangeVo.getUserId();
+        //获取管理范围ids
+        SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
+        String mtAuthIds = mtAuthService.getMtAuth(curUser.getId(),mtType);
+        //当临时表没有数据时候,获取登录人的权限范围
+        if (StringUtils.isEmpty(mtAuthIds)&&SysConstants.MT_TEMP.equals(orgRangeVo.getMtType())){
+            mtAuthIds=iAppMtAuthFacade.mgeAppRightRangeStr(ContextUtils.getUserInfo().getId());
+        }
+        if (StringUtils.isEmpty(id)) {
+            //获取机构树根节点列表
+            List<Map<String, Object>> treeList = this.treeRootList(mtAuthIds);
+            return Result.success(checkTreeNode(treeList, mtType, userId));
+        } else {
+            List<Map<String, Object>> treeList = this.getChildTreeNode(id, YesNotEnum.NO.getValue(), mtAuthIds);
+            return Result.success(checkTreeNode(treeList, mtType, userId));
+        }
+    }
+
+    /**
+     * 、机构新增
+     * @return
+     */
+    @ApiOperation(value = "机构新增")
+    @PostMapping(value = "org")
+    public Result save(@RequestBody OrgVo vo) {
+        try {
+            OrgInfo orgInfo = new OrgInfo();
+            UserUtils.copyObject(orgInfo, vo);
+            SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
+            orgInfo = this.upSetOrg(orgInfo);
+            if (iOrgInfoFacade.checkCode("", orgInfo.getCode()) != null)
+                return Result.fail(ResultEnum.FAIL.getKey(), "机构代码已存在");
+            if (iOrgInfoFacade.checkName("", orgInfo.getFullName(), "") != null)
+                return Result.fail(ResultEnum.FAIL.getKey(), "机构名称已存在");
+
+            if (!iUserInfoFacade.getRootUser().equals(user.getUserName()) && StringUtils.isEmpty(orgInfo.getUpGovId()))
+                return Result.fail(ResultEnum.FAIL.getKey(), "请选择机构后再新增!");
+            //保存机构在这
+            orgInfo = iOrgInfoFacade.addOrg(orgInfo);
+            // TODO: 2019/1/30
+            //维护子表
+            if (!iUserInfoFacade.getRootUser().equals(user.getName())) {
+                OrgMtAuth orgMtAuth = iOrgMtAuthFacade.getOrgMtAuthById(user.getId()).get(0);
+                String orgMtIds = orgMtAuth.getOrgId();
+                if (orgMtIds != null && orgMtIds.indexOf(orgInfo.getUpGovId() + ":0") >= 0) {
+                    //原机构范围只勾选了父节点,需添加新增的机构节点,修改父节点记录为勾选部分子节点
+                    orgMtIds = orgMtIds.replace(orgInfo.getUpGovId() + ":0", orgInfo.getUpGovId() + ":1," + orgInfo.getId() + ":-1");
+                } else if (orgMtIds != null && orgMtIds.indexOf(orgInfo.getUpGovId() + ":1") >= 0) {
+                    //原父节点记录为勾选部分子节点,需添加新增的机构节点
+                    orgMtIds = orgMtIds.replace(orgInfo.getUpGovId() + ":1", orgInfo.getUpGovId() + ":1," + orgInfo.getId() + ":-1");
+                }
+                if (!orgMtAuth.getOrgId().equals(orgMtIds)) {
+                    orgMtAuth.setOrgId(orgMtIds);
+                    iOrgMtAuthFacade.save(orgMtIds, user.getId());
+                }
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "新增异常");
+        }
+        return Result.success();
+    }
+
+
+    @ApiOperation(value = "机构修改")
+    @PutMapping(value = "org/{id}")
+    public Result update(@RequestBody OrgVo vo) {
+        try {
+            if (iOrgInfoFacade.checkCode(vo.getId(), vo.getCode()) != null)
+                return Result.fail(ResultEnum.FAIL.getKey(), "机构代码已存在");
+            if (iOrgInfoFacade.checkName(vo.getId(), vo.getFullName(), "") != null)
+                return Result.fail(ResultEnum.FAIL.getKey(), "机构名称已存在");
+            OrgInfo orgInfo = iOrgInfoFacade.detail(vo.getId());
+            Date date = orgInfo.getOrgEndDate();
+            UserUtils.copyObject(orgInfo, vo);
+            orgInfo.setOrgStartDate(date);
+            iOrgInfoFacade.updateOrg(orgInfo);
+        } catch (Exception e) {
+            logger.error("修改失败", e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "保存失败");
+        }
+        return Result.success();
+    }
+
+    /**
+     * 设置org更新值
+     * @param orgInfo
+     */
+
+    private OrgInfo upSetOrg(OrgInfo orgInfo) {
+        OrgInfo oldOrg = new OrgInfo();
+        if (StringUtils.isNotEmpty(orgInfo.getId())) {
+            oldOrg = iOrgInfoFacade.detail(orgInfo.getId());
+        } else {
+            oldOrg.setOrgStartDate(new Date());
+        }
+        oldOrg.setUpGovId(orgInfo.getUpGovId());
+        oldOrg.setOrgKind(orgInfo.getOrgKind());
+        oldOrg.setFullName(orgInfo.getFullName());
+        oldOrg.setShortName(orgInfo.getShortName());
+        oldOrg.setAreaCode(orgInfo.getAreaCode());
+        oldOrg.setBizType(orgInfo.getBizType());
+        oldOrg.setCode(orgInfo.getCode());
+        oldOrg.setOrgType(orgInfo.getOrgType());
+        oldOrg.setUnitClass(orgInfo.getUnitClass());
+        oldOrg.setOrgLevel(orgInfo.getOrgLevel());
+        oldOrg.setEmail(orgInfo.getEmail());
+        oldOrg.setLinkMan(orgInfo.getLinkMan());
+        oldOrg.setTel(orgInfo.getTel());
+        oldOrg.setOrgRank(orgInfo.getOrgRank());
+        return oldOrg;
+    }
+
+    /**
+     * 机构删除
+     * @return
+     */
+    @ApiOperation(value = "机构删除")
+    @ApiImplicitParam(name = "id", value = "id")
+    @DeleteMapping(value = "org/{id}")
+    public Result deleteOrg(@PathVariable("id") String id) {
+        logger.info(id);
+        Searchable searchable = Searchable.newSearchable();
+        searchable.addSearchFilter("orgId", SearchOperator.eq, id);
+        searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
+        SearchDTO searchDTO = searchable.toSearchDTO();
+        Page<UserInfo> page = iUserInfoFacade.userList(searchDTO);
+        if (page.getContent().size() > 0)
+            return Result.fail(ResultEnum.FAIL.getKey(), "该机构有人员存在,不可删除");
+        Page<ApplyInfo> appPage = applyInfoFacade.applyInfoPage(searchDTO);
+        if (appPage.getContent().size() > 0)
+            return Result.fail(ResultEnum.FAIL.getKey(), "该机构有应用存在,不可删除");
+//        searchable = Searchable.newSearchable();
+//        searchable.addSearchFilter("orgId", SearchOperator.eq, id);
+//        searchDTO = searchable.toSearchDTO();
+//        List<TenantOrg> tenantOrgs = tenementFacade.checkOrg(searchDTO);
+//        if (tenantOrgs != null && tenantOrgs.size() > 0)
+//            return ResponseStatus.fail("该机构有租户存在,不可删除");
+        try {
+            iOrgInfoFacade.deleteOrg(id);
+        } catch (Exception e) {
+            logger.error("删除失败", e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "删除失败");
+        }
+        return Result.success();
+    }
+
+
+    @ApiOperation(value = "机构调动")
+    @ApiImplicitParams({@ApiImplicitParam(name = "orgId", value = "机构id", required = true),
+            @ApiImplicitParam(name = "upGovId", value = "上级机构Id", required = true),})
+    @PostMapping(value = "org/transfer")
+    public Result orgInfoMove(@RequestBody MergersVo mergersVo) {
+        String orgId = mergersVo.getOrgId();
+        String upGovId = mergersVo.getUpGovId();
+        if (orgId.equals(upGovId)) {
+            return Result.fail(ResultEnum.FAIL.getKey(), "不能选择自身");
+        }
+        OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+        if (orgInfo.getUpGovId().equals(upGovId)) {
+            return Result.fail(ResultEnum.FAIL.getKey(), "不能选择同一个上级机构");
+        }
+        try {
+            iOrgInfoFacade.moveOrg(orgId, upGovId);
+        } catch (Exception e) {
+            logger.error("调动失败", e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "调动失败");
+        }
+        return Result.success();
+    }
+
+    /**
+     * 机构合并
+     * @param mergersVo
+     * @return
+     */
+    @ApiOperation(value = "机构合并")
+    @ApiImplicitParams({@ApiImplicitParam(name = "orgId", value = "合并机构id", required = true),
+            @ApiImplicitParam(name = "targetId", value = "目标机构Id", required = true),})
+    @PostMapping(value = "org/mergers")
+    public Result orgInfoMerfe(@RequestBody MergersVo mergersVo) {
+        String orgId = mergersVo.getOrgId();
+        String targetId = mergersVo.getTargetId();
+        if (orgId.equals(targetId))
+            return Result.fail(ResultEnum.FAIL.getKey(), "不能选择自身");
+        ResponseStatus result = iOrgInfoFacade.orgInfoMerge(orgId, targetId);
+        if (result.getStatusCode().equals("200")) {
+            OrgInfo orgInfo = iOrgInfoFacade.detail(targetId);
+            iUserInfoFacade.updateByOrgId(orgId, targetId, orgInfo.getFullName());
+            List<NoticeUserVO> list = iManageInfoFacade.getManagerByOrgId(orgId);
+            for (NoticeUserVO note : list) {
+                if (!StringUtils.isEmpty(note.getUserId())) {
+                    iAppMtAuthFacade.save("", note.getUserId());
+                    iUserMtAuthFacade.save("", note.getUserId());
+                    iOrgMtAuthFacade.save("", note.getUserId());
+                    iManageInfoFacade.deleteAdmin(note.getUserId());
+                }
+            }
+        }
+        return Result.success();
+    }
+
+    @ApiOperation(value = "机构拖动排序")
+    @ApiImplicitParams({@ApiImplicitParam(name = "startId", value = "需要拖动的机构", required = true),
+            @ApiImplicitParam(name = "endId", value = "拖动到目标机构", required = true),
+            @ApiImplicitParam(name = "moveType", value = "prev:目标机构前,next: 目标机构后", required = true)})
+    @PostMapping(value = "org/sort")
+    public Result reSort(@RequestBody SortVo sortVo) {
+
+        try {
+            iOrgInfoFacade.reSort(sortVo.getStartId(), sortVo.getEndId(), sortVo.getMoveType());
+        } catch (Exception e) {
+            logger.error("排序失败", e);
+        }
+        return Result.success();
+    }
+
+
+    /**
+     * 机构详情
+     * @param orgId
+     * @return
+     */
+    @GetMapping(value = "org/{id}")
+    @ApiOperation(value = "获取单个机构")
+    @ApiImplicitParam(name = "id", value = "id", required = true)
+    public Result<OrgVo> orgInfoDetail(@PathVariable(value = "id") String orgId) {
+        OrgInfo detail = iOrgInfoFacade.detail(orgId);
+        OrgVo org = new OrgVo();
+        UserUtils.copyObject(org, detail);
+        List<NoticeUserVO> managerList = this.getAdmins(orgId);
+        org.setAdmins(managerList);
+        return Result.success(org);
+    }
+
+    /**
+     * orginfo转map
+     * @param orgInfosList
+     * @param orgNums
+     * @return
+     */
+    private List<Map<String, Object>> orgToTreeNode(List<OrgInfo> orgInfosList, Map<String, Long> orgNums) {
+        //子级和自身的子级个数
+        List<Map<String, Object>> mapList = new ArrayList<>();
+        for (OrgInfo orgInfo : orgInfosList) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("id", orgInfo.getId());
+            map.put("code", orgInfo.getCode());
+            map.put("name", orgInfo.getFullName());
+            map.put("pid", orgInfo.getUpGovId());
+            map.put("path", orgInfo.getPath());
+            if (orgNums.containsKey(orgInfo.getId()) && orgNums.get(orgInfo.getId()) > 0) {
+                map.put("isParent", true);
+            } else {
+                map.put("isParent", false);
+            }
+            mapList.add(map);
+        }
+        return mapList;
+    }
+//    @PostMapping(value = "org/tree/auth")
+//    @ApiOperation(value = "授权管理—机构配额详情、人员授权详情机构树")
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name="id",value="id"),
+//            @ApiImplicitParam(name="orgId",value="应用所属机构Id",required = true)
+//    })
+//    public Result<List<Map<String, Object>>> appMtTreeYB(@RequestBody Map<String,String> map) {
+//        String orgId=map.get("orgId");
+//        String id= map.get("id");
+//        if (StringUtils.isEmpty(id)) {
+//            String ids = getInitAuthTreeIds(orgId);
+//            return Result.success(getInitMtTree(ids));
+//        } else {
+//            return  Result.success(getChildTreeNode(id, YesNotEnum.NO.getValue()));
+//        }
+//    }
+
+//    /**
+//     * 授权树的初始化
+//     * 管理范围与应用所属机构的最小集合
+//     *
+//     * @param appOrgId
+//     * @return
+//     */
+//    public String getInitAuthTreeIds(String appOrgId) {
+//        SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
+//        if (iUserInfoFacade.getRootUser().equals(curUser.getName())) {
+//            return appOrgId + ":2";
+//        }
+//        String mtIds = mtAuthService.getMtAuth(curUser.getId(), SysConstants.MT_APP);
+//        return iOrgInfoFacade.filterMtIdsWithOrgIdAndChild(appOrgId, mtIds);
+//    }
+
+
+//    /**
+//     * 机构配置-配额下发-计算
+//     * @param request
+//     * @param userId
+//     * @param orgId   应用所属机构id
+//     * @return
+//     */
+//    @PostMapping(value = "searchOrg")
+//    public ResponseDTO searchOrg(HttpServletRequest request,
+//                                 @RequestParam(value = "userId", required = false) String userId,
+//                                 @RequestParam(value = "orgId", required = false) String orgId) {
+//        SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
+//        String unitClass = request.getParameter("unitClass");
+//        String roleLevel = request.getParameter("roleLevel");
+//        return iOrgInfoFacade.searchOrgForQuota(user.getId(), orgId, unitClass, roleLevel);
+//    }
+
+
+//
+//    @ApiOperation(value = "批量导出机构树")
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name="type",value="type:机构树类型(ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围)",required = true)})
+//    @PostMapping(value = "orgMap")
+//    public Result orgMap(@RequestBody Map params) {
+//        BaseSecurityUser userInfo = SessionUtils.getUserInfo();
+//        String type = (String) params.get("type");
+//        String mtOrgIds = mtAuthService.getMtAuth(userInfo.getId(), type);
+//        Map<String, Object> result = iOrgInfoFacade.getUpgovIdMap(mtOrgIds);
+//        return Result.success(result);
+//    }
+//
+//    /**
+//     * 机构新增、编辑
+//     * @param orgId
+//     * @param model
+//     * @param type  1 跳转信息页,2 跳转新增页
+//     * @return
+//     */
+//    @PostMapping(value = "orgInfo")
+//    public String orgInfo(@RequestParam(value = "orgId", required = false) String orgId, Model model,
+//                          int type, String pageType) {
+//        SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
+//        if (null == orgId || "0".equals(orgId) || "".equals(orgId)) {
+//            UserInfo userInfo = iUserInfoFacade.userDetail(user.getId());
+//            orgId = userInfo.getOrgId();
+//        }
+//        String fcode = "";
+//        String scode = "";
+//        OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+//        if (StringUtils.isNotEmpty(pageType)) {
+//            model.addAttribute("pageType", pageType);
+//        }
+//        model.addAttribute("model", orgInfo);
+//        if (type == 1) {
+//            if (orgInfo != null) {
+//                fcode = orgInfo.getCode().substring(0, orgInfo.getCode().length() - 4);
+//                scode = orgInfo.getCode().substring(orgInfo.getCode().length() - 4, orgInfo.getCode().length());
+//            }
+//            model.addAttribute("fcode", fcode);
+//            model.addAttribute("scode", scode);
+//            List<NoticeUserVO> managerList = this.getAdmins(orgId);
+//            if (CollectionUtils.isNotEmpty(managerList)) {//找到管理员
+//                model.addAttribute("admins", managerList);
+//            }
+//            return "organization/orgInfo";
+//        } else
+//            return "organization/orgNew";
+//    }
+
+    private List<NoticeUserVO> getAdmins(String orgId) {
+        Map map = new HashMap();
+        List<NoticeUserVO> list = new ArrayList<NoticeUserVO>();
+        List<NoticeUserVO> targetList = iManageInfoFacade.getOrgMgeManager(orgId);
+        if (CollectionUtils.isEmpty(targetList)) {
+            OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+            if (StringUtils.isNotBlank(orgInfo.getUpGovId())) {
+                String upGovId = orgInfo.getUpGovId();
+                targetList = getAdmins(upGovId);
+            }
+        }
+        for (NoticeUserVO noticeUserVO : targetList) {
+            if (map.get(noticeUserVO.getUserId()) == null) {
+                map.put(noticeUserVO.getUserId(), noticeUserVO);
+                list.add(noticeUserVO);
+            }
+        }
+        return list;
+    }
+//
+//    private UserInfo getAdmin(List<NoticeUserVO> managerList) {
+//        UserInfo adminUser = userInfoFacade.userDetail(managerList.get(0).getUserId());
+//        adminUser.setMobileWork(managerList.get(0).getMobile());
+//        return adminUser;
+//    }
+
+//
+//    /**
+//     * 机构反馈-机构修改
+//     * @param orgId
+//     * @param model
+//     * @return
+//     */
+//    @PostMapping(value = "orgInfoEdit")
+//    public String orgInfoEdit(@RequestParam(value = "orgId", required = false) String orgId, Model model) {
+//        OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+//        String fcode = "";
+//        String scode = "";
+//        if (orgInfo != null) {
+//            fcode = orgInfo.getCode().substring(0, orgInfo.getCode().length() - 4);
+//            scode = orgInfo.getCode().substring(orgInfo.getCode().length() - 4, orgInfo.getCode().length());
+//        }
+//        model.addAttribute("fcode", fcode);
+//        model.addAttribute("scode", scode);
+//        model.addAttribute("model", orgInfo);
+//        return "organization/orgInfoEdit";
+//    }
+
+
+//    /**
+//     * 机构调动页面
+//     * @param orgId
+//     * @return
+//     */
+//    @PostMapping(value = "orgMove")
+//    public String orgMove(@RequestParam(value = "orgId", required = true) String orgId, Model model) {
+//        OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+//        model.addAttribute("model", orgInfo);
+//        return "organization/orgMove";
+//    }
+
+//    /**
+//     * 机构合并页面
+//     * @param orgId
+//     * @return
+//     */
+//    @PostMapping(value = "orgMerge")
+//    public String orgMerge(@RequestParam(value = "orgId", required = true) String orgId, Model model) {
+//       /* OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
+//        String sex = CodeResourceUtils.convert("DM_SEX", "2", "null", "CODE");
+//        logger.info(sex);
+//        model.addAttribute("model", orgInfo);
+//        return "organization/orgMerge";*/
+//        return null;
+//    }
+
+
+    /**
+     * 根据ids获取初始树根节点
+     * @param mtAuthIds:管理范围ids
+     * @return
+     */
+    public List<Map<String, Object>> treeRootList(String mtAuthIds) {
+        if (StringUtils.isBlank(mtAuthIds)) {
+            return new ArrayList<>();
+        }
+        StringBuffer orgIds = new StringBuffer();
+        for (String orgIdStr : mtAuthIds.split(",")) {
+            String[] orgIdStatus = orgIdStr.split(":");
+            orgIds.append(orgIdStatus[0] + ",");
+        }
+        List<OrgInfo> orgInfosList = iOrgInfoFacade.getOrgsByIds(orgIds.toString());
+        Map<String, Long> orgNums = iOrgInfoFacade.countOrgByIds(orgIds.toString());
+        List<Map<String, Object>> mapList = this.orgToTreeNode(orgInfosList, orgNums);
+        mapList = TreeNodeUtils.generateTree(mapList, new SimpleTreeNodeItemResolver("id", "pid"), 0);
+        for (Map<String, Object> map : mapList) {
+            map.remove("children");
+        }
+        return mapList;
+    }
+
+    /**
+     * 异步获取子节点
+     * @param parentId  父节点id
+     * @param state     机构状态:0:未删除,1:已删除,null:全部
+     * @param mtAuthIds 管理范围,为""或null时不过滤
+     * @return
+     */
+    public List<Map<String, Object>> getChildTreeNode(String parentId, String state, String mtAuthIds) {
+        //子级机构
+        List<OrgInfo> childList = iOrgInfoFacade.getOrgListByUpId(parentId);
+        Map<String, Long> orgNums = iOrgInfoFacade.countOrgByUpOrgId(parentId, state);
+        if (StringUtils.isNotEmpty(mtAuthIds)) {
+            Iterator<OrgInfo> iterator = childList.iterator();
+            while (iterator.hasNext()) {
+                OrgInfo orgInfo = iterator.next();
+                //不在管理范围内
+                if (!OrgInfoUtil.isHaveAuth(orgInfo.getId(), orgInfo.getPath(), mtAuthIds))
+                    iterator.remove();
+            }
+        }
+        List<Map<String, Object>> mapList = this.orgToTreeNode(childList, orgNums);
+        return mapList;
+    }
+
+    /**
+     * 管理员管理-管理范围-节点状态勾选
+     * @param treeNodes
+     * @param type         机构树类型
+     * @param targetUserId
+     * @return
+     */
+    public List<Map<String, Object>> checkTreeNode(List<Map<String, Object>> treeNodes, String type, String targetUserId) {
+        String mtAuthIds = mtAuthService.getMtAuth(targetUserId, type);
+        for (Map<String, Object> treeNode : treeNodes) {
+            String orgId = (String) treeNode.get("id");
+            String path = (String) treeNode.get("path");
+            if (StringUtils.isNotEmpty(mtAuthIds) && mtAuthIds.indexOf(orgId + ":1") > -1) {//半勾选
+                treeNode.put("checked", "1");
+            } else if (OrgInfoUtil.isHaveAuth(orgId, path, mtAuthIds)) {//全勾选
+                treeNode.put("checked", "2");
+            } else {
+                treeNode.put("checked", "0");//未勾选
+            }
+        }
+        return treeNodes;
+    }
+
+
+    @ApiOperation(value = "完整树")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "节点机构id"),
+            @ApiImplicitParam(name = "type", value = "'1':顶点为自身所在机构,0:根节点", required = true)})
+    @PostMapping(value = "org/tree/full")
+    public Result fullOrgTree(@RequestBody Map<String, String> params) {
+        String id = params.get("id");
+        String type = params.get("type");
+        if (StringUtils.isEmpty(id)) {
+            SecurityUser securityUser = SessionUtils.getUserInfo();
+            if (YesNotEnum.YES.getValue().equals(type) && StringUtils.isNotEmpty(securityUser.getSecurityOrg())) {
+                id = securityUser.getSecurityOrg();
+            } else {
+                id = iOrgInfoFacade.getRootOrgId();
+            }
+            List<OrgInfo> orgInfos = iOrgInfoFacade.getOrgsByIds(id);
+            Map<String, Long> orgNums = iOrgInfoFacade.countOrgByIds(id);
+            List<Map<String, Object>> resultList = this.orgToTreeNode(orgInfos, orgNums);
+            return Result.success(resultList);
+        } else {
+            List<Map<String, Object>> result = this.getChildTreeNode(id, YesNotEnum.NO.getValue(), null);
+            return Result.success(result);
+        }
+    }
+
+    /**
+     * 机构查询
+     * @return
+     */
+//    @PostMapping(value = "searchOrgTree")
+//    public List<Map<String, Object>> searchOrgTree(@RequestParam(value = "orgName", required = false) String orgName,
+//                                                   @RequestParam(value = "orgCode", required = false) String orgCode) {
+//        if (StringUtils.isBlank(orgName) && StringUtils.isBlank(orgCode)) {
+//            throw new ApplicationException("orgName and orgCode can not be all Null");
+//        }
+//        return iOrgInfoFacade.searchOrgTree(orgName, orgCode);
+//    }
+
+    /**
+     * 授权管理-机构配额-配额下发-机构树
+     * @param unitClass
+     * @param roleLevel
+     * @param id        节点机构id
+     * @return
+     */
+//    @PostMapping(value = "calQuotaTreeYB")
+//    public List<OrgTreeNode> calQuotaTreeYB(
+//            @RequestParam(value = "unitClass", required = false) String unitClass,
+//            @RequestParam(value = "roleLevel", required = false) String roleLevel,
+//            @RequestParam(value = "id", required = false) String id) {
+//        if (StringUtils.isEmpty(id)) {
+//            return new ArrayList<OrgTreeNode>();
+//        } else {
+//            SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
+//            return iOrgInfoFacade.getCalQuotaTree(id, user.getId(), unitClass, roleLevel);
+//        }
+//    }
+
+    /**
+     * 审计管理—机构树
+     * @param type 机构树类型 ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围
+     * @param id   异步加载的树节点
+     * @return
+     */
+    @ApiOperation(value = "审计管理—机构树")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "节点机构id", required = true),
+            @ApiImplicitParam(name = "type", value = "机构树类型 ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围", required = true)})
+    @PostMapping(value = "org/tree/audit")
+    public Result userAuditTree(
+            @RequestParam(value = "type", required = false) String type,
+            @RequestParam(value = "id", required = false) String id) {
+        //获取管理范围ids
+        SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
+        String mtAuthIds = mtAuthService.getMtAuth(curUser.getId(), type);
+        if (StringUtils.isEmpty(id)) {
+            List<Map<String, Object>> result = this.treeRootList(mtAuthIds);
+            return Result.success(result);
+        } else {
+            List<Map<String, Object>> result = this.getChildTreeNode(id, null, mtAuthIds);
+            return Result.success(result);
+        }
+    }
+
+    @ApiOperation(value = "机构树匹配")
+    @ApiImplicitParams({@ApiImplicitParam(name = "name", value = "机构id", required = false),
+            @ApiImplicitParam(name = "mtType", value = "机构树类型 org:机构管理范围 user:用户管理范围 app:权限管理范围 mge:管理员管理范围", required = false),
+            @ApiImplicitParam(name = "pageNum", value = "条数", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "页数", required = false)
+    })
+    @PostMapping(value = "org/tree/match")
+    public Result orgMatch(@RequestBody Map<String, Object> params) {
+        String mtType = (String) params.get("mtType");
+        String name = (String) params.get("name");
+        Integer pageNum = (Integer) params.get("pageNum");
+        Integer pageSize = (Integer) params.get("pageSize");
+        String mts = "";
+        String userName = ContextUtils.getUserInfo().getName();
+        if (StringUtils.isBlank(mtType)) {
+            mts = "";
+        } else if ("org".equals(mtType)) {
+            mts = iOrgMtAuthFacade.mgeOrgRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("user".equals(mtType)) {
+            mts = iUserMtAuthFacade.mgeUserRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("app".equals(mtType)) {
+            mts = iAppMtAuthFacade.mgeAppRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("mge".equals(mtType)) {
+            mts = iMgeMtAuthFacade.mgeMgeRightRangeStr(ContextUtils.getUserInfo().getId());
+        }
+        if (!iUserInfoFacade.getRootUser().equals(userName) && StringUtils.isBlank(mts) && !StringUtils.isBlank(mtType) && !"all".equals(mtType)) {
+            return Result.success();
+        }
+        ResponseDTO responseDTO = iOrgInfoFacade.orgMatch(name, mts, pageNum, pageSize);
+        return Result.success(StringUtils.getLong(responseDTO.getMessage()),responseDTO.getResult());
+    }
+
+    @ApiOperation(value = "获取过滤后的父节点")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "机构id", required = true),
+            @ApiImplicitParam(name = "type", value = "机构树类型 org:机构管理范围 user:用户管理范围 app:权限管理范围 mge:管理员管理范围", required = true),
+    })
+    @PostMapping(value = "org/tree/filter")
+    public Result getFilterOrgTree(@RequestParam(value = "codeId") String codeId,
+                                   @RequestParam(value = "type", required = false) String type) {
+        OrgTreeNode node = iOrgInfoFacade.getOrgTreeNode(codeId);
+        String path = node.getPath();
+        String[] paths = path.split("-");
+        List<String> levelOrder = new ArrayList<String>();
+        String mtIds = "";
+        if (StringUtils.isBlank(type)) {
+            mtIds = "";
+        } else if ("org".equals(type)) {
+            mtIds = iOrgMtAuthFacade.mgeOrgRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("user".equals(type)) {
+            mtIds = iUserMtAuthFacade.mgeUserRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("app".equals(type)) {
+            mtIds = iAppMtAuthFacade.mgeAppRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else if ("mge".equals(type)) {
+            mtIds = iMgeMtAuthFacade.mgeMgeRightRangeStr(ContextUtils.getUserInfo().getId());
+        } else {
+            mtIds = "";
+        }
+        for (String curNodeId : paths) {
+            OrgTreeNode curNode = iOrgInfoFacade.getOrgTreeNode(curNodeId);
+            if (OrgInfoUtil.isHaveAuth(curNode.getValue(), curNode.getPath(), mtIds) || StringUtils.isEmpty(mtIds)) {
+                levelOrder.add(curNodeId);
+            }
+        }
+        levelOrder.add(codeId);
+        return Result.success(levelOrder);
+    }
+
+//    /**
+//     * 授权管理—机构配额详情、人员授权详情机构树
+//     * @param id 节点机构id
+//     * @return
+//     */
+//    @PostMapping(value = "appMtTree")
+//    public List<Map<String, Object>> appMtTree(
+//            @RequestParam(value = "id", required = false) String id) {
+//        if (StringUtils.isEmpty(id)) {
+//            SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
+//            String mtIds = mtAuthService.getMtAuth(curUser.getId(), SysConstants.MT_APP);
+//            return getInitMtTree(mtIds);
+//        } else {
+//            return getChildTreeNode(id, YesNotEnum.NO.getValue());
+//        }
+//    }
+
+}

+ 37 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/vo/GovOrgVo.java

@@ -0,0 +1,37 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by Administrator on 2020/6/30.
+ */
+@Data
+@ApiModel(value = "政务机构Vo")
+public class GovOrgVo {
+    //编号
+    @ApiModelProperty(value = "id",required = true)
+    private String id;
+
+    //机构代码(共12位)=行政区划(6位)+业务类型(2位)+扩展代码(4位)
+    @ApiModelProperty(value = "机构代码",required = true)
+    private String code;
+
+    //机构全称
+    @ApiModelProperty(value = "机构全称",required = true)
+    private String fullName;
+
+    //机构简称
+    @ApiModelProperty(value = "机构简称")
+    private String shortName;
+
+    // 上级政府机构id
+    @ApiModelProperty(value = "上级政府机构id")
+    private String upGovId;
+
+    // 上级政府机构名称
+    @ApiModelProperty(value = "上级政府机构名称")
+    private String upGovName;
+
+}

+ 20 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/vo/MergersVo.java

@@ -0,0 +1,20 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "机构合并入参Vo")
+public class MergersVo {
+
+    @ApiModelProperty(value = "合并机构id",required = true)
+    String orgId;
+
+    @ApiModelProperty(value = "目标机构Id",required = true)
+    String targetId;
+
+    @ApiModelProperty(value = "上级机构Id",required = true)
+    String upGovId;
+
+}

+ 23 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/vo/OrgRangeVo.java

@@ -0,0 +1,23 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org.vo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "管理员管理范围Vo")
+public class OrgRangeVo {
+    @ApiModelProperty(value = "用戶id")
+    String userId;
+    @ApiModelProperty(value = "ORG:用户中心; APP:授权; TEMP:临时")
+    String mtType;
+    @ApiModelProperty(value = "机构id,可以不传")
+    String id;
+
+
+}

+ 104 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/vo/OrgVo.java

@@ -0,0 +1,104 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org.vo;
+
+import com.dragoninfo.dcuc.user.admin.vo.NoticeUserVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Created by yica on 2020/5/12.
+ */
+@Data
+@ApiModel(value = "机构Vo")
+public class OrgVo {
+
+
+    //编号
+    //编号
+    @ApiModelProperty(value = "id",required = true)
+    private String id;
+
+    //机构代码(共12位)=行政区划(6位)+业务类型(2位)+扩展代码(4位)
+    //编号
+    @ApiModelProperty(value = "机构代码",required = true)
+    private String code;
+
+    //机构全称
+    @ApiModelProperty(value = "机构全称",required = true)
+    private String fullName;
+
+    //机构简称
+    @ApiModelProperty(value = "机构简称")
+    private String shortName;
+
+    //行政区划
+    @ApiModelProperty(value = "行政区划",required = true)
+    private String areaCode;
+
+    //机构类别 1,行政单位,2 业务单位
+    @ApiModelProperty(value = "机构类别",required = true)
+    private String orgType;
+
+
+    //机构类型 1:正式 2:临时
+    @ApiModelProperty(name = "机构类型",required = true)
+    private String orgKind;
+
+    //标准代码
+    @ApiModelProperty(value = "标准代码",required = true)
+    private String bizType;
+
+    //单位层级;1:部级单位 2:厅级单位 3:局级单位 4:处级单位 5:科级单位 6:股级单位
+    @ApiModelProperty(value = "单位层级",required = true)
+    private String orgLevel;
+
+    //单位级别;01:正部级单位 02:副部级单位 11:正厅级单位 12:副厅级单位 21:正处级单位 22:副处级单位
+    //          31:正科级单位 32:副科级单位 41:正股级单位 42:副股级单位
+    @ApiModelProperty(value = "单位级别",required = true)
+    private String orgRank;
+
+    // 上级行政机构 行政隶属于那一个公安局的单位
+    @ApiModelProperty(value = "上级行政机构")
+    private String upGovId;
+
+    // 上级行政机构名称
+    @ApiModelProperty(value = "上级行政机构名称")
+    private String upGovName;
+
+    //上级单位code
+    @ApiModelProperty(value = "上级单位code")
+    private String upGovCode;
+
+    //联系人
+    @ApiModelProperty(value = "联系人")
+    private String linkMan;
+
+    //电话
+    @ApiModelProperty(value = "电话")
+    private String tel;
+
+    //E-mail
+    @ApiModelProperty(value = "E-mail")
+    private String email;
+
+    //单位类别
+    @ApiModelProperty(value = "单位类别")
+    private String unitClass;
+
+
+    //排序号
+    @ApiModelProperty(value = "SORT_NO")
+    private Integer sortNo;
+
+    @ApiModelProperty(value = "机构管理员信息")
+    private  List<NoticeUserVO> admins;
+
+
+
+
+
+
+
+}

+ 20 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/org/vo/SortVo.java

@@ -0,0 +1,20 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.org.vo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "排序Vo")
+public class SortVo {
+
+    @ApiModelProperty(value = "需要拖动的机构",required = true)
+    String startId;
+
+    @ApiModelProperty(value = "拖动到目标机构",required = true)
+    String endId;
+
+    @ApiModelProperty(value = "prev:目标机构前,next: 目标机构后",required = true)
+    String moveType;
+}

+ 2 - 2
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/resource/MdDynCodeDicSonController.java

@@ -49,7 +49,7 @@ public class MdDynCodeDicSonController extends BaseController {
             return codeList;
         Searchable searchable = Searchable.newSearchable();
         searchable.addSearchFilter(columnName, SearchOperator.eq, columnValue);
-        List<Map<String, Object>> list = iCodeInfoFacade.pageCodeDicData(searchable, codeDicId);
+        List<Map<String, Object>> list = iCodeInfoFacade.pageCodeDicData(searchable.toSearchDTO());
         for (Map map : list) {
             CodeRecord codeRecord = new CodeRecord();
             String name = codeDic.getNameField();
@@ -103,7 +103,7 @@ public class MdDynCodeDicSonController extends BaseController {
         if (StringUtils.isNotEmpty(name)) {
             searchable.addSearchFilter(codeDic.getNameField(), SearchOperator.like, name);
         }
-        List<Map<String, Object>> list = iCodeInfoFacade.pageCodeDicData(searchable, id);
+        List<Map<String, Object>> list = iCodeInfoFacade.pageCodeDicData(searchable.toSearchDTO());
         return list;
     }
 

+ 36 - 0
src/main/java/com/dragoninfo/dcuc/authweb/util/UserUtils.java

@@ -0,0 +1,36 @@
+package com.dragoninfo.dcuc.authweb.util;
+
+import com.dragonsoft.duceap.commons.util.bean.BeanUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Created by Administrator on 2018/7/4.
+ */
+public class UserUtils {
+    private static Logger logger = LoggerFactory.getLogger(UserUtils.class);
+
+     /*
+     * 对象复制
+     *
+     * @param obj1 需复制的对象
+     * @param obj2 被复制的对象
+     * @return
+     */
+    public static <T> T copyObject(T obj1, T obj2) {
+        try {
+            BeanUtils.copyProperties(obj1,obj2);
+        } catch (IllegalAccessException e) {
+            logger.error("属性拷贝异常",e);
+        } catch (InvocationTargetException e) {
+            logger.error("属性拷贝异常",e);
+        }
+        return obj1;
+    }
+
+
+
+
+}