修改方法重载中docid没设置的bug

main
youHong.ai 2022-12-19 19:49:02 +08:00
parent e99562c417
commit 242080e581
9 changed files with 394 additions and 122 deletions

View File

@ -208,6 +208,9 @@ window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {},
getLevelByScore: async function (config) { getLevelByScore: async function (config) {
let scoreFiled = config.scoreFiled let scoreFiled = config.scoreFiled
let score = Utils.getFiledValueByName(scoreFiled); let score = Utils.getFiledValueByName(scoreFiled);
if(score == 0 || score == ''){
return
}
let result = await Utils.api({ let result = await Utils.api({
url: "/api/ayh/workflow/apa/level", url: "/api/ayh/workflow/apa/level",
data: { data: {
@ -225,10 +228,20 @@ window.workflowCus = Object.assign(window.workflowCus ? window.workflowCus : {},
/* ******************* apa流程通过apa分数字段带出level字段 ******************* */ /* ******************* apa流程通过apa分数字段带出level字段 ******************* */
$(() => { $(() => {
let config = { let config = {
scoreFiled: "", scoreFiled: "apafsptyg",
levelField: "" levelField: "level1"
}
try {
setTimeout(()=>{
WfForm.bindFieldChangeEvent(Utils.convertNameObjToId(config.scoreFiled),()=>{
console.log("asdfasdfasdfsadfasdf")
window.workflowCus.getLevelByScore(config)
})
window.workflowCus.getLevelByScore(config)
},100)
}catch (err){
console.log(err)
} }
window.workflowCus.getLevelByScore(config)
}) })
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */ /* ******************* apa流程通过apa分数字段带出level字段eng ******************* */

View File

@ -51,14 +51,14 @@ public class HttpUtils {
private final GlobalCache globalCache = new GlobalCache(); private final GlobalCache globalCache = new GlobalCache();
// 线程池 // 线程池
private final ThreadPoolExecutor executorService; private final ThreadPoolExecutor executorService;
private final PropertyPreFilters filters = new PropertyPreFilters();
private final PropertyPreFilters.MySimplePropertyPreFilter excludefilter = filters.addFilter();
// 默认编码 // 默认编码
private String DEFAULT_ENCODING = "UTF-8"; private String DEFAULT_ENCODING = "UTF-8";
/** /**
* basic * basic
*/ */
private CredentialsProvider credentialsProvider = null; private CredentialsProvider credentialsProvider = null;
private final PropertyPreFilters filters = new PropertyPreFilters();
private final PropertyPreFilters.MySimplePropertyPreFilter excludefilter = filters.addFilter();
{ {
// private final ExecutorService executorService = Executors.newFixedThreadPool(3); // private final ExecutorService executorService = Executors.newFixedThreadPool(3);
@ -69,7 +69,7 @@ public class HttpUtils {
new LinkedBlockingQueue<>(1024), new LinkedBlockingQueue<>(1024),
threadFactory, threadFactory,
new ThreadPoolExecutor.AbortPolicy()); new ThreadPoolExecutor.AbortPolicy());
String[] excludeProperties = {"locale","contentByteArr","response"}; String[] excludeProperties = {"locale", "contentByteArr", "response"};
excludefilter.addExcludes(excludeProperties); excludefilter.addExcludes(excludeProperties);
} }
@ -642,9 +642,9 @@ public class HttpUtils {
httpUtilParamInfo = new HttpUtilParamInfo(); httpUtilParamInfo = new HttpUtilParamInfo();
} }
httpUtilParamInfo.setResponse(apply); httpUtilParamInfo.setResponse(apply);
if(apply.getResponseMap() == null){ if (apply.getResponseMap() == null) {
httpUtilParamInfo.setResponseString(apply.getEntityString()); httpUtilParamInfo.setResponseString(apply.getEntityString());
}else { } else {
httpUtilParamInfo.setResponseMap(apply.getResponseMap()); httpUtilParamInfo.setResponseMap(apply.getResponseMap());
} }
httpUtilParamInfo.setResponseDate(new Date()); httpUtilParamInfo.setResponseDate(new Date());
@ -679,9 +679,9 @@ public class HttpUtils {
httpUtilParamInfo = new HttpUtilParamInfo(); httpUtilParamInfo = new HttpUtilParamInfo();
} }
httpUtilParamInfo.setResponse(apply); httpUtilParamInfo.setResponse(apply);
if(apply.getResponseMap() == null){ if (apply.getResponseMap() == null) {
httpUtilParamInfo.setResponseString(apply.getEntityString()); httpUtilParamInfo.setResponseString(apply.getEntityString());
}else { } else {
httpUtilParamInfo.setResponseMap(apply.getResponseMap()); httpUtilParamInfo.setResponseMap(apply.getResponseMap());
} }
httpUtilParamInfo.setResponseDate(new Date()); httpUtilParamInfo.setResponseDate(new Date());
@ -718,9 +718,9 @@ public class HttpUtils {
responeVo.setCode(response.getStatusLine().getStatusCode()); responeVo.setCode(response.getStatusLine().getStatusCode());
responeVo.setResponse(response); responeVo.setResponse(response);
httpUtilParamInfo.setResponse(responeVo); httpUtilParamInfo.setResponse(responeVo);
if(responeVo.getResponseMap() == null){ if (responeVo.getResponseMap() == null) {
httpUtilParamInfo.setResponseString(responeVo.getEntityString()); httpUtilParamInfo.setResponseString(responeVo.getEntityString());
}else { } else {
httpUtilParamInfo.setResponseMap(responeVo.getResponseMap()); httpUtilParamInfo.setResponseMap(responeVo.getResponseMap());
} }
httpUtilParamInfo.setResponseDate(new Date()); httpUtilParamInfo.setResponseDate(new Date());
@ -1042,14 +1042,14 @@ public class HttpUtils {
*/ */
private HttpPost uploadFileByInputStream(String url, List<HttpMultipartFile> multipartFileList, private HttpPost uploadFileByInputStream(String url, List<HttpMultipartFile> multipartFileList,
Map<String, Object> params, Map<String, String> headers) { Map<String, Object> params, Map<String, String> headers) {
log.info(Util.logStr("start request : url is [{}],other param [\n{}\n],heard [\n{}\n]", url, JSONObject.toJSONString(params, //log.info(Util.logStr("start request : url is [{}],other param [\n{}\n],heard [\n{}\n]", url, JSONObject.toJSONString(params,
excludefilter, // excludefilter,
SerializerFeature.PrettyFormat, // SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat), // SerializerFeature.WriteDateUseDateFormat),
JSONObject.toJSONString(headers, // JSONObject.toJSONString(headers,
excludefilter, // excludefilter,
SerializerFeature.PrettyFormat, // SerializerFeature.PrettyFormat,
SerializerFeature.WriteDateUseDateFormat))); // SerializerFeature.WriteDateUseDateFormat)));
HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo(); HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo();
httpUtilParamInfo.setParams(params); httpUtilParamInfo.setParams(params);
httpUtilParamInfo.setUrl(url); httpUtilParamInfo.setUrl(url);

View File

@ -13,8 +13,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
/** /**
* @author EBU7-dev1-ayh * @author EBU7-dev1-ayh create 2021/12/19 0019 14:39
* create 2021/12/19 0019 14:39
*/ */
@ -22,6 +21,8 @@ public class RecordsetUtil implements InvocationHandler {
private final RecordSet recordSet = new RecordSet(); private final RecordSet recordSet = new RecordSet();
private final RecordSet rs = new RecordSet();
public <T> T getMapper(Class<T> tClass) { public <T> T getMapper(Class<T> tClass) {
if (tClass == null) { if (tClass == null) {
throw new BindingException("class is null!"); throw new BindingException("class is null!");
@ -40,8 +41,7 @@ public class RecordsetUtil implements InvocationHandler {
ResultMapper resultMapper = new ResultMapper(); ResultMapper resultMapper = new ResultMapper();
Select select = method.getAnnotation(Select.class); Select select = method.getAnnotation(Select.class);
if (select != null) { if (select != null) {
// 查询 // 查询
RecordSet rs = new RecordSet();
String sql = select.value(); String sql = select.value();
boolean custom = select.custom(); boolean custom = select.custom();
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
@ -59,7 +59,7 @@ public class RecordsetUtil implements InvocationHandler {
Update update = method.getAnnotation(Update.class); Update update = method.getAnnotation(Update.class);
if (update != null) { if (update != null) {
// 查询 // 查询
String sql = update.value(); String sql = update.value();
boolean custom = update.custom(); boolean custom = update.custom();
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
@ -90,7 +90,7 @@ public class RecordsetUtil implements InvocationHandler {
} }
Insert insert = method.getAnnotation(Insert.class); Insert insert = method.getAnnotation(Insert.class);
if (insert != null) { if (insert != null) {
// 查询 // 查询
String sql = insert.value(); String sql = insert.value();
boolean custom = insert.custom(); boolean custom = insert.custom();
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);
@ -114,7 +114,7 @@ public class RecordsetUtil implements InvocationHandler {
} }
Delete delete = method.getAnnotation(Delete.class); Delete delete = method.getAnnotation(Delete.class);
if (delete != null) { if (delete != null) {
// 查询 // 查询
String sql = delete.value(); String sql = delete.value();
boolean custom = delete.custom(); boolean custom = delete.custom();
PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args);

View File

@ -1,6 +1,7 @@
package com.api.youhong.ai.pcn.organization.orgchart.controller; package com.api.youhong.ai.pcn.organization.orgchart.controller;
import aiyh.utils.ApiResult; import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.youhong.ai.pcn.organization.orgchart.service.OrgChartService; import com.api.youhong.ai.pcn.organization.orgchart.service.OrgChartService;
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo; import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
import weaver.hrm.HrmUserVarify; import weaver.hrm.HrmUserVarify;
@ -35,8 +36,28 @@ public class OrgChartController {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getOrgChartTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { public String getOrgChartTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User logInUser = HrmUserVarify.getUser(request, response); try {
List<OrgChartNodeVo> treeList = service.getOrgChartTree(logInUser); User logInUser = HrmUserVarify.getUser(request, response);
return ApiResult.success(treeList); List<OrgChartNodeVo> treeList = service.getOrgChartTree(logInUser);
return ApiResult.success(treeList);
} catch (Exception e) {
Util.getLogger().error("get chart tree error ! \n" + Util.getErrString(e));
return ApiResult.error("get chart tree error!" + e.getMessage());
}
}
@Path("get-all")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String getOrgChartTreeAll(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User logInUser = HrmUserVarify.getUser(request, response);
List<OrgChartNodeVo> treeList = service.getOrgChartTreeAll(logInUser);
return ApiResult.success(treeList);
} catch (Exception e) {
Util.getLogger().error("get all chart tree error ! \n" + Util.getErrString(e));
return ApiResult.error("get all chart tree error!" + e.getMessage());
}
} }
} }

View File

@ -40,7 +40,7 @@ public interface OrgChartMapper {
" hrm.departmentid department_id, " + " hrm.departmentid department_id, " +
" dept.DEPARTMENTNAME department_name, " + " dept.DEPARTMENTNAME department_name, " +
" job.JOBTITLENAME job_title_name, " + " job.JOBTITLENAME job_title_name, " +
" cus1.$t{typeOfEmploymentFiled} type_of_employment " + " uftb.$t{parentField} type_of_employment " +
"from hrmresource hrm " + "from hrmresource hrm " +
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " + " inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
" inner join cus_fielddata cus on cus.ID = hrm.ID " + " inner join cus_fielddata cus on cus.ID = hrm.ID " +
@ -50,9 +50,13 @@ public interface OrgChartMapper {
" and cus1.scope = 'HrmCustomFieldByInfoType' " + " and cus1.scope = 'HrmCustomFieldByInfoType' " +
" and cus1.scopeid = -1" + " and cus1.scopeid = -1" +
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " + " inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
" inner join $t{typeOfEmploymentTable} uftb on uftb.$t{typeOfEmploymentIdField} = cus1.$t{typeOfEmploymentFiled} " +
"where hrm.status in (0, 1)") "where hrm.status in (0, 1)")
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField, List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
@ParamMapper("lastNameEnField") String lastNameEnField); @ParamMapper("lastNameEnField") String lastNameEnField,
@ParamMapper("typeOfEmploymentTable") String typeOfEmploymentTable,
@ParamMapper("parentField") String parentField,
@ParamMapper("typeOfEmploymentIdField") String typeOfEmploymentIdField);
/** /**

View File

@ -41,84 +41,13 @@ public class OrgChartService {
*/ */
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) { public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
int userId = logInUser.getUID(); int userId = logInUser.getUID();
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField);
if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) {
throw new CustomerException("查询不到相关人员!");
}
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>(); AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
/* ******************* 将pojo转换为Dto对象对节点属性默认值赋值找出当前用户并设置显示 ******************* */ List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
List<HrmResourceDto> hrmResourceDtoList = hrmResourceList.stream()
.map(struct::hrmResourceToDto)
.peek(item -> Builder.startSet(item)
.with(HrmResourceDto::setShow, 0)
.with(HrmResourceDto::setShowBrother, 0)
.with(HrmResourceDto::setShowChildren, 0)
.endSet())
.collect(Collectors.toList());
hrmResourceDtoList.stream()
.peek(item -> {
if (item.getManagerId() == userId) {
item.setShow(1);
}
})
.filter(item -> item.getId() == userId)
.forEach(item -> {
Builder.startSet(item)
.with(HrmResourceDto::setShow, 1)
.with(HrmResourceDto::setShowBrother, 1)
.with(HrmResourceDto::setShowChildren, 1)
.with(HrmResourceDto::setCurrent, true)
.endSet();
currentUser.set(item);
});
/* ******************* 系统管理员默认全部展开哦 ******************* */ /* ******************* 系统管理员默认全部展开哦 ******************* */
if (userId == 1) { if (userId == 1) {
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream() return systemAdminTree(hrmResourceDtoList);
.map(struct::hrmResourceDtoToVo)
.peek(item -> Builder.startSet(item)
.with(OrgChartNodeVo::setShow, 1)
.with(OrgChartNodeVo::setShowBrother, 1)
.with(OrgChartNodeVo::setShowChildren, 1)
.with(OrgChartNodeVo::setCurrent, true)
.endSet())
.collect(Collectors.toList());
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
parentId -> parentId == null || parentId <= 0)
.stream().peek(item -> Builder.startSet(item)
.with(OrgChartNodeVo::setIsRoot, true)
.with(OrgChartNodeVo::setCurrent, true)
.endSet())
.peek(item -> recursionChildrenNums(item, 0))
.collect(Collectors.toList());
} }
Assert.notNull(currentUser.get(), "not find current login user info!"); filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
/* ******************* 根据当前登陆人的分部来过滤 ******************* */
hrmResourceDtoList = hrmResourceDtoList.stream()
.filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
.collect(Collectors.toList());
/* ******************* 查找当前登陆人员的所有上级 ******************* */
String currentUserManagerStr = currentUser.get().getManagerStr();
if (Objects.isNull(currentUserManagerStr)) {
currentUserManagerStr = "";
}
currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ",");
List<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
.map(Integer::parseInt)
.collect(Collectors.toList());
/* ******************* 对当前用户的所有直接上级设置标识 ******************* */
hrmResourceDtoList.stream()
.filter(item -> currentUserManagerList.contains(item.getId()))
.forEach(item -> Builder.startSet(item)
.with(HrmResourceDto::setShowChildren, 1)
.with(HrmResourceDto::setCurrentParent, true)
.endSet());
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */ /* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId); ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
List<OrgChartNodeVo> orgChartNodeVoList = null; List<OrgChartNodeVo> orgChartNodeVoList = null;
@ -157,6 +86,176 @@ public class OrgChartService {
} }
/**
* <h2>getOrgChartTreeAll </h2>
* <i>2022/12/16 17:21</i>
* ************************************************************
*
* @param logInUser id
* @return List<OrgChartNodeVo>
* @author youHong.ai ******************************************
*/
public List<OrgChartNodeVo> getOrgChartTreeAll(User logInUser) {
int userId = logInUser.getUID();
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
List<HrmResourceDto> hrmResourceDtoList = getHrmResourceDtoList(userId, currentUser);
/* ******************* 系统管理员默认全部展开哦 ******************* */
if (userId == 1) {
return systemAdminTree(hrmResourceDtoList);
}
filterCurrentSubCom(hrmResourceDtoList, currentUser, logInUser);
List<OrgChartNodeVo> orgChartNodeVoList = null;
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
orgChartNodeVoList = hrmResourceDtoList.stream()
.map(struct::hrmResourceDtoToVo)
.peek(item ->
Builder.startSet(item)
.with(OrgChartNodeVo::setShow, 1)
.with(OrgChartNodeVo::setShowBrother, 1)
.with(OrgChartNodeVo::setShowChildren, 1)
.endSet()
).collect(Collectors.toList());
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
OrgChartNodeVo::setChildren,
parentId -> parentId == null || parentId <= 0)
.stream()
.peek(item -> item.setIsRoot(true))
.peek(item -> recursionChildrenNums(item, 0))
.collect(Collectors.toList());
}
/**
* <h2>filterCurrentSubCom </h2>
* <i>2022/12/16 17:16</i>
* ************************************************************
*
* @param hrmResourceDtoList dtolist
* @param currentUser
* @param logInUser
* @author youHong.ai ******************************************
*/
private void filterCurrentSubCom(List<HrmResourceDto> hrmResourceDtoList,
AtomicReference<HrmResourceDto> currentUser,
User logInUser) {
Assert.notNull(currentUser.get(), "not find current login user info!");
/* ******************* 根据当前登陆人的分部来过滤 ******************* */
hrmResourceDtoList = hrmResourceDtoList.stream()
.filter(item -> logInUser.getUserSubCompany1() == item.getSubCompanyId())
.collect(Collectors.toList());
/* ******************* 查找当前登陆人员的所有上级 ******************* */
String currentUserManagerStr = currentUser.get().getManagerStr();
if (Objects.isNull(currentUserManagerStr) || "".equals(currentUserManagerStr)) {
currentUserManagerStr = "0";
}
currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ",");
List<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
.map(Integer::parseInt)
.collect(Collectors.toList());
/* ******************* 对当前用户的所有直接上级设置标识 ******************* */
hrmResourceDtoList.stream()
.filter(item -> currentUserManagerList.contains(item.getId()))
.forEach(item -> Builder.startSet(item)
.with(HrmResourceDto::setShowChildren, 1)
.with(HrmResourceDto::setCurrentParent, true)
.endSet());
}
/**
* <h2>systemAdminTree </h2>
* <i>2022/12/16 17:15</i>
* ************************************************************
*
* @param hrmResourceDtoList dtolist
* @return List<OrgChartNodeVo> list
* @author youHong.ai ******************************************
*/
private List<OrgChartNodeVo> systemAdminTree(List<HrmResourceDto> hrmResourceDtoList) {
List<OrgChartNodeVo> collect = hrmResourceDtoList.stream()
.map(struct::hrmResourceDtoToVo)
.peek(item -> Builder.startSet(item)
.with(OrgChartNodeVo::setShow, 1)
.with(OrgChartNodeVo::setShowBrother, 1)
.with(OrgChartNodeVo::setShowChildren, 1)
.with(OrgChartNodeVo::setCurrent, true)
.endSet())
.collect(Collectors.toList());
return Util.listToTree(collect, OrgChartNodeVo::getId, OrgChartNodeVo::getManagerId,
OrgChartNodeVo::getChildren, OrgChartNodeVo::setChildren,
parentId -> parentId == null || parentId <= 0)
.stream().peek(item -> Builder.startSet(item)
.with(OrgChartNodeVo::setIsRoot, true)
.with(OrgChartNodeVo::setCurrent, true)
.endSet())
.peek(item -> recursionChildrenNums(item, 0))
.collect(Collectors.toList());
}
/**
* <h2>getHrmResourceDtoList dtolist</h2>
* <i>2022/12/16 17:09</i>
* ************************************************************
*
* @param userId ID
* @param currentUser
* @return List<HrmResourceDto> dtolist
* @author youHong.ai ******************************************
*/
private List<HrmResourceDto> getHrmResourceDtoList(Integer userId, AtomicReference<HrmResourceDto> currentUser) {
// 人员类型自定义字段
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
// 英文自定义名称字段
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
// 人员类型id字段 建模表
String typeOfEmploymentIdField = Util.getCusConfigValue("typeOfEmploymentIdField");
Assert.notBlank(typeOfEmploymentIdField, "config [typeOfEmploymentIdField] is null or blank!");
// 人员类型父级字段 建模表
String parentField = Util.getCusConfigValue("parentField");
Assert.notBlank(parentField, "config [parentField] is null or blank!");
// 人员类型建模表表名
String typeOfEmploymentTable = Util.getCusConfigValue("typeOfEmploymentTable");
Assert.notBlank(typeOfEmploymentTable, "config [typeOfEmploymentTable] is null or blank!");
// 查询所有人员信息
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField,
typeOfEmploymentTable, parentField, typeOfEmploymentIdField);
if (Objects.isNull(hrmResourceList) || hrmResourceList.isEmpty()) {
throw new CustomerException("查询不到相关人员!");
}
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
/* ******************* 将pojo转换为Dto对象对节点属性默认值赋值找出当前用户并设置显示 ******************* */
List<HrmResourceDto> hrmResourceDtoList = hrmResourceList.stream()
.map(struct::hrmResourceToDto)
.peek(item -> Builder.startSet(item)
.with(HrmResourceDto::setShow, 0)
.with(HrmResourceDto::setShowBrother, 0)
.with(HrmResourceDto::setShowChildren, 0)
.endSet())
.collect(Collectors.toList());
hrmResourceDtoList.stream()
.peek(item -> {
if (Objects.equals(item.getManagerId(), userId)) {
item.setShow(1);
}
})
.filter(item -> Objects.equals(item.getId(), userId))
.forEach(item -> {
Builder.startSet(item)
.with(HrmResourceDto::setShow, 1)
.with(HrmResourceDto::setShowBrother, 1)
.with(HrmResourceDto::setShowChildren, 1)
.with(HrmResourceDto::setCurrent, true)
.endSet();
currentUser.set(item);
});
return hrmResourceDtoList;
}
/** /**
* <h2></h2> * <h2></h2>
* <i>2022/12/3 17:55</i> * <i>2022/12/3 17:55</i>

View File

@ -649,6 +649,8 @@ public class DealWithMapping extends ToolUtil {
for (DocImageFile docImageFile : docImageFiles) { for (DocImageFile docImageFile : docImageFiles) {
MultipartFile multipartFile = new MultipartFile(); MultipartFile multipartFile = new MultipartFile();
InputStream fileInputStream = ImageFileManager.getInputStreamById(docImageFile.getImageFileId()); InputStream fileInputStream = ImageFileManager.getInputStreamById(docImageFile.getImageFileId());
multipartFile.setDocId(docImageFile.getDocId());
multipartFile.setImageFileId(docImageFile.getImageFileId());
multipartFile.setFileKey(paramName); multipartFile.setFileKey(paramName);
multipartFile.setStream(fileInputStream); multipartFile.setStream(fileInputStream);
multipartFile.setFileName(docImageFile.getImageFileName()); multipartFile.setFileName(docImageFile.getImageFileName());

View File

@ -170,16 +170,16 @@ public class TestOrganization extends BaseTest {
@Test @Test
public void testReadCsv() { public void testReadCsv() {
String srcPath = GCONST.getSysFilePath() + "HRIS_PositionExport20221120" + ".csv"; String srcPath = GCONST.getSysFilePath() + "HRIS_PositionExport20221120" + ".csv";
// String charset = "utf-8"; // String charset = "utf-8";
// try (CSVReader csvReader = new CSVReaderBuilder(new BufferedReader(new InputStreamReader(new FileInputStream(new File(srcPath)), charset))).build()) { // try (CSVReader csvReader = new CSVReaderBuilder(new BufferedReader(new InputStreamReader(new FileInputStream(new File(srcPath)), charset))).build()) {
// Iterator<String[]> iterator = csvReader.iterator(); // Iterator<String[]> iterator = csvReader.iterator();
// while (iterator.hasNext()) { // while (iterator.hasNext()) {
// Arrays.stream(iterator.next()).forEach(System.out::print); // Arrays.stream(iterator.next()).forEach(System.out::print);
// System.out.println(); // System.out.println();
// } // }
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
BufferedReader reader = null; BufferedReader reader = null;
String line = null; String line = null;
@ -192,8 +192,8 @@ public class TestOrganization extends BaseTest {
String[] fieldsArr = null; String[] fieldsArr = null;
int lineNum = 0; int lineNum = 0;
int insertResult = 0; int insertResult = 0;
// TableInfo tableInfo = new TableInfo(); // TableInfo tableInfo = new TableInfo();
// tableInfo.setTableName(tableName); // tableInfo.setTableName(tableName);
try { try {
List<List<String>> listField = new ArrayList<>(); List<List<String>> listField = new ArrayList<>();
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -233,7 +233,7 @@ public class TestOrganization extends BaseTest {
@Test @Test
public void testOrgChart() { public void testOrgChart() {
User user = new User(1); User user = new User(35);
OrgChartService orgChartService = new OrgChartService(); OrgChartService orgChartService = new OrgChartService();
List<OrgChartNodeVo> orgChartTree = orgChartService.getOrgChartTree(user); List<OrgChartNodeVo> orgChartTree = orgChartService.getOrgChartTree(user);
System.out.println(JSON.toJSONString(orgChartTree)); System.out.println(JSON.toJSONString(orgChartTree));

View File

@ -1,12 +1,22 @@
package youhong.ai.pcn; package youhong.ai.pcn;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.httpUtil.util.HttpUtils;
import basetest.BaseTest; import basetest.BaseTest;
import com.itextpdf.text.pdf.BaseFont;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test; import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.xhtmlrenderer.pdf.ITextFontResolver;
import org.xhtmlrenderer.pdf.ITextRenderer;
import weaver.email.EmailWorkRunnable;
import weaver.general.GCONST;
import java.util.ArrayList; import java.io.File;
import java.util.Collections; import java.io.FileOutputStream;
import java.util.List; import java.io.OutputStream;
import java.util.*;
/** /**
* <h1></h1> * <h1></h1>
@ -28,4 +38,127 @@ public class WorkflowTest extends BaseTest {
.reduce(0, Integer::sum); .reduce(0, Integer::sum);
System.out.println(sum); System.out.println(sum);
} }
@Test
public void testEmail() {
String content = "<p><b>各位大佬:</b></p>\n" +
" <p>先前注册的gitea私有云仓库账号域名备案已完成现登陆仓库时请使用域名登陆</p>\n" +
" <br>\n" +
" <p>私有仓库登陆地址:<a href=\"https://gitea.yeyaguitu.cn/\">gitea私有仓库login</a></p>\n" +
" <br>\n" +
" <p>登陆账号为先前注册的账号:<b>#{zhanghao}</b>,默认密码为用户名!</p>\n" +
"<p>如已绑定仓库,需要重新设置仓库远程地址,方法如下:</p>\n" +
"<div>\n" +
" <b>执行命令:</b><br>\n" +
" git remote -v\n" +
" <br>比如:\n" +
" <p>\n" +
" origin http://1.****.82/ecology/ebu_ecology_dev1.git (fetch)<br>\n" +
" origin http://1.****.82/ecology/ebu_ecology_dev1.git (push)\n" +
" <p>\n" +
" <p>查看到remote的名称一般默认为 origin</p>\n" +
" <br>\n" +
" <b>执行命令:</b><br>\n" +
" git remote set-url origin https://gitea.yeyaguitu.cn/ecology/ebu_ecology_dev1.git\n" +
" <p>其中 origin 为查询到的remote的名称</p>";
List<Map<String, String>> list = new ArrayList<>();
list.add(new HashMap<String, String>() {{
put("name", "bokang.xiao");
put("email", "ic_excellent@qq.com");
}});
list.add(new HashMap<String, String>() {{
put("name", "chaoyang.he");
put("email", "chaoyang.he@weaver.com.cn");
}});
list.add(new HashMap<String, String>() {{
put("name", "jiacheng.deng");
put("email", "jiacheng.deng@weaver.com.cn");
}});
list.add(new HashMap<String, String>() {{
put("name", "jiayong.cao");
put("email", "jiayong.cao@weaver.com.cn");
}});
list.add(new HashMap<String, String>() {{
put("name", "jingwei.tao");
put("email", "jingwei.tao@weaver.com.cn");
}});
list.add(new HashMap<String, String>() {{
put("name", "weilin.zhu");
put("email", "bleach_725@163.com");
}});
list.add(new HashMap<String, String>() {{
put("name", "xuanran.wang");
put("email", "xuanran.wang@weaver.com.cn");
}});
list.add(new HashMap<String, String>() {{
put("name", "xvqiang.ren");
put("email", "1215877336@qq.com");
}});
list.add(new HashMap<String, String>() {{
put("name", "youhong.ai");
put("email", "youhong.ai@weaver.com.cn");
}});
for (Map<String, String> map : list) {
EmailWorkRunnable.threadModeReminder(map.get("email"), "域名变更提醒补充", content.replace("#{zhanghao}", map.get("name")));
}
}
@Test
public void testPdfFromWorkflow() throws Exception {
// 创建和初始化URL
//URL oracleURL = new URL("https://ecology.yeyaguitu.cn/spa/workflow/static4form/index.html#/main/workflow/req?requestid=50051&ismode=2&ismonitor=0&f_weaver_belongto_usertype=0&f_weaver_belongto_userid=1&urger=0&modeid=34&isprint=1");
// 获取网页作为输入流
//InputStream is = oracleURL.openStream();
//ITextRenderer renderer = new ITextRenderer();
//renderer.setDocument();
//OutputStream os = new FileOutputStream(GCONST.getSysFilePath() + "testpdf.pdf");
//renderer.layout();
//renderer.createPDF(os);
//os.close();
// 初始化HTML加载选项
//HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// 将流加载到Document对象中
//Document pdfDocument = new Document(is, htmloptions);
// 将输出另存为PDF格式
//pdfDocument.save(GCONST.getSysFilePath() + "HTML-to-PDF.pdf");
HttpUtils httpUtils = new HttpUtils();
String htmlUrl = "https://ecology.yeyaguitu.cn/spa/workflow/static4form/index.html#/main/workflow/req?requestid=50051&ismode=2&ismonitor=0&f_weaver_belongto_usertype=0&f_weaver_belongto_userid=1&urger=0&modeid=34&isprint=1";
log.info(Util.logStr("页面路径:{}", htmlUrl));
String html = httpUtils.apiGet(htmlUrl).getEntityString();
//String htmlContent = html.replace("<!DOCTYPE html>", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
// .replace("<!doctype html>", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
// .replace("<html lang=\"en\" xmlns:th=\"http://www.thymeleaf.org\">", "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">");
//log.info(Util.logStr("html内容\n{}", htmlContent));
File pdf = new File(GCONST.getSysFilePath() + "test.pdf");
Document document = Jsoup.parse(html);
String html1 = document.html();
HtmPdfUtil.html2pdf(html1, pdf);
}
} }
class HtmPdfUtil {
/**
* HTMLPDFhtml
*
* @param htmlContent
* @param pdfFile
* @throws Exception
*/
public static void html2pdf(String htmlContent, File pdfFile) throws Exception {
OutputStream os = new FileOutputStream(pdfFile);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString(htmlContent);
// 中文
ITextFontResolver fontResolver = renderer.getFontResolver();
ClassPathResource resource = new ClassPathResource("font/simsun.ttc");
fontResolver.addFont(resource.getURL().toString(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.layout();
renderer.createPDF(os);
os.close();
}
}