liuxiaolong
2019-05-06 f99bc8c6a1d10610373738edd7d0aa0181c81d99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
package com.cloud.user.service.impl;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cloud.common.utils.FastDFSUtil;
import com.cloud.common.utils.RestTemplateUtil;
import com.cloud.user.dao.BbEmployeeDao;
import com.cloud.user.dao.PersonMergeDao;
import com.cloud.user.model.*;
import com.cloud.user.service.BbPersonToDevService;
import com.cloud.user.utils.Base64Utils;
import com.cloud.user.utils.EnumStr;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
 
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@Service
public class BbPersonToDevSerImpl implements BbPersonToDevService {
 
   @Value("${c_server.port}")
   private String c_ser_port = "";
   @Value("${dev_server.ip_host}")
   private String devServer = "";
   @Value("${dev_server.port}")
   private String devPort = "";
   @Value("${dev_server.addpath}")
   private String addPath = "";
   @Autowired
   private RestTemplateUtil restTempUtil;
   @Autowired
   private EnumStr enumStr;
   @Autowired
   private BbEmployeeDao bbEmployeeDao;
   @Autowired
   private PersonMergeDao perMergeDao;
 
   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   @Autowired
   private FastDFSUtil fastDFSUtil;
 
   private Integer times = 0 ;
    @Override
    public JSONArray getAllCluListData() {
        JSONArray dbClues = new JSONArray();
        log.info("devServer:"+devServer+"addPath:"+addPath);
        JSONObject devJson = restTempUtil.post(devServer + ":" + devPort + addPath + "/getAllCluListData",
                null, MediaType.APPLICATION_JSON_UTF8, JSONObject.class, true);
        JSONArray  dbJson = null;
        log.info("设备返回json:data:"+ devJson.getJSONArray("data"));
        if (devJson.getBoolean("success")){
            dbJson = devJson.getJSONArray("data");
        }else{
            throw new RuntimeException("设备模块查询集群设备信息:"+devJson.getString("msg"));
        }
        for (Object db : dbJson) {
            JSONObject dBaseCluster = new JSONObject();   //  空值
            JSONObject dbo = (JSONObject)db;
            dBaseCluster.put("id",dbo.getString("cluster_id"));
            dBaseCluster.put("label",dbo.getString("cluster_name"));
            dBaseCluster.put("parentId","0");
            List<ClusterNode> cluList = new ArrayList<ClusterNode>();
            log.info("集群设备遍历查询:"+dBaseCluster.toJSONString());
            // 2. 第二种方式
            JSONArray list = dbo.getJSONArray("list");
            JSONArray children = new JSONArray();
            if (list != null && list.size() > 0){
                for (Object o : list) {
                    JSONObject obj = (JSONObject)o;
                    JSONObject jsonObj = new JSONObject();
                    jsonObj.put("parentId",dbo.getString("cluster_id"));
                    jsonObj.put("id",obj.getString("uuid"));
                    jsonObj.put("label",obj.getString("dev_name"));
                    jsonObj.put("children",new JSONArray());
                    children.add(jsonObj);
                }
                log.info("集群设备查询:设备遍历;--->"+list);
            }
            dBaseCluster .put("children",children);
        dbClues.add(dBaseCluster);
        }
// ============ 接口 未通调用下方
      /*  DBaseCluster dBaseCluster = new DBaseCluster();   //  空值
        dBaseCluster.setCluId("uuid-ts");
        dBaseCluster.setCluName("cluster-name");
        ArrayList<ClusterNode> cluList = new ArrayList<>();
        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setUuid("wp-test-uuid1");
        clusterNode.setNode_ip("192.168.1.148");
        clusterNode.setDev_name("wp-test1");
        cluList.add(clusterNode);
        dBaseCluster.setCluList(cluList);
        dbClues.add(dBaseCluster);*/
        return dbClues;
    }
 
