From 01014bda043f3c1c7c969e3ff318b01a7d18e84b Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Wed, 7 Dec 2022 19:38:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=81=E5=93=8D=E5=BA=94=E5=AF=B9=E8=B1=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 2 +- .../java/aiyh/utils/httpUtil/ResponeVo.java | 275 +++++++++++++----- .../httpUtil/httpAsync/HttpAsyncThread.java | 62 ++-- .../httpAsync/HttpAsyncThreadCallBack.java | 9 +- .../httpUtil/staticUtil/HttpStaticUtils.java | 12 +- .../aiyh/utils/httpUtil/util/HttpUtils.java | 5 +- .../orgchart/dto/HrmResourceDto.java | 3 + .../orgchart/mapper/OrgChartMapper.java | 17 +- .../orgchart/pojo/HrmResource.java | 3 + .../orgchart/service/OrgChartService.java | 77 +++-- .../commons/config/dao/ConfigMappingCMD.java | 32 +- .../config/entity/ResponseMapping.java | 15 +- .../java/youhong/ai/pcn/TestOrganization.java | 50 +++- 13 files changed, 393 insertions(+), 169 deletions(-) diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 1cf328d..e4891bc 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -850,7 +850,7 @@ public class Util extends weaver.general.Util { } else { try { System.out.println("已存在文件:" + packageName + "." + className + ".java"); - System.out.print("你想如何处理该文件:替换[r/ApiResult] 重命名[w/W] 跳过[n/N] ? "); + System.out.print("你想如何处理该文件:替换[r/R] 重命名[w/W] 跳过[n/N] ? "); Scanner scanner = new Scanner(System.in); String next = scanner.next(); System.out.println(next); diff --git a/src/main/java/aiyh/utils/httpUtil/ResponeVo.java b/src/main/java/aiyh/utils/httpUtil/ResponeVo.java index 9174466..6f07cbb 100644 --- a/src/main/java/aiyh/utils/httpUtil/ResponeVo.java +++ b/src/main/java/aiyh/utils/httpUtil/ResponeVo.java @@ -2,11 +2,11 @@ package aiyh.utils.httpUtil; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.Header; +import org.apache.http.*; +import org.apache.http.params.HttpParams; import java.io.InputStream; import java.util.List; @@ -15,34 +15,44 @@ import java.util.Map; /** * @author EBU7-dev1-ayh - * @date 2021/8/31 0031 17:16 - * http请求相应 + * @date 2021/8/31 0031 17:16 http请求相应 */ -public class ResponeVo { - /** - * 相应状态码 - */ - private int code; - /** - * 相应内容 - */ - private String entityString; - /** - * 相应头信息 - */ - @JSONField(serialize = false) - private Header[] allHeaders; - private Locale locale; +public class ResponeVo implements HttpResponse { + /** + * 相应状态码 + */ + private int code; + /** + * 相应内容 + */ + private String entityString; + /** + * 相应头信息 + */ + + private Locale locale; private InputStream content; private byte[] contentByteArr; - private Map requestData; - public int getCode() { - return code; - } + private Map requestData; + + + private HttpResponse response; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public void setResponse(HttpResponse response) { + this.response = response; + } public Map getRequestData() { return requestData; @@ -53,30 +63,32 @@ public class ResponeVo { } /** - * 根据相应结果转化为map集合 - * @return 资源皇后的map集合 - * @throws JsonProcessingException JSON转换异常 - */ - public Map getEntityMap() throws JsonProcessingException { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(this.getEntityString(), Map.class); - } + * 根据相应结果转化为map集合 + * + * @return 资源皇后的map集合 + * @throws JsonProcessingException JSON转换异常 + */ + public Map getEntityMap() throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(this.getEntityString(), Map.class); + } - /** - * 根据相应结果,转化为实体类 - * @param clazz 需要映射的实体类 - * @param 需要转换实体类的泛型 - * @return 转换后的实体类 - * @throws JsonProcessingException JSON转换异常 - */ - public T getEntity(Class clazz) throws JsonProcessingException { + /** + * 根据相应结果,转化为实体类 + * + * @param clazz 需要映射的实体类 + * @param 需要转换实体类的泛型 + * @return 转换后的实体类 + * @throws JsonProcessingException JSON转换异常 + */ + public T getEntity(Class clazz) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(this.getEntityString(), clazz); } - /** * 根据相应结果,转化为实体类 + * * @param 需要转换实体类的泛型处理器 * @return 转换后的实体类 * @throws JsonProcessingException JSON转换异常 @@ -86,48 +98,167 @@ public class ResponeVo { return mapper.readValue(this.getEntityString(), typeReference); } - /** - * 根据相应结果转化为实体集合 - * @param clazz 需要映射的实体类 - * @param 需要转换的实体类的泛型 - * @return 转换后的实体类的集合 - */ - public List getEntityArray(Class clazz) { - return JSON.parseArray(this.getEntityString(), clazz); - } + /** + * 根据相应结果转化为实体集合 + * + * @param clazz 需要映射的实体类 + * @param 需要转换的实体类的泛型 + * @return 转换后的实体类的集合 + */ + public List getEntityArray(Class clazz) { + return JSON.parseArray(this.getEntityString(), clazz); + } - public Locale getLocale() { - return locale; - } + @Override + public StatusLine getStatusLine() { + return this.response.getStatusLine(); + } - public void setLocale(Locale locale) { - this.locale = locale; - } + @Override + public void setStatusLine(StatusLine statusLine) { - public void setCode(int code) { - this.code = code; - } + } - public Header[] getAllHeaders() { - return allHeaders; - } + @Override + public void setStatusLine(ProtocolVersion protocolVersion, int i) { - public void setAllHeaders(Header[] allHeaders) { - this.allHeaders = allHeaders; - } + } - public String getEntityString() { - return entityString; - } + @Override + public void setStatusLine(ProtocolVersion protocolVersion, int i, String s) { - public void setEntityString(String entityString) { - this.entityString = entityString; - } + } + + @Override + public void setStatusCode(int i) throws IllegalStateException { + + } + + @Override + public void setReasonPhrase(String s) throws IllegalStateException { + + } + + @Override + public HttpEntity getEntity() { + return null; + } + + @Override + public void setEntity(HttpEntity httpEntity) { + + } + + public Locale getLocale() { + return locale; + } + + public void setLocale(Locale locale) { + this.locale = locale; + } + + @Override + public ProtocolVersion getProtocolVersion() { + return this.response.getProtocolVersion(); + } + + @Override + public boolean containsHeader(String s) { + return response.containsHeader(s); + } + + @Override + public Header[] getHeaders(String s) { + return response.getHeaders(s); + } + + @Override + public Header getFirstHeader(String s) { + return response.getFirstHeader(s); + } + + @Override + public Header getLastHeader(String s) { + return response.getLastHeader(s); + } + + public Header[] getAllHeaders() { + return response.getAllHeaders(); + } + + @Override + public void addHeader(Header header) { + + } + + @Override + public void addHeader(String s, String s1) { + + } + + @Override + public void setHeader(Header header) { + + } + + @Override + public void setHeader(String s, String s1) { + + } + + @Override + public void setHeaders(Header[] headers) { + + } + + @Override + public void removeHeader(Header header) { + + } + + @Override + public void removeHeaders(String s) { + + } + + @Override + public HeaderIterator headerIterator() { + return response.headerIterator(); + } + + @Override + public HeaderIterator headerIterator(String s) { + return response.headerIterator(s); + } + + @Override + @Deprecated + public HttpParams getParams() { + return response.getParams(); + } + + @Override + public void setParams(HttpParams httpParams) { + + } + + + public String getEntityString() { + return entityString; + } + + public void setEntityString(String entityString) { + this.entityString = entityString; + } public InputStream getContent() { return content; } + public void setContent(InputStream content) { + this.content = content; + } + public byte[] getContentByteArr() { return contentByteArr; } @@ -136,10 +267,6 @@ public class ResponeVo { this.contentByteArr = contentByteArr; } - public void setContent(InputStream content) { - this.content = content; - } - @Override public String toString() { return "ResponeVo{" + diff --git a/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThread.java b/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThread.java index 1e875c9..2f4a8e3 100644 --- a/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThread.java +++ b/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThread.java @@ -1,54 +1,52 @@ package aiyh.utils.httpUtil.httpAsync; +import aiyh.utils.httpUtil.ExtendedIOUtils; +import aiyh.utils.httpUtil.ResponeVo; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; -import aiyh.utils.httpUtil.ExtendedIOUtils; -import aiyh.utils.httpUtil.ResponeVo; import java.util.Locale; import java.util.concurrent.Callable; /** * @author EBU7-dev1-ayh - * @date 2021/9/2 0002 22:55 - * async + * @date 2021/9/2 0002 22:55 async */ public class HttpAsyncThread implements Callable { - private final CloseableHttpClient httpClient; - private final HttpUriRequest request; - private String DEFAULT_ENCODING = "UTF-8"; + private final CloseableHttpClient httpClient; + private final HttpUriRequest request; + private String DEFAULT_ENCODING = "UTF-8"; - public HttpAsyncThread(CloseableHttpClient httpClient, HttpUriRequest request, String DEFAULT_ENCODING) { - this.httpClient = httpClient; - this.request = request; - this.DEFAULT_ENCODING = DEFAULT_ENCODING; - } + public HttpAsyncThread(CloseableHttpClient httpClient, HttpUriRequest request, String DEFAULT_ENCODING) { + this.httpClient = httpClient; + this.request = request; + this.DEFAULT_ENCODING = DEFAULT_ENCODING; + } - @Override - public ResponeVo call() throws Exception { - ResponeVo responeVo = new ResponeVo(); - CloseableHttpResponse response = null; - try { - response = httpClient.execute(request); - HttpEntity entity = response.getEntity(); - Header[] allHeaders = response.getAllHeaders(); - Locale locale = response.getLocale(); - responeVo.setLocale(locale); - responeVo.setAllHeaders(allHeaders); - responeVo.setEntityString(EntityUtils.toString(entity, DEFAULT_ENCODING)); - responeVo.setCode(response.getStatusLine().getStatusCode()); - } catch (Exception e) { - throw e; - } - ExtendedIOUtils.closeQuietly(httpClient); - ExtendedIOUtils.closeQuietly(response); - return responeVo; - } + @Override + public ResponeVo call() throws Exception { + ResponeVo responeVo = new ResponeVo(); + CloseableHttpResponse response = null; + try { + response = httpClient.execute(request); + HttpEntity entity = response.getEntity(); + Header[] allHeaders = response.getAllHeaders(); + Locale locale = response.getLocale(); + responeVo.setLocale(locale); + responeVo.setEntityString(EntityUtils.toString(entity, DEFAULT_ENCODING)); + responeVo.setCode(response.getStatusLine().getStatusCode()); + } catch (Exception e) { + throw e; + } + ExtendedIOUtils.closeQuietly(httpClient); + ExtendedIOUtils.closeQuietly(response); + return responeVo; + } } diff --git a/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThreadCallBack.java b/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThreadCallBack.java index 4bcf525..bd2af44 100644 --- a/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThreadCallBack.java +++ b/src/main/java/aiyh/utils/httpUtil/httpAsync/HttpAsyncThreadCallBack.java @@ -6,7 +6,6 @@ import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtilParamInfo; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; -import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; @@ -20,18 +19,16 @@ import java.util.function.Consumer; /** * @author EBU7-dev1-ayh - * @date 2021/9/2 0002 23:18 - * callback + * @date 2021/9/2 0002 23:18 callback */ public class HttpAsyncThreadCallBack implements Runnable { + private static final Logger log = Util.getLogger("http_util"); private final CloseableHttpClient httpClient; private final HttpUriRequest request; private final Consumer consumer; private String defaultEncoding = "UTF-8"; - private static final Logger log = Util.getLogger("http_util"); - private HttpUtilParamInfo httpUtilParamInfo = new HttpUtilParamInfo(); public HttpAsyncThreadCallBack(CloseableHttpClient httpClient, HttpUriRequest request, Consumer consumer) { @@ -54,11 +51,9 @@ public class HttpAsyncThreadCallBack implements Runnable { response = httpClient.execute(request); HttpEntity entity = response.getEntity(); - Header[] allHeaders = response.getAllHeaders(); ResponeVo responeVo = new ResponeVo(); Locale locale = response.getLocale(); responeVo.setLocale(locale); - responeVo.setAllHeaders(allHeaders); responeVo.setEntityString(EntityUtils.toString(entity, defaultEncoding)); responeVo.setCode(response.getStatusLine().getStatusCode()); httpUtilParamInfo.setResponse(responeVo); diff --git a/src/main/java/aiyh/utils/httpUtil/staticUtil/HttpStaticUtils.java b/src/main/java/aiyh/utils/httpUtil/staticUtil/HttpStaticUtils.java index 8688af4..8172f49 100644 --- a/src/main/java/aiyh/utils/httpUtil/staticUtil/HttpStaticUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/staticUtil/HttpStaticUtils.java @@ -33,19 +33,16 @@ import java.util.function.Consumer; /** * @author EBU7-dev1-ayh - * @date 2021/8/31 0031 17:16 - * http请求工具 + * @date 2021/8/31 0031 17:16 http请求工具 */ public class HttpStaticUtils { - // 默认编码 - public static String DEFAULT_ENCODING = "UTF-8"; - - private static final ToolUtil toolUtil = new ToolUtil(); - // 线程池 public static final ThreadPoolExecutor executorService; + private static final ToolUtil toolUtil = new ToolUtil(); + // 默认编码 + public static String DEFAULT_ENCODING = "UTF-8"; static { // private final ExecutorService executorService = Executors.newFixedThreadPool(3); @@ -423,7 +420,6 @@ public class HttpStaticUtils { Header[] allHeaders = response.getAllHeaders(); Locale locale = response.getLocale(); responeVo.setLocale(locale); - responeVo.setAllHeaders(allHeaders); responeVo.setEntityString(EntityUtils.toString(entity, DEFAULT_ENCODING)); responeVo.setCode(response.getStatusLine().getStatusCode()); } catch (Exception e) { diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index e858fb6..2c3e946 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -39,8 +39,7 @@ import java.util.function.Function; /** * @author EBU7-dev1-ayh - * @date 2021/8/31 0031 17:16 - * http请求工具 与HttpStaticUtils使用相同,说明请查看HttpStaticUtils + * @date 2021/8/31 0031 17:16 http请求工具 与HttpStaticUtils使用相同,说明请查看HttpStaticUtils */ @@ -700,9 +699,9 @@ public class HttpUtils { Header[] allHeaders = response.getAllHeaders(); Locale locale = response.getLocale(); responeVo.setLocale(locale); - responeVo.setAllHeaders(allHeaders); responeVo.setEntityString(EntityUtils.toString(entity, DEFAULT_ENCODING)); responeVo.setCode(response.getStatusLine().getStatusCode()); + responeVo.setResponse(response); httpUtilParamInfo.setResponse(responeVo); httpUtilParamInfo.setResponseDate(new Date()); try { diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/dto/HrmResourceDto.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/dto/HrmResourceDto.java index f692657..8517cb7 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/dto/HrmResourceDto.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/dto/HrmResourceDto.java @@ -61,4 +61,7 @@ public class HrmResourceDto { /** 头像地址 */ private String avatar; + + /** 当前所属分部 */ + private Integer subCompanyId; } diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java index c89e166..742c417 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/mapper/OrgChartMapper.java @@ -27,24 +27,28 @@ public interface OrgChartMapper { * * @param typeOfEmploymentField 人员自定义字段 * @return List 返回的人员信息 - * @author youHong.ai - * ****************************************** + * @author youHong.ai ****************************************** */ @Select("select hrm.id, " + + " hrm.subcompanyid1 sub_company_id," + " hrm.messagerurl avatar," + - " cus.$t{lastNameEnField} last_name, " + + " (case when cus.$t{lastNameEnField} is null then hrm.lastname " + + " else cus.$t{lastNameEnField} end) last_name, " + " hrm.managerstr manager_str, " + " hrm.jobtitle job_title_id, " + " hrm.managerid manager_id, " + " hrm.departmentid department_id, " + " dept.DEPARTMENTNAME department_name, " + " job.JOBTITLENAME job_title_name, " + - " cus.$t{typeOfEmploymentFiled} type_of_employment " + + " cus1.$t{typeOfEmploymentFiled} type_of_employment " + "from hrmresource hrm " + " 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 " + + " and cus.SCOPEID = 1 " + + " inner join cus_fielddata cus1 on cus1.id = hrm.id" + + " and cus1.scope = 'HrmCustomFieldByInfoType' " + + " and cus1.scopeid = -1" + " inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " + "where hrm.status in (0, 1)") List selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField, @@ -58,8 +62,7 @@ public interface OrgChartMapper { * * @param userId 当前用户id * @return ShowPointOrAll 展示与否的人员信息 - * @author youHong.ai - * ****************************************** + * @author youHong.ai ****************************************** */ @Select("select id,resources,show_all,show_type from uf_show_point_or_all " + "where concat(',',resources,',') like concat('%,',#{userId},',%')") diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/pojo/HrmResource.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/pojo/HrmResource.java index 85a8cd9..ec7eab4 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/pojo/HrmResource.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/pojo/HrmResource.java @@ -47,5 +47,8 @@ public class HrmResource { /** 用工类型 */ private Integer typeOfEmployment; + /** 当前所属分部 */ + private Integer subCompanyId; + } diff --git a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java index 253f57d..cd235e6 100644 --- a/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java +++ b/src/main/java/com/api/youhong/ai/pcn/organization/orgchart/service/OrgChartService.java @@ -52,11 +52,30 @@ public class OrgChartService { //List hrmResourceDtoList = new ArrayList(); AtomicReference currentUser = new AtomicReference<>(); /* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */ - List 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().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); - }); + List 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) { List collect = hrmResourceDtoList.stream() @@ -73,21 +92,32 @@ public class OrgChartService { parentId -> parentId == null || parentId <= 0) .stream().peek(item -> Builder.startSet(item) .with(OrgChartNodeVo::setIsRoot, true) - .with(OrgChartNodeVo::setCurrentParent, true) + .with(OrgChartNodeVo::setCurrent, true) .endSet()) .peek(item -> recursionChildrenNums(item, 0)) .collect(Collectors.toList()); } 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)) { currentUserManagerStr = ""; } currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ","); - List currentUserManagerList = Arrays.stream(currentUserManagerStr.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + List 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()); + 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); @@ -100,17 +130,30 @@ public class OrgChartService { .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()); + 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, parentId -> parentId == null || parentId <= 0).stream().peek(item -> item.setIsRoot(true)).peek(item -> recursionChildrenNums(item, 0)).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()); } diff --git a/src/main/java/weaver/xiao/commons/config/dao/ConfigMappingCMD.java b/src/main/java/weaver/xiao/commons/config/dao/ConfigMappingCMD.java index abd7130..cc32fb7 100644 --- a/src/main/java/weaver/xiao/commons/config/dao/ConfigMappingCMD.java +++ b/src/main/java/weaver/xiao/commons/config/dao/ConfigMappingCMD.java @@ -2,10 +2,7 @@ package weaver.xiao.commons.config.dao; import weaver.conn.RecordSet; import weaver.general.Util; -import weaver.xiao.commons.config.entity.DocImageFile; -import weaver.xiao.commons.config.entity.FieldMessage; -import weaver.xiao.commons.config.entity.MappingDetail; -import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.entity.*; import weaver.xiao.commons.config.enumtype.DataSourceEnum; import weaver.xiao.commons.exception.ValueDealException; import weaver.xiao.commons.utils.SqlUtil; @@ -108,17 +105,22 @@ public class ConfigMappingCMD { mappingDetails.add(mappingDetail); } requestMappingConfig.setConfigDetail(mappingDetails); -// //查询明细4的信息 -// RecordSet detail4RecordSet = new RecordSet(); -// List responseMappingList = new ArrayList<>(); -// String queryDetail4Sql = "select responseFieldName,workflowField,mainOrDetail,detailTableId,workflowFieldName from uf_request_config_dt4 where mainid = ?"; -// toolUtil.writeDebuggerLog("执行查询的明细sql query detail4Sql >>>>"+queryDetail4Sql+" mainId:"+mainId); -// detail4RecordSet.executeQuery(queryDetail4Sql,mainId); -// while (detail4RecordSet.next()){ -// ResponseMapping responseMapping = sqlUtil.recordSetToEntityByEntity(detail4RecordSet, ResponseMapping.class); -// responseMappingList.add(responseMapping); -// } -// requestMappingConfig.setResponseMappingList(responseMappingList); + try { + + //查询明细4的信息 + RecordSet detail4RecordSet = new RecordSet(); + List responseMappingList = new ArrayList<>(); + String queryDetail4Sql = "select responseFieldName,workflowField,mainOrDetail,detailTableId,workflowFieldName from uf_request_config_dt4 where mainid = ?"; + toolUtil.writeDebuggerLog("执行查询的明细sql query detail4Sql >>>>" + queryDetail4Sql + " mainId:" + mainId); + detail4RecordSet.executeQuery(queryDetail4Sql, mainId); + while (detail4RecordSet.next()) { + ResponseMapping responseMapping = sqlUtil.recordSetToEntityByEntity(detail4RecordSet, ResponseMapping.class); + responseMappingList.add(responseMapping); + } + requestMappingConfig.setResponseMappingList(responseMappingList); + } catch (Exception ignore) { + + } requestMappingConfig.setConfigDetail(mappingDetails); } diff --git a/src/main/java/weaver/xiao/commons/config/entity/ResponseMapping.java b/src/main/java/weaver/xiao/commons/config/entity/ResponseMapping.java index eb74d44..0af8dcc 100644 --- a/src/main/java/weaver/xiao/commons/config/entity/ResponseMapping.java +++ b/src/main/java/weaver/xiao/commons/config/entity/ResponseMapping.java @@ -1,6 +1,7 @@ package weaver.xiao.commons.config.entity; import lombok.Data; +import weaver.xiao.commons.utils.annotation.SqlFieldMapping; /** * @author XiaoBokang @@ -9,9 +10,19 @@ import lombok.Data; @Data public class ResponseMapping { + + @SqlFieldMapping("responseFieldName") private String responseFieldName; + + @SqlFieldMapping("workflowField") private String workflowField; - private String mainOrDetail; + + @SqlFieldMapping("mainOrDetail") + private Integer mainOrDetail; + + @SqlFieldMapping("detailTableId") private String detailTableId; + + @SqlFieldMapping("workflowFieldName") private String workflowFieldName; -} +} \ No newline at end of file diff --git a/src/test/java/youhong/ai/pcn/TestOrganization.java b/src/test/java/youhong/ai/pcn/TestOrganization.java index 4966161..89992af 100644 --- a/src/test/java/youhong/ai/pcn/TestOrganization.java +++ b/src/test/java/youhong/ai/pcn/TestOrganization.java @@ -5,11 +5,16 @@ import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import basetest.BaseTest; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.api.youhong.ai.pcn.organization.orgchart.service.OrgChartService; import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo; import com.fasterxml.jackson.core.JsonProcessingException; import ebu7common.youhong.ai.bean.Builder; import ebu7common.youhong.ai.sftp.SftpConnectUtil; +import org.apache.http.Header; +import org.apache.http.HeaderElement; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; import org.junit.Test; import weaver.conn.RecordSet; import weaver.general.GCONST; @@ -41,6 +46,27 @@ import java.util.regex.Pattern; public class TestOrganization extends BaseTest { + public static String getFileName(HttpResponse response) { + Header contentHeader = response.getFirstHeader("Content-Disposition"); + String filename = null; + if (contentHeader != null) { + HeaderElement[] values = contentHeader.getElements(); + if (values.length == 1) { + NameValuePair param = values[0].getParameterByName("filename"); + if (param != null) { + try { + //filename = new String(param.getValue().toString().getBytes(), "utf-8"); + //filename=URLDecoder.decode(param.getValue(),"utf-8"); + filename = param.getValue(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + return filename; + } + @Test public void testSftp() throws IOException { SftpConnectUtil sftpConnectUtil = new SftpConnectUtil( @@ -54,7 +80,6 @@ public class TestOrganization extends BaseTest { System.out.println(hris_positionExport20221120); } - @Test public void testGeOrganizationData() { GetOrganizationResult getOrganizationResult = new GetOrganizationResult(); @@ -67,7 +92,6 @@ public class TestOrganization extends BaseTest { log.info(JSON.toJSONString(positionList)); } - @Test public void testStaticLog() { log.info("哈哈哈好的方式"); @@ -192,7 +216,6 @@ public class TestOrganization extends BaseTest { } } - @Test public void testOrgChart() { User user = new User(1); @@ -200,4 +223,25 @@ public class TestOrganization extends BaseTest { List orgChartTree = orgChartService.getOrgChartTree(user); System.out.println(JSON.toJSONString(orgChartTree)); } + + @Test + public void testDownload() throws IOException { + HttpUtils httpUtils = new HttpUtils(); +// String url = "http://e-sign-dev-yace-web-alb-1694614450.cn-north-1.elb.amazonaws.com.cn:8070/contract/download?appId=100000&signType=SHA256&sign=OEI4RDA5RjMwRTE3Qzk1ODI0RkM3OENCQTA3QzZEQUFBQTgwRjM5MDdDMkIzQTIxNDFERDkyNUI5RDVFRjc4Qg==×tamp=2022-12-07%2014:32:08&bizContent=JTdCJTIyZG9jTm8lMjIlM0ElMjJjMGY5YzhjYTk5OTQ0MzZjYThjY2Y0MWVmMTZkMDUzYSUyMiU3RA=="; + String url = "https://apigwaws-lite.porsche-cloudservice.com/env-101/econtract/econtract/contract/api/v1/contract/download"; + String heard = "{\"apikey\":\"TulQxnZSRKeHoQfmeZzOUzGn6KpTDkDK\",\"appId\":\"100001\",\"bizContent\":\"JTdCJTIyY29udHJhY3RObyUyMiUzQSUyMjAwZDBkNmFlYzFkOTQzNGE4YjFlZjc5YzZjODcwNWFmJTIyJTdE\",\"sign\":\"M0I2NjhGRjgwNDY2RjM4MjRBMTg4RUQ0QUU0MkEzOUVEQTAxNTZCRTgwRDE3NzQ3RkQxMzZGOEE1M0FCODRGOA==\",\"signType\":\"SHA256\",\"Content-Type\":\"application/json\",\"timestamp\":\"2022-12-07 17:38:07\"} "; + Map map = JSONObject.parseObject(heard, Map.class); + FaRequestUtils.downContract(new HashMap() {{ + put("contractNo", "00d0d6aec1d9434a8b1ef79c6c8705af"); + }}, (map1, response) -> { + getFileName(response); + Header[] allHeaders = response.getAllHeaders(); + for (Header allHeader : allHeaders) { + System.out.println(allHeader); + } + return null; + }, url); + + + } }