XMLWAN 3 лет назад
Родитель
Сommit
90c9f456e3

+ 1 - 1
conf/app.conf Просмотреть файл

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

+ 4 - 3
controllers/drug_stock_api_contorller.go Просмотреть файл

246
 					warehouseInfo.StockMinNumber = 0
246
 					warehouseInfo.StockMinNumber = 0
247
 					warehouseInfo.MaxUnit = min_unit
247
 					warehouseInfo.MaxUnit = min_unit
248
 				}
248
 				}
249
-				if max_unit == medical.MinUnit {
249
+				if max_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
250
 					warehouseInfo.StockMaxNumber = 0
250
 					warehouseInfo.StockMaxNumber = 0
251
 					warehouseInfo.StockMinNumber = warehousing_count
251
 					warehouseInfo.StockMinNumber = warehousing_count
252
 					warehouseInfo.MaxUnit = min_unit
252
 					warehouseInfo.MaxUnit = min_unit
278
 
278
 
279
 				if medical.MaxUnit == medical.MinUnit {
279
 				if medical.MaxUnit == medical.MinUnit {
280
 					drugflow.MaxUnit = min_unit
280
 					drugflow.MaxUnit = min_unit
281
+
281
 				}
282
 				}
282
 				if max_unit == medical.MinUnit {
283
 				if max_unit == medical.MinUnit {
283
 					warehouseInfo.MaxUnit = min_unit
284
 					warehouseInfo.MaxUnit = min_unit
602
 						warehouseInfo.StockMinNumber = 0
603
 						warehouseInfo.StockMinNumber = 0
603
 						warehouseInfo.MaxUnit = min_unit
604
 						warehouseInfo.MaxUnit = min_unit
604
 					}
605
 					}
605
-					if max_unit == medical.MinUnit {
606
+					if max_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
606
 						warehouseInfo.StockMaxNumber = 0
607
 						warehouseInfo.StockMaxNumber = 0
607
 						warehouseInfo.StockMinNumber = warehousing_count
608
 						warehouseInfo.StockMinNumber = warehousing_count
608
 						warehouseInfo.MaxUnit = min_unit
609
 						warehouseInfo.MaxUnit = min_unit
641
 						warehouseInfo.MaxUnit = min_unit
642
 						warehouseInfo.MaxUnit = min_unit
642
 					}
643
 					}
643
 
644
 
644
-					if max_unit == medical.MinUnit {
645
+					if max_unit == medical.MinUnit && medical.MinUnit != medical.MaxUnit {
645
 						warehouseInfo.StockMaxNumber = 0
646
 						warehouseInfo.StockMaxNumber = 0
646
 						warehouseInfo.StockMinNumber = warehousing_count
647
 						warehouseInfo.StockMinNumber = warehousing_count
647
 						warehouseInfo.MaxUnit = min_unit
648
 						warehouseInfo.MaxUnit = min_unit

+ 16 - 1
controllers/schedule_api_controller.go Просмотреть файл

753
 func (this *ScheduleApiController) SearchSchedulePatients() {
753
 func (this *ScheduleApiController) SearchSchedulePatients() {
754
 	keywords := this.GetString("keywords")
754
 	keywords := this.GetString("keywords")
755
 	week_type, _ := this.GetInt64("week_type", 0)
755
 	week_type, _ := this.GetInt64("week_type", 0)
756
+	start_sch := this.GetString("start_sch")
757
+	end_sch := this.GetString("end_sch")
756
 
758
 
757
 	thisTime1 := time.Now()
759
 	thisTime1 := time.Now()
758
 	thisTime2 := time.Now()
760
 	thisTime2 := time.Now()
765
 
767
 
766
 	switch week_type {
768
 	switch week_type {
767
 	case 1:
769
 	case 1:
770
+		timeLayout := "2006-01-02"
771
+		loc, _ := time.LoadLocation("Local")
772
+
773
+		var startSchTime int64
774
+		if len(start_sch) > 0 {
775
+			theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_sch+" 00:00:00", loc)
776
+			startSchTime = theTime.Unix()
777
+		}
778
+		var endSchTime int64
779
+		if len(end_sch) > 0 {
780
+			theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_sch+" 00:00:00", loc)
781
+			endSchTime = theTime.Unix()
782
+		}
768
 
783
 
769
 		adminUserInfo := this.GetAdminUserInfo()
784
 		adminUserInfo := this.GetAdminUserInfo()
770
-		list, _ := service.GetSchedualPatientsByKeywords(keywords, adminUserInfo.CurrentOrgId)
785
+		list, _ := service.GetSchedualPatientsByKeywords(keywords, adminUserInfo.CurrentOrgId, startSchTime, endSchTime)
771
 		this.ServeSuccessJSON(map[string]interface{}{
786
 		this.ServeSuccessJSON(map[string]interface{}{
772
 			"schdules": list,
787
 			"schdules": list,
773
 		})
788
 		})

+ 43 - 4
controllers/stock_in_api_controller.go Просмотреть файл

212
 					return
212
 					return
213
 				}
213
 				}
214
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
214
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
215
+
215
 				total := float64(warehousing_count) * price
216
 				total := float64(warehousing_count) * price
216
 
217
 
218
+				if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
219
+					utils.ErrorLog("packing_price")
220
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
221
+					return
222
+				}
223
+				packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
224
+
217
 				var productDates int64
225
 				var productDates int64
218
 				var expiryDates int64
226
 				var expiryDates int64
219
 
227
 
274
 					StockCount:       warehousing_count,
282
 					StockCount:       warehousing_count,
275
 					Dealer:           dealer,
283
 					Dealer:           dealer,
276
 					LicenseNumber:    license_number,
284
 					LicenseNumber:    license_number,
285
+					PackingPrice:     packing_price,
277
 				}
286
 				}
278
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
287
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
279
 
288
 
521
 				}
530
 				}
522
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
531
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
523
 				total := float64(warehousing_count) * price
532
 				total := float64(warehousing_count) * price
524
-
533
+				if items["packing_price"] == nil || reflect.TypeOf(items["packing_price"]).String() != "string" {
534
+					utils.ErrorLog("packing_price")
535
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
536
+					return
537
+				}
538
+				packing_price, _ := strconv.ParseFloat(items["packing_price"].(string), 64)
525
 				var productDates int64
539
 				var productDates int64
526
 				var expiryDates int64
540
 				var expiryDates int64
527
 
541
 
588
 						Dealer:           dealer,
602
 						Dealer:           dealer,
589
 						StockCount:       warehousing_count,
603
 						StockCount:       warehousing_count,
590
 						LicenseNumber:    license_number,
604
 						LicenseNumber:    license_number,
605
+						PackingPrice:     packing_price,
591
 					}
606
 					}
592
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
607
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
593
 
608
 
613
 						Manufacturer:     manufacturer,
628
 						Manufacturer:     manufacturer,
614
 						Dealer:           dealer,
629
 						Dealer:           dealer,
615
 						LicenseNumber:    license_number,
630
 						LicenseNumber:    license_number,
631
+						PackingPrice:     packing_price,
616
 					}
632
 					}
617
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
633
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
618
 
634
 
703
 				goodinfo := models.WarehousingInfo{
719
 				goodinfo := models.WarehousingInfo{
704
 					WarehousingCount: item.WarehousingCount,
720
 					WarehousingCount: item.WarehousingCount,
705
 					StockCount:       info.StockCount + total,
721
 					StockCount:       info.StockCount + total,
722
+					Price:            item.Price,
723
+					Manufacturer:     item.Manufacturer,
724
+					Number:           item.Number,
725
+					ProductDate:      item.ProductDate,
726
+					ExpiryDate:       item.ExpiryDate,
727
+					LicenseNumber:    item.LicenseNumber,
728
+					Dealer:           item.Dealer,
729
+					Remark:           item.Remark,
730
+					PackingPrice:     item.PackingPrice,
706
 				}
731
 				}
707
 
732
 
708
-				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
733
+				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
709
 
734
 
710
 				//flowStock := models.VmStockFlow{
735
 				//flowStock := models.VmStockFlow{
711
 				//	Count:         item.WarehousingCount,
736
 				//	Count:         item.WarehousingCount,
736
 				goodinfo := models.WarehousingInfo{
761
 				goodinfo := models.WarehousingInfo{
737
 					WarehousingCount: item.WarehousingCount,
762
 					WarehousingCount: item.WarehousingCount,
738
 					StockCount:       info.StockCount - total,
763
 					StockCount:       info.StockCount - total,
764
+					Price:            item.Price,
765
+					Manufacturer:     item.Manufacturer,
766
+					Number:           item.Number,
767
+					ProductDate:      item.ProductDate,
768
+					ExpiryDate:       item.ExpiryDate,
769
+					LicenseNumber:    item.LicenseNumber,
770
+					Dealer:           item.Dealer,
771
+					Remark:           item.Remark,
772
+					PackingPrice:     item.PackingPrice,
739
 				}
773
 				}
740
-				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
774
+				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
741
 				//改变库存
775
 				//改变库存
742
 				good, _ := service.GetLastInfoMationById(info.GoodId)
776
 				good, _ := service.GetLastInfoMationById(info.GoodId)
743
 				warhouseCount := strconv.FormatInt(total, 10)
777
 				warhouseCount := strconv.FormatInt(total, 10)
761
 					LicenseNumber:    item.LicenseNumber,
795
 					LicenseNumber:    item.LicenseNumber,
762
 					Dealer:           item.Dealer,
796
 					Dealer:           item.Dealer,
763
 					Remark:           item.Remark,
797
 					Remark:           item.Remark,
798
+					PackingPrice:     item.PackingPrice,
764
 				}
799
 				}
765
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
800
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
766
 			}
801
 			}
7248
 				ExpireDate:              expiry_date,
7283
 				ExpireDate:              expiry_date,
7249
 				ReturnCount:             0,
7284
 				ReturnCount:             0,
7250
 			}
7285
 			}
7251
-
7286
+			// warehosueinfos, _ := service.GetWarehouseInfoByIdNight(id)
7252
 			info := models.WarehousingInfo{
7287
 			info := models.WarehousingInfo{
7253
 				StockCount: last_stock_count,
7288
 				StockCount: last_stock_count,
7254
 			}
7289
 			}
7290
+
7291
+			//if(last_stock_count > warehosueinfos.StockCount){
7292
+			//  info.WarehousingCount = last_stock_count
7293
+			//}
7255
 			//更改库存
7294
 			//更改库存
7256
 			service.UpdatedWarehousingInfo(info, id)
7295
 			service.UpdatedWarehousingInfo(info, id)
7257
 			if stock_count != last_stock_count {
7296
 			if stock_count != last_stock_count {

+ 1 - 0
models/self_drug_models.go Просмотреть файл

673
 	DrugName                string  `json:"drug_name"`
673
 	DrugName                string  `json:"drug_name"`
674
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
674
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
675
 	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
675
 	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
676
+	MedicalInsuranceNumber  string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
676
 }
677
 }
677
 
678
 
678
 type XtDrugAdjustPrice struct {
679
 type XtDrugAdjustPrice struct {

+ 34 - 32
models/stock_models.go Просмотреть файл

131
 	Type             int64       `gorm:"column:type" json:"type"`
131
 	Type             int64       `gorm:"column:type" json:"type"`
132
 	LicenseNumber    string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
132
 	LicenseNumber    string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
133
 	WarehouseInfoId  int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
133
 	WarehouseInfoId  int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
134
+	PackingPrice     float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
134
 }
135
 }
135
 
136
 
136
 func (WarehousingInfo) TableName() string {
137
 func (WarehousingInfo) TableName() string {
442
 }
443
 }
443
 
444
 
444
 type WarehouseOutInfoOne struct {
445
 type WarehouseOutInfoOne struct {
445
-	ID                      int64   `gorm:"column:id" json:"id"`
446
-	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
447
-	WarehouseInfotId        int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
448
-	GoodId                  int64   `gorm:"column:good_id" json:"good_id"`
449
-	GoodTypeId              int64   `gorm:"column:good_type_id" json:"good_type_id"`
450
-	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
451
-	Count                   int64   `gorm:"column:count" json:"count"`
452
-	Price                   float64 `gorm:"column:price" json:"price"`
453
-	TotalPrice              float64 `gorm:"column:total_price" json:"total_price"`
454
-	ProductDate             int64   `gorm:"column:product_date" json:"product_date"`
455
-	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date"`
456
-	Mtime                   int64   `gorm:"column:mtime" json:"mtime"`
457
-	Ctime                   int64   `gorm:"column:ctime" json:"ctime"`
458
-	Status                  int64   `gorm:"column:status" json:"status"`
459
-	OrgId                   int64   `gorm:"column:org_id" json:"org_id"`
460
-	Remark                  string  `gorm:"column:remark" json:"remark"`
461
-	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel"`
462
-	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
463
-	Type                    int64   `gorm:"column:type" json:"type"`
464
-	Dealer                  int64   `gorm:"column:dealer" json:"dealer"`
465
-	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer"`
466
-	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys"`
467
-	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time"`
468
-	PatientId               int64   `gorm:"column:patient_id" json:"patient_id"`
469
-	GoodName                string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
470
-	SpecificationName       string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
471
-	MinNumber               int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
472
-	PackingPrice            float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
473
-	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
474
-	Number                  string  `gorm:"column:number" json:"number" form:"number"`
475
-	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
476
-	LicenseNumber           string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
446
+	ID                          int64   `gorm:"column:id" json:"id"`
447
+	WarehouseOutId              int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
448
+	WarehouseInfotId            int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
449
+	GoodId                      int64   `gorm:"column:good_id" json:"good_id"`
450
+	GoodTypeId                  int64   `gorm:"column:good_type_id" json:"good_type_id"`
451
+	WarehousingOutTarget        int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
452
+	Count                       int64   `gorm:"column:count" json:"count"`
453
+	Price                       float64 `gorm:"column:price" json:"price"`
454
+	TotalPrice                  float64 `gorm:"column:total_price" json:"total_price"`
455
+	ProductDate                 int64   `gorm:"column:product_date" json:"product_date"`
456
+	ExpiryDate                  int64   `gorm:"column:expiry_date" json:"expiry_date"`
457
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime"`
458
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime"`
459
+	Status                      int64   `gorm:"column:status" json:"status"`
460
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id"`
461
+	Remark                      string  `gorm:"column:remark" json:"remark"`
462
+	IsCancel                    int64   `gorm:"column:is_cancel" json:"is_cancel"`
463
+	WarehouseOutOrderNumber     string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
464
+	Type                        int64   `gorm:"column:type" json:"type"`
465
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer"`
466
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer"`
467
+	IsSys                       int64   `gorm:"column:is_sys" json:"is_sys"`
468
+	SysRecordTime               int64   `gorm:"column:sys_record_time" json:"sys_record_time"`
469
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
470
+	GoodName                    string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
471
+	SpecificationName           string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
472
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
473
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
474
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
475
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
476
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
477
+	LicenseNumber               string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
478
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
477
 }
479
 }
