Merge pull request '编制、分部树排序、人事卡片按钮权限BUG' (#68) from feature/dxf into develop

Reviewed-on: #68
pull/70/head
dxfeng 3 years ago
commit 347632e301

@ -22,4 +22,6 @@ public interface CardButtonMapper {
List<Long> listAllId();
int deleteByIds(@Param("ids")Collection<Long> ids);
CardButtonPO getEditButton();
}

@ -52,5 +52,13 @@
from jcl_org_cardbutton t
where t.delete_type = 0
</select>
<select id="getEditButton" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_cardbutton t
where t.delete_type = 0
and sys_default = 0
and id = 1
</select>
</mapper>

@ -89,7 +89,7 @@
<!--<if test="param.jobTitle != null and param.jobTitle != ''">-->
<!--and t.job_title = #{param.jobTitle}-->
<!--</if>-->
order by t.id asc;
order by t.show_order asc
</select>
<select id="getResourceListByJobId"
resultMap="HrmResourceMap">
@ -125,6 +125,7 @@
<foreach collection="companyIds" open="(" item="companyId" separator="," close=")">
#{companyId}
</foreach>
order by t.show_order asc;
</select>
<sql id="likeSql">

@ -530,8 +530,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 源部门
DepartmentPO deptById = getDepartmentMapper().getDeptById(originalDeptId);
long timeMillis = System.currentTimeMillis();
deptById.setDeptName(deptById.getDeptName() + "_" + timeMillis);
deptById.setDeptNameShort(deptById.getDeptNameShort() + "_" + timeMillis);
// 处理自动编号
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), timeMillis));
// 设置上级分部

