Преглед на файлове

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

csx преди 3 години
родител
ревизия
78acb1d43d

+ 1 - 1
conf/app.conf Целия файл

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

Файловите разлики са ограничени, защото са твърде много
+ 985 - 889
controllers/his_api_controller.go


+ 2 - 1
controllers/manager_center_api_controller.go Целия файл

@@ -1682,8 +1682,9 @@ func (c *ManagerCenterApiController) GetGoodInfoList() {
1682 1682
 	good_kind, _ := c.GetInt64("good_kind")
1683 1683
 	is_mark, _ := c.GetInt64("is_mark")
1684 1684
 	manufacturer, _ := c.GetInt64("manufacturer")
1685
+	is_type, _ := c.GetInt64("is_type")
1685 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 1688
 	if err == nil {
1688 1689
 		c.ServeSuccessJSON(map[string]interface{}{
1689 1690
 			"list":  goodInfos,

+ 9 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Целия файл

@@ -4705,10 +4705,17 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4705 4705
 
4706 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 4714
 				prepare := &models.DialysisBeforePrepareGoods{
4709 4715
 					GoodId:     good_id,
4710 4716
 					GoodTypeId: good_type_id,
4711 4717
 					Count:      count,
4718
+					ProjectId:  project_id,
4712 4719
 				}
4713 4720
 				beforePrepares = append(beforePrepares, prepare)
4714 4721
 
@@ -4716,6 +4723,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4716 4723
 					GoodId:     good_id,
4717 4724
 					GoodTypeId: good_type_id,
4718 4725
 					Count:      count,
4726
+					ProjectId:  project_id,
4719 4727
 				}
4720 4728
 				newBeforePrepares = append(newBeforePrepares, newPrepare)
4721 4729
 			}
@@ -4759,6 +4767,7 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4759 4767
 			Creater:    adminInfo.AdminUser.Id,
4760 4768
 			Status:     1,
4761 4769
 			Ctime:      time.Now().Unix(),
4770
+			ProjectId:  item.ProjectId,
4762 4771
 		}
4763 4772
 		//清空准备表的数据
4764 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,7 +636,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
636 636
 
637 637
 			fmt.Println("theTIME", theTime)
638 638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
639
-			fmt.Println("keyFour323223323232323232", keyFour)
639
+
640 640
 			redis.Set(keyFour, "", time.Second)
641 641
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
642 642
 			redis.Set(keyFive, "", time.Second)

+ 3 - 0
models/dialysis.go Целия файл

@@ -1028,6 +1028,7 @@ type DialysisBeforePrepare struct {
1028 1028
 	CommdityCode string                   `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1029 1029
 	NewCount     int64                    `gorm:"column:new_count" json:"new_count" form:"new_count"`
1030 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 1034
 func (DialysisBeforePrepare) TableName() string {
@@ -1040,6 +1041,7 @@ type DialysisBeforePrepareGoods struct {
1040 1041
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1041 1042
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1042 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 1047
 type NewDialysisBeforePrepareGoods struct {
@@ -1049,6 +1051,7 @@ type NewDialysisBeforePrepareGoods struct {
1049 1051
 	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1050 1052
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1051 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 1057
 type QueueCallConfig struct {

+ 1 - 0
models/dialysis_parameter_models.go Целия файл

@@ -95,6 +95,7 @@ type BloodAutomaticReduceDetail struct {
95 95
 	GoodId                  int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
96 96
 	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
97 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 101
 func (BloodAutomaticReduceDetail) TableName() string {

+ 14 - 0
models/stock_models.go Целия файл

@@ -232,12 +232,22 @@ type WarehouseOutInfo struct {
232 232
 	Number                  string       `gorm:"column:number" json:"number" form:"number"`
233 233
 	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
234 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 238
 func (WarehouseOutInfo) TableName() string {
238 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 251
 type SalesReturn struct {
242 252
 	ID           int64  `gorm:"column:id" json:"id"`
243 253
 	OrderNumber  string `gorm:"column:order_number" json:"order_number"`
@@ -372,6 +382,7 @@ type AutomaticReduceDetail struct {
372 382
 	Count                   int64               `gorm:"column:count" json:"count"`
373 383
 	Type                    int64               `gorm:"column:type" json:"type"`
374 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 388
 func (AutomaticReduceDetail) TableName() string {
@@ -552,6 +563,7 @@ type VmStockFlow struct {
552 563
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
553 564
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
554 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 569
 func (VmStockFlow) TableName() string {
@@ -583,6 +595,8 @@ type CancelStockInfo struct {
583 595
 	WarehouseInfoId int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
584 596
 	GoodInfo        GoodInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
585 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 602
 func (CancelStockInfo) TableName() string {

+ 6 - 6
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go Целия файл

@@ -554,12 +554,11 @@ func (MonitoringRecordVM) TableName() string {
554 554
 }
555 555
 
556 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 562
 	Patient                  *PatientVM                       `gorm:"ForeignKey:PatientID" json:"patient"`
564 563
 	DialysisOrder            DialysisOrderVM                  `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
565 564
 	Prescription             PrescriptionVM                   `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
@@ -576,6 +575,7 @@ type ScheduleVM struct {
576 575
 	LastAfterWeight          XtAssessmentAfterDislysisVM      `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
577 576
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
578 577
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
578
+	Count                    int
579 579
 }
580 580
 
581 581
 func (ScheduleVM) TableName() string {

+ 6 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Целия файл

@@ -59,7 +59,7 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
59 59
 	for _, item := range schedules {
60 60
 
61 61
 		if orgID != 10101 {
62
-			dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
62
+			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
63 63
 			item.Patient.TotalDialysis = dialysis_count
64 64
 		}
65 65
 		if orgID == 10101 {
@@ -207,6 +207,11 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
207 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 215
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
211 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 217
 	return

+ 38 - 6
service/stock_service.go Целия файл

@@ -259,7 +259,7 @@ func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
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 263
 	offset := (page - 1) * limit
264 264
 	db := readDb.Model(&models.GoodInfo{})
265 265
 	db = db.Where("org_id = ? AND status = 1", orgId)
@@ -291,6 +291,9 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
291 291
 		if manufacturer > 0 {
292 292
 			db = db.Where("manufacturer = ?", manufacturer)
293 293
 		}
294
+		if is_type > 0 {
295
+			db = db.Where("good_type_id = ?", is_type)
296
+		}
294 297
 	} else {
295 298
 		if is_use > 0 {
296 299
 			if is_use == 1 {
@@ -316,6 +319,9 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
316 319
 		if manufacturer > 0 {
317 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 327
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
@@ -3483,6 +3489,12 @@ func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64,
3483 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 3498
 func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
3487 3499
 
3488 3500
 	detail := models.BloodAutomaticReduceDetail{}
@@ -3491,15 +3503,30 @@ func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64,
3491 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 3504
 	prepare := models.DialysisBeforePrepare{}
3493 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 3508
 	return err
3495 3509
 
3496 3510
 }
3497 3511
 
3498 3512
 func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3513
+
3499 3514
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
3500 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 3530
 func UpDateWarehouStockFlowByStockDelete(id int64, recordtime int64, good_id int64, count int64, patient_id int64) (err error) {
3504 3531
 
3505 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,9 +3552,14 @@ func GetAutoDialysisBefor(goodid int64, goodtypeid int64, patientid int64, orgid
3525 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 3563
 	return detail, err
3532 3564
 }
3533 3565
 
@@ -4700,9 +4732,9 @@ func GetHisAdviceListByDrugIdEight(drugid int64, patient_id int64, advice_date i
4700 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 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 4738
 	return detail, err
4707 4739
 }
4708 4740
 

+ 46 - 17
service/warhouse_service.go Целия файл

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