岗位自动任务

This commit is contained in:
“wyx12345678” 2024-05-07 18:08:10 +08:00
parent c4eadecde8
commit 1d18576d78
2 changed files with 38 additions and 5 deletions

View File

@ -693,17 +693,20 @@ public class MessageListen extends AbstractMessageServiceHandler {
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
if (data != null) if (data != null){
for (Map.Entry<String, String> entry : data.entrySet()) for (Map.Entry<String, String> entry : data.entrySet()) {
conn.setRequestProperty(entry.getKey(), entry.getValue()); conn.setRequestProperty(entry.getKey(), entry.getValue());
}
}
//设置是否向httpUrlConnection输出设置是否从httpUrlConnection读入此外发送post请求必须设置这两个 //设置是否向httpUrlConnection输出设置是否从httpUrlConnection读入此外发送post请求必须设置这两个
//最常用的Http请求无非是get和postget请求可以获取静态页面也可以把参数放在URL字串后面传递给servlet //最常用的Http请求无非是get和postget请求可以获取静态页面也可以把参数放在URL字串后面传递给servlet
//post与get的 不同之处在于post的参数不是放在URL字串里面而是放在http请求的正文内 //post与get的 不同之处在于post的参数不是放在URL字串里面而是放在http请求的正文内
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8"); OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
if (params != null) if (params != null) {
out.write(mapToStr(params)); out.write(mapToStr(params));
}
//缓冲数据 //缓冲数据
out.flush(); out.flush();
out.close(); out.close();
@ -738,13 +741,15 @@ public class MessageListen extends AbstractMessageServiceHandler {
if (map != null) { if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) { for (Map.Entry<String, String> entry : map.entrySet()) {
stringBuilder.append(entry.getKey()); stringBuilder.append(entry.getKey());
if (entry.getValue() != null) if (entry.getValue() != null) {
stringBuilder.append("=").append(entry.getValue()); stringBuilder.append("=").append(entry.getValue());
}
stringBuilder.append("&"); stringBuilder.append("&");
} }
} }
if (stringBuilder.length() > 0) if (stringBuilder.length() > 0) {
return stringBuilder.substring(0, stringBuilder.length() - 1); return stringBuilder.substring(0, stringBuilder.length() - 1);
}
return null; return null;
} }
} }

View File

@ -0,0 +1,28 @@
package shkd.cosmic.cxkg.task;
import cn.hutool.http.HttpRequest;
import shkd.cosmic.cxkg.task.DTO.QueryDTO;
/**
* @projectName: shkd-cosmic-root-project
* @package: shkd.cosmic.cxkg.task
* @className: JobtitleTaskImpl
* @author: wenyx
* @description: TODO
* @date: 2024/5/7 16:09
* @version: 1.0
*/
public class JobtitleTaskImpl {
public void getJobtitleInfo(){
QueryDTO queryDTO = new QueryDTO();
queryDTO.setCurpage(1);
queryDTO.setPagesize(2);
String json = HttpRequest.post("10.157.226.9:8088/api/hrm/resful/getHrmUserInfoWithPage")
.body("")
.execute().body();
}
}