28169 2 miesięcy temu
rodzic
commit
e1aba399ee

BIN
XT_New.exe Wyświetl plik


+ 6 - 6
controllers/base_api_controller.go Wyświetl plik

83
 		userAdmin.ModifyTime = 1530786071
83
 		userAdmin.ModifyTime = 1530786071
84
 		var subscibe models.ServeSubscibe
84
 		var subscibe models.ServeSubscibe
85
 		subscibe.ID = 11
85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10744 //机构id
86
+		subscibe.OrgId = 10721 //机构id
87
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodStart = 1547447814
88
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.PeriodEnd = 1550039814
89
 		subscibe.State = 1
89
 		subscibe.State = 1
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94
 		subscibes[4] = &subscibe
94
 		subscibes[4] = &subscibe
95
 		var adminUserInfo service.AdminUserInfo
95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10744 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 18470 //4
96
+		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 18723 //4
98
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.AdminUser = &userAdmin
99
 		adminUserInfo.Subscibes = subscibes
99
 		adminUserInfo.Subscibes = subscibes
100
 		this.SetSession("admin_user_info", &adminUserInfo)
100
 		this.SetSession("admin_user_info", &adminUserInfo)
329
 		userAdmin.ModifyTime = 1530786071
329
 		userAdmin.ModifyTime = 1530786071
330
 		var subscibe models.ServeSubscibe
330
 		var subscibe models.ServeSubscibe
331
 		subscibe.ID = 11
331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10744 //机构id小英9675或4
332
+		subscibe.OrgId = 10721 //机构id小英9675或4
333
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodStart = 1538035409
334
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.PeriodEnd = 1569571409
335
 		subscibe.State = 1
335
 		subscibe.State = 1
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
 		subscibes[4] = &subscibe
340
 		subscibes[4] = &subscibe
341
 		var adminUserInfo service.AdminUserInfo
341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10744 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 18470 //4
342
+		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 18723 //4
344
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.AdminUser = &userAdmin
345
 		adminUserInfo.Subscibes = subscibes
345
 		adminUserInfo.Subscibes = subscibes
346
 		this.SetSession("admin_user_info", &adminUserInfo)
346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 10 - 14
controllers/common_api_controller.go Wyświetl plik

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+
4
 	"XT_New/enums"
9
 	"XT_New/enums"
5
 	"XT_New/models"
10
 	"XT_New/models"
6
 	"XT_New/service"
11
 	"XT_New/service"
7
 	"XT_New/utils"
12
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10
 	"github.com/jinzhu/gorm"
13
 	"github.com/jinzhu/gorm"
11
-	"strconv"
12
-	"time"
13
 )
14
 )
14
 
15
 
