添加从浪潮获取人员标签(先判断本地有没有,然后在从浪潮人员标签查询)

This commit is contained in:
sh
2026-05-25 19:25:36 +08:00
parent b309b0ce39
commit ac7eec396c
4 changed files with 84 additions and 8 deletions

View File

@@ -217,6 +217,11 @@ oauth:
read-timeout: 30
write-timeout: 30
#浪潮
lc:
#获取人员标签
personTag: http://10.98.80.146/prod-api/dispatch/public/person/tag
#ai
chat:
baseUrl: http://192.168.133.200:8080

View File

@@ -15,6 +15,7 @@ import com.ruoyi.cms.domain.UserInfoDetail;
import com.ruoyi.cms.util.AppUserFieldCustomCopy;
import com.ruoyi.cms.util.DictUtils;
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.entity.MyChart;
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();
@Autowired
private OauthClient oauthClient;
/**
* 查询APP用户
*
@@ -142,18 +146,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
file.setBussinessid(userId);
List<File> files=fileMapper.selectFileList(file);
appUser.setFileList(files);
//处理tag
//返回政策标签名称,主要为了查询政策用的
String userTag=appUser.getUserTag();
if(!StringUtils.isBlank(userTag)){
String tagName = DictUtils.getDictLabelNames("user_type", userTag, ",");
String tagName=StringUtils.isNotBlank(userTag)?DictUtils.getDictLabelNames("user_type", userTag, ","):oauthClient.nwLcUserTag(appUser.getIdCard());
tagName = StringUtils.defaultIfBlank(tagName, "");
String idCard = appUser.getIdCard();
if (userTag.contains(StringUtil.USER_TYPE_SY)
&& StringUtils.isNotBlank(idCard)
&& StringUtil.isAgeBetween16And24(idCard)) {
if (StringUtils.isNotBlank(idCard)&&StringUtil.isAgeBetween16And24(idCard)) {
boolean isUnemployed = StringUtils.isNotBlank(userTag) && userTag.contains(StringUtil.USER_TYPE_SY)||(StringUtils.isNotBlank(tagName) && tagName.contains("失业"));
if (isUnemployed && !tagName.contains("16-24岁新疆籍失业青年")) {
tagName += ",16-24岁新疆籍失业青年";
}
appUser.setUserTagName(tagName);
}
appUser.setUserTagName(tagName);
}
return appUser;
}

View File

@@ -127,6 +127,48 @@ public class HttpUtils {
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() : "";
}
}
/**
* 执行请求核心方法
*/

View File

@@ -76,6 +76,10 @@ public class OauthClient {
@Value("${oauth.write-timeout:30}")
private int writeTimeout;
/*====================== 浪潮-人员标签 ======================*/
@Value("${lc.personTag}")
public String personTagUrl;
@Autowired
private RedisCache redisCache;
@@ -258,6 +262,27 @@ public class OauthClient {
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
* @param jsonStr