478
 
480
 
479
 type WarehouseOutInfoTwo struct {
481
 type WarehouseOutInfoTwo struct {

+ 1 - 1
service/gobal_config_service.go Просмотреть файл

809
 		db = db.Where("x.warehouse_out_id = ?", id)
809
 		db = db.Where("x.warehouse_out_id = ?", id)
810
 	}
810
 	}
811
 
811
 
812
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
812
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
813
 	return info, err
813
 	return info, err
814
 }
814
 }
815
 
815
 

+ 50 - 38
service/mobile_dialysis_service.go Просмотреть файл

2025
 	tx.Commit()
2025
 	tx.Commit()
2026
 	return err
2026
 	return err
2027
 }
2027
 }
2028
-
2029
 func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDryweight, error) {
2028
 func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDryweight, error) {
2030
 	var record models.SgjPatientDryweight
2029
 	var record models.SgjPatientDryweight
2031
-	redis := RedisClient()
2032
-	defer redis.Close()
2033
-
2034
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
2035
-	last_dry_weight_str, _ := redis.Get(key).Result()
2036
-
2037
-	if len(last_dry_weight_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2038
-		err := readDb.Model(&models.SgjPatientDryweight{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Last(&record).Error
2039
-		if err != nil {
2040
-			if err == gorm.ErrRecordNotFound {
2041
-				if record.ID <= 0 {
2042
-					redis.Set(key, "null", time.Second*60*60*18)
2043
-				}
2044
-				return nil, nil
2045
-			} else {
2046
-				return nil, err
2047
-			}
2048
-		} else {
2049
-			if record.ID > 0 {
2050
-				//缓存数据
2051
-				last_dry_weight_str, err := json.Marshal(record)
2052
-				if err == nil {
2053
-					redis.Set(key, last_dry_weight_str, time.Second*60*60*18)
2054
-					return nil, err
2055
-				}
2056
-			} else {
2057
-				redis.Set(key, "null", time.Second*60*60*18)
2058
-				return nil, err
2059
-			}
2060
-			return &record, nil
2061
-		}
2062
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2063
-		if last_dry_weight_str == "null" {
2064
-			return &record, nil
2030
+	err := readDb.Model(&models.SgjPatientDryweight{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Last(&record).Error
2031
+	if err != nil {
2032
+		if err == gorm.ErrRecordNotFound {
2033
+			return nil, nil
2065
 		} else {
2034
 		} else {
2066
-			json.Unmarshal([]byte(last_dry_weight_str), &record)
2067
-			return &record, nil
2035
+			return nil, err
2068
 		}
2036
 		}
2069
-
2070
 	}
2037
 	}
2038
+	return &record, nil
2071
 }
2039
 }
2072
 
2040
 
2041
+//func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDryweight, error) {
2042
+//	var record models.SgjPatientDryweight
2043
+//	redis := RedisClient()
2044
+//	defer redis.Close()
2045
+//
2046
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
2047
+//	last_dry_weight_str, _ := redis.Get(key).Result()
2048
+//
2049
+//	if len(last_dry_weight_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2050
+//		err := readDb.Model(&models.SgjPatientDryweight{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Last(&record).Error
2051
+//		if err != nil {
2052
+//			if err == gorm.ErrRecordNotFound {
2053
+//				if record.ID <= 0 {
2054
+//					redis.Set(key, "null", time.Second*60*60*18)
2055
+//				}
2056
+//				return nil, nil
2057
+//			} else {
2058
+//				return nil, err
2059
+//			}
2060
+//		} else {
2061
+//			if record.ID > 0 {
2062
+//				//缓存数据
2063
+//				last_dry_weight_str, err := json.Marshal(record)
2064
+//				if err == nil {
2065
+//					redis.Set(key, last_dry_weight_str, time.Second*60*60*18)
2066
+//					return nil, err
2067
+//				}
2068
+//			} else {
2069
+//				redis.Set(key, "null", time.Second*60*60*18)
2070
+//				return nil, err
2071
+//			}
2072
+//			return &record, nil
2073
+//		}
2074
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2075
+//		if last_dry_weight_str == "null" {
2076
+//			return &record, nil
2077
+//		} else {
2078
+//			json.Unmarshal([]byte(last_dry_weight_str), &record)
2079
+//			return &record, nil
2080
+//		}
2081
+//
2082
+//	}
2083
+//}
2084
+
2073
 // 透析方案
2085
 // 透析方案
2074
 func MobileGetDialysisSolutionByModeIdSix(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
2086
 func MobileGetDialysisSolutionByModeIdSix(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
2075
 	var record models.DialysisSolution
2087
 	var record models.DialysisSolution

+ 9 - 8
service/role_service.go Просмотреть файл

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
+	"XT_New/models"
5
+	"XT_New/utils"
4
 	"database/sql"
6
 	"database/sql"
7
+	"encoding/json"
5
 	"fmt"
8
 	"fmt"
6
 	"strconv"
9
 	"strconv"
7
 	"strings"
10
 	"strings"
8
 	"time"
11
 	"time"
9
-	"encoding/json"
10
-	"XT_New/models"
11
-	"XT_New/utils"
12
 
12
 
13
 	"github.com/jinzhu/gorm"
13
 	"github.com/jinzhu/gorm"
14
 )
14
 )
131
 	TitleName       string `gorm:"-" json:"title_name"`
131
 	TitleName       string `gorm:"-" json:"title_name"`
132
 	IsSubSuperAdmin bool   `gorm:"-" json:"is_sub_super_admin"`
132
 	IsSubSuperAdmin bool   `gorm:"-" json:"is_sub_super_admin"`
133
 	//mobile          string `gorm:"-" json:"mobile"`
133
 	//mobile          string `gorm:"-" json:"mobile"`
134
-	Sort     int `gorm:"sort" json:"sort"`
135
-	IsMark   int `gorm:"is_mark" json:"is_mark"`
136
-	UserType int `gorm:"user_type" json:"user_type"`
134
+	Sort         int    `gorm:"sort" json:"sort"`
135
+	IsMark       int    `gorm:"is_mark" json:"is_mark"`
136
+	UserType     int    `gorm:"user_type" json:"user_type"`
137
+	DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
137
 }
138
 }
138
 
139
 
139
 func GetAdminUsersAndLoginInfo(orgID int64, appID int64, page int, count int) ([]*AdminUserManageViewModel, int, error) {
140
 func GetAdminUsersAndLoginInfo(orgID int64, appID int64, page int, count int) ([]*AdminUserManageViewModel, int, error) {
144
 		page = 1
145
 		page = 1
145
 	}
146
 	}
146
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
147
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
147
-	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids,u_a_r.sort,u_a_r.is_mark,u_a_r.user_type FROM sgj_user_admin_role AS u_a_r   LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l  ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id  LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
148
+	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name,u_a_r.doctor_number, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status,u_a_r.avatar,u_a_r.role_ids,u_a_r.sort,u_a_r.is_mark,u_a_r.user_type FROM sgj_user_admin_role AS u_a_r   LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ?  ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l  ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id  LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
148
 	defer rows.Close()
149
 	defer rows.Close()
149
 	if err != nil {
150
 	if err != nil {
150
 		if err == gorm.ErrRecordNotFound {
151
 		if err == gorm.ErrRecordNotFound {
795
 	defer redis.Close()
796
 	defer redis.Close()
796
 
797
 
797
 	// cur_date := time.Now().Format("2006-01-02")
798
 	// cur_date := time.Now().Format("2006-01-02")
798
-	key := "user_all_role:" + strconv.FormatInt(org_id, 10) + ":"+ strconv.FormatInt(admin_user_id, 10)
799
+	key := "user_all_role:" + strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(admin_user_id, 10)
799
 	role_str, _ := redis.Get(key).Result()
800
 	role_str, _ := redis.Get(key).Result()
800
 
801
 
801
 	if len(role_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
802
 	if len(role_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis

+ 2 - 2
service/schedule_service.go Просмотреть файл

446
 
446
 
447
 }
447
 }
448
 
448
 
449
-func GetSchedualPatientsByKeywords(keywords string, org_id int64) (schedule []*models.Schedule, err error) {
449
+func GetSchedualPatientsByKeywords(keywords string, org_id int64, startime int64, endtime int64) (schedule []*models.Schedule, err error) {
450
 	likeKey := "%" + keywords + "%"
450
 	likeKey := "%" + keywords + "%"
451
 
451
 
452
 	err = readDb.
452
 	err = readDb.
456
 		Preload("DeviceNumber", "status = 1 ").
456
 		Preload("DeviceNumber", "status = 1 ").
457
 		Preload("TreatmentMode", "status = 1 ").
457
 		Preload("TreatmentMode", "status = 1 ").
458
 		Joins("JOIN xt_patients as p ON p.id = s.patient_id AND (p.name LIKE ? OR p.dialysis_no LIKE ?)", likeKey, likeKey).
458
 		Joins("JOIN xt_patients as p ON p.id = s.patient_id AND (p.name LIKE ? OR p.dialysis_no LIKE ?)", likeKey, likeKey).
459
-		Where("s.user_org_id=? and s.schedule_date >= UNIX_TIMESTAMP(DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00')) and s.schedule_date <= UNIX_TIMESTAMP(DATE_FORMAT( SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7), '%Y-%m-%d 23:59:59')) and s.status=1", org_id).
459
+		Where("s.user_org_id=? and s.schedule_date >= ? and s.schedule_date <= ? and s.status=1", org_id, startime, endtime).
460
 		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, s.status, s.created_time, s.updated_time, p.name as patient").
460
 		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, s.status, s.created_time, s.updated_time, p.name as patient").
461
 		Order("schedule_date asc").
461
 		Order("schedule_date asc").
462
 		Find(&schedule).Error
462
 		Find(&schedule).Error

+ 12 - 4
service/stock_service.go Просмотреть файл

411
 	if len(warehousingInfo) > 0 {
411
 	if len(warehousingInfo) > 0 {
412
 		utx := writeDb.Begin()
412
 		utx := writeDb.Begin()
413
 		if len(warehousingInfo) > 0 {
413
 		if len(warehousingInfo) > 0 {
414
-			thisSQL := "INSERT INTO xt_warehouse_info (warehousing_id, good_id, good_type_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,stock_count,license_number) VALUES "
414
+			thisSQL := "INSERT INTO xt_warehouse_info (warehousing_id, good_id, good_type_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,stock_count,license_number,packing_price) VALUES "
415
 			insertParams := make([]string, 0)
415
 			insertParams := make([]string, 0)
416
 			insertData := make([]interface{}, 0)
416
 			insertData := make([]interface{}, 0)
417
 			for _, info := range warehousingInfo {
417
 			for _, info := range warehousingInfo {
418
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
418
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
419
 				insertData = append(insertData, info.WarehousingId)
419
 				insertData = append(insertData, info.WarehousingId)
420
 				insertData = append(insertData, info.GoodId)
420
 				insertData = append(insertData, info.GoodId)
421
 				insertData = append(insertData, info.GoodTypeId)
421
 				insertData = append(insertData, info.GoodTypeId)
436
 				insertData = append(insertData, info.Type)
436
 				insertData = append(insertData, info.Type)
437
 				insertData = append(insertData, info.WarehousingCount)
437
 				insertData = append(insertData, info.WarehousingCount)
438
 				insertData = append(insertData, info.LicenseNumber)
438
 				insertData = append(insertData, info.LicenseNumber)
439
+				insertData = append(insertData, info.PackingPrice)
439
 			}
440
 			}
440
 			thisSQL += strings.Join(insertParams, ", ")
441
 			thisSQL += strings.Join(insertParams, ", ")
441
 			err = utx.Exec(thisSQL, insertData...).Error
442
 			err = utx.Exec(thisSQL, insertData...).Error
3848
 		db = db.Where("x.org_id = ?", orgid)
3849
 		db = db.Where("x.org_id = ?", orgid)
3849
 	}
3850
 	}
3850
 
3851
 
3851
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
3852
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
3852
 	return out, err
3853
 	return out, err
3853
 }
3854
 }
3854
 
3855
 
5227
 	return list, err
5228
 	return list, err
5228
 }
5229
 }
5229
 
5230
 
5231
+func GetWarehouseInfoByIdNight(id int64) (models.WarehousingInfo, error) {
5232
+
5233
+	info := models.WarehousingInfo{}
5234
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&info).Error
5235
+	return info, err
5236
+}
5237
+
5230
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
5238
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
5231
 
5239
 
5232
 	info := models.WarehousingInfo{}
5240
 	info := models.WarehousingInfo{}
5491
 
5499
 
5492
 func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
5500
 func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
5493
 
5501
 
5494
-	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark}).Error
5502
+	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark, "packing_price": info.PackingPrice}).Error
5495
 	return err
