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
package com.hxzkoa.services;
 
import java.text.ParseException;
import java.util.ArrayList;
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_fence;
import com.hxzkoa.json.tb_shipin;
import com.hxzkoa.json.tb_xunjianbaobiao;
import com.hxzkoa.json.tb_xunjianset;
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ModifyConfig;
 
@Service
public class FenceService {
    @PersistenceContext
    private EntityManager em;
    @Autowired
    private CaozuoService cs;
 
    public List<tb_fence> getFenceList() {
        String sql = null;
        Query query = null;
        sql = "SELECT id,floor,type,bumen,name,zuobiao,shape,start,stop,addtime,color,baoliu1 FROM tb_fence";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_fence> tb_fenceList = new ArrayList<tb_fence>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_fence fence = new tb_fence();
                Object[] obj = (Object[]) resultList.get(i);
                fence.setId((int) obj[0]);
                fence.setFloor(obj[1] == null ? "" : obj[1].toString());
                fence.setType(obj[2] == null ? "" : obj[2].toString());
                fence.setBumen(obj[3] == null ? "" : obj[3].toString());
                fence.setName(obj[4] == null ? "" : obj[4].toString());
                fence.setZuobiao(obj[5] == null ? "" : obj[5].toString());
                fence.setShape(obj[6] == null ? "" : obj[6].toString());
                fence.setStart(obj[7] == null ? "" : obj[7].toString());
                fence.setStop(obj[8] == null ? "" : obj[8].toString());
                fence.setAddtime(obj[9] == null ? "" : obj[9].toString());
                fence.setColor(obj[10] == null ? "" : obj[10].toString());
                fence.setBaoliu1(obj[11] == null ? "" : obj[11].toString());
                tb_fenceList.add(fence);
            }
        }
        return tb_fenceList;
    }
    
    public List<tb_shipin> getShipinManagement(int page) {
        String sql = null;
        Query query = null;
        sql = "SELECT * FROM tb_shipin LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", (page - 1) * Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage")));
        query.setParameter("end", Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage")));
        List resultList = query.getResultList();
        List<tb_shipin> tb_shipinList = new ArrayList<tb_shipin>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_shipin shipin = new tb_shipin();
                Object[] obj = (Object[]) resultList.get(i);
                shipin.setId((int) obj[0]);
                shipin.setFencename(obj[1] == null ? "" : obj[1].toString());
                shipin.setShebeiid(obj[2] == null ? "" : obj[2].toString());
                shipin.setTongdaoid(obj[3] == null ? "" : obj[3].toString());
                shipin.setAddtime(obj[4] == null ? "" : obj[4].toString());
                shipin.setPosx(obj[5] == null ? "" : obj[5].toString());
                shipin.setPosy(obj[6] == null ? "" : obj[6].toString());
                shipin.setPosz(obj[7] == null ? "" : obj[7].toString());
                shipin.setFloor(obj[8] == null ? "" : obj[8].toString());
                shipin.setName(obj[9] == null ? "" : obj[9].toString());
                tb_shipinList.add(shipin);
            }
        }
        return tb_shipinList;
    }
    
    public int getShipinManagementCount() {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_shipin";
        query = this.em.createNativeQuery(sql);
        return Integer.parseInt(query.getSingleResult().toString());
    }
    
    @Transactional
    public int shipinManagement_add(tb_shipin shipin) {
        String sql = null;
        Query query = null;
        sql = "INSERT INTO tb_shipin(fencename,shebeiid,tongdaoid,addtime,posx,posy,posz,floor,name) VALUES(:fencename,:shebeiid,:tongdaoid,now(),:posx,:posy,:posz,:floor,:name)";
        query = this.em.createNativeQuery(sql);
        query.setParameter("fencename", shipin.getFencename());
        query.setParameter("shebeiid", shipin.getShebeiid());
        query.setParameter("tongdaoid", shipin.getTongdaoid());
        query.setParameter("posx", shipin.getPosx());
        query.setParameter("posy", shipin.getPosy());
        query.setParameter("posz", shipin.getPosz());
        query.setParameter("floor", shipin.getFloor());
        query.setParameter("name", shipin.getName());
        int executeUpdate = query.executeUpdate();
//      String sql2 = null;
//      Query query2 = null;
//      sql2 = "SELECT id FROM tb_shipin WHERE shebeiid=:shebeiid";
//      query2 = this.em.createNativeQuery(sql2);
//      query2.setParameter("shebeiid",shipin.getShebeiid());
//      List resultList2 = query2.getResultList();
//      String id = null;
//      if (resultList2.size() > 0) {
//          Object[] obj = (Object[])resultList2.get(0);
//          id = obj[0].toString();
//      }
//      String xieyi = "BSTOCS1,ADDVIDEO,"+id+","+shipin.getFencename()+","+shipin.getShebeiid()+","+shipin.getTongdaoid()+","+shipin.getPosx()+","+shipin.getPosy()+","+shipin.getPosz()+","+shipin.getFloor()+","+shipin.getName()+",END";
//      Udp_
        return executeUpdate;
    }
    
    @Transactional
    public void shipinManagement_modify(tb_shipin shipin) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_shipin SET fencename=:fencename,shebeiid=:shebeiid,tongdaoid=:tongdaoid,posx=:posx,posy=:posy,posz=:posz,floor=:floor,name=:name WHERE id=:id";
        query = this.em.createNativeQuery(sql);
        query.setParameter("id", shipin.getId());
        query.setParameter("fencename", shipin.getFencename());
        query.setParameter("shebeiid", shipin.getShebeiid());
        query.setParameter("tongdaoid", shipin.getTongdaoid());
        query.setParameter("posx", shipin.getPosx());
        query.setParameter("posy", shipin.getPosy());
        query.setParameter("posz", shipin.getPosz());
        query.setParameter("floor", shipin.getFloor());
        query.setParameter("name", shipin.getName());
        query.executeUpdate();
    }
    
    @Transactional
    public void shipinManagement_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_shipin WHERE id = :id";
            query = this.em.createNativeQuery(sql);
            query.setParameter("id", id);
            query.executeUpdate();
        }
    }
    
    @Transactional
    public List idfindshebeiid(String id) {
        String sql = null;
        Query query = null;
        sql = "SELECT shebeiid FROM tb_shipin WHERE id = :id";
        query = this.em.createNativeQuery(sql);
        query.setParameter("id", id);
        List resultList = query.getResultList();
        return resultList;
    }
    
    @Transactional
    public void shipinManagement_deleteAll() {
        String sql = null;
        Query query = null;
        sql = "DELETE FROM tb_shipin";
        query = this.em.createNativeQuery(sql);
        query.executeUpdate();
    }
    
    public List<tb_shipin> searchshipinManagement(String input) {
        String sql = null;
        Query query = null;
        sql = "SELECT * FROM tb_shipin WHERE name = :name";
        query = this.em.createNativeQuery(sql);
        query.setParameter("name", input);
        List resultList = query.getResultList();
        List<tb_shipin> tb_shipinList = new ArrayList<tb_shipin>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_shipin shipin = new tb_shipin();
                Object[] obj = (Object[]) resultList.get(i);
                shipin.setId((int) obj[0]);
                shipin.setFencename(obj[1] == null ? "" : obj[1].toString());
                shipin.setShebeiid(obj[2] == null ? "" : obj[2].toString());
                shipin.setTongdaoid(obj[3] == null ? "" : obj[3].toString());
                shipin.setAddtime(obj[4] == null ? "" : obj[4].toString());
                shipin.setPosx(obj[5] == null ? "" : obj[5].toString());
                shipin.setPosy(obj[6] == null ? "" : obj[6].toString());
                shipin.setPosz(obj[7] == null ? "" : obj[7].toString());
                shipin.setFloor(obj[8] == null ? "" : obj[8].toString());
                shipin.setName(obj[9] == null ? "" : obj[9].toString());
                tb_shipinList.add(shipin);
            }
        }
        return tb_shipinList;
    }
    
    public List<tb_fence> searchFenceList(String input) throws ParseException {
 
        String sql = null;
        Query query = null;
        sql = "SELECT id,floor,type,bumen,`name`,zuobiao,shape,`start`,`stop`,addtime,color FROM tb_fence WHERE type LIKE :type";
        query = this.em.createNativeQuery(sql);
        query.setParameter("type", "%" + input + "%");
        List resultList = query.getResultList();
        List<tb_fence> tb_fenceList = new ArrayList<tb_fence>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                Object[] obj = (Object[]) resultList.get(i);
                tb_fence fence = new tb_fence();
                fence.setFloor(obj[1] == null ? "" : obj[1].toString());
                fence.setType(obj[2] == null ? "" : obj[2].toString());
                fence.setBumen(obj[3] == null ? "" : obj[3].toString());
                fence.setName(obj[4] == null ? "" : obj[4].toString());
                fence.setZuobiao(obj[5] == null ? "" : obj[5].toString());
                fence.setShape(obj[6] == null ? "" : obj[6].toString());
                // fence.setStart(new Time(new
                // SimpleDateFormat("hh:mm:ss").parse(obj[7] == null ? "" :
                // obj[7].toString()).getTime()));
                // fence.setStop(new Time(new
                // SimpleDateFormat("hh:mm:ss").parse(obj[8] == null ? "" :
                // obj[8].toString()).getTime()));
                fence.setStart(obj[7] == null ? "" : obj[7].toString());
                fence.setStop(obj[8] == null ? "" : obj[8].toString());
                fence.setAddtime(obj[9] == null ? "" : obj[9].toString());
                fence.setColor(obj[10] == null ? "" : obj[10].toString());
                tb_fenceList.add(fence);
            }
        }
        return tb_fenceList;
    }
 
    @Transactional
    public void fenceList_modify(tb_fence fence) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_fence SET bumen=:bumen,name=:name,zuobiao=:zuobiao,start=:start,stop=:stop,baoliu1=:baoliu1 WHERE id=:id";
        cs.tb_caozuo("tb_fence", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("bumen", fence.getBumen());
        query.setParameter("name", fence.getName());
        query.setParameter("zuobiao", fence.getZuobiao());
        query.setParameter("start", fence.getStart());
        query.setParameter("stop", fence.getStop());
        query.setParameter("id", fence.getId());
        query.setParameter("baoliu1", fence.getBaoliu1());
        query.executeUpdate();
    }
 
    @Transactional
    public void fenceList_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_fence WHERE id = :id";
            cs.tb_caozuo("tb_fence", 2);
            query = this.em.createNativeQuery(sql);
            query.setParameter("id", id);
            query.executeUpdate();
        }
    }
 
    @Transactional
    public void fenceList_deleteAll() {
        String sql = null;
        Query query = null;
        sql = "DELETE FROM tb_fence";
        cs.tb_caozuo("tb_fence", 2);
        query = this.em.createNativeQuery(sql);
        query.executeUpdate();
    }
 
    public List<tb_xunjianset> getInspectionSettings() {
        String sql = null;
        Query query = null;
        sql = "SELECT quyu,startime,stoptime,xunshu,tagid,needstoptime,cishu,addtime FROM tb_xunjianset";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_xunjianset> tb_xunjiansetList = new ArrayList<tb_xunjianset>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_xunjianset xunjianset = new tb_xunjianset();
                Object[] obj = (Object[]) resultList.get(i);
                xunjianset.setId(i + 1);
                xunjianset.setQuyu(obj[0] == null ? "" : obj[0].toString());
                xunjianset.setStartime(obj[1] == null ? "" : obj[1].toString());
                xunjianset.setStoptime(obj[2] == null ? "" : obj[2].toString());
                xunjianset.setXunshu(obj[3] == null ? "" : obj[3].toString());
                xunjianset.setTagid(obj[4] == null ? "" : obj[4].toString());
                xunjianset.setNeedstoptime(obj[5] == null ? "" : obj[5].toString());
                xunjianset.setCishu(obj[6] == null ? "" : obj[6].toString());
                xunjianset.setAddtime(obj[7] == null ? "" : obj[7].toString());
                tb_xunjiansetList.add(xunjianset);
            }
        }
        return tb_xunjiansetList;
    }
 
    @Transactional
    public void inspectionSettings_modify(tb_xunjianset xunjianset) {
        String sql = null;
        Query query = null;
        sql = "UPDATE tb_xunjianset SET xunshu=:xunshu,tagid=:tagid,cishu=:cishu,needstoptime=:needstoptime,stoptime=:stoptime WHERE quyu=:quyu";
        cs.tb_caozuo("tb_xunjianset", 3);
        query = this.em.createNativeQuery(sql);
        query.setParameter("quyu", xunjianset.getQuyu());
        query.setParameter("xunshu", xunjianset.getXunshu());
        query.setParameter("tagid", xunjianset.getTagid());
        query.setParameter("cishu", xunjianset.getCishu());
        query.setParameter("needstoptime", xunjianset.getNeedstoptime());
        query.setParameter("stoptime", xunjianset.getStoptime());
        query.executeUpdate();
    }
 
    public List<tb_xunjianbaobiao> getInspectionRecord() {
        String sql = null;
        Query query = null;
        sql = "SELECT id,name,tagid,quyu,bianhao,intime,outtime,alltime,succ,addtime FROM tb_xunjianbaobiao";
        query = this.em.createNativeQuery(sql);
        List resultList = query.getResultList();
        List<tb_xunjianbaobiao> tb_xunjianbaobiaoList = new ArrayList<tb_xunjianbaobiao>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_xunjianbaobiao xunjianbaobiao = new tb_xunjianbaobiao();
                Object[] obj = (Object[]) resultList.get(i);
                xunjianbaobiao.setId((int) obj[0]);
                xunjianbaobiao.setName(obj[1] == null ? "" : obj[1].toString());
                xunjianbaobiao.setTagid(obj[2] == null ? "" : obj[2].toString());
                xunjianbaobiao.setQuyu(obj[3] == null ? "" : obj[3].toString());
                xunjianbaobiao.setBianhao(obj[4] == null ? "" : obj[4].toString());
                xunjianbaobiao.setIntime(obj[5] == null ? "" : obj[5].toString());
                xunjianbaobiao.setOuttime(obj[6] == null ? "" : obj[6].toString());
                xunjianbaobiao.setAlltime(obj[7] == null ? "" : obj[7].toString());
                xunjianbaobiao.setSucc(obj[8] == null ? "" : obj[8].toString());
                xunjianbaobiao.setAddtime(obj[9] == null ? "" : obj[9].toString());
                tb_xunjianbaobiaoList.add(xunjianbaobiao);
            }
        }
        return tb_xunjianbaobiaoList;
    }
 
    public List<tb_xunjianbaobiao> getInspectionRecord(int page,int perPage) {
        String sql = null;
        Query query = null;
        sql = "SELECT id,name,tagid,quyu,bianhao,intime,outtime,alltime,succ,addtime FROM tb_xunjianbaobiao LIMIT :start,:end";
        query = this.em.createNativeQuery(sql);
        query.setParameter("start", (page - 1) * perPage);
        query.setParameter("end", perPage);
        List resultList = query.getResultList();
        List<tb_xunjianbaobiao> tb_xunjianbaobiaoList = new ArrayList<tb_xunjianbaobiao>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_xunjianbaobiao xunjianbaobiao = new tb_xunjianbaobiao();
                Object[] obj = (Object[]) resultList.get(i);
                xunjianbaobiao.setId((int) obj[0]);
                xunjianbaobiao.setName(obj[1] == null ? "" : obj[1].toString());
                xunjianbaobiao.setTagid(obj[2] == null ? "" : obj[2].toString());
                xunjianbaobiao.setQuyu(obj[3] == null ? "" : obj[3].toString());
                xunjianbaobiao.setBianhao(obj[4] == null ? "" : obj[4].toString());
                xunjianbaobiao.setIntime(obj[5] == null ? "" : obj[5].toString());
                xunjianbaobiao.setOuttime(obj[6] == null ? "" : obj[6].toString());
                xunjianbaobiao.setAlltime(obj[7] == null ? "" : obj[7].toString());
                xunjianbaobiao.setSucc(obj[8] == null ? "" : obj[8].toString());
                xunjianbaobiao.setAddtime(obj[9] == null ? "" : obj[9].toString());
                tb_xunjianbaobiaoList.add(xunjianbaobiao);
            }
        }
        return tb_xunjianbaobiaoList;
    }
 
    public List<tb_xunjianbaobiao> searchInspectionRecord(String input) {
        String sql = null;
        Query query = null;
        sql = "SELECT id,name,tagid,quyu,bianhao,intime,outtime,alltime,succ,addtime FROM tb_xunjianbaobiao WHERE tagid = :tag_id";
        query = this.em.createNativeQuery(sql);
        query.setParameter("tag_id", input);
        List resultList = query.getResultList();
        List<tb_xunjianbaobiao> tb_xunjianbaobiaoList = new ArrayList<tb_xunjianbaobiao>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_xunjianbaobiao xunjianbaobiao = new tb_xunjianbaobiao();
                Object[] obj = (Object[]) resultList.get(i);
                xunjianbaobiao.setId((int) obj[0]);
                xunjianbaobiao.setName(obj[1] == null ? "" : obj[1].toString());
                xunjianbaobiao.setTagid(obj[2] == null ? "" : obj[2].toString());
                xunjianbaobiao.setQuyu(obj[3] == null ? "" : obj[3].toString());
                xunjianbaobiao.setBianhao(obj[4] == null ? "" : obj[4].toString());
                xunjianbaobiao.setIntime(obj[5] == null ? "" : obj[5].toString());
                xunjianbaobiao.setOuttime(obj[6] == null ? "" : obj[6].toString());
                xunjianbaobiao.setAlltime(obj[7] == null ? "" : obj[7].toString());
                xunjianbaobiao.setSucc(obj[8] == null ? "" : obj[8].toString());
                xunjianbaobiao.setAddtime(obj[9] == null ? "" : obj[9].toString());
                tb_xunjianbaobiaoList.add(xunjianbaobiao);
            }
        }
        return tb_xunjianbaobiaoList;
    }
 
    public int getInspectionRecordCount() {
        String sql = null;
        Query query = null;
        sql = "SELECT count(1) FROM tb_xunjianbaobiao";
        query = this.em.createNativeQuery(sql);
        return Integer.parseInt(query.getSingleResult().toString());
    }
 
    @Transactional
    public void inspectionRecord_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_xunjianbaobiao WHERE id = :id";
            cs.tb_caozuo("tb_xunjianbaobiao", 2);
            query = this.em.createNativeQuery(sql);
            query.setParameter("id", id);
            query.executeUpdate();
        }
    }
 
    @Transactional
    public void inspectionRecord_deleteAll() {
        String sql = null;
        Query query = null;
        sql = "DELETE FROM tb_xunjianbaobiao";
        cs.tb_caozuo("tb_xunjianbaobiao", 2);
        query = this.em.createNativeQuery(sql);
        query.executeUpdate();
    }
    
    @Transactional
    public List<tb_xunjianbaobiao> getXunjianbaobiao(String tagid,String quyu) {
        String sql = null;
        Query query = null;
        sql = "SELECT bianhao,intime FROM tb_xunjianbaobiao WHERE tagid=:tagid AND quyu=:quyu";
        query = this.em.createNativeQuery(sql);
        query.setParameter("tagid", tagid);
        query.setParameter("quyu", quyu);
        List resultList = query.getResultList();
        List<tb_xunjianbaobiao> tb_xunjianbaobaioList = new ArrayList<tb_xunjianbaobiao>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                tb_xunjianbaobiao xunjianbaobiao = new tb_xunjianbaobiao();
                Object[] obj = (Object[]) resultList.get(i);
                xunjianbaobiao.setBianhao(obj[0] == null ? "" : obj[0].toString());
                xunjianbaobiao.setIntime(obj[1] == null ? "" : obj[1].toString());
                tb_xunjianbaobaioList.add(xunjianbaobiao);
            }
        }
        return tb_xunjianbaobaioList;
    }
 
    @Transactional
    public void xunjianbaobiao_add(tb_xunjianbaobiao xunjianbaobiao) {
        String sql = null;
        Query query = null;
        sql = "INSERT tb_xunjianbaobiao (name,tagid,quyu,bianhao,intime,addtime) VALUES (:name,:tagid,:quyu,:bianhao,now(),now())";
        cs.tb_caozuo("tb_xunjianbaobiao", 1);
        query = this.em.createNativeQuery(sql);
        query.setParameter("name", xunjianbaobiao.getName());
        query.setParameter("tagid", xunjianbaobiao.getTagid());
        query.setParameter("quyu", xunjianbaobiao.getQuyu());
        query.setParameter("bianhao", xunjianbaobiao.getBianhao());
        query.executeUpdate();
    }
    
    public List<tb_fence> searchFenceListid(int input) throws ParseException {
        int id = input;
        String sql = null;
        Query query = null;
        sql = "SELECT id,floor,type,bumen,`name`,zuobiao,shape,`start`,`stop`,addtime,color FROM tb_fence WHERE id = :id";
        query = this.em.createNativeQuery(sql);
        query.setParameter("id", id);
        List resultList = query.getResultList();
        List<tb_fence> tb_fenceList = new ArrayList<tb_fence>();
        if (resultList.size() > 0) {
            for (int i = 0; i < resultList.size(); i++) {
                Object[] obj = (Object[]) resultList.get(i);
                tb_fence fence = new tb_fence();
                fence.setFloor(obj[1] == null ? "" : obj[1].toString());
                fence.setType(obj[2] == null ? "" : obj[2].toString());
                fence.setBumen(obj[3] == null ? "" : obj[3].toString());
                fence.setName(obj[4] == null ? "" : obj[4].toString());
                fence.setZuobiao(obj[5] == null ? "" : obj[5].toString());
                fence.setShape(obj[6] == null ? "" : obj[6].toString());
                // fence.setStart(new Time(new
                // SimpleDateFormat("hh:mm:ss").parse(obj[7] == null ? "" :
                // obj[7].toString()).getTime()));
                // fence.setStop(new Time(new
                // SimpleDateFormat("hh:mm:ss").parse(obj[8] == null ? "" :
                // obj[8].toString()).getTime()));
                fence.setStart(obj[7] == null ? "" : obj[7].toString());
                fence.setStop(obj[8] == null ? "" : obj[8].toString());
                fence.setAddtime(obj[9] == null ? "" : obj[9].toString());
                fence.setColor(obj[10] == null ? "" : obj[10].toString());
                tb_fenceList.add(fence);
            }
        }
        return tb_fenceList;
    }
 
}