huangzqa 4 年之前
父节点
当前提交
fa5f11599b

+ 0 - 1
src/main/assembly/conf/application.yml

@@ -32,7 +32,6 @@ duceap:
     #默认使用HttpServletRequest.getLocalAddr()方法获取ip地址,
     #应用在docker部署环境中无法获取机子的真实ip地址 考虑以配置参数的形式传入
     address: http://127.0.0.1:8871/dcucauth
-    enabled: true
   security:
     type: dcuc
     dcuc:

+ 537 - 537
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/user/PoliceManagementController.java

@@ -1,553 +1,553 @@
-//package com.dragoninfo.dcuc.authweb.restcontroller.user;
-//
-//import com.dragoninfo.dcuc.auth.auth.facade.IStaffAssignAuthInfoFacade;
-//import com.dragoninfo.dcuc.authweb.common.SysConstants;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.AuthUtils;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.ExportExcelUtils;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.ImpExcelUtils;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.BusinessVo;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.PoliceInVo;
-//import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.PostInfoVo;
-//import com.dragoninfo.dcuc.authweb.util.UserUtils;
-//import com.dragoninfo.dcuc.duceap.facade.IDuceapUploadFacade;
-//import com.dragoninfo.dcuc.duceap.upload.dto.DocContentDTO;
-//import com.dragoninfo.dcuc.org.org.entity.OrgInfo;
-//import com.dragoninfo.dcuc.org.org.facade.IOrgInfoFacade;
-//import com.dragoninfo.dcuc.user.admin.facade.IUserMtAuthFacade;
-//import com.dragoninfo.dcuc.user.user.entity.PostInfo;
-//import com.dragoninfo.dcuc.user.user.entity.UserInfo;
-//import com.dragoninfo.dcuc.user.user.entity.UserInfoView;
-//import com.dragoninfo.dcuc.user.user.enumresources.JobTypeEnum;
-//import com.dragoninfo.dcuc.user.user.enumresources.UserTypeEnum;
-//import com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum;
-//import com.dragoninfo.dcuc.user.user.facade.IAccountInfoFacade;
-//import com.dragoninfo.dcuc.user.user.facade.IPostInfoFacade;
-//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.http.ResponseStatus;
-//import com.dragonsoft.duceap.base.entity.search.SearchDTO;
-//import com.dragonsoft.duceap.base.entity.security.SecurityUser;
-//import com.dragonsoft.duceap.base.entity.uploader.FileHolder;
-//import com.dragonsoft.duceap.base.exception.ApplicationException;
-//import com.dragonsoft.duceap.commons.util.bean.BeanUtils;
-//import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
-//import com.dragonsoft.duceap.commons.util.json.JsonUtils;
-//import com.dragonsoft.duceap.commons.util.string.StringUtils;
-//import com.dragonsoft.duceap.core.context.ContextUtils;
-//import com.dragonsoft.duceap.core.search.SearchRequest;
-//import com.dragonsoft.duceap.core.search.Searchable;
-//import com.dragonsoft.duceap.core.search.enums.SearchOperator;
-//import com.dragonsoft.duceap.core.search.filter.Condition;
-//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.factory.annotation.Autowired;
-//import org.springframework.data.domain.Page;
-//import org.springframework.data.domain.Sort;
-//import org.springframework.web.bind.annotation.*;
-//
-//import javax.annotation.Resource;
-//import javax.servlet.http.HttpServletRequest;
-//import javax.servlet.http.HttpServletResponse;
-//import java.io.ByteArrayInputStream;
-//import java.io.IOException;
-//import java.io.InputStream;
-//import java.lang.reflect.InvocationTargetException;
-//import java.math.BigDecimal;
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.List;
-//import java.util.Map;
-//
-//
-///**
-// * 警员管理Controller
-// * Created by yica on 2018/5/24.
-// */
-//@Api(tags = {"警员管理接口"})
-//@RestController
-//@RequestMapping(value = "/usersvr/v2")
-//public class PoliceManagementController {
-//    private static Logger logger = LoggerFactory.getLogger(PoliceManagementController.class);
-//
-//    @Autowired
-//    private IOrgInfoFacade orgInfoFacade;
-//    @Autowired
-//    private IUserInfoFacade userInfoFacade;
-//    @Autowired
-//    private IPostInfoFacade postInfoFacade;
-//    @Autowired
-//    private IAccountInfoFacade accountInfoFacade;
-//
-//    @Autowired
-//    private IStaffAssignAuthInfoFacade staffAssignAuthInfoFacade;
-//
-//    @Autowired
-//    private IUserMtAuthFacade iUserMtAuthFacade;
-//
-//    @Resource
-//    private IDuceapUploadFacade uploadhandler;
-//
-//    @ApiOperation(value = "警员查询列表")
-//    @ApiImplicitParam(name = "SearchDTO", value = "查询条件")
-//    @PostMapping(value = "/polices")
-//    public Result policePage(SearchDTO searchDTO) {
-//        Searchable searchable = Searchable.toSearchable(searchDTO);
-//        searchable.getSearchParams().get("orgId");
-//        searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
-//        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
-//        searchable.addSort(Sort.Direction.ASC, "sortNo");
-//
-//        Page<UserInfoView> page = null;
-//        page = userInfoFacade.userInfoPage(searchable.toSearchDTO());
-//        return Result.success(page.getTotalElements(), page.getContent());
-//    }
-//
-//    @ApiOperation(value = "获取警员")
-//    @GetMapping(value = "/police/{id}")
-//    @ApiImplicitParam(name = "id", value = "id", required = true)
-//    public Result<PoliceInVo> get(@PathVariable("id") String id) {
-//        UserInfo userInfo = new UserInfo();
-//        userInfo = userInfoFacade.userDetail(id);
-//        List<PostInfo> postInfos = postInfoFacade.getPostInfos(id);
-//        PoliceInVo policeInVo=new PoliceInVo();
-//        UserUtils.copyObject( policeInVo,userInfo);
-//        List<PostInfoVo> list=UserUtils.copyObjectByVo(postInfos);
-//        policeInVo.setPostInfos(list);
-//        policeInVo.setFile( uploadhandler.queryByBusiId(id,""));
-//        List<FileHolder> fileHolders = uploadhandler.queryByBusiId(id,"");
-//        return Result.success(policeInVo);
-//    }
-//
-//
-//
-//    @ApiOperation(value = "修改警员")
-//    @PutMapping(value = "/police/{id}")
-//    public Result update(@RequestBody PoliceInVo userVo) {
-//        try {
-//            UserInfo info = new UserInfo();
-//            //用户PoliceInVo copy到UserInfo
-//            setUser(userVo, info);
-//            if (UserUtils.verificaName(info)){
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"姓名不能为ADMIN");
-//            }
-//            if (UserUtils.verificaIdcard(info,userInfoFacade)){
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"身份证重复!");
-//            }
-//            if (CollectionUtils.isEmpty(info.getPostInfos())) {
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"职务信息不能为空!");
-//            }
-//            //设置用户部门
-//            UserUtils.setUserOrg(orgInfoFacade, info.getPostInfos(), info);
-//            ResponseStatus responseStatus = userInfoFacade.savePolice(info);
-//            if(!responseStatus.getStatusCode().equals("200")){
-//                return  Result.fail(responseStatus.getStatusCode(),responseStatus.getMessage());
-//            }else {
-//                return Result.success();
-//            }
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"保存异常");
-//        }
-//    }
-//
-//    @ApiOperation(value = "保存警员")
-//    @PostMapping(value = "/police")
-//    public Result save(@RequestBody PoliceInVo userVo) {
-//        try {
-//            UserInfo info = new UserInfo();
-//            setUser(userVo, info);
-//            //姓名不能为ADMIN
-//            if (UserUtils.verificaIdcard(info,userInfoFacade)){
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"身份证重复!");
-//            }
-//            if (UserUtils.verificaName(info)){
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"姓名不能为ADMIN");
-//            }
-//            if (CollectionUtils.isEmpty(info.getPostInfos())) {
-//                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"职务信息不能为空!");
-//            }
-//            //设置用户部门
-//            UserUtils.setUserOrg(orgInfoFacade, info.getPostInfos(), info);
-//            ResponseStatus responseStatus = userInfoFacade.savePolice(info);
-//            if(!responseStatus.getStatusCode().equals("200")){
-//                return  Result.fail(responseStatus.getStatusCode(),responseStatus.getMessage());
-//            }else {
-//                return Result.success();
-//            }
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"保存异常");
+package com.dragoninfo.dcuc.authweb.restcontroller.user;
+
+import com.dragoninfo.dcuc.auth.auth.facade.IStaffAssignAuthInfoFacade;
+import com.dragoninfo.dcuc.authweb.common.SysConstants;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.AuthUtils;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.ExportExcelUtils;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils.ImpExcelUtils;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.BusinessVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.PoliceInVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.PostInfoVo;
+import com.dragoninfo.dcuc.authweb.util.UserUtils;
+import com.dragoninfo.dcuc.duceap.facade.IDuceapUploadFacade;
+import com.dragoninfo.dcuc.duceap.upload.dto.DocContentDTO;
+import com.dragoninfo.dcuc.org.entity.OrgInfo;
+import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
+import com.dragoninfo.dcuc.user.admin.facade.IUserMtAuthFacade;
+import com.dragoninfo.dcuc.user.user.entity.PostInfo;
+import com.dragoninfo.dcuc.user.user.entity.UserInfo;
+import com.dragoninfo.dcuc.user.user.entity.UserInfoView;
+import com.dragoninfo.dcuc.user.user.enumresources.JobTypeEnum;
+import com.dragoninfo.dcuc.user.user.enumresources.UserTypeEnum;
+import com.dragoninfo.dcuc.user.user.enumresources.YesNotEnum;
+import com.dragoninfo.dcuc.user.user.facade.IAccountInfoFacade;
+import com.dragoninfo.dcuc.user.user.facade.IPostInfoFacade;
+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.http.ResponseStatus;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.base.entity.security.SecurityUser;
+import com.dragonsoft.duceap.base.entity.uploader.FileHolder;
+import com.dragonsoft.duceap.base.exception.ApplicationException;
+import com.dragonsoft.duceap.commons.util.bean.BeanUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.commons.util.json.JsonUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import com.dragonsoft.duceap.core.context.ContextUtils;
+import com.dragonsoft.duceap.core.search.SearchRequest;
+import com.dragonsoft.duceap.core.search.Searchable;
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
+import com.dragonsoft.duceap.core.search.filter.Condition;
+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.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Sort;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 警员管理Controller
+ * Created by yica on 2018/5/24.
+ */
+@Api(tags = {"警员管理接口"})
+@RestController
+@RequestMapping(value = "/usersvr/v2")
+public class PoliceManagementController {
+    private static Logger logger = LoggerFactory.getLogger(PoliceManagementController.class);
+
+    @Autowired
+    private IOrgInfoFacade orgInfoFacade;
+    @Autowired
+    private IUserInfoFacade userInfoFacade;
+    @Autowired
+    private IPostInfoFacade postInfoFacade;
+    @Autowired
+    private IAccountInfoFacade accountInfoFacade;
+
+    @Autowired
+    private IStaffAssignAuthInfoFacade staffAssignAuthInfoFacade;
+
+    @Autowired
+    private IUserMtAuthFacade iUserMtAuthFacade;
+
+    @Resource
+    private IDuceapUploadFacade uploadhandler;
+
+    @ApiOperation(value = "警员查询列表")
+    @ApiImplicitParam(name = "SearchDTO", value = "查询条件")
+    @PostMapping(value = "/polices")
+    public Result policePage(SearchDTO searchDTO) {
+        Searchable searchable = Searchable.toSearchable(searchDTO);
+        searchable.getSearchParams().get("orgId");
+        searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
+        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
+        searchable.addSort(Sort.Direction.ASC, "sortNo");
+
+        Page<UserInfoView> page = null;
+        page = userInfoFacade.userInfoPage(searchable.toSearchDTO());
+        return Result.success(page.getTotalElements(), page.getContent());
+    }
+
+    @ApiOperation(value = "获取警员")
+    @GetMapping(value = "/police/{id}")
+    @ApiImplicitParam(name = "id", value = "id", required = true)
+    public Result<PoliceInVo> get(@PathVariable("id") String id) {
+        UserInfo userInfo = new UserInfo();
+        userInfo = userInfoFacade.userDetail(id);
+        List<PostInfo> postInfos = postInfoFacade.getPostInfos(id);
+        PoliceInVo policeInVo=new PoliceInVo();
+        UserUtils.copyObject( policeInVo,userInfo);
+        List<PostInfoVo> list=UserUtils.copyObjectByVo(postInfos);
+        policeInVo.setPostInfos(list);
+        policeInVo.setFile( uploadhandler.queryByBusiId(id,""));
+        List<FileHolder> fileHolders = uploadhandler.queryByBusiId(id,"");
+        return Result.success(policeInVo);
+    }
+
+
+
+    @ApiOperation(value = "修改警员")
+    @PutMapping(value = "/police/{id}")
+    public Result update(@RequestBody PoliceInVo userVo) {
+        try {
+            UserInfo info = new UserInfo();
+            //用户PoliceInVo copy到UserInfo
+            setUser(userVo, info);
+            if (UserUtils.verificaName(info)){
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"姓名不能为ADMIN");
+            }
+            if (UserUtils.verificaIdcard(info,userInfoFacade)){
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"身份证重复!");
+            }
+            if (CollectionUtils.isEmpty(info.getPostInfos())) {
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"职务信息不能为空!");
+            }
+            //设置用户部门
+            UserUtils.setUserOrg(orgInfoFacade, info.getPostInfos(), info);
+            ResponseStatus responseStatus = userInfoFacade.savePolice(info);
+            if(!responseStatus.getStatusCode().equals("200")){
+                return  Result.fail(responseStatus.getStatusCode(),responseStatus.getMessage());
+            }else {
+                return Result.success();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"保存异常");
+        }
+    }
+
+    @ApiOperation(value = "保存警员")
+    @PostMapping(value = "/police")
+    public Result save(@RequestBody PoliceInVo userVo) {
+        try {
+            UserInfo info = new UserInfo();
+            setUser(userVo, info);
+            //姓名不能为ADMIN
+            if (UserUtils.verificaIdcard(info,userInfoFacade)){
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"身份证重复!");
+            }
+            if (UserUtils.verificaName(info)){
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"姓名不能为ADMIN");
+            }
+            if (CollectionUtils.isEmpty(info.getPostInfos())) {
+                return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"职务信息不能为空!");
+            }
+            //设置用户部门
+            UserUtils.setUserOrg(orgInfoFacade, info.getPostInfos(), info);
+            ResponseStatus responseStatus = userInfoFacade.savePolice(info);
+            if(!responseStatus.getStatusCode().equals("200")){
+                return  Result.fail(responseStatus.getStatusCode(),responseStatus.getMessage());
+            }else {
+                return Result.success();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"保存异常");
+        }
+    }
+
+    @ApiOperation(value = "删除警员")
+    @ApiImplicitParam(name = "id", value = "id", required = true)
+    @DeleteMapping(value = "/police/{id}")
+    public Result del(@PathVariable("id") String id) {
+        try {
+            userInfoFacade.deleteUser(id);
+            accountInfoFacade.del(id);
+            //删除角色授权
+            staffAssignAuthInfoFacade.deleteAllStaffRole(id);
+            return Result.success("删除成功");
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"删除失败");
+        }
+    }
+
+
+    @ApiOperation(value = "获取警号和排序号")
+    @GetMapping(value = "/police/number")
+    public Result getNewPoliceNumber() {
+        String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.POLICE.getValue());
+        int pn = Integer.valueOf(policeNumber) + 1;
+        BigDecimal num = new BigDecimal(1);
+        BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.POLICE.getValue()).add(num);
+        HashMap<String, String> map = new HashMap<>();
+        map.put("policeNumber",pn+"");
+        map.put("pSortNo",sort+"");
+        return Result.success(map);
+    }
+
+    /**
+     * 警员排序
+     *
+     * @return Result
+     */
+
+    @PostMapping(value = "/police/sort")
+    @ApiOperation(value = "警员排序")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "postId 职务ID", required = true),
+            @ApiImplicitParam(name = "sort", value = "排序 10:上升,20:下降", required = true)
+    })
+    public Result jySortPo(@RequestBody Map<String,String> map) {
+        String id = map.get("id");
+        String sortType =  map.get("sort");
+        try {
+            userInfoFacade.jySortPo(id, sortType);
+            return Result.success();
+        } catch (Exception e) {
+            logger.error("排序失败",e);
+            return Result.fail(ResultEnum.FAIL.getValue());
+        }
+    }
+
+
+    @ApiOperation(value = "导出警员信息")
+    @ApiImplicitParam(name = "SearchDTO", value = "查询条件")
+    @PostMapping(value = "/police/exports")
+    public void listExport(SearchDTO searchDTO, HttpServletRequest request, HttpServletResponse response) {
+        String name = "警员信息";
+        try {
+            searchDTO.setSize(String.valueOf(SysConstants.EXPORT_NUMBER_MAX));
+            Searchable searchable = Searchable.toSearchable(searchDTO);
+            searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
+            Condition condition = searchable.getSearchFilterByKey("jobType_eq");
+            if (condition == null) {
+                List<String> list = new ArrayList<String>();
+                list.add(JobTypeEnum.LZ.getValue());
+                list.add(JobTypeEnum.SW.getValue());
+                list.add(JobTypeEnum.TX.getValue());
+                searchable.addSearchFilter("jobType", SearchOperator.notIn, list);
+            }
+            List<UserInfoView> list = this.queryPolice(searchable.toSearchDTO());
+            searchDTO.setMetadata(template());
+            ExportExcelUtils.exportPoliceExcel(name, list, Searchable.toSearchable(searchDTO).getMetaData(), request, response);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new ApplicationException(300, "导出失败", e);
+        }
+    }
+
+    @ApiOperation(value = "批量导出警员信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orgIds", value = "要导出的机构ids 用,隔开"),
+    })
+    @PostMapping(value = "/police/batchExports")
+    public void batchExport(HttpServletRequest request, HttpServletResponse response) {
+        String orgIds = request.getParameter("orgIds");
+        try {
+            SearchDTO searchDTO=new SearchDTO();
+            //TODO 导出无数据
+            List<UserInfoView> userInfoViews = userInfoFacade.batchExportPolice(orgIds);
+            searchDTO.setMetadata(template());
+            ExportExcelUtils.exportPoliceExcel("警员信息", userInfoViews,Searchable.toSearchable(searchDTO).getMetaData(), request, response);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new ApplicationException(300, "导出失败", e);
+        }
+    }
+
+    /**
+     * 导入警员
+     *
+     * @return
+     */
+    @PostMapping(value = "police/import")
+    @ApiImplicitParam(name = "fileId", value = "导入文件id")
+    @ApiOperation(value = "警员导入")
+    public Result impExcel(@RequestBody String fileId) {
+        try {
+            fileId = JsonUtils.parseObject(fileId).getString("fileId");
+            DocContentDTO fileContent = uploadhandler.getFileContent(fileId);
+            byte[] fileData = fileContent.getFileData();
+            InputStream inputStream = new ByteArrayInputStream(fileData);
+            List<UserInfo> list = ImpExcelUtils.loadScoreInfo(inputStream, UserTypeEnum.POLICE.getValue());
+            String message = this.impPolice(list);
+            if (message != null) {
+                if(message.startsWith("身份证或警号重复,未保存人员")){
+                    throw new NumberFormatException(message);
+                }
+            }
+            return Result.success("导入成功");
+        } catch (IOException e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail("300","导入文件类型错误");
+        } catch (NumberFormatException e) {
+
+            return Result.fail("300",e.getMessage());
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.fail("300","导入失败");
+        }
+    }
+
+    /**
+     * 根据业务域获取警种,通过机构id和警种获取用户
+     * @return
+     */
+    @PostMapping(value = "police/businessUser")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orgIds", value = "机构id"),
+            @ApiImplicitParam(name = "business", value = "选择的业务域"),
+    })
+    @ApiOperation(value = "业务域--中的用户")
+    public Result usersByOrgIdAndBusiness(@RequestBody BusinessVo businessVo) {
+        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
+        String orgId = businessVo.getOrgId();
+        String business = businessVo.getBusiness();
+        SecurityUser securityUser = (SecurityUser) ContextUtils.getUserInfo();
+        UserInfo user = userInfoFacade.userDetail(securityUser.getId());
+        if (StringUtils.isEmpty(orgId) || StringUtils.isEmpty(business)){
+            return Result.success(list);
+        }
+        Searchable searchable = new SearchRequest();
+        //通过业务域获取警种
+        List<String> policeTypeIds = userInfoFacade.findPoliceTypeByBusId(business);
+        searchable.addSearchParam("userType_eq", UserTypeEnum.POLICE.getValue());
+        searchable.addSearchParam("orgId_eq", orgId);
+        searchable.addSearchParam("id_ne", securityUser.getId());
+        searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
+      /*  for (UserInfoView userInfo : userList) {
+            Map<String, String> map = new HashMap<String, String>();
+            map.put("code", userInfo.getId());
+            map.put("value", userInfo.getName());
+            list.add(map);
+        }*/
+        for (String policeTypeId : policeTypeIds) {
+            //searchable.addSearchParam("policeCategory_eq", policeTypeId);  查询所有警种的警员
+            SearchDTO searchDTO = searchable.toSearchDTO();
+            List<UserInfoView> userList = userInfoFacade.roleInfoList(searchDTO);
+            for (UserInfoView userInfo : userList) {
+                Map<String, String> map = new HashMap<String, String>();
+                map.put("code", userInfo.getId());
+                map.put("value", userInfo.getName());
+                list.add(map);
+            }
+        }
+
+        return Result.success(list);
+    }
+
+    /**
+     * 某机构下包含某业务域的警员
+     */
+    @PostMapping(value = "police/businessInclude")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orgIds", value = "机构id"),
+            @ApiImplicitParam(name = "business", value = "选择的业务域"),
+    })
+    @ApiOperation(value = "业务域中已包含的用户")
+    public Result businessInclude(@RequestBody BusinessVo businessVo) {
+        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
+        String orgId = businessVo.getOrgId();
+        String business = businessVo.getBusiness();
+        if (StringUtils.isEmpty(orgId) || StringUtils.isEmpty(business)) {
+            return Result.success(list);
+        }
+        Searchable searchable = new SearchRequest();
+        SecurityUser securityUser = (SecurityUser) ContextUtils.getUserInfo();
+        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
+        searchable.addSearchFilter("orgId", SearchOperator.eq, orgId);
+        searchable.addSearchFilter("policeBusiness", SearchOperator.like, business);
+        searchable.addSearchFilter("id", SearchOperator.ne, securityUser.getId());
+        SearchDTO searchDTO = searchable.toSearchDTO();
+        List<UserInfoView> userList = userInfoFacade.roleInfoList(searchDTO);
+        for (UserInfoView userInfo : userList) {
+            Map<String, String> map = new HashMap<String, String>();
+            map.put("code", userInfo.getId());
+            map.put("value", userInfo.getName());
+            list.add(map);
+        }
+        return Result.success(list);
+    }
+
+    /**
+     * 保存机构警员业务域
+     *
+     * @return
+     */
+    @PostMapping(value = "police/business")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orgIds", value = "机构id"),
+            @ApiImplicitParam(name = "business", value = "选择的业务域"),
+            @ApiImplicitParam(name = "selectId", value = "已选警员id,用逗号隔开"),
+            @ApiImplicitParam(name = "availableId", value = "未选警员id,用逗号隔开")
+    })
+    @ApiOperation(value = "业务域保存配置")
+    public Result saveBusiness(@RequestBody BusinessVo businessVo ) {
+        try {
+            String orgId = businessVo.getOrgId();
+            String business = businessVo.getBusiness();
+            String select = businessVo.getSelectId();
+            String available = businessVo.getAvailableId();
+            userInfoFacade.saveBusiness(orgId, business, select, available);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return Result.success("保存失败");
+        }
+        return Result.success("保存成功");
+    }
+    /**
+     * 模板
+     * @return
+     */
+    private String template(){
+        return "[{\"name\":\"name\",\"displyName\":\"姓名\"},{\"name\":\"policeNumber\",\"displyName\":\"警号\"}," +
+                "{\"name\":\"idcard\",\"displyName\":\"身份证\"}," +
+                "{\"name\":\"orgCode\",\"displyName\":\"单位机构代码\"}," +
+                "{\"name\":\"mobileWork\",\"displyName\":\"手机号码(接收短信验证码)\"}," +
+                "{\"name\":\"nation\",\"displyName\":\"民族(表码)\"}," +
+                "{\"name\":\"mobilePrivate\",\"displyName\":\"手机号码(私人)\"}," +
+                "{\"name\":\"manType\",\"displyName\":\"人员类型(表码)\"}," +
+                "{\"name\":\"rank\",\"displyName\":\"警衔(表码)\"}," +
+                "{\"name\":\"title\",\"displyName\":\"职级(表码)\"}," +
+                "{\"name\":\"postType\",\"displyName\":\"职务\"},{\"name\":\"jobType\",\"displyName\":\"在职类型(表码)\"}," +
+                "{\"name\":\"policeCategory\",\"displyName\":\"警种(表码)\"}" +
+                "]";
+    }
+
+//    private String returnStr(String type) {
+//        if ("toAuxiliary".equals(type)) {
+//            return "/usermanagement/auxiliarypolice/auxiliaryPoliceEdit";
+//        } else if ("toExternal".equals(type)) {
+//            return "/usermanagement/externalpersonnel/externalPersonnelEdit";
 //        }
