Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 11 months ago
parent
commit
547ba85430

+ 7 - 7
controllers/base_api_controller.go View File

@@ -73,7 +73,7 @@ func (this *BaseAuthAPIController) Prepare() {
73 73
 		var userAdmin models.AdminUser
74 74
 		userAdmin.Id = 16919
75 75
 		userAdmin.Mobile = "15717313968"
76
-		userAdmin.Id = 10579 //4,809
76
+		userAdmin.Id = 10599 //4,809
77 77
 		userAdmin.Mobile = "12222222222"
78 78
 		userAdmin.IsSuperAdmin = true
79 79
 		userAdmin.Status = 1
@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 11
84
-		subscibe.OrgId = 10344 //机构id 10344
84
+		subscibe.OrgId = 10598 //机构id 10344
85 85
 		subscibe.PeriodStart = 1547447814
86 86
 		subscibe.PeriodEnd = 1550039814
87 87
 		subscibe.State = 1
@@ -91,8 +91,8 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
95
-		adminUserInfo.CurrentAppId = 14655 //4
94
+		adminUserInfo.CurrentOrgId = 10598 //机构id小英9675或4
95
+		adminUserInfo.CurrentAppId = 3467  //4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 11
329
-		subscibe.OrgId = 10344 //机构id小英10344或4
329
+		subscibe.OrgId = 10598 //机构id小英10344或4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,8 +336,8 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
340
-		adminUserInfo.CurrentAppId = 14655 //4
339
+		adminUserInfo.CurrentOrgId = 10598 //机构id小英9675或4
340
+		adminUserInfo.CurrentAppId = 3467  //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes
343 343
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 1 - 1
controllers/dialysis_api_controller.go View File

@@ -7150,7 +7150,7 @@ func (this *DialysisApiController) GetDialysisPatientsFlow() {
7150 7150
 
7151 7151
 	} else {
7152 7152
 		dialysisSchedule, err, total := service.GetDialysisWatchFlow(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
7153
-		fmt.Println("dialysisSchedule-----------------------", dialysisSchedule)
7153
+
7154 7154
 		if err == nil {
7155 7155
 			this.ServeSuccessJSON(map[string]interface{}{
7156 7156
 				"schedule": dialysisSchedule,

+ 6 - 8
controllers/manage_api_controller.go View File

@@ -2881,7 +2881,6 @@ func (this *MachineApiController) GetPatientDetail() {
2881 2881
 
2882 2882
 func (this *MachineApiController) SaveReminder() {
2883 2883
 	id, _ := this.GetInt64("id")
2884
-	fmt.Print("码字", id)
2885 2884
 	info := this.GetAdminUserInfo()
2886 2885
 	orgId := info.CurrentOrgId
2887 2886
 	remander := models.DeviceRemander{
@@ -2892,8 +2891,7 @@ func (this *MachineApiController) SaveReminder() {
2892 2891
 	}
2893 2892
 	data, errs := service.GetRemanderData(orgId)
2894 2893
 	if errs == gorm.ErrRecordNotFound {
2895
-		err := service.CreateRemander(&remander).Error()
2896
-		fmt.Print(err)
2894
+		service.CreateRemander(&remander).Error()
2897 2895
 	} else if errs == nil {
2898 2896
 		deviceRemander := models.DeviceRemander{
2899 2897
 			ID:        data.ID,
@@ -2902,11 +2900,11 @@ func (this *MachineApiController) SaveReminder() {
2902 2900
 			UserOrgId: orgId,
2903 2901
 			Mtime:     time.Now().Unix(),
2904 2902
 		}
2905
-		err := service.UpdateRemander(&deviceRemander)
2906
-		if err != nil {
2907
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2908
-			return
2909
-		}
2903
+		service.UpdateRemander(&deviceRemander)
2904
+		//if err != nil {
2905
+		//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2906
+		//	return
2907
+		//}
2910 2908
 	}
2911 2909
 	this.ServeSuccessJSON(map[string]interface{}{
2912 2910
 		"id": id,

+ 23 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -606,6 +606,7 @@ func (this *DialysisAPIController) DialysisRecord() {
606 606
 	lastAssesmentBeforDialysis, _ := service.GetLastAssessmentBeforDialysis(patientID, adminInfo.Org.Id)
607 607
 
608 608
 	dryWeightList, _ := service.GetPatientDryList(patientID, adminInfo.Org.Id)
609
+
609 610
 	returnData := map[string]interface{}{
610 611
 		"patient":                        patient,
611 612
 		"schedual":                       schedual,
@@ -2610,6 +2611,10 @@ func (c *DialysisAPIController) Finish() {
2610 2611
 			tempassessmentAfterDislysis.ActualUltrafiltration = 0
2611 2612
 		}
2612 2613
 
2614
+		if adminUserInfo.Org.Id == 10612 {
2615
+			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
2616
+		}
2617
+
2613 2618
 	}
2614 2619
 
2615 2620
 	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
@@ -10572,6 +10577,24 @@ func (c *DialysisAPIController) MobileCoverSch() {
10572 10577
 	id_one, _ := c.GetInt64("id_one")
10573 10578
 	id_two, _ := c.GetInt64("id_two")
10574 10579
 	sch, _ := service.GetScheduleTen(c.GetMobileAdminUserInfo().Org.Id, id_one)
10580
+	//针对凤凰医院
10581
+	if c.GetMobileAdminUserInfo().Org.Id == 10579 || c.GetMobileAdminUserInfo().Org.Id == 10344 || c.GetMobileAdminUserInfo().Org.Id == 10206 {
10582
+		advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10583
+		if len(advice) > 0 {
10584
+			service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10585
+		}
10586
+	}
10587
+
10588
+	if c.GetMobileAdminUserInfo().Org.Id == 10206 || c.GetMobileAdminUserInfo().Org.Id == 10344 {
10589
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10590
+		project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10591
+		if len(hisAdvice) > 0 {
10592
+			service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10593
+		}
10594
+		if len(project) > 0 {
10595
+			service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10596
+		}
10597
+	}
10575 10598
 	sch_two, _ := service.GetScheduleTen(c.GetMobileAdminUserInfo().Org.Id, id_two)
10576 10599
 
10577 10600
 	order, _ := service.GetOneDialysisOrderOne(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)

+ 161 - 2
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -522,10 +522,148 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
522 522
 func (this *StaffScheduleApiController) DeleteSchedule() {
523 523
 	id, _ := this.GetInt64("id")
524 524
 	org_id := this.GetMobileAdminUserInfo().Org.Id
525
-	err := service.DeleteSchedule(id)
526 525
 
526
+	schedule, _ := service.GetScheduleNight(org_id, id)
527
+
528
+	//如果使用的是保存出库功能
529
+	drugOutConfig, _ := service.FindDrugOutConfigById(org_id)
530
+	//退库
531
+	if drugOutConfig.IsOpen == 1 {
532
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, org_id)
533
+		for _, item := range hisAdvice {
534
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
535
+			err := service.DrugAutoAddCancelInfo(item, creater)
536
+			if err != nil {
537
+				err = fmt.Errorf("!:%v", err)
538
+				return
539
+			}
540
+		}
541
+		//查询是否有出库记录
542
+		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, org_id)
543
+	}
544
+
545
+	//查询该患者当天是否开耗材
546
+	list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, org_id)
547
+	if len(list) > 0 {
548
+
549
+		operation_time := time.Now().Unix()
550
+		creater := this.GetMobileAdminUserInfo().AdminUser.Id
551
+		//创建退库单
552
+		timeStr := time.Now().Format("2006-01-02")
553
+		timeArr := strings.Split(timeStr, "-")
554
+		total, _ := service.FindAllCancelStockTotal(org_id)
555
+		total = total + 1
556
+		orderNumber := "CKTKD" + strconv.FormatInt(org_id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
557
+		houseConfig, _ := service.GetAllStoreHouseConfig(org_id)
558
+		cancelStock := models.CancelStock{
559
+			OrderNumber:  orderNumber,
560
+			OperaTime:    operation_time,
561
+			OrgId:        org_id,
562
+			Creater:      creater,
563
+			Ctime:        time.Now().Unix(),
564
+			Status:       1,
565
+			ReturnTime:   schedule.ScheduleDate,
566
+			Type:         1,
567
+			StorehouseId: houseConfig.StorehouseOutInfo,
568
+			IsCheck:      1,
569
+		}
570
+		_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, org_id)
571
+		if msgerrkonde == gorm.ErrRecordNotFound {
572
+			service.AddSigleCancelStock(&cancelStock)
573
+		}
574
+		cancel, _ := service.GetLastCancelStockById(org_id)
575
+		//进行退库操作
576
+		for _, item := range list {
577
+			good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
578
+			manufacturer, _ := service.GetManufactureById(item.Manufacturer)
579
+			deaerler, _ := service.GetDealerById(item.Dealer)
580
+			//回退库存
581
+			service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
582
+			goodList, _ := service.GetSumGoodList(org_id, houseConfig.StorehouseOutInfo, item.GoodId)
583
+			var flush_count int64
584
+			for _, it := range goodList {
585
+				flush_count += it.StockCount
586
+			}
587
+			cancelStockInfo := models.CancelStockInfo{
588
+				GoodId:          item.GoodId,
589
+				CancelStockId:   cancel.ID,
590
+				GoodTypeId:      good.GoodTypeId,
591
+				Count:           item.Count,
592
+				Price:           item.Price,
593
+				Total:           0,
594
+				ProductDate:     item.ProductDate,
595
+				ExpiryDate:      item.ExpiryDate,
596
+				Ctime:           time.Now().Unix(),
597
+				Status:          1,
598
+				OrgId:           org_id,
599
+				OrderNumber:     cancel.OrderNumber,
600
+				Type:            0,
601
+				Dealer:          deaerler.DealerName,
602
+				Manufacturer:    manufacturer.ManufacturerName,
603
+				Number:          item.Number,
604
+				RegisterAccount: "",
605
+				Remark:          "",
606
+				WarehouseInfoId: item.WarehouseInfotId,
607
+				PatientId:       item.PatientId,
608
+				RecordDate:      item.SysRecordTime,
609
+				StorehouseId:    houseConfig.StorehouseOutInfo,
610
+				IsCheck:         1,
611
+			}
612
+
613
+			service.CreateCancelStockInfoOne(&cancelStockInfo)
614
+
615
+			cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
616
+
617
+			flow := models.VmStockFlow{
618
+				WarehousingId:           item.WarehouseInfotId,
619
+				GoodId:                  item.GoodId,
620
+				Number:                  item.Number,
621
+				LicenseNumber:           item.LicenseNumber,
622
+				Count:                   item.Count,
623
+				UserOrgId:               org_id,
624
+				PatientId:               item.PatientId,
625
+				SystemTime:              item.SysRecordTime,
626
+				ConsumableType:          7,
627
+				IsSys:                   0,
628
+				WarehousingOrder:        "",
629
+				WarehouseOutId:          item.WarehouseOutId,
630
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
631
+				IsEdit:                  0,
632
+				CancelStockId:           cancel.ID,
633
+				CancelOrderNumber:       cancel.OrderNumber,
634
+				Manufacturer:            manufacturer.ID,
635
+				Dealer:                  0,
636
+				Creator:                 org_id,
637
+				UpdateCreator:           0,
638
+				Status:                  1,
639
+				Ctime:                   time.Now().Unix(),
640
+				Mtime:                   0,
641
+				Price:                   item.Price,
642
+				WarehousingDetailId:     item.WarehouseInfotId,
643
+				WarehouseOutDetailId:    item.ID,
644
+				CancelOutDetailId:       cancelInfo.ID,
645
+				ProductDate:             item.ProductDate,
646
+				ExpireDate:              item.ExpiryDate,
647
+				StorehouseId:            houseConfig.StorehouseOutInfo,
648
+				OverCount:               flush_count,
649
+			}
650
+			service.CreateStockFlowOne(flow)
651
+
652
+			//退库数量增加
653
+			service.UpdateSumAddCancelCount(org_id, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
654
+			//出库数量减少
655
+			service.UpdateSumCount(org_id, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
656
+
657
+			//更新库存
658
+			service.UpdateSumGood(org_id, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
659
+
660
+			//更新基础库库存
661
+			service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, org_id)
662
+		}
663
+	}
664
+
665
+	err := service.DeleteSchedule(id)
527 666
 	if err == nil {
528
-		schedule, _ := service.GetScheduleNight(org_id, id)
529 667
 
530 668
 		//记录日志
531 669
 		byterequest, _ := json.Marshal(schedule)
@@ -1253,6 +1391,27 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
1253 1391
 		}
1254 1392
 		service.UpdateRepeatSchStatus(org_id, schedule_date)
1255 1393
 		service.CreateScheduleLog(scheduleLog)
1394
+
1395
+		scheduleToday, _ := service.GetPatientScheduleToday(schedule.PatientId, schedule.ScheduleDate, schedule.UserOrgId)
1396
+
1397
+		//针对凤凰医院
1398
+		if org_id == 10579 || org_id == 10344 || org_id == 10206 {
1399
+			advice, _ := service.GetDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1400
+			if len(advice) > 0 {
1401
+				service.UpdateAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1402
+			}
1403
+		}
1404
+
1405
+		if org_id == 10206 || org_id == 10344 {
1406
+			hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1407
+			project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1408
+			if len(hisAdvice) > 0 {
1409
+				service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1410
+			}
1411
+			if len(project) > 0 {
1412
+				service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1413
+			}
1414
+		}
1256 1415
 		if err == nil {
1257 1416
 			c.ServeSuccessJSON(map[string]interface{}{
1258 1417
 				"msg": "ok",

+ 175 - 0
controllers/schedule_api_controller.go View File

@@ -97,6 +97,25 @@ func (c *ScheduleApiController) CoverSch() {
97 97
 	id_one, _ := c.GetInt64("id_one")
98 98
 	id_two, _ := c.GetInt64("id_two")
99 99
 	sch, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_one)
100
+	orgId := c.GetAdminUserInfo().CurrentOrgId
101
+	//针对凤凰医院
102
+	if orgId == 10579 || orgId == 10344 || orgId == 10206 {
103
+		advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
104
+		if len(advice) > 0 {
105
+			service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
106
+		}
107
+	}
108
+
109
+	if orgId == 10206 || orgId == 10344 {
110
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
111
+		project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, orgId)
112
+		if len(hisAdvice) > 0 {
113
+			service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
114
+		}
115
+		if len(project) > 0 {
116
+			service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, orgId)
117
+		}
118
+	}
100 119
 	sch_two, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_two)
101 120
 	//order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
102 121
 	//if order.ID > 0 {
@@ -714,6 +733,24 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
714 733
 					}
715 734
 
716 735
 					schedule.Status = 0
736
+					//针对凤凰医院
737
+					if adminInfo.CurrentOrgId == 10579 || adminInfo.CurrentOrgId == 10344 || adminInfo.CurrentOrgId == 10206 {
738
+						advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
739
+						if len(advice) > 0 {
740
+							service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
741
+						}
742
+					}
743
+
744
+					if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
745
+						hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
746
+						project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
+						if len(hisAdvice) > 0 {
748
+							service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
749
+						}
750
+						if len(project) > 0 {
751
+							service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
752
+						}
753
+					}
717 754
 					service.SaveSch(&schedule)
718 755
 				}
719 756
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
@@ -1985,6 +2022,144 @@ func (c *ScheduleApiController) DeleteSchedule() {
1985 2022
 
1986 2023
 	schedule.Status = 0
1987 2024
 	schedule.UpdatedTime = time.Now().Unix()
2025
+
2026
+	//如果使用的是保存出库功能
2027
+	drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
2028
+	//退库
2029
+	if drugOutConfig.IsOpen == 1 {
2030
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2031
+		for _, item := range hisAdvice {
2032
+			creater := adminINfo.AdminUser.Id
2033
+			err = service.DrugAutoAddCancelInfo(item, creater)
2034
+			if err != nil {
2035
+				err = fmt.Errorf("!:%v", err)
2036
+				return
2037
+			}
2038
+		}
2039
+		//查询是否有出库记录
2040
+		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2041
+	}
2042
+
2043
+	//查询该患者当天是否开耗材
2044
+	list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2045
+	if len(list) > 0 {
2046
+
2047
+		operation_time := time.Now().Unix()
2048
+		creater := c.GetAdminUserInfo().AdminUser.Id
2049
+		//创建退库单
2050
+		timeStr := time.Now().Format("2006-01-02")
2051
+		timeArr := strings.Split(timeStr, "-")
2052
+		total, _ := service.FindAllCancelStockTotal(c.GetAdminUserInfo().CurrentOrgId)
2053
+		total = total + 1
2054
+		orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2055
+		houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2056
+		cancelStock := models.CancelStock{
2057
+			OrderNumber:  orderNumber,
2058
+			OperaTime:    operation_time,
2059
+			OrgId:        c.GetAdminUserInfo().CurrentOrgId,
2060
+			Creater:      creater,
2061
+			Ctime:        time.Now().Unix(),
2062
+			Status:       1,
2063
+			ReturnTime:   schedule.ScheduleDate,
2064
+			Type:         1,
2065
+			StorehouseId: houseConfig.StorehouseOutInfo,
2066
+			IsCheck:      1,
2067
+		}
2068
+		_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, c.GetAdminUserInfo().CurrentOrgId)
2069
+		if msgerrkonde == gorm.ErrRecordNotFound {
2070
+			service.AddSigleCancelStock(&cancelStock)
2071
+		}
2072
+		cancel, _ := service.GetLastCancelStockById(c.GetAdminUserInfo().CurrentOrgId)
2073
+		//进行退库操作
2074
+		for _, item := range list {
2075
+			good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
2076
+			manufacturer, _ := service.GetManufactureById(item.Manufacturer)
2077
+			deaerler, _ := service.GetDealerById(item.Dealer)
2078
+			//回退库存
2079
+			service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
2080
+			goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId)
2081
+			var flush_count int64
2082
+			for _, it := range goodList {
2083
+				flush_count += it.StockCount
2084
+			}
2085
+			cancelStockInfo := models.CancelStockInfo{
2086
+				GoodId:          item.GoodId,
2087
+				CancelStockId:   cancel.ID,
2088
+				GoodTypeId:      good.GoodTypeId,
2089
+				Count:           item.Count,
2090
+				Price:           item.Price,
2091
+				Total:           0,
2092
+				ProductDate:     item.ProductDate,
2093
+				ExpiryDate:      item.ExpiryDate,
2094
+				Ctime:           time.Now().Unix(),
2095
+				Status:          1,
2096
+				OrgId:           c.GetAdminUserInfo().CurrentOrgId,
2097
+				OrderNumber:     cancel.OrderNumber,
2098
+				Type:            0,
2099
+				Dealer:          deaerler.DealerName,
2100
+				Manufacturer:    manufacturer.ManufacturerName,
2101
+				Number:          item.Number,
2102
+				RegisterAccount: "",
2103
+				Remark:          "",
2104
+				WarehouseInfoId: item.WarehouseInfotId,
2105
+				PatientId:       item.PatientId,
2106
+				RecordDate:      item.SysRecordTime,
2107
+				StorehouseId:    houseConfig.StorehouseOutInfo,
2108
+				IsCheck:         1,
2109
+			}
2110
+
2111
+			service.CreateCancelStockInfoOne(&cancelStockInfo)
2112
+
2113
+			cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2114
+
2115
+			flow := models.VmStockFlow{
2116
+				WarehousingId:           item.WarehouseInfotId,
2117
+				GoodId:                  item.GoodId,
2118
+				Number:                  item.Number,
2119
+				LicenseNumber:           item.LicenseNumber,
2120
+				Count:                   item.Count,
2121
+				UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
2122
+				PatientId:               item.PatientId,
2123
+				SystemTime:              item.SysRecordTime,
2124
+				ConsumableType:          7,
2125
+				IsSys:                   0,
2126
+				WarehousingOrder:        "",
2127
+				WarehouseOutId:          item.WarehouseOutId,
2128
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
2129
+				IsEdit:                  0,
2130
+				CancelStockId:           cancel.ID,
2131
+				CancelOrderNumber:       cancel.OrderNumber,
2132
+				Manufacturer:            manufacturer.ID,
2133
+				Dealer:                  0,
2134
+				Creator:                 c.GetAdminUserInfo().CurrentOrgId,
2135
+				UpdateCreator:           0,
2136
+				Status:                  1,
2137
+				Ctime:                   time.Now().Unix(),
2138
+				Mtime:                   0,
2139
+				Price:                   item.Price,
2140
+				WarehousingDetailId:     item.WarehouseInfotId,
2141
+				WarehouseOutDetailId:    item.ID,
2142
+				CancelOutDetailId:       cancelInfo.ID,
2143
+				ProductDate:             item.ProductDate,
2144
+				ExpireDate:              item.ExpiryDate,
2145
+				StorehouseId:            houseConfig.StorehouseOutInfo,
2146
+				OverCount:               flush_count,
2147
+			}
2148
+			service.CreateStockFlowOne(flow)
2149
+
2150
+			//退库数量增加
2151
+			service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
2152
+			//出库数量减少
2153
+			service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
2154
+
2155
+			//更新库存
2156
+			service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
2157
+
2158
+			//更新基础库库存
2159
+			service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
2160
+		}
2161
+	}
2162
+
1988 2163
 	err = service.UpdateSchedule(schedule)
1989 2164
 
1990 2165
 	//记录日志

+ 46 - 56
controllers/self_drug_api_congtroller.go View File

@@ -3858,10 +3858,25 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3858 3858
 
3859 3859
 			//期间减少
3860 3860
 			banceOutList, _ := service.GetInitOutBanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3861
+
3861 3862
 			for _, it := range banceOutList {
3862 3863
 				item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
3863 3864
 			}
3864 3865
 
3866
+			//期间盘盈
3867
+			infoFlow, _ := service.GetInitInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3868
+
3869
+			for _, it := range infoFlow {
3870
+				item.WareStartInStockFlow = append(item.WareStartInStockFlow, it)
3871
+			}
3872
+
3873
+			//期间盘亏
3874
+			outInfoFlow, _ := service.GetInitOutInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3875
+
3876
+			for _, it := range outInfoFlow {
3877
+				item.WareStartOutStockFlow = append(item.WareStartOutStockFlow, it)
3878
+			}
3879
+
3865 3880
 		}
3866 3881
 
3867 3882
 		if err != nil {
@@ -3940,41 +3955,6 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3940 3955
 		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
3941 3956
 
3942 3957
 		item.DrugEndFlow = endFlow
3943
-		//获取期初结余入库数量
3944
-		//startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)
3945
-		//for _, it := range startDrugInfo {
3946
-		//  item.DrugWarehouseInfoStart = append(item.DrugWarehouseInfoStart, it)
3947
-		//}
3948
-		//
3949
-		////获取期初结余出库数量
3950
-		//flowOutList, _ := service.GetDrugFlowOut(item.ID, orgId, startTime)
3951
-		//for _, it := range flowOutList {
3952
-		//  item.DrugWarehouseOutInfoStart = append(item.DrugWarehouseOutInfoStart, it)
3953
-		//}
3954
-		//
3955
-		////获取期初结余退库数量
3956
-		//cancelInfo, _ := service.GetStartDrugFlowCancelInfo(item.ID, orgId, startTime)
3957
-		//for _, it := range cancelInfo {
3958
-		//  item.WareStartStockCancelInfo = append(item.WareStartStockCancelInfo, it)
3959
-		//}
3960
-		//
3961
-		////获取期末结余入库数量
3962
-		//drugwarehouseinfoend, _ := service.DrugWarehouseInfoEnd(item.ID, orgId, endTime)
3963
-		//for _, it := range drugwarehouseinfoend {
3964
-		//  item.DrugWarehouseInfoEnd = append(item.DrugWarehouseInfoEnd, it)
3965
-		//}
3966
-
3967
-		////获取期末出库结余
3968
-		//endDrugInfo, _ := service.DrugWarehouseOutInfoEnd(item.ID, orgId, endTime)
3969
-		//for _, it := range endDrugInfo {
3970
-		//  item.DrugWarehouseOutInfoEnd = append(item.DrugWarehouseOutInfoEnd, it)
3971
-		//}
3972
-		//
3973
-		////获取期末退库数量
3974
-		//flowCancelInfo, _ := service.GetEndDrugFlowCancelInfo(item.ID, orgId, endTime)
3975
-		//for _, it := range flowCancelInfo {
3976
-		//  item.WareEndStockCancelInfo = append(item.WareEndStockCancelInfo, it)
3977
-		//}
3978 3958
 
3979 3959
 		//期中增加
3980 3960
 		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
@@ -3995,27 +3975,6 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3995 3975
 			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
3996 3976
 		}
3997 3977
 
3998
-		////获取期初盘盈
3999
-		//startProfit, _ := service.GetDrugFlowStartProfit(item.ID, orgId, startTime)
4000
-		//for _, it := range startProfit {
4001
-		//  item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
4002
-		//}
4003
-		////获取期初盘亏
4004
-		//startLosses, _ := service.GetDrugFlowStartLosses(item.ID, orgId, startTime)
4005
-		//for _, it := range startLosses {
4006
-		//  item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
4007
-		//}
4008
-		////获取期末盘盈
4009
-		//endProfit, _ := service.GetDrugFlowEndProfit(item.ID, orgId, endTime)
4010
-		//for _, it := range endProfit {
4011
-		//  item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
4012
-		//}
4013
-		////获取期末盘亏
4014
-		//losses, _ := service.GetDrugFlowEndLosses(item.ID, orgId, endTime)
4015
-		//for _, it := range losses {
4016
-		//  item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
4017
-		//}
4018
-
4019 3978
 		//获取期中盘盈
4020 3979
 		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
4021 3980
 		for _, it := range profit {
@@ -4027,6 +3986,37 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
4027 3986
 		for _, it := range endLosses {
4028 3987
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
4029 3988
 		}
3989
+
3990
+		//获取入库
3991
+		infoFLow, _ := service.GetNewDrugFlowInWarehouseInfo(item.ID, orgId, startTime)
3992
+
3993
+		for _, it := range infoFLow {
3994
+			item.NewDrugFlowInWarehouseInfo = append(item.NewDrugFlowInWarehouseInfo, it)
3995
+		}
3996
+		//获取盘盈
3997
+		infoProfitFlow, _ := service.GetNewDrugFlowPofitWarehouseInfo(item.ID, orgId, startTime)
3998
+
3999
+		for _, it := range infoProfitFlow {
4000
+			item.NewDrugFlowPofitWarehouseInfo = append(item.NewDrugFlowPofitWarehouseInfo, it)
4001
+		}
4002
+		//获取出库
4003
+		infoOutFlow, _ := service.GetNewDrugFlowOutWarehouseInfo(item.ID, orgId, startTime)
4004
+		for _, it := range infoOutFlow {
4005
+			item.NewDrugFlowOutWarehouseInfo = append(item.NewDrugFlowOutWarehouseInfo, it)
4006
+		}
4007
+
4008
+		//获取退库
4009
+		infoCacelFlow, _ := service.GetNewDrugFlowCacelWarehouseInfo(item.ID, orgId, startTime)
4010
+		for _, it := range infoCacelFlow {
4011
+			item.NewDrugFlowNoCancelWarehouseInfo = append(item.NewDrugFlowNoCancelWarehouseInfo, it)
4012
+		}
4013
+
4014
+		//获取盘亏
4015
+		infoNoPofitFlow, _ := service.GetNewDrugFlowNoPofitWarehouseInfo(item.ID, orgId, startTime)
4016
+		for _, it := range infoNoPofitFlow {
4017
+			item.NewDrugFlowNoPofitWarehouseInfo = append(item.NewDrugFlowNoPofitWarehouseInfo, it)
4018
+		}
4019
+
4030 4020
 	}
4031 4021
 	if err != nil {
4032 4022
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")

+ 10 - 1
models/new_stock_models.go View File

@@ -288,7 +288,10 @@ type GoodInfoTwenty struct {
288 288
 	StartFlowWarehouseInfo []*VmStockFlowTwenty //本期增加
289 289
 
290 290
 	StWarehousingInfoTwo  []*StWarehousingInfoOne  `gorm:"json:"new_warehouse_info_start"` //期间增加
291
-	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`
291
+	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`   //减少
292
+	WareStartInStockFlow  []*VmStockFlowTwenty     `gorm:"json:"new_stock_in_flow"`        //盘盈
293
+	WareStartOutStockFlow []*VmStockFlowTwenty     `gorm:"json:"new_stock_out_flow"`       //盘亏
294
+
292 295
 	//期初结余
293 296
 	StartFlowInfo    []*VmStockFlowTwenty
294 297
 	StartOutFlowInfo []*VmStockFlowTwenty
@@ -433,6 +436,12 @@ type VmBaseDrugTwenty struct {
433 436
 
434 437
 	DrugStatFlow DrugFlowTwenty
435 438
 	DrugEndFlow  DrugFlowTwenty
439
+
440
+	NewDrugFlowInWarehouseInfo       []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_in_flow_info"`
441
+	NewDrugFlowOutWarehouseInfo      []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_out_flow_info"`
442
+	NewDrugFlowPofitWarehouseInfo    []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_profit_flow_info"`
443
+	NewDrugFlowNoPofitWarehouseInfo  []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_no_profit_flow_info"`
444
+	NewDrugFlowNoCancelWarehouseInfo []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_cancel_flow_info"`
436 445
 }
437 446
 
438 447
 func (VmBaseDrugTwenty) TableName() string {

+ 6 - 0
service/manage_center_service.go View File

@@ -1070,3 +1070,9 @@ func DeletePatientDiagnose(id int64) error {
1070 1070
 	err := XTWriteDB().Model(&models.XtPatientDiagnose{}).Where("id=? and status= 1", id).Updates(map[string]interface{}{"status": 0}).Error
1071 1071
 	return err
1072 1072
 }
1073
+
1074
+func GetPatientGoodStockCount(patient_id int64, record_time int64, user_org_id int64) (auto []*models.XtAutomaticReduceDetail, err error) {
1075
+
1076
+	err = XTReadDB().Where("patient_id = ? and record_time =? and user_org_id = ? and status=1", patient_id, record_time, user_org_id).Find(&auto).Error
1077
+	return auto, err
1078
+}

+ 6 - 0
service/patient_service.go View File

@@ -1371,6 +1371,9 @@ func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int6
1371 1371
 	if advice_type == 1 && advice_type > 0 {
1372 1372
 		db = db.Where("x.advice_type = ?", advice_type)
1373 1373
 	}
1374
+	if advice_type == 2 && advice_type > 0 {
1375
+		db = db.Where("x.advice_type = ?", advice_type)
1376
+	}
1374 1377
 	if advice_type == 3 && advice_type > 0 {
1375 1378
 		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
1376 1379
 	}
@@ -2118,6 +2121,9 @@ func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end in
2118 2121
 	if advice_type == 1 && advice_type > 0 {
2119 2122
 		db = db.Where("x.advice_type = ?", advice_type)
2120 2123
 	}
2124
+	if advice_type == 2 && advice_type > 0 {
2125
+		db = db.Where("x.advice_type = ?", advice_type)
2126
+	}
2121 2127
 	if advice_type == 3 && advice_type > 0 {
2122 2128
 		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
2123 2129
 	}

+ 21 - 3
service/schedule_service.go View File

@@ -1798,6 +1798,12 @@ func GetHisDoctorAdviceListTwenty(patient_id int64, schedule_date int64, user_or
1798 1798
 	return advice, err
1799 1799
 }
1800 1800
 
1801
+func GetHisDoctorAdviceListTwentyOne(patient_id int64, schedule_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
1802
+
1803
+	err = XTReadDB().Where("patient_id = ? and advice_date = ? and user_org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&advice).Error
1804
+	return advice, err
1805
+}
1806
+
1801 1807
 func GetHisPrescriptionProjectList(patient_id int64, record_date int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
1802 1808
 	err = XTReadDB().Where("patient_id = ? and record_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Find(&project).Error
1803 1809
 	return project, err
@@ -1832,6 +1838,13 @@ func GetLastSchedule(patient_id int64, user_org_id int64) (models.XtSchedule, er
1832 1838
 	return schedule, err
1833 1839
 }
1834 1840
 
1841
+func GetPatientScheduleToday(patient_id int64, schedule_date int64, user_org_id int64) (models.XtSchedule, error) {
1842
+
1843
+	schedule := models.XtSchedule{}
1844
+	err = XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status=0", patient_id, schedule_date, user_org_id).Find(&schedule).Error
1845
+	return schedule, err
1846
+}
1847
+
1835 1848
 func UpdateRepeatSchStatus(user_org_id int64, schedule_date int64) {
1836 1849
 	var schedules []models.XtSchedule
1837 1850
 	// Find duplicate records based on patient_id, schedule_date, and user_org_id
@@ -1843,9 +1856,8 @@ func UpdateRepeatSchStatus(user_org_id int64, schedule_date int64) {
1843 1856
 
1844 1857
 	for _, schedule := range schedules {
1845 1858
 		// Update records with status = 0 where id is less than max_id
1846
-		XTReadDB().Model(&models.XtSchedule{}).
1847
-			Where("patient_id = ? AND schedule_date = ? AND id < ?", schedule.PatientId, schedule.ScheduleDate, schedule.MaxId).
1848
-			Update("status", 0)
1859
+		XTReadDB().Model(&models.XtSchedule{}).Where("patient_id = ? AND schedule_date = ? AND id < ?", schedule.PatientId, schedule.ScheduleDate, schedule.MaxId).Update("status", 0)
1860
+
1849 1861
 	}
1850 1862
 
1851 1863
 }
@@ -1865,3 +1877,9 @@ func UpdateMobileSchedule(id_two int64, mode_id int64, bed_id int64, zone_id int
1865 1877
 
1866 1878
 	return err
1867 1879
 }
1880
+
1881
+func GetPatientGoodCountToday(patient_id int64, schedule_date int64, user_org_id int64) (list []*models.WarehouseOutInfo, err error) {
1882
+
1883
+	err = XTReadDB().Where("patient_id =? and record_time=? and use_org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&list).Error
1884
+	return list, err
1885
+}

+ 136 - 3
service/self_drug_service.go View File

@@ -3015,7 +3015,7 @@ func GetPurchaseStockQueryList(good_type int64, keyword string, page int64, limi
3015 3015
 
3016 3016
 func GetInitBalanceList(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.StWarehousingInfoOne, err error) {
3017 3017
 
3018
-	db := XTReadDB().Model(&list).Where("status=1")
3018
+	db := XTReadDB().Model(&list).Where("status=1 and is_check=1")
3019 3019
 
3020 3020
 	if good_id > 0 {
3021 3021
 		db = db.Where("good_id = ?", good_id)
@@ -3025,7 +3025,7 @@ func GetInitBalanceList(good_id int64, user_org_id int64, start_time int64, end_
3025 3025
 	}
3026 3026
 
3027 3027
 	if start_time > 0 {
3028
-		db = db.Where("ctime<=?", start_time)
3028
+		db = db.Where("ctime<?", start_time)
3029 3029
 	}
3030 3030
 
3031 3031
 	if storehouse_id > 0 {
@@ -3050,7 +3050,7 @@ func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end
3050 3050
 	}
3051 3051
 
3052 3052
 	if start_time > 0 {
3053
-		db = db.Where("ctime<=?", start_time)
3053
+		db = db.Where("ctime<?", start_time)
3054 3054
 	}
3055 3055
 
3056 3056
 	if storehouse_id > 0 {
@@ -3061,3 +3061,136 @@ func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end
3061 3061
 
3062 3062
 	return list, err
3063 3063
 }
3064
+
3065
+func GetInitInfoFlow(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.VmStockFlowTwenty, err error) {
3066
+
3067
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type =10")
3068
+
3069
+	if good_id > 0 {
3070
+		db = db.Where("good_id = ?", good_id)
3071
+	}
3072
+	if user_org_id > 0 {
3073
+		db = db.Where("user_org_id = ?", user_org_id)
3074
+	}
3075
+
3076
+	if start_time > 0 {
3077
+		db = db.Where("ctime<?", start_time)
3078
+	}
3079
+
3080
+	if storehouse_id > 0 {
3081
+		db = db.Where("storehouse_id = ?", storehouse_id)
3082
+	}
3083
+
3084
+	err = db.Find(&list).Error
3085
+
3086
+	return list, err
3087
+}
3088
+
3089
+func GetInitOutInfoFlow(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.VmStockFlowTwenty, err error) {
3090
+
3091
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type =11")
3092
+
3093
+	if good_id > 0 {
3094
+		db = db.Where("good_id = ?", good_id)
3095
+	}
3096
+	if user_org_id > 0 {
3097
+		db = db.Where("user_org_id = ?", user_org_id)
3098
+	}
3099
+
3100
+	if start_time > 0 {
3101
+		db = db.Where("ctime<?", start_time)
3102
+	}
3103
+
3104
+	if storehouse_id > 0 {
3105
+		db = db.Where("storehouse_id = ?", storehouse_id)
3106
+	}
3107
+
3108
+	err = db.Find(&list).Error
3109
+
3110
+	return list, err
3111
+}
3112
+
3113
+func GetNewDrugFlowInWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3114
+
3115
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=1")
3116
+
3117
+	if drug_id > 0 {
3118
+		db = db.Where("drug_id = ?", drug_id)
3119
+	}
3120
+	if user_org_id > 0 {
3121
+		db = db.Where("user_org_id = ?", user_org_id)
3122
+	}
3123
+	if start_time > 0 {
3124
+		db = db.Where("ctime<?", start_time)
3125
+	}
3126
+	err = db.Find(&list).Error
3127
+	return list, err
3128
+}
3129
+
3130
+func GetNewDrugFlowPofitWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3131
+
3132
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=10")
3133
+
3134
+	if drug_id > 0 {
3135
+		db = db.Where("drug_id = ?", drug_id)
3136
+	}
3137
+	if user_org_id > 0 {
3138
+		db = db.Where("user_org_id = ?", user_org_id)
3139
+	}
3140
+	if start_time > 0 {
3141
+		db = db.Where("ctime<?", start_time)
3142
+	}
3143
+	err = db.Find(&list).Error
3144
+	return list, err
3145
+}
3146
+
3147
+func GetNewDrugFlowOutWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3148
+
3149
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=3")
3150
+
3151
+	if drug_id > 0 {
3152
+		db = db.Where("drug_id = ?", drug_id)
3153
+	}
3154
+	if user_org_id > 0 {
3155
+		db = db.Where("user_org_id = ?", user_org_id)
3156
+	}
3157
+	if start_time > 0 {
3158
+		db = db.Where("ctime<?", start_time)
3159
+	}
3160
+	err = db.Find(&list).Error
3161
+	return list, err
3162
+}
3163
+
3164
+func GetNewDrugFlowCacelWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3165
+
3166
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=7")
3167
+
3168
+	if drug_id > 0 {
3169
+		db = db.Where("drug_id = ?", drug_id)
3170
+	}
3171
+	if user_org_id > 0 {
3172
+		db = db.Where("user_org_id = ?", user_org_id)
3173
+	}
3174
+	if start_time > 0 {
3175
+		db = db.Where("ctime<?", start_time)
3176
+	}
3177
+	err = db.Find(&list).Error
3178
+	return list, err
3179
+}
3180
+
3181
+func GetNewDrugFlowNoPofitWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3182
+
3183
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=11")
3184
+
3185
+	if drug_id > 0 {
3186
+		db = db.Where("drug_id = ?", drug_id)
3187
+	}
3188
+	if user_org_id > 0 {
3189
+		db = db.Where("user_org_id = ?", user_org_id)
3190
+	}
3191
+	if start_time > 0 {
3192
+		db = db.Where("ctime<?", start_time)
3193
+	}
3194
+	err = db.Find(&list).Error
3195
+	return list, err
3196
+}