15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
package com.hxzkoa.services;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.hxzkoa.json.tb_achor;
import com.hxzkoa.json.tb_collector;
import com.hxzkoa.json.tb_department;
import com.hxzkoa.json.tb_icon;
import com.hxzkoa.json.tb_kaoqing;
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_realkaoqing;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ModifyConfig;
 
@Service
public class BasicInfoService {
    @PersistenceContext
    private EntityManager em;
    @Autowired
    private CaozuoService cs;
 
    public List<tb_icon> getIconManagement(int page) {
        int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
        int start = (page - 1) * perPage;
        int end = perPage;
        String sql = null;
        Query query = null;
        sql = "SELECT Serial_number,icon_name,icon_adress,add_time,beizhu FROM tb_icon LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", start);
        query.setParameter("end", end);
        List resultList = query.getResultList();
        List<tb_icon> tb_iconList = new ArrayList<tb_icon>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_icon icon = new tb_icon();
                Object[] obj = (Object[]) resultList.get(i);
                icon.setSerial_number((int) obj[0]);
                icon.setIcon_name(obj[1] == null ? "" : obj[1].toString());
                icon.setIcon_adress(obj[2] == null ? "" : obj[2].toString());
                icon.setAdd_time(obj[3] == null ? "" : obj[3].toString());
                icon.setBeizhu(obj[4] == null ? "" : obj[4].toString());
                tb_iconList.add(icon);
            }
        }
        return tb_iconList;
    }
 
    public int getIconManagementCount() {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_icon";
        query = this.em.createNativeQuery(sql);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    @Transactional
    public int iconManagement_add(tb_icon icon) {
        String sql = null;
        Query query = null;
        sql = "INSERT INTO tb_icon( icon_name,icon_adress,add_time,beizhu) VALUES(:icon_name,:icon_adress,now(),:beizhu)";
        cs.tb_caozuo("tb_icon", 1);
        query = this.em.createNativeQuery(sql);
        query.setParameter("icon_name", icon.getIcon_name());
        query.setParameter("icon_adress", icon.getIcon_adress());
        query.setParameter("beizhu", icon.getBeizhu());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int iconManagement_check(String iconName) {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_icon WHERE icon_Name= :iconName";
        query = this.em.createNativeQuery(sql);
        query.setParameter("iconName", iconName);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    @Transactional
    public void iconManagement_delete(String[] checkVal) {
        String sql = null;
        Query query = null;
        for (int i = 0; i < checkVal.length; i++) {
            int id = Integer.parseInt(checkVal[i]);
            sql = "DELETE FROM tb_icon WHERE Serial_number = :id";
            cs.tb_caozuo("tb_icon", 2);
            query = this.em.createNativeQuery(sql);
            query.setParameter("id", id);
            query.executeUpdate();
        }
    }
 
    public List<tb_department> getDepartmentManagement() {
        String sql = null;
        Query query = null;
        sql = "SELECT id,departmentName,iconadress,addtime FROM tb_department";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_department> tb_departmentList = new ArrayList<tb_department>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_department department = new tb_department();
                Object[] obj = (Object[]) resultList.get(i);
                department.setId((int) obj[0]);
                department.setDepartmentName(obj[1] == null ? "" : obj[1].toString());
                department.setIconadress(obj[2] == null ? "" : obj[2].toString());
                department.setAddtime(obj[3] == null ? "" : obj[3].toString());
                tb_departmentList.add(department);
            }
        }
        return tb_departmentList;
    }
 
    public List<tb_department> getDepartmentManagement(int page) {
        int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
        int start = (page - 1) * perPage;
        int end = perPage;
        String sql = null;
        Query query = null;
        sql = "SELECT id,departmentName,iconadress,addtime FROM tb_department LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", start);
        query.setParameter("end", end);
        List resultList = query.getResultList();
        List<tb_department> tb_departmentList = new ArrayList<tb_department>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_department department = new tb_department();
                Object[] obj = (Object[]) resultList.get(i);
                department.setId((int) obj[0]);
                department.setDepartmentName(obj[1] == null ? "" : obj[1].toString());
                department.setIconadress(obj[2] == null ? "" : obj[2].toString());
                department.setAddtime(obj[3] == null ? "" : obj[3].toString());
                tb_departmentList.add(department);
            }
        }
        return tb_departmentList;
    }
 
    public List<tb_icon> getIconList() {
        String sql = null;
        Query query = null;
        sql = "SELECT icon_name,icon_adress FROM tb_icon";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_icon> tb_iconList = new ArrayList<tb_icon>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_icon icon = new tb_icon();
                Object[] obj = (Object[]) resultList.get(i);
                icon.setIcon_name(obj[0] == null ? "" : obj[0].toString());
                icon.setIcon_adress(obj[1] == null ? "" : obj[1].toString());
                tb_iconList.add(icon);
            }
        }
        return tb_iconList;
    }
 
    public List<tb_department> getAllDepartmentManagement() {
        String sql = null;
        Query query = null;
        sql = "SELECT id,departmentName,iconadress,addtime FROM tb_department";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_department> tb_departmentList = new ArrayList<tb_department>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_department department = new tb_department();
                Object[] obj = (Object[]) resultList.get(i);
                department.setId((int) obj[0]);
                department.setDepartmentName(obj[1] == null ? "" : obj[1].toString());
                department.setIconadress(obj[2] == null ? "" : obj[2].toString());
                department.setAddtime(obj[3] == null ? "" : obj[3].toString());
                tb_departmentList.add(department);
            }
        }
        return tb_departmentList;
    }
 
    public int getDepartmentManagementCount() {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_department";
        query = this.em.createNativeQuery(sql);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    public List<tb_department> searchDepartmentManagement(String input) {
        String departmentName = input;
        String sql = null;
        Query query = null;
        sql = "SELECT id,departmentName,iconadress,addtime FROM tb_department WHERE departmentName = :departmentName";
        query = this.em.createNativeQuery(sql);
        query.setParameter("departmentName", departmentName);
        List resultList = query.getResultList();
        List<tb_department> tb_departmentList = new ArrayList<tb_department>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_department department = new tb_department();
                Object[] obj = (Object[]) resultList.get(i);
                department.setId((int) obj[0]);
                department.setDepartmentName(obj[1] == null ? "" : obj[1].toString());
                department.setIconadress(obj[2] == null ? "" : obj[2].toString());
                department.setAddtime(obj[3] == null ? "" : obj[3].toString());
                tb_departmentList.add(department);
            }
        }
        return tb_departmentList;
    }
 
    @Transactional
    public void departmentManagement_delete(String[] checkVal) {
        String sql = null;
        Query query = null;
        for (int i = 0; i < checkVal.length; i++) {
            String departmentName = checkVal[i];
            sql = "DELETE FROM tb_department WHERE departmentName = :departmentName";
            cs.tb_caozuo("tb_department", 2);
            query = this.em.createNativeQuery(sql);
            query.setParameter("departmentName", departmentName);
            query.executeUpdate();
        }
    }
 
    @Transactional
    public void departmentManagement_deleteAll() {
        String sql = null;
        Query query = null;
        sql = "DELETE FROM tb_department";
        cs.tb_caozuo("tb_department", 2);
        query = this.em.createNativeQuery(sql);
        query.executeUpdate();
    }
 
    @Transactional
    public int departmentManagement_add(tb_department department) {
        String sql = null;
        Query query = null;
        sql = "INSERT INTO tb_department(departmentName,iconadress,addtime) VALUES(:departmentName,:iconadress,now())";
        cs.tb_caozuo("tb_department", 1);
        query = this.em.createNativeQuery(sql);
        query.setParameter("departmentName", department.getDepartmentName());
        query.setParameter("iconadress", department.getIconadress());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int departmentManagement_check(String name) {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_department WHERE departmentName= :departmentName";
        query = this.em.createNativeQuery(sql);
        query.setParameter("departmentName", name);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    @Transactional
    public void departmentManagement_modify(tb_department department) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_department SET departmentName=:departmentName,iconadress=:iconadress,addtime = now() WHERE id=:id";
        cs.tb_caozuo("tb_department", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("id", department.getId());
        query.setParameter("departmentName", department.getDepartmentName());
        query.setParameter("iconadress", department.getIconadress());
        query.executeUpdate();
    }
 
    public List<tb_person> getPersonManagement() {
        String sql = null;
        Query query = null;
        sql = "SELECT id,p_name,p_tagid,p_sex,p_minzu,p_phone,p_department,p_ban,p_zu,p_idcardnum,p_adress,p_canin,p_x,p_y,p_floor,p_sos,p_online,p_power,p_kaoqing,p_fence,p_fencename,p_kaoqqingname,p_image,p_addtiem FROM tb_person";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_person> tb_personList = new ArrayList<tb_person>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_person person = new tb_person();
                Object[] obj = (Object[]) resultList.get(i);
                person.setId((int) obj[0]);
                person.setP_name(obj[1] == null ? "" : obj[1].toString());
                person.setP_tagid(obj[2] == null ? "" : obj[2].toString());
                person.setP_sex(obj[3] == null ? "" : obj[3].toString());
                person.setP_department(obj[6] == null ? "" : obj[6].toString());
                person.setP_phone(obj[5] == null ? "" : obj[5].toString());
                person.setP_x(obj[12] == null ? "" : obj[12].toString());
                person.setP_y(obj[13] == null ? "" : obj[13].toString());
                person.setP_floor(obj[14] == null ? "" : obj[14].toString());
                person.setP_online(obj[16] == null ? "" : obj[16].toString());
                person.setP_power(obj[17] == null ? "" : obj[17].toString());
                person.setP_image(obj[22] == null ? "" : obj[22].toString());
                person.setP_addtiem(obj[23] == null ? "" : obj[23].toString());
                tb_personList.add(person);
            }
        }
        return tb_personList;
    }
    
    public List<tb_person> getPersonManagementTemplate(int page) {
        int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
        int start = (page - 1) * perPage;
        int end = perPage;
        String sql = null;
        Query query = null;
        sql = "SELECT p_name,p_tagid,p_sex,p_phone,p_department FROM tb_person LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", start);
        query.setParameter("end", end);
        List resultList = query.getResultList();
        List<tb_person> tb_personList = new ArrayList<tb_person>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_person person = new tb_person();
                Object[] obj = (Object[]) resultList.get(i);
                person.setP_name(obj[0] == null ? "" : obj[0].toString());
                person.setP_tagid(obj[1] == null ? "" : obj[1].toString());
                person.setP_sex(obj[2] == null ? "" : obj[2].toString());
                person.setP_department(obj[4] == null ? "" : obj[4].toString());
                person.setP_phone(obj[3] == null ? "" : obj[3].toString());
                tb_personList.add(person);
            }
        }
        return tb_personList;
    }
 
    public List<tb_person> getPersonManagement(int page) {
        int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
        int start = (page - 1) * perPage;
        int end = perPage;
        String sql = null;
        Query query = null;
        sql = "SELECT id,p_name,p_tagid,p_sex,p_minzu,p_phone,p_department,p_ban,p_zu,p_idcardnum,p_adress,p_canin,p_x,p_y,p_floor,p_sos,p_online,p_power,p_kaoqing,p_fence,p_fencename,p_kaoqqingname,p_image,p_addtiem FROM tb_person LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", start);
        query.setParameter("end", end);
        List resultList = query.getResultList();
        List<tb_person> tb_personList = new ArrayList<tb_person>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_person person = new tb_person();
                Object[] obj = (Object[]) resultList.get(i);
                person.setId((int) obj[0]);
                person.setP_name(obj[1] == null ? "" : obj[1].toString());
                person.setP_tagid(obj[2] == null ? "" : obj[2].toString());
                person.setP_sex(obj[3] == null ? "" : obj[3].toString());
                person.setP_department(obj[6] == null ? "" : obj[6].toString());
                person.setP_phone(obj[5] == null ? "" : obj[5].toString());
                person.setP_x(obj[12] == null ? "" : obj[12].toString());
                person.setP_y(obj[13] == null ? "" : obj[13].toString());
                person.setP_floor(obj[14] == null ? "" : obj[14].toString());
                person.setP_online(obj[16] == null ? "" : obj[16].toString());
                person.setP_power(obj[17] == null ? "" : obj[17].toString());
                person.setP_image(obj[22] == null ? "" : obj[22].toString());
                person.setP_addtiem(obj[23] == null ? "" : obj[23].toString());
                tb_personList.add(person);
            }
        }
        return tb_personList;
    }
 
    public int getPersonManagementCount() {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_person";
        query = this.em.createNativeQuery(sql);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    public List<tb_person> searchPersonManagement(String input) {
        String sql = null;
        Query query = null;
        sql = "SELECT id,p_name,p_tagid,p_sex,p_minzu,p_phone,p_department,p_ban,p_zu,p_idcardnum,p_adress,p_canin,p_x,p_y,p_floor,p_sos,p_online,p_power,p_kaoqing,p_fence,p_fencename,p_kaoqqingname,p_image,p_addtiem FROM tb_person WHERE p_tagid = :p_tagid";
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", input);
        List resultList = query.getResultList();
        List<tb_person> tb_personList = new ArrayList<tb_person>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_person person = new tb_person();
                Object[] obj = (Object[]) resultList.get(i);
                person.setId((int) obj[0]);
                person.setP_name(obj[1] == null ? "" : obj[1].toString());
                person.setP_tagid(obj[2] == null ? "" : obj[2].toString());
                person.setP_sex(obj[3] == null ? "" : obj[3].toString());
                person.setP_department(obj[6] == null ? "" : obj[6].toString());
                person.setP_phone(obj[5] == null ? "" : obj[5].toString());
                person.setP_x(obj[12] == null ? "" : obj[12].toString());
                person.setP_y(obj[13] == null ? "" : obj[13].toString());
                person.setP_floor(obj[14] == null ? "" : obj[14].toString());
                person.setP_power(obj[17] == null ? "" : obj[17].toString());
                person.setP_image(obj[22] == null ? "" : obj[22].toString());
                person.setP_addtiem(obj[23] == null ? "" : obj[23].toString());
                tb_personList.add(person);
            }
        }
        return tb_personList;
    }
 
    @Transactional
    public int personManagement_delete(String checkVal) {
        String sql = null;
        Query query = null;
        String str = "未绑定";
        sql = "UPDATE tb_person SET p_name=:str WHERE p_tagid = :tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("tagid", checkVal);
        query.setParameter("str", str);
        query.executeUpdate();
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int personManagement_deleteAll() {
        String sql = null;
        Query query = null;
        String str = "未绑定";
        sql = "UPDATE tb_person SET p_name=:str";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("str", str);
        query.executeUpdate();
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    public List<tb_department> getDepartmentList() {
        String sql = null;
        Query query = null;
        sql = "SELECT departmentName,iconadress FROM tb_department";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_department> tb_departmentList = new ArrayList<tb_department>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_department department = new tb_department();
                Object[] obj = (Object[]) resultList.get(i);
                department.setDepartmentName(obj[0] == null ? "" : obj[0].toString());
                department.setIconadress(obj[1] == null ? "" : obj[1].toString());
                tb_departmentList.add(department);
            }
        }
        return tb_departmentList;
    }
 
    @Transactional
    public int personManagement_modify(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_image = (SELECT iconadress FROM tb_department WHERE departmentName = :p_department LIMIT 1),p_power=(SELECT power FROM tb_tag WHERE tag_id = :p_tagid LIMIT 1),p_department = :p_department,p_name = :p_name,p_sex = :p_sex,p_phone = :p_phone,p_addtiem = now() WHERE p_tagid= :p_tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_department", person.getP_department());
        query.setParameter("p_name", person.getP_name());
        query.setParameter("p_sex", person.getP_sex());
        query.setParameter("p_phone", person.getP_phone());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int personManagement_add(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "INSERT INTO tb_person(p_tagid,p_image,p_power,p_department,p_name,p_sex,p_phone,p_addtiem,p_minzu,p_x,p_y,p_floor,p_sos,p_online,p_kaoqing,p_fence) VALUES(:p_tagid,(SELECT iconadress FROM tb_department WHERE departmentName = :p_department LIMIT 1),(SELECT power FROM tb_tag WHERE tag_id = :p_tagid LIMIT 1),:p_department,:p_name,:p_sex,:p_phone,now(),:p_minzu,:p_x,:p_y,:p_floor,:p_sos,:p_online,:p_kaoqing,:p_fence)";
        cs.tb_caozuo("tb_person", 1);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_department", person.getP_department());
        query.setParameter("p_name", person.getP_name());
        query.setParameter("p_sex", person.getP_sex());
        query.setParameter("p_phone", person.getP_phone());
        query.setParameter("p_minzu", person.getP_minzu());
        query.setParameter("p_x", person.getP_x());
        query.setParameter("p_y", person.getP_y());
        query.setParameter("p_floor", person.getP_floor());
        query.setParameter("p_sos", person.getP_sos());
        query.setParameter("p_online", person.getP_online());
        query.setParameter("p_kaoqing", person.getP_kaoqing());
        query.setParameter("p_fence", person.getP_fence());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int person_modify_kaoqin(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_kaoqing = :p_kaoqin WHERE p_tagid= :p_tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_kaoqin", person.getP_kaoqing());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
    
    @Transactional
    public int person_modify_power(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_power = :p_power WHERE p_tagid= :p_tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_power", person.getP_power());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
    
    @Transactional
    public int person_modify_sos(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_sos = :p_sos WHERE p_tagid= :p_tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_sos", person.getP_sos());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
 
    @Transactional
    public int person_modify_warning(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_sos = :p_sos WHERE p_tagid= :p_tagid";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_sos", person.getP_sos());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
    
    @Transactional
    public int person_modify_XYF(tb_person person) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_person SET p_x = :p_x,p_y = :p_y,p_floor = :p_floor,p_addtiem = now() WHERE p_tagid= :p_tagid ";
        cs.tb_caozuo("tb_person", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("p_tagid", person.getP_tagid());
        query.setParameter("p_x", person.getP_x());
        query.setParameter("p_y", person.getP_y());
        query.setParameter("p_floor", person.getP_floor());
        int executeUpdate = query.executeUpdate();
        return executeUpdate;
    }
}