5503
 	return err
5496
 }
5504
 }
5497
 
5505
 

+ 42 - 41
service/warhouse_service.go Просмотреть файл

101
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
101
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
102
 		drug_price = drup.RetailPrice
102
 		drug_price = drup.RetailPrice
103
 	}
103
 	}
104
+	fmt.Println(drug_price)
104
 
105
 
105
 	if advice.PrescribingNumberUnit == drup.MinUnit {
106
 	if advice.PrescribingNumberUnit == drup.MinUnit {
106
 		drug_price = drup.MinPrice
107
 		drug_price = drup.MinPrice
145
 			DrugId:                  advice.DrugId,
146
 			DrugId:                  advice.DrugId,
146
 			Number:                  warehouse.Number,
147
 			Number:                  warehouse.Number,
147
 			BatchNumber:             warehouse.BatchNumber,
148
 			BatchNumber:             warehouse.BatchNumber,
148
-			Price:                   drug_price,
149
+			Price:                   warehouse.RetailPrice,
149
 			CountUnit:               drup.MinUnit,
150
 			CountUnit:               drup.MinUnit,
150
-			RetailPrice:             drug_price,
151
+			RetailPrice:             warehouse.RetailPrice,
151
 			ProductDate:             warehouse.ProductDate,
152
 			ProductDate:             warehouse.ProductDate,
152
 			ExpiryDate:              warehouse.ExpiryDate,
153
 			ExpiryDate:              warehouse.ExpiryDate,
153
 			PatientId:               advice.PatientId,
154
 			PatientId:               advice.PatientId,
163
 			ProductDate:             warehouse.ProductDate,
164
 			ProductDate:             warehouse.ProductDate,
164
 			ExpireDate:              warehouse.ExpiryDate,
165
 			ExpireDate:              warehouse.ExpiryDate,
165
 			Count:                   deliver_number, //按最小单位计算,
166
 			Count:                   deliver_number, //按最小单位计算,
166
-			Price:                   drug_price,
167
+			Price:                   warehouse.RetailPrice,
167
 			Status:                  1,
168
 			Status:                  1,
168
 			Ctime:                   time.Now().Unix(),
169
 			Ctime:                   time.Now().Unix(),
169
 			UserOrgId:               orgID,
170
 			UserOrgId:               orgID,
278
 			DrugId:                  advice.DrugId,
279
 			DrugId:                  advice.DrugId,
279
 			Number:                  warehouse.Number,
280
 			Number:                  warehouse.Number,
280
 			BatchNumber:             warehouse.BatchNumber,
281
 			BatchNumber:             warehouse.BatchNumber,
281
-			Price:                   drug_price,
282
+			Price:                   warehouse.RetailPrice,
282
 			CountUnit:               drup.MinUnit,
283
 			CountUnit:               drup.MinUnit,
283
 			ProductDate:             warehouse.ProductDate,
284
 			ProductDate:             warehouse.ProductDate,
284
 			ExpiryDate:              warehouse.ExpiryDate,
285
 			ExpiryDate:              warehouse.ExpiryDate,
318
 			ProductDate:       warehouse.ProductDate,
319
 			ProductDate:       warehouse.ProductDate,
319
 			ExpiryDate:        warehouse.ExpiryDate,
320
 			ExpiryDate:        warehouse.ExpiryDate,
320
 			WarehousingCount:  warehouse.WarehousingCount,
321
 			WarehousingCount:  warehouse.WarehousingCount,
321
-			Price:             warehouse.Price,
322
+			Price:             warehouse.RetailPrice,
322
 			TotalPrice:        warehouse.TotalPrice,
323
 			TotalPrice:        warehouse.TotalPrice,
323
 			Dealer:            warehouse.Dealer,
324
 			Dealer:            warehouse.Dealer,
324
 			Manufacturer:      warehouse.Manufacturer,
325
 			Manufacturer:      warehouse.Manufacturer,
354
 			ProductDate:             warehouse.ProductDate,
355
 			ProductDate:             warehouse.ProductDate,
355
 			ExpireDate:              warehouse.ExpiryDate,
356
 			ExpireDate:              warehouse.ExpiryDate,
356
 			Count:                   stock_number,
357
 			Count:                   stock_number,
357
-			Price:                   drug_price,
358
+			Price:                   warehouse.RetailPrice,
358
 			Status:                  1,
359
 			Status:                  1,
359
 			Ctime:                   time.Now().Unix(),
360
 			Ctime:                   time.Now().Unix(),
360
 			UserOrgId:               orgID,
361
 			UserOrgId:               orgID,
477
 	if advice.PrescribingNumberUnit != drup.MaxUnit && advice.PrescribingNumberUnit != drup.MinUnit {
478
 	if advice.PrescribingNumberUnit != drup.MaxUnit && advice.PrescribingNumberUnit != drup.MinUnit {
478
 		min_price = drup.RetailPrice
479
 		min_price = drup.RetailPrice
479
 	}
480
 	}
480
-
481
+	fmt.Println(min_price)
481
 	// 根据先进先出原则,查询最先入库的批次,进行出库
482
 	// 根据先进先出原则,查询最先入库的批次,进行出库
482
 	// 如果没有对应的库存,则报错
483
 	// 如果没有对应的库存,则报错
483
 
484
 
511
 			DrugId:                  advice.DrugId,
512
 			DrugId:                  advice.DrugId,
512
 			Number:                  warehouse.Number,
513
 			Number:                  warehouse.Number,
513
 			BatchNumber:             warehouse.BatchNumber,
514
 			BatchNumber:             warehouse.BatchNumber,
514
-			Price:                   min_price,
515
+			Price:                   warehouse.RetailPrice,
515
 			CountUnit:               drup.MinUnit,
516
 			CountUnit:               drup.MinUnit,
516
-			RetailPrice:             min_price,
517
+			RetailPrice:             warehouse.RetailPrice,
517
 			ProductDate:             warehouse.ProductDate,
518
 			ProductDate:             warehouse.ProductDate,
518
 			ExpiryDate:              warehouse.ExpiryDate,
519
 			ExpiryDate:              warehouse.ExpiryDate,
519
 			PatientId:               advice.PatientId,
520
 			PatientId:               advice.PatientId,
530
 			ProductDate:             warehouse.ProductDate,
531
 			ProductDate:             warehouse.ProductDate,
531
 			ExpireDate:              warehouse.ExpiryDate,
532
 			ExpireDate:              warehouse.ExpiryDate,
532
 			Count:                   deliver_number,
533
 			Count:                   deliver_number,
533
-			Price:                   min_price,
534
+			Price:                   warehouse.RetailPrice,
534
 			Status:                  1,
535
 			Status:                  1,
535
 			Ctime:                   time.Now().Unix(),
536
 			Ctime:                   time.Now().Unix(),
536
 			UserOrgId:               orgID,
537
 			UserOrgId:               orgID,
659
 			DrugId:                  advice.DrugId,
660
 			DrugId:                  advice.DrugId,
660
 			Number:                  warehouse.Number,
661
 			Number:                  warehouse.Number,
661
 			BatchNumber:             warehouse.BatchNumber,
662
 			BatchNumber:             warehouse.BatchNumber,
662
-			Price:                   min_price,
663
-			RetailPrice:             min_price,
663
+			Price:                   warehouse.RetailPrice,
664
+			RetailPrice:             warehouse.RetailPrice,
664
 			ProductDate:             warehouse.ProductDate,
665
 			ProductDate:             warehouse.ProductDate,
665
 			ExpiryDate:              warehouse.ExpiryDate,
666
 			ExpiryDate:              warehouse.ExpiryDate,
666
 			PatientId:               advice.PatientId,
667
 			PatientId:               advice.PatientId,
678
 			ProductDate:             warehouse.ProductDate,
679
 			ProductDate:             warehouse.ProductDate,
679
 			ExpireDate:              warehouse.ExpiryDate,
680
 			ExpireDate:              warehouse.ExpiryDate,
680
 			Count:                   stock_number,
681
 			Count:                   stock_number,
681
-			Price:                   min_price,
682
+			Price:                   warehouse.RetailPrice,
682
 			Status:                  1,
683
 			Status:                  1,
683
 			Ctime:                   time.Now().Unix(),
684
 			Ctime:                   time.Now().Unix(),
684
 			UserOrgId:               orgID,
685
 			UserOrgId:               orgID,
926
 		}
927
 		}
