소스 검색

11月8日库存管理

XMLWAN 3 년 전
부모
커밋
5cec7dfc86

+ 19 - 0
controllers/self_drug_api_congtroller.go 파일 보기

@@ -83,6 +83,8 @@ func SelfDrugRouters() {
83 83
 	beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
84 84
 
85 85
 	beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
86
+
87
+	beego.Router("/api/drug/getinventorymodelist", &SelfDrugApiController{}, "Get:GetInventoryModeList")
86 88
 }
87 89
 
88 90
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -2607,3 +2609,20 @@ func (this *SelfDrugApiController) GetDamageByDrugId() {
2607 2609
 		"list": list,
2608 2610
 	})
2609 2611
 }
2612
+
2613
+func (this *SelfDrugApiController) GetInventoryModeList() {
2614
+
2615
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2616
+
2617
+	list, err := service.GetInventoryModeList(orgId)
2618
+	manufacturerList, err := service.GetAllManufacturerList(orgId)
2619
+	if err != nil {
2620
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2621
+		return
2622
+	}
2623
+
2624
+	this.ServeSuccessJSON(map[string]interface{}{
2625
+		"list":             list,
2626
+		"manufacturerList": manufacturerList,
2627
+	})
2628
+}

+ 10 - 9
models/device_models.go 파일 보기

@@ -140,15 +140,16 @@ func (DeviceGroup) TableName() string {
140 140
 }
141 141
 
142 142
 type DeviceNumber struct {
143
-	ID         int64  `gorm:"column:id" json:"id"`
144
-	OrgID      int64  `gorm:"column:org_id" json:"-"`
145
-	Number     string `gorm:"column:number" json:"number"`
146
-	GroupID    int64  `gorm:"column:group_id" json:"group_id"`
147
-	ZoneID     int64  `gorm:"column:zone_id" json:"zone_id"`
148
-	Status     int8   `json:"-"`
149
-	CreateTime int64  `gorm:"column:ctime" json:"-"`
150
-	ModifyTime int64  `gorm:"column:mtime" json:"-"`
151
-	Sort       int64  `gorm:"column:sort" json:"sort" form:"sort"`
143
+	ID         int64      `gorm:"column:id" json:"id"`
144
+	OrgID      int64      `gorm:"column:org_id" json:"-"`
145
+	Number     string     `gorm:"column:number" json:"number"`
146
+	GroupID    int64      `gorm:"column:group_id" json:"group_id"`
147
+	ZoneID     int64      `gorm:"column:zone_id" json:"zone_id"`
148
+	Status     int8       `json:"-"`
149
+	CreateTime int64      `gorm:"column:ctime" json:"-"`
150
+	ModifyTime int64      `gorm:"column:mtime" json:"-"`
151
+	Sort       int64      `gorm:"column:sort" json:"sort" form:"sort"`
152
+	DeviceZone DeviceZone `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:ZoneID;"`
152 153
 }
153 154
 
