Browse Source

库存流水展示

XMLWAN 2 years ago
parent
commit
fc94889929

+ 5 - 2
controllers/dialysis_api_controller.go View File

@@ -6034,14 +6034,17 @@ func (this *DialysisApiController) GetDialysisAdviceToday() {
6034 6034
 
6035 6035
 	schedule_type, _ := this.GetInt64("schedule_type")
6036 6036
 
6037
-	partion_type, _ := this.GetInt64("partion_type")
6037
+	//partion_type, _ := this.GetInt64("partion_type")
6038 6038
 
6039
+	partion_type := this.GetString("partion_type")
6040
+	var ids []string
6041
+	ids = strings.Split(partion_type, ",")
6039 6042
 	start_time := this.GetString("selected_date")
6040 6043
 	timeLayout := "2006-01-02"
6041 6044
 	loc, _ := time.LoadLocation("Local")
6042 6045
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6043 6046
 
6044
-	list, err := service.GetDialysisAdviceSchedulistTen(orgId, schedule_type, partion_type, startTime.Unix())
6047
+	list, err := service.GetDialysisAdviceSchedulistTen(orgId, schedule_type, ids, startTime.Unix())
6045 6048
 
6046 6049
 	drug, _ := service.GetAllBaseDrugListTwenty(orgId)
6047 6050
 	_, config := service.FindXTHisRecordByOrgId(orgId)

+ 5 - 2
controllers/print_data_api_controller.go View File

@@ -37,7 +37,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
37 37
 	idStrs := strings.Split(schIDStr, ",")
38 38
 	adminUserInfo := this.GetAdminUserInfo()
39 39
 
40
-	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 {
40
+	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 {
41 41
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42 42
 		for _, item := range schedules {
43 43
 
@@ -136,7 +136,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
136 136
 		})
137 137
 	}
138 138
 
139
-	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 {
139
+	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 && this.GetAdminUserInfo().CurrentOrgId != 10188 && this.GetAdminUserInfo().CurrentOrgId != 10217 && this.GetAdminUserInfo().CurrentOrgId != 10340 {
140 140
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
141 141
 		for _, item := range schedules {
142 142
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
@@ -259,6 +259,8 @@ func (this *PrintDataAPIController) CourseRecordPrintData() {
259 259
 	patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
260 260
 
261 261
 	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
262
+
263
+	operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId)
262 264
 	if err != nil {
263 265
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
264 266
 		return
@@ -267,6 +269,7 @@ func (this *PrintDataAPIController) CourseRecordPrintData() {
267 269
 			"record":    record,
268 270
 			"patient":   patient,
269 271
 			"adminUser": adminUser,
272
+			"operators": operators,
270 273
 		})
271 274
 	}
272 275
 }

+ 3 - 3
service/dialysis_solution_service.go View File

@@ -495,7 +495,7 @@ func GetDialysisAdviceSchedulistSeven(orgID int64, schedule_type int64, partitio
495 495
 
496 496
 }
497 497
 
498
-func GetDialysisAdviceSchedulistTen(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
498
+func GetDialysisAdviceSchedulistTen(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
499 499
 
500 500
 	db := XTReadDB().Model(&models.VmBloodScheduleOne{}).Where("status = 1")
501 501
 
@@ -505,8 +505,8 @@ func GetDialysisAdviceSchedulistTen(orgID int64, schedule_type int64, partition_
505 505
 	if schedule_type > 0 {
506 506
 		db = db.Where("schedule_type = ?", schedule_type)
507 507
 	}
508
-	if partition_id > 0 {
509
-		db = db.Where("partition_id = ?", partition_id)
508
+	if len(partition_id) > 0 {
509
+		db = db.Where("partition_id in(?)", partition_id)
510 510
 	}
511 511
 
512 512
 	if orgID > 0 {

+ 45 - 41
service/pharmacy_service.go View File

@@ -646,7 +646,7 @@ func DispensingMedicine(orgid, patient_id, stime, etime, creater int64) (err err
646 646
 			if PettyCash(v.DrugId) {
647 647
 				continue
648 648
 			}
649
-			//判断药品库存是否充足
649
+			////判断药品库存是否充足
650 650
 			kou := FenDrugInventory(v, orgid)
651 651
 			if !kou {
652 652
 				err = fmt.Errorf(FindDrugsName(v.DrugId) + "库存不足")
@@ -675,48 +675,52 @@ func DispensingMedicine(orgid, patient_id, stime, etime, creater int64) (err err
675 675
 		return err1
676 676
 	}
677 677
 
678
-	err = tx.Raw("select id from xt_doctor_advice where status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and "+
679
-		"user_org_id = ? and patient_id = ? and is_medicine = 0 and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, orgid).Scan(&xids).Error
680
-	if err != nil {
681
-		return
682
-	}
683
-	xid := make([]int64, 0)
684
-	for _, v := range xids {
685
-		xid = append(xid, v.Id)
686
-	}
687
-	var advice []*models.HisDoctorAdviceInfo
688
-	err = tx.Raw("select * from xt_doctor_advice where id in (?) and status = 1", xid).Scan(&advice).Error
689
-	if err != nil {
690
-		return
691
-	}
692
-	for _, v := range advice {
693
-		tmp_bool := IsPharmacyConfig(orgid)
694
-		if tmp_bool {
695
-			if PettyCash(v.DrugId) {
696
-				continue
697
-			}
698
-			kou := FenDrugInventory(v, orgid)
699
-			if !kou {
700
-				err = fmt.Errorf(FindDrugsName(v.DrugId) + "库存不足")
701
-				return
702
-			}
703
-			//扣减库存
704
-			err = FenStock(orgid, creater, v)
705
-			if err != nil {
706
-				err = fmt.Errorf("!:%v", err)
707
-				return
678
+	//针对大丰响水
679
+	if orgid != 10217 && orgid != 10188 && orgid != 9671 && orgid != 10164 {
680
+		err = tx.Raw("select id from xt_doctor_advice where status = 1 and (advice_type = 2 or advice_type = 3) and advice_date >= ? and advice_date <= ? and "+
681
+			"user_org_id = ? and patient_id = ? and is_medicine = 0 and drug_id in (select id from xt_base_drug where org_id = ? and is_pharmacy = 1)", stime, etime, orgid, patient_id, orgid).Scan(&xids).Error
682
+		if err != nil {
683
+			return
684
+		}
685
+		xid := make([]int64, 0)
686
+		for _, v := range xids {
687
+			xid = append(xid, v.Id)
688
+		}
689
+		var advice []*models.HisDoctorAdviceInfo
690
+		err = tx.Raw("select * from xt_doctor_advice where id in (?) and status = 1", xid).Scan(&advice).Error
691
+		if err != nil {
692
+			return
693
+		}
694
+
695
+		for _, v := range advice {
696
+			tmp_bool := IsPharmacyConfig(orgid)
697
+			if tmp_bool {
698
+				if PettyCash(v.DrugId) {
699
+					continue
700
+				}
701
+				kou := FenDrugInventory(v, orgid)
702
+				if !kou {
703
+					err = fmt.Errorf(FindDrugsName(v.DrugId) + "库存不足")
704
+					return
705
+				}
706
+				//扣减库存
707
+				err = FenStock(orgid, creater, v)
708
+				if err != nil {
709
+					err = fmt.Errorf("!:%v", err)
710
+					return
711
+				}
708 712
 			}
709 713
 		}
710
-	}
711
-	//修改状态
712
-	errs1 := XTWriteDB().Model(&models.XtDoctorAdviceL{}).Where("id in (?)", xid).Updates(map[string]interface{}{
713
-		"is_medicine":     1,
714
-		"people":          0,
715
-		"dispensing_time": time_now,
716
-		"updated_time":    time.Now().Unix(),
717
-	}).Error
718
-	if errs1 != nil {
719
-		return errs1
714
+		//修改状态
715
+		errs1 := XTWriteDB().Model(&models.XtDoctorAdviceL{}).Where("id in (?)", xid).Updates(map[string]interface{}{
716
+			"is_medicine":     1,
717
+			"people":          0,
718
+			"dispensing_time": time_now,
719
+			"updated_time":    time.Now().Unix(),
720
+		}).Error
721
+		if errs1 != nil {
722
+			return errs1
723
+		}
720 724
 	}
721 725
 
722 726
 	//生成明细记录

+ 1 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -104,6 +104,7 @@ type DialysisOrderVM struct {
104 104
 	WashpipeNurse  int64           `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
105 105
 	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
106 106
 	QualityNurseId int64           `gorm:"column:quality_nurse_id" json:"quality_nurse_id" form:"quality_nurse_id"`
107
+	Url            string          `gorm:"column:url" json:"url" form:"url"`
107 108
 }
108 109
 
109 110
 func (DialysisOrderVM) TableName() string {

+ 8 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -479,3 +479,11 @@ func GetBatchSummerVM(orgid int64, patient_id int64, assessment_date int64) (*Su
479 479
 	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and assessment_date =? and status = 1", orgid, patient_id, assessment_date).Find(&SummerVM).Error
480 480
 	return &SummerVM, err
481 481
 }
482
+
483
+func GetAdminUserEsTwo(orgid int64) (admin []*models.UserAdminRoles, err error) {
484
+	db := p_service.UserReadDB().Table("sgj_user_admin_role as x").Where("x.status =1")
485
+	table := p_service.UserReadDB().Table("sgj_user_admin_electronic_signature as s")
486
+	fmt.Println("table", table)
487
+	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ?", orgid).Scan(&admin).Error
488
+	return admin, err
489
+}

+ 4 - 4
service/schedule_service.go View File

@@ -356,7 +356,7 @@ func UpdateScheduleOne(id int64, schedule models.Schedule) error {
356 356
 }
357 357
 
358 358
 // 参数一:当前操作的患者的排班     参数二被替换床位对应的排班
359
-func UpdateScheduleTwo(schone models.Schedule, schtwo models.Schedule) error {
359
+func UpdateScheduleTwo(schone models.Schedule, schtwo models.Schedule) (err error) {
360 360
 	utx := XTWriteDB().Begin()
361 361
 	//床位
362 362
 	var tempBedID int64
@@ -388,12 +388,12 @@ func UpdateScheduleTwo(schone models.Schedule, schtwo models.Schedule) error {
388 388
 	schone.ScheduleType = tempTypeTwo
389 389
 	schtwo.ScheduleType = tempTypeID
390 390
 
391
-	if err := utx.Model(&models.Schedule{}).Where("id = ?", schone.ID).Updates(map[string]interface{}{"partition_id": schone.PartitionId, "bed_id": schone.BedId, "schedule_type": schone.ScheduleType, "is_export": 90000}).Error; err != nil {
391
+	if err = utx.Model(&models.Schedule{}).Where("id = ?", schone.ID).Updates(map[string]interface{}{"partition_id": schone.PartitionId, "bed_id": schone.BedId, "schedule_type": schone.ScheduleType, "is_export": 90000}).Error; err != nil {
392 392
 		utx.Rollback()
393 393
 		return err
394 394
 	}
395 395
 
396
-	if err := utx.Model(&models.Schedule{}).Where("id = ?", schtwo.ID).Updates(map[string]interface{}{"partition_id": schtwo.PartitionId, "bed_id": schtwo.BedId, "schedule_type": schtwo.ScheduleType, "is_export": 90000}).Error; err != nil {
396
+	if err = utx.Model(&models.Schedule{}).Where("id = ?", schtwo.ID).Updates(map[string]interface{}{"partition_id": schtwo.PartitionId, "bed_id": schtwo.BedId, "schedule_type": schtwo.ScheduleType, "is_export": 90000}).Error; err != nil {
397 397
 		utx.Rollback()
398 398
 		return err
399 399
 	}
@@ -401,7 +401,7 @@ func UpdateScheduleTwo(schone models.Schedule, schtwo models.Schedule) error {
401 401
 	return err
402 402
 }
403 403
 
404
-func UpdateScheduleThree(schone *models.Schedule, schtwo *models.Schedule) error {
404
+func UpdateScheduleThree(schone *models.Schedule, schtwo *models.Schedule) (err error) {
405 405
 	utx := XTWriteDB().Begin()
406 406
 	//床位
407 407
 	var tempBedID int64