+//        return "";
 //    }
-//
-//    @ApiOperation(value = "删除警员")
-//    @ApiImplicitParam(name = "id", value = "id", required = true)
-//    @DeleteMapping(value = "/police/{id}")
-//    public Result del(@PathVariable("id") String id) {
-//        try {
-//            userInfoFacade.deleteUser(id);
-//            accountInfoFacade.del(id);
-//            //删除角色授权
-//            staffAssignAuthInfoFacade.deleteAllStaffRole(id);
-//            return Result.success("删除成功");
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.fail(ResultEnum.SERVICE_FAIL.getValue(),"删除失败");
-//        }
-//    }
-//
-//
-//    @ApiOperation(value = "获取警号和排序号")
-//    @GetMapping(value = "/police/number")
-//    public Result getNewPoliceNumber() {
-//        String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.POLICE.getValue());
-//        int pn = Integer.valueOf(policeNumber) + 1;
+
+    /**
+     * copy UserInfo
+     * @param userVo
+     * @param info
+     * @throws IllegalAccessException
+     * @throws InvocationTargetException
+     */
+    public void setUser(PoliceInVo userVo, UserInfo info) throws IllegalAccessException, InvocationTargetException {
+        BeanUtils.copyProperties(info, userVo);
+        // info.setBirth(isNotEmpty(info.getBirth())?info.getBirth().replaceAll("-","").substring(0,8):"");
+        List<PostInfo> postInfos = UserUtils.copyObjectList(userVo.getPostInfos());
+        info.setPostInfos(postInfos);
+        info.setFileHolders(userVo.getFile());
+    }
+
+
+    //    private UserInfo returnUser(String id, String type) {
+//        UserInfo userInfo = userInfoFacade.userDetail(id);
+//        userInfo.setCreateTime(new Date());
+//        userInfo.setCreateTimeStr(ContactUtils.getDate(new Date()));
 //        BigDecimal num = new BigDecimal(1);
