forked from integrated_whb/integrated_whb
460 lines
17 KiB
Java
460 lines
17 KiB
Java
|
package com.zcloud.controller.system;
|
|||
|
|
|||
|
import com.zcloud.controller.base.BaseController;
|
|||
|
import com.zcloud.entity.Page;
|
|||
|
import com.zcloud.entity.PageData;
|
|||
|
import com.zcloud.entity.system.Department;
|
|||
|
import com.zcloud.logs.LogAnno;
|
|||
|
import com.zcloud.service.prevention.ListManagerService;
|
|||
|
import com.zcloud.service.system.DepartmentService;
|
|||
|
import com.zcloud.service.system.SupervisionDepartmentService;
|
|||
|
import com.zcloud.service.system.UsersService;
|
|||
|
import com.zcloud.util.DateUtil;
|
|||
|
import com.zcloud.util.Jurisdiction;
|
|||
|
import com.zcloud.util.Tools;
|
|||
|
import net.sf.json.JSONArray;
|
|||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
import org.springframework.stereotype.Controller;
|
|||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|||
|
import org.springframework.web.bind.annotation.RequestParam;
|
|||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
|
|||
|
import java.util.*;
|
|||
|
|
|||
|
/**
|
|||
|
* 说明:组织机构
|
|||
|
* 作者:luoxiaobao
|
|||
|
* 官网:www.fhadmin. org
|
|||
|
*/
|
|||
|
@Controller
|
|||
|
@RequestMapping("/department")
|
|||
|
public class DepartmentController extends BaseController {
|
|||
|
|
|||
|
@Autowired
|
|||
|
private DepartmentService departmentService;
|
|||
|
@Autowired
|
|||
|
private UsersService usersService;
|
|||
|
@Autowired
|
|||
|
private ListManagerService listManagerService;
|
|||
|
@Autowired
|
|||
|
private SupervisionDepartmentService supervisionDepartmentService;
|
|||
|
|
|||
|
/**新增
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/add")
|
|||
|
@RequiresPermissions("department:add")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "新增")
|
|||
|
public Object add() throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
pd.put("DEPARTMENT_ID", this.get32UUID()); //主键
|
|||
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
|||
|
departmentService.save(pd);
|
|||
|
// 存储监管单位
|
|||
|
if(pd != null && pd.get("ISSUPERVISE") != null
|
|||
|
&& Tools.notEmpty(pd.get("ISSUPERVISE").toString())
|
|||
|
&& "1".equals(pd.get("ISSUPERVISE").toString())
|
|||
|
&& pd.get("checkedIds") != null
|
|||
|
&& Tools.notEmpty(pd.get("checkedIds").toString())
|
|||
|
&& pd.get("checkedIds").toString().length() > 0) {
|
|||
|
|
|||
|
|
|||
|
String checkedIds[] = pd.get("checkedIds").toString().split(",");
|
|||
|
for(String subId : checkedIds) {
|
|||
|
PageData sd = new PageData();
|
|||
|
sd.put("SUPERVISIONDEPARTMENT_ID", this.get32UUID());
|
|||
|
sd.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
|
|||
|
sd.put("SUB_DEPARTMENT_ID", subId);
|
|||
|
sd.put("ISDELETE", "0");
|
|||
|
sd.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
|
|||
|
sd.put("CREATOR", Jurisdiction.getName()); // 添加人
|
|||
|
sd.put("CREATTIME", DateUtil.date2Str(new Date())); // 创建时间
|
|||
|
sd.put("OPERATOR", Jurisdiction.getName()); // 修改人
|
|||
|
sd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
|||
|
supervisionDepartmentService.save(sd);
|
|||
|
}
|
|||
|
}
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 删除
|
|||
|
* @param DEPARTMENT_ID
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/delete")
|
|||
|
@RequiresPermissions("department:del")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "删除")
|
|||
|
public Object delete(@RequestParam String DEPARTMENT_ID) throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd.put("DEPARTMENT_ID", DEPARTMENT_ID);
|
|||
|
if(departmentService.listSubDepartmentByParentId(DEPARTMENT_ID).size() > 0){//判断是否有子级,是:不允许删除
|
|||
|
errInfo = "haveChild";
|
|||
|
map.put("msg", "该部门有下级部门,请先删除下级部门"); //返回结果
|
|||
|
} else if(usersService.listUserbyDep(pd).size() > 0) {
|
|||
|
errInfo = "haveUser";
|
|||
|
map.put("msg", "该部门有用户,请先删除用户"); //返回结果
|
|||
|
} else if(listManagerService.listListByDep(pd).size() > 0) {
|
|||
|
errInfo = "havelist";
|
|||
|
map.put("msg", "该部门有清单,请先删除清单"); //返回结果
|
|||
|
}else{
|
|||
|
departmentService.delete(pd); //执行删除
|
|||
|
}
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**修改
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/edit")
|
|||
|
@RequiresPermissions("department:edit")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "修改")
|
|||
|
public Object edit() throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
departmentService.edit(pd);
|
|||
|
// 删除旧的监管单位
|
|||
|
PageData pd2 = new PageData();
|
|||
|
pd2.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
|
|||
|
pd2.put("OPERATOR", Jurisdiction.getName()); // 修改人
|
|||
|
pd2.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
|||
|
supervisionDepartmentService.deleteByDept(pd2);
|
|||
|
// 存储监管单位
|
|||
|
if(pd != null && pd.get("ISSUPERVISE") != null
|
|||
|
&& Tools.notEmpty(pd.get("ISSUPERVISE").toString())
|
|||
|
&& "1".equals(pd.get("ISSUPERVISE").toString())
|
|||
|
&& pd.get("checkedIds") != null
|
|||
|
&& Tools.notEmpty(pd.get("checkedIds").toString())
|
|||
|
&& pd.get("checkedIds").toString().length() > 0) {
|
|||
|
String checkedIds[] = pd.get("checkedIds").toString().split(",");
|
|||
|
for(String subId : checkedIds) {
|
|||
|
PageData sd = new PageData();
|
|||
|
sd.put("SUPERVISIONDEPARTMENT_ID", this.get32UUID());
|
|||
|
sd.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
|
|||
|
sd.put("SUB_DEPARTMENT_ID", subId);
|
|||
|
sd.put("ISDELETE", "0");
|
|||
|
sd.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
|
|||
|
sd.put("CREATOR", Jurisdiction.getName()); // 添加人
|
|||
|
sd.put("CREATTIME", DateUtil.date2Str(new Date())); // 创建时间
|
|||
|
sd.put("OPERATOR", Jurisdiction.getName()); // 修改人
|
|||
|
sd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
|||
|
supervisionDepartmentService.save(sd);
|
|||
|
}
|
|||
|
}
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**列表
|
|||
|
* @param page
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/list")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "列表")
|
|||
|
public Object list(Page page) throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
String CORPINFO_ID = Jurisdiction.getCORPINFO_ID();
|
|||
|
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
|
|||
|
if(Tools.notEmpty(KEYWORDS))pd.put("keywords", KEYWORDS.trim());
|
|||
|
String DEPARTMENT_ID = null == pd.get("DEPARTMENT_ID")?"":pd.get("DEPARTMENT_ID").toString();
|
|||
|
pd.put("DEPARTMENT_ID", DEPARTMENT_ID); //当作上级ID
|
|||
|
pd.put("CORPINFO_ID", CORPINFO_ID); //当作上级ID
|
|||
|
pd.put("ISMAIN", Jurisdiction.getIS_MAIN());
|
|||
|
pd.put("ISSUPERVISE", Jurisdiction.getISSUPERVISE());
|
|||
|
if(pd.get("ISSUPERVISE").equals(1) && pd.get("DEPARTMENT_ID")==null){
|
|||
|
pd.put("DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID());
|
|||
|
|
|||
|
} else {
|
|||
|
pd.put("SELECT_DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID());
|
|||
|
|
|||
|
}
|
|||
|
String DEPTIDS = pd.getString("DEPTIDS");
|
|||
|
if(Tools.notEmpty(DEPTIDS)) {
|
|||
|
String DEPT_IDS[] = DEPTIDS.split(",");
|
|||
|
pd.put("DEPT_IDS", DEPT_IDS);
|
|||
|
}
|
|||
|
page.setPd(pd);
|
|||
|
List<PageData> varList = departmentService.listForLevelName(page); //列出Department列表
|
|||
|
if("".equals(DEPARTMENT_ID) || "0".equals(DEPARTMENT_ID)) {
|
|||
|
map.put("PARENT_ID", "0"); //上级ID
|
|||
|
}else {
|
|||
|
map.put("PARENT_ID", departmentService.findById(pd).getString("PARENT_ID")); //上级ID
|
|||
|
}
|
|||
|
map.put("varList", varList);
|
|||
|
map.put("page", page);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 显示列表ztree
|
|||
|
* @return
|
|||
|
*/
|
|||
|
@RequestMapping(value="/listTree")
|
|||
|
@RequiresPermissions("department:list")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "显示列表")
|
|||
|
public Object listTree()throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
String url = pd.get("url")==null?"department_list.html?DEPARTMENT_ID=":pd.getString("url");
|
|||
|
|
|||
|
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
|
|||
|
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
|
|||
|
// List<Department> zdepartmentPdList = new ArrayList<Department>();
|
|||
|
//
|
|||
|
// PageData dept = new PageData();
|
|||
|
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
|
|||
|
// dept=this.departmentService.findById(dept);
|
|||
|
|
|||
|
//获取部门下拉树
|
|||
|
List<Department> zdepartmentPdList = new ArrayList<Department>();
|
|||
|
PageData dept = new PageData();
|
|||
|
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|||
|
dept=this.departmentService.findByCorpId(dept);
|
|||
|
|
|||
|
Department depar = new Department();
|
|||
|
depar.setDEPARTMENT_ID(dept.getString("DEPARTMENT_ID"));
|
|||
|
depar.setPARENT_ID(dept.getString("PARENT_ID"));
|
|||
|
depar.setNAME(dept.getString("NAME"));
|
|||
|
depar.setDISABLED(true);
|
|||
|
depar.setTreeurl(url+depar.getDEPARTMENT_ID());
|
|||
|
PageData pd2 = new PageData();
|
|||
|
pd2.put("parentId", depar.getDEPARTMENT_ID());
|
|||
|
pd2.put("SUP_DEPARTMENT_ID", Jurisdiction.getDEPARTMENT_ID());
|
|||
|
String isMain = Jurisdiction.getIS_MAIN();
|
|||
|
pd.put("USER_ID",Jurisdiction.getUSER_ID());
|
|||
|
PageData cpd = new PageData();
|
|||
|
PageData npd = new PageData();
|
|||
|
cpd = usersService.findById(pd);
|
|||
|
if(cpd.getString("ISLEADER") != null && cpd.getString("ISLEADER").equals("1")){
|
|||
|
String DEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
|
|||
|
String ids = departmentService.getDEPARTMENT_IDS(DEPARTMENT_ID);
|
|||
|
ids=Jurisdiction.getDEPARTMENT_ID()+","+ids; //把自己部门插入进去
|
|||
|
if(ids!=null && Tools.notEmpty(ids)&& ids.lastIndexOf(",")>-1) {
|
|||
|
ids = ids.substring(0,ids.lastIndexOf(","));
|
|||
|
pd2.put("DEPARTMENT_IDS", ids.split(","));
|
|||
|
}else {
|
|||
|
pd2.put("DEPARTMENT_IDS", DEPARTMENT_ID);
|
|||
|
}
|
|||
|
}
|
|||
|
pd2.put("ISLEADER",cpd.getString("ISLEADER"));
|
|||
|
depar.setSubDepartment(this.departmentService.listAllDep(pd2,url,isMain));
|
|||
|
|
|||
|
depar.setTarget("treeFrame");
|
|||
|
depar.setIcon("../../../assets/images/user.gif");
|
|||
|
zdepartmentPdList.add(depar);
|
|||
|
// zdepartmentPdList.addAll(departmentService.listAllDepartment(ZDEPARTMENT_ID));
|
|||
|
JSONArray arr = JSONArray.fromObject(zdepartmentPdList);
|
|||
|
String json = arr.toString();
|
|||
|
json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url").replaceAll("DISABLED", "disabled");
|
|||
|
|
|||
|
map.put("USER_ID", Jurisdiction.getUSER_ID());
|
|||
|
map.put("zTreeNodes", json);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* 显示列表ztree
|
|||
|
* @return
|
|||
|
*/
|
|||
|
@RequestMapping(value="/listzTree")
|
|||
|
@RequiresPermissions("department:list")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "显示列表")
|
|||
|
public Object listzTree()throws Exception{
|
|||
|
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
String url = pd.get("url")==null?"department_list.html?DEPARTMENT_ID=":pd.getString("url");
|
|||
|
|
|||
|
// String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID();
|
|||
|
// ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID;
|
|||
|
// List<Department> zdepartmentPdList = new ArrayList<Department>();
|
|||
|
//
|
|||
|
// PageData dept = new PageData();
|
|||
|
// dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID);
|
|||
|
// dept=this.departmentService.findById(dept);
|
|||
|
|
|||
|
//获取部门下拉树
|
|||
|
List<Department> zdepartmentPdList = new ArrayList<Department>();
|
|||
|
PageData dept = new PageData();
|
|||
|
dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|||
|
dept=this.departmentService.findByCorpId(dept);
|
|||
|
|
|||
|
Department depar = new Department();
|
|||
|
depar.setDEPARTMENT_ID(dept.getString("DEPARTMENT_ID"));
|
|||
|
depar.setPARENT_ID(dept.getString("PARENT_ID"));
|
|||
|
depar.setNAME(dept.getString("NAME"));
|
|||
|
depar.setTreeurl(url+depar.getDEPARTMENT_ID());
|
|||
|
depar.setSubDepartment(this.departmentService.listAllDepartment(depar.getDEPARTMENT_ID(),url));
|
|||
|
depar.setTarget("treeFrame");
|
|||
|
depar.setIcon("../../../assets/images/user.gif");
|
|||
|
zdepartmentPdList.add(depar);
|
|||
|
// zdepartmentPdList.addAll(departmentService.listAllDepartment(ZDEPARTMENT_ID));
|
|||
|
JSONArray arr = JSONArray.fromObject(zdepartmentPdList);
|
|||
|
String json = arr.toString();
|
|||
|
json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url");
|
|||
|
|
|||
|
map.put("USER_ID", Jurisdiction.getUSER_ID());
|
|||
|
map.put("zTreeNodes", json);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/**去新增页面
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/goAdd")
|
|||
|
@RequiresPermissions("department:add")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "去新增页面")
|
|||
|
public Object goAdd()throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
String DEPARTMENT_ID = null == pd.get("DEPARTMENT_ID")?"":pd.get("DEPARTMENT_ID").toString();
|
|||
|
pd.put("DEPARTMENT_ID", DEPARTMENT_ID); //上级ID
|
|||
|
map.put("pds",departmentService.findById(pd)); //传入上级所有信息
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**去修改页面
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/goEdit")
|
|||
|
@RequiresPermissions("department:edit")
|
|||
|
@ResponseBody
|
|||
|
@LogAnno(menuType= "双重预防",menuServer= "企业管理",instructionsOperate = "组织机构",instructionsType = "去修改页面获取信息")
|
|||
|
public Object goEdit()throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
pd = departmentService.findById(pd); //根据ID读取
|
|||
|
|
|||
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|||
|
pd.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
|
|||
|
List<PageData> varlist = supervisionDepartmentService.listAll(pd); //根据ID读取
|
|||
|
map.put("pd", pd); //放入视图容器
|
|||
|
map.put("varlist", varlist);
|
|||
|
PageData supPd = new PageData();
|
|||
|
supPd.put("DEPARTMENT_ID", pd.get("PARENT_ID").toString());
|
|||
|
//pd.put("DEPARTMENT_ID",pd.get("PARENT_ID").toString()); //用作上级信息
|
|||
|
map.put("pds",departmentService.findById(supPd)); //传入上级所有信息
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**判断编码是否存在
|
|||
|
* @return
|
|||
|
*/
|
|||
|
@RequestMapping(value="/hasBianma")
|
|||
|
@ResponseBody
|
|||
|
public Object hasBianma() throws Exception{
|
|||
|
Map<String,String> map = new HashMap<String,String>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
if(departmentService.findByBianma(pd) != null){
|
|||
|
errInfo = "error";
|
|||
|
}
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
/** 判断部门等级 如果没有上一级就是1
|
|||
|
* @return
|
|||
|
*/
|
|||
|
@RequestMapping(value="/parentGrade")
|
|||
|
@ResponseBody
|
|||
|
public Object parentGrade () throws Exception{
|
|||
|
Map<String,String> map = new HashMap<String,String>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
|
|||
|
String deptGrade = getparentId(pd.getString("deptGrade")) +"";
|
|||
|
map.put("deptGrade", deptGrade);
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
/**
|
|||
|
* @return
|
|||
|
*/
|
|||
|
public Integer getparentId (String parentId) throws Exception {
|
|||
|
Integer parentGrade =1;
|
|||
|
|
|||
|
PageData parentDepePd = new PageData();
|
|||
|
parentDepePd.put("DEPARTMENT_ID", parentId);
|
|||
|
PageData parent = departmentService.findById(parentDepePd);
|
|||
|
if(!Tools.isEmpty(parent)) {
|
|||
|
parentId = parent.getString("PARENT_ID");
|
|||
|
if(!"0".equals(parentId)) {
|
|||
|
parentGrade = getparentId(parentId);
|
|||
|
parentGrade ++;
|
|||
|
}
|
|||
|
}
|
|||
|
return parentGrade ;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/**判断同等级的名字是否重复
|
|||
|
* @return
|
|||
|
*/
|
|||
|
@RequestMapping(value="/hasName")
|
|||
|
@ResponseBody
|
|||
|
public Object hasName() throws Exception{
|
|||
|
Map<String,String> map = new HashMap<String,String>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
|
|||
|
PageData parentDepePd = new PageData();
|
|||
|
parentDepePd.put("NAME", pd.getString("name"));
|
|||
|
parentDepePd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|||
|
parentDepePd.put("ISEDIT", "1");
|
|||
|
parentDepePd.put("DEPARTMENT_ID", pd.get("DEPARTMENT_ID"));
|
|||
|
//就是父id相同的名字
|
|||
|
PageData parent = departmentService.findByName(parentDepePd);
|
|||
|
if(!Tools.isEmpty(parent)) {
|
|||
|
errInfo = "error";
|
|||
|
}
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|