新增查询工具映射boolean类型,保时捷人员组织架构图默认全部展开

main
youHong.ai 2022-12-05 15:09:34 +08:00
parent a54073c604
commit 26c7992abd
4 changed files with 145 additions and 13 deletions

View File

@ -1,5 +1,10 @@
package aiyh.utils.recordset;
import aiyh.utils.annotation.BooleanConverter;
import aiyh.utils.annotation.BooleanConverterEnum;
import aiyh.utils.excention.CustomerException;
import com.google.common.base.Strings;
import org.jetbrains.annotations.NotNull;
import weaver.conn.RecordSet;
import java.lang.reflect.Field;
@ -13,11 +18,51 @@ import java.lang.reflect.Field;
public class BooleanTypeHandler implements TypeHandler{
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
return rs.getBoolean(fieldName);
return getBoolean(declaredField, rs.getString(fieldName));
}
@Override
public Object getValue(RecordSet rs, int index,Field declaredField) {
return rs.getBoolean(index);
return getBoolean(declaredField, rs.getString(index));
}
@NotNull
private Object getBoolean(Field declaredField, String fieldValue) {
try {
BooleanConverter annotation = declaredField.getAnnotation(BooleanConverter.class);
BooleanConverterEnum value = annotation.value();
String trueStr = annotation.trueStr();
String falseStr = annotation.falseStr();
String trueInteger = annotation.trueInteger();
String falseInteger = annotation.falseInteger();
boolean defaultValue = annotation.defaultValue();
String booleanVal = null;
try {
booleanVal = fieldValue;
} catch (Exception ignored) {
}
boolean hasValueTrue = annotation.hasValueTrue();
if (value == BooleanConverterEnum.STRING) {
if (booleanVal == null || booleanVal.equals(falseStr)) {
return false;
} else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueStr)) {
return true;
} else {
return defaultValue;
}
} else if (value == BooleanConverterEnum.INTEGER) {
if (booleanVal == null || booleanVal.equals(falseInteger)) {
return false;
} else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueInteger)) {
return true;
} else {
return defaultValue;
}
}else {
return defaultValue;
}
} catch (Exception e) {
throw new CustomerException("不支持的类型转换!");
}
}
}

View File

@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource;
import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll;
import java.util.List;
@ -19,9 +20,19 @@ import java.util.List;
public interface OrgChartMapper {
/**
* <h2></h2>
* <i>2022/12/5 11:05</i>
* ******************************************
*
* @param typeOfEmploymentField
* @return List<HrmResource>
* @author youHong.ai
* ******************************************
*/
@Select("select hrm.id, " +
" hrm.messagerurl avatar," +
" hrm.lastname last_name, " +
" cus.$t{lastNameEnField} last_name, " +
" hrm.managerstr manager_str, " +
" hrm.jobtitle job_title_id, " +
" hrm.managerid manager_id, " +
@ -33,9 +44,25 @@ public interface OrgChartMapper {
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
" inner join cus_fielddata cus on cus.ID = hrm.ID " +
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
" and (cus.SCOPEID = -1 or cus.SCOPEID = 3) " +
" and cus.SCOPEID = -1 " +
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
"where hrm.status in (0, 1)")
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField);
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
@ParamMapper("lastNameEnField") String lastNameEnField);
/**
* <h2></h2>
* <i>2022/12/5 11:51</i>
* ******************************************
*
* @param userId id
* @return ShowPointOrAll
* @author youHong.ai
* ******************************************
*/
@Select("select id,resources,show_all,show_type from uf_show_point_or_all " +
"where concat(',',resources,',') like concat('%,',#{userId},',%')")
ShowPointOrAll selectShowPointOrAll(@ParamMapper("userId") int userId);
}

View File

@ -0,0 +1,34 @@
package com.api.youhong.ai.pcn.organization.orgchart.pojo;
import aiyh.utils.annotation.BooleanConverter;
import aiyh.utils.annotation.BooleanConverterEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* <h1></h1>
*
* <p>create: 2022-12-05 10:51</p>
*
* @author youHong.ai
*/
@Getter
@Setter
@ToString
public class ShowPointOrAll {
/** id */
private Integer id;
/** 多人力资源的人员id */
private String resources;
/** 是否全部展开 */
@BooleanConverter(BooleanConverterEnum.INTEGER)
private boolean showAll;
/** 是否显示不同的人员标识 */
@BooleanConverter(BooleanConverterEnum.INTEGER)
private boolean showType;
}

View File

@ -6,6 +6,7 @@ import com.api.youhong.ai.pcn.organization.orgchart.dto.HrmResourceDto;
import com.api.youhong.ai.pcn.organization.orgchart.mapper.OrgChartMapper;
import com.api.youhong.ai.pcn.organization.orgchart.mapstruct.OrgChartMapStruct;
import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource;
import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll;
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
import ebu7common.youhong.ai.bean.Builder;
import weaver.hrm.User;
@ -41,7 +42,9 @@ public class OrgChartService {
int userId = logInUser.getUID();
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField);
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField);
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
/* ******************* 将pojo转换为Dto对象对节点属性默认值赋值找出当前用户并设置显示 ******************* */
@ -82,10 +85,33 @@ public class OrgChartService {
.with(HrmResourceDto::setCurrentParent, true)
.endSet());
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
List<OrgChartNodeVo> orgChartNodeVoList = null;
if (Objects.isNull(showPointOrAll)) {
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
List<OrgChartNodeVo> orgChartNodeVoList = hrmResourceDtoList.stream()
orgChartNodeVoList = hrmResourceDtoList.stream()
.map(struct::hrmResourceDtoToVo)
.collect(Collectors.toList());
} else {
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
orgChartNodeVoList = hrmResourceDtoList.stream()
.map(struct::hrmResourceDtoToVo)
.peek(item -> {
if (showPointOrAll.isShowAll()) {
Builder.startSet(item)
.with(OrgChartNodeVo::setShow, 1)
.with(OrgChartNodeVo::setShowBrother, 1)
.with(OrgChartNodeVo::setShowChildren, 1)
.endSet();
}
if (!showPointOrAll.isShowType()) {
item.setType(-1);
}
})
.collect(Collectors.toList());
}
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
OrgChartNodeVo::setChildren,