浏览代码

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

csx 3 年前
父节点
当前提交
78acb1d43d

+ 1 - 1
conf/app.conf 查看文件

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3
 runmode = dev
3
 runmode = dev
4
 
4
 
5
 #
5
 #

文件差异内容过多而无法显示
+ 985 - 889
controllers/his_api_controller.go


+ 2 - 1
controllers/manager_center_api_controller.go 查看文件

1682
 	good_kind, _ := c.GetInt64("good_kind")
1682
 	good_kind, _ := c.GetInt64("good_kind")
1683
 	is_mark, _ := c.GetInt64("is_mark")
1683
 	is_mark, _ := c.GetInt64("is_mark")
1684
 	manufacturer, _ := c.GetInt64("manufacturer")
1684
 	manufacturer, _ := c.GetInt64("manufacturer")
1685
+	is_type, _ := c.GetInt64("is_type")
1685
 	adminUserInfo := c.GetAdminUserInfo()
1686
 	adminUserInfo := c.GetAdminUserInfo()
1686
-	goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer)
1687
+	goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer, is_type)
1687
 	if err == nil {
1688
 	if err == nil {
1688
 		c.ServeSuccessJSON(map[string]interface{}{
1689
 		c.ServeSuccessJSON(map[string]interface{}{
1689
 			"list":  goodInfos,
1690
 			"list":  goodInfos,

+ 9 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

4705
 
4705
 
4706
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
4706
 				count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
4707
 
4707
 
4708
+				if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
4709
+					utils.ErrorLog("project_id")
4710
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4711
+					return
4712
+				}
4713
+				project_id := int64(items["project_id"].(float64))
4708
 				prepare := &models.DialysisBeforePrepareGoods{
4714
 				prepare := &models.DialysisBeforePrepareGoods{
4709
 					GoodId:     good_id,
4715
 					GoodId:     good_id,
4710
 					GoodTypeId: good_type_id,
4716
 					GoodTypeId: good_type_id,
4711
 					Count:      count,
4717
 					Count:      count,
4718
+					ProjectId:  project_id,
4712
 				}
4719
 				}
4713
 				beforePrepares = append(beforePrepares, prepare)
4720
 				beforePrepares = append(beforePrepares, prepare)
4714
 
4721
 
4716
 					GoodId:     good_id,
4723
 					GoodId:     good_id,
4717
 					GoodTypeId: good_type_id,
4724
 					GoodTypeId: good_type_id,
4718
 					Count:      count,
4725
 					Count:      count,
4726
+					ProjectId:  project_id,
4719
 				}
4727
 				}
4720
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4728
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4721
 			}
4729
 			}
4759
 			Creater:    adminInfo.AdminUser.Id,
4767
 			Creater:    adminInfo.AdminUser.Id,
4760
 			Status:     1,
4768
 			Status:     1,
4761
 			Ctime:      time.Now().Unix(),
4769
 			Ctime:      time.Now().Unix(),
4770
+			ProjectId:  item.ProjectId,
4762
 		}
4771
 		}
4763
 		//清空准备表的数据
4772
 		//清空准备表的数据
4764
 		err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4773
 		err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)

+ 1 - 1
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

636
 
636
 
637
 			fmt.Println("theTIME", theTime)
637
 			fmt.Println("theTIME", theTime)
638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
639
-			fmt.Println("keyFour323223323232323232", keyFour)
639
+
640
 			redis.Set(keyFour, "", time.Second)
640
 			redis.Set(keyFour, "", time.Second)
641
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
641
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
642
 			redis.Set(keyFive, "", time.Second)
642
 			redis.Set(keyFive, "", time.Second)

+ 3 - 0
models/dialysis.go 查看文件

1028
 	CommdityCode string                   `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1028
 	CommdityCode string                   `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1029
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1029
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1030
 	Children     []*DialysisBeforePrepare `gorm:"column:children" json:"children" form:"children"`
1030
 	Children     []*DialysisBeforePrepare `gorm:"column:children" json:"children" form:"children"`