    @Override
    public List<DBaseCluster> getAllCluDataBaseList(){
        List<DBaseCluster> dbClues = new ArrayList<DBaseCluster>();
        log.info("devServer:"+devServer+"addPath:"+addPath);
        JSONObject devJson = restTempUtil.post(devServer + ":" + devPort + addPath +"/getAllCluDataBaseList",
                null, MediaType.APPLICATION_JSON_UTF8, JSONObject.class, true);
        log.info("设备返回:devJson:----》"+ devJson);
        if (devJson != null && devJson.getBoolean("success") ){
            JSONArray  clues = devJson.getJSONArray("data");
            log.info("各集群底库列表查询----》"+clues.toJSONString());
           if (clues!=null && clues.size()>0)
               for (Object clue : clues){
                   JSONObject clu  = (JSONObject)clue;
                   DBaseCluster cluster = new DBaseCluster();
                   cluster.setCluId(clu.getString("cluster_id"));
                   cluster.setCluName(clu.getString("cluster_name"));
                   JSONArray syncDataBase = clu.getJSONArray("syncDataBase");
                  List<SyncDataBase> sdb = new ArrayList<>();
                   if (syncDataBase != null){
                       sdb = JSONObject.parseArray(syncDataBase.toJSONString(), SyncDataBase.class);
                   }
                   cluster.setSyncDataBase(sdb);
                   JSONArray cluIPList = clu.getJSONArray("cluIPList");
                   List<CluIP> Ips = new ArrayList<>();
                   if (cluIPList != null){
                       Ips = JSONObject.parseArray(cluIPList.toJSONString(), CluIP.class);
                   }
                   cluster.setCluIPList(Ips);
                   dbClues.add(cluster);  // 将封装 集群数据 加入集合
               }
        }else {
            throw new RuntimeException("各集群底库列表查询异常。");
        }
       // 接口 未 通 调用 下方 内容
       /* DBaseCluster dBaseCluster = new DBaseCluster();   //  空值
        dBaseCluster.setCluId("uuid-db");
        dBaseCluster.setCluName("cluster-name");
        ArrayList<SyncDataBase> dataBase = new ArrayList<>();
        SyncDataBase syncDataBase = new SyncDataBase();
        syncDataBase.setTableName("wp-test-db1");
        syncDataBase.setUuid("wp-uuid-db1");
        dataBase.add(syncDataBase);
        SyncDataBase syncDataBase2 = new SyncDataBase();
        syncDataBase2.setTableName("wp-test-db2");
        syncDataBase2.setUuid("wp-uuid-db2");
        dataBase.add(syncDataBase2);
        dBaseCluster.setSyncDataBase(dataBase);
        dbClues.add(dBaseCluster);*/
       log.info("各集群底库列表 service 返回信息----》"+dbClues.toString());
        return dbClues;
    }
 