-//        BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.POLICE.getValue()).add(num);
-//        HashMap<String, String> map = new HashMap<>();
-//        map.put("policeNumber",pn+"");
-//        map.put("pSortNo",sort+"");
-//        return Result.success(map);
-//    }
-//
-//    /**
-//     * 警员排序
-//     *
-//     * @return Result
-//     */
-//
-//    @PostMapping(value = "/police/sort")
-//    @ApiOperation(value = "警员排序")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "id", value = "postId 职务ID", required = true),
-//            @ApiImplicitParam(name = "sort", value = "排序 10:上升,20:下降", required = true)
-//    })
-//    public Result jySortPo(@RequestBody Map<String,String> map) {
-//        String id = map.get("id");
-//        String sortType =  map.get("sort");
-//        try {
-//            userInfoFacade.jySortPo(id, sortType);
-//            return Result.success();
-//        } catch (Exception e) {
-//            logger.error("排序失败",e);
-//            return Result.fail(ResultEnum.FAIL.getValue());
+//        if ("toExternal".equals(type)) {
+//            String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.EXTERNAL.getValue());
+//            int pn = Integer.valueOf(policeNumber.substring(2, policeNumber.length())) + 1;
+//            userInfo.setPoliceNumber("WB" + String.format("%06d", pn));
+//            BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.EXTERNAL.getValue()).add(num);
+//            userInfo.setSortNo(sort);
+//        } else if ("toAuxiliary".equals(type)) {
+//            String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.HELPER.getValue());
+//            int pn = Integer.valueOf(policeNumber.substring(2, policeNumber.length())) + 1;
+//            userInfo.setPoliceNumber("FJ" + String.format("%06d", pn));
+//            BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.HELPER.getValue()).add(num);
+//            userInfo.setSortNo(sort);
 //        }