927
 		warehouseOutInfo.Count = stock_number
928
 		warehouseOutInfo.Count = stock_number
928
 
929
 
929
-		warehouseOutInfo.CountUnit = advice.CountUnit
930
+		//warehouseOutInfo.CountUnit = advice.CountUnit
930
 
931
 
931
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
932
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
932
 		if errOne != nil {
933
 		if errOne != nil {
1124
 			PatientId:               patient_id,
1125
 			PatientId:               patient_id,
1125
 			Number:                  warehouse.Number,
1126
 			Number:                  warehouse.Number,
1126
 			LicenseNumber:           warehouse.LicenseNumber,
1127
 			LicenseNumber:           warehouse.LicenseNumber,
1127
-			Price:                   info.PackingPrice,
1128
+			Price:                   warehouse.PackingPrice,
1128
 			ExpiryDate:              warehouse.ExpiryDate,
1129
 			ExpiryDate:              warehouse.ExpiryDate,
1129
 			ProductDate:             warehouse.ProductDate,
1130
 			ProductDate:             warehouse.ProductDate,
1130
 			ProjectId:               goods.ProjectId,
1131
 			ProjectId:               goods.ProjectId,
1172
 				ProductDate:             warehouse.ProductDate,
1173
 				ProductDate:             warehouse.ProductDate,
1173
 				ExpireDate:              warehouse.ExpiryDate,
1174
 				ExpireDate:              warehouse.ExpiryDate,
1174
 				Count:                   deliver_number,
1175
 				Count:                   deliver_number,
1175
-				Price:                   info.PackingPrice,
1176
+				Price:                   warehouse.PackingPrice,
1176
 				Status:                  1,
1177
 				Status:                  1,
1177
 				Ctime:                   time.Now().Unix(),
1178
 				Ctime:                   time.Now().Unix(),
1178
 				UserOrgId:               orgID,
1179
 				UserOrgId:               orgID,
1207
 					ProductDate:             warehouse.ProductDate,
1208
 					ProductDate:             warehouse.ProductDate,
1208
 					ExpireDate:              warehouse.ExpiryDate,
1209
 					ExpireDate:              warehouse.ExpiryDate,
1209
 					Count:                   exsit.Count + goods.Count,
1210
 					Count:                   exsit.Count + goods.Count,
1210
-					Price:                   info.PackingPrice,
1211
+					Price:                   warehouse.PackingPrice,
1211
 					Status:                  1,
1212
 					Status:                  1,
1212
 					Ctime:                   time.Now().Unix(),
1213
 					Ctime:                   time.Now().Unix(),
1213
 					UserOrgId:               orgID,
1214
 					UserOrgId:               orgID,
1241
 				ProductDate:             warehouse.ProductDate,
1242
 				ProductDate:             warehouse.ProductDate,
1242
 				ExpireDate:              warehouse.ExpiryDate,
1243
 				ExpireDate:              warehouse.ExpiryDate,
1243
 				Count:                   deliver_number,
1244
 				Count:                   deliver_number,
1244
-				Price:                   info.PackingPrice,
1245
+				Price:                   warehouse.PackingPrice,
1245
 				Status:                  1,
1246
 				Status:                  1,
1246
 				Ctime:                   time.Now().Unix(),
1247
 				Ctime:                   time.Now().Unix(),
1247
 				UserOrgId:               orgID,
1248
 				UserOrgId:               orgID,
1275
 					ProductDate:             warehouse.ProductDate,
1276
 					ProductDate:             warehouse.ProductDate,
1276
 					ExpireDate:              warehouse.ExpiryDate,
1277
 					ExpireDate:              warehouse.ExpiryDate,
1277
 					Count:                   exsit.Count + goods.Count,
1278
 					Count:                   exsit.Count + goods.Count,
1278
-					Price:                   info.PackingPrice,
1279
+					Price:                   warehouse.PackingPrice,
1279
 					Status:                  1,
1280
 					Status:                  1,
1280
 					Ctime:                   time.Now().Unix(),
1281
 					Ctime:                   time.Now().Unix(),
1281
 					UserOrgId:               orgID,
1282
 					UserOrgId:               orgID,
1341
 			PatientId:               patient_id,
1342
 			PatientId:               patient_id,
1342
 			Number:                  warehouse.Number,
1343
 			Number:                  warehouse.Number,
1343
 			LicenseNumber:           warehouse.LicenseNumber,
1344
 			LicenseNumber:           warehouse.LicenseNumber,
1344
-			Price:                   info.PackingPrice,
1345
+			Price:                   warehouse.PackingPrice,
1345
 			ExpiryDate:              warehouse.ExpiryDate,
1346
 			ExpiryDate:              warehouse.ExpiryDate,
1346
 			ProductDate:             warehouse.ProductDate,
1347
 			ProductDate:             warehouse.ProductDate,
1347
 			ProjectId:               goods.ProjectId,
1348
 			ProjectId:               goods.ProjectId,
1365
 				ProductDate:             warehouse.ProductDate,
1366
 				ProductDate:             warehouse.ProductDate,
1366
 				ExpireDate:              warehouse.ExpiryDate,
1367
 				ExpireDate:              warehouse.ExpiryDate,
1367
 				Count:                   stock_number,
1368
 				Count:                   stock_number,
1368
-				Price:                   info.PackingPrice,
1369
+				Price:                   warehouse.PackingPrice,
1369
 				Status:                  1,
1370
 				Status:                  1,
1370
 				Ctime:                   time.Now().Unix(),
1371
 				Ctime:                   time.Now().Unix(),
1371
 				UserOrgId:               orgID,
1372
 				UserOrgId:               orgID,
1397
 					ProductDate:             warehouse.ProductDate,
1398
 					ProductDate:             warehouse.ProductDate,
1398
 					ExpireDate:              warehouse.ExpiryDate,
1399
 					ExpireDate:              warehouse.ExpiryDate,
1399
 					Count:                   exsit.Count + goods.Count,
1400
 					Count:                   exsit.Count + goods.Count,
1400
-					Price:                   info.PackingPrice,
1401
+					Price:                   warehouse.PackingPrice,
1401
 					Status:                  1,
1402
 					Status:                  1,
1402
 					Ctime:                   time.Now().Unix(),
1403
 					Ctime:                   time.Now().Unix(),
1403
 					UserOrgId:               orgID,
1404
 					UserOrgId:               orgID,
1434
 				ProductDate:             warehouse.ProductDate,
1435
 				ProductDate:             warehouse.ProductDate,
1435
 				ExpireDate:              warehouse.ExpiryDate,
1436
 				ExpireDate:              warehouse.ExpiryDate,
1436
 				Count:                   stock_number,
1437
 				Count:                   stock_number,
1437
-				Price:                   info.PackingPrice,
1438
+				Price:                   warehouse.PackingPrice,
1438
 				Status:                  1,
1439
 				Status:                  1,
1439
 				Ctime:                   time.Now().Unix(),
1440
 				Ctime:                   time.Now().Unix(),
1440
 				UserOrgId:               orgID,
1441
 				UserOrgId:               orgID,
1466
 					ProductDate:             warehouse.ProductDate,
1467
 					ProductDate:             warehouse.ProductDate,
1467
 					ExpireDate:              warehouse.ExpiryDate,
1468
 					ExpireDate:              warehouse.ExpiryDate,
1468
 					Count:                   exsit.Count + goods.Count,
1469
 					Count:                   exsit.Count + goods.Count,
1469
-					Price:                   info.PackingPrice,
1470
+					Price:                   warehouse.PackingPrice,
1470
 					Status:                  1,
1471
 					Status:                  1,
1471
 					Ctime:                   time.Now().Unix(),
1472
 					Ctime:                   time.Now().Unix(),
1472
 					UserOrgId:               orgID,
1473
 					UserOrgId:               orgID,
1694
 			Status:                  1,
1695
 			Status:                  1,
1695
 			Ctime:                   time.Now().Unix(),
1696
 			Ctime:                   time.Now().Unix(),
1696
 			Mtime:                   0,
1697
 			Mtime:                   0,
1697
-			Price:                   goods.Price,
1698
+			Price:                   warehouse.PackingPrice,
1698
 			WarehousingDetailId:     0,
1699
 			WarehousingDetailId:     0,
1699
 			WarehouseOutDetailId:    warehouseOutInfo.ID,
1700
 			WarehouseOutDetailId:    warehouseOutInfo.ID,
1700
 			CancelOutDetailId:       0,
1701
 			CancelOutDetailId:       0,
1742
 			ExpiryDate:              goods.ExpiryDate,
1743
 			ExpiryDate:              goods.ExpiryDate,
1743
 			ProductDate:             goods.ProductDate,
1744
 			ProductDate:             goods.ProductDate,
1744
 			Number:                  warehouse.Number,
1745
 			Number:                  warehouse.Number,
1745
-			Price:                   goods.Price,
1746
+			Price:                   warehouse.PackingPrice,
1746
 			LicenseNumber:           goods.LicenseNumber,
1747
 			LicenseNumber:           goods.LicenseNumber,
1747
 		}
1748
 		}
