添加从浪潮获取人员标签(先判断本地有没有,然后在从浪潮人员标签查询)
This commit is contained in:
@@ -217,6 +217,11 @@ oauth:
|
|||||||
read-timeout: 30
|
read-timeout: 30
|
||||||
write-timeout: 30
|
write-timeout: 30
|
||||||
|
|
||||||
|
#浪潮
|
||||||
|
lc:
|
||||||
|
#获取人员标签
|
||||||
|
personTag: http://10.98.80.146/prod-api/dispatch/public/person/tag
|
||||||
|
|
||||||
#ai
|
#ai
|
||||||
chat:
|
chat:
|
||||||
baseUrl: http://192.168.133.200:8080
|
baseUrl: http://192.168.133.200:8080
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.ruoyi.cms.domain.UserInfoDetail;
|
|||||||
import com.ruoyi.cms.util.AppUserFieldCustomCopy;
|
import com.ruoyi.cms.util.AppUserFieldCustomCopy;
|
||||||
import com.ruoyi.cms.util.DictUtils;
|
import com.ruoyi.cms.util.DictUtils;
|
||||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||||
|
import com.ruoyi.cms.util.oauth.OauthClient;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.MyChart;
|
import com.ruoyi.common.core.domain.entity.MyChart;
|
||||||
import com.ruoyi.common.core.domain.entity.File;
|
import com.ruoyi.common.core.domain.entity.File;
|
||||||
@@ -81,6 +82,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
|||||||
|
|
||||||
private final RestTemplate restTemplate = new RestTemplate();
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OauthClient oauthClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询APP用户
|
* 查询APP用户
|
||||||
*
|
*
|
||||||
@@ -142,18 +146,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
|||||||
file.setBussinessid(userId);
|
file.setBussinessid(userId);
|
||||||
List<File> files=fileMapper.selectFileList(file);
|
List<File> files=fileMapper.selectFileList(file);
|
||||||
appUser.setFileList(files);
|
appUser.setFileList(files);
|
||||||
//处理tag
|
//返回政策标签名称,主要为了查询政策用的
|
||||||
String userTag=appUser.getUserTag();
|
String userTag=appUser.getUserTag();
|
||||||
if(!StringUtils.isBlank(userTag)){
|
String tagName=StringUtils.isNotBlank(userTag)?DictUtils.getDictLabelNames("user_type", userTag, ","):oauthClient.nwLcUserTag(appUser.getIdCard());
|
||||||
String tagName = DictUtils.getDictLabelNames("user_type", userTag, ",");
|
tagName = StringUtils.defaultIfBlank(tagName, "");
|
||||||
String idCard = appUser.getIdCard();
|
String idCard = appUser.getIdCard();
|
||||||
if (userTag.contains(StringUtil.USER_TYPE_SY)
|
if (StringUtils.isNotBlank(idCard)&&StringUtil.isAgeBetween16And24(idCard)) {
|
||||||
&& StringUtils.isNotBlank(idCard)
|
boolean isUnemployed = StringUtils.isNotBlank(userTag) && userTag.contains(StringUtil.USER_TYPE_SY)||(StringUtils.isNotBlank(tagName) && tagName.contains("失业"));
|
||||||
&& StringUtil.isAgeBetween16And24(idCard)) {
|
if (isUnemployed && !tagName.contains("16-24岁新疆籍失业青年")) {
|
||||||
tagName += ",16-24岁新疆籍失业青年";
|
tagName += ",16-24岁新疆籍失业青年";
|
||||||
}
|
}
|
||||||
appUser.setUserTagName(tagName);
|
|
||||||
}
|
}
|
||||||
|
appUser.setUserTagName(tagName);
|
||||||
}
|
}
|
||||||
return appUser;
|
return appUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,48 @@ public class HttpUtils {
|
|||||||
return executeRequest(requestBuilder.build(), connectTimeout, readTimeout, writeTimeout);
|
return executeRequest(requestBuilder.build(), connectTimeout, readTimeout, writeTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送 GET 请求(无请求头)
|
||||||
|
*/
|
||||||
|
public static String doGet(String url) throws Exception {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.get()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new IOException("GET 请求失败,状态码:" + response.code());
|
||||||
|
}
|
||||||
|
ResponseBody body = response.body();
|
||||||
|
return body != null ? body.string() : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送 GET 请求(带请求头)
|
||||||
|
*/
|
||||||
|
public static String doGet(String url, Map<String, String> headers) throws Exception {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request.Builder builder = new Request.Builder().url(url);
|
||||||
|
|
||||||
|
if (headers != null && !headers.isEmpty()) {
|
||||||
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
|
builder.addHeader(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Request request = builder.get().build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new IOException("GET 请求失败,状态码:" + response.code());
|
||||||
|
}
|
||||||
|
ResponseBody body = response.body();
|
||||||
|
return body != null ? body.string() : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行请求核心方法
|
* 执行请求核心方法
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ public class OauthClient {
|
|||||||
@Value("${oauth.write-timeout:30}")
|
@Value("${oauth.write-timeout:30}")
|
||||||
private int writeTimeout;
|
private int writeTimeout;
|
||||||
|
|
||||||
|
/*====================== 浪潮-人员标签 ======================*/
|
||||||
|
@Value("${lc.personTag}")
|
||||||
|
public String personTagUrl;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@@ -258,6 +262,27 @@ public class OauthClient {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份证获取tagName
|
||||||
|
* @param idCard
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String nwLcUserTag(String idCard){
|
||||||
|
String url=personTagUrl+"/"+idCard;
|
||||||
|
try {
|
||||||
|
String result = HttpUtils.doGet(url);
|
||||||
|
JSONObject json = JSONObject.parseObject(result);
|
||||||
|
if(json.getIntValue("code") != 200){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JSONObject data = json.getJSONObject("data");
|
||||||
|
return data == null ? null : data.getString("tagName");
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析List
|
* 解析List
|
||||||
* @param jsonStr
|
* @param jsonStr
|
||||||
|
|||||||
Reference in New Issue
Block a user