-//    }
 //
-//
-//    @ApiOperation(value = "导出警员信息")
-//    @ApiImplicitParam(name = "SearchDTO", value = "查询条件")
-//    @PostMapping(value = "/police/exports")
-//    public void listExport(SearchDTO searchDTO, HttpServletRequest request, HttpServletResponse response) {
-//        String name = "警员信息";
-//        try {
-//            searchDTO.setSize(String.valueOf(SysConstants.EXPORT_NUMBER_MAX));
-//            Searchable searchable = Searchable.toSearchable(searchDTO);
-//            searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
-//            Condition condition = searchable.getSearchFilterByKey("jobType_eq");
-//            if (condition == null) {
-//                List<String> list = new ArrayList<String>();
-//                list.add(JobTypeEnum.LZ.getValue());
-//                list.add(JobTypeEnum.SW.getValue());
-//                list.add(JobTypeEnum.TX.getValue());
-//                searchable.addSearchFilter("jobType", SearchOperator.notIn, list);
-//            }
-//            List<UserInfoView> list = this.queryPolice(searchable.toSearchDTO());
-//            searchDTO.setMetadata(template());
-//            ExportExcelUtils.exportPoliceExcel(name, list, Searchable.toSearchable(searchDTO).getMetaData(), request, response);
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            throw new ApplicationException(300, "导出失败", e);
-//        }
+//        return userInfo;
 //    }
 //
-//    @ApiOperation(value = "批量导出警员信息")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "orgIds", value = "要导出的机构ids 用,隔开"),
-//    })
-//    @PostMapping(value = "/police/batchExports")
-//    public void batchExport(HttpServletRequest request, HttpServletResponse response) {
-//        String orgIds = request.getParameter("orgIds");
-//        try {
-//            SearchDTO searchDTO=new SearchDTO();
-//            //TODO 导出无数据
-//            List<UserInfoView> userInfoViews = userInfoFacade.batchExportPolice(orgIds);
-//            searchDTO.setMetadata(template());
-//            ExportExcelUtils.exportPoliceExcel("警员信息", userInfoViews,Searchable.toSearchable(searchDTO).getMetaData(), request, response);
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            throw new ApplicationException(300, "导出失败", e);
-//        }
-//    }
 //
-//    /**
-//     * 导入警员
-//     *
-//     * @return
-//     */
-//    @PostMapping(value = "police/import")
-//    @ApiImplicitParam(name = "fileId", value = "导入文件id")
-//    @ApiOperation(value = "警员导入")
-//    public Result impExcel(@RequestBody String fileId) {
-//        try {
-//            fileId = JsonUtils.parseObject(fileId).getString("fileId");
-//            DocContentDTO fileContent = uploadhandler.getFileContent(fileId);
-//            byte[] fileData = fileContent.getFileData();
-//            InputStream inputStream = new ByteArrayInputStream(fileData);
-//            List<UserInfo> list = ImpExcelUtils.loadScoreInfo(inputStream, UserTypeEnum.POLICE.getValue());
-//            String message = this.impPolice(list);
-//            if (message != null) {
-//                if(message.startsWith("身份证或警号重复,未保存人员")){
-//                    throw new NumberFormatException(message);
-//                }
-//            }
-//            return Result.success("导入成功");
-//        } catch (IOException e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.fail("300","导入文件类型错误");
-//        } catch (NumberFormatException e) {
-//
-//            return Result.fail("300",e.getMessage());
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.fail("300","导入失败");
-//        }
-//    }
 //
