|
|
@ -8,8 +8,10 @@ import com.yxt.anrui.base.api.basevehiclebrand.BaseVehicleBrandFeign; |
|
|
|
import com.yxt.anrui.base.api.basevehiclebrand.BaseVehicleBrandSelectQuery; |
|
|
|
import com.yxt.anrui.base.api.basevehiclebrand.BaseVehicleBrandSelectVo; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.*; |
|
|
|
import com.yxt.anrui.portal.api.sysstaffinfo.SysStaffinfo; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo; |
|
|
|
import com.yxt.anrui.portal.biz.sysstaffinfo.SysStaffinfoService; |
|
|
|
import com.yxt.anrui.portal.biz.sysstafforg.SysStaffOrgService; |
|
|
|
import com.yxt.anrui.portal.biz.sysuser.SysUserService; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
@ -21,6 +23,7 @@ import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
@ -47,6 +50,8 @@ public class SysOrganizationService extends MybatisBaseService<SysOrganizationMa |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private BaseVehicleBrandFeign baseVehicleBrandFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffinfoService sysStaffInfoService; |
|
|
|
|
|
|
|
public PagerVo<SysOrganization> listPage(PagerQuery<SysOrganizationQuery> pq) { |
|
|
|
SysOrganizationQuery query = pq.getParams(); |
|
|
@ -148,36 +153,48 @@ public class SysOrganizationService extends MybatisBaseService<SysOrganizationMa |
|
|
|
return baseMapper.selectChildrenListByPsid(sid); |
|
|
|
} |
|
|
|
|
|
|
|
/* private void getChildrens(SysOrganizationVo s) { |
|
|
|
String sid = s.getSid(); |
|
|
|
QueryWrapper<SysOrganization> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(sid)) { |
|
|
|
qw.eq("psid", sid); |
|
|
|
} |
|
|
|
qw.orderByAsc("sort"); |
|
|
|
List<SysOrganizationVo> sysOrganizationVos = baseMapper.selectListAllVo(qw); |
|
|
|
if (!sysOrganizationVos.isEmpty()) { |
|
|
|
for (SysOrganizationVo sfv : sysOrganizationVos) { |
|
|
|
getChildrens(sfv); |
|
|
|
} |
|
|
|
} |
|
|
|
s.setChildren(sysOrganizationVos); |
|
|
|
}*/ |
|
|
|
|
|
|
|
public void addSysStaffOrg(String sids, String manageType, SysOrganization entity) { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean addSysStaffOrg(String sids, String manageType, SysOrganization entity) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String[] sidArr = sids.split(","); |
|
|
|
String name = ""; |
|
|
|
for (String sid : sidArr) { |
|
|
|
//查询组织关系中是否已经包含分管的人员
|
|
|
|
String orgSid = getOrgSid(entity.getSid()); |
|
|
|
if ("1".equals(manageType)) { |
|
|
|
int count = sysStaffOrgService.selectByStaffAndOrg(orgSid, sid, "2"); |
|
|
|
int count1 = sysStaffOrgService.selectByStaffAndType(orgSid, sid, "3"); |
|
|
|
int count2 = sysStaffOrgService.selectByStaffAndOrg(orgSid, sid, "1"); |
|
|
|
if (count > 0 || count2 > 0) { |
|
|
|
SysStaffinfo sysStaffinfo = sysStaffInfoService.fetchBySid(sid); |
|
|
|
name = sysStaffinfo.getName(); |
|
|
|
return rb.setMsg("该组织机构中已包含" + name + ",请勿重复操作"); |
|
|
|
} |
|
|
|
if (count1 > 0) { |
|
|
|
SysStaffinfo sysStaffinfo = sysStaffInfoService.fetchBySid(sid); |
|
|
|
name = sysStaffinfo.getName(); |
|
|
|
return rb.setMsg(name + "已是其他机构组织的主管"); |
|
|
|
} |
|
|
|
//查询是否有员工信息,如果有的话,删除关联关系
|
|
|
|
sysStaffOrgService.deleteByStaffSidAndType(orgSid, sid, "3"); |
|
|
|
} else {//分管操作
|
|
|
|
int count = sysStaffOrgService.selectByStaffAndOrg(orgSid, sid, "1"); |
|
|
|
int count1 = sysStaffOrgService.selectByStaffAndOrg(orgSid, sid, "3"); |
|
|
|
if (count > 0 || count1 > 0) { |
|
|
|
SysStaffinfo sysStaffinfo = sysStaffInfoService.fetchBySid(sid); |
|
|
|
name = sysStaffinfo.getName(); |
|
|
|
return rb.setMsg("该组织机构中已包含" + name + ",请勿重复操作"); |
|
|
|
} |
|
|
|
} |
|
|
|
//添加员工与组织的关联关系
|
|
|
|
SysStaffOrg sysStaffOrg = new SysStaffOrg(); |
|
|
|
sysStaffOrg.setManageType(manageType); |
|
|
|
sysStaffOrg.setOrgSid(entity.getSid()); |
|
|
|
sysStaffOrg.setOrgName(entity.getName()); |
|
|
|
sysStaffOrg.setStaffSid(sid); |
|
|
|
|
|
|
|
|
|
|
|
// entity = fetchBySid(entity.getSid());
|
|
|
|
String orgSidPath = entity.getOrgSidPath();// sysOrganization.getOrgSidPath();
|
|
|
|
String orgSidPath = entity.getOrgSidPath(); |
|
|
|
if (StringUtils.isNotBlank(orgSidPath)) { |
|
|
|
sysStaffOrg.setOrgSidPath(orgSidPath + "/" + entity.getSid()); |
|
|
|
sysStaffOrg.setOrgSidPath(orgSidPath); |
|
|
|
} else { |
|
|
|
sysStaffOrg.setOrgSidPath(entity.getSid()); |
|
|
|
} |
|
|
@ -192,6 +209,7 @@ public class SysOrganizationService extends MybatisBaseService<SysOrganizationMa |
|
|
|
} |
|
|
|
sysStaffOrgService.save(sysStaffOrg); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(SysOrganizationDto dto) { |
|
|
@ -421,13 +439,14 @@ public class SysOrganizationService extends MybatisBaseService<SysOrganizationMa |
|
|
|
public String getOrgSid(String sid) { |
|
|
|
SysOrganization sysOrganization = fetchBySid(sid); |
|
|
|
String orgSid = ""; |
|
|
|
if ("0".equals(sysOrganization.getPsid())) { |
|
|
|
if ("0".equals(sysOrganization.getPsid())) {//总公司
|
|
|
|
orgSid = sysOrganization.getSid(); |
|
|
|
return orgSid; |
|
|
|
} |
|
|
|
if ("1".equals(sysOrganization.getIsDept())) { |
|
|
|
if (sysOrganization.getIsDept() == 0) {//是独立法人的
|
|
|
|
return sysOrganization.getSid(); |
|
|
|
} |
|
|
|
sid = sysOrganization.getPsid(); |
|
|
|
return getOrgSid(sid); |
|
|
|
} |
|
|
|
} |