|
@@ -350,71 +350,363 @@ func UploadSYData(org_id int64) {
|
350
|
350
|
}
|
351
|
351
|
|
352
|
352
|
// 同步逻辑
|
353
|
|
-func SyncSYData(org_id int64) {
|
|
353
|
+//func SyncSYData(org_id int64) {
|
|
354
|
+// record, _ := GetLastSyncResultRecord(org_id)
|
|
355
|
+// if record.ID == 0 {
|
|
356
|
+// //通过接口从高品那里获取检验数据
|
|
357
|
+// start_time := "2023-06-01"
|
|
358
|
+// end_time := "2023-06-30"
|
|
359
|
+// result := GetGPReportListData(start_time, end_time, key)
|
|
360
|
+// list := GetGPResultDataTwo(result, key)
|
|
361
|
+// jsonData, err := json.Marshal(result)
|
|
362
|
+// if err != nil {
|
|
363
|
+// fmt.Println("转换为JSON时发生错误:", err)
|
|
364
|
+// return
|
|
365
|
+// }
|
|
366
|
+// jsonStr := string(jsonData)
|
|
367
|
+// jsonData1, err1 := json.Marshal(list)
|
|
368
|
+// if err1 != nil {
|
|
369
|
+// fmt.Println("转换为JSON时发生错误:", err1)
|
|
370
|
+// return
|
|
371
|
+// }
|
|
372
|
+// jsonStr1 := string(jsonData1)
|
|
373
|
+// saveLog1(jsonStr, "", "列表数据", "列表数据")
|
|
374
|
+// saveLog1(jsonStr1, "", "结果数据", "结果数据")
|
|
375
|
+//
|
|
376
|
+// if err == nil {
|
|
377
|
+// fmt.Println(list)
|
|
378
|
+// //插入到系统检验检查数据
|
|
379
|
+// if len(list) > 0 {
|
|
380
|
+// for _, item := range list {
|
|
381
|
+// project_id := int64(0)
|
|
382
|
+// //xt_project_id := int64(0)
|
|
383
|
+// if len(item.ListResult.Barcode) > 0 {
|
|
384
|
+// project_id, _, _ = GetSyjhProjectID(org_id, item.ChargeItemName)
|
|
385
|
+// } else {
|
|
386
|
+// continue
|
|
387
|
+// }
|
|
388
|
+// //var patient models.Patients
|
|
389
|
+// printInfo, _ := GetHisLabelPrintStatusInfoById(item.ListResult.CustomerBarcode)
|
|
390
|
+// if printInfo.ID == 0 {
|
|
391
|
+// patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
|
|
392
|
+// printInfo.PatientId = patient.ID
|
|
393
|
+//
|
|
394
|
+// }
|
|
395
|
+// if printInfo.PatientId == 0 {
|
|
396
|
+// continue
|
|
397
|
+// }
|
|
398
|
+// item_id, _ := GetSyItemID(org_id, item.ChargeItemName, item.InspectionName, project_id)
|
|
399
|
+// tx := writeMiddleDb.Begin()
|
|
400
|
+// var inspection models.MiddleInspection
|
|
401
|
+// var inspection_reference models.MiddleInspectionReference
|
|
402
|
+//
|
|
403
|
+// recordDateStr := ""
|
|
404
|
+// inspect_date := ""
|
|
405
|
+// if len(item.ListResult.InspectDate) > 0 {
|
|
406
|
+//
|
|
407
|
+// inspect_date = item.ListResult.InspectDate
|
|
408
|
+//
|
|
409
|
+// } else {
|
|
410
|
+// inspect_date = strings.Split(item.ListResult.ReceiveDateTime, " ")[0]
|
|
411
|
+//
|
|
412
|
+// }
|
|
413
|
+//
|
|
414
|
+// recordDateStr = inspect_date
|
|
415
|
+//
|
|
416
|
+// date, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
417
|
+// record_date := date
|
|
418
|
+// var total int
|
|
419
|
+// var RangeOptions string
|
|
420
|
+// var RangeMin string
|
|
421
|
+// var RangeMax string
|
|
422
|
+// // 判断检查类型
|
|
423
|
+// var ItemType int
|
|
424
|
+// if strings.Contains(item.Reference, "--") {
|
|
425
|
+// ItemType = 1
|
|
426
|
+// } else {
|
|
427
|
+// ItemType = 2
|
|
428
|
+//
|
|
429
|
+// }
|
|
430
|
+//
|
|
431
|
+// if ItemType == 1 {
|
|
432
|
+// Range := strings.Split(item.Reference, "--")
|
|
433
|
+// RangeMin = Range[0]
|
|
434
|
+// RangeMax = Range[1]
|
|
435
|
+// } else {
|
|
436
|
+// RangeOptions = item.Reference
|
|
437
|
+// }
|
|
438
|
+// err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
439
|
+// if inspection_reference.ID > 0 {
|
|
440
|
+// ItemType = inspection_reference.RangeType
|
|
441
|
+// }
|
|
442
|
+// if total <= 0 {
|
|
443
|
+// inspection_reference.OrgId = org_id
|
|
444
|
+// inspection_reference.ProjectName = item.ChargeItemName
|
|
445
|
+// inspection_reference.Project = item.ChargeItemName
|
|
446
|
+// inspection_reference.ProjectId = project_id
|
|
447
|
+// inspection_reference.ItemName = item.InspectionName
|
|
448
|
+// inspection_reference.ItemNameAddition = item.Barcode
|
|
449
|
+// inspection_reference.ItemId = item_id
|
|
450
|
+// inspection_reference.RangeType = ItemType
|
|
451
|
+// inspection_reference.RangeMin = RangeMin
|
|
452
|
+// inspection_reference.RangeMax = RangeMax
|
|
453
|
+// inspection_reference.RangeOptions = RangeOptions
|
|
454
|
+// inspection_reference.Unit = item.Unit
|
|
455
|
+// inspection_reference.Status = 1
|
|
456
|
+// inspection_reference.CreatedTime = time.Now().Unix()
|
|
457
|
+// inspection_reference.UpdatedTime = time.Now().Unix()
|
|
458
|
+// inspection_reference.InspectDate = inspect_date
|
|
459
|
+// inspection_reference.UTime = inspect_date
|
|
460
|
+// err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
461
|
+// if err != nil {
|
|
462
|
+// tx.Rollback()
|
|
463
|
+// }
|
|
464
|
+// }
|
|
465
|
+// var itotal int
|
|
466
|
+// err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
467
|
+// if itotal <= 0 {
|
|
468
|
+// //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
469
|
+// //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
470
|
+// inspection.PatientId = printInfo.PatientId
|
|
471
|
+// inspection.OrgId = org_id
|
|
472
|
+// inspection.ProjectId = project_id
|
|
473
|
+// inspection.ItemName = inspection_reference.ItemName
|
|
474
|
+// inspection.ProjectName = inspection_reference.ProjectName
|
|
475
|
+// inspection.InspectType = ItemType
|
|
476
|
+// inspection.ItemId = item_id
|
|
477
|
+//
|
|
478
|
+// inspection.InspectValue = item.Result
|
|
479
|
+// inspection.InspectDate = inspect_date
|
|
480
|
+// inspection.RecordDate = record_date.Unix()
|
|
481
|
+// inspection.Status = 1
|
|
482
|
+// inspection.CreatedTime = time.Now().Unix()
|
|
483
|
+// inspection.UpdatedTime = time.Now().Unix()
|
|
484
|
+// inspection.UTime = inspect_date
|
|
485
|
+// inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
486
|
+// err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
487
|
+// if err != nil {
|
|
488
|
+// tx.Rollback()
|
|
489
|
+// }
|
|
490
|
+// }
|
|
491
|
+// tx.Commit()
|
|
492
|
+//
|
|
493
|
+// }
|
|
494
|
+// //插入一条查询检验检查结果记录状态数据
|
|
495
|
+// var info LisSyncResultStatusInfo
|
|
496
|
+// info.Ctime = time.Now().Unix()
|
|
497
|
+// info.Status = 1
|
|
498
|
+// info.Mtime = time.Now().Unix()
|
|
499
|
+// info.OrgId = org_id
|
|
500
|
+// info.IsResult = 1
|
|
501
|
+// code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
|
|
502
|
+// info.LastId = code
|
|
503
|
+// info.ResultDate = time.Now().Unix()
|
|
504
|
+// info.GpSyncEndDate = end_time
|
|
505
|
+// writeMiddleDb.Save(&info)
|
|
506
|
+// }
|
|
507
|
+// }
|
|
508
|
+//
|
|
509
|
+// } else {
|
|
510
|
+// //start_time := record.GpSyncEndDate
|
|
511
|
+// //end_time := time.Now().Format("2006-01-02")
|
|
512
|
+// //
|
|
513
|
+// //result := GetGPReportListData(start_time, end_time, key)
|
|
514
|
+// //list := GetGPResultDataTwo(result, key)
|
|
515
|
+// //
|
|
516
|
+// ////插入一条插入中间库记录数据
|
|
517
|
+// //if err == nil {
|
|
518
|
+// // if len(list) > 0 {
|
|
519
|
+// // //插入到系统检验检查数据
|
|
520
|
+// // for _, item := range list {
|
|
521
|
+// // project_id := int64(0)
|
|
522
|
+// // if len(item.ListResult.CustomerBarcode) > 0 {
|
|
523
|
+// // project_id, _, _ = GetSyjhProjectID(org_id, item.ChargeItemName)
|
|
524
|
+// // } else {
|
|
525
|
+// // continue
|
|
526
|
+// // }
|
|
527
|
+// // var patient models.Patients
|
|
528
|
+// // printInfo, _ := GetHisLabelPrintStatusInfoById(item.ListResult.CustomerBarcode)
|
|
529
|
+// // if printInfo.ID == 0 {
|
|
530
|
+// // patient, _ = GetPatientID(org_id, item.ListResult.PatientName)
|
|
531
|
+// // }
|
|
532
|
+// // if patient.ID > 0 {
|
|
533
|
+// // printInfo.PatientId = patient.ID
|
|
534
|
+// // }
|
|
535
|
+// // if printInfo.PatientId == 0 {
|
|
536
|
+// // continue
|
|
537
|
+// // }
|
|
538
|
+// //
|
|
539
|
+// // item_id, _ := GetSyItemID(org_id, item.ChargeItemName, item.InspectionName, project_id)
|
|
540
|
+// // tx := writeMiddleDb.Begin()
|
|
541
|
+// // var inspection models.MiddleInspection
|
|
542
|
+// // var inspection_reference models.MiddleInspectionReference
|
|
543
|
+// //
|
|
544
|
+// // recordDateStr := ""
|
|
545
|
+// // inspect_date := ""
|
|
546
|
+// // if len(item.ListResult.InspectDate) > 0 {
|
|
547
|
+// //
|
|
548
|
+// // inspect_date = item.ListResult.InspectDate
|
|
549
|
+// // } else {
|
|
550
|
+// // inspect_date = strings.Split(item.ListResult.ReceiveDateTime, " ")[0]
|
|
551
|
+// //
|
|
552
|
+// // }
|
|
553
|
+// // recordDateStr = inspect_date
|
|
554
|
+// //
|
|
555
|
+// // date, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
556
|
+// // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
|
|
557
|
+// // var total int
|
|
558
|
+// // var RangeOptions string
|
|
559
|
+// // var RangeMin string
|
|
560
|
+// // var RangeMax string
|
|
561
|
+// // // 判断检查类型
|
|
562
|
+// // var ItemType int
|
|
563
|
+// // if strings.Contains(item.Reference, "--") {
|
|
564
|
+// // ItemType = 1
|
|
565
|
+// // } else {
|
|
566
|
+// // ItemType = 2
|
|
567
|
+// //
|
|
568
|
+// // }
|
|
569
|
+// //
|
|
570
|
+// // if ItemType == 1 {
|
|
571
|
+// // Range := strings.Split(item.Reference, "--")
|
|
572
|
+// // RangeMin = Range[0]
|
|
573
|
+// // RangeMax = Range[1]
|
|
574
|
+// // } else {
|
|
575
|
+// // RangeOptions = item.Reference
|
|
576
|
+// // }
|
|
577
|
+// //
|
|
578
|
+// // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
579
|
+// // if inspection_reference.ID > 0 {
|
|
580
|
+// // ItemType = inspection_reference.RangeType
|
|
581
|
+// // }
|
|
582
|
+// // if total <= 0 {
|
|
583
|
+// // inspection_reference.OrgId = org_id
|
|
584
|
+// // inspection_reference.ProjectName = item.ChargeItemName
|
|
585
|
+// // inspection_reference.Project = item.ChargeItemName
|
|
586
|
+// // inspection_reference.ProjectId = project_id
|
|
587
|
+// // inspection_reference.ItemName = item.InspectionName
|
|
588
|
+// // inspection_reference.ItemNameAddition = item.Barcode
|
|
589
|
+// // inspection_reference.ItemId = item_id
|
|
590
|
+// // inspection_reference.RangeType = ItemType
|
|
591
|
+// // inspection_reference.RangeMin = RangeMin
|
|
592
|
+// // inspection_reference.RangeMax = RangeMax
|
|
593
|
+// // inspection_reference.RangeOptions = RangeOptions
|
|
594
|
+// // inspection_reference.Unit = item.Unit
|
|
595
|
+// // inspection_reference.Status = 1
|
|
596
|
+// // inspection_reference.CreatedTime = time.Now().Unix()
|
|
597
|
+// // inspection_reference.UpdatedTime = time.Now().Unix()
|
|
598
|
+// // inspection_reference.InspectDate = inspect_date
|
|
599
|
+// // inspection_reference.UTime = inspect_date
|
|
600
|
+// // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
601
|
+// // if err != nil {
|
|
602
|
+// // tx.Rollback()
|
|
603
|
+// // }
|
|
604
|
+// // }
|
|
605
|
+// //
|
|
606
|
+// // var itotal int
|
|
607
|
+// // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
608
|
+// // if itotal <= 0 {
|
|
609
|
+// // //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
610
|
+// // //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
611
|
+// // inspection.PatientId = printInfo.PatientId
|
|
612
|
+// // inspection.OrgId = org_id
|
|
613
|
+// // inspection.ProjectId = project_id
|
|
614
|
+// // inspection.ItemName = inspection_reference.ItemName
|
|
615
|
+// // inspection.ProjectName = inspection_reference.ProjectName
|
|
616
|
+// // inspection.InspectType = ItemType
|
|
617
|
+// // inspection.ItemId = item_id
|
|
618
|
+// //
|
|
619
|
+// // inspection.InspectValue = item.Result
|
|
620
|
+// // inspection.InspectDate = inspect_date
|
|
621
|
+// // inspection.RecordDate = record_date.Unix()
|
|
622
|
+// // inspection.Status = 1
|
|
623
|
+// // inspection.CreatedTime = time.Now().Unix()
|
|
624
|
+// // inspection.UpdatedTime = time.Now().Unix()
|
|
625
|
+// // inspection.UTime = inspect_date
|
|
626
|
+// // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
627
|
+// // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
628
|
+// // if err != nil {
|
|
629
|
+// // tx.Rollback()
|
|
630
|
+// // }
|
|
631
|
+// // }
|
|
632
|
+// //
|
|
633
|
+// // tx.Commit()
|
|
634
|
+// //
|
|
635
|
+// // }
|
|
636
|
+// // //插入一条查询检验检查结果记录状态数据
|
|
637
|
+// // var info LisSyncResultStatusInfo
|
|
638
|
+// // info.Ctime = time.Now().Unix()
|
|
639
|
+// // info.Status = 1
|
|
640
|
+// // info.Mtime = time.Now().Unix()
|
|
641
|
+// // info.OrgId = org_id
|
|
642
|
+// // info.IsResult = 1
|
|
643
|
+// // info.ResultDate = time.Now().Unix()
|
|
644
|
+// // info.GpSyncEndDate = end_time
|
|
645
|
+// // writeMiddleDb.Save(&info)
|
|
646
|
+// // }
|
|
647
|
+// //}
|
|
648
|
+// }
|
|
649
|
+// //// 第一步:跟进org_id 去中间库查出需要同步的数据
|
|
650
|
+//
|
|
651
|
+// //inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
|
|
652
|
+// //inspections, _ := GetSyncInspectionByOrgId(org_id)
|
|
653
|
+// //// 第二步:将数据同步到业务库
|
|
654
|
+// //if len(inspection_references) > 0 {
|
|
655
|
+// // for _, inspection_reference := range inspection_references {
|
|
656
|
+// // SyncInspectionReference(&inspection_reference)
|
|
657
|
+// // }
|
|
658
|
+// //}
|
|
659
|
+// //if len(inspections) > 0 {
|
|
660
|
+// // for _, inspection := range inspections {
|
|
661
|
+// // SyncInspection(&inspection)
|
|
662
|
+// // }
|
|
663
|
+// //}
|
|
664
|
+// //return
|
|
665
|
+//}
|
|
666
|
+
|
|
667
|
+func SyncSYData2() {
|
|
668
|
+ org_id := int64(10191)
|
|
669
|
+ start_time := "2024-04-20"
|
|
670
|
+ end_time := "2024-04-26"
|
354
|
671
|
record, _ := GetLastSyncResultRecord(org_id)
|
355
|
|
- if record.ID == 0 {
|
356
|
|
- //通过接口从高品那里获取检验数据
|
357
|
|
- start_time := "2023-06-01"
|
358
|
|
- end_time := "2023-06-30"
|
359
|
|
- result := GetGPReportListData(start_time, end_time, key)
|
360
|
|
- list := GetGPResultDataTwo(result, key)
|
361
|
|
- jsonData, err := json.Marshal(result)
|
362
|
|
- if err != nil {
|
363
|
|
- fmt.Println("转换为JSON时发生错误:", err)
|
364
|
|
- return
|
365
|
|
- }
|
366
|
|
- jsonStr := string(jsonData)
|
367
|
|
- jsonData1, err1 := json.Marshal(list)
|
368
|
|
- if err1 != nil {
|
369
|
|
- fmt.Println("转换为JSON时发生错误:", err1)
|
370
|
|
- return
|
371
|
|
- }
|
372
|
|
- jsonStr1 := string(jsonData1)
|
373
|
|
- saveLog1(jsonStr, "", "列表数据", "列表数据")
|
374
|
|
- saveLog1(jsonStr1, "", "结果数据", "结果数据")
|
|
672
|
+ if record.ID > 0 {
|
|
673
|
+ start_time = record.GpSyncEndDate
|
|
674
|
+ end_time = time.Now().Format("2006-01-02")
|
|
675
|
+ }
|
|
676
|
+ loc, _ := time.LoadLocation("Local")
|
|
677
|
+ theTime, _ := time.ParseInLocation("2006-01-02", start_time, loc)
|
|
678
|
+ newtheTime := theTime.Unix() - 60*60*24*3
|
|
679
|
+
|
|
680
|
+ SyncTime := time.Unix(newtheTime, 0)
|
|
681
|
+ syncTimeStr := SyncTime.Format("2006-01-02")
|
|
682
|
+
|
|
683
|
+ result := GetGPReportListData(syncTimeStr, end_time, key)
|
|
684
|
+ if len(result) > 0 {
|
|
685
|
+ for _, item := range result {
|
|
686
|
+ list := GetGPResultDataTwo(item, key)
|
375
|
687
|
|
376
|
|
- if err == nil {
|
377
|
|
- fmt.Println(list)
|
378
|
688
|
//插入到系统检验检查数据
|
379
|
689
|
if len(list) > 0 {
|
380
|
690
|
for _, item := range list {
|
381
|
691
|
project_id := int64(0)
|
382
|
|
- //xt_project_id := int64(0)
|
383
|
|
- if len(item.ListResult.Barcode) > 0 {
|
384
|
|
- project_id, _, _ = GetSyjhProjectID(org_id, item.ChargeItemName)
|
385
|
|
- } else {
|
386
|
|
- continue
|
387
|
|
- }
|
388
|
|
- //var patient models.Patients
|
389
|
|
- printInfo, _ := GetHisLabelPrintStatusInfoById(item.ListResult.CustomerBarcode)
|
390
|
|
- if printInfo.ID == 0 {
|
391
|
|
- patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
|
392
|
|
- printInfo.PatientId = patient.ID
|
|
692
|
+ patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
|
393
|
693
|
|
394
|
|
- }
|
395
|
|
- if printInfo.PatientId == 0 {
|
|
694
|
+ if patient.ID == 0 {
|
396
|
695
|
continue
|
397
|
696
|
}
|
398
|
|
- item_id, _ := GetSyItemID(org_id, item.ChargeItemName, item.InspectionName, project_id)
|
399
|
697
|
tx := writeMiddleDb.Begin()
|
400
|
698
|
var inspection models.MiddleInspection
|
401
|
699
|
var inspection_reference models.MiddleInspectionReference
|
402
|
700
|
|
403
|
|
- recordDateStr := ""
|
404
|
|
- inspect_date := ""
|
405
|
|
- if len(item.ListResult.InspectDate) > 0 {
|
406
|
|
-
|
407
|
|
- inspect_date = item.ListResult.InspectDate
|
408
|
|
-
|
409
|
|
- } else {
|
410
|
|
- inspect_date = strings.Split(item.ListResult.ReceiveDateTime, " ")[0]
|
411
|
|
-
|
412
|
|
- }
|
|
701
|
+ recordDateStr := item.ListResult.ReceiveDateTime
|
|
702
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
|
|
703
|
+ inspect_date := recordDate.Format("2006-01-02 15:04")
|
413
|
704
|
|
414
|
|
- recordDateStr = inspect_date
|
|
705
|
+ date, _ := time.Parse("2006-01-02 15:04:05", recordDateStr)
|
|
706
|
+ utils.InfoLog("date2: %v", date.Unix())
|
|
707
|
+ record_date_time, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
|
|
708
|
+ record_date := record_date_time.Unix()
|
415
|
709
|
|
416
|
|
- date, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
417
|
|
- record_date := date
|
418
|
710
|
var total int
|
419
|
711
|
var RangeOptions string
|
420
|
712
|
var RangeMin string
|
|
@@ -425,7 +717,6 @@ func SyncSYData(org_id int64) {
|
425
|
717
|
ItemType = 1
|
426
|
718
|
} else {
|
427
|
719
|
ItemType = 2
|
428
|
|
-
|
429
|
720
|
}
|
430
|
721
|
|
431
|
722
|
if ItemType == 1 {
|
|
@@ -435,11 +726,35 @@ func SyncSYData(org_id int64) {
|
435
|
726
|
} else {
|
436
|
727
|
RangeOptions = item.Reference
|
437
|
728
|
}
|
438
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
729
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project = ? and item_name = ? and status = 1", org_id, item.ChargeItemName, item.InspectionName).Find(&inspection_reference).Count(&total).Error
|
439
|
730
|
if inspection_reference.ID > 0 {
|
440
|
731
|
ItemType = inspection_reference.RangeType
|
|
732
|
+ project_id = inspection_reference.ProjectId
|
441
|
733
|
}
|
442
|
734
|
if total <= 0 {
|
|
735
|
+ var inspection_referenceTwo models.MiddleInspectionReference
|
|
736
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, item.ChargeItemName).First(&inspection_referenceTwo).Error
|
|
737
|
+ if inspection_referenceTwo.ID > 0 {
|
|
738
|
+ project_id = inspection_referenceTwo.ProjectId
|
|
739
|
+ } else {
|
|
740
|
+ err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_referenceTwo).Error
|
|
741
|
+ if inspection_referenceTwo.ProjectId > 0 {
|
|
742
|
+ project_id = inspection_referenceTwo.ProjectId + 1
|
|
743
|
+ } else {
|
|
744
|
+ project_id = 1019101
|
|
745
|
+ }
|
|
746
|
+ }
|
|
747
|
+
|
|
748
|
+ var item_id int64
|
|
749
|
+ var inspection_referenceThree models.MiddleInspectionReference
|
|
750
|
+ readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ?", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_referenceThree)
|
|
751
|
+ utils.InfoLog("inspection_reference: %v", inspection_reference)
|
|
752
|
+ if inspection_referenceThree.ItemId > 0 {
|
|
753
|
+ item_id = inspection_referenceThree.ItemId + 1
|
|
754
|
+ } else {
|
|
755
|
+ item_id = project_id*100 + 1
|
|
756
|
+ }
|
|
757
|
+
|
443
|
758
|
inspection_reference.OrgId = org_id
|
444
|
759
|
inspection_reference.ProjectName = item.ChargeItemName
|
445
|
760
|
inspection_reference.Project = item.ChargeItemName
|
|
@@ -463,371 +778,48 @@ func SyncSYData(org_id int64) {
|
463
|
778
|
}
|
464
|
779
|
}
|
465
|
780
|
var itotal int
|
466
|
|
- err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
781
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, inspection_reference.ItemId, record_date, patient.ID).Find(&inspection).Count(&itotal).Error
|
467
|
782
|
if itotal <= 0 {
|
468
|
783
|
//item.Result = strings.Replace(item.Result, ">", ">", -1)
|
469
|
784
|
//item.Result = strings.Replace(item.Result, "<", "<", -1)
|
470
|
|
- inspection.PatientId = printInfo.PatientId
|
|
785
|
+ inspection.PatientId = patient.ID
|
471
|
786
|
inspection.OrgId = org_id
|
472
|
787
|
inspection.ProjectId = project_id
|
473
|
788
|
inspection.ItemName = inspection_reference.ItemName
|
474
|
789
|
inspection.ProjectName = inspection_reference.ProjectName
|
475
|
790
|
inspection.InspectType = ItemType
|
476
|
|
- inspection.ItemId = item_id
|
477
|
|
-
|
|
791
|
+ inspection.ItemId = inspection_reference.ItemId
|
478
|
792
|
inspection.InspectValue = item.Result
|
479
|
793
|
inspection.InspectDate = inspect_date
|
480
|
|
- inspection.RecordDate = record_date.Unix()
|
|
794
|
+ inspection.RecordDate = record_date
|
481
|
795
|
inspection.Status = 1
|
482
|
796
|
inspection.CreatedTime = time.Now().Unix()
|
483
|
797
|
inspection.UpdatedTime = time.Now().Unix()
|
484
|
798
|
inspection.UTime = inspect_date
|
485
|
|
- inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
799
|
+ inspection.HisUserId = strconv.FormatInt(patient.ID, 10)
|
|
800
|
+ inspection.SysProjectId = inspection_reference.XtProjectId
|
|
801
|
+ inspection.SysItemId = inspection_reference.XtItemId
|
486
|
802
|
err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
487
|
803
|
if err != nil {
|
488
|
804
|
tx.Rollback()
|
489
|
805
|
}
|
490
|
806
|
}
|
491
|
807
|
tx.Commit()
|
492
|
|
-
|
493
|
808
|
}
|
494
|
|
- //插入一条查询检验检查结果记录状态数据
|
495
|
|
- var info LisSyncResultStatusInfo
|
496
|
|
- info.Ctime = time.Now().Unix()
|
497
|
|
- info.Status = 1
|
498
|
|
- info.Mtime = time.Now().Unix()
|
499
|
|
- info.OrgId = org_id
|
500
|
|
- info.IsResult = 1
|
501
|
|
- code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
|
502
|
|
- info.LastId = code
|
503
|
|
- info.ResultDate = time.Now().Unix()
|
504
|
|
- info.GpSyncEndDate = end_time
|
505
|
|
- writeMiddleDb.Save(&info)
|
506
|
809
|
}
|
507
|
810
|
}
|
508
|
|
-
|
509
|
|
- } else {
|
510
|
|
- //start_time := record.GpSyncEndDate
|
511
|
|
- //end_time := time.Now().Format("2006-01-02")
|
512
|
|
- //
|
513
|
|
- //result := GetGPReportListData(start_time, end_time, key)
|
514
|
|
- //list := GetGPResultDataTwo(result, key)
|
515
|
|
- //
|
516
|
|
- ////插入一条插入中间库记录数据
|
517
|
|
- //if err == nil {
|
518
|
|
- // if len(list) > 0 {
|
519
|
|
- // //插入到系统检验检查数据
|
520
|
|
- // for _, item := range list {
|
521
|
|
- // project_id := int64(0)
|
522
|
|
- // if len(item.ListResult.CustomerBarcode) > 0 {
|
523
|
|
- // project_id, _, _ = GetSyjhProjectID(org_id, item.ChargeItemName)
|
524
|
|
- // } else {
|
525
|
|
- // continue
|
526
|
|
- // }
|
527
|
|
- // var patient models.Patients
|
528
|
|
- // printInfo, _ := GetHisLabelPrintStatusInfoById(item.ListResult.CustomerBarcode)
|
529
|
|
- // if printInfo.ID == 0 {
|
530
|
|
- // patient, _ = GetPatientID(org_id, item.ListResult.PatientName)
|
531
|
|
- // }
|
532
|
|
- // if patient.ID > 0 {
|
533
|
|
- // printInfo.PatientId = patient.ID
|
534
|
|
- // }
|
535
|
|
- // if printInfo.PatientId == 0 {
|
536
|
|
- // continue
|
537
|
|
- // }
|
538
|
|
- //
|
539
|
|
- // item_id, _ := GetSyItemID(org_id, item.ChargeItemName, item.InspectionName, project_id)
|
540
|
|
- // tx := writeMiddleDb.Begin()
|
541
|
|
- // var inspection models.MiddleInspection
|
542
|
|
- // var inspection_reference models.MiddleInspectionReference
|
543
|
|
- //
|
544
|
|
- // recordDateStr := ""
|
545
|
|
- // inspect_date := ""
|
546
|
|
- // if len(item.ListResult.InspectDate) > 0 {
|
547
|
|
- //
|
548
|
|
- // inspect_date = item.ListResult.InspectDate
|
549
|
|
- // } else {
|
550
|
|
- // inspect_date = strings.Split(item.ListResult.ReceiveDateTime, " ")[0]
|
551
|
|
- //
|
552
|
|
- // }
|
553
|
|
- // recordDateStr = inspect_date
|
554
|
|
- //
|
555
|
|
- // date, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
556
|
|
- // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
|
557
|
|
- // var total int
|
558
|
|
- // var RangeOptions string
|
559
|
|
- // var RangeMin string
|
560
|
|
- // var RangeMax string
|
561
|
|
- // // 判断检查类型
|
562
|
|
- // var ItemType int
|
563
|
|
- // if strings.Contains(item.Reference, "--") {
|
564
|
|
- // ItemType = 1
|
565
|
|
- // } else {
|
566
|
|
- // ItemType = 2
|
567
|
|
- //
|
568
|
|
- // }
|
569
|
|
- //
|
570
|
|
- // if ItemType == 1 {
|
571
|
|
- // Range := strings.Split(item.Reference, "--")
|
572
|
|
- // RangeMin = Range[0]
|
573
|
|
- // RangeMax = Range[1]
|
574
|
|
- // } else {
|
575
|
|
- // RangeOptions = item.Reference
|
576
|
|
- // }
|
577
|
|
- //
|
578
|
|
- // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
579
|
|
- // if inspection_reference.ID > 0 {
|
580
|
|
- // ItemType = inspection_reference.RangeType
|
581
|
|
- // }
|
582
|
|
- // if total <= 0 {
|
583
|
|
- // inspection_reference.OrgId = org_id
|
584
|
|
- // inspection_reference.ProjectName = item.ChargeItemName
|
585
|
|
- // inspection_reference.Project = item.ChargeItemName
|
586
|
|
- // inspection_reference.ProjectId = project_id
|
587
|
|
- // inspection_reference.ItemName = item.InspectionName
|
588
|
|
- // inspection_reference.ItemNameAddition = item.Barcode
|
589
|
|
- // inspection_reference.ItemId = item_id
|
590
|
|
- // inspection_reference.RangeType = ItemType
|
591
|
|
- // inspection_reference.RangeMin = RangeMin
|
592
|
|
- // inspection_reference.RangeMax = RangeMax
|
593
|
|
- // inspection_reference.RangeOptions = RangeOptions
|
594
|
|
- // inspection_reference.Unit = item.Unit
|
595
|
|
- // inspection_reference.Status = 1
|
596
|
|
- // inspection_reference.CreatedTime = time.Now().Unix()
|
597
|
|
- // inspection_reference.UpdatedTime = time.Now().Unix()
|
598
|
|
- // inspection_reference.InspectDate = inspect_date
|
599
|
|
- // inspection_reference.UTime = inspect_date
|
600
|
|
- // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
601
|
|
- // if err != nil {
|
602
|
|
- // tx.Rollback()
|
603
|
|
- // }
|
604
|
|
- // }
|
605
|
|
- //
|
606
|
|
- // var itotal int
|
607
|
|
- // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date.Unix(), printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
608
|
|
- // if itotal <= 0 {
|
609
|
|
- // //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
610
|
|
- // //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
611
|
|
- // inspection.PatientId = printInfo.PatientId
|
612
|
|
- // inspection.OrgId = org_id
|
613
|
|
- // inspection.ProjectId = project_id
|
614
|
|
- // inspection.ItemName = inspection_reference.ItemName
|
615
|
|
- // inspection.ProjectName = inspection_reference.ProjectName
|
616
|
|
- // inspection.InspectType = ItemType
|
617
|
|
- // inspection.ItemId = item_id
|
618
|
|
- //
|
619
|
|
- // inspection.InspectValue = item.Result
|
620
|
|
- // inspection.InspectDate = inspect_date
|
621
|
|
- // inspection.RecordDate = record_date.Unix()
|
622
|
|
- // inspection.Status = 1
|
623
|
|
- // inspection.CreatedTime = time.Now().Unix()
|
624
|
|
- // inspection.UpdatedTime = time.Now().Unix()
|
625
|
|
- // inspection.UTime = inspect_date
|
626
|
|
- // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
627
|
|
- // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
628
|
|
- // if err != nil {
|
629
|
|
- // tx.Rollback()
|
630
|
|
- // }
|
631
|
|
- // }
|
632
|
|
- //
|
633
|
|
- // tx.Commit()
|
634
|
|
- //
|
635
|
|
- // }
|
636
|
|
- // //插入一条查询检验检查结果记录状态数据
|
637
|
|
- // var info LisSyncResultStatusInfo
|
638
|
|
- // info.Ctime = time.Now().Unix()
|
639
|
|
- // info.Status = 1
|
640
|
|
- // info.Mtime = time.Now().Unix()
|
641
|
|
- // info.OrgId = org_id
|
642
|
|
- // info.IsResult = 1
|
643
|
|
- // info.ResultDate = time.Now().Unix()
|
644
|
|
- // info.GpSyncEndDate = end_time
|
645
|
|
- // writeMiddleDb.Save(&info)
|
646
|
|
- // }
|
647
|
|
- //}
|
648
|
|
- }
|
649
|
|
- //// 第一步:跟进org_id 去中间库查出需要同步的数据
|
650
|
|
-
|
651
|
|
- //inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
|
652
|
|
- //inspections, _ := GetSyncInspectionByOrgId(org_id)
|
653
|
|
- //// 第二步:将数据同步到业务库
|
654
|
|
- //if len(inspection_references) > 0 {
|
655
|
|
- // for _, inspection_reference := range inspection_references {
|
656
|
|
- // SyncInspectionReference(&inspection_reference)
|
657
|
|
- // }
|
658
|
|
- //}
|
659
|
|
- //if len(inspections) > 0 {
|
660
|
|
- // for _, inspection := range inspections {
|
661
|
|
- // SyncInspection(&inspection)
|
662
|
|
- // }
|
663
|
|
- //}
|
664
|
|
- //return
|
665
|
|
-}
|
666
|
|
-
|
667
|
|
-func SyncSYData2() {
|
668
|
|
- org_id := int64(10191)
|
669
|
|
- start_time := "2024-01-01"
|
670
|
|
- end_time := "2024-04-15"
|
671
|
|
- record, _ := GetLastSyncResultRecord(org_id)
|
672
|
|
- if record.ID > 0 {
|
673
|
|
- start_time = record.GpSyncEndDate
|
674
|
|
- end_time = time.Now().Format("2006-01-02")
|
675
|
|
- }
|
676
|
|
- result := GetGPReportListData(start_time, end_time, key)
|
677
|
|
- list := GetGPResultDataTwo(result, key)
|
678
|
|
- jsonData, err := json.Marshal(result)
|
679
|
|
- if err != nil {
|
680
|
|
- fmt.Println("转换为JSON时发生错误:", err)
|
681
|
|
- return
|
682
|
|
- }
|
683
|
|
- jsonStr := string(jsonData)
|
684
|
|
- jsonData1, err1 := json.Marshal(list)
|
685
|
|
- if err1 != nil {
|
686
|
|
- fmt.Println("转换为JSON时发生错误:", err1)
|
687
|
|
- return
|
|
811
|
+ //插入一条查询检验检查结果记录状态数据
|
|
812
|
+ var info LisSyncResultStatusInfo
|
|
813
|
+ info.Ctime = time.Now().Unix()
|
|
814
|
+ info.Status = 1
|
|
815
|
+ info.Mtime = time.Now().Unix()
|
|
816
|
+ info.OrgId = org_id
|
|
817
|
+ info.IsResult = 1
|
|
818
|
+ info.ResultDate = time.Now().Unix()
|
|
819
|
+ info.GpSyncEndDate = end_time
|
|
820
|
+ writeMiddleDb.Save(&info)
|
688
|
821
|
}
|
689
|
|
- jsonStr1 := string(jsonData1)
|
690
|
|
- saveLog1(jsonStr, "", "列表数据", "列表数据")
|
691
|
|
- saveLog1(jsonStr1, "", "结果数据", "结果数据")
|
692
|
|
-
|
693
|
|
- if err == nil {
|
694
|
|
- fmt.Println(list)
|
695
|
|
- //插入到系统检验检查数据
|
696
|
|
- if len(list) > 0 {
|
697
|
|
- tx := writeMiddleDb.Begin()
|
698
|
|
- for _, item := range list {
|
699
|
|
- project_id := int64(0)
|
700
|
|
- patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
|
701
|
|
-
|
702
|
|
- if patient.ID == 0 {
|
703
|
|
- continue
|
704
|
|
- }
|
705
|
|
- var inspection models.MiddleInspection
|
706
|
|
- var inspection_reference models.MiddleInspectionReference
|
707
|
|
-
|
708
|
|
- recordDateStr := item.ListResult.ReceiveDateTime
|
709
|
|
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", recordDateStr)
|
710
|
|
- inspect_date := recordDate.Format("2006-01-02 15:04")
|
711
|
|
-
|
712
|
|
- date, _ := time.Parse("2006-01-02 15:04:05", recordDateStr)
|
713
|
|
- utils.InfoLog("date2: %v", date.Unix())
|
714
|
|
- record_date_time, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", inspect_date)
|
715
|
|
- record_date := record_date_time.Unix()
|
716
|
|
-
|
717
|
|
- var total int
|
718
|
|
- var RangeOptions string
|
719
|
|
- var RangeMin string
|
720
|
|
- var RangeMax string
|
721
|
|
- // 判断检查类型
|
722
|
|
- var ItemType int
|
723
|
|
- if strings.Contains(item.Reference, "--") {
|
724
|
|
- ItemType = 1
|
725
|
|
- } else {
|
726
|
|
- ItemType = 2
|
727
|
|
- }
|
728
|
822
|
|
729
|
|
- if ItemType == 1 {
|
730
|
|
- Range := strings.Split(item.Reference, "--")
|
731
|
|
- RangeMin = Range[0]
|
732
|
|
- RangeMax = Range[1]
|
733
|
|
- } else {
|
734
|
|
- RangeOptions = item.Reference
|
735
|
|
- }
|
736
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and item_name = ? and status = 1", org_id, item.InspectionName).Find(&inspection_reference).Count(&total).Error
|
737
|
|
- if inspection_reference.ID > 0 {
|
738
|
|
- ItemType = inspection_reference.RangeType
|
739
|
|
- project_id = inspection_reference.ProjectId
|
740
|
|
- }
|
741
|
|
- if total <= 0 {
|
742
|
|
- var inspection_referenceTwo models.MiddleInspectionReference
|
743
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, item.ChargeItemName).First(&inspection_referenceTwo).Error
|
744
|
|
- if inspection_referenceTwo.ID > 0 {
|
745
|
|
- project_id = inspection_referenceTwo.ProjectId
|
746
|
|
- } else {
|
747
|
|
- err = readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id=? ", org_id).Select("max(project_id) as project_id").Scan(&inspection_referenceTwo).Error
|
748
|
|
- if inspection_referenceTwo.ProjectId > 0 {
|
749
|
|
- project_id = inspection_referenceTwo.ProjectId + 1
|
750
|
|
- } else {
|
751
|
|
- project_id = 1019101
|
752
|
|
- }
|
753
|
|
- }
|
754
|
|
-
|
755
|
|
- var item_id int64
|
756
|
|
- var inspection_referenceThree models.MiddleInspectionReference
|
757
|
|
- readMiddleDb.Table("xt_middle_inspection_reference").Where("org_id = ? and project_id = ?", org_id, project_id).Select("max(item_id) as item_id").First(&inspection_referenceThree)
|
758
|
|
- utils.InfoLog("inspection_reference: %v", inspection_reference)
|
759
|
|
- if inspection_referenceThree.ItemId > 0 {
|
760
|
|
- item_id = inspection_referenceThree.ItemId + 1
|
761
|
|
- } else {
|
762
|
|
- item_id = project_id*100 + 1
|
763
|
|
- }
|
764
|
|
-
|
765
|
|
- inspection_reference.OrgId = org_id
|
766
|
|
- inspection_reference.ProjectName = item.ChargeItemName
|
767
|
|
- inspection_reference.Project = item.ChargeItemName
|
768
|
|
- inspection_reference.ProjectId = project_id
|
769
|
|
- inspection_reference.ItemName = item.InspectionName
|
770
|
|
- inspection_reference.ItemNameAddition = item.Barcode
|
771
|
|
- inspection_reference.ItemId = item_id
|
772
|
|
- inspection_reference.RangeType = ItemType
|
773
|
|
- inspection_reference.RangeMin = RangeMin
|
774
|
|
- inspection_reference.RangeMax = RangeMax
|
775
|
|
- inspection_reference.RangeOptions = RangeOptions
|
776
|
|
- inspection_reference.Unit = item.Unit
|
777
|
|
- inspection_reference.Status = 1
|
778
|
|
- inspection_reference.CreatedTime = time.Now().Unix()
|
779
|
|
- inspection_reference.UpdatedTime = time.Now().Unix()
|
780
|
|
- inspection_reference.InspectDate = inspect_date
|
781
|
|
- inspection_reference.UTime = inspect_date
|
782
|
|
- err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
783
|
|
- if err != nil {
|
784
|
|
- tx.Rollback()
|
785
|
|
- }
|
786
|
|
- }
|
787
|
|
- var itotal int
|
788
|
|
- err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, inspection_reference.ItemId, record_date, patient.ID).Find(&inspection).Count(&itotal).Error
|
789
|
|
- if itotal <= 0 {
|
790
|
|
- //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
791
|
|
- //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
792
|
|
- inspection.PatientId = patient.ID
|
793
|
|
- inspection.OrgId = org_id
|
794
|
|
- inspection.ProjectId = project_id
|
795
|
|
- inspection.ItemName = inspection_reference.ItemName
|
796
|
|
- inspection.ProjectName = inspection_reference.ProjectName
|
797
|
|
- inspection.InspectType = ItemType
|
798
|
|
- inspection.ItemId = inspection_reference.ItemId
|
799
|
|
- inspection.InspectValue = item.Result
|
800
|
|
- inspection.InspectDate = inspect_date
|
801
|
|
- inspection.RecordDate = record_date
|
802
|
|
- inspection.Status = 1
|
803
|
|
- inspection.CreatedTime = time.Now().Unix()
|
804
|
|
- inspection.UpdatedTime = time.Now().Unix()
|
805
|
|
- inspection.UTime = inspect_date
|
806
|
|
- inspection.HisUserId = strconv.FormatInt(patient.ID, 10)
|
807
|
|
- inspection.SysProjectId = inspection_reference.XtProjectId
|
808
|
|
- inspection.SysItemId = inspection_reference.XtItemId
|
809
|
|
- err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
810
|
|
- if err != nil {
|
811
|
|
- tx.Rollback()
|
812
|
|
- }
|
813
|
|
- }
|
814
|
|
- }
|
815
|
|
- //插入一条查询检验检查结果记录状态数据
|
816
|
|
- var info LisSyncResultStatusInfo
|
817
|
|
- info.Ctime = time.Now().Unix()
|
818
|
|
- info.Status = 1
|
819
|
|
- info.Mtime = time.Now().Unix()
|
820
|
|
- info.OrgId = org_id
|
821
|
|
- info.IsResult = 1
|
822
|
|
- code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
|
823
|
|
- info.LastId = code
|
824
|
|
- info.ResultDate = time.Now().Unix()
|
825
|
|
- info.GpSyncEndDate = end_time
|
826
|
|
- writeMiddleDb.Save(&info)
|
827
|
|
-
|
828
|
|
- tx.Commit()
|
829
|
|
- }
|
830
|
|
- }
|
831
|
823
|
SyncToSssytx()
|
832
|
824
|
UpdateJg()
|
833
|
825
|
}
|