-//    /**
-//     * 根据业务域获取警种,通过机构id和警种获取用户
-//     * @return
-//     */
-//    @PostMapping(value = "police/businessUser")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "orgIds", value = "机构id"),
-//            @ApiImplicitParam(name = "business", value = "选择的业务域"),
-//    })
-//    @ApiOperation(value = "业务域--中的用户")
-//    public Result usersByOrgIdAndBusiness(@RequestBody BusinessVo businessVo) {
-//        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
-//        String orgId = businessVo.getOrgId();
-//        String business = businessVo.getBusiness();
-//        SecurityUser securityUser = (SecurityUser) ContextUtils.getUserInfo();
-//        UserInfo user = userInfoFacade.userDetail(securityUser.getId());
-//        if (StringUtils.isEmpty(orgId) || StringUtils.isEmpty(business)){
-//            return Result.success(list);
-//        }
-//        Searchable searchable = new SearchRequest();
-//        //通过业务域获取警种
-//        List<String> policeTypeIds = userInfoFacade.findPoliceTypeByBusId(business);
-//        searchable.addSearchParam("userType_eq", UserTypeEnum.POLICE.getValue());
-//        searchable.addSearchParam("orgId_eq", orgId);
-//        searchable.addSearchParam("id_ne", securityUser.getId());
-//        searchable.addSearchFilter("deleted", SearchOperator.eq, YesNotEnum.NO.getValue());
-//      /*  for (UserInfoView userInfo : userList) {
-//            Map<String, String> map = new HashMap<String, String>();
-//            map.put("code", userInfo.getId());
-//            map.put("value", userInfo.getName());
-//            list.add(map);
-//        }*/
-//        for (String policeTypeId : policeTypeIds) {
-//            //searchable.addSearchParam("policeCategory_eq", policeTypeId);  查询所有警种的警员
-//            SearchDTO searchDTO = searchable.toSearchDTO();
-//            List<UserInfoView> userList = userInfoFacade.roleInfoList(searchDTO);
-//            for (UserInfoView userInfo : userList) {
-//                Map<String, String> map = new HashMap<String, String>();
-//                map.put("code", userInfo.getId());
-//                map.put("value", userInfo.getName());
-//                list.add(map);
+//    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 = orgInfoFacade.detail(orgId);
+//            if (StringUtils.isNotBlank(orgInfo.getUpGovId())) {
+//                String upGovId = orgInfo.getUpGovId();
+//                targetList = getAdmins(upGovId);
 //            }
 //        }
-//
-//        return Result.success(list);
-//    }
-//
-//    /**
-//     * 某机构下包含某业务域的警员
-//     */
-//    @PostMapping(value = "police/businessInclude")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "orgIds", value = "机构id"),
-//            @ApiImplicitParam(name = "business", value = "选择的业务域"),
-//    })
-//    @ApiOperation(value = "业务域中已包含的用户")
-//    public Result businessInclude(@RequestBody BusinessVo businessVo) {
-//        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
-//        String orgId = businessVo.getOrgId();
-//        String business = businessVo.getBusiness();
-//        if (StringUtils.isEmpty(orgId) || StringUtils.isEmpty(business)) {
-//            return Result.success(list);
-//        }
-//        Searchable searchable = new SearchRequest();
-//        SecurityUser securityUser = (SecurityUser) ContextUtils.getUserInfo();
-//        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
-//        searchable.addSearchFilter("orgId", SearchOperator.eq, orgId);
-//        searchable.addSearchFilter("policeBusiness", SearchOperator.like, business);
-//        searchable.addSearchFilter("id", SearchOperator.ne, securityUser.getId());
-//        SearchDTO searchDTO = searchable.toSearchDTO();
-//        List<UserInfoView> userList = userInfoFacade.roleInfoList(searchDTO);
-//        for (UserInfoView userInfo : userList) {
-//            Map<String, String> map = new HashMap<String, String>();
-//            map.put("code", userInfo.getId());
-//            map.put("value", userInfo.getName());
-//            list.add(map);
-//        }
-//        return Result.success(list);
-//    }
-//
-//    /**
-//     * 保存机构警员业务域
-//     *
-//     * @return
-//     */
-//    @PostMapping(value = "police/business")
-//    @ApiImplicitParams({
-//            @ApiImplicitParam(name = "orgIds", value = "机构id"),
-//            @ApiImplicitParam(name = "business", value = "选择的业务域"),
-//            @ApiImplicitParam(name = "selectId", value = "已选警员id,用逗号隔开"),
-//            @ApiImplicitParam(name = "availableId", value = "未选警员id,用逗号隔开")
-//    })
-//    @ApiOperation(value = "业务域保存配置")
-//    public Result saveBusiness(@RequestBody BusinessVo businessVo ) {
-//        try {
-//            String orgId = businessVo.getOrgId();
-//            String business = businessVo.getBusiness();
-//            String select = businessVo.getSelectId();
-//            String available = businessVo.getAvailableId();
-//            userInfoFacade.saveBusiness(orgId, business, select, available);
-//        } catch (Exception e) {
-//            logger.error(e.getMessage(), e);
-//            return Result.success("保存失败");
-//        }
-//        return Result.success("保存成功");
-//    }
-//    /**
-//     * 模板
-//     * @return
-//     */
-//    private String template(){
-//        return "[{\"name\":\"name\",\"displyName\":\"姓名\"},{\"name\":\"policeNumber\",\"displyName\":\"警号\"}," +
-//                "{\"name\":\"idcard\",\"displyName\":\"身份证\"}," +
-//                "{\"name\":\"orgCode\",\"displyName\":\"单位机构代码\"}," +
-//                "{\"name\":\"mobileWork\",\"displyName\":\"手机号码(接收短信验证码)\"}," +
-//                "{\"name\":\"nation\",\"displyName\":\"民族(表码)\"}," +
-//                "{\"name\":\"mobilePrivate\",\"displyName\":\"手机号码(私人)\"}," +
-//                "{\"name\":\"manType\",\"displyName\":\"人员类型(表码)\"}," +
-//                "{\"name\":\"rank\",\"displyName\":\"警衔(表码)\"}," +
-//                "{\"name\":\"title\",\"displyName\":\"职级(表码)\"}," +
-//                "{\"name\":\"postType\",\"displyName\":\"职务\"},{\"name\":\"jobType\",\"displyName\":\"在职类型(表码)\"}," +
-//                "{\"name\":\"policeCategory\",\"displyName\":\"警种(表码)\"}" +
-//                "]";
-//    }
-//
-////    private String returnStr(String type) {
-////        if ("toAuxiliary".equals(type)) {
-////            return "/usermanagement/auxiliarypolice/auxiliaryPoliceEdit";
-////        } else if ("toExternal".equals(type)) {
-////            return "/usermanagement/externalpersonnel/externalPersonnelEdit";
-////        }
-////        return "";
-////    }
-//
-//    /**
-//     * copy UserInfo
-//     * @param userVo
-//     * @param info
-//     * @throws IllegalAccessException
-//     * @throws InvocationTargetException
-//     */
-//    public void setUser(PoliceInVo userVo, UserInfo info) throws IllegalAccessException, InvocationTargetException {
-//        BeanUtils.copyProperties(info, userVo);
-//        // info.setBirth(isNotEmpty(info.getBirth())?info.getBirth().replaceAll("-","").substring(0,8):"");
-//        List<PostInfo> postInfos = UserUtils.copyObjectList(userVo.getPostInfos());
-//        info.setPostInfos(postInfos);
-//        info.setFileHolders(userVo.getFile());
-//    }
-//
-//
-//    //    private UserInfo returnUser(String id, String type) {
-////        UserInfo userInfo = userInfoFacade.userDetail(id);
-////        userInfo.setCreateTime(new Date());
-////        userInfo.setCreateTimeStr(ContactUtils.getDate(new Date()));
-////        BigDecimal num = new BigDecimal(1);
-////        if ("toExternal".equals(type)) {
-////            String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.EXTERNAL.getValue());
-////            int pn = Integer.valueOf(policeNumber.substring(2, policeNumber.length())) + 1;
-////            userInfo.setPoliceNumber("WB" + String.format("%06d", pn));
-////            BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.EXTERNAL.getValue()).add(num);
-////            userInfo.setSortNo(sort);
-////        } else if ("toAuxiliary".equals(type)) {
-////            String policeNumber = userInfoFacade.policeNumber(UserTypeEnum.HELPER.getValue());
-////            int pn = Integer.valueOf(policeNumber.substring(2, policeNumber.length())) + 1;
-////            userInfo.setPoliceNumber("FJ" + String.format("%06d", pn));
-////            BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.HELPER.getValue()).add(num);
-////            userInfo.setSortNo(sort);
-////        }
-////
-////        return userInfo;
-////    }
-////
-////
-////
-////    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 = orgInfoFacade.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;
-////    }
-////
-////
-//    public List<UserInfoView> queryPolice(SearchDTO searchDTO) {
-//        Searchable searchable = Searchable.toSearchable(searchDTO);
-//        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
-//        searchDTO = searchable.toSearchDTO();
-//        List<UserInfoView> list = userInfoFacade.userPageExcel(searchDTO).getContent();
-//        return list;
-//    }
-//
-//
-//    public String impPolice(List<UserInfo> list) {
-//        List<String> orgMgeMt = iUserMtAuthFacade.mgeUserRightRangeList(ContextUtils.getUserInfo().getId());
-//        BigDecimal num = new BigDecimal(1);
-//        BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.POLICE.getValue()).add(num);
-//        for (UserInfo info : list) {
-//            OrgInfo orgInfo = orgInfoFacade.getOrgInfoByCode(info.getOrgCode());
-//            if (orgInfo == null) {
-//                throw new NumberFormatException("身份证" + info.getIdcard() + "用户的单位机构代码不存在!");
-//            }
-//            if (!AuthUtils.isHaveAuth(orgMgeMt, orgInfo)&&!userInfoFacade.isRootUser(ContextUtils.getUserInfo().getId())) {
-//                throw new NumberFormatException("没有身份证" + info.getIdcard() + "用户所填写单位机构代码的管理权限!");
+//        for (NoticeUserVO noticeUserVO : targetList) {
+//            if (map.get(noticeUserVO.getUserId()) == null) {
+//                map.put(noticeUserVO.getUserId(), noticeUserVO);
+//                list.add(noticeUserVO);
 //            }
