a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
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.basic.security.manager;
 
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Base64;
 
import com.basic.security.base.BaseApplication;
import com.basic.security.manager.es.ReadConfig;
import com.basic.security.model.ModelAdapter;
import com.basic.security.model.Org;
import com.basic.security.model.Person;
import com.basic.security.model.PersonA;
import com.basic.security.utils.Base64Util;
import com.basic.security.utils.BasicIdUtil;
import com.basic.security.utils.BitmapHolder;
import com.basic.security.utils.CompareFeatureResult;
import com.basic.security.utils.Constants;
import com.basic.security.utils.ExcelUtil;
import com.basic.security.utils.FaceId;
import com.basic.security.utils.FastDFSUtil;
import com.basic.security.utils.SocketUtil;
import com.basic.security.utils.ToastUtil;
 
import org.androidannotations.api.BackgroundExecutor;
import org.json.JSONArray;
import org.json.JSONObject;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;
 
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import static com.basic.security.model.Sync.needSync;
 
public class PersonManager extends BaseManager {
    static Map<String, ModelAdapter> findPersonByIdMap = new HashMap<>();
    static long lastFindPersonById = System.currentTimeMillis();
    static BitmapHolder bitmapHolder = new BitmapHolder();
 
    public static void savePerson(ModelAdapter person) {
        removePersonFromCache(person);
        save(person);
        GuestManager.updateGuestName(person);
//        uploadToTemporary(person.getId());
    }
 
    public static void uploadToTemporary(String personId) {
        BackgroundExecutor.execute(new BackgroundExecutor.Task("", 0, "") {
            public void execute() {
                try {
                    ModelAdapter savedPerson = PersonManager.findById("person", personId);
                    RequestParams params = new RequestParams("http://" + ReadConfig.getInstance().getTempHost() + ":" + ReadConfig.getInstance().getTempPort() + "" + ReadConfig.getInstance().getTempUrl() + "");
                    params.addHeader("Content-Type", "application/json-rpc");
                    JSONArray jsonArray = new JSONArray();
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("id", savedPerson.getId());
                    jsonObject.put("name", savedPerson.getString("name")); //姓名(可空)
                    jsonObject.put("cardId", savedPerson.getString("id_card_number")); //身份证号(可以不准)
                    jsonObject.put("gender", savedPerson.getString("")); //性别(可空)
                    jsonObject.put("phone", savedPerson.getString("phone")); //手机号(可空)
                    jsonObject.put("distributionIds", savedPerson.getString("")); //集群id(必需)
                    jsonObject.put("distributionNames", savedPerson.getString("")); //集群名称(必需)
                    jsonObject.put("deviceId", DeviceManager.getDeviceId()); //设备id:例如: DSPAD010120181101(类似这种之前统一规定的设备id)
                    String camera_image_fastdfs_path = savedPerson.getString("camera_image_fastdfs_path");
                    if (camera_image_fastdfs_path == null || camera_image_fastdfs_path.length() == 0) {
                        byte[] camera_image_path = savedPerson.getBlob("camera_image_path");
                        if (camera_image_path != null && camera_image_path != null) {
                            String picPath = FastDFSUtil.upLoadVisitorPic(camera_image_path, System.currentTimeMillis());
                            savedPerson.setString("camera_image_fastdfs_path", picPath);
                        }
                    }
                    jsonObject.put("photos", savedPerson.getString("camera_image_fastdfs_path")); //图片的fstdfs路径(必需)
                    byte[] camera_image_feature = savedPerson.getBlob("camera_image_feature");
                    if (camera_image_feature != null && camera_image_feature != null) {
                        jsonObject.put("featureBase64", Base64.encodeToString(camera_image_feature, Base64.NO_WRAP)); //图片的特征值(必需)
                    }
                    jsonArray.put(jsonObject);
                    String bodyJsonContent = jsonArray.toString();
                    params.setBodyContent(bodyJsonContent);
                    params.setAsJsonContent(true);
                    x.http().post(params, new Callback.CommonCallback<String>() {
                        public void onSuccess(String result) {
                        }
 
                        public void onError(Throwable ex, boolean isOnCallback) {
                            ex.printStackTrace();
                            System1.out.println("httponError");
                        }
 
                        public void onCancelled(CancelledException cex) {
                            System1.out.println("httponCancelled");
                        }
 
                        public void onFinished() {
                        }
                    });
                } catch (Exception e) {
                    System1.out.println("PersonManager.execute " + e.getMessage());
//                    e.printStackTrace();
                }
            }
        });
    }
 
