소스 검색

11月9日库存管理

XMLWAN 1 년 전
부모
커밋
a2d295f026

+ 13 - 4
controllers/dialysis_api_controller.go 파일 보기

@@ -2962,13 +2962,22 @@ func (c *DialysisApiController) GetDialysisOrder() {
2962 2962
 
2963 2963
 	check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2964 2964
 
2965
-	if adminUserInfo.CurrentOrgId != 10101 {
2965
+	if adminUserInfo.CurrentOrgId != 10101 && adminUserInfo.CurrentOrgId != 10445 {
2966 2966
 		dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2967 2967
 		patientInfo.TotalDialysis = dialysis_count
2968 2968
 	}
2969
-	if adminUserInfo.CurrentOrgId == 10101 {
2970
-		dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2971
-		patientInfo.TotalDialysis = dialysis_count
2969
+	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 {
2970
+
2971
+		if xttime <= 1640966400 {
2972
+			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2973
+			patientInfo.TotalDialysis = dialysis_count
2974
+		}
2975
+
2976
+		if xttime >= 1672502400 {
2977
+			dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2978
+			patientInfo.TotalDialysis = dialysis_count
2979
+		}
2980
+
2972 2981
 	}
2973 2982
 
2974 2983
 	//相关操作对应的操作人

+ 15 - 3
controllers/dialysis_record_api_controller.go 파일 보기

@@ -1010,10 +1010,22 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1010 1010
 	//更新患者表排班备注
1011 1011
 	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1012 1012
 
1013
-	//统计该患者总次数
1014
-	dialysisCount, _ := service.GetDialysisTotalCount(adminUserInfo.CurrentOrgId, patientID)
1013
+	////统计该患者总次数
1014
+	//dialysisCount, _ := service.GetDialysisTotalCount(adminUserInfo.CurrentOrgId, patientID)
1015
+	//
1016
+	//service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, dialysisCount.Count)
1017
+
1018
+	if adminUserInfo.CurrentOrgId != 10101 && adminUserInfo.CurrentOrgId != 10445 && adminUserInfo.CurrentOrgId != 3877 {
1019
+		//统计该患者总次数
1020
+		dialysisCount, _ := service.GetDialysisTotalCount(adminUserInfo.CurrentOrgId, patientID)
1021
+		service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, dialysisCount.Count)
1022
+	}
1015 1023
 
1016
-	service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, dialysisCount.Count)
1024
+	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 3877 {
1025
+		//统计该患者总次数
1026
+		dialysisCount, _ := service.GetDialysisTotalCountOne(adminUserInfo.CurrentOrgId, patientID)
1027
+		service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.CurrentOrgId, dialysisCount.Count)
1028
+	}
1017 1029
 
1018 1030
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1019 1031
 	redis := service.RedisClient()

+ 12 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go 파일 보기

@@ -2346,9 +2346,18 @@ func (this *DialysisAPIController) StartDialysis() {
2346 2346
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2347 2347
 		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
2348 2348
 
2349
-		//统计该患者总次数
2350
-		dialysisCount, _ := service.GetDialysisTotalCount(adminUserInfo.Org.Id, patientID)
2351
-		service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.Org.Id, dialysisCount.Count)
2349
+		if adminUserInfo.Org.Id != 10101 && adminUserInfo.Org.Id != 10445 && adminUserInfo.Org.Id != 3877 {
2350
+			//统计该患者总次数
2351
+			dialysisCount, _ := service.GetDialysisTotalCount(adminUserInfo.Org.Id, patientID)
2352
+			service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.Org.Id, dialysisCount.Count)
2353
+		}
2354
+
2355
+		if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 3877 {
2356
+			//统计该患者总次数
2357
+			dialysisCount, _ := service.GetDialysisTotalCountOne(adminUserInfo.Org.Id, patientID)
2358
+			service.UpdateDialysisOrder(patientID, recordDate.Unix(), adminUserInfo.Org.Id, dialysisCount.Count)
2359
+		}
2360
+
2352 2361
 		redis := service.RedisClient()
2353 2362
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2354 2363
 		redis.Set(key, "", time.Second)

+ 9 - 8
models/new_monitor.go 파일 보기

@@ -41,14 +41,15 @@ func (VMMonitorPatients) TableName() string {
41 41
 }
42 42
 