15
 type CommonApiController struct {
16
 type CommonApiController struct {
583
 func (this *CommonApiController) GetTotalSexCount() {
584
 func (this *CommonApiController) GetTotalSexCount() {
584
 	adminUser := this.GetAdminUserInfo()
585
 	adminUser := this.GetAdminUserInfo()
585
 	orgid := adminUser.CurrentOrgId
586
 	orgid := adminUser.CurrentOrgId
586
-	fmt.Println("orgid", orgid)
587
-	startime, _ := this.GetInt64("startime")
588
-	fmt.Println("开始时间", startime)
589
-	endtime, _ := this.GetInt64("endtime")
590
-	fmt.Println("结束时间", endtime)
587
+	//startime, _ := this.GetInt64("startime")
588
+	//
589
+	//endtime, _ := this.GetInt64("endtime")
590
+
591
 	lapsetotype, _ := this.GetInt64("lapsetotype")
591
 	lapsetotype, _ := this.GetInt64("lapsetotype")
592
 	sourcetype, _ := this.GetInt64("sourcetype")
592
 	sourcetype, _ := this.GetInt64("sourcetype")
593
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
593
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
642
 func (this *CommonApiController) GetTotalAgeCount() {
642
 func (this *CommonApiController) GetTotalAgeCount() {
643
 	adminUser := this.GetAdminUserInfo()
643
 	adminUser := this.GetAdminUserInfo()
644
 	orgid := adminUser.CurrentOrgId
644
 	orgid := adminUser.CurrentOrgId
645
-	fmt.Println("orgid", orgid)
646
-	startime, _ := this.GetInt64("startime")
647
-	fmt.Println("开始时间", startime)
648
-	endtime, _ := this.GetInt64("endtime")
649
-	fmt.Println("结束时间", endtime)
650
 	lapsetotype, _ := this.GetInt64("lapsetotype")
645
 	lapsetotype, _ := this.GetInt64("lapsetotype")
651
 	sourcetype, _ := this.GetInt64("sourcetype")
646
 	sourcetype, _ := this.GetInt64("sourcetype")
652
 	//统计透析总人数
647
 	//统计透析总人数
1451
 	limit, _ := this.GetInt64("limit")
1446
 	limit, _ := this.GetInt64("limit")
1452
 
1447
 
1453
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1448
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1449
+
1454
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1450
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1455
 
1451
 
1456
 	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1452
 	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)

+ 5 - 5
controllers/dialysis_api_controller.go Wyświetl plik

2879
 			service.CreateDialysisFinish(finish)
2879
 			service.CreateDialysisFinish(finish)
2880
 		}
2880
 		}
2881
 
2881
 
2882
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
2882
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10480 || adminUserInfo.CurrentOrgId == 10293 || adminUserInfo.CurrentOrgId == 9478 {
2883
 			var dewater_amount float64
2883
 			var dewater_amount float64
2884
 			dewater_amount = 0
2884
 			dewater_amount = 0
2885
 			if dry_weight > 0 {
2885
 			if dry_weight > 0 {
2886
 				dewater_amount = weight_before - dry_weight - additional_weight
2886
 				dewater_amount = weight_before - dry_weight - additional_weight
2887
 
2887
 
2888
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 {
2888
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 && adminUserInfo.CurrentOrgId != 10480 && adminUserInfo.CurrentOrgId != 10293 && adminUserInfo.CurrentOrgId != 9478 {
2889
 					dewater_amount = dewater_amount * 1000
2889
 					dewater_amount = dewater_amount * 1000
2890
 				}
2890
 				}
2891
 
2891
 
3248
 		dewater_amount = 0
3248
 		dewater_amount = 0
3249
 		if evaluation.DryWeight > 0 {
3249
 		if evaluation.DryWeight > 0 {
3250
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3250
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3251
-			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 {
3252
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3251
+			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 || adminUserInfo.CurrentOrgId == 9478 {
3252
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 && adminUserInfo.CurrentOrgId != 9478 {
3253
 					dewater_amount = dewater_amount * 1000
3253
 					dewater_amount = dewater_amount * 1000
3254
 				}
3254
 				}
3255
 
3255
 
3526
 		}
3526
 		}
3527
 
3527
 
3528
 		//针对孝昌康桥超滤率计算问题
3528
 		//针对孝昌康桥超滤率计算问题
3529
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10697 {
3529
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10697 || adminUserInfo.CurrentOrgId == 9478 {
3530
 			if assessmentBeforeDislysis.ID == 0 {
3530
 			if assessmentBeforeDislysis.ID == 0 {
3531
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3531
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3532
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3532
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {

+ 12 - 1
controllers/gobal_config_api_controller.go Wyświetl plik

1150
 	idsInters := dataBody["ids"].([]interface{})
1150
 	idsInters := dataBody["ids"].([]interface{})
1151
 	advice_type, _ := c.GetInt64("advice_type")
1151
 	advice_type, _ := c.GetInt64("advice_type")
1152
 	stop_type, _ := c.GetInt64("stop_type")
1152
 	stop_type, _ := c.GetInt64("stop_type")
1153
+	his_str := c.GetString("his_str")
1154
+	if len(his_str) == 0 {
1155
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1156
+		return
1157
+	}
1158
+
1159
+	idStrs := strings.Split(his_str, ",")
1153
 	if len(idsInters) == 0 {
1160
 	if len(idsInters) == 0 {
1154
 		if err != nil {
1161
 		if err != nil {
1155
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
1162
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
1161
 		id := int64(idsInter.(float64))
1168
 		id := int64(idsInter.(float64))
1162
 		ids = append(ids, id)
1169
 		ids = append(ids, id)
1163
 	}
1170
 	}
1171
+
1164
 	getPrint, err := service.GetPrint(ids, OrgID, advice_type, stop_type)
1172
 	getPrint, err := service.GetPrint(ids, OrgID, advice_type, stop_type)
1173
+
1174
+	hisPrint, _ := service.GetHisPrint(idStrs, OrgID)
1165
 	c.ServeSuccessJSON(map[string]interface{}{
1175
 	c.ServeSuccessJSON(map[string]interface{}{
1166
-		"doctoradvice": getPrint,
1176
+		"doctoradvice":    getPrint,
1177
+		"hisdoctoradvice": hisPrint,
1167
 	})
1178
 	})
1168
 }
1179
 }
1169
 
1180
 

+ 1 - 3
controllers/his_api_controller.go Wyświetl plik

3494
 	var adviceList []models.HisDoctorAdviceInfo
3494
 	var adviceList []models.HisDoctorAdviceInfo
3495
 	var projectList []models.HisPrescriptionProject
3495
 	var projectList []models.HisPrescriptionProject
3496
 
3496
 
3497
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 {
3497
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 || adminInfo.CurrentOrgId == 9478 {
3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3500
 
3500
 
3857
 
3857
 
3858
 											}
3858
 											}
3859
 
3859
 
3860
-											fmt.Println("s.ID==========================", s.ID)
3861
-
3862
 											if s.ID > 0 {
3860
 											if s.ID > 0 {
3863
 												//查询改药品是否已经停用
3861
 												//查询改药品是否已经停用
3864
 												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
3862
 												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)

+ 232 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go Wyświetl plik

3536
 
3536
 
3537
 	}
3537
 	}
3538
 
3538
 
3539
+	//查找是否开启配置
3540
+	//orderSetting, _ := service.GetDialysisOrderSetting(adminUserInfo.Org.Id)
3541
+	////开启下机扣减
3542
+	//if orderSetting.IsOpen == 1 {
3543
+	//
3544
+	//	//查询今日患者排班的模式
3545
+	//	db := service.XTWriteDB()
3546
+	//	// 开始外部循环的事务
3547
+	//	tx := db.Begin()
3548
+	//	// 在函数结束时处理事务回滚
3549
+	//	defer func() {
3550
+	//		if r := recover(); r != nil {
3551
+	//			tx.Rollback()
3552
+	//		}
3553
+	//	}()
3554
+	//
3555
+	//	schedule, _ := service.GetDialysisOrderSchedule(id, recordDate.Unix(), adminUserInfo.Org.Id, tx)
3556
+	//
3557
+	//	if schedule.ModeId == 1 {
3558
+	//		//扣减库存
3559
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3560
+	//
3561
+	//		patient, _ := service.GetSfPatientById(tx, id)
3562
+	//		var over_count int64
3563
+	//		if schedule.ModeId == 1 {
3564
+	//			over_count = patient.HdCount
3565
+	//		}
3566
+	//		if schedule.ModeId == 2 {
3567
+	//			over_count = patient.HdfCount
3568
+	//		}
3569
+	//
3570
+	//		if schedule.ModeId == 3 {
3571
+	//			over_count = patient.HdhpCount
3572
+	//		}
3573
+	//		if schedule.ModeId == 4 {
3574
+	//			over_count = patient.HpCount
3575
+	//		}
3576
+	//		if schedule.ModeId == 5 {
3577
+	//			over_count = patient.OtherCount
3578
+	//		}
3579
+	//		patientCountFlow := models.SfPatientCountFlow{
3580
+	//			PatientId:      id,
3581
+	//			ModeId:         schedule.ModeId,
3582
+	//			Count:          1,
3583
+	//			Status:         1,
3584
+	//			Ctime:          time.Now().Unix(),
3585
+	//			Mtime:          time.Now().Unix(),
3586
+	//			RecordDate:     recordDate.Unix(),
3587
+	//			UserOrgId:      adminUserInfo.Org.Id,
3588
+	//			Creater:        adminUserInfo.AdminUser.Id,
3589
+	//			IsType:         1,
3590
+	//			OverCount:      over_count,
3591
+	//			WarehouseOutId: 0,
3592
+	//		}
3593
+	//
3594
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3595
+	//	}
3596
+	//
3597
+	//	if schedule.ModeId == 2 {
3598
+	//
3599
+	//		//扣减库存
3600
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3601
+	//
3602
+	//		patient, _ := service.GetSfPatientById(tx, id)
3603
+	//		var over_count int64
3604
+	//		if schedule.ModeId == 1 {
3605
+	//			over_count = patient.HdCount
3606
+	//		}
3607
+	//		if schedule.ModeId == 2 {
3608
+	//			over_count = patient.HdfCount
3609
+	//		}
3610
+	//
3611
+	//		if schedule.ModeId == 3 {
3612
+	//			over_count = patient.HdhpCount
3613
+	//		}
3614
+	//		if schedule.ModeId == 4 {
3615
+	//			over_count = patient.HpCount
3616
+	//		}
3617
+	//		if schedule.ModeId == 5 {
3618
+	//			over_count = patient.OtherCount
3619
+	//		}
3620
+	//		patientCountFlow := models.SfPatientCountFlow{
3621
+	//			PatientId:      id,
3622
+	//			ModeId:         schedule.ModeId,
3623
+	//			Count:          1,
3624
+	//			Status:         1,
3625
+	//			Ctime:          time.Now().Unix(),
3626
+	//			Mtime:          time.Now().Unix(),
3627
+	//			RecordDate:     recordDate.Unix(),
3628
+	//			UserOrgId:      adminUserInfo.Org.Id,
3629
+	//			Creater:        adminUserInfo.AdminUser.Id,
3630
+	//			IsType:         2,
3631
+	//			OverCount:      over_count,
3632
+	//			WarehouseOutId: 0,
3633
+	//		}
3634
+	//
3635
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3636
+	//	}
3637
+	//
3638
+	//	if schedule.ModeId == 3 {
3639
+	//
3640
+	//		//扣减库存
3641
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3642
+	//
3643
+	//		patient, _ := service.GetSfPatientById(tx, id)
3644
+	//		var over_count int64
3645
+	//		if schedule.ModeId == 1 {
3646
+	//			over_count = patient.HdCount
3647
+	//		}
3648
+	//		if schedule.ModeId == 2 {
3649
+	//			over_count = patient.HdfCount
3650
+	//		}
3651
+	//
3652
+	//		if schedule.ModeId == 3 {
3653
+	//			over_count = patient.HdhpCount
3654
+	//		}
3655
+	//		if schedule.ModeId == 4 {
3656
+	//			over_count = patient.HpCount
3657
+	//		}
3658
+	//		if schedule.ModeId == 5 {
3659
+	//			over_count = patient.OtherCount
3660
+	//		}
3661
+	//		patientCountFlow := models.SfPatientCountFlow{
3662
+	//			PatientId:      id,
3663
+	//			ModeId:         schedule.ModeId,
3664
+	//			Count:          1,
3665
+	//			Status:         1,
3666
+	//			Ctime:          time.Now().Unix(),
3667
+	//			Mtime:          time.Now().Unix(),
3668
+	//			RecordDate:     recordDate.Unix(),
3669
+	//			UserOrgId:      adminUserInfo.Org.Id,
3670
+	//			Creater:        adminUserInfo.AdminUser.Id,
3671
+	//			IsType:         3,
3672
+	//			OverCount:      over_count,
3673
+	//			WarehouseOutId: 0,
3674
+	//		}
3675
+	//
3676
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3677
+	//	}
3678
+	//	if schedule.ModeId == 4 {
3679
+	//
3680
+	//		//扣减库存
3681
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3682
+	//
3683
+	//		patient, _ := service.GetSfPatientById(tx, id)
3684
+	//		var over_count int64
3685
+	//		if schedule.ModeId == 1 {
3686
+	//			over_count = patient.HdCount
3687
+	//		}
3688
+	//		if schedule.ModeId == 2 {
3689
+	//			over_count = patient.HdfCount
3690
+	//		}
3691
+	//
3692
+	//		if schedule.ModeId == 3 {
3693
+	//			over_count = patient.HdhpCount
3694
+	//		}
3695
+	//		if schedule.ModeId == 4 {
3696
+	//			over_count = patient.HpCount
3697
+	//		}
3698
+	//		if schedule.ModeId == 5 {
3699
+	//			over_count = patient.OtherCount
3700
+	//		}
3701
+	//		patientCountFlow := models.SfPatientCountFlow{
3702
+	//			PatientId:      id,
3703
+	//			ModeId:         schedule.ModeId,
3704
+	//			Count:          1,
3705
+	//			Status:         1,
3706
+	//			Ctime:          time.Now().Unix(),
3707
+	//			Mtime:          time.Now().Unix(),
3708
+	//			RecordDate:     recordDate.Unix(),
3709
+	//			UserOrgId:      adminUserInfo.Org.Id,
3710
+	//			Creater:        adminUserInfo.AdminUser.Id,
3711
+	//			IsType:         4,
3712
+	//			OverCount:      over_count,
3713
+	//			WarehouseOutId: 0,
3714
+	//		}
3715
+	//
3716
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3717
+	//	}
3718
+	//	if schedule.ModeId != 1 && schedule.ModeId != 2 && schedule.ModeId != 3 && schedule.ModeId != 4 {
3719
+	//
3720
+	//		//扣减库存
3721
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3722
+	//
3723
+	//		patient, _ := service.GetSfPatientById(tx, id)
3724
+	//		var over_count int64
3725
+	//		if schedule.ModeId == 1 {
3726
+	//			over_count = patient.HdCount
3727
+	//		}
3728
+	//		if schedule.ModeId == 2 {
3729
+	//			over_count = patient.HdfCount
3730
+	//		}
3731
+	//
3732
+	//		if schedule.ModeId == 3 {
3733
+	//			over_count = patient.HdhpCount
3734
+	//		}
3735
+	//		if schedule.ModeId == 4 {
3736
+	//			over_count = patient.HpCount
3737
+	//		}
3738
+	//		if schedule.ModeId == 5 {
3739
+	//			over_count = patient.OtherCount
3740
+	//		}
3741
+	//		patientCountFlow := models.SfPatientCountFlow{
3742
+	//			PatientId:      id,
3743
+	//			ModeId:         schedule.ModeId,
3744
+	//			Count:          1,
3745
+	//			Status:         1,
3746
+	//			Ctime:          time.Now().Unix(),
3747
+	//			Mtime:          time.Now().Unix(),
3748
+	//			RecordDate:     recordDate.Unix(),
3749
+	//			UserOrgId:      adminUserInfo.Org.Id,
3750
+	//			Creater:        adminUserInfo.AdminUser.Id,
3751
+	//			IsType:         5,
3752
+	//			OverCount:      over_count,
3753
+	//			WarehouseOutId: 0,
3754
+	//		}
3755
+	//
3756
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3757
+	//	}
3758
+	//
3759
+	//	tx.Commit()
3760
+	//	return
3761
+	//}
3762
+
3539
 }
3763
 }
3540
 
3764
 
3541
 func (c *DialysisAPIController) GetAllZone() {
3765
 func (c *DialysisAPIController) GetAllZone() {
3916
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
4140
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3917
 			}
4141
 			}
3918
 
4142
 
3919
-			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
4143
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 || adminUserInfo.Org.Id == 9478 {
3920
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
4144
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3921
 			}
4145
 			}
3922
 
4146
 
4091
 				}
4315
 				}
4092
 			}
4316
 			}
4093
 
4317
 
4094
-			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4318
+			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10744 {
4095
 				if prescription.ModeId == 2 {
4319
 				if prescription.ModeId == 2 {
4096
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4320
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4097
 					if totalMin == 0 {
4321
 					if totalMin == 0 {
5237
 			}
5461
 			}
5238
 
5462
 
5239
 			//重庆塘坝卫生院
5463
 			//重庆塘坝卫生院
5240
-			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5464
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5241
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5465
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5466
+				fmt.Println("ultrafiltration_rate--------------------", ultrafiltration_rate)
5242
 				record.UltrafiltrationRate = ultrafiltration_rate
5467
 				record.UltrafiltrationRate = ultrafiltration_rate
5243
 			}
5468
 			}
5244
 
5469
 
5428
 	}
5653
 	}
5429
 
5654
 
5430
 	//长沙南雅
5655
 	//长沙南雅
5431
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 {
5656
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 || adminInfo.Org.Id == 9478 {
5432
 
5657
 
5433
 		if ultrafiltration_rate > 0 {
5658
 		if ultrafiltration_rate > 0 {
5434
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5659
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5509
 		}
5734
 		}
5510
 	}
5735
 	}
5511
 
5736
 
5512
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 {
5737
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 || adminInfo.Org.Id == 9478 || adminInfo.Org.Id == 10290 {
5513
 		var replacement_rate float64
5738
 		var replacement_rate float64
5514
 		var displacement_quantity float64
5739
 		var displacement_quantity float64
5515
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5740
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5533
 
5758
 
5534
 	}
5759
 	}
5535
 
5760
 
5536
-	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 {
5761
+	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5537
 
5762
 
5538
 		var replacement_rate float64
5763
 		var replacement_rate float64
5539
 		var displacement_quantity float64
5764
 		var displacement_quantity float64
5552
 		record.UltrafiltrationVolume = ultrafiltration_volume
5777
 		record.UltrafiltrationVolume = ultrafiltration_volume
5553
 	}
5778
 	}
5554
 
5779
 
5555
-	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 {
5780
+	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 || adminInfo.Org.Id == 10744 {
5556
 
5781
 
5557
 		var replacement_rate float64
5782
 		var replacement_rate float64
5558
 		var displacement_quantity float64
5783
 		var displacement_quantity float64

+ 3 - 3
controllers/mobile_api_controllers/patient_api_controller.go Wyświetl plik

3878
 	if evaluation.DryWeight > 0 {
3878
 	if evaluation.DryWeight > 0 {
3879
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3879
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3880
 
3880
 
3881
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
3881
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 || adminUserInfo.Org.Id == 9478 {
3882
 
3882
 
3883
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3883
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 && adminUserInfo.Org.Id != 9478 {
3884
 				dewater_amount = dewater_amount * 1000
3884
 				dewater_amount = dewater_amount * 1000
3885
 			}
3885
 			}
3886
 
3886
 
4603
 	}
4603
 	}
4604
 
4604
 
4605
 	//针对孝昌康桥超滤率计算问题
4605
 	//针对孝昌康桥超滤率计算问题
4606
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
4606
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 || adminUserInfo.Org.Id == 9478 {
4607
 		if evaluation.ID == 0 {
4607
 		if evaluation.ID == 0 {
4608
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4608
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4609
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4609
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {

+ 19 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Wyświetl plik

407
 	timenow := time.Now().Format("2006-01-02")
407
 	timenow := time.Now().Format("2006-01-02")
408
 	timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timenow)
408
 	timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timenow)
409
 	//针对百霖和贝尔
409
 	//针对百霖和贝尔
410
-	if orgid == 10138 || orgid == 10278 || orgid == 3877 {
410
+	if orgid == 10138 || orgid == 10278 || orgid == 3877 || orgid == 10610 || orgid == 10537 {
411
 		//获取今日的排班数据
411
 		//获取今日的排班数据
412
 		list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
412
 		list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
413
 		for _, item := range list {
413
 		for _, item := range list {
1629
 		"order": order,
1629
 		"order": order,
1630
 	})
1630
 	})
1631
 }
1631
 }
1632
+
1633
+func (c *StaffScheduleApiController) GetPatientialysisSolutonByPatientId() {
1634
+
1635
+	patient_id, _ := c.GetInt64("patient_id")
1636
+
1637
+	record_date, _ := c.GetInt64("record_date")
1638
+
1639
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1640
+
1641
+	schedule, _ := service.GetPatientScheduleByPatient(patient_id, record_date, orgId)
1642
+
1643
+	dialysisSolution, _ := service.GetDialysisSolutonByScheduleModeId(schedule.ModeId, patient_id, orgId)
1644
+
1645
+	c.ServeSuccessJSON(map[string]interface{}{
1646
+		"dialysisSolution": dialysisSolution,
1647
+	})
1648
+
1649
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Wyświetl plik

42
 
42
 
43
 	beego.Router("/m/api/patient/getmobiledialysiscount", &StaffScheduleApiController{}, "Get:GetMobileDialysisCount")
43
 	beego.Router("/m/api/patient/getmobiledialysiscount", &StaffScheduleApiController{}, "Get:GetMobileDialysisCount")
44
 
44
 
45
+	beego.Router("/api/schedule/getpatientdialysissolutionbypatientid", &StaffScheduleApiController{}, "Get:GetPatientialysisSolutonByPatientId")
46
+
45
 }
47
 }

+ 639 - 30
controllers/patient_api_controller.go Wyświetl plik

233
 
233
 
234
 	beego.Router("/api/patient/checkpatientcount", &PatientApiController{}, "Get:CheckPatientCount")
234
 	beego.Router("/api/patient/checkpatientcount", &PatientApiController{}, "Get:CheckPatientCount")
235
 
235
 
236
-	beego.Router("/api/patient/returncheckpatientcount", &PatientApiController{}, "Get:ReturnCheckPatientCount")
236
+	beego.Router("/api/patient/returncheck", &PatientApiController{}, "Get:ReturnCheckPatientCount")
237
+
238
+	beego.Router("/api/patient/deletepatientcount", &PatientApiController{}, "Get:DeletePatientCount")
239
+
240
+	beego.Router("/api/patient/savepatientoutcount", &PatientApiController{}, "Get:SavePatientOutCount")
241
+
242
+	beego.Router("/api/patient/getpatientoutcountlist", &PatientApiController{}, "Get:GetPatientOutCountList")
243
+
244
+	beego.Router("/api/patient/deletepatientoutcount", &PatientApiController{}, "Get:DeletePatientOutCount")
245
+
246
+	beego.Router("/api/patient/checkpatientoutcount", &PatientApiController{}, "Get:CheckPatientOutCount")
247
+
248
+	beego.Router("/api/patient/returnpatientoutlist", &PatientApiController{}, "Get:ReturnPatientOutList")
249
+
250
+	beego.Router("/api/patient/getpatientcountmaplist", &PatientApiController{}, "Get:GetPatientCountMapList")
251
+
252
+	beego.Router("/api/patient/getpatientcountflow", &PatientApiController{}, "Get:GetPatientCountFlow")
253
+
254
+	beego.Router("/api/patient/getdialysisordersetting", &PatientApiController{}, "Get:GetDialysisOrderSetting")
255
+
256
+	beego.Router("/api/patient/savepatientordersetting", &PatientApiController{}, "Get:SavePatientOrderSetting")
257
+
258
+	beego.Router("/api/patient/getpatientcountflowlist", &PatientApiController{}, "Get:GetPatientCountFlowList")
259
+
260
+	beego.Router("/api/patient/getpatientcountflowbyid", &PatientApiController{}, "Get:GetPatientCountFlowById")
237
 
261
 
238
 }
262
 }
239
 func (c *PatientApiController) GetExportList() {
263
 func (c *PatientApiController) GetExportList() {
9111
 
9135
 
9112
 	nowtime := recordDate.Unix()
9136
 	nowtime := recordDate.Unix()
9113
 
9137
 
9114
-	patientInCount := models.SfPatientInCount{
9115
-		PatientId:  patient_id,
9116
-		UserOrgId:  orgId,
9117
-		HdCount:    hd_count,
9118
-		HdfCount:   hdf_count,
9119
-		HdhpCount:  hdhp_count,
9120
-		HpCount:    hp_count,
9121
-		Status:     1,
9122
-		Creater:    creater,
9123
-		Ctime:      time.Now().Unix(),
9124
-		Mtime:      time.Now().Unix(),
9125
-		IsCheck:    2,
9126
-		RecordDate: nowtime,
9127
-		Remark:     remark,
9128
-		OtherCount: other_count,
9129
-	}
9130
-
9131
-	fmt.Println(patientInCount)
9132
-
9133
 	db := service.XTWriteDB()
9138
 	db := service.XTWriteDB()
9134
 	// 开始外部循环的事务
9139
 	// 开始外部循环的事务
9135
 	tx := db.Begin()
9140
 	tx := db.Begin()
9140
 		}
9145
 		}
9141
 	}()
9146
 	}()
9142
 
9147
 
9143
-	service.CreatePatientInCount(tx, patientInCount)
9148
+	if hd_count > 0 {
9149
+		patientInCount := models.SfPatientInCount{
9150
+			PatientId:  patient_id,
9151
+			UserOrgId:  orgId,
9152
+			IsType:     1,
9153
+			Count:      hd_count,
9154
+			Status:     1,
9155
+			Creater:    creater,
9156
+			Ctime:      time.Now().Unix(),
9157
+			Mtime:      time.Now().Unix(),
9158
+			IsCheck:    2,
9159
+			RecordDate: nowtime,
9160
+			Remark:     remark,
9161
+			StockCount: hd_count,
9162
+		}
9163
+
9164
+		service.CreatePatientInCount(tx, patientInCount)
9165
+
9166
+	}
9167
+
9168
+	if hdf_count > 0 {
9169
+
9170
+		patientInCount := models.SfPatientInCount{
9171
+			PatientId:  patient_id,
9172
+			UserOrgId:  orgId,
9173
+			IsType:     2,
9174
+			Count:      hdf_count,
9175
+			Status:     1,
9176
+			Creater:    creater,
9177
+			Ctime:      time.Now().Unix(),
9178
+			Mtime:      time.Now().Unix(),
9179
+			IsCheck:    2,
9180
+			RecordDate: nowtime,
9181
+			Remark:     remark,
9182
+			StockCount: hdf_count,
9183
+		}
9184
+
9185
+		service.CreatePatientInCount(tx, patientInCount)
9186
+
9187
+	}
9188
+
9189
+	if hdhp_count > 0 {
9190
+
9191
+		patientInCount := models.SfPatientInCount{
9192
+			PatientId:  patient_id,
9193
+			UserOrgId:  orgId,
9194
+			IsType:     3,
9195
+			Count:      hdhp_count,
9196
+			Status:     1,
9197
+			Creater:    creater,
9198
+			Ctime:      time.Now().Unix(),
9199
+			Mtime:      time.Now().Unix(),
9200
+			IsCheck:    2,
9201
+			RecordDate: nowtime,
9202
+			Remark:     remark,
9203
+			StockCount: hdhp_count,
9204
+		}
9205
+
9206
+		service.CreatePatientInCount(tx, patientInCount)
9207
+	}
9208
+
9209
+	if hp_count > 0 {
9210
+
9211
+		patientInCount := models.SfPatientInCount{
9212
+			PatientId:  patient_id,
9213
+			UserOrgId:  orgId,
9214
+			IsType:     4,
9215
+			Count:      hp_count,
9216
+			Status:     1,
9217
+			Creater:    creater,
9218
+			Ctime:      time.Now().Unix(),
9219
+			Mtime:      time.Now().Unix(),
9220
+			IsCheck:    2,
9221
+			RecordDate: nowtime,
9222
+			Remark:     remark,
9223
+			StockCount: hp_count,
9224
+		}
9225
+		service.CreatePatientInCount(tx, patientInCount)
9226
+	}
9227
+
9228
+	if other_count > 0 {
9229
+
9230
+		patientInCount := models.SfPatientInCount{
9231
+			PatientId:  patient_id,
9232
+			UserOrgId:  orgId,
9233
+			IsType:     5,
9234
+			Count:      other_count,
9235
+			Status:     1,
9236
+			Creater:    creater,
9237
+			Ctime:      time.Now().Unix(),
9238
+			Mtime:      time.Now().Unix(),
9239
+			IsCheck:    2,
9240
+			RecordDate: nowtime,
9241
+			Remark:     remark,
9242
+			StockCount: other_count,
9243
+		}
9144
 
9244
 
9145
-	service.ModifyPatientCount(tx, hd_count, hdf_count, hdhp_count, hp_count, patient_id)
9245
+		service.CreatePatientInCount(tx, patientInCount)
9246
+	}
9146
 
9247
 
9147
 	tx.Commit()
9248
 	tx.Commit()
9148
 
9249
 
9149
 	this.ServeSuccessJSON(map[string]interface{}{
9250
 	this.ServeSuccessJSON(map[string]interface{}{
9150
-		"patientInCount": patientInCount,
9251
+		"msg": "保存成功",
9151
 	})
9252
 	})
9152
 
9253
 
9153
 }
9254
 }
9155
 func (this *PatientApiController) GetPatientCountList() {
9256
 func (this *PatientApiController) GetPatientCountList() {
9156
 
9257
 
9157
 	orgId := this.GetAdminUserInfo().CurrentOrgId
9258
 	orgId := this.GetAdminUserInfo().CurrentOrgId
9259
+	appId := this.GetAdminUserInfo().CurrentAppId
9158
 	patient_id, _ := this.GetInt64("patient_id")
9260
 	patient_id, _ := this.GetInt64("patient_id")
9159
 	page, _ := this.GetInt64("page")
9261
 	page, _ := this.GetInt64("page")
9160
 	limit, _ := this.GetInt64("limit")
9262
 	limit, _ := this.GetInt64("limit")
9161
-	patient, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit)
9263
+	start_time := this.GetString("start_time")
9264
+	end_time := this.GetString("end_time")
9265
+	timeLayout := "2006-01-02"
9266
+	loc, _ := time.LoadLocation("Local")
9267
+	var startTime int64
9268
+	if len(start_time) > 0 {
9269
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9270
+		if err != nil {
9271
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9272
+			return
9273
+		}
9274
+		startTime = theTime.Unix()
9275
+	}
9276
+
9277
+	var endTime int64
9278
+	if len(end_time) > 0 {
9279
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9280
+		if err != nil {
9281
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9282
+			return
9283
+		}
9284
+		endTime = theTime.Unix()
9285
+	}
9286
+	list, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit, startTime, endTime)
9287
+	patient, _ := service.GetPatientMapListOne(orgId)
9288
+
9289
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9162
 
9290
 
9163
 	this.ServeSuccessJSON(map[string]interface{}{
9291
 	this.ServeSuccessJSON(map[string]interface{}{
9164
-		"patient": patient,
9165
-		"total":   total,
9292
+		"list":     list,
9293
+		"total":    total,
9294
+		"patient":  patient,
9295
+		"userList": userList,
9166
 	})
9296
 	})
9167
 }
9297
 }
9168
 
9298
 
9170
 
9300
 
9171
 	id, _ := this.GetInt64("id")
9301
 	id, _ := this.GetInt64("id")
9172
 
9302
 
9173
-	checkpatientcount, _ := service.CheckPatientCount(id)
9303
+	db := service.XTWriteDB()
9304
+	// 开始外部循环的事务
9305
+	tx := db.Begin()
9306
+	// 在函数结束时处理事务回滚
9307
+	defer func() {
9308
+		if r := recover(); r != nil {
9309
+			tx.Rollback()
9310
+		}
9311
+	}()
9312
+
9313
+	creater := this.GetAdminUserInfo().AdminUser.Id
9314
+
9315
+	recordDateStr := time.Now().Format("2006-01-02")
9316
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9317
+
9318
+	warehouseInfo, _ := service.GetPatientCountById(id, tx)
9319
+
9320
+	if warehouseInfo.ID > 0 {
9321
+		service.ModiftyPatientCount(warehouseInfo.Count, warehouseInfo.IsType, warehouseInfo.PatientId, tx)
9322
+		patient, _ := service.GetSfPatientById(tx, warehouseInfo.PatientId)
9323
+
9324
+		var over_count int64
9325
+		if warehouseInfo.IsType == 1 {
9326
+			over_count = patient.HdCount
9327
+		}
9328
+		if warehouseInfo.IsType == 2 {
9329
+			over_count = patient.HdfCount
9330
+		}
9331
+
9332
+		if warehouseInfo.IsType == 3 {
9333
+			over_count = patient.HdhpCount
9334
+		}
9335
+		if warehouseInfo.IsType == 4 {
9336
+			over_count = patient.HpCount
9337
+		}
9338
+		if warehouseInfo.IsType == 5 {
9339
+			over_count = patient.OtherCount
9340
+		}
9341
+		patientCountFlow := models.SfPatientCountFlow{
9342
+			UserOrgId:       warehouseInfo.UserOrgId,
9343
+			Count:           warehouseInfo.Count,
9344
+			ModeId:          warehouseInfo.IsType,
9345
+			IsType:          1,
9346
+			PatientId:       warehouseInfo.PatientId,
9347
+			Status:          1,
9348
+			Ctime:           time.Now().Unix(),
9349
+			Mtime:           time.Now().Unix(),
9350
+			OverCount:       over_count,
9351
+			RecordDate:      recordDate.Unix(),
9352
+			Creater:         creater,
9353
+			WarehouseInfoId: warehouseInfo.ID,
9354
+		}
9355
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9356
+	}
9357
+
9358
+	checkpatientcount, _ := service.CheckPatientCount(id, tx)
9359
+
9360
+	tx.Commit()
9174
 
9361
 
9175
 	this.ServeSuccessJSON(map[string]interface{}{
9362
 	this.ServeSuccessJSON(map[string]interface{}{
9176
 		"checkpatientcount": checkpatientcount,
9363
 		"checkpatientcount": checkpatientcount,
9191
 		}
9378
 		}
9192
 	}()
9379
 	}()
9193
 
9380
 
9194
-	patientCount, _ := service.ReturnCheckPatientCount(id)
9381
+	patientCountObj, _ := service.GetPatientCountById(id, tx)
9195
 
9382
 
9196
-	patientCountObj, _ := service.GetPatientCountById(id)
9383
+	service.ReducePatientCount(patientCountObj.Count, patientCountObj.IsType, patientCountObj.PatientId, tx)
9197
 
9384
 
9198
-	service.UpdatePatientInCount(tx, patientCountObj.HdCount, patientCountObj.HdfCount, patientCountObj.HdhpCount, patientCountObj.HpCount, patientCountObj.PatientId)
9385
+	patientCount, _ := service.ReturnCheckPatientCount(id, tx)
9386
+
9387
+	service.UpdatePatientCountFlow(id, tx)
9199
 
9388
 
9200
 	tx.Commit()
9389
 	tx.Commit()
9201
 	this.ServeSuccessJSON(map[string]interface{}{
9390
 	this.ServeSuccessJSON(map[string]interface{}{
9203
 	})
9392
 	})
9204
 
9393
 
9205
 }
9394
 }
9395
+
9396
+func (this *PatientApiController) DeletePatientCount() {
9397
+
9398
+	id, _ := this.GetInt64("id")
9399
+
9400
+	service.DeletePatientCount(id)
9401
+
9402
+	this.ServeSuccessJSON(map[string]interface{}{
9403
+		"msg": "删除成功!",
9404
+	})
9405
+
9406
+}
9407
+
9408
+func (this *PatientApiController) SavePatientOutCount() {
9409
+
9410
+	patient_id, _ := this.GetInt64("patient_id")
9411
+
9412
+	count, _ := this.GetInt64("count")
9413
+
9414
+	remark := this.GetString("remark")
9415
+
9416
+	mode_id, _ := this.GetInt64("mode_id")
9417
+
9418
+	creater := this.GetAdminUserInfo().AdminUser.Id
9419
+
9420
+	recordDateStr := time.Now().Format("2006-01-02")
9421
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9422
+
9423
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9424
+
9425
+	sfPatientOutCount := models.SfPatientOutCount{
9426
+		UserOrgId:  orgId,
9427
+		PatientId:  patient_id,
9428
+		ModeId:     mode_id,
9429
+		Count:      count,
9430
+		Remark:     remark,
9431
+		Creater:    creater,
9432
+		Status:     1,
9433
+		Ctime:      time.Now().Unix(),
9434
+		Mtime:      time.Now().Unix(),
9435
+		IsCheck:    2,
9436
+		RecordDate: recordDate.Unix(),
9437
+	}
9438
+
9439
+	service.CreateSfPatientOutCount(sfPatientOutCount)
9440
+
9441
+	this.ServeSuccessJSON(map[string]interface{}{
9442
+		"msg": "保存成功!",
9443
+	})
9444
+
9445
+}
9446
+
9447
+func (this *PatientApiController) GetPatientOutCountList() {
9448
+
9449
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9450
+
9451
+	limit, _ := this.GetInt64("limit")
9452
+
9453
+	page, _ := this.GetInt64("page")
9454
+
9455
+	patient_id, _ := this.GetInt64("patient_id")
9456
+
9457
+	start_time := this.GetString("start_time")
9458
+	end_time := this.GetString("end_time")
9459
+	timeLayout := "2006-01-02"
9460
+	loc, _ := time.LoadLocation("Local")
9461
+	var startTime int64
9462
+	if len(start_time) > 0 {
9463
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9464
+		if err != nil {
9465
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9466
+			return
9467
+		}
9468
+		startTime = theTime.Unix()
9469
+	}
9470
+
9471
+	var endTime int64
9472
+	if len(end_time) > 0 {
9473
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9474
+		if err != nil {
9475
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9476
+			return
9477
+		}
9478
+		endTime = theTime.Unix()
9479
+	}
9480
+
9481
+	outcount, total, _ := service.GetPatientOutCountList(patient_id, orgId, limit, page, startTime, endTime)
9482
+
9483
+	patient, _ := service.GetPatientMapListOne(orgId)
9484
+
9485
+	appId := this.GetAdminUserInfo().CurrentAppId
9486
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9487
+	this.ServeSuccessJSON(map[string]interface{}{
9488
+		"list":     outcount,
9489
+		"total":    total,
9490
+		"patient":  patient,
9491
+		"userList": userList,
9492
+	})
9493
+
9494
+}
9495
+
9496
+func (this *PatientApiController) DeletePatientOutCount() {
9497
+
9498
+	id, _ := this.GetInt64("id")
9499
+
9500
+	service.DeletePatientOutCount(id)
9501
+
9502
+	this.ServeSuccessJSON(map[string]interface{}{
9503
+		"msg": "ok",
9504
+	})
9505
+
9506
+}
9507
+
9508
+func (this *PatientApiController) CheckPatientOutCount() {
9509
+
9510
+	id, _ := this.GetInt64("id")
9511
+	db := service.XTWriteDB()
9512
+	// 开始外部循环的事务
9513
+	tx := db.Begin()
9514
+	// 在函数结束时处理事务回滚
9515
+	defer func() {
9516
+		if r := recover(); r != nil {
9517
+			tx.Rollback()
9518
+		}
9519
+	}()
9520
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9521
+
9522
+	creater := this.GetAdminUserInfo().AdminUser.Id
9523
+
9524
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9525
+
9526
+	recordDateStr := time.Now().Format("2006-01-02")
9527
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9528
+
9529
+	if outCountList.ID > 0 {
9530
+
9531
+		//扣减库存
9532
+		service.ReducePatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9533
+
9534
+		patient, _ := service.GetSfPatientById(tx, outCountList.PatientId)
9535
+
9536
+		var over_count int64
9537
+		if outCountList.ModeId == 1 {
9538
+			over_count = patient.HdCount
9539
+		}
9540
+		if outCountList.ModeId == 2 {
9541
+			over_count = patient.HdfCount
9542
+		}
9543
+
9544
+		if outCountList.ModeId == 3 {
9545
+			over_count = patient.HdhpCount
9546
+		}
9547
+		if outCountList.ModeId == 4 {
9548
+			over_count = patient.HpCount
9549
+		}
9550
+		if outCountList.ModeId == 5 {
9551
+			over_count = patient.OtherCount
9552
+		}
9553
+
9554
+		patientCountFlow := models.SfPatientCountFlow{
9555
+			PatientId:      outCountList.PatientId,
9556
+			ModeId:         outCountList.ModeId,
9557
+			Count:          outCountList.Count,
9558
+			Status:         1,
9559
+			Ctime:          time.Now().Unix(),
9560
+			Mtime:          time.Now().Unix(),
9561
+			RecordDate:     recordDate.Unix(),
9562
+			UserOrgId:      orgId,
9563
+			Creater:        creater,
9564
+			IsType:         2,
9565
+			OverCount:      over_count,
9566
+			WarehouseOutId: outCountList.ID,
9567
+		}
9568
+
9569
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9570
+
9571
+	}
9572
+	//审核
9573
+	service.CheckPatientOutCount(id, tx)
9574
+
9575
+	tx.Commit()
9576
+
9577
+	this.ServeSuccessJSON(map[string]interface{}{
9578
+		"msg": "ok",
9579
+	})
9580
+
9581
+}
9582
+
9583
+func (this *PatientApiController) ReturnPatientOutList() {
9584
+
9585
+	id, _ := this.GetInt64("id")
9586
+	db := service.XTWriteDB()
9587
+	// 开始外部循环的事务
9588
+	tx := db.Begin()
9589
+	// 在函数结束时处理事务回滚
9590
+	defer func() {
9591
+		if r := recover(); r != nil {
9592
+			tx.Rollback()
9593
+		}
9594
+	}()
9595
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9596
+
9597
+	if outCountList.ID > 0 {
9598
+		//回退库存
9599
+		service.ModiftyPatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9600
+
9601
+		service.DeletePatientCountFlow(id, tx)
9602
+	}
9603
+	//反审核
9604
+	service.ReturnPatientOutCount(id, tx)
9605
+
9606
+	tx.Commit()
9607
+	this.ServeSuccessJSON(map[string]interface{}{
9608
+		"msg": "ok",
9609
+	})
9610
+}
9611
+
9612
+func (this *PatientApiController) GetPatientCountMapList() {
9613
+
9614
+	patient_id, _ := this.GetInt64("patient_id")
9615
+
9616
+	limit, _ := this.GetInt64("limit")
9617
+
9618
+	page, _ := this.GetInt64("page")
9619
+
9620
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9621
+
9622
+	list, total, _ := service.GetPatientCountMapList(patient_id, limit, page, orgId)
9623
+
9624
+	patient, _ := service.GetPatientMapListOne(orgId)
9625
+
9626
+	this.ServeSuccessJSON(map[string]interface{}{
9627
+		"list":    list,
9628
+		"total":   total,
9629
+		"patient": patient,
9630
+	})
9631
+}
9632
+
9633
+func (this *PatientApiController) GetPatientCountFlow() {
9634
+
9635
+	patient_id, _ := this.GetInt64("patient_id")
9636
+	is_type, _ := this.GetInt64("is_type")
9637
+	mode_id, _ := this.GetInt64("mode_id")
9638
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9639
+	start_time := this.GetString("start_time")
9640
+	end_time := this.GetString("end_time")
9641
+	timeLayout := "2006-01-02"
9642
+	loc, _ := time.LoadLocation("Local")
9643
+	var startTime int64
9644
+	if len(start_time) > 0 {
9645
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9646
+		if err != nil {
9647
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9648
+			return
9649
+		}
9650
+		startTime = theTime.Unix()
9651
+	}
9652
+
9653
+	var endTime int64
9654
+	if len(end_time) > 0 {
9655
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9656
+		if err != nil {
9657
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9658
+			return
9659
+		}
9660
+		endTime = theTime.Unix()
9661
+	}
9662
+
9663
+	list, total, _ := service.GetPatientCountFlow(patient_id, orgId, is_type, mode_id, startTime, endTime)
9664
+
9665
+	patient, _ := service.GetSfPatientByIdOne(patient_id)
9666
+
9667
+	appId := this.GetAdminUserInfo().CurrentAppId
9668
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9669
+
9670
+	this.ServeSuccessJSON(map[string]interface{}{
9671
+		"list":     list,
9672
+		"total":    total,
9673
+		"patient":  patient,
9674
+		"userList": userList,
9675
+	})
9676
+}
9677
+
9678
+func (this *PatientApiController) GetDialysisOrderSetting() {
9679
+
9680
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9681
+
9682
+	order, _ := service.GetDialysisOrderSetting(orgId)
9683
+
9684
+	this.ServeSuccessJSON(map[string]interface{}{
9685
+		"order": order,
9686
+	})
9687
+}
9688
+
9689
+func (this *PatientApiController) SavePatientOrderSetting() {
9690
+
9691
+	is_open, _ := this.GetInt64("is_open")
9692
+
9693
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9694
+
9695
+	orderSetting := models.XtDialysisOrderSetting{
9696
+		IsOpen:    is_open,
9697
+		UserOrgId: orgId,
9698
+		Ctime:     time.Now().Unix(),
9699
+		Mtime:     time.Now().Unix(),
9700
+		Status:    1,
9701
+	}
9702
+
9703
+	service.CreateDialysisOrder(orderSetting)
9704
+
9705
+	this.ServeSuccessJSON(map[string]interface{}{
9706
+		"order": orderSetting,
9707
+	})
9708
+}
9709
+
9710
+func (this *PatientApiController) GetPatientCountFlowList() {
9711
+
9712
+	patient_id, _ := this.GetInt64("patient_id")
9713
+
9714
+	start_time := this.GetString("start_time")
9715
+
9716
+	end_time := this.GetString("end_time")
9717
+
9718
+	limit, _ := this.GetInt64("limit")
9719
+
9720
+	page, _ := this.GetInt64("page")
9721
+
9722
+	is_type, _ := this.GetInt64("is_type")
9723
+
9724
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9725
+
9726
+	timeLayout := "2006-01-02"
9727
+	loc, _ := time.LoadLocation("Local")
9728
+	var startTime int64
9729
+	if len(start_time) > 0 {
9730
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9731
+		if err != nil {
9732
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9733
+			return
9734
+		}
9735
+		startTime = theTime.Unix()
9736
+	}
9737
+
9738
+	var endTime int64
9739
+	if len(end_time) > 0 {
9740
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9741
+		if err != nil {
9742
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9743
+			return
9744
+		}
9745
+		endTime = theTime.Unix()
9746
+	}
9747
+
9748
+	list, total, _ := service.GetPatientCountFlowList(patient_id, startTime, endTime, limit, page, orgId, is_type)
9749
+
9750
+	flowList, _ := service.GetPatientCountListFlowOne(patient_id, startTime, endTime, is_type, orgId)
9751
+
9752
+	patient, _ := service.GetPatientMapListOne(orgId)
9753
+
9754
+	appId := this.GetAdminUserInfo().CurrentAppId
9755
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9756
+
9757
+	this.ServeSuccessJSON(map[string]interface{}{
9758
+		"list":     list,
9759
+		"total":    total,
9760
+		"patient":  patient,
9761
+		"userList": userList,
9762
+		"flowList": flowList,
9763
+	})
9764
+}
9765
+
9766
+func (this *PatientApiController) GetPatientCountFlowById() {
9767
+
9768
+	patient_id, _ := this.GetInt64("patient_id")
9769
+
9770
+	start_time := this.GetString("start_time")
9771
+
9772
+	end_time := this.GetString("end_time")
9773
+
9774
+	is_type, _ := this.GetInt64("is_type")
9775
+
9776
+	mode_id, _ := this.GetInt64("mode_id")
9777
+
9778
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9779
+
9780
+	appId := this.GetAdminUserInfo().CurrentAppId
9781
+
9782
+	timeLayout := "2006-01-02"
9783
+	loc, _ := time.LoadLocation("Local")
9784
+	var startTime int64
9785
+	if len(start_time) > 0 {
9786
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9787
+		if err != nil {
9788
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9789
+			return
9790
+		}
9791
+		startTime = theTime.Unix()
9792
+	}
9793
+
9794
+	var endTime int64
9795
+	if len(end_time) > 0 {
9796
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9797
+		if err != nil {
9798
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9799
+			return
9800
+		}
9801
+		endTime = theTime.Unix()
9802
+	}
9803
+
9804
+	flowList, _ := service.GetPatientCountFlowByIdList(patient_id, orgId, mode_id, is_type, startTime, endTime)
9805
+
9806
+	patient, _ := service.GetPatientMapListOne(orgId)
9807
+
9808
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9809
+	this.ServeSuccessJSON(map[string]interface{}{
9810
+		"list":     flowList,
9811
+		"patient":  patient,
9812
+		"userList": userList,
9813
+	})
9814
+}

+ 3 - 0
controllers/pharmacy_controller.go Wyświetl plik

1469
 
1469
 
1470
 	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1470
 	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471
 
1471
 
1472
+	drug, _ := service.GetNewBaseDrugById(drug_id)
1473
+
1472
 	this.ServeSuccessJSON(map[string]interface{}{
1474
 	this.ServeSuccessJSON(map[string]interface{}{
1473
 		"adviceList": adviceList,
1475
 		"adviceList": adviceList,
1476
+		"drug":       drug,
1474
 	})
1477
 	})
1475
 }
1478
 }

+ 8 - 28
controllers/statistics_api_controller.go Wyświetl plik

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"fmt"
5
+	"sort"
6
+	"strconv"
7
+	"strings"
8
+	"time"
9
+
4
 	"XT_New/enums"
10
 	"XT_New/enums"
5
 	"XT_New/models"
11
 	"XT_New/models"
6
 	"XT_New/service"
12
 	"XT_New/service"
7
 	"XT_New/service/statistics_service"
13
 	"XT_New/service/statistics_service"
8
 	"XT_New/utils"
14
 	"XT_New/utils"
9
-	"fmt"
10
 	"github.com/astaxie/beego"
15
 	"github.com/astaxie/beego"
11
-	"sort"
12
-	"strconv"
13
-	"strings"
14
-	"time"
15
 )
16
 )
16
 
17
 