1748
 		warehouseOutInfo.Count = stock_number
1749
 		warehouseOutInfo.Count = stock_number
1785
 			Status:                  1,
1786
 			Status:                  1,
1786
 			Ctime:                   time.Now().Unix(),
1787
 			Ctime:                   time.Now().Unix(),
1787
 			Mtime:                   0,
1788
 			Mtime:                   0,
1788
-			Price:                   goods.Price,
1789
+			Price:                   warehouse.PackingPrice,
1789
 			WarehousingDetailId:     0,
1790
 			WarehousingDetailId:     0,
1790
 			WarehouseOutDetailId:    warehouseOutInfo.ID,
1791
 			WarehouseOutDetailId:    warehouseOutInfo.ID,
1791
 			CancelOutDetailId:       0,
1792
 			CancelOutDetailId:       0,
1850
 			ExpiryDate:              goods.ExpiryDate,
1851
 			ExpiryDate:              goods.ExpiryDate,
1851
 			ProductDate:             goods.ProductDate,
1852
 			ProductDate:             goods.ProductDate,
1852
 			Number:                  goods.Number,
1853
 			Number:                  goods.Number,
1853
-			Price:                   goods.Price,
1854
+			Price:                   warehouse.PackingPrice,
1854
 			LicenseNumber:           goods.LicenseNumber,