43 43
 type VMMonitorDialysisOrder struct {
44
-	ID           int64        `gorm:"column:id" json:"id"`
45
-	DialysisDate int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
46
-	UserOrgId    int64        `gorm:"column:user_org_id" json:"user_org_id"`
47
-	PatientId    int64        `gorm:"column:patient_id" json:"patient_id"`
48
-	BedID        int64        `gorm:"column:bed_id" json:"bed_id"`
49
-	Status       int64        `gorm:"column:status" json:"status"`
50
-	DeviceNumber DeviceNumber `gorm:"ForeignKey:BedId" json:"device_number"`
51
-	StartTime    int64        `gorm:"column:start_time" json:"start_time"`
44
+	ID            int64        `gorm:"column:id" json:"id"`
45
+	DialysisDate  int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
46
+	UserOrgId     int64        `gorm:"column:user_org_id" json:"user_org_id"`
47
+	PatientId     int64        `gorm:"column:patient_id" json:"patient_id"`
48
+	BedID         int64        `gorm:"column:bed_id" json:"bed_id"`
49
+	Status        int64        `gorm:"column:status" json:"status"`
50
+	DeviceNumber  DeviceNumber `gorm:"ForeignKey:BedId" json:"device_number"`
51
+	StartTime     int64        `gorm:"column:start_time" json:"start_time"`
52
+	DialysisTotal int64        `gorm:"column:dialysis_total" json:"dialysis_total" form:"dialysis_total"`
52 53
 }
53 54
 
54 55
 func (VMMonitorDialysisOrder) TableName() string {

+ 7 - 5
service/device_service.go 파일 보기

@@ -391,11 +391,13 @@ func UpdateDeviceGroup(group *models.DeviceGroup) error {
391 391
 //////// 机号 Number
392 392
 
393 393
 type DeviceNumberVM struct {
394
-	ID     int64  `gorm:"column:id" json:"id"`
395
-	OrgID  int64  `gorm:"column:org_id" json:"-"`
396
-	Number string `gorm:"column:number" json:"number"`
397
-	ZoneID int64  `gorm:"column:zone_id" json:"zone_id"`
398
-	Status int64  `gorm:"column:status" json:"status" form:"status"`
394
+	ID      int64  `gorm:"column:id" json:"id"`
395
+	OrgID   int64  `gorm:"column:org_id" json:"-"`
396
+	Number  string `gorm:"column:number" json:"number"`
397
+	ZoneID  int64  `gorm:"column:zone_id" json:"zone_id"`
398
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
399
+	Sort    int64  `gorm:"column:sort" json:"sort" form:"sort"`
400
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
399 401
 }
400 402
 
401 403
 func (DeviceNumberVM) TableName() string {

+ 15 - 0
service/mobile_dialysis_service.go 파일 보기

@@ -2755,6 +2755,11 @@ func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (
2755 2755
 	return
2756 2756
 }
2757 2757
 
2758
+func GetDialysisOrderCountTwo(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2759
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1672502400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2760
+	return
2761
+}
2762
+
2758 2763
 func GetFirstDateOfMonth(d time.Time) time.Time {
2759 2764
 	d = d.AddDate(0, 0, -d.Day()+1)
2760 2765
 	return GetZeroTime(d)
@@ -5199,6 +5204,16 @@ func GetDialysisTotalCount(org_id int64, patient_id int64) (models.BloodDialysis
5199 5204
 	return order, err
5200 5205
 }
5201 5206
 
5207
+func GetDialysisTotalCountOne(org_id int64, patient_id int64) (models.BloodDialysisOrderCount, error) {
5208
+
5209
+	order := models.BloodDialysisOrderCount{}
5210
+	db := XTReadDB().Table("xt_dialysis_order as o")
5211
+
5212
+	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule as x on x.patient_id = o.patient_id where o.status =1 and o.user_org_id = ? and o.patient_id = ? and o.dialysis_date>=1672502400 and  x.schedule_date = o.dialysis_date and x.status = 1 ", org_id, patient_id).Scan(&order).Error
5213
+
5214
+	return order, err
5215
+}
5216
+
5202 5217
 func UpdateDialysisOrder(patient_id int64, dialysis_date int64, user_org_id int64, dialysis_total int64) (models.DialysisOrder, error) {
5203 5218
 
5204 5219
 	order := models.DialysisOrder{}

+ 1 - 1
service/patient_service.go 파일 보기

@@ -2517,7 +2517,7 @@ func GetAllPatientListByListOne(orgID int64) (patients []*models.VMMonitorPatien
2517 2517
 	patient_info_str, _ := redis.Get(key).Result()
2518 2518
 
2519 2519
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2520
-		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2520
+		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1", orgID).Find(&patients).Error
2521 2521
 		if err != nil {
2522 2522
 			if err == gorm.ErrRecordNotFound {
2523 2523
 				return nil, nil