1031
+	ProjectId    int64                    `gorm:"column:project_id" json:"project_id" form:"project_id"`
1031
 }
1032
 }
1032
 
1033
 
1033
 func (DialysisBeforePrepare) TableName() string {
1034
 func (DialysisBeforePrepare) TableName() string {
1040
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1041
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1041
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1042
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1042
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1043
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1044
+	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1043
 }
1045
 }
1044
 
1046
 
1045
 type NewDialysisBeforePrepareGoods struct {
1047
 type NewDialysisBeforePrepareGoods struct {
1049
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1051
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1050
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1052
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1051
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1053
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1054
+	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1052
 }
1055
 }
1053
 
1056
 
1054
 type QueueCallConfig struct {
1057
 type QueueCallConfig struct {

+ 1 - 0
models/dialysis_parameter_models.go 查看文件

95
 	GoodId                  int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
95
 	GoodId                  int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
97
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
97
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
98
+	ProjectId               int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
98
 }
99
 }
99
 
100
 
100
 func (BloodAutomaticReduceDetail) TableName() string {
101
 func (BloodAutomaticReduceDetail) TableName() string {

+ 14 - 0
models/stock_models.go 查看文件

232
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
232
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
233
 	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
233
 	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
234
 	ConsumableType          int64        `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
234
 	ConsumableType          int64        `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
235
+	ProjectId               int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
235
 }
236
 }
236
 
237
 
237
 func (WarehouseOutInfo) TableName() string {
238
 func (WarehouseOutInfo) TableName() string {
238
 	return "xt_warehouse_out_info"
239
 	return "xt_warehouse_out_info"
239
 }
240
 }
240
 
241
 
242
+type WarehouseOutInfoSeven struct {
243
+	ID    int64 `gorm:"column:id" json:"id"`
244
+	Count int64 `gorm:"column:count" json:"count"`
245
+}
246
+
247
+func (WarehouseOutInfoSeven) TableName() string {
248
+	return "xt_warehouse_out_info"
249
+}
250
+
241
 type SalesReturn struct {
251
 type SalesReturn struct {
242
 	ID           int64  `gorm:"column:id" json:"id"`
252
 	ID           int64  `gorm:"column:id" json:"id"`
243
 	OrderNumber  string `gorm:"column:order_number" json:"order_number"`
253
 	OrderNumber  string `gorm:"column:order_number" json:"order_number"`
372
 	Count                   int64               `gorm:"column:count" json:"count"`
382
 	Count                   int64               `gorm:"column:count" json:"count"`
373
 	Type                    int64               `gorm:"column:type" json:"type"`
383
 	Type                    int64               `gorm:"column:type" json:"type"`
374
 	WarehouseOutInfo        []*WarehouseOutInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"warehouseOutInfo"`
384
 	WarehouseOutInfo        []*WarehouseOutInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"warehouseOutInfo"`
385
+	ProjectId               int64               `gorm:"column:project_id" json:"project_id" form:"project_id"`
375
 }
386
 }
376
 
387
 
377
 func (AutomaticReduceDetail) TableName() string {
388
 func (AutomaticReduceDetail) TableName() string {
552
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
563
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
553
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
564
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
554
 	ReturnCount             int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
565
 	ReturnCount             int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
566
+	ProjectId               int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
555
 }
567
 }
556
 
568
 
557
 func (VmStockFlow) TableName() string {
569
 func (VmStockFlow) TableName() string {
583
 	WarehouseInfoId int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
595
 	WarehouseInfoId int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
584
 	GoodInfo        GoodInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
596
 	GoodInfo        GoodInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
585
 	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
597
 	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
598
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
599
+	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
586
 }
600
 }
587
 
601
 
588
 func (CancelStockInfo) TableName() string {
602
 func (CancelStockInfo) TableName() string {

+ 6 - 6
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go 查看文件

554
 }
554
 }
555
 
555
 