154 155
 func (DeviceNumber) TableName() string {

+ 6 - 8
models/schedule_models.go 파일 보기

@@ -190,14 +190,13 @@ type VmSchedulesRemind struct {
190 190
 
191 191
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
192 192
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
193
-	DialysisOrder              DialysisOrder              `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
193
+	DialysisOrder              DialysisOrder              `json:"order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
194 194
 	XtPatients                 XtPatients                 `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
195
-	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
196
-	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
197
-	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
198
-	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
199
-	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
200
-	Solution                   []*DialysisSolution        `json:"solution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
195
+	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
196
+	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
197
+	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
198
+	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
199
+	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
201 200
 }
202 201
 
203 202
 func (VmSchedulesRemind) TableName() string {
@@ -225,7 +224,6 @@ type WeekScheduleSix struct {
225 224
 	DialysisPrescription       DialysisSolution           `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
226 225
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
227 226
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
228
-	Solution                   []*DialysisSolution        `json:"solution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
229 227
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
230 228
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
231 229
 }

+ 18 - 0
models/self_drug_models.go 파일 보기

@@ -936,3 +936,21 @@ type SgjDrugWarehouseOutInfo struct {
936 936
 func (SgjDrugWarehouseOutInfo) TableName() string {
937 937
 	return "xt_drug_warehouse_out_info"
938 938
 }
939
+
940
+type PatientDrugWarehouseInfo struct {
941
+	DrugId         int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
942
+	Number         string  `gorm:"column:number" json:"number" form:"number"`
943
+	ProductDate    int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
944
+	ExpiryDate     int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
945
+	StockMaxNumber int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
946
+	StockMinNumber int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
947
+	BatchNumber    string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
948
+	DrugName       string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
949
+	MaxUnit        string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
950
+	MinUnit        string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
951
+	MinNumber      int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
952
+	Dose           float64 `gorm:"column:dose" json:"dose" form:"dose"`
953
+	DoseUnit       string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
954
+	Manufacturer   int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
955
+	Dealer         int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
956
+}

+ 3 - 2
service/doctor_schedule_service.go 파일 보기

@@ -648,8 +648,9 @@ func GetSearchPatient(keywords string, orgid int64, startime int64) (schedule []
648 648
 
649 649
 	likeKey := "%" + keywords + "%"
650 650
 	db := XTReadDB().Table("xt_schedule as s")
651
-	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", "status= 1").
652
-		Preload("DialysisOrder", "status =1").
651
+	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
652
+		return db.Where("status =1").Preload("DeviceZone", "status = 1")
653
+	}).Preload("DialysisOrder", "status =1").
653 654
 		Joins("JOIN xt_patients as p ON p.id = s.patient_id And(p.name LIKE ? OR p.dialysis_no LIKE ?)", likeKey, likeKey).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
654 655
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
655 656
 	return schedule, err

+ 6 - 12
service/schedule_service.go 파일 보기

@@ -605,12 +605,10 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
605 605
 		db = db.Where("x.partition_id in (?)", zone)
606 606
 	}
607 607
 
608
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("XtAssessmentBeforeDislysis", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
609
-		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
610
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
608
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date = ?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
609
+		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
610
+	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date =?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
611 611
 		return db.Where("status =1").Order("id asc")
612
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
613
-		return db.Where("status =1").Group("patient_id,mode_id").Order("id asc")
614 612
 	}).Find(&list).Error
615 613
 
616 614
 	return list, err
@@ -632,12 +630,10 @@ func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int
632 630
 		db = db.Where("x.partition_id in (?)", zone)
633 631
 	}
634 632
 
635
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("XtAssessmentBeforeDislysis", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
636
-		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
637
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
633
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
634
+		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
635
+	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
638 636
 		return db.Where("status =1").Order("id asc")
639
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
640
-		return db.Where("status =1").Group("patient_id,mode_id").Order("id desc")
641 637
 	}).Find(&list).Error
642 638
 
643 639
 	return list, err
@@ -824,8 +820,6 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
824 820
 			return db.Where("status = 1").Order("id asc")
825 821
 		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
826 822
 		return db.Where("status = 1").Order("id asc")
827
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
828
-		return db.Where("status = 1").Group("patient_id,mode_id").Order("id asc")
829 823
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
830 824
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
831 825
 	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").

+ 12 - 0
service/self_drug_service.go 파일 보기

@@ -1144,3 +1144,15 @@ func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (dr
1144 1144
 	err = db.Preload("XtBaseDrug", "status = 1").Find(&drug).Error
1145 1145
 	return drug, err
1146 1146
 }
1147
+
1148
+func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo, err error) {
1149
+
1150
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1151
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
1152
+	fmt.Println(table)
1153
+	if orgid > 0 {
1154
+		db = db.Where("x.org_id = ?", orgid)
1155
+	}
1156
+	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").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1157
+	return info, err
1158
+}