    /**
     *   String ipes = JSONArray.toJSONString(cips);
     *   JSONArray objects = JSONArray.parseArray(ipes);
     *  调用 c 服务 添加 人员
     * @param persons
     * @param ipInfos
     * @return
     */
    @Override
    public List<PerInDBStatus> addSyncPersons(List<CServerPerson> persons, List<IpTable> ipInfos){
        List<PerInDBStatus> perDBStatus = new ArrayList<PerInDBStatus>();
        List<CSerResult> dbClues = null;
        JSONObject objects = new JSONObject();
 
        log.info("分享service添加人员:===>"+persons);
        String peres = JSONArray.toJSONString(persons);// 将对象 序列化成json string
        JSONArray perJsons = JSONArray.parseArray(peres);  //  对象 json 序列化
        objects.put("personList",perJsons);
 
        // 将人员 id 加入 到 perDBStatus 中
        for (CServerPerson person : persons){
            PerInDBStatus perInDBS = new PerInDBStatus();
            perInDBS.setPersonId(person.getPersonId());
            perDBStatus.add(perInDBS);               //
        }
        log.info("分享service添加底库ipInfos:===>"+ipInfos);
        int ipInfoIndex = 1,ipInfoMax = ipInfos.size();
        for (IpTable ipTab : ipInfos){  // 遍历 集群 信息
            List<String> tableIds = ipTab.getTableIds();
            for (String tableId : tableIds){
            objects.put("uuid",tableId);
                String  dbClueJsons = restTempUtil.post( "http://"+ipTab.getIp()+ ":" + c_ser_port + "/addPersons",  // ipTab.getIp()  192.168.1.124
                    objects, MediaType.APPLICATION_JSON_UTF8, String.class, false);
                dbClues = JSONArray.parseArray(dbClueJsons, CSerResult.class);
      log.info("分享service添加底库http 参数:===>"+objects.toJSONString());
                // 假数据
              /*  int times = 1 ;
                String testAddPersonJson = "["; // 1 true/-1 false\
                for (CServerPerson person : persons){
                    if (times != persons.size()){
                        if (times%2==0){
                            testAddPersonJson += "{\"personId\":\""+person.getPersonId()+"\",\"result\":\"-1\",\"msg\":\"error\"},";
                        }else {
                        testAddPersonJson += "{\"personId\":\""+person.getPersonId()+"\",\"result\":\"1\",\"msg\":\"success\"},";
                        }
                    }else {
                        testAddPersonJson += "{\"personId\":\""+person.getPersonId()+"\",\"result\":\"-1\",\"msg\":\"error\"}]";
                    }
                    times++;
                }
                dbClues = JSONArray.parseArray(testAddPersonJson, CSerResult.class);*/
                // 待修改。。。。。。。。。
log.info("分享service添加底库http return 返回信息:===>"+dbClues);
                for (CSerResult cResult : dbClues){
                    for (PerInDBStatus perStatus : perDBStatus){
                        if (perStatus.getPersonId().equalsIgnoreCase(cResult.getPersonId())){
                            String result = cResult.getResult();
                            String msg = cResult.getMsg();
                            if (result == null || "".equals(result)){
                                msg = "c 服务调用失败。";
                                perStatus.setIsSuccess(false);
                                if (ipInfoIndex == 1){
                                    perStatus.setIsSomeSuccess(false);
                                }
                            }else if("-1".equalsIgnoreCase(result)){
                                perStatus.setIsSuccess(false);
                                if (ipInfoIndex == 1){
                                    perStatus.setIsSomeSuccess(false);
                                }
                            }else{
                                if (ipInfoIndex == 1){  // 第一次成功  ,后续在成功 则全部成功,
                                    perStatus.setIsSuccess(true);
                                }
                                if (ipInfoIndex == 1 || !perStatus.getIsSomeSuccess()){  // 判断全部失败 则false
                                    perStatus.setIsSomeSuccess(true);
                                }
                            }
                            DataBaseStatus dataBaseStatus = new DataBaseStatus(tableId,
                                    null,result,msg);
                          if (perStatus.getIsSomeSuccess())perStatus.getCluList().add(ipTab.getCluId()); //  集群信息
                            perStatus.getDbStatus().add(dataBaseStatus);
                        }
                    }
                }
            }
            ++ipInfoIndex;  // 集群 遍历坐标
        }
        log.info("分享service添加底库多人状态 service return 返回信息:===>"+perDBStatus);
        return perDBStatus;
    }
 
    /**
     * 依据 ids 获取多人数据
     * @param personIds
     * @return
     */
    public List<CServerPerson> findByPersonIds(List<String> personIds){
        List<CServerPerson> byPersonIds = new ArrayList<>();
        if (personIds== null){
            log.info("查询人员id为空null,当然查不到人啦!~~");
            return byPersonIds;
        }
        log.info(personIds.size()+"查询多人总库bb_person_base信息:"+personIds);
       byPersonIds = bbEmployeeDao.findByPersonIds(new HashSet(personIds),null);
        log.info(byPersonIds.size()+"查询多人总库bb_person_base return返回信息:"+byPersonIds);
        return byPersonIds;
    }
 
