组织架构列表
This commit is contained in:
parent
009a668d14
commit
a699eae348
|
|
@ -1,9 +1,12 @@
|
|||
package com.weaver.seconddev.jcl.organization.controller;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.emonitor.bean.WeaResult;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.component.table.AbstractWeaTable;
|
||||
import com.weaver.seconddev.jcl.common.web.BaseCommonController;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Department;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Employee;
|
||||
|
|
@ -35,11 +38,11 @@ public class ChangeOrganzationController extends BaseCommonController {
|
|||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/addOrganaztionDepartment")
|
||||
public Map<String, Object> addOrganaztionDepartment(@RequestBody Department department){
|
||||
public WeaResult<Map<String, Object>> addOrganaztionDepartment(@RequestBody Department department){
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
organaztionService.addOrganaztionDepartment(department,this.getCurrentUser());
|
||||
|
||||
return actionMap;
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
/**
|
||||
* 删除员工部门
|
||||
|
|
@ -48,11 +51,11 @@ public class ChangeOrganzationController extends BaseCommonController {
|
|||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/delOrganaztionDepartment")
|
||||
public Map<String, Object> delOrganaztionDepartment(@RequestBody Department department){
|
||||
public WeaResult<Map<String, Object>> delOrganaztionDepartment(@RequestBody Department department){
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
organaztionService.delOrganaztionDepartment(department,this.getCurrentUser());
|
||||
|
||||
return actionMap;
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
/**
|
||||
* 修改员工部门
|
||||
|
|
@ -61,11 +64,75 @@ public class ChangeOrganzationController extends BaseCommonController {
|
|||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/updateOrganaztionDepartment")
|
||||
public Map<String, Object> updateOrganaztionDepartment(@RequestBody Department department){
|
||||
public WeaResult<Map<String, Object>> updateOrganaztionDepartment(@RequestBody Department department){
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
organaztionService.updateOrganaztionDepartment(department,this.getCurrentUser());
|
||||
|
||||
return actionMap;
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
/**
|
||||
* 合并员工部门
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/mergeOrganaztionDepartment")
|
||||
public WeaResult<Map<String, Object>> mergeOrganaztionDepartment(@RequestBody Department department){
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
organaztionService.mergeOrganaztionDepartment(department,this.getCurrentUser());
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
/**
|
||||
* 拆分员工部门
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/splitOrganaztionDepartment")
|
||||
public WeaResult<Map<String, Object>> splitOrganaztionDepartment(@RequestParam Map<String, Object> params){
|
||||
|
||||
try {
|
||||
organaztionService.splitOrganzationDepartment(params,this.getCurrentUser());
|
||||
}catch (Exception e){
|
||||
|
||||
return WeaResult.fail(e.getMessage(),e);
|
||||
}
|
||||
|
||||
return WeaResult.success(Maps.newHashMap());
|
||||
}
|
||||
/**
|
||||
* 获得部门信息
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/getDepartmentCodeById")
|
||||
public WeaResult<List<Map<String, Object>>> getDepartmentCodeById(@RequestParam("id") String id){
|
||||
List<Map<String, Object>> actionMap = Lists.newArrayList();
|
||||
try {
|
||||
actionMap = organaztionService.getDepartmentCodeById(id);
|
||||
}catch (Exception e){
|
||||
|
||||
return WeaResult.fail(e.getMessage(),e);
|
||||
}
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织列表查询
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@PostMapping("/queryOrganzationTableData")
|
||||
@ResponseBody
|
||||
public WeaResult<AbstractWeaTable> queryOrganzationTableData(@RequestParam Map<String, Object> params){
|
||||
Gson gson = new Gson();
|
||||
log.error("*********queryTableData********");
|
||||
log.error(gson.toJson(params));
|
||||
AbstractWeaTable weaTable = organaztionService.queryOrganzationTableData(this.getCurrentUser(),params);
|
||||
return WeaResult.success(weaTable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
|
|
@ -75,6 +78,4 @@ public class Department {
|
|||
private String sscb;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.weaver.seconddev.jcl.organization.service;
|
||||
|
||||
import com.weaver.common.component.table.AbstractWeaTable;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Department;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface OrganaztionService {
|
||||
|
|
@ -14,4 +16,11 @@ public interface OrganaztionService {
|
|||
void updateOrganaztionDepartment(Department department, SimpleEmployee employee);
|
||||
|
||||
void mergeOrganaztionDepartment(Department department, SimpleEmployee employee);
|
||||
|
||||
void splitOrganzationDepartment(Map<String,Object> param,SimpleEmployee employee);
|
||||
|
||||
List<Map<String, Object>> getDepartmentCodeById(String id);
|
||||
|
||||
AbstractWeaTable queryOrganzationTableData(SimpleEmployee simpleEmployee, Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -807,7 +807,6 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
if (endindex > total){
|
||||
endindex = total;
|
||||
}
|
||||
startindex = endindex-pageSize;
|
||||
if (startindex < 0){
|
||||
startindex = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
package com.weaver.seconddev.jcl.organization.service.impl;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.weaver.common.component.table.AbstractWeaTable;
|
||||
import com.weaver.common.component.table.WeaTable;
|
||||
import com.weaver.common.form.service.IdGeneratorService;
|
||||
import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import com.weaver.seconddev.jcl.common.service.impl.CommonServiceImpl;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Department;
|
||||
import com.weaver.seconddev.jcl.organization.exception.EmployeeJclRunTimeException;
|
||||
import com.weaver.seconddev.jcl.organization.service.OrganaztionService;
|
||||
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DateUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -20,6 +27,7 @@ import java.beans.PropertyDescriptor;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class OrganaztionSeviceImpl implements OrganaztionService {
|
||||
|
|
@ -29,6 +37,7 @@ public class OrganaztionSeviceImpl implements OrganaztionService {
|
|||
private CommonService commonService;
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
private static final Logger log = LoggerFactory.getLogger(OrganaztionSeviceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -61,21 +70,115 @@ public class OrganaztionSeviceImpl implements OrganaztionService {
|
|||
|
||||
@Override
|
||||
public void updateOrganaztionDepartment(Department department, SimpleEmployee employee) {
|
||||
String sql = "select sjzzmc,sjzz,sjzzbh from uf_organization_bghzzsj where bh=?";
|
||||
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(department.getSjzzbh()));
|
||||
String sql = "select bh,zzmc,zz from uf_organization_bghzzsj where bh=? and form_data_id=? ";
|
||||
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(department.getSjzzbh(),department.getForm_data_id()));
|
||||
|
||||
sql = "update uf_organization_bghzzsj set zzmc=?,bmsqcj=?,bmfzr=?,fgld=?,sscb=?,bz=?,sjzzmc=?,sjzz=?,sjzzbh=? where bh=?";
|
||||
sql = "update uf_organization_bghzzsj set zzmc=?,bmsqcj=?,bmfzr=?,fgld=?,sscb=?,bz=?,sjzzmc=?,sjzz=?,sjzzbh=? where bh=? and form_data_id=?";
|
||||
databaseUtils.execute(sql,CommonUtils.getParamList(department.getZzmc(),department.getBmsqcj(),department.getBmfzr(),department.getFgld(),department.getSscb(),department.getBz(),
|
||||
CommonUtils.null2String(dataList.get(0).get("sjzzmc")),CommonUtils.null2String(dataList.get(0).get("sjzz")),CommonUtils.null2String(dataList.get(0).get("sjzzbh")),department.getBh()));
|
||||
CommonUtils.null2String(dataList.get(0).get("zzmc")),CommonUtils.null2String(dataList.get(0).get("zz")),CommonUtils.null2String(dataList.get(0).get("bh")),department.getBh(),department.getForm_data_id()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeOrganaztionDepartment(Department department, SimpleEmployee employee) {
|
||||
String bhbbmid = department.getBhbbmid();
|
||||
String sql = "update uf_organization_bghzzsj set delete_type='1' where bh in (?)";
|
||||
databaseUtils.execute(sql,CommonUtils.getParamList(bhbbmid));
|
||||
String sql = "select id,code from eteams.department where id in ("+bhbbmid+")";
|
||||
log.error("mergeOrganaztionDepartment query sql :"+sql);
|
||||
List<Map<String, Object>> departmentList = databaseUtils.getSqlList(sql);
|
||||
log.error("departmentList : [{}]",departmentList);
|
||||
List<String> departmentStrs = departmentList.stream().map(e->"'"+e.get("code").toString()+"'").collect(Collectors.toList());;
|
||||
|
||||
sql = "update uf_organization_bghzzsj set delete_type='3',is_delete='1' where bh in ("+String.join(",",departmentStrs)+")";
|
||||
log.error("mergeOrganaztionDepartment update sql :"+sql);
|
||||
databaseUtils.execute(sql);
|
||||
addOrganaztionDepartment( department, employee);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void splitOrganzationDepartment(Map<String,Object> param, SimpleEmployee employee) {
|
||||
Gson gson = new Gson();
|
||||
log.error("param : "+param);
|
||||
log.error(gson.toJson(param));
|
||||
String splitDepartment = String.valueOf(param.get("departmentId"));
|
||||
String splitDepartmentCode = String.valueOf(param.get("departmentCode"));
|
||||
String fgldId = String.valueOf(param.get("fgldId"));
|
||||
String sscb = String.valueOf(param.get("sscb"));
|
||||
List<Map<String,Object>> dataList = gson.fromJson(param.get("data").toString(),List.class);
|
||||
|
||||
String sql = "select * from eteams.department where parent=? and delete_type='0'";
|
||||
List<Map<String, Object>> sonDepartmList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(splitDepartment));
|
||||
sql = "select * from eteams.employee where department=? and delete_type='0'";
|
||||
List<Map<String, Object>> personList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(splitDepartment));
|
||||
if (sonDepartmList.size() >0){
|
||||
throw new EmployeeJclRunTimeException("被拆分组织有子部门");
|
||||
}else if (personList.size() >0){
|
||||
throw new EmployeeJclRunTimeException("被拆分组织下存在人员");
|
||||
}
|
||||
for (Map<String,Object> data:dataList){
|
||||
log.error("splitOrganzationDepartment data"+data);
|
||||
String bmfzr = ((List<Map<String,Object>>)data.get("bmfzr")).get(0).get("id").toString();
|
||||
String sjzz = ((List<Map<String,Object>>)data.get("sjzz")).get(0).get("id").toString();
|
||||
String sjzzName = ((List<Map<String,Object>>)data.get("sjzz")).get(0).get("name").toString();
|
||||
Department department = Department.builder().form_data_id(String.valueOf(param.get("id"))).bh(data.get("bh").toString()).czlx("4").bcfzzid(splitDepartmentCode).bz(data.get("bz").toString())
|
||||
.sscb(sscb).fgld(fgldId).sjzzmc(sjzzName).bmsqcj(data.get("bmsqcj").toString()).bmfzr(bmfzr).zzmc(data.get("zzmc").toString()).sjzz(sjzz).sjzzbh(data.get("sjzzbh").toString()).build();
|
||||
addOrganaztionDepartment(department,employee);
|
||||
}
|
||||
|
||||
sql = "update uf_organization_bghzzsj set delete_type='3',is_delete='1' where bh=?";
|
||||
databaseUtils.execute(sql,CommonUtils.getParamList(splitDepartmentCode));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getDepartmentCodeById(String id) {
|
||||
String sql = "select * from eteams.department where id=?";
|
||||
return databaseUtils.getSqlList(sql,CommonUtils.getParamList(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractWeaTable queryOrganzationTableData(SimpleEmployee simpleEmployee, Map<String, Object> params) {
|
||||
int current = Integer.valueOf(CommonUtils.null2String(params.get("current")));
|
||||
int pageSize = Integer.valueOf(CommonUtils.null2String(params.get("pageSize")));
|
||||
String orgId = CommonUtils.null2String(params.get("orgId"));
|
||||
WeaTable weaTable =new WeaTable();
|
||||
|
||||
|
||||
String sql = "select * from eteams.department where id in(select distinct cid from eteams.depart_link dl where pid in (?) and delete_type='0') and delete_type='0'";
|
||||
List<Map<String, Object>> allSonDepartmentList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(orgId));
|
||||
|
||||
Map<String,List<Map<String, Object>>> allSonDepartmentGroup = allSonDepartmentList.stream().collect(Collectors.groupingBy(e->e.get("parent").toString()));
|
||||
for (Map.Entry<String,List<Map<String, Object>>> entry :allSonDepartmentGroup.entrySet()){
|
||||
String parentId = entry.getKey();
|
||||
List<Map<String, Object>> list = entry.getValue();
|
||||
for (Map<String, Object> map:allSonDepartmentList){
|
||||
if (parentId.equals(CommonUtils.null2String(map.get("id")))){
|
||||
map.put("isParent",true);
|
||||
map.put("children",list);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.error("allSonDepartmentList : [{}]",allSonDepartmentList);
|
||||
List<Map<String, Object>> dataList = allSonDepartmentList.stream().filter(e->orgId.equals(e.get("parent").toString())).collect(Collectors.toList());
|
||||
int startindex = (current-1)*pageSize;
|
||||
int endindex = current*pageSize;
|
||||
int total = dataList.size();
|
||||
if (pageSize != 9999){
|
||||
if (endindex > total){
|
||||
endindex = total;
|
||||
}
|
||||
if (startindex < 0){
|
||||
startindex = 0;
|
||||
}
|
||||
dataList = dataList.subList(startindex,endindex);
|
||||
}
|
||||
weaTable.setTotal(total);
|
||||
weaTable.setPageSize(pageSize);
|
||||
weaTable.setCurrent(current);
|
||||
weaTable.setData(dataList);
|
||||
|
||||
|
||||
|
||||
return weaTable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue