|
@@ -115,7 +115,7 @@ func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int
|
115
|
115
|
|
116
|
116
|
func FindOrgWaterMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
|
117
|
117
|
|
118
|
|
- db := readDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ?", org_id)
|
|
118
|
+ db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 2", org_id)
|
119
|
119
|
|
120
|
120
|
db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
121
|
121
|
|
|
@@ -426,3 +426,131 @@ func BatchCreateMonitor(advices []*sz.TempHdMiddle, rdb *gorm.DB) (err error) {
|
426
|
426
|
}
|
427
|
427
|
return
|
428
|
428
|
}
|
|
429
|
+
|
|
430
|
+func FindOrgOtherMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
|
|
431
|
+
|
|
432
|
+ db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND (device_type = 1 OR device_type = 3)", org_id)
|
|
433
|
+
|
|
434
|
+ db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
435
|
+
|
|
436
|
+ err = db.Find(&waterMachine).Error
|
|
437
|
+
|
|
438
|
+ return
|
|
439
|
+}
|
|
440
|
+
|
|
441
|
+func FindOrgMachineRepairData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.DeviceRepair, err error) {
|
|
442
|
+ db := readUserDb.Model(&models.DeviceRepair{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
|
|
443
|
+ db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
444
|
+ err = db.Find(&waterMachine).Error
|
|
445
|
+ return
|
|
446
|
+}
|
|
447
|
+
|
|
448
|
+func BatchCreateOtherMachineRecord(wms []*sz.TempHdOtherMachine, rdb *gorm.DB) (err error) {
|
|
449
|
+ if len(wms) > 0 {
|
|
450
|
+ utx := rdb.Begin()
|
|
451
|
+ if len(wms) > 0 {
|
|
452
|
+ thisSQL := "INSERT INTO t_hd_wm (HOSPITAL_ID, EQUIPMENT_ID, EQUIPMENT_BRAND, EQUIPMENT_MODEL, ENABLE_TIME,DISCARDED_TIME,XGBZ,CREATE_TIME,UPDATE_TIME,SJSCSJ) VALUES "
|
|
453
|
+ insertParams := make([]string, 0)
|
|
454
|
+ insertData := make([]interface{}, 0)
|
|
455
|
+ for _, wm := range wms {
|
|
456
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
|
|
457
|
+ insertData = append(insertData, wm.HospitalId)
|
|
458
|
+ insertData = append(insertData, wm.EquipmentId)
|
|
459
|
+ insertData = append(insertData, wm.EquipmentBrand)
|
|
460
|
+ insertData = append(insertData, wm.EquipmentModel)
|
|
461
|
+ insertData = append(insertData, wm.EnableTime)
|
|
462
|
+ insertData = append(insertData, wm.DiscardedTime)
|
|
463
|
+ insertData = append(insertData, wm.Xgbz)
|
|
464
|
+ insertData = append(insertData, wm.CreateTime)
|
|
465
|
+ insertData = append(insertData, wm.UpdateTime)
|
|
466
|
+ insertData = append(insertData, wm.Sjscsj)
|
|
467
|
+
|
|
468
|
+ }
|
|
469
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
470
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
471
|
+ if err != nil {
|
|
472
|
+ utx.Rollback()
|
|
473
|
+ return
|
|
474
|
+ }
|
|
475
|
+ }
|
|
476
|
+ utx.Commit()
|
|
477
|
+ }
|
|
478
|
+ return
|
|
479
|
+}
|
|
480
|
+
|
|
481
|
+func BatchCreateMainTain(maintain []*sz.TempHdMaintain, rdb *gorm.DB) (err error) {
|
|
482
|
+ if len(maintain) > 0 {
|
|
483
|
+ utx := rdb.Begin()
|
|
484
|
+ if len(maintain) > 0 {
|
|
485
|
+ thisSQL := "INSERT INTO t_hd_maintain (HOSPITAL_ID, EQUIPMENT_ID, EQUIPMENT_TYPE, REPAIR_TIME, XGBZ,CREATE_TIME,SJSCSJ) VALUES "
|
|
486
|
+ insertParams := make([]string, 0)
|
|
487
|
+ insertData := make([]interface{}, 0)
|
|
488
|
+ for _, wm := range maintain {
|
|
489
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
|
|
490
|
+ insertData = append(insertData, wm.HospitalId)
|
|
491
|
+ insertData = append(insertData, wm.EquipmentId)
|
|
492
|
+ insertData = append(insertData, wm.EquipmentType)
|
|
493
|
+ insertData = append(insertData, wm.RepairTime)
|
|
494
|
+ insertData = append(insertData, wm.Xgbz)
|
|
495
|
+ insertData = append(insertData, wm.CreateTime)
|
|
496
|
+ insertData = append(insertData, wm.Sjscsj)
|
|
497
|
+ }
|
|
498
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
499
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
500
|
+ if err != nil {
|
|
501
|
+ utx.Rollback()
|
|
502
|
+ return
|
|
503
|
+ }
|
|
504
|
+ }
|
|
505
|
+ utx.Commit()
|
|
506
|
+ }
|
|
507
|
+ return
|
|
508
|
+}
|
|
509
|
+
|
|
510
|
+func FindOrgMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
|
|
511
|
+
|
|
512
|
+ db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DeviceNumber", "status = 1")
|
|
513
|
+
|
|
514
|
+ db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
515
|
+
|
|
516
|
+ err = db.Find(&waterMachine).Error
|
|
517
|
+
|
|
518
|
+ return
|
|
519
|
+}
|
|
520
|
+
|
|
521
|
+func BatchCreateHDMRecord(wms []*sz.TempHdDm, rdb *gorm.DB) (err error) {
|
|
522
|
+ if len(wms) > 0 {
|
|
523
|
+ utx := rdb.Begin()
|
|
524
|
+ if len(wms) > 0 {
|
|
525
|
+ thisSQL := "INSERT INTO t_hd_dm (HOSPITAL_ID, EQUIPMENT_ID,SICKBED_NO, EQUIPMENT_BRAND, EQUIPMENT_MODEL, ENABLE_TIME,DISCARDED_TIME,STATUS,EQUIPMENT_TYPE, XGBZ,CREATE_TIME,UPDATE_TIME,SJSCSJ) VALUES "
|
|
526
|
+ insertParams := make([]string, 0)
|
|
527
|
+ insertData := make([]interface{}, 0)
|
|
528
|
+ for _, wm := range wms {
|
|
529
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
|
|
530
|
+ insertData = append(insertData, wm.HospitalId)
|
|
531
|
+ insertData = append(insertData, wm.EquipmentId)
|
|
532
|
+ insertData = append(insertData, wm.SickbedNo)
|
|
533
|
+ insertData = append(insertData, wm.EquipmentBrand)
|
|
534
|
+ insertData = append(insertData, wm.EquipmentModel)
|
|
535
|
+ insertData = append(insertData, wm.EnableTime)
|
|
536
|
+ insertData = append(insertData, wm.DiscardedTime)
|
|
537
|
+ insertData = append(insertData, wm.Status)
|
|
538
|
+ insertData = append(insertData, wm.EquipmentType)
|
|
539
|
+
|
|
540
|
+ insertData = append(insertData, wm.Xgbz)
|
|
541
|
+ insertData = append(insertData, wm.CreateTime)
|
|
542
|
+ insertData = append(insertData, wm.UpdateTime)
|
|
543
|
+ insertData = append(insertData, wm.Sjscsj)
|
|
544
|
+
|
|
545
|
+ }
|
|
546
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
547
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
548
|
+ if err != nil {
|
|
549
|
+ utx.Rollback()
|
|
550
|
+ return
|
|
551
|
+ }
|
|
552
|
+ }
|
|
553
|
+ utx.Commit()
|
|
554
|
+ }
|
|
555
|
+ return
|
|
556
|
+}
|