-//            info.setSortNo(sort);
-//            info.setOrgId(orgInfo.getId());
-//            info.setOrgName(orgInfo.getFullName());
-//            info.setOrgCode(orgInfo.getCode());
-//            info.setOrgLevel(orgInfo.getOrgLevel());
-//            //默认导入单位为编制单位,佛山地区使用该字段
-//            sort = sort.add(num);
 //        }
-//        return userInfoFacade.impPoliceGd(list);
+//        return list;
 //    }
 //
 //
-//
-//
-//
-//}
+    public List<UserInfoView> queryPolice(SearchDTO searchDTO) {
+        Searchable searchable = Searchable.toSearchable(searchDTO);
+        searchable.addSearchFilter("userType", SearchOperator.eq, UserTypeEnum.POLICE.getValue());
+        searchDTO = searchable.toSearchDTO();
+        List<UserInfoView> list = userInfoFacade.userPageExcel(searchDTO).getContent();
+        return list;
+    }
+
+
+    public String impPolice(List<UserInfo> list) {
+        List<String> orgMgeMt = iUserMtAuthFacade.mgeUserRightRangeList(ContextUtils.getUserInfo().getId());
+        BigDecimal num = new BigDecimal(1);
+        BigDecimal sort = userInfoFacade.sortNew(UserTypeEnum.POLICE.getValue()).add(num);
+        for (UserInfo info : list) {
+            OrgInfo orgInfo = orgInfoFacade.getOrgInfoByCode(info.getOrgCode());
+            if (orgInfo == null) {
+                throw new NumberFormatException("身份证" + info.getIdcard() + "用户的单位机构代码不存在!");
+            }
+            if (!AuthUtils.isHaveAuth(orgMgeMt, orgInfo)&&!userInfoFacade.isRootUser(ContextUtils.getUserInfo().getId())) {
+                throw new NumberFormatException("没有身份证" + info.getIdcard() + "用户所填写单位机构代码的管理权限!");
+            }
+            info.setSortNo(sort);
+            info.setOrgId(orgInfo.getId());
+            info.setOrgName(orgInfo.getFullName());
+            info.setOrgCode(orgInfo.getCode());
+            info.setOrgLevel(orgInfo.getOrgLevel());
+            //默认导入单位为编制单位,佛山地区使用该字段
+            sort = sort.add(num);
+        }
+        return userInfoFacade.impPoliceGd(list);
+    }
+
+
+
+
+
+}

+ 203 - 14
src/main/java/com/dragoninfo/dcuc/authweb/util/UserUtils.java

@@ -1,10 +1,27 @@
 package com.dragoninfo.dcuc.authweb.util;
 