1855
 			LicenseNumber:           goods.LicenseNumber,
1855
 			ConsumableType:          2,
1856
 			ConsumableType:          2,
1856
 		}
1857
 		}
1900
 			ExpiryDate:              goods.ExpiryDate,
1901
 			ExpiryDate:              goods.ExpiryDate,
1901
 			ProductDate:             goods.ProductDate,
1902
 			ProductDate:             goods.ProductDate,
1902
 			Number:                  goods.Number,
1903
 			Number:                  goods.Number,
1903
-			Price:                   goods.Price,
1904
+			Price:                   warehouse.PackingPrice,
1904
 			LicenseNumber:           goods.LicenseNumber,
1905
 			LicenseNumber:           goods.LicenseNumber,
1905
 			ConsumableType:          2,
1906
 			ConsumableType:          2,
1906
 		}
1907
 		}
1990
 			DrugId:                  advice.DrugId,
1991
 			DrugId:                  advice.DrugId,
1991
 			Number:                  warehouse.Number,
1992
 			Number:                  warehouse.Number,
1992
 			BatchNumber:             warehouse.BatchNumber,
1993
 			BatchNumber:             warehouse.BatchNumber,
1993
-			Price:                   drug_price,
1994
+			Price:                   warehouse.RetailPrice,
1994
 			CountUnit:               drup.MinUnit,
1995
 			CountUnit:               drup.MinUnit,
1995
 			RetailPrice:             drug_price,
1996
 			RetailPrice:             drug_price,
1996
 			ProductDate:             warehouse.ProductDate,
1997
 			ProductDate:             warehouse.ProductDate,
2009
 			ProductDate:             warehouse.ProductDate,
2010
 			ProductDate:             warehouse.ProductDate,
2010
 			ExpireDate:              warehouse.ExpiryDate,
2011
 			ExpireDate:              warehouse.ExpiryDate,