17
 type StatisticsApiController struct {
18
 type StatisticsApiController struct {
497
 	mode, _ := c.GetInt64("mode")
498
 	mode, _ := c.GetInt64("mode")
498
 	origin, _ := c.GetInt64("origin")
499
 	origin, _ := c.GetInt64("origin")
499
 	time_way, _ := c.GetInt64("time_way")
500
 	time_way, _ := c.GetInt64("time_way")
500
-	//timeLayout := "2006-01-02"
501
-	//loc, _ := time.LoadLocation("Local")
502
-	//var startTime int64
503
-	//if len(start_date) > 0 {
504
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
505
-	//	fmt.Println("err-----------", err)
506
-	//	if err != nil {
507
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
508
-	//		return
509
-	//	}
510
-	//	//startTime = theTime.Unix()
511
-	//}
512
-	//var endTime int64
513
-	//if len(end_date) > 0 {
514
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
515
-	//	if err != nil {
516
-	//		utils.ErrorLog(err.Error())
517
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
-	//		return
519
-	//	}
520
-	//	//endTime = theTime.Unix()
521
-	//}
501
+
522
 	dates, err := splitDateRange(start_date, end_date)
502
 	dates, err := splitDateRange(start_date, end_date)
523
 	if err != nil {
503
 	if err != nil {
524
 		fmt.Println("Error:", err)
504
 		fmt.Println("Error:", err)
1833
 	var startTime int64
1813
 	var startTime int64
1834
 	if len(start_date) > 0 {
1814
 	if len(start_date) > 0 {
1835
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
1815
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
1836
-		fmt.Println("err-----------", err)
1816
+
1837
 		if err != nil {
1817
 		if err != nil {
1838
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1818
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1839
 			return
1819
 			return

+ 1 - 1
models/dialysis.go Wyświetl plik

346
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
346
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
347
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
347
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
348
 	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
348
 	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
349
-	Height                 int64   `gorm:"column:height" json:"height" form:"height"`
349
+	Height                 string  `gorm:"column:height" json:"height" form:"height"`
350
 }
350
 }
351
 
351
 
352
 func (PredialysisEvaluationList) TableName() string {
352
 func (PredialysisEvaluationList) TableName() string {

+ 30 - 0
models/his_models.go Wyświetl plik

3091
 func (NewHisPrescription) TableName() string {
3091
 func (NewHisPrescription) TableName() string {
3092
 	return "his_prescription"
3092
 	return "his_prescription"
3093
 }
3093
 }
3094
+
3095
+type NBHisDoctorAdviceInfo struct {
3096
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
3097
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3098
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3099
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
3100
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
3101
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
3102
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
3103
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
3104
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
3105
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
3106
+	DrugCode              string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
3107
+}
3108
+
3109
+func (NBHisDoctorAdviceInfo) TableName() string {
3110
+	return "his_doctor_advice_info"
3111
+}
3112
+
3113
+type NBXtBaseDrug struct {
3114
+	ID       int64  `gorm:"column:id" json:"id" form:"id"`
3115
+	DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
3116
+	Status   int64  `gorm:"column:status" json:"status" form:"status"`
3117
+	OrgId    int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3118
+	ScanCode string `gorm:"column:scan_code" json:"scan_code" form:"scan_code"`
3119
+}
3120
+
3121
+func (NBXtBaseDrug) TableName() string {
3122
+	return "xt_base_drug"
3123
+}

+ 57 - 5
models/patient_models.go Wyświetl plik

3134
 	HdfCount    int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3134
 	HdfCount    int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3135
 	HdhpCount   int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3135
 	HdhpCount   int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3136
 	HpCount     int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3136
 	HpCount     int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3137
+	OtherCount  int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3137
 }
3138
 }
3138
 
3139
 
3139
 func (SfPatients) TableName() string {
3140
 func (SfPatients) TableName() string {
3144
 	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3145
 	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3145
 	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3146
 	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3146
 	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3147
 	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3147
-	HdCount    int64  `gorm:"column:hd_count" json:"hd_count" form:"hd_count"`
3148
-	HdfCount   int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3149
-	HdhpCount  int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3150
-	HpCount    int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3148
+	IsType     int64  `gorm:"column:is_type" json:"is_type" form:"is_type"`
3151
 	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3149
 	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3152
 	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3150
 	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3153
 	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3151
 	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3155
 	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3153
 	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3156
 	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3154
 	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3157
 	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3155
 	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3158
-	OtherCount int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3156
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3157
+	StockCount int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
3159
 }
3158
 }
3160
 
3159
 
3161
 func (SfPatientInCount) TableName() string {
3160
 func (SfPatientInCount) TableName() string {
3162
 	return "xt_patient_in_count"
3161
 	return "xt_patient_in_count"
3163
 }
3162
 }
3163
+
3164
+type SfPatientOutCount struct {
3165
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3166
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3167
+	ModeId     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3168
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3169
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3170
+	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3171
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3172
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3173
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
3174
+	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3175
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3176
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3177
+}
3178
+
3179
+func (SfPatientOutCount) TableName() string {
3180
+	return "xt_patient_out_count"
3181
+}
3182
+
3183
+type SfPatientCountFlow struct {
3184
+	ID              int64 `gorm:"column:id" json:"id" form:"id"`
3185
+	UserOrgId       int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3186
+	Count           int64 `gorm:"column:count" json:"count" form:"count"`
3187
+	ModeId          int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3188
+	IsType          int64 `gorm:"column:is_type" json:"is_type" form:"is_type"`
3189
+	PatientId       int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3190
+	Status          int64 `gorm:"column:status" json:"status" form:"status"`
3191
+	Ctime           int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3192
+	Mtime           int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3193
+	OverCount       int64 `gorm:"column:over_count" json:"over_count" form:"over_count"`
3194
+	RecordDate      int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
3195
+	Creater         int64 `gorm:"column:creater" json:"creater" form:"creater"`
3196
+	WarehouseInfoId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
3197
+	WarehouseOutId  int64 `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
3198
+}
3199
+
3200
+func (SfPatientCountFlow) TableName() string {
3201
+	return "xt_patient_count_flow"
3202
+}
3203
+
3204
+type XtDialysisOrderSetting struct {
3205
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
3206
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
3207
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3208
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3209
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3210
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
3211
+}
3212
+
3213
+func (XtDialysisOrderSetting) TableName() string {
3214
+	return "xt_dialysis_order_setting"
3215
+}

+ 8 - 14
service/common_service.go Wyświetl plik

293
 
293
 
294
 func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
294
 func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
295
 	db := readDb.Table("xt_patients as x")
295
 	db := readDb.Table("xt_patients as x")
296
-	//if lapsetotype > 0 {
297
-	// db = db.Where("x.lapseto = ?", lapsetotype)
298
-	//}
299
-	//if sourcetype > 0 {
300
-	// db = db.Where("x.source = ?", sourcetype)
301
-	//}
302
-	db.Where("x.user_org_id=? and x.status=1", orgID).Count(&total)
296
+	db.Where("x.user_org_id=? and x.status=1 and x.patient_type=1", orgID).Count(&total)
303
 	return
297
 	return
304
 }
298
 }
305
 
299
 
321
 
315
 
322
 func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
316
 func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
323
 
317
 
324
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
318
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
325
 	if lapsetotype > 0 {
319
 	if lapsetotype > 0 {
326
 		db = db.Where("x.lapseto = ?", lapsetotype)
320
 		db = db.Where("x.lapseto = ?", lapsetotype)
327
 	}
321
 	}
333
 }
327
 }
334
 
328
 
335
 func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
329
 func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
336
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
330
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
337
 	if lapsetotype > 0 {
331
 	if lapsetotype > 0 {
338
 		db = db.Where("x.lapseto = ?", lapsetotype)
332
 		db = db.Where("x.lapseto = ?", lapsetotype)
339
 	}
333
 	}
352
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
346
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
353
 
347
 
354
 	if lapsetotype == 0 {
348
 	if lapsetotype == 0 {
355
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
349
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356
 	}
350
 	}
357
 	if sourcetype == 0 {
351
 	if sourcetype == 0 {
358
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
352
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
359
 	}
353
 	}
360
 
354
 
361
 	if lapsetotype > 0 {
355
 	if lapsetotype > 0 {
362
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
363
 	}
357
 	}
364
 
358
 
365
 	if sourcetype > 0 {
359
 	if sourcetype > 0 {
366
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
360
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
367
 	}
361
 	}
368
 
362
 
369
 	return counts, err
363
 	return counts, err
388
     WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
382
     WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
389
     ELSE '150'
383
     ELSE '150'
390
 	 END
384
 	 END
391
-	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1
385
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.patient_type =1
392
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
386
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
393
 
387
 
394
 	}
388
 	}

+ 6 - 0
service/gobal_config_service.go Wyświetl plik

202
 	return doctor, err
202
 	return doctor, err
203
 }
203
 }
204
 
204
 
205
+func GetHisPrint(ids []string, org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
206
+
207
+	err = XTReadDB().Where("id in (?) and user_org_id = ?", ids, org_id).Order("execution_time asc").Find(&advice).Error
208
+	return advice, err
209
+}
210
+
205
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
211
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
206
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
212
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
207
 		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error
213
 		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error

+ 1 - 0
service/mobile_dialysis_service.go Wyświetl plik

634
 
634
 
635
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
635
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
636
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
636
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
637
+
637
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
638
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
638
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
639
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
639
 		if err != nil {
640
 		if err != nil {

+ 14 - 15
service/new_warehouse_service.go Wyświetl plik

4508
 
4508
 
4509
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4509
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4510
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4510
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4511
-			fmt.Println("hahhahahahahhaah")
4512
 			var stockMax int64
4511
 			var stockMax int64
4513
 			var stockMin int64
4512
 			var stockMin int64
4513
+
4514
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4514
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4515
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4515
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4516
 
4516
 
4522
 	}
4522
 	}
4523
 
4523
 
4524
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4524
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4525
-		fmt.Println("ooowowowowowowowowowo")
4526
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4525
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4527
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4526
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4528
 
4527
 
4547
 
4546
 
4548
 	}
4547
 	}
4549
 
4548
 
4550
-	fmt.Println("stock_number", stock_number)
4551
-	fmt.Println("deliver_number=============", deliver_number)
4549
+	//fmt.Println("stock_number", stock_number)
4550
+	//fmt.Println("deliver_number=============", deliver_number)
4552
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4551
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4553
 	if stock_number >= deliver_number {
4552
 	if stock_number >= deliver_number {
4554
 
4553
 
4558
 		maxNumber = deliver_number / drup.MinNumber
4557
 		maxNumber = deliver_number / drup.MinNumber
4559
 		minNumber = deliver_number % drup.MinNumber
4558
 		minNumber = deliver_number % drup.MinNumber
4560
 
4559
 
4561
-		fmt.Println("max_Number=====================", maxNumber)
4562
-		fmt.Println("minNumber=====================", minNumber)
4560
+		//fmt.Println("max_Number=====================", maxNumber)
4561
+		//fmt.Println("minNumber=====================", minNumber)
4563
 
4562
 
4564
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4563
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4565
 			minNumber = maxNumber
4564
 			minNumber = maxNumber
4573
 
4572
 
4574
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4573
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4575
 
4574
 
4576
-			fmt.Println("金1")
4575
+			//fmt.Println("金1")
4577
 
4576
 
4578
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4577
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4579
 		}
4578
 		}
4580
 
4579
 
4581
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4580
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4582
-			fmt.Println("jin2")
4581
+			//fmt.Println("jin2")
4583
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4582
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4584
 		}
4583
 		}
4585
 
4584
 
4586
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4585
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4587
-			fmt.Println("jin3")
4586
+			//fmt.Println("jin3")
4588
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4587
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4589
 		}
4588
 		}
4590
 
4589
 
4597
 
4596
 
4598
 		warehouse.Mtime = time.Now().Unix()
4597
 		warehouse.Mtime = time.Now().Unix()
4599
 
4598
 
4600
-		fmt.Println("hahhahahah", warehouse.StockMinNumber)
4601
-		fmt.Println("howowowoowow", minNumber)
4599
+		//fmt.Println("hahhahahah", warehouse.StockMinNumber)
4600
+		//fmt.Println("howowowoowow", minNumber)
4602
 		if warehouse.StockMinNumber < minNumber {
4601
 		if warehouse.StockMinNumber < minNumber {
4603
 
4602
 
4604
 			if warehouse.MaxUnit != warehouse.MinUnit {
4603
 			if warehouse.MaxUnit != warehouse.MinUnit {
4609
 			if warehouse.MaxUnit != warehouse.MinUnit {
4608
 			if warehouse.MaxUnit != warehouse.MinUnit {
4610
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4609
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4611
 			}
4610
 			}
4612
-			fmt.Println("minNumber------", minNumber)
4613
-			fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4614
-			fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4615
-			fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4611
+			//fmt.Println("minNumber------", minNumber)
4612
+			//fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4613
+			//fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4614
+			//fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4616
 
4615
 
4617
 			if warehouse.MaxUnit == warehouse.MinUnit {
4616
 			if warehouse.MaxUnit == warehouse.MinUnit {
4618
 				//改动的地方
4617
 				//改动的地方

+ 456 - 10
service/patient_service.go Wyświetl plik

589
 }
589
 }
590
 
590
 
591
 func GetPatientCount(orgID int64) (total int64) {
591
 func GetPatientCount(orgID int64) (total int64) {
592
-	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
592
+	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 and patient_type = 1", orgID).Count(&total)
593
 	return
593
 	return
594
 }
594
 }
595
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
595
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
5074
 	return patient, err
5074
 	return patient, err
5075
 }
5075
 }
5076
 
5076
 
5077
+func GetPatientMapListOne(user_org_id int64) (patient []*models.SfPatients, err error) {
5078
+
5079
+	err = XTReadDB().Where("user_org_id = ? and status=1 and lapseto =1", user_org_id).Find(&patient).Error
5080
+
5081
+	return patient, err
5082
+}
5083
+
5084
+func GetAllAdminUserList(org_id int64, app_id int64) (admin []*models.SgjUserAdminRole, err error) {
5085
+
5086
+	err = UserReadDB().Where("org_id = ? and app_id = ? and status=1", org_id, app_id).Find(&admin).Error
5087
+
5088
+	return admin, err
5089
+}
5090
+
5077
 func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) error {
5091
 func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) error {
5078
 
5092
 
5079
 	err := tx.Create(&patientCount).Error
5093
 	err := tx.Create(&patientCount).Error
5085
 	return err
5099
 	return err
5086
 }
5100
 }
5087
 
5101
 
5088
-func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, patient_id int64) (models.SfPatients, error) {
5102
+func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, other_count int64, patient_id int64) (models.SfPatients, error) {
5089
 
5103
 
5090
 	patients := models.SfPatients{}
5104
 	patients := models.SfPatients{}
5091
 
5105
 
5097
 
5111
 
5098
 	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", hp_count)).Error
5112
 	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", hp_count)).Error
5099
 
5113
 
5114
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", other_count)).Error
5115
+
5100
 	return patients, err
5116
 	return patients, err
5101
 }
5117
 }
5102
 
5118
 
5115
 	return patients, err
5131
 	return patients, err
5116
 }
5132
 }
5117
 
5133
 
5118
-func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64) (patient []*models.SfPatientInCount, total int64, err error) {
5134
+func ModiftyPatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5135
+
5136
+	patients := models.SfPatients{}
5137
+	if is_type == 1 {
5138
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count + ?", count)).Error
5139
+		if err != nil {
5140
+			tx.Rollback()
5141
+			return patients, err
5142
+		}
5143
+	}
5144
+	if is_type == 2 {
5145
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count + ?", count)).Error
5146
+		if err != nil {
5147
+			tx.Rollback()
5148
+			return patients, err
5149
+		}
5150
+	}
5151
+	if is_type == 3 {
5152
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count + ?", count)).Error
5153
+		if err != nil {
5154
+			tx.Rollback()
5155
+			return patients, err
5156
+		}
5157
+	}
5158
+	if is_type == 4 {
5159
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", count)).Error
5160
+		if err != nil {
5161
+			tx.Rollback()
5162
+			return patients, err
5163
+		}
5164
+	}
5165
+	if is_type == 5 {
5166
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", count)).Error
5167
+		if err != nil {
5168
+			tx.Rollback()
5169
+			return patients, err
5170
+		}
5171
+	}
5172
+	return patients, err
5173
+}
5174
+
5175
+func ReducePatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5176
+
5177
+	patients := models.SfPatients{}
5178
+	if is_type == 1 {
5179
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count - ?", count)).Error
5180
+		if err != nil {
5181
+			tx.Rollback()
5182
+			return patients, err
5183
+		}
5184
+	}
5185
+	if is_type == 2 {
5186
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count - ?", count)).Error
5187
+		if err != nil {
5188
+			tx.Rollback()
5189
+			return patients, err
5190
+		}
5191
+	}
5192
+	if is_type == 3 {
5193
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count - ?", count)).Error
5194
+		if err != nil {
5195
+			tx.Rollback()
5196
+			return patients, err
5197
+		}
5198
+	}
5199
+	if is_type == 4 {
5200
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count - ?", count)).Error
5201
+		if err != nil {
5202
+			tx.Rollback()
5203
+			return patients, err
5204
+		}
5205
+	}
5206
+	if is_type == 5 {
5207
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count - ?", count)).Error
5208
+		if err != nil {
5209
+			tx.Rollback()
5210
+			return patients, err
5211
+		}
5212
+	}
5213
+	return patients, err
5214
+}
5215
+
5216
+func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64, start_time int64, end_time int64) (patient []*models.SfPatientInCount, total int64, err error) {
5119
 
5217
 
5120
 	db := XTReadDB().Model(&patient).Where("status=1")
5218
 	db := XTReadDB().Model(&patient).Where("status=1")
5121
 
5219
 
5129
 		db = db.Where("user_org_id = ?", user_org_id)
5227
 		db = db.Where("user_org_id = ?", user_org_id)
5130
 	}
5228
 	}
5131
 
5229
 
5230
+	if start_time > 0 {
5231
+		db = db.Where("record_date >=?", start_time)
5232
+	}
5233
+	if end_time > 0 {
5234
+		db = db.Where("record_date<=?", end_time)
5235
+	}
5236
+
5132
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&patient).Error
5237
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&patient).Error
5133
 
5238
 
5134
 	return patient, total, err
5239
 	return patient, total, err
5135
 }
5240
 }
5136
 
5241
 
5137
-func CheckPatientCount(id int64) (models.SfPatientInCount, error) {
5242
+func CheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5138
 
5243
 
5139
 	patientInCount := models.SfPatientInCount{}
5244
 	patientInCount := models.SfPatientInCount{}
5140
 
5245
 
5141
-	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5142
-
5246
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5247
+	if err != nil {
5248
+		tx.Rollback()
5249
+		return patientInCount, err
5250
+	}
5143
 	return patientInCount, err
5251
 	return patientInCount, err
5144
 }
5252
 }
5145
 
5253
 
5146
-func ReturnCheckPatientCount(id int64) (models.SfPatientInCount, error) {
5254
+func ReturnCheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5147
 
5255
 
5148
 	patientInCount := models.SfPatientInCount{}
5256
 	patientInCount := models.SfPatientInCount{}
5149
 
5257
 
5150
-	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5258
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5259
+
5260
+	if err != nil {
5261
+		tx.Rollback()
5262
+		return patientInCount, err
5263
+	}
5151
 
5264
 
5152
 	return patientInCount, err
5265
 	return patientInCount, err
5153
 }
5266
 }
5154
 
5267
 
5155
-func GetPatientCountById(id int64) (models.SfPatientInCount, error) {
5268
+func UpdatePatientCountFlow(id int64, tx *gorm.DB) error {
5269
+
5270
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_info_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5271
+
5272
+	if err != nil {
5273
+		tx.Rollback()
5274
+		return err
5275
+	}
5276
+	return err
5277
+}
5278
+
5279
+func GetPatientCountById(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5156
 
5280
 
5157
 	patientInCount := models.SfPatientInCount{}
5281
 	patientInCount := models.SfPatientInCount{}
5158
 
5282
 
5159
-	err := XTReadDB().Where("id = ?", id).Find(&patientInCount).Error
5283
+	err := tx.Where("id = ?", id).Find(&patientInCount).Error
5284
+	if err != nil {
5285
+		tx.Rollback()
5286
+		return patientInCount, err
5287
+	}
5160
 
5288
 
5161
 	return patientInCount, err
5289
 	return patientInCount, err
5162
 }
5290
 }
5291
+
5292
+func DeletePatientCount(id int64) (models.SfPatientInCount, error) {
5293
+
5294
+	patientCount := models.SfPatientInCount{}
5295
+
5296
+	err := XTWriteDB().Model(&patientCount).Where("id = ?", id).Updates(map[string]interface{}{"status": 0}).Error
5297
+
5298
+	return patientCount, err
5299
+}
5300
+
5301
+func CreateSfPatientOutCount(outCount models.SfPatientOutCount) error {
5302
+
5303
+	err := XTWriteDB().Create(&outCount).Error
5304
+
5305
+	return err
5306
+}
5307
+
5308
+func GetPatientOutCountList(patient_id int64, user_org_id int64, limit int64, page int64, start_time int64, end_time int64) (outcount []*models.SfPatientOutCount, total int64, err error) {
5309
+
5310
+	db := XTReadDB().Model(&outcount).Where("status=1")
5311
+
5312
+	offset := (page - 1) * limit
5313
+
5314
+	if patient_id > 0 {
5315
+		db = db.Where("patient_id = ?", patient_id)
5316
+	}
5317
+
5318
+	if user_org_id > 0 {
5319
+		db = db.Where("user_org_id = ?", user_org_id)
5320
+	}
5321
+
5322
+	if start_time > 0 {
5323
+		db = db.Where("start_time>=?", start_time)
5324
+	}
5325
+
5326
+	if end_time > 0 {
5327
+		db = db.Where("end_time<=?", end_time)
5328
+	}
5329
+
5330
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&outcount).Error
5331
+
5332
+	return outcount, total, err
5333
+
5334
+}
5335
+
5336
+func GetPatientScheduleByPatient(patient_id int64, record_date int64, user_org_id int64) (models.XtSchedule, error) {
5337
+
5338
+	schedule := models.XtSchedule{}
5339
+	err = XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Last(&schedule).Error
5340
+
5341
+	return schedule, err
5342
+}
5343
+
5344
+func GetDialysisSolutonByScheduleModeId(mode_id int64, patient_id int64, user_org_id int64) (models.DialysisSolution, error) {
5345
+
5346
+	solution := models.DialysisSolution{}
5347
+
5348
+	err = XTReadDB().Where("mode_id = ? and patient_id = ? and user_org_id = ? and solution_status =1", mode_id, patient_id, user_org_id).Find(&solution).Error
5349
+
5350
+	return solution, err
5351
+}
5352
+
5353
+func DeletePatientOutCount(id int64) error {
5354
+
5355
+	outCount := models.SfPatientOutCount{}
5356
+
5357
+	err := XTWriteDB().Model(&outCount).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
5358
+
5359
+	return err
5360
+}
5361
+
5362
+func GetPatientOutCountById(id int64, tx *gorm.DB) (models.SfPatientOutCount, error) {
5363
+
5364
+	outCount := models.SfPatientOutCount{}
5365
+	err = tx.Where("id=? and status=1", id).Find(&outCount).Error
5366
+
5367
+	if err != gorm.ErrRecordNotFound {
5368
+		if err != nil {
5369
+			tx.Rollback()
5370
+			return outCount, err
5371
+		}
5372
+	}
5373
+	return outCount, err
5374
+}
5375
+
5376
+func CreatePatientCountFlow(flow models.SfPatientCountFlow, tx *gorm.DB) error {
5377
+
5378
+	err := tx.Create(&flow).Error
5379
+
5380
+	if err != nil {
5381
+		tx.Rollback()
5382
+		return err
5383
+	}
5384
+
5385
+	return err
5386
+}
5387
+
5388
+func GetSfPatientById(tx *gorm.DB, patient_id int64) (models.SfPatients, error) {
5389
+
5390
+	patients := models.SfPatients{}
5391
+	err := tx.Where("id =? and status=1", patient_id).Find(&patients).Error
5392
+
5393
+	if err != gorm.ErrRecordNotFound {
5394
+		if err != nil {
5395
+			tx.Rollback()
5396
+			return patients, err
5397
+		}
5398
+	}
5399
+	return patients, err
5400
+}
5401
+
5402
+func GetSfPatientByIdOne(patient_id int64) (models.SfPatients, error) {
5403
+
5404
+	patients := models.SfPatients{}
5405
+	err := XTReadDB().Where("id =? and status=1", patient_id).Find(&patients).Error
5406
+
5407
+	return patients, err
5408
+}
5409
+
5410
+func CheckPatientOutCount(id int64, tx *gorm.DB) error {
5411
+
5412
+	patients := models.SfPatientOutCount{}
5413
+
5414
+	err := tx.Model(&patients).Where("id=? and status=1", id).Updates(map[string]interface{}{"is_check": 1, "mtime": time.Now().Unix()}).Error
5415
+
5416
+	return err
5417
+}
5418
+
5419
+func ReturnPatientOutCount(id int64, tx *gorm.DB) error {
5420
+
5421
+	err = tx.Model(&models.SfPatientOutCount{}).Where("id=?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5422
+
5423
+	if err != nil {
5424
+		tx.Rollback()
5425
+		return err
5426
+	}
5427
+
5428
+	return err
5429
+}
5430
+
5431
+func DeletePatientCountFlow(id int64, tx *gorm.DB) error {
5432
+
5433
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_out_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5434
+
5435
+	if err != nil {
5436
+		tx.Rollback()
5437
+		return err
5438
+	}
5439
+	return err
5440
+
5441
+}
5442
+
5443
+func GetPatientCountMapList(patient_id int64, limit int64, page int64, user_org_id int64) (patient []*models.SfPatients, total int64, err error) {
5444
+
5445
+	db := XTReadDB().Model(&patient).Where("status=1")
5446
+
5447
+	offset := (page - 1) * limit
5448
+
5449
+	if (patient_id) > 0 {
5450
+		db = db.Where("id = ?", patient_id)
5451
+	}
5452
+	if (user_org_id) > 0 {
5453
+		db = db.Where("user_org_id = ?", user_org_id)
5454
+	}
5455
+
5456
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&patient).Error
5457
+
5458
+	return patient, total, err
5459
+}
5460
+
5461
+func GetPatientCountFlow(patient_id int64, user_org_id int64, is_type int64, mode_id int64, start_time int64, end_time int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5462
+
5463
+	db := XTReadDB().Model(&flow).Where("status=1")
5464
+
5465
+	if patient_id > 0 {
5466
+		db = db.Where("patient_id=?", patient_id)
5467
+	}
5468
+	if user_org_id > 0 {
5469
+		db = db.Where("user_org_id = ?", user_org_id)
5470
+	}
5471
+	if is_type > 0 {
5472
+		db = db.Where("is_type = ?", is_type)
5473
+	}
5474
+	if mode_id > 0 {
5475
+		db = db.Where("mode_id = ?", mode_id)
5476
+	}
5477
+
5478
+	if start_time > 0 {
5479
+		db = db.Where("ctime>=?", start_time)
5480
+	}
5481
+	if end_time > 0 {
5482
+		db = db.Where("ctime<=?", end_time)
5483
+	}
5484
+	err = db.Find(&flow).Error
5485
+
5486
+	return flow, total, err
5487
+}
5488
+
5489
+func GetDialysisOrderSetting(user_org_id int64) (models.XtDialysisOrderSetting, error) {
5490
+
5491
+	orderSetting := models.XtDialysisOrderSetting{}
5492
+	err = XTReadDB().Model(&orderSetting).Where("user_org_id = ? and status=1", user_org_id).Find(&orderSetting).Error
5493
+
5494
+	return orderSetting, err
5495
+}
5496
+
5497
+func GetDialysisOrderSchedule(patient_id int64, schedule_date int64, user_org_id int64, tx *gorm.DB) (models.XtSchedule, error) {
5498
+
5499
+	schedule := models.XtSchedule{}
5500
+
5501
+	err = tx.Where("patient_id=? and schedule_date = ? and user_org_id=? and status=1", patient_id, schedule_date, user_org_id).Find(&schedule).Error
5502
+
5503
+	if err != nil {
5504
+		tx.Rollback()
5505
+		return schedule, err
5506
+	}
5507
+
5508
+	return schedule, err
5509
+}
5510
+
5511
+func CreateDialysisOrder(setting models.XtDialysisOrderSetting) error {
5512
+
5513
+	err := XTWriteDB().Create(&setting).Error
5514
+
5515
+	return err
5516
+}
5517
+
5518
+func GetPatientCountFlowList(patient_id int64, start_time int64, end_time int64, limit int64, page int64, orgId int64, is_type int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5519
+
5520
+	db := XTReadDB().Model(&flow).Where("status=1")
5521
+
5522
+	offset := (page - 1) * limit
5523
+
5524
+	if patient_id > 0 {
5525
+		db = db.Where("patient_id = ?", patient_id)
5526
+	}
5527
+	if start_time > 0 {
5528
+		db = db.Where("ctime>=?", start_time)
5529
+	}
5530
+
5531
+	if end_time > 0 {
5532
+		db = db.Where("ctime<=?", end_time)
5533
+	}
5534
+
5535
+	if orgId > 0 {
5536
+		db = db.Where("user_org_id = ?", orgId)
5537
+	}
5538
+
5539
+	if is_type > 0 {
5540
+		db = db.Where("is_type = ?", is_type)
5541
+	}
5542
+
5543
+	err = db.Group("patient_id,mode_id,is_type").Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&flow).Error
5544
+
5545
+	return flow, total, err
5546
+}
5547
+
5548
+func GetPatientCountListFlowOne(patient_id int64, start_time int64, end_time int64, is_type int64, orgId int64) (flow []*models.SfPatientCountFlow, err error) {
5549
+
5550
+	db := XTReadDB().Model(&flow).Where("status=1")
5551
+
5552
+	if patient_id > 0 {
5553
+		db = db.Where("patient_id = ?", patient_id)
5554
+	}
5555
+	if start_time > 0 {
5556
+		db = db.Where("ctime>=?", start_time)
5557
+	}
5558
+
5559
+	if end_time > 0 {
5560
+		db = db.Where("ctime<=?", end_time)
5561
+	}
5562
+
5563
+	if orgId > 0 {
5564
+		db = db.Where("user_org_id = ?", orgId)
5565
+	}
5566
+
5567
+	if is_type > 0 {
5568
+		db = db.Where("is_type = ?", is_type)
5569
+	}
5570
+
5571
+	err = db.Order("id desc").Find(&flow).Error
5572
+
5573
+	return flow, err
5574
+
5575
+}
5576
+
5577
+func GetPatientCountFlowByIdList(patient_id int64, orgId int64, mode_id int64, is_type int64, startTime int64, endTime int64) (flow []*models.SfPatientCountFlow, err error) {
5578
+
5579
+	db := XTReadDB().Model(&flow).Where("status=1")
5580
+
5581
+	if patient_id > 0 {
5582
+		db = db.Where("patient_id=?", patient_id)
5583
+	}
5584
+	if orgId > 0 {
5585
+		db = db.Where("user_org_id =?", orgId)
5586
+	}
5587
+
5588
+	if mode_id > 0 {
5589
+		db = db.Where("mode_id = ?", mode_id)
5590
+	}
5591
+
5592
+	if is_type > 0 {
5593
+		db = db.Where("is_type =?", is_type)
5594
+	}
5595
+
5596
+	if startTime > 0 {
5597
+		db = db.Where("ctime>=?", startTime)
5598
+	}
5599
+	if endTime > 0 {
5600
+		db = db.Where("ctime<=?", endTime)
5601
+	}
5602
+	if mode_id > 0 {
5603
+		db = db.Where("mode_id = ?", mode_id)
5604
+	}
5605
+	err = db.Find(&flow).Error
5606
+
5607
+	return flow, err
5608
+}

+ 5 - 5
service/patientmanage_service.go Wyświetl plik

1971
 
1971
 
1972
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1972
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1973
 	var count []*models.Inspection
1973
 	var count []*models.Inspection
1974
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1974
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 and pp.patient_type =1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1975
 
1975
 
1976
 	return int64(len(count)), err2
1976
 	return int64(len(count)), err2
1977
 }
1977
 }
1978
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1978
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1979
 	var count []*models.Inspection
1979
 	var count []*models.Inspection
1980
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1980
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1 and pp.patient_type =1   WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1981
 	return int64(len(count)), err2
1981
 	return int64(len(count)), err2
1982
 }
1982
 }
1983
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
1983
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
1984
-	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error
1984
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1 and xt_patients.patient_type = 1", orgid).Count(&total).Error
1985
 	return total, err
1985
 	return total, err
1986
 }
1986
 }
1987
 
1987
 
1988
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patient_id int64, item_name string) (inspections []*models.Inspection, err error) {
1988
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patient_id int64, item_name string) (inspections []*models.Inspection, err error) {
1989
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1989
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
1990
 	if startime > 0 {
1990
 	if startime > 0 {
1991
 		db = db.Where("x.inspect_date >= ?", startime)
1991
 		db = db.Where("x.inspect_date >= ?", startime)
1992
 	}
1992
 	}
2009
 }
2009
 }
2010
 
2010
 
2011
 func GetPatientKTVORURRInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
2011
 func GetPatientKTVORURRInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
2012
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
2012
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
2013
 	if startime > 0 {
2013
 	if startime > 0 {
2014
 		db = db.Where("x.inspect_date >= ?", startime)
2014
 		db = db.Where("x.inspect_date >= ?", startime)
2015
 	}
2015
 	}

+ 9 - 1
service/pharmacy_service.go Wyświetl plik

2561
 	return
2561
 	return
2562
 }
2562
 }
2563
 
2563
 
2564
-func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.NBHisDoctorAdviceInfo, err error) {
2565
 
2565
 
2566
 	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2566
 	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567
 
2567
 
2568
 	return advice, err
2568
 	return advice, err
2569
 }
2569
 }
2570
+
2571
+func GetNewBaseDrugById(id int64) (models.NBXtBaseDrug, error) {
2572
+
2573
+	drug := models.NBXtBaseDrug{}
2574
+	err := XTReadDB().Where("id = ?", id).Find(&drug).Error
2575
+
2576
+	return drug, err
2577
+}

+ 1 - 1
service/self_drug_service.go Wyświetl plik

1271
 		if orgid > 0 {
1271
 		if orgid > 0 {
1272
 			db = db.Where("x.org_id = ?", orgid)
1272
 			db = db.Where("x.org_id = ?", orgid)
1273
 		}
1273
 		}
1274
-		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1274
+		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.id").Scan(&info).Error
1275
 		return info, err
1275
 		return info, err
1276
 	} else {
1276
 	} else {
1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")
1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")

+ 1 - 1
service/sign_service.go Wyświetl plik

2488
 
2488
 
2489
 func CheckSchedule() (schedule []*models.XtSchedule, err error) {
2489
 func CheckSchedule() (schedule []*models.XtSchedule, err error) {
2490
 
2490
 
2491
-	err = readDb3.Where("user_org_id = 10445 and schedule_date<1741536000").Find(&schedule).Error
2491
+	err = readDb3.Where("user_org_id = 9535 and schedule_date<1741536000").Find(&schedule).Error
2492
 
2492
 
2493
 	return schedule, err
2493
 	return schedule, err
2494
 }
2494
 }

+ 28 - 8
service/warhouse_service.go Wyświetl plik

11049
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
11049
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
11050
 			var stockMax int64
11050
 			var stockMax int64
11051
 			var stockMin int64
11051
 			var stockMin int64
11052
+
11053
+			var stockMac_One int64
11054
+
11052
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
11055
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
11053
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
11056
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
11054
 
11057
 
11055
-			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMax, tx)
11058
+			stockMac_One = lastWarehouse.StockMaxNumber + stockMax
11059
+
11060
+			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMac_One, tx)
11056
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
11061
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
11057
 
11062
 
11058
 		}
11063
 		}
11061
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11066
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11062
 
11067
 
11063
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
11068
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
11069
+
11064
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
11070
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
11065
 
11071
 
11066
 	}
11072
 	}
11083
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
11089
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
11084
 
11090
 
11085
 	}
11091
 	}
11092
+
11093
+	fmt.Println("stock_number--------------", stock_number)
11094
+	fmt.Println("deliver_number", deliver_number)
11086
 	if stock_number >= deliver_number {
11095
 	if stock_number >= deliver_number {
11087
 
11096
 
11088
 		var maxNumber int64 = 0
11097
 		var maxNumber int64 = 0
11091
 		maxNumber = deliver_number / drup.MinNumber
11100
 		maxNumber = deliver_number / drup.MinNumber
11092
 		minNumber = deliver_number % drup.MinNumber
11101
 		minNumber = deliver_number % drup.MinNumber
11093
 
11102
 
11103
+		fmt.Println("maxNumber==============", maxNumber)
11104
+
11105
+		fmt.Println("maxNumber==============", minNumber)
11106
+
11094
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
11107
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
11095
 			minNumber = maxNumber
11108
 			minNumber = maxNumber
11096
 		}
11109
 		}
11101
 			}
11114
 			}
11102
 		}
11115
 		}
11103
 
11116
 
11117
+		fmt.Println("warehouse.StockMaxNumber", warehouse.StockMaxNumber)
11118
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11119
+
11104
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11120
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11105
-			//fmt.Println("金1")
11121
+			fmt.Println("金1")
11106
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
11122
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
11107
 		}
11123
 		}
11108
 
11124
 
11109
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11125
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11110
-			//fmt.Println("金2")
11126
+			fmt.Println("金2")
11111
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11127
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11112
 		}
11128
 		}
11113
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
11129
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
11114
-			//fmt.Println("金3")
11130
+			fmt.Println("金3")
11115
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11131
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11116
 		}
11132
 		}
11117
 
11133
 
11124
 
11140
 
11125
 		warehouse.Mtime = time.Now().Unix()
11141
 		warehouse.Mtime = time.Now().Unix()
11126
 
11142
 
11143
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11144
+
11145
+		fmt.Println("minNumber222222222222222", minNumber)
11146
+
11127
 		if warehouse.StockMinNumber < minNumber {
11147
 		if warehouse.StockMinNumber < minNumber {
11128
-			//fmt.Println("金4")
11148
+			fmt.Println("金4")
11129
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11149
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11130
 			if warehouse.MaxUnit != warehouse.MinUnit {
11150
 			if warehouse.MaxUnit != warehouse.MinUnit {
11131
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
11151
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
11134
 				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11154
 				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11135
 			}
11155
 			}
11136
 		} else {
11156
 		} else {
11137
-			//fmt.Println("金5")
11157
+			fmt.Println("金5", minNumber)
11138
 			if minNumber > 0 {
11158
 			if minNumber > 0 {
11139
 				if (warehouse.StockMinNumber - minNumber) >= 0 {
11159
 				if (warehouse.StockMinNumber - minNumber) >= 0 {
11140
 					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
11160
 					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
11143
 			}
11163
 			}
11144
 
11164
 
11145
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
11165
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
11146
-				//fmt.Println("6")
11166
+				fmt.Println("6", warehouse.StockMinNumber)
11147
 				if warehouse.StockMinNumber > 0 {
11167
 				if warehouse.StockMinNumber > 0 {
11148
 					if warehouse.StockMinNumber-deliver_number >= 0 {
11168
 					if warehouse.StockMinNumber-deliver_number >= 0 {
11149
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11169
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11157
 
11177
 
11158
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
11178
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
11159
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
11179
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
11160
-				//fmt.Println("金7")
11180
+				fmt.Println("金7")
11161
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11181
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11162
 			}
11182
 			}
11163
 
11183