|
@@ -1674,54 +1674,19 @@ public class CustomerApiController {
|
|
mpInfo.put("id",indid);
|
|
mpInfo.put("id",indid);
|
|
|
|
|
|
|
|
|
|
- String salecom = source.getString("salecom");
|
|
|
|
- //多渠道不显示标签 最高级全部显示 , 渠道不一样 不显示
|
|
|
|
- if(StringUtils.isEmpty(deptCode)||deptCode.equals(salecom)){
|
|
|
|
- //单渠道显示所有标签
|
|
|
|
- mpInfo.putAll(JSON.parseObject(jsonObject.getString("_source"),Map.class));
|
|
|
|
- } else{
|
|
|
|
- logger.info(jsonObject.toJSONString());
|
|
|
|
- Map<String, Object> maps = JSON.parseObject(jsonObject.getString("_source"),Map.class);
|
|
|
|
-
|
|
|
|
- List<String> publicLabels = new ArrayList<>();
|
|
|
|
- publicLabels.add("label1");
|
|
|
|
- publicLabels.add("label2");
|
|
|
|
- publicLabels.add("label3");
|
|
|
|
- publicLabels.add("label4");
|
|
|
|
- publicLabels.add("label9");
|
|
|
|
- publicLabels.add("label10");
|
|
|
|
- publicLabels.add("label21");
|
|
|
|
- publicLabels.add("Label67");
|
|
|
|
- publicLabels.add("Label69");
|
|
|
|
- publicLabels.add("Label70");
|
|
|
|
- publicLabels.add("Label71");
|
|
|
|
- publicLabels.add("Label74");
|
|
|
|
- publicLabels.add("label77");
|
|
|
|
- publicLabels.add("Label80");
|
|
|
|
- publicLabels.add("Label96");
|
|
|
|
- publicLabels.add("Label97");
|
|
|
|
- publicLabels.add("Label100");
|
|
|
|
- publicLabels.add("Label101");
|
|
|
|
- publicLabels.add("Label103");
|
|
|
|
- publicLabels.add("Label104");
|
|
|
|
- publicLabels.add("Label105");
|
|
|
|
- publicLabels.add("Label106");
|
|
|
|
-
|
|
|
|
- for (Map.Entry<String, Object> entry : maps.entrySet()){
|
|
|
|
- String key = entry.getKey();
|
|
|
|
- if(key.startsWith("label")){
|
|
|
|
- if(publicLabels.contains(key)){
|
|
|
|
- //公用标签显示
|
|
|
|
- mpInfo.put(key,entry.getValue());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- mpInfo.put(key,entry.getValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ String salecom = source.getString("salecom"); // 可能会得到用逗号分割的多个标签
|
|
|
|
+ String[] salecoms = salecom.split(",");
|
|
|
|
+ Arrays.sort(salecoms);
|
|
|
|
+ Map<String, Object> sourceMap = JSON.parseObject(jsonObject.getString("_source"), Map.class);
|
|
|
|
+ if (StringUtils.isEmpty(deptCode)) {
|
|
|
|
+ // 根渠道,也就是上海人寿,也是admin用户所属的渠道,返回jsonObject中的所有标签(公共标签 + 渠道标签)
|
|
|
|
+ mpInfo.putAll(sourceMap);
|
|
|
|
+ } else if (Arrays.binarySearch(salecoms, deptCode) >= 0) {
|
|
|
|
+ // 登录用户的渠道与客户渠道一致,返回jsonObject中的公共标签 + shanglifeecif.customerno_salecom_relation表中的渠道标签
|
|
|
|
+ mpInfo.putAll(getPublicLabels(sourceMap));
|
|
|
|
+ mpInfo.putAll(getSalecomLabels(source.getString("scustid"), deptCode));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if(mpInfo.containsKey("birthday")){
|
|
if(mpInfo.containsKey("birthday")){
|
|
mpInfo.put("birthday", source.getString("birthday"));
|
|
mpInfo.put("birthday", source.getString("birthday"));
|
|
mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD,source.getString("birthday"))));
|
|
mpInfo.put("age",DateUtils.getAge(DateUtils.dateTime(DateUtils.YYYY_MM_DD,source.getString("birthday"))));
|
|
@@ -1734,4 +1699,80 @@ public class CustomerApiController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 只返回公共标签(以label开头和不以label开头的公共标签都会返回)
|
|
|
|
+ * @param source 包含所有标签的map
|
|
|
|
+ * @return 只包含公共标签的map
|
|
|
|
+ */
|
|
|
|
+ private Map<String, Object> getPublicLabels(Map<String, Object> source) {
|
|
|
|
+ Map<String, Object> rst = new HashMap<>();
|
|
|
|
+ // 一般公共标签的key不以label开头,但也有一部分公共标签是以label开头的,将以label开头的公共标签Key存入list后续使用
|
|
|
|
+ List<String> publicLabels = new ArrayList<>(); // 存放以label开头的公共标签key
|
|
|
|
+ publicLabels.add("label1");
|
|
|
|
+ publicLabels.add("label2");
|
|
|
|
+ publicLabels.add("label3");
|
|
|
|
+ publicLabels.add("label4");
|
|
|
|
+ publicLabels.add("label9");
|
|
|
|
+ publicLabels.add("label10");
|
|
|
|
+ publicLabels.add("label21");
|
|
|
|
+ publicLabels.add("Label67");
|
|
|
|
+ publicLabels.add("Label69");
|
|
|
|
+ publicLabels.add("Label70");
|
|
|
|
+ publicLabels.add("Label71");
|
|
|
|
+ publicLabels.add("Label74");
|
|
|
|
+ publicLabels.add("label77");
|
|
|
|
+ publicLabels.add("Label80");
|
|
|
|
+ publicLabels.add("Label96");
|
|
|
|
+ publicLabels.add("Label97");
|
|
|
|
+ publicLabels.add("Label100");
|
|
|
|
+ publicLabels.add("Label101");
|
|
|
|
+ publicLabels.add("Label103");
|
|
|
|
+ publicLabels.add("Label104");
|
|
|
|
+ publicLabels.add("Label105");
|
|
|
|
+ publicLabels.add("Label106");
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, Object> entry : source.entrySet()){
|
|
|
|
+ String key = entry.getKey();
|
|
|
|
+ if(key.startsWith("label")){
|
|
|
|
+ if(publicLabels.contains(key)){
|
|
|
|
+ // 以label开头的公共标签
|
|
|
|
+ rst.put(key,entry.getValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ // 不以label开头的公共标签
|
|
|
|
+ rst.put(key,entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rst;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 从ES表shanglifeecif.customerno_salecom_relation中获得指定客户指定渠道的渠道标签
|
|
|
|
+ * @param customerno 客户号
|
|
|
|
+ * @param salecom 渠道号
|
|
|
|
+ * @return 指定客户指定渠道的所有渠道标签
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Object> getSalecomLabels(String customerno, String salecom) throws IOException {
|
|
|
|
+ Map<String, Object> rst = new HashMap<>();
|
|
|
|
+ String q = String.format("customerno:%s%20AND%20salecom:%s", customerno, salecom);
|
|
|
|
+ Request scriptRequest = new Request("GET", "/shanglifeecif.customerno_salecom_relation/_search?pretty=true&q="+ q);
|
|
|
|
+ Response response = restClient.performRequest(scriptRequest);
|
|
|
|
+ String result = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result);
|
|
|
|
+ JSONObject hitsobject = (JSONObject) jsonObject.get("hits");
|
|
|
|
+ JSONArray array = JSON.parseArray(hitsobject.get("hits").toString());
|
|
|
|
+ for (int i = 0; i <array.size() ; i++) {
|
|
|
|
+ JSONObject json = (JSONObject)array.get(i);
|
|
|
|
+ Map<String, Object> source = JSON.parseObject(json.getString("_source"), Map.class);
|
|
|
|
+ for (Map.Entry<String, Object> entry : source.entrySet()){
|
|
|
|
+ String key = entry.getKey();
|
|
|
|
+ if(key.startsWith("label")){
|
|
|
|
+ rst.put(key, entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return rst;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|