556
 type ScheduleVM struct {
556
 type ScheduleVM struct {
557
-	ID           int64 `gorm:"column:id" json:"id"`
558
-	PatientID    int64 `gorm:"column:patient_id" json:"patient_id"`
559
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
560
-	BedID        int64 `gorm:"column:bed_id" json:"bed_id"`
561
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
562
-
557
+	ID                       int64                            `gorm:"column:id" json:"id"`
558
+	PatientID                int64                            `gorm:"column:patient_id" json:"patient_id"`
559
+	ScheduleDate             int64                            `gorm:"column:schedule_date" json:"schedule_date"`
560
+	BedID                    int64                            `gorm:"column:bed_id" json:"bed_id"`
561
+	PartitionId              int64                            `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
563
 	Patient                  *PatientVM                       `gorm:"ForeignKey:PatientID" json:"patient"`
562
 	Patient                  *PatientVM                       `gorm:"ForeignKey:PatientID" json:"patient"`
564
 	DialysisOrder            DialysisOrderVM                  `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
563
 	DialysisOrder            DialysisOrderVM                  `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
565
 	Prescription             PrescriptionVM                   `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
564
 	Prescription             PrescriptionVM                   `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
576
 	LastAfterWeight          XtAssessmentAfterDislysisVM      `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
575
 	LastAfterWeight          XtAssessmentAfterDislysisVM      `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
577
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
576
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
578
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
577
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
578
+	Count                    int
579
 }
579
 }
580
 
580
 
581
 func (ScheduleVM) TableName() string {
581
 func (ScheduleVM) TableName() string {

+ 6 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go 查看文件

59
 	for _, item := range schedules {
59
 	for _, item := range schedules {
60
 
60
 
61
 		if orgID != 10101 {
61
 		if orgID != 10101 {
62
-			dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
62
+			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
63
 			item.Patient.TotalDialysis = dialysis_count
63
 			item.Patient.TotalDialysis = dialysis_count
64
 		}
64
 		}
65
 		if orgID == 10101 {
65
 		if orgID == 10101 {
207
 	return
207
 	return
208
 }
208
 }
209
 
209
 
210
+//func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64)(order []*models.DialysisOrder,err error) {
211
+// err = p_service.XTReadDB().Where("dialysis_date <= ? AND status = 1 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Find(&order).Error
212
+// return order,err
213
+//}
214
+
210
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
215
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
211
 	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
216
 	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
212
 	return
217
 	return

+ 38 - 6
service/stock_service.go 查看文件

259
 
259
 
260
 }
260
 }
261
 
261
 
262
-func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_use int64, is_charge int64, good_kind int64, is_mark int64, manufacturer int64) (list []*models.GoodInfo, total int64, err error) {
262
+func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_use int64, is_charge int64, good_kind int64, is_mark int64, manufacturer int64, is_type int64) (list []*models.GoodInfo, total int64, err error) {
263
 	offset := (page - 1) * limit
263
 	offset := (page - 1) * limit
264
 	db := readDb.Model(&models.GoodInfo{})
264
 	db := readDb.Model(&models.GoodInfo{})
265
 	db = db.Where("org_id = ? AND status = 1", orgId)
265
 	db = db.Where("org_id = ? AND status = 1", orgId)
291
 		if manufacturer > 0 {
291
 		if manufacturer > 0 {
292
 			db = db.Where("manufacturer = ?", manufacturer)
292
 			db = db.Where("manufacturer = ?", manufacturer)
293
 		}
293
 		}
294
+		if is_type > 0 {
295
+			db = db.Where("good_type_id = ?", is_type)
296
+		}
294
 	} else {
297
 	} else {
295
 		if is_use > 0 {
298
 		if is_use > 0 {
296
 			if is_use == 1 {
299
 			if is_use == 1 {
316
 		if manufacturer > 0 {
319
 		if manufacturer > 0 {
317
 			db = db.Where("manufacturer = ?", manufacturer)
320
 			db = db.Where("manufacturer = ?", manufacturer)
318
 		}
321
 		}
322
+		if is_type > 0 {
323
+			db = db.Where("good_type_id = ?", is_type)
324
+		}
319
 	}
325
 	}
320
 
326
 
321
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
327
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
3483
 	return err
3489
 	return err
3484
 }
3490
 }
3485
 
3491
 
3492
+func GetWarehosueOutByStockFlow(patient_id int64, recrod_date int64, goodid int64) (stockflow []*models.VmStockFlow, err error) {
3493
+
3494
+	err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and consumable_type = 3 and status = 1", patient_id, recrod_date, goodid).Find(&stockflow).Error
3495
+	return stockflow, err
3496
+}
3497
+
3486
 func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
3498
 func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
3487
 
3499
 
3488
 	detail := models.BloodAutomaticReduceDetail{}
3500
 	detail := models.BloodAutomaticReduceDetail{}
3491
 	err = XTWriteDB().Model(&info).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3503
 	err = XTWriteDB().Model(&info).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3492
 	prepare := models.DialysisBeforePrepare{}
3504
 	prepare := models.DialysisBeforePrepare{}
3493
 	err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3505
 	err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3506
+	flow := models.VmStockFlow{}
3507
+	err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3494
 	return err
3508
 	return err
3495
 
3509
 
3496
 }
3510
 }
3497
 
3511
 
3498
 func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3512
 func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3513
+
3499
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
3514
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
3500
 	return err
3515
 	return err
3501
 }
3516
 }
3502
 
3517
 
3518
+func GetCancelStockInfoByPatientId(patientid int64, goodid int64, record_date int64) (info []*models.CancelStockInfo, err error) {
3519
+
3520
+	err = XTReadDB().Where("patient_id = ? and good_id = ? and record_date = ? and status = 1", patientid, goodid, record_date).Find(&info).Error
3521
+	return info, err
3522
+}
3523
+
3524
+func GetHisPrepscritionByPatientId(patientid int64, goodid int64, record_date int64) (list []*models.HisPrescriptionProject, err error) {
3525
+
3526
+	err = XTReadDB().Where("patient_id = ? and project_id = ? and record_date = ? and status = 1", patientid, goodid, record_date).Find(&list).Error
3527
+	return list, err
3528
+}
3529
+
3503
 func UpDateWarehouStockFlowByStockDelete(id int64, recordtime int64, good_id int64, count int64, patient_id int64) (err error) {
3530
 func UpDateWarehouStockFlowByStockDelete(id int64, recordtime int64, good_id int64, count int64, patient_id int64) (err error) {
3504
 
3531
 
3505
 	err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and system_time = ? and good_id = ? and patient_id = ?", id, recordtime, good_id, patient_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3532
 	err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and system_time = ? and good_id = ? and patient_id = ?", id, recordtime, good_id, patient_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3525
 	return &autoreduece, nil
3552
 	return &autoreduece, nil
3526
 }
3553
 }
3527
 
3554
 
3528
-func GetAutoRecordByGoodId(goodid int64, patientid int64, recorddate int64) (models.WarehouseOutInfo, error) {
3529
-	detail := models.WarehouseOutInfo{}
3530
-	err := XTReadDB().Model(&detail).Where("good_id = ? and patient_id = ? and sys_record_time = ? and status = 1", goodid, patientid, recorddate).Find(&detail).Error
3555
+func GetAutoRecordByGoodIdSeven(goodid int64, patientid int64, recorddate int64) (models.WarehouseOutInfoSeven, error) {
3556
+	detail := models.WarehouseOutInfoSeven{}
3557
+	err := XTReadDB().Select("id,count").Where(" good_id = ? and sys_record_time = ?  and patient_id = ?  and status = 1", goodid, recorddate, patientid).Find(&detail).Error
3558
+	return detail, err
3559
+}
3560
+
3561
+func GetAutoRecordByGoodIdSevenEight(goodid int64, patientid int64, recorddate int64) (detail []*models.WarehouseOutInfoSeven, err error) {
3562
+	err = XTReadDB().Select("id,count").Where("good_id = ? and sys_record_time = ?  and patient_id = ?  and status = 1", goodid, recorddate, patientid).Find(&detail).Error
3531
 	return detail, err
3563
 	return detail, err
3532
 }
3564
 }
3533
 
3565
 
4700
 	return info, err
4732
 	return info, err
4701
 }
4733
 }
4702
 
4734
 
4703
-func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date int64) (models.DrugAutomaticReduceDetail, error) {
4735
+func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date int64, advice_id int64) (models.DrugAutomaticReduceDetail, error) {
4704
 	detail := models.DrugAutomaticReduceDetail{}
4736
 	detail := models.DrugAutomaticReduceDetail{}
4705
-	err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patient_id, advice_date).Last(&detail).Error
4737
+	err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, advice_date, advice_id).Last(&detail).Error
4706
 	return detail, err
4738
 	return detail, err
4707
 }
4739
 }
4708
 
4740
 

+ 46 - 17
service/warhouse_service.go 查看文件

580
 		var maxNumber int64 = 0
580
 		var maxNumber int64 = 0
581
 		var minNumber int64 = 0
581
 		var minNumber int64 = 0
582
 
582
 
583
-		//fmt.Println("deliver_number23332323232333232323233232323232",deliver_number)
584
 		maxNumber = deliver_number / drup.MinNumber
583
 		maxNumber = deliver_number / drup.MinNumber
585
-
586
-		if deliver_number <= drup.MinNumber {
587
-			minNumber = deliver_number % drup.MinNumber
588
-		} else {
589
-			minNumber = deliver_number
590
-		}
591
-
592
-		if deliver_number <= drup.MinNumber && warehouse.StockMaxNumber == 0 {
593
-			minNumber = deliver_number
594
-		}
584
+		minNumber = deliver_number % drup.MinNumber
595
 
585
 
596
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
586
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
597
 			minNumber = maxNumber
587
 			minNumber = maxNumber
602
 				return errors.New("库存数量不足")
592
 				return errors.New("库存数量不足")
603
 			}
593
 			}
604
 		}
594
 		}
595
+		if minNumber != 0 {
596
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
597
+		}
605
 
598
 
606
-		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
607
-		//fmt.Println("最大单位23323232323232332323233232323",warehouse.StockMaxNumber)
608
 		if warehouse.StockMaxNumber < 0 {
599
 		if warehouse.StockMaxNumber < 0 {
609
 			warehouse.StockMaxNumber = 0
600
 			warehouse.StockMaxNumber = 0
610
 		}
601
 		}
602
+		if warehouse.StockMinNumber < 0 {
603
+			warehouse.StockMinNumber = 0
604
+		}
611
 
605
 
612
 		warehouse.Mtime = time.Now().Unix()
606
 		warehouse.Mtime = time.Now().Unix()
613
-		//fmt.Println("最小单位2323223233232233233232323232323323232",warehouse.StockMinNumber)
614
-		//fmt.Println("最小换算量233232332322323322332323232332323223",minNumber)
607
+		fmt.Println("w23332233232232332", warehouse.StockMinNumber, minNumber)
608
+
615
 		if warehouse.StockMinNumber < minNumber {
609
 		if warehouse.StockMinNumber < minNumber {
610
+			fmt.Println("进来的风3232332322323")
616
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
611
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
617
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
612
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
618
 		} else {
613
 		} else {
619
-			//fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhh",warehouse.StockMinNumber,minNumber)
614
+			fmt.Println("进3232332322323")
620
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
615
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
621
-			//fmt.Println("我的魏2232332322323323",warehouse.StockMinNumber)
616
+		}
617
+
618
+		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
619
+			fmt.Println("2223232332322323", warehouse.StockMinNumber)
620
+			warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
621
+
622
 		}
622
 		}
623
 
623
 
624
 		if drup.MaxUnit != drup.MinUnit {
624
 		if drup.MaxUnit != drup.MinUnit {
626
 				return errors.New("库存数量不足")
626
 				return errors.New("库存数量不足")
627
 			}
627
 			}
628
 		}
628
 		}
629
+		if warehouse.StockMinNumber <= 0 {
630
+			warehouse.StockMinNumber = 0
631
+		}
629
 
632
 
630
 		//扣减库存232332332332
633
 		//扣减库存232332332332
631
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
634
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
1054
 				GoodTypeId: item.GoodTypeId,
1057
 				GoodTypeId: item.GoodTypeId,
1055
 				GoodId:     item.GoodId,
1058
 				GoodId:     item.GoodId,
1056
 				Count:      item.Count,
1059
 				Count:      item.Count,
1060
+				ProjectId:  item.ProjectId,
1057
 			}
1061
 			}
1058
 
1062
 
1059
 			ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
1063
 			ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
1074
 //耗材出库
1078
 //耗材出库
1075
 func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
1079
 func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
1076
 
1080
 
1081
+	fmt.Println("count23323223233232323232332232323", count, goods.Count)
1077
 	var deliver_number int64 = 0
1082
 	var deliver_number int64 = 0
1078
 	var stock_number int64 = 0
1083
 	var stock_number int64 = 0
1079
 	var maxNumber int64 = 0
1084
 	var maxNumber int64 = 0
1116
 			Price:                   info.PackingPrice,
1121
 			Price:                   info.PackingPrice,
1117
 			ExpiryDate:              warehouse.ExpiryDate,
1122
 			ExpiryDate:              warehouse.ExpiryDate,
1118
 			ProductDate:             warehouse.ProductDate,
1123
 			ProductDate:             warehouse.ProductDate,
1124
+			ProjectId:               goods.ProjectId,
1119
 		}
1125
 		}
1120
 		warehouseOutInfo.Count = count
1126
 		warehouseOutInfo.Count = count
1121
 
1127
 
1141
 			GoodId:                  goods.GoodId,
1147
 			GoodId:                  goods.GoodId,
1142
 			GoodTypeId:              goods.GoodTypeId,
1148
 			GoodTypeId:              goods.GoodTypeId,
1143
 			Count:                   count,
1149
 			Count:                   count,
1150
+			ProjectId:               goods.ProjectId,
1144
 		}
1151
 		}
1145
 		//查询当天耗材是否已经存在数据
1152
 		//查询当天耗材是否已经存在数据
1146
 		_, errcode := GetAutoMaticReduceDetail(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1153
 		_, errcode := GetAutoMaticReduceDetail(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1174
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1181
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1175
 				IsSys:                   1,
1182
 				IsSys:                   1,
1176
 				PatientId:               patient_id,
1183
 				PatientId:               patient_id,
1184
+				ProjectId:               goods.ProjectId,
1177
 			}
1185
 			}
1178
 			//查询流水是否存在
1186
 			//查询流水是否存在
1179
 			exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1187
 			exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1209
 					IsSys:                   1,
1217
 					IsSys:                   1,
1210
 					PatientId:               patient_id,
1218
 					PatientId:               patient_id,
1211
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1219
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1220
+					ProjectId:               goods.ProjectId,
1212
 				}
1221
 				}
1213
 
1222
 
1214
 				errFour := UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1223
 				errFour := UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1241
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1250
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1242
 				IsSys:                   1,
1251
 				IsSys:                   1,
1243
 				PatientId:               patient_id,
1252
 				PatientId:               patient_id,
1253
+				ProjectId:               goods.ProjectId,
1244
 			}
1254
 			}
1245
 			//查询流水是否存在
1255
 			//查询流水是否存在
1246
 			exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1256
 			exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1275
 					IsSys:                   1,
1285
 					IsSys:                   1,
1276
 					PatientId:               patient_id,
1286
 					PatientId:               patient_id,
1277
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1287
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1288
+					ProjectId:               goods.ProjectId,
1278
 				}
1289
 				}
1279
 				//UpdatedStockFlow(flow)
1290
 				//UpdatedStockFlow(flow)
1280
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1291
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1327
 			Price:                   info.PackingPrice,
1338
 			Price:                   info.PackingPrice,
1328
 			ExpiryDate:              warehouse.ExpiryDate,
1339
 			ExpiryDate:              warehouse.ExpiryDate,
1329
 			ProductDate:             warehouse.ProductDate,
1340
 			ProductDate:             warehouse.ProductDate,
1341
+			ProjectId:               goods.ProjectId,
1330
 		}
1342
 		}
1331
 		warehouseOutInfo.Count = stock_number
1343
 		warehouseOutInfo.Count = stock_number
1332
 
1344
 
1362
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1374
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1363
 				IsSys:                   1,
1375
 				IsSys:                   1,
1364
 				PatientId:               patient_id,
1376
 				PatientId:               patient_id,
1377
+				ProjectId:               goods.ProjectId,
1365
 			}
1378
 			}
1366
 			//查询流水是否存在
1379
 			//查询流水是否存在
1367
 			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1380
 			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1394
 					IsSys:                   1,
1407
 					IsSys:                   1,
1395
 					PatientId:               patient_id,
1408
 					PatientId:               patient_id,
1396
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1409
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1410
+					ProjectId:               goods.ProjectId,
1397
 				}
1411
 				}
1398
 				//UpdatedStockFlow(flow)
1412
 				//UpdatedStockFlow(flow)
1399
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1413
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1429
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1443
 				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1430
 				IsSys:                   1,
1444
 				IsSys:                   1,
1431
 				PatientId:               patient_id,
1445
 				PatientId:               patient_id,
1446
+				ProjectId:               goods.ProjectId,
1432
 			}
1447
 			}
1433
 			//查询流水是否存在
1448
 			//查询流水是否存在
1434
 			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1449
 			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1460
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1475
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1461
 					IsSys:                   1,
1476
 					IsSys:                   1,
1462
 					PatientId:               patient_id,
1477
 					PatientId:               patient_id,
1478
+					ProjectId:               goods.ProjectId,
1463
 				}
1479
 				}
1464
 				//UpdatedStockFlow(flow)
1480
 				//UpdatedStockFlow(flow)
1465
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1481
 				UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
1976
 			PatientId:               advice.PatientId,
1992
 			PatientId:               advice.PatientId,
1977
 			Count:                   deliver_number, //出最小单位
1993
 			Count:                   deliver_number, //出最小单位
1978
 			WarehouseInfoId:         warehouse.ID,
1994
 			WarehouseInfoId:         warehouse.ID,
1995
+			AdviceId:                advice.ID,
1979
 		}
1996
 		}
1980
 
1997
 
1981
 		drugflow := models.DrugFlow{
1998
 		drugflow := models.DrugFlow{
2000
 			IsSys:                   1,
2017
 			IsSys:                   1,
2001
 			PatientId:               advice.PatientId,
2018
 			PatientId:               advice.PatientId,
2002
 			WarehousingDetailId:     warehouse.ID,
2019
 			WarehousingDetailId:     warehouse.ID,
2020
+			AdviceId:                advice.ID,
2003
 		}
2021
 		}
2004
 
2022
 
2005
 		CreateDrugFlowOne(drugflow)
2023
 		CreateDrugFlowOne(drugflow)
2099
 			PatientId:               advice.PatientId,
2117
 			PatientId:               advice.PatientId,
2100
 			Count:                   deliver_number,
2118
 			Count:                   deliver_number,
2101
 			WarehouseInfoId:         warehouse.ID,
2119
 			WarehouseInfoId:         warehouse.ID,
2120
+			AdviceId:                advice.ID,
2102
 		}
2121
 		}
2103
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
2122
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
2104
 		if errOne != nil {
2123
 		if errOne != nil {
2196
 			IsSys:                   1,
2215
 			IsSys:                   1,
2197
 			PatientId:               advice.PatientId,
2216
 			PatientId:               advice.PatientId,
2198
 			WarehousingDetailId:     warehouse.ID,
2217
 			WarehousingDetailId:     warehouse.ID,
2218
+			AdviceId:                advice.ID,
2199
 		}
2219
 		}
2200
 
2220
 
2201
 		CreateDrugFlowOne(drugflow)
2221
 		CreateDrugFlowOne(drugflow)
2280
 			PatientId:               advice.PatientId,
2300
 			PatientId:               advice.PatientId,
2281
 			WarehouseInfoId:         warehouse.ID,
2301
 			WarehouseInfoId:         warehouse.ID,
2282
 			Count:                   deliver_number,
2302
 			Count:                   deliver_number,
2303
+			AdviceId:                advice.ID,
2283
 		}
2304
 		}
2284
 
2305
 
2285
 		drugflow := models.DrugFlow{
2306
 		drugflow := models.DrugFlow{
2305
 			PatientId:               advice.PatientId,
2326
 			PatientId:               advice.PatientId,
2306
 			SystemTime:              advice.RecordDate,
2327
 			SystemTime:              advice.RecordDate,
2307
 			WarehousingDetailId:     warehouse.ID,
2328
 			WarehousingDetailId:     warehouse.ID,
2329
+			AdviceId:                advice.ID,
2308
 		}
2330
 		}
2309
 
2331
 
2310
 		CreateDrugFlowOne(drugflow)
2332
 		CreateDrugFlowOne(drugflow)
2326
 			Count:                   deliver_number,
2348
 			Count:                   deliver_number,
2327
 			CountUnit:               drup.MinUnit,
2349
 			CountUnit:               drup.MinUnit,
2328
 			WarehouseInfoId:         warehouse.ID,
2350
 			WarehouseInfoId:         warehouse.ID,
2351
+			AdviceId:                advice.ID,
2329
 		}
2352
 		}
2330
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
2353
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
2331
 		if errTwo != nil {
2354
 		if errTwo != nil {
2361
 		if warehouse.StockMaxNumber < 0 {
2384
 		if warehouse.StockMaxNumber < 0 {
2362
 			return errors.New("库存数量不足")
2385
 			return errors.New("库存数量不足")
2363
 		}
2386
 		}
2387
+		if warehouse.StockMinNumber <= 0 {
2388
+			warehouse.StockMinNumber = 0
2389
+		}
2364
 
2390
 
2365
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2391
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2366
 
2392
 
2394
 			WarehouseInfoId:         warehouse.ID,
2420
 			WarehouseInfoId:         warehouse.ID,
2395
 			Count:                   deliver_number,
2421
 			Count:                   deliver_number,
2396
 			CountUnit:               drup.MinUnit,
2422
 			CountUnit:               drup.MinUnit,
2423
+			AdviceId:                advice.ID,
2397
 		}
2424
 		}
2398
 
2425
 
2399
 		drugflow := models.DrugFlow{
2426
 		drugflow := models.DrugFlow{
2419
 			PatientId:               advice.PatientId,
2446
 			PatientId:               advice.PatientId,
2420
 			SystemTime:              advice.RecordDate,
2447
 			SystemTime:              advice.RecordDate,
2421
 			WarehousingDetailId:     warehouse.ID,
2448
 			WarehousingDetailId:     warehouse.ID,
2449
+			AdviceId:                advice.ID,
2422
 		}
2450
 		}
2423
 
2451
 
2424
 		CreateDrugFlowOne(drugflow)
2452
 		CreateDrugFlowOne(drugflow)
2440
 			Count:                   deliver_number,
2468
 			Count:                   deliver_number,
2441
 			CountUnit:               drup.MinUnit,
2469
 			CountUnit:               drup.MinUnit,
2442
 			WarehouseInfoId:         warehouse.ID,
2470
 			WarehouseInfoId:         warehouse.ID,
2471
+			AdviceId:                advice.ID,
2443
 		}
2472
 		}
2444
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
2473
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
2445
 		if errTwo != nil {
2474
 		if errTwo != nil {