2011
 			Count:                   deliver_number, //按最小单位计算,
2012
 			Count:                   deliver_number, //按最小单位计算,
2012
-			Price:                   drug_price,
2013
+			Price:                   warehouse.RetailPrice,
2013
 			Status:                  1,
2014
 			Status:                  1,
2014
 			Ctime:                   time.Now().Unix(),
2015
 			Ctime:                   time.Now().Unix(),
2015
 			UserOrgId:               orgID,
2016
 			UserOrgId:               orgID,
2116
 			DrugId:                  advice.DrugId,
2117
 			DrugId:                  advice.DrugId,
2117
 			Number:                  warehouse.Number,
2118
 			Number:                  warehouse.Number,
2118
 			BatchNumber:             warehouse.BatchNumber,
2119
 			BatchNumber:             warehouse.BatchNumber,
2119
-			Price:                   drug_price,
2120
+			Price:                   warehouse.RetailPrice,
2120
 			CountUnit:               drup.MinUnit,
2121
 			CountUnit:               drup.MinUnit,
2121
 			ProductDate:             warehouse.ProductDate,
2122
 			ProductDate:             warehouse.ProductDate,
2122
 			ExpiryDate:              warehouse.ExpiryDate,
2123
 			ExpiryDate:              warehouse.ExpiryDate,
2207
 			ProductDate:             warehouse.ProductDate,
2208
 			ProductDate:             warehouse.ProductDate,
2208
 			ExpireDate:              warehouse.ExpiryDate,
2209
 			ExpireDate:              warehouse.ExpiryDate,
2209
 			Count:                   deliver_number,
2210
 			Count:                   deliver_number,
2210
-			Price:                   drug_price,
2211
+			Price:                   warehouse.RetailPrice,
2211
 			Status:                  1,
2212
 			Status:                  1,
2212
 			Ctime:                   time.Now().Unix(),
2213
 			Ctime:                   time.Now().Unix(),
2213
 			UserOrgId:               orgID,
2214
 			UserOrgId:               orgID,
2264
 	if advice.PrescribingNumberUnit != drup.MaxUnit && advice.PrescribingNumberUnit != drup.MinUnit {
2265
 	if advice.PrescribingNumberUnit != drup.MaxUnit && advice.PrescribingNumberUnit != drup.MinUnit {
2265
 		min_price = drup.RetailPrice
2266
 		min_price = drup.RetailPrice
2266
 	}
2267
 	}
2267
-
2268
+	fmt.Println(min_price)
2268
 	// 根据先进先出原则,查询最先入库的批次,进行出库
2269
 	// 根据先进先出原则,查询最先入库的批次,进行出库
2269
 	// 如果没有对应的库存,则报错
2270
 	// 如果没有对应的库存,则报错
2270
 	//开启事物
2271
 	//开启事物
2298
 			DrugId:                  advice.DrugId,
2299
 			DrugId:                  advice.DrugId,
2299
 			Number:                  warehouse.Number,
2300
 			Number:                  warehouse.Number,
2300
 			BatchNumber:             warehouse.BatchNumber,
2301
 			BatchNumber:             warehouse.BatchNumber,
2301
-			Price:                   min_price,
2302
+			Price:                   warehouse.RetailPrice,
2302
 			CountUnit:               drup.MinUnit,
2303
 			CountUnit:               drup.MinUnit,
2303
-			RetailPrice:             min_price,
2304
+			RetailPrice:             warehouse.RetailPrice,
2304
 			ProductDate:             warehouse.ProductDate,
2305
 			ProductDate:             warehouse.ProductDate,
2305
 			ExpiryDate:              warehouse.ExpiryDate,
2306
 			ExpiryDate:              warehouse.ExpiryDate,
2306
 			PatientId:               advice.PatientId,
2307
 			PatientId:               advice.PatientId,
2317
 			ProductDate:             warehouse.ProductDate,
2318
 			ProductDate:             warehouse.ProductDate,
2318
 			ExpireDate:              warehouse.ExpiryDate,
2319
 			ExpireDate:              warehouse.ExpiryDate,
2319
 			Count:                   deliver_number,
2320
 			Count:                   deliver_number,
2320
-			Price:                   min_price,
2321
+			Price:                   warehouse.RetailPrice,
2321
 			Status:                  1,
2322
 			Status:                  1,
2322
 			Ctime:                   time.Now().Unix(),
2323
 			Ctime:                   time.Now().Unix(),
2323
 			UserOrgId:               orgID,
2324
 			UserOrgId:               orgID,
2418
 			DrugId:                  advice.DrugId,
2419
 			DrugId:                  advice.DrugId,
2419
 			Number:                  warehouse.Number,
2420
 			Number:                  warehouse.Number,
2420
 			BatchNumber:             warehouse.BatchNumber,
2421
 			BatchNumber:             warehouse.BatchNumber,
2421
-			Price:                   min_price,
2422
-			RetailPrice:             min_price,
2422
+			Price:                   warehouse.RetailPrice,
2423
+			RetailPrice:             warehouse.RetailPrice,
2423
 			ProductDate:             warehouse.ProductDate,
2424
 			ProductDate:             warehouse.ProductDate,
2424
 			ExpiryDate:              warehouse.ExpiryDate,
2425
 			ExpiryDate:              warehouse.ExpiryDate,
2425
 			PatientId:               advice.PatientId,
2426
 			PatientId:               advice.PatientId,
2437
 			ProductDate:             warehouse.ProductDate,
2438
 			ProductDate:             warehouse.ProductDate,
2438
 			ExpireDate:              warehouse.ExpiryDate,
2439
 			ExpireDate:              warehouse.ExpiryDate,
2439
 			Count:                   stock_number,
2440
 			Count:                   stock_number,
2440
-			Price:                   min_price,
2441
+			Price:                   warehouse.RetailPrice,
2441
 			Status:                  1,
2442
 			Status:                  1,
2442
 			Ctime:                   time.Now().Unix(),
2443
 			Ctime:                   time.Now().Unix(),
2443
 			UserOrgId:               orgID,
2444
 			UserOrgId:               orgID,
2489
 			ProductDate:       warehouse.ProductDate,
2490
 			ProductDate:       warehouse.ProductDate,
2490
 			ExpiryDate:        warehouse.ExpiryDate,
2491
 			ExpiryDate:        warehouse.ExpiryDate,
2491
 			WarehousingCount:  warehouse.WarehousingCount,
2492
 			WarehousingCount:  warehouse.WarehousingCount,
2492
-			Price:             warehouse.Price,
2493
+			Price:             warehouse.RetailPrice,
2493
 			TotalPrice:        warehouse.TotalPrice,
2494
 			TotalPrice:        warehouse.TotalPrice,
2494
 			Dealer:            warehouse.Dealer,
2495
 			Dealer:            warehouse.Dealer,
2495
 			Manufacturer:      warehouse.Manufacturer,
2496
 			Manufacturer:      warehouse.Manufacturer,