+import com.dragoninfo.dcuc.authweb.restcontroller.user.vo.PostInfoVo;
+import com.dragoninfo.dcuc.org.entity.OrgInfo;
+import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
+import com.dragoninfo.dcuc.user.user.entity.PostInfo;
+import com.dragoninfo.dcuc.user.user.entity.UserInfo;
+import com.dragoninfo.dcuc.user.user.entity.UserInfoView;
+import com.dragoninfo.dcuc.user.user.enumresources.AuxiliaryTypeEnum;
+import com.dragoninfo.dcuc.user.user.enumresources.JobTypeEnum;
+import com.dragoninfo.dcuc.user.user.enumresources.UserTypeEnum;
+import com.dragoninfo.dcuc.user.user.facade.IUserInfoFacade;
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.commons.util.bean.BeanUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.commons.util.json.JsonUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import net.sf.ezmorph.bean.MorphDynaBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.InvocationTargetException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -14,25 +31,39 @@ import java.util.regex.Pattern;
 public class UserUtils {
     private static Logger logger = LoggerFactory.getLogger(UserUtils.class);
 
-     /*
-     * 对象复制
+    public static String getSysUserListId() {
+        return "00000000000000000000000000000000";
+    }
+
+
+    /**
+     * 职务信息
      *
-     * @param obj1 需复制的对象
-     * @param obj2 被复制的对象
+     * @param json
      * @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);
+    public static List<PostInfo> fromJson(String json) {
+        List<PostInfo> postInfos = new ArrayList<PostInfo>();
+        Object[] objects = JsonUtils.toArray(json);
+        for (int i = 0; i < objects.length; i++) {
+            MorphDynaBean morphDynaBean = (MorphDynaBean) objects[i];
+            PostInfo pInfo = new PostInfo();
+            String id = "";
+            if (morphDynaBean.toString().indexOf("id") != -1) {
+                id = (String) morphDynaBean.get("id");
+                pInfo.setId(id);
+            }
+            String orgId = (String) morphDynaBean.get("orgId");
+            String postType = (String) morphDynaBean.get("postType");
+            String jobType = (String) morphDynaBean.get("jobType");
+            pInfo.setOrgId(orgId);
+            pInfo.setPostType(postType);
+            pInfo.setJobType(jobType);
+            postInfos.add(pInfo);
         }
-        return obj1;
+        return postInfos;
     }
 
-
     /**
      * 正则身份证校验
      *
@@ -104,7 +135,6 @@ public class UserUtils {
         return matches;
     }
 
-
     public static boolean checkEmaile(String emaile) {
         String RULE_EMAIL = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
         //正则表达式的模式 编译正则表达式
@@ -115,6 +145,165 @@ public class UserUtils {
         return m.matches();
     }
 
+    /**
+     * 放入用户部门、层级、所在机构区划
+     *
+     * @param list
+     * @param info
+     * @return
+     */
+    public static UserInfo setUserOrg(IOrgInfoFacade orgInfoFacade, List<PostInfo> list, UserInfo info) {
+        String postId = "";
+        String orgId = "";
+        int jobType = Integer.MAX_VALUE;
+        for (PostInfo postinfo : list) {
+            String type = postinfo.getJobType();
+            //确定警员的单位依次按 JobTypeEnum code 从小到大
+            if (StringUtils.isNotEmpty(type) && Integer.parseInt(type) < jobType) {
+                orgId = postinfo.getOrgId();
+                jobType = Integer.parseInt(postinfo.getJobType());
+            }
+            if (StringUtils.isNotEmpty(postinfo.getId())) {
+                postId += postinfo.getId() + ",";
+            }
+            //设置职位机构名称
+            OrgInfo orgInfo = orgInfoFacade.detail(postinfo.getOrgId());
+            postinfo.setOrgName(orgInfo.getFullName());
+            if (JobTypeEnum.FP.getValue().equals(type)) {
+                info.setUserType(UserTypeEnum.HELPER.getValue());
+                info.setAuxiliaryType(AuxiliaryTypeEnum.FP.getValue());
+                orgId = postinfo.getOrgId();
+                break;
+            }
+        }
+        OrgInfo orgInfo = orgInfoFacade.detail(orgId);
+        info.setOrgId(orgId);
+        info.setOrgName(orgInfo.getFullName());
+        //添加层级
+        info.setOrgLevel(orgInfo.getOrgLevel());
+        info.setOrgCode(orgInfo.getCode());
+        info.setJobType(postId);
+        info.setDeleted("0");
+        return info;
+    }
+
+    /**
+     * 对象复制
+     *
+     * @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;
+    }
+
+
+
+
+    public static List<PostInfo> copyObjectList(List<PostInfoVo> postInfos) {
+
+        List<PostInfo> objects = new ArrayList<>();
+        if (CollectionUtils.isEmpty(postInfos))return objects;
+        for (PostInfoVo postInfoVo : postInfos) {
+            PostInfo postInfo1 = new PostInfo();
+            try {
+                BeanUtils.copyProperties(postInfo1,postInfoVo);
+            } catch (IllegalAccessException e) {
+                logger.error("属性拷贝异常",e);
+            } catch (InvocationTargetException e) {
+                logger.error("属性拷贝异常",e);
+            }
+            objects.add(postInfo1);
+        }
+        return objects;
+    }
+
+    public static List<PostInfoVo> copyObjectByVo(List<PostInfo> postInfos) {
+        List<PostInfoVo> objects = new ArrayList<>();
+        for (PostInfo postInfo : postInfos) {
+            PostInfoVo postInfo1 = new PostInfoVo();
+            try {
+                BeanUtils.copyProperties(postInfo1,postInfo);
+            } catch (IllegalAccessException e) {
+                logger.error("属性拷贝异常",e);
+            } catch (InvocationTargetException e) {
+                logger.error("属性拷贝异常",e);
+            }
+            objects.add(postInfo1);
+        }
+        return objects;
+    }
+
+    /**
+     * 日期转换
+     * @param date
+     * @return
+     */
+    public static String transformDate(Date date){
+        if (date==null)return "";
+        SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd");
+        String newdate=dateformat.format(date);
+        return newdate;
+    }
+    /**
+     * 8,14位日期转换
+     * @param date
+     * @return
+     */
+    public static String birthTransform(String date,String bit){
+        String newdate = date;
+        if (StringUtils.isEmpty(date))return "";
+        if(bit.equals("8"))
+        {/*8位日期转换*/
+            newdate=date.substring(0,4)+"-"+ date.substring(4,6)+"-"+date.substring(6,8);
+        } if(bit.equals("14")){
+            /*14位日期转换*/
+            newdate=date.substring(0,4)+"-"+ date.substring(4,6)+"-"+date.substring(6,8)+" "+date.substring(8,10)+":"+date.substring(10,12)+":"+date.substring(12,14);
+        }if(bit.equals("10")){
+            /*14位日期转换*/
+            newdate=date.substring(0,4)+"-"+ date.substring(4,6)+"-"+date.substring(6,8)+" "+date.substring(8,10)+":"+date.substring(10,12)+":"+date.substring(12,14);
+        }
+        return newdate;
+    }
+
+
+
+    /**
+     * 验证身份证
+
+     * @param info
+     * @return
+     */
+    public static Boolean verificaIdcard(UserInfo info, IUserInfoFacade userInfoFacade) {
+        if (StringUtils.isNotEmpty(info.getIdcard())){
+            Map map=new HashMap();
+            map.put("userId",info.getId());
+            map.put("idcard",info.getIdcard());
+            ResponseStatus responseStatus = userInfoFacade.checkIdcard(map);
+            return !"200".equals(responseStatus.getStatusCode());
+        }
+        return false;
+    }
+
+    /**
+     * 验证姓名
+
+     * @param info
+     * @return
+     */
+    public static Boolean verificaName(UserInfo info){
+        return "ADMIN".equals(info.getName().trim());
+    }
+
+
 
 
 }