    @Override
    public List<JSONObject> addPersonsToEs(List<String> personIds) {
        List<JSONObject> esPersonIds = new ArrayList<>();
        if (personIds== null){
            log.info("查询人员id为空null,当然查不到人啦!~~");
            return esPersonIds;
        }
        List<PadPersonInfo> byPersonIds = bbEmployeeDao.findByPersonIds(new HashSet(personIds),null);
 
        for (PadPersonInfo byPersonId : byPersonIds) {
            byte[] feature = byPersonId.getByteFeature();
            if (feature == null  || feature.length < 10){
                JSONObject esAddPerson = new JSONObject();
                esAddPerson.put("status",false);
                esAddPerson.put("personId",byPersonId.getPersonId());
                esAddPerson.put("msg","feature 人员特征值不存在。");
                esPersonIds.add(esAddPerson);
                log.info(byPersonId.getPersonId()+"该人员缺特征值不能加入es索引");
            }else {
                JSONObject jsonEs = JSONObject.parseObject(JSONObject.toJSONString(byPersonId));
                jsonEs.put("id",byPersonId.getPersonId());
                jsonEs.put("update_time",sdf.format(new Date()));
                String photos = byPersonId.getPhotos();
                if (StringUtils.isBlank(photos) || photos.length() < 5 ){
                    // 暂无特征值
                }else{
                    try {
                        byte[] bytes = fastDFSUtil.downloadFDFS(byPersonId.getPhotos());
                    String s = Base64Utils.byteToBase64(bytes);
                    jsonEs.put("personImage",s);   //
                    } catch (Exception e){
                        e.printStackTrace();
                        JSONObject esAddPerson = new JSONObject();
                        esAddPerson.put("status",false);
                        esAddPerson.put("personId",byPersonId.getPersonId());
                        esAddPerson.put("msg",byPersonId.getPhotos()+"人员图片路径有误,"+e.getLocalizedMessage());
                        esPersonIds.add(esAddPerson);
                        log.info("图片base64下载失败。");
                        break;
                    }
                }
                jsonEs.put("id_card_number",byPersonId.getIdcard());   //
                jsonEs.put("personFeature",Base64Utils.byteToBase64(feature));   //
                jsonEs.put("camera_image_fastdfs_path",photos);
                jsonEs.put("synchronization_status","0");
                if (byPersonId.getPersonId().startsWith("PSVAD")){  //  分析设备
                     jsonEs.put("indevice_type","1");
                }else if (byPersonId.getPersonId().startsWith("PSSVR")){  //  后台添加人员
                    jsonEs.put("indevice_type","2");
                }else if (byPersonId.getPersonId().startsWith("PSPAD")){  // 进出入pad
                    jsonEs.put("indevice_type","3");
                }else {
                    jsonEs.put("indevice_type","4");
                }
               // 移除 非必要 字段
                jsonEs.remove("idcard");  // 移除
                jsonEs.remove("feature");
                jsonEs.remove("personPic");
                jsonEs.remove("byteFeature");
                JSONObject jsonParam = new JSONObject();
                jsonParam.put("doc",jsonEs);
                jsonParam.put("doc_as_upsert",true);
                // 人员数据 待 加入 es 新建 索引中
                String esUrl = "http://"+enumStr.getEsHOSTNAME()+":"+enumStr.getEsHTTP_PORT()+EnumStr.esUserIndex+"/"+jsonEs.getString("id")+"/_update";
                String post1 = RestTemplateUtil.post(esUrl, jsonParam, MediaType.APPLICATION_JSON_UTF8, false);
                JSONObject jsonObject = JSONObject.parseObject(post1);
                JSONObject shards = jsonObject.getJSONObject("_shards");
                if (shards != null ){   //  successful
                    Integer successful = shards.getInteger("successful");
                    if (successful != null){
                        // 成功
                        JSONObject esAddPerson = new JSONObject();
                        esAddPerson.put("status",true);
                        esAddPerson.put("personId",byPersonId.getPersonId());
                        esAddPerson.put("msg","人员 数据上传es成功。");
                        esPersonIds.add(esAddPerson);
                        log.info("加入es成功");
                    }else {
                        JSONObject esAddPerson = new JSONObject();
                        esAddPerson.put("status",false);
                        esAddPerson.put("personId",byPersonId.getPersonId());
                        esAddPerson.put("msg","人员 数据上传es 存在问题,"+shards);
                        esPersonIds.add(esAddPerson);
                        log.info("加入es失败:"+jsonObject.getJSONObject("error"));
                    }
                }else {
                    JSONObject esAddPerson = new JSONObject();
                    esAddPerson.put("status",false);
                    esAddPerson.put("personId",byPersonId.getPersonId());
                    esAddPerson.put("msg","人员 数据上传es 存在问题,"+jsonObject.getJSONObject("error"));
                    esPersonIds.add(esAddPerson);
                    log.info("加入es失败:"+jsonObject.getJSONObject("error"));
                }
            }
        }
        return esPersonIds;
    }
 