    //删除人员
    public static void deletePerson(ModelAdapter person) {
        try {
            if ("1".equals(person.getString("auto_init"))) {
                return;
            }
            if (Constants.deletePersonPhysical) {
                String camera_image_path = ModelAdapter.getAttachmentPath(person.getId(), Person.camera_image_path, Person.tableName);
                if (!TextUtils.isEmpty(camera_image_path)) {
                    File camera_image_path_file = new File(camera_image_path);
                    if (camera_image_path_file.exists()) {
                        camera_image_path_file.delete();
                    }
                }
            }
            FeatureManager.removeFeature(person.getString(Person.id));
            PersonIdentityManager.deletePersonIdentityByPersonId(person.getString(Person.id));
            PersonAManager.deletePersonAByPerson(person);
            if (Constants.deletePersonPhysical) {
                deletePhysically(person);
            } else {
                deleteWithDelFlag(person);
            }
            removePersonFromCache(person);
            SocketUtil.rpcCallDeletePerson(person);
            if (Constants.isIndoor) {
                GuestManager.removePersonId(person.getString(Person.id));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    public static void deletePersonList(List<ModelAdapter> modelAdapterList) {
        for (ModelAdapter modelAdapter : modelAdapterList) {
            deletePerson(modelAdapter);
        }
    }
 
    //获取所有人员信息的列表
    public static List<ModelAdapter> getPersonList(String sign_up_status) {
        List<ModelAdapter> allPersonList = new ArrayList<>();
        String del_flag = "0";
        if (syncTableNames.contains("person")) {
            del_flag = Base64Util.encodeToString("person", "del_flag", del_flag);
            sign_up_status = Base64Util.encodeToString("person", "sign_up_status", sign_up_status);
        }
        List<ModelAdapter> documentList = findList("select * from person where name!='系统管理员' and del_flag ='" + del_flag + "' and sign_up_status='" + sign_up_status + "' order by sign_up_time desc");
        // 过滤掉不是本设备的系统管理员
        for (ModelAdapter person : documentList) {
            if (!"1".equals(person.getString("auto_init"))
                    || ("1".equals(person.getString("auto_init"))
                    && DeviceManager.getDeviceId().equals(person.getString("device_id")))) {
                // 过滤掉人脸特征为空的人
                if (person.getBlob("camera_image_feature") != null
                        || ("1".equals(person.getString("auto_init"))
                        && DeviceManager.getDeviceId().equals(person.getString("device_id")))) {
                    allPersonList.add(person);
                }
            }
        }
        return allPersonList;
    }
 
    public static void removePersonFromCache(ModelAdapter person) {
        try {
            String personId = person.getString(Person.id);
            findPersonByIdMap.remove(personId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    public static ModelAdapter findPersonById(String personId) {
        try {
            ModelAdapter person = findPersonByIdMap.get(personId);
            if (System.currentTimeMillis() - lastFindPersonById < 1000 && person != null) {
                return person;
            } else {
                person = findById("person", personId);
                findPersonByIdMap.put(personId, person);
                lastFindPersonById = System.currentTimeMillis();
            }
            return person;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    // 获取含有特定身份的所有人员
    public static List<ModelAdapter> getIdentityPersonList(List<ModelAdapter> allPersonList, Map<String, ModelAdapter> checkedIdentityMap) {
        List<ModelAdapter> allPersonIdList = new ArrayList<>();// 获取符合身份的所有人员信息
        List<ModelAdapter> personList = new ArrayList<>();
        Map<String, ModelAdapter> checkedPerson = new HashMap<>();
        personList.clear();
        allPersonIdList.clear();
        checkedPerson.clear();
        // 获取符合身份的所有人员信息
        for (String ruleId : checkedIdentityMap.keySet()) {
            allPersonIdList.addAll(findList("select * from person_identity where identity_id='" + ruleId + "'"));
        }
        for (int j = 0; j < allPersonList.size(); j++) {
            for (int i = 0; i < allPersonIdList.size(); i++) {
                if (allPersonList.get(j).getId().equals(allPersonIdList.get(i).getString("person_id"))
                        && !checkedPerson.containsKey(allPersonIdList.get(i).getString("person_id"))) {
                    checkedPerson.put(allPersonIdList.get(i).getString("person_id"), allPersonList.get(j));
                    ModelAdapter person = allPersonList.get(j);
                    if (person != null) {
                        personList.add(person);
                    }
                }
            }
        }
        return personList;
    }
 
 
    public static void reFindPerson(CompareFeatureResult compareFeatureResult) {
        try {
            if (compareFeatureResult != null && compareFeatureResult.person != null) {
                compareFeatureResult.person = PersonManager.findPersonById(compareFeatureResult.personId);
            }
            if (compareFeatureResult != null && compareFeatureResult.person == null) {
                compareFeatureResult.personId = "";
            }
        } catch (Exception e) {
            try {
                if (compareFeatureResult != null) {
                    compareFeatureResult.person = null;
                    compareFeatureResult.personId = "";
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            e.printStackTrace();
        }
    }
 
    // 人员注册时选中的为有效时间内通行,返回的为可以通行的时间规则
    public static List<ModelAdapter> getValidSignUpRuleList(ModelAdapter person) {
        List<ModelAdapter> checkedTimeRuleList = new ArrayList<>();
        String checked_time_rule_id = person.getString("checked_time_rule_id");
        if (!TextUtils.isEmpty(checked_time_rule_id)) {
            if (TimeRuleManager.timeRuleIsValid(checked_time_rule_id)) {
                ModelAdapter checked_time_rule = findById("time", checked_time_rule_id);
                checkedTimeRuleList.add(checked_time_rule);
            }
        }
        return checkedTimeRuleList;
    }
 
    // 人员注册时选中的为有效时间内通行,提前多久提示,返回的为可以通行的时间规则
    public static List<ModelAdapter> getValidSignUpRuleListButTimeNotReach(ModelAdapter person) {
        List<ModelAdapter> checkedTimeRuleList = new ArrayList<>();
        long noReachTime = HintDoorAccessManager.getNoReachTime();
        String checked_time_rule_id = person.getString("checked_time_rule_id");
        if (!TextUtils.isEmpty(checked_time_rule_id)) {
//            if (TimeRuleManager.timeRuleIsValid(checked_time_rule_id),noReachTime * 1000){
            if (TimeRuleManager.timeRuleIsValid(checked_time_rule_id, noReachTime * 60 * 1000)) {
                ModelAdapter checked_time_rule = findById("time", checked_time_rule_id);
                checkedTimeRuleList.add(checked_time_rule);
            }
        }
        return checkedTimeRuleList;
    }
 
    public static List<ModelAdapter> findPersonList(String sql) {
        return findList(sql);
    }
 
    public static ModelAdapter findByNameAndOrgId(String personName, String personOrgId) {
        return findOne("select * from " + Person.tableName + " where " + Person.name + "='" + personName + "' " +
                "and " + Person.org_id + "='" + personOrgId + "'");
    }
 
    public static void importPersonList(String dirPath) {
        Map<String, File> photoFileMap = new HashMap<>();
        File dir = new File(dirPath);
        File[] files = dir.listFiles();
        File excelFile = null;
        for (File file : files) {
            String fileName = file.getName();
            if (fileName.endsWith(".jpg")
                    || fileName.endsWith(".jpeg")
                    || fileName.endsWith(".png")
                    || fileName.endsWith(".JPG")
                    ) {
                fileName = fileName.substring(0, fileName.lastIndexOf('.'));
                photoFileMap.put(fileName, file);
            }
            if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
                excelFile = file;
            }
        }
        if (photoFileMap.size() == 0) {
            ToastUtil.show("选择的文件夹中没有人脸照片");
            return;
        }
        ExcelUtil.parseExcel(excelFile, photoFileMap);
    }
 
    private static byte[] cropImage(int x1, int y1, int x2, int y2, Bitmap frameBitmap) {
        float ratio = 0.8f;
        int enlargeWidth = (int) (ratio * (x2 - x1));
        int enlargeHeight = (int) (ratio * (y2 - y1));
        x1 = x1 - enlargeWidth / 2;
        x2 = x2 + enlargeWidth / 2;
        y1 = y1 - enlargeHeight / 2;
        y2 = y2 + enlargeHeight / 2;
        if (x1 < 0) {
            x1 = 0;
        }
        if (y1 < 0) {
            y1 = 0;
        }
        if (x2 > frameBitmap.getWidth()) {
            x2 = frameBitmap.getWidth();
        }
        if (y2 > frameBitmap.getHeight()) {
            y2 = frameBitmap.getHeight();
        }
        int width = (x2 - x1);
        int height = (y2 - y1);
        if (width > frameBitmap.getWidth()) {
            width = frameBitmap.getWidth();
        }
        if (height > frameBitmap.getHeight()) {
            height = frameBitmap.getHeight();
        }
        Bitmap bitmap = null;
        if (frameBitmap != null) {
            bitmap = frameBitmap;
        }
        byte[] faceData = null;
        if (bitmap != null) {
            bitmapHolder.storeBitmap(bitmap);
            bitmapHolder.cropBitmap(x1, y1, x2, y2);
            Bitmap faceBitmap = bitmapHolder.getBitmapAndFree();
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            faceBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            faceData = stream.toByteArray();
            if (faceBitmap != null && !faceBitmap.isRecycled()) {
                faceBitmap.recycle();
            }
        }
        return faceData;
    }
 
    public static ModelAdapter savePicToDatabase(File file, String orgId) {
        try {
            String _name = file.getName();
            String filePath = file.getAbsolutePath();//获取文件路径
            String fileName = file.getName().substring(0, _name.lastIndexOf("."));//获取文件名
            Bitmap bitmap = BitmapFactory.decodeFile(filePath);
            BaseApplication.getApplication().detectLock.lock();
            String facePosition = FaceId.instance.facePosition(file.getAbsolutePath());
            if (facePosition.length() <= 0) {
                System1.out.println("SaveTestData.run 没有找到人脸");
                return null;
            }
            String[] rectFace = facePosition.split(",");
            byte[] faceJpgData = cropImage(Integer.parseInt(rectFace[0]),
                    Integer.parseInt(rectFace[1]),
                    Integer.parseInt(rectFace[2]),
                    Integer.parseInt(rectFace[3]), bitmap);
            byte[] featureData = FaceId.instance.extractFeature(file.getAbsolutePath());
            BaseApplication.getApplication().detectLock.unlock();
            if (featureData == null) {
                System1.out.println("SaveTestData.run 提取特征失败! 请检查SDK是否初始化");
                return null;
            }
            String compareResultStr = FeatureManager.compareFeature(featureData, Constants.minRecognizeScore);
            String personId = compareResultStr.split(",", -1)[0];
            if (!TextUtils.isEmpty(personId)) {
                return findById(Person.tableName, personId);
            }
            ModelAdapter person = new ModelAdapter()
                    .setString(Person.id, BasicIdUtil.getPersonId(featureData))
                    .setString("name", fileName)
                    .setString("sign_up_status", "已注册")
                    .setString("verify_status", "不需要验证身份证")
                    .setString("sign_up_method", "统一导入")
                    .setString("sign_up_time", System.currentTimeMillis() + "")
                    .setString("device_id", DeviceManager.getDeviceId())
                    .setString("company_id", CompanyManager.getCompanyId())
                    .setString(Person.org_id, orgId)
                    .setString("table", "person");
            person.setString(Person.device_id, DeviceManager.getDeviceId());
            person.setString(Person.company_id, CompanyManager.getCompanyId());
            person.setBlob("camera_image_feature", featureData);
            person.setBlob("camera_image_path", faceJpgData);
            PersonManager.savePerson(person);
            FeatureManager.addFeature(person.getId(), featureData);
            return person;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    public static List<ModelAdapter> filterByOrgId(List<ModelAdapter> personList, String selectedOrgId) {
        if (!TextUtils.isEmpty(selectedOrgId)) {
            List<ModelAdapter> newPersonList = new ArrayList<>();
            for (ModelAdapter person : personList) {
                String person_org_ids = person.getString(Person.org_ids);
                if (person_org_ids != null && person_org_ids.contains(Org.separator + selectedOrgId + Org.separator)) {
                    newPersonList.add(person);
                }
            }
            return newPersonList;
        }
        return personList;
    }
 
    public static List<ModelAdapter> findPersonContainsOrgId(String orgId) {
        return findList("select * from person where " + Person.org_ids + " like '%" + Org.separator + orgId + Org.separator + "%'");
    }
 
    public static void insertPersonFromPersonA(ModelAdapter personA) {
        class InsertPersonFromPersonAHelper {
            public void addPerson() {
                ModelAdapter person = new ModelAdapter();
                person.setString(Person.camera_image_feature_path, "");
                person.setString(Person.student_id, "");
                person.setString(Person.checked_time_rule_id, "");
                person.setString(Person.sign_up_rule, "");
                person.setString(Person.org_id, "");
                person.setString(Person.org_ids, "");
                person.setString(Person.id, personA.getString(PersonA.id));
                person.setString(Person.name, personA.getString(PersonA.personName));
                person.setString(Person.camera_image_feature, personA.getString(PersonA.faceFeature));
                person.setString(Person.phone, personA.getString(PersonA.phoneNum));
                person.setString(Person.sign_up_time, System.currentTimeMillis() + "");
                person.setString(Person.sign_up_status, "已注册");
                person.setString(Person.auto_init, "0");
                person.setString(Person.table, Person.tableName);
                person.setString(Person.del_flag, "0");
                person.setString(Person.update_time, System.currentTimeMillis() + "");
                person.setString(Person.id_card_number, personA.getString(PersonA.idCard));
                person.setString(Person.verify_status, "不需要验证身份证");
                person.setString(Person.camera_image_bitmap, "");
                person.setString(Person.camera_image_fastdfs_path, "");
                person.setString(Person.id_card_image_path, "");
                person.setString(Person.id_card_image_feature, "");
                person.setString(Person.type, "");
                person.setString(Person.sign_up_method, "分析导入");
                person.setString(Person.guest_allow_start_time, "");
                person.setString(Person.all_device, "1");
                person.setString(Person.company_id, CompanyManager.getCompanyId());
                person.setString(Person.device_id, DeviceManager.getDeviceId());
                person.setString(Person.respondent_ids, "");
                person.setString(Person.respondent_names, "");
                person.setString(Person.guest_visit_status, "");
                person.setString(Person.guest_visit_valid_time, "");
                person.setString(Person.guest_exit_time, "");
                person.setString(Person.guest_enter_time, "");
                person.setString(Person.guest_visit_reason, "");
                person.setString(Person.guest_remark, "");
                person.setString(Person.id, personA.getId());
                person.setString(needSync, Constants.FALSE);
                if (person.getString(Person.del_flag).equals("0")) {
                    byte[] feature = person.getBlob(Person.camera_image_feature);
                    if (feature != null && feature.length > 10) {
                        FeatureManager.addFeature(person.getId(), feature);
                    }
                } else {
                    FeatureManager.removeFeature(person.getId());
                }
                savePerson(person);
            }
 
 
            public void updatePerson(ModelAdapter dbPerson) {
                dbPerson.setString(Person.id, personA.getString(PersonA.id));
                dbPerson.setString(Person.name, personA.getString(PersonA.personName));
                dbPerson.setString(Person.camera_image_feature, personA.getString(PersonA.faceFeature));
                dbPerson.setString(Person.phone, personA.getString(PersonA.phoneNum));
                dbPerson.setString(Person.sign_up_time, System.currentTimeMillis() + "");
                dbPerson.setString(Person.verify_status, "已注册");
                dbPerson.setString(Person.auto_init, "0");
                dbPerson.setString(Person.table, Person.tableName);
                dbPerson.setString(Person.del_flag, "0");
                PersonCameraImagePathManager.download_camera_image_path(personA.getString(PersonA.personPicUrl), dbPerson);
                if (dbPerson.getString(Person.del_flag).equals("0")) {
                    byte[] feature = dbPerson.getBlob(Person.camera_image_feature);
                    if (feature != null && feature.length > 10) {
                        FeatureManager.addFeature(dbPerson.getId(), feature);
                    }
                } else {
                    FeatureManager.removeFeature(dbPerson.getId());
                }
                dbPerson.setString(needSync, Constants.FALSE);
                savePerson(dbPerson);
            }
 
            public void addPersonA() {
                personA.setString(needSync, Constants.FALSE);
                PersonAManager.savePersonA(personA);
            }
 
            public void updatePersonA(ModelAdapter dbPersonA) {
                personA.setString(needSync, Constants.FALSE);
                dbPersonA.setString(needSync, Constants.FALSE);
                PersonAManager.savePersonA(personA);
            }
 
            public void execute() {
                ModelAdapter dbPerson = PersonManager.findPersonById(personA.getString(PersonA.id));
                if (dbPerson == null) {
                    addPerson();
                } else {
                    updatePerson(dbPerson);
                }
                ModelAdapter dbPersonA = PersonAManager.findPersonAById(personA.getString(PersonA.id));
                if (dbPersonA == null) {
                    addPersonA();
                } else {
                    updatePersonA(dbPersonA);
                }
            }
        }
        new InsertPersonFromPersonAHelper().execute();
        String identities = personA.getString(PersonA.identities);
        PersonIdentityManager.reSavePersonIdentities(personA.getString(PersonA.id), identities);
        ModelAdapter personAType = PersonATypeManager.findPersonATypeById(personA.getString(PersonA.tableId));
    }
 
    public static void updatePersonFromPersonA(ModelAdapter personA) {
        insertPersonFromPersonA(personA);
    }
 
    public static void deletePersonFromPersonA(ModelAdapter personA) {
        insertPersonFromPersonA(personA);
    }
 
    public static int getNotSignUpCount() {
        return findList("select * from " + Person.tableName + " where " + Person.sign_up_status + "='未注册'").size();
    }
}