@ -1,6 +1,8 @@
package com.engine.organization.service.impl;
import com.api.browser.bean.SearchConditionItem;
import com.engine.common.service.HrmCommonService;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import com.engine.core.impl.Service;
import com.engine.organization.entity.TopTab;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
@ -10,10 +12,12 @@ import com.engine.organization.entity.extend.param.ExtendInfoParams;
import com.engine.organization.entity.extend.po.ExtendGroupPO;
import com.engine.organization.entity.extend.po.ExtendInfoPO;
import com.engine.organization.entity.extend.po.ExtendTitlePO;
import com.engine.organization.entity.personnelcard.po.CardButtonPO;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
import com.engine.organization.mapper.extend.*;
import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
import com.engine.organization.mapper.personnelcard.CardButtonMapper;
import com.engine.organization.service.ExtService;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.DBType;
@ -69,8 +73,7 @@ public class ExtServiceImpl extends Service implements ExtService {
return conditionItems;
}
List<String> readOnlyFieldList = new ArrayList<>(Arrays.asList(readOnlyFields));
//TODO 细化权限
if ("4".equals(extendType) && !user.isAdmin()) {
if ("4".equals(extendType) && noEditRight(user)) {
String ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(String.valueOf(id));
if (Util.null2String(user.getUID()).equals(ecResourceId)) {
List<String> readOnlyList = infoPOList.stream().filter(item -> !"1".equals(Util.null2String(item.getIsModify()))).map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
@ -156,9 +159,8 @@ public class ExtServiceImpl extends Service implements ExtService {
}
}
Map<Long, List<ExtendInfoPO>> allFields = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
//TODO 控制展示权限
boolean checkRight = true;
if (2 == viewAttr && "4".equals(extendType) && !user.isAdmin()) {
if (2 == viewAttr && "4".equals(extendType) && noEditRight(user)) {
checkRight = false;
String ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(String.valueOf(id));
if (Util.null2String(user.getUID()).equals(ecResourceId)) {
@ -171,6 +173,7 @@ public class ExtServiceImpl extends Service implements ExtService {
// 查询所有分布模块,拓展明细表信息
Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
// 遍历Map,组装数据
boolean finalCheckRight = checkRight;
for (Map.Entry<Long, List<ExtendInfoPO>> entry : groupMap.entrySet()) {
Map<String, Object> tableMap = new HashMap<>();
tableMap.put("hide", false);
@ -190,7 +193,6 @@ public class ExtServiceImpl extends Service implements ExtService {
List<Map<String, Object>> maps = getExtDTMapper().listCompExtDT(tableName, id, fields);
maps.removeIf(Objects::isNull);
// 兼容Oracle,map的key转换为小写
boolean finalCheckRight = checkRight;
List<Map<String, Object>> collect = maps.stream().map(item -> {
Map<String, Object> resultMap = new HashMap<>();
Set<String> keys = item.keySet();
@ -325,10 +327,39 @@ public class ExtServiceImpl extends Service implements ExtService {
}
}
/**
*
*
* @param obj
* @return
*/
private Object parseDetailValue(Object obj) {
if (null == obj || StringUtils.isBlank(Util.null2String(obj))) {
return null;
}
return obj;
}
/**
*
*
* @param user
* @return
*/
private boolean noEditRight(User user) {
boolean hasEditRight = user.isAdmin();
CardButtonPO editButton = MapperProxyFactory.getProxy(CardButtonMapper.class).getEditButton();
// 非系统管理员判断是否拥有角色
if (!hasEditRight && null != editButton) {
// 判断是否有这个角色
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
List<String> roleIds = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(user.getUID()).split(",")));
List<String> accessRoleIds = new ArrayList<>(Arrays.asList(Util.null2String(editButton.getRoles()).split(",")));
roleIds.retainAll(accessRoleIds);
hasEditRight = CollectionUtils.isNotEmpty(roleIds);
}
return !hasEditRight;
}
}

@ -12,6 +12,7 @@ import com.engine.organization.entity.DeleteParam;
import com.engine.organization.entity.browser.po.CustomBrowserBean;
import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.staff.bo.StaffBO;
import com.engine.organization.entity.staff.param.StaffSearchParam;
import com.engine.organization.entity.staff.po.StaffPO;
@ -135,16 +136,9 @@ public class StaffServiceImpl extends Service implements StaffService {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID());
OrganizationAssert.isFalse(staffPO.getStaffNum() < 0, "编制数不可小于0请更正");
checkRequired(staffPO);
// 赋值
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(staffPO.getEcCompany()));
if (null != jclCompanyId) {
staffPO.setCompId(jclCompanyId.getId());
}
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(staffPO.getEcDepartment()));
if (null != jclDepartmentId) {
staffPO.setDeptId(jclDepartmentId.getId());
}
int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO);
// 同步组织架构图编制信息
new StaffTriggerRunnable(staffPO).run();
@ -158,16 +152,9 @@ public class StaffServiceImpl extends Service implements StaffService {
StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID());
staffPO.setPermanentNum(staffByID.getPermanentNum());
staffPO.setFreezeNum(staffByID.getFreezeNum());
checkRequired(staffPO);
// 赋值
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(staffPO.getEcCompany()));
if (null != jclCompanyId) {
staffPO.setCompId(jclCompanyId.getId());
}
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(staffPO.getEcDepartment()));
if (null != jclDepartmentId) {
staffPO.setDeptId(jclDepartmentId.getId());
}
Integer changeNum = param.getChangeNum();
if (null == changeNum) {
// 插入明细表数据
@ -453,15 +440,29 @@ public class StaffServiceImpl extends Service implements StaffService {
switch (staffPlanByID.getControlDimension()) {
case "1":// 分部
OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择分部时,分部必填!");
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(Util.null2String(staffPO.getEcCompany()));
if (null != jclCompanyId) {
staffPO.setCompId(jclCompanyId.getId());
}
break;
case "2":// 部门
OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择部门时,分部必填!");
OrganizationAssert.notNull(staffPO.getEcDepartment(), "编制维度选择部门时,部门必填!");
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(staffPO.getEcDepartment()));
if (null != jclDepartmentId) {
staffPO.setDeptId(jclDepartmentId.getId());
staffPO.setCompId(jclDepartmentId.getParentComp());
staffPO.setEcCompany(jclDepartmentId.getEcCompany());
}
break;
case "3": // 岗位
OrganizationAssert.notNull(staffPO.getEcCompany(), "编制维度选择岗位时,分部必填!");
OrganizationAssert.notNull(staffPO.getEcDepartment(), "编制维度选择岗位时,部门必填!");
OrganizationAssert.notNull(staffPO.getJobId(), "编制维度选择岗位时,岗位必填!");
JobPO jobById = getJobMapper().getJobById(staffPO.getJobId());
if (null != jobById) {
staffPO.setDeptId(jobById.getParentDept());
staffPO.setEcDepartment(jobById.getEcDepartment());
staffPO.setCompId(jobById.getParentComp());
staffPO.setEcCompany(jobById.getEcCompany());
}
break;
default:
break;

@ -35,7 +35,7 @@ public class SearchTreeUtil {
// 排序,设置是否为叶子节点
List<TreeNode> collect = treeList.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
).sorted(Comparator.comparing(SearchTree::getOrderNum)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
treeDatas.addAll(collect);
}

Loading…
Cancel
Save