    /**
     * 查询人员状态
     * @param personId
     * @param ips
     * @return
     */
    @Override
    public List<CSerResult> isExists(String personId, List<String> ips) throws UnsupportedEncodingException {
        List<CSerResult> cResults = new ArrayList<CSerResult>();
        JSONObject object = new JSONObject();
        object.put("personId",personId);
        log.info("service isExists 查询单人底库信息:--->"+personId);
//        int times = 0 ;
        log.info("service isExists 查询单人底库信息:--->"+ips);
        for (String ip : ips){
//            CSerResult cResult
//            JSONObject result = restTempUtil.post("http://"+ip + ":" + c_ser_port + "/personIsExists",
//                    object, MediaType.APPLICATION_JSON_UTF8, JSONObject.class, false);
                String  result  = restTempUtil.post("http://"+ip + ":" + c_ser_port + "/personIsExists",
                        object, MediaType.APPLICATION_JSON_UTF8, String.class, false);
 
            CSerResult  cResult = JSONObject.parseObject(new String(result.getBytes("ISO8859-1"),"utf-8"),CSerResult.class);
            cResult.setPersonId(personId);
 
 
            cResults.add(cResult);
        }
        return cResults;
    }
 
    /**
     * 更新 人员 service
     * @param personIds
     * @param ips
     * @return
     */
    @Override
    public Map<String,List<UpdatePerToViewResult>> updateSyncPersons(List<String> personIds, List<String> ips) throws UnsupportedEncodingException {
        log.info("待更新人员数据--->:"+personIds+"待更新人员集群ip--->:"+ips);
        List<CServerPerson> byPersonIds = bbEmployeeDao.findByPersonIds(new HashSet(personIds),null);
 
        Map<String,List<UpdatePerToViewResult>> cResult = new HashMap<String,List<UpdatePerToViewResult>>();
        if (byPersonIds.size()<1){
            throw new RuntimeException("请选择总库存在人员");
        }
       /* if (personIds.size()!=byPersonIds.size()){
            throw new RuntimeException("选择的总库人员中有人数据信息不完善,不能进行分享。");
        }*/
        for (CServerPerson byPersonId : byPersonIds){
            // 获取 当前 新人员 所 关联 待更新人员
            PersonMerge personMerge = perMergeDao.selectPersonMergeByPersonId(byPersonId.getPersonId());
            String oldPerIds = null;String[] persones = {};
                List<UpdatePerToViewResult> viewResults = new ArrayList<UpdatePerToViewResult>();
            if (personMerge !=null){  // 返回该人员所须 合并人员信息
                oldPerIds = personMerge.getMergeFrom();
                persones =  oldPerIds.split(",");
                //
               /* for (String persone : persones) {
                    UpdatePerToViewResult upPerViewResult = new UpdatePerToViewResult();
                    upPerViewResult.setPersonId(persone);
                    List<CSerResult> exists = isExists(persone, ips);
                    for (CSerResult exist : exists) {
                    upPerViewResult.getAllDataBase().addAll(exist.getExistDataBase());
                    }
 
                }*/
                    cResult.put(byPersonId.getPersonId(),viewResults);
            }else {
                CSerResult dbClues = new CSerResult();
                dbClues.setPersonId(byPersonId.getPersonId());
                cResult.put(byPersonId.getPersonId(),null);
//                return cResult;
            }
            Set<String> personls =  new HashSet(Arrays.asList(persones));
            for (int i = 0,item = ips.size();i < item; ++i){
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("newPerId",byPersonId.getPersonId());
                jsonObject.put("idcard",byPersonId.getIdcard());
                jsonObject.put("perPicUrl",byPersonId.getPersonPic());
               if (byPersonId.getByteFeature() == null || byPersonId.getByteFeature().length < 5){
                   throw new RuntimeException(byPersonId.getPersonId()+"该人员特征值为空,请管理员处理。");
               }
                jsonObject.put("feature", Base64Utils.byteToBase64(byPersonId.getByteFeature()));
                if (oldPerIds != null && personls.size() > 0){
//                    String testAddPersonJson = "[";  // 测试使用json
                        for (String person : personls){
                            UpdatePerToViewResult upPerViewResult = new UpdatePerToViewResult();
                            upPerViewResult.setPersonId(person);
                            List<CSerResult> exists = isExists(person, ips);
                            for (CSerResult exist : exists) {
                                upPerViewResult.getAllDataBase().addAll(exist.getExistDataBase());
                            }
                            /*if (exists ==null || exists .size()<1){  // wp 修改于2018-12-13 ,考虑人员不存在于分析各节点上的情况
                                upPerViewResult.setResult("0");
                            }*/
//                            viewResults.add(upPerViewResult);
                            jsonObject.put("oldId",person);
                            log.info(jsonObject+"===>>>跟新人员发送信息");
                                                String dbClueJsons = restTempUtil.post("http://"+ips.get(i) + ":" + c_ser_port + "/updatePersonByOldId",
                                                        jsonObject, MediaType.APPLICATION_JSON_UTF8, String.class, false);
                                                new String();
                            UpdatePerToViewResult dbClues = JSONObject.parseObject(dbClueJsons,UpdatePerToViewResult.class);
                            log.info("返回人员更新后的信息===>>>"+dbClues);
 
                            dbClues.setPersonId(person); // 赋值
 
                            if ("1".equals(dbClues.getResult())){  // 说明 存在
//                                UpdatePerToViewResult cSerResult = cResult.get(person);
                                if (upPerViewResult.getResult()==null){upPerViewResult.setResult("1");
                                    upPerViewResult.setMsg("success");}
                                upPerViewResult.getExistDataBase().addAll(dbClues.getExistDataBase());
//                                cResult.put(person,cSerResult);
                            }else if ("-1".equals(dbClues.getResult())){
//                                UpdatePerToViewResult cSerResult = cResult.get(person);
                                upPerViewResult.setResult("-1");
                                upPerViewResult.setMsg("error");
//                                cResult.put(person,upPerViewResult);
                            }else {
//                                UpdatePerToViewResult cSerResult = cResult.get(person);
                                if (upPerViewResult.getResult()==null){upPerViewResult.setResult("0");
                                    upPerViewResult.setMsg("succes");  //cResult.put(person,cSerResult);
                                }
                            }
                            viewResults.add(upPerViewResult);
                        }
                    }else{      //  不包含 待更新人员 也需要将人员更新一便
                        jsonObject.put("oldId","");
                           String dbClueJsons1 = restTempUtil.post("http://"+ips.get(i) + ":" + c_ser_port + "/updatePersonByOldId",
                                   jsonObject, MediaType.APPLICATION_JSON_UTF8, String.class, false);
 
                        UpdatePerToViewResult dbClues =   //  new UpdatePerToViewResult();
                               JSONObject.parseObject(dbClueJsons1,UpdatePerToViewResult.class); // 测试时给空对象,实际要调用c接口
 
                        dbClues.setPersonId(byPersonId.getPersonId()); // 赋值
                        viewResults.add(dbClues);
                    }
            }
            cResult.put(byPersonId.getPersonId(),viewResults);
        }
        return cResult;
    }
 
    @Override
    public List<MergePersonView> queryUpdatingPerson(String personLike) {
        List<MergePersonView> allMergePerson = bbEmployeeDao.findAllMergePerson();
        MergePersonView mergePerson = null;
        for (int i = 0;i < allMergePerson.size();++i){
            mergePerson = allMergePerson.get(i);
            boolean flag = true;
            if (personLike!=null && !personLike.isEmpty()){
                String idCard = mergePerson.getIdcard();
                String perName = mergePerson.getName();
                if ((idCard!=null && idCard.contains(personLike))||(perName!=null && perName.contains(personLike))){
                }else { flag = false;}
            }
            String mergeFrom = mergePerson.getMergeFrom();
            if (mergeFrom!=null){
                String[] split = mergeFrom.split(",");
                mergePerson.setMergePersonIds(new HashSet(Arrays.asList(split)));
                List<CServerPerson> byPersonIds = bbEmployeeDao.findByPersonIds(new HashSet(Arrays.asList(split)),personLike);
               if (flag || byPersonIds.size()>0 ){
                   mergePerson.setMergePersonList(byPersonIds);
               }else{
                   allMergePerson.remove(i--);
               }
            }
        }
        return allMergePerson;
    }
 
    @Override
    public Integer queryUpdatingPersonCount() {
        return bbEmployeeDao.queryUpdatingPersonCount();
    }
 
    @Override
    public Integer deleteMergePersonByPersonId(String personId) {
        return bbEmployeeDao.deleteMergePerson(personId);
    }
 
    @Override
    public Integer updatePersonForCluInfo(Set<String> cluInfos, String personId) {
        if (cluInfos==null || cluInfos.size()<1){
            return 0;}else {
        return bbEmployeeDao.updateBbPersonBaseForCluInfo(cluInfos,personId);
        }
    }
 
 
}