Kaynağa Gözat

11月9日库存管理

XMLWAN 1 yıl önce
ebeveyn
işleme
99369a3ae9

+ 2 - 2
conf/app.conf Dosyayı Görüntüle

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

+ 0 - 1
controllers/his_api_controller.go Dosyayı Görüntüle

@@ -6645,7 +6645,6 @@ func (c *HisApiController) Refund() {
6645 6645
 			infos = append(infos, &info.HisDoctorAdviceInfo)
6646 6646
 		}
6647 6647
 		if info.ProjectId > 0 && info.AdviceId == 0 {
6648
-			fmt.Println("info232323233232233", order_id)
6649 6648
 			if info.HisPrescriptionProject.Type == 3 {
6650 6649
 				var good models.DialysisBeforePrepareGoods
6651 6650
 				var newGood models.NewDialysisBeforePrepareGoods

+ 0 - 3
controllers/patient_api_controller.go Dosyayı Görüntüle

@@ -4526,10 +4526,7 @@ func (c *PatientApiController) GetRemindPatientList() {
4526 4526
 	limit, _ := c.GetInt64("limit", 10)
4527 4527
 	adminUserInfo := c.GetAdminUserInfo()
4528 4528
 	total, patients, _ := service.GetAllWaitRemindPatient(adminUserInfo.CurrentOrgId, page, limit)
4529
-	fmt.Println("机构ID2222222222222", c.GetAdminUserInfo().CurrentOrgId)
4530
-
4531 4529
 	_, errcode := service.GetOrgFollowIsExist(c.GetAdminUserInfo().CurrentOrgId)
4532
-	fmt.Println("机构ID2222222222222", errcode)
4533 4530
 	if errcode == gorm.ErrRecordNotFound {
4534 4531
 		information, err := service.GetAdminUserRoleInformation(0)
4535 4532
 		if err != nil {

+ 0 - 1
controllers/self_drug_api_congtroller.go Dosyayı Görüntüle

@@ -3410,7 +3410,6 @@ func (this *SelfDrugApiController) GetDrugNewQuery() {
3410 3410
 	for _, it := range drug {
3411 3411
 		var sum_count int64
3412 3412
 		var limit_count int64
3413
-		fmt.Println("it233323323232323223", it.DrugName)
3414 3413
 		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3415 3414
 		for _, item := range drugInfo {
3416 3415
 

+ 57 - 0
controllers/stock_in_api_controller.go Dosyayı Görüntüle

@@ -154,6 +154,8 @@ func StockManagerApiRegistRouters() {
154 154
 	beego.Router("/api/settle/stock", &StockManagerApiController{}, "Get:HandleSettleStock")
155 155
 	beego.Router("/api/settle/cancelstock", &StockManagerApiController{}, "Get:HandleRefundStock")
156 156
 
157
+	beego.Router("/api/stock/getnewgoodwarehouseinfo", &StockManagerApiController{}, "Get:GetNewGoodWarehouseInfo")
158
+
157 159
 }
158 160
 func (c *StockManagerApiController) HandleRefundStock() {
159 161
 	order_id, _ := c.GetInt64("order_id", 0)
@@ -663,6 +665,7 @@ func (c *StockManagerApiController) EditWarehouse() {
663 665
 				manufacturer := int64(items["manufacturer"].(float64))
664 666
 				dealer := int64(items["dealer"].(float64))
665 667
 				license_number, _ := items["license_number"].(string)
668
+				register_number, _ := items["register_number"].(string)
666 669
 				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
667 670
 					utils.ErrorLog("id")
668 671
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -694,6 +697,7 @@ func (c *StockManagerApiController) EditWarehouse() {
694 697
 						PackingPrice:     packing_price,
695 698
 						StorehouseId:     storehouse_id,
696 699
 						IsCheck:          2,
700
+						RegisterNumber:   register_number,
697 701
 					}
698 702
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
699 703
 
@@ -721,6 +725,7 @@ func (c *StockManagerApiController) EditWarehouse() {
721 725
 						LicenseNumber:    license_number,
722 726
 						PackingPrice:     packing_price,
723 727
 						StorehouseId:     storehouse_id,
728
+						RegisterNumber:   register_number,
724 729
 					}
725 730
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
726 731
 
@@ -745,6 +750,7 @@ func (c *StockManagerApiController) EditWarehouse() {
745 750
 						ConsumableType:      1,
746 751
 						WarehousingDetailId: warehouseInfo.ID,
747 752
 						StorehouseId:        storehouse_id,
753
+						RegisterNumber:      register_number,
748 754
 					}
749 755
 
750 756
 					stockFlow = append(stockFlow, flow)
@@ -7801,3 +7807,54 @@ func (this *StockManagerApiController) GetInvetoryWarehouseInfoList() {
7801 7807
 		"dealerList":       dealerList,
7802 7808
 	})
7803 7809
 }
7810
+
7811
+func (this *StockManagerApiController) GetNewGoodWarehouseInfo() {
7812
+
7813
+	timeLayout := "2006-01-02"
7814
+	loc, _ := time.LoadLocation("Local")
7815
+	start_time := this.GetString("start_time")
7816
+	end_time := this.GetString("end_time")
7817
+	var startTime int64
7818
+	if len(start_time) > 0 {
7819
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
7820
+		if err != nil {
7821
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7822
+			return
7823
+		}
7824
+		startTime = theTime.Unix()
7825
+
7826
+	}
7827
+	var endTime int64
7828
+	if len(end_time) > 0 {
7829
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
7830
+		if err != nil {
7831
+			utils.ErrorLog(err.Error())
7832
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7833
+			return
7834
+		}
7835
+		endTime = theTime.Unix()
7836
+	}
7837
+	storehouse_id, _ := this.GetInt64("storehouse_id")
7838
+
7839
+	keywords := this.GetString("keywords")
7840
+
7841
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7842
+
7843
+	var goodids []int64
7844
+	//查询商品名称
7845
+	if len(keywords) > 0 {
7846
+		//查询商品名称
7847
+		list, _ := service.GetGoodInforByGoodName(keywords, orgId)
7848
+		for _, item := range list {
7849
+			goodids = append(goodids, item.ID)
7850
+			//入库详情但里面查询
7851
+		}
7852
+	}
7853
+
7854
+	list, _ := service.GetNewGoodWarehouseInfo(startTime, endTime, orgId, goodids, storehouse_id)
7855
+	this.ServeSuccessJSON(map[string]interface{}{
7856
+		"list": list,
7857
+		//"manufacturerList": manufacturerList,
7858
+		//"dealerList":       dealerList,
7859
+	})
7860
+}

+ 11 - 6
service/manage_center_service.go Dosyayı Görüntüle

@@ -461,9 +461,15 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
461 461
 			var sum_count int64  //该批次总库存
462 462
 			var over_count int64 //剩余数量
463 463
 
464
-			over_count = druginfo.StockMaxNumber*drug.MinNumber + druginfo.StockMinNumber
464
+			if druginfo.MaxUnit != druginfo.MinUnit {
465
+				over_count = druginfo.StockMaxNumber*drug.MinNumber + druginfo.StockMinNumber
466
+			}
467
+			if druginfo.MaxUnit == druginfo.MinUnit {
468
+				over_count = druginfo.StockMaxNumber + druginfo.StockMinNumber
469
+			}
470
+
465 471
 			if infos.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
466
-				out_count = info.Count * drug.MinNumber
472
+				out_count = infos.Count * drug.MinNumber
467 473
 
468 474
 			}
469 475
 			if infos.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
@@ -491,7 +497,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
491 497
 			fmt.Println("g该批次总库存wowowoowow", sum_count)
492 498
 			if (over_count + out_count) <= sum_count {
493 499
 				if its.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
494
-
500
+					fmt.Print("itscoutn233232223999wi", its.Count)
495 501
 					//退库
496 502
 					warehouseInfo := models.DrugWarehouseInfo{
497 503
 						StockMinNumber: its.Count,
@@ -505,7 +511,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
505 511
 
506 512
 				}
507 513
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
508
-
514
+					fmt.Print("itscoutn999888", its.Count)
509 515
 					warehouseInfo := models.DrugWarehouseInfo{
510 516
 						StockMaxNumber: its.Count,
511 517
 					}
@@ -518,7 +524,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
518 524
 				}
519 525
 
520 526
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
521
-
527
+					fmt.Print("itscoutnwohhhhwhw", its.Count)
522 528
 					warehouseInfo := models.DrugWarehouseInfo{
523 529
 						StockMaxNumber: its.Count,
524 530
 					}
@@ -906,7 +912,6 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
906 912
 
907 913
 func GoodAutoAddCancelInfo(good *models.NewDialysisBeforePrepareGoods, creater int64) error {
908 914
 
909
-	fmt.Print("order_id223233232323223323223wo", good.OrderId)
910 915
 	//查询已经出库数量
911 916
 	info, _ := GetWareOutInfo(good.GoodId, good.RecordDate, good.UserOrgId, good.PatientId, good.OrderId)
912 917
 	if len(info) > 0 {

+ 111 - 39
service/new_warehouse_service.go Dosyayı Görüntüle

@@ -1848,6 +1848,9 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1848 1848
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1849 1849
 		}
1850 1850
 
1851
+		fmt.Println("libai", out_count)
1852
+		fmt.Println("cancel", cancel_count)
1853
+		fmt.Println("deliver_number", deliver_number)
1851 1854
 		if deliver_number < (out_count - cancel_count) {
1852 1855
 			operation_time := time.Now().Unix()
1853 1856
 
@@ -2002,7 +2005,7 @@ func GetSigleDrugWarehouseOutInfoOne(patient_id int64, advice_date int64, orgid
2002 2005
 
2003 2006
 func UpdateSingleDrugWarehouseOutInfoSix(patient_id int64, advice_date int64, orgid int64, info *models.DrugWarehouseOutInfo, advice_id int64) error {
2004 2007
 
2005
-	err := XTWriteDB().Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and advice_id = ?", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
2008
+	err := XTWriteDB().Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and advice_id = ? and status= 1", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
2006 2009
 	return err
2007 2010
 }
2008 2011
 
@@ -2083,7 +2086,7 @@ func FindDrugCancelStock(return_date int64, org_id int64) (*models.DrugCancelSto
2083 2086
 
2084 2087
 	stock := models.DrugCancelStock{}
2085 2088
 	var err error
2086
-	err = XTReadDB().Where("return_date = ? and org_id = ? and status = 1", return_date, org_id).Find(&stock).Error
2089
+	err = XTReadDB().Where("return_time = ? and org_id = ? and status = 1", return_date, org_id).Find(&stock).Error
2087 2090
 	if err == gorm.ErrRecordNotFound {
2088 2091
 		return nil, err
2089 2092
 	}
@@ -2096,7 +2099,7 @@ func FindDrugCancelStock(return_date int64, org_id int64) (*models.DrugCancelSto
2096 2099
 func FindLastDrugCancelStock(advice_date int64, org_id int64) (models.DrugCancelStock, error) {
2097 2100
 
2098 2101
 	cancelStock := models.DrugCancelStock{}
2099
-	err := XTReadDB().Where("return_date = ? and org_id = ? and status = 1", advice_date, org_id).Find(&cancelStock).Error
2102
+	err := XTReadDB().Where("return_time = ? and org_id = ? and status = 1", advice_date, org_id).Find(&cancelStock).Error
2100 2103
 	return cancelStock, err
2101 2104
 }
2102 2105
 
@@ -2127,15 +2130,19 @@ func UpdateHisPrescriptionProjectStatus(project_id int64, record_time int64, use
2127 2130
 }
2128 2131
 
2129 2132
 // 药品自动出库 递归方式
2130
-func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
2133
+func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, prescribingCount float64) (err error) {
2131 2134
 
2132 2135
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
2133 2136
 	var deliver_number int64 = 0
2137
+	var deliver_number_one int64 = 0
2134 2138
 	var stock_number int64 = 0
2135 2139
 
2136 2140
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
2137 2141
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
2138 2142
 
2143
+	prescribingCount_temp := strconv.FormatFloat(math.Abs(prescribingCount), 'f', 0, 64)
2144
+	prescribe_count, _ := strconv.ParseInt(prescribingCount_temp, 10, 64)
2145
+
2139 2146
 	var drug_price float64
2140 2147
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
2141 2148
 		deliver_number = count * drup.MinNumber
@@ -2145,6 +2152,14 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2145 2152
 
2146 2153
 	}
2147 2154
 
2155
+	if advice.PrescribingNumberUnit == drup.MaxUnit {
2156
+		deliver_number_one = prescribe_count * drup.MinNumber
2157
+
2158
+	} else {
2159
+		deliver_number_one = prescribe_count
2160
+
2161
+	}
2162
+
2148 2163
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
2149 2164
 		drug_price = drup.RetailPrice
2150 2165
 	}
@@ -2162,7 +2177,8 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2162 2177
 	// 如果没有对应的库存,则报错
2163 2178
 	storeConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
2164 2179
 	lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
2165
-	if lastWarehouse.StockMinNumber >= drup.MinNumber {
2180
+
2181
+	if lastWarehouse.StockMinNumber >= drup.MinNumber && lastWarehouse.MaxUnit != lastWarehouse.MinUnit {
2166 2182
 		var stockMax int64
2167 2183
 		var stockMin int64
2168 2184
 		stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
@@ -2174,7 +2190,6 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2174 2190
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
2175 2191
 
2176 2192
 	if err != nil {
2177
-
2178 2193
 		return err
2179 2194
 	}
2180 2195
 	// 将该批次的剩余库存数量转换为拆零数量
@@ -2196,8 +2211,8 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2196 2211
 	}
2197 2212
 
2198 2213
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
2199
-	fmt.Println("stock_nbumber3223323232", stock_number)
2200
-	fmt.Println("deliver_number", deliver_number)
2214
+	fmt.Println("剩余库存2332233223232323", stock_number)
2215
+	fmt.Println("出库数量233232332323232", deliver_number)
2201 2216
 	if stock_number >= deliver_number {
2202 2217
 
2203 2218
 		var maxNumber int64 = 0
@@ -2235,41 +2250,83 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2235 2250
 
2236 2251
 		warehouse.Mtime = time.Now().Unix()
2237 2252
 
2238
-		fmt.Println("minnU目标而332322323323233223323223我", minNumber)
2239
-		fmt.Println("max_number232232332232322wo", maxNumber)
2240
-		fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
2253
+		//fmt.Println("minnU目标而332322323323233223323223我", minNumber)
2254
+		//fmt.Println("max_number232232332232322wo", maxNumber)
2255
+		//fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
2241 2256
 
2242
-		if warehouse.StockMinNumber < minNumber {
2257
+		if warehouse.MaxUnit != warehouse.MinUnit {
2258
+			if warehouse.StockMinNumber < minNumber {
2243 2259
 
2244
-			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
2245
-			if warehouse.MaxUnit != warehouse.MinUnit {
2246
-				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
2247
-			}
2248
-		} else {
2249
-			if minNumber > 0 {
2250
-				if (warehouse.StockMinNumber - minNumber) >= 0 {
2251
-					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
2260
+				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
2261
+				if warehouse.MaxUnit != warehouse.MinUnit {
2262
+					warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
2252 2263
 				}
2264
+			} else {
2265
+				if minNumber > 0 {
2266
+					if (warehouse.StockMinNumber - minNumber) >= 0 {
2267
+						warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
2268
+					}
2253 2269
 
2254
-			}
2270
+				}
2255 2271
 
2256
-			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
2257
-				if warehouse.StockMinNumber > 0 {
2258
-					if warehouse.StockMinNumber-deliver_number >= 0 {
2272
+				if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
2273
+					if warehouse.StockMinNumber > 0 {
2274
+						if warehouse.StockMinNumber-deliver_number >= 0 {
2275
+							warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
2276
+						}
2277
+
2278
+					}
2279
+
2280
+				}
2281
+
2282
+				if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
2283
+					if (warehouse.StockMinNumber - deliver_number) >= 0 {
2259 2284
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
2260 2285
 					}
2261 2286
 
2262 2287
 				}
2263 2288
 
2264 2289
 			}
2265
-
2266 2290
 		}
2267 2291
 
2268
-		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
2269
-			if (warehouse.StockMinNumber - deliver_number) >= 0 {
2270
-				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
2292
+		if warehouse.MinUnit == warehouse.MaxUnit {
2293
+			//fmt.Println("minNUMBER233223233223322323",minNumber)
2294
+			//fmt.Println("warehouse.StockMinNumber",warehouse.StockMinNumber)
2295
+			//fmt.Println("warehouse.StockMaxNumber",warehouse.StockMaxNumber)
2296
+			if warehouse.StockMaxNumber > 0 && warehouse.StockMinNumber == 0 && warehouse.StockMaxNumber >= minNumber {
2297
+				warehouse.StockMaxNumber = warehouse.StockMaxNumber - minNumber
2298
+
2271 2299
 			}
2272 2300
 
2301
+			if warehouse.StockMaxNumber == 0 && warehouse.StockMinNumber > 0 && warehouse.StockMinNumber >= minNumber {
2302
+				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
2303
+			}
2304
+
2305
+			if warehouse.StockMaxNumber > 0 && warehouse.StockMinNumber > 0 && (warehouse.StockMaxNumber+warehouse.StockMinNumber) > minNumber {
2306
+
2307
+				var out_false int64 = 0
2308
+				if warehouse.StockMinNumber >= minNumber {
2309
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
2310
+					out_false = 1
2311
+				}
2312
+				fmt.Println("out_false233223233223wo", out_false)
2313
+				if warehouse.StockMinNumber < minNumber && out_false == 0 {
2314
+
2315
+					var over_total int64
2316
+					over_total = warehouse.StockMinNumber
2317
+					warehouse.StockMinNumber = 0
2318
+					warehouse.StockMaxNumber = warehouse.StockMaxNumber - (minNumber - over_total)
2319
+				}
2320
+			}
2321
+
2322
+			//if warehouse.StockMaxNumber < minNumber && warehouse.StockMaxNumber < minNumber && (warehouse.StockMaxNumber + warehouse.StockMinNumber) > minNumber {
2323
+			//  var over_count int64
2324
+			//  over_count = warehouse.StockMinNumber
2325
+			//  warehouse.StockMinNumber = 0
2326
+			//  warehouse.StockMaxNumber = warehouse.StockMaxNumber - (minNumber -over_count)
2327
+			//
2328
+			//}
2329
+
2273 2330
 		}
2274 2331
 
2275 2332
 		if drup.MaxUnit != drup.MinUnit {
@@ -2330,7 +2387,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2330 2387
 
2331 2388
 		//查询今日该药品该患者是否有出库数据
2332 2389
 		lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
2333
-
2390
+		fmt.Println("lastDrugOutInfo0000000293293292392392393293239239", lastDrugOutInfo)
2334 2391
 		if lastDrugOutInfo.ID == 0 {
2335 2392
 			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
2336 2393
 			if errOne != nil {
@@ -2345,7 +2402,10 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2345 2402
 			if lastDrugOutInfo.CountUnit == drup.MinUnit {
2346 2403
 				his_count = lastDrugOutInfo.Count
2347 2404
 			}
2405
+			fmt.Println("deliver_numberwode8888888823832832832832832832823823-------------------------", deliver_number)
2406
+			fmt.Println("his_countnide-------------------------------------------------------", his_count)
2348 2407
 			if deliver_number != his_count {
2408
+				//warehouseOutInfo.Count = deliver_number_one
2349 2409
 				errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
2350 2410
 				if errThree != nil {
2351 2411
 					return errThree
@@ -2367,11 +2427,11 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2367 2427
 			cancel_count += item.Count
2368 2428
 		}
2369 2429
 
2370
-		fmt.Println("deliver_number", deliver_number)
2430
+		fmt.Println("deliver_number_one", deliver_number)
2371 2431
 		fmt.Println("out_count", out_count)
2372 2432
 		fmt.Println("cancel_count", cancel_count)
2373 2433
 		//如果本次出库数据大于历史出库数据 新增1条流水
2374
-		if deliver_number > (out_count - cancel_count) {
2434
+		if deliver_number_one > (out_count - cancel_count) {
2375 2435
 			drugflow := models.DrugFlow{
2376 2436
 				WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
2377 2437
 				WarehouseOutId:          warehouseout.ID,
@@ -2379,7 +2439,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2379 2439
 				Number:                  warehouse.Number,
2380 2440
 				ProductDate:             warehouse.ProductDate,
2381 2441
 				ExpireDate:              warehouse.ExpiryDate,
2382
-				Count:                   deliver_number - (out_count - cancel_count), //按最小单位计算,
2442
+				Count:                   deliver_number_one - (out_count - cancel_count), //按最小单位计算,
2383 2443
 				Price:                   warehouse.RetailPrice,
2384 2444
 				Status:                  1,
2385 2445
 				Ctime:                   time.Now().Unix(),
@@ -2450,7 +2510,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2450 2510
 		}
2451 2511
 
2452 2512
 		//如果本次出库数据小于历史出库数据 新增1条退库流水
2453
-		if deliver_number < (out_count - cancel_count) {
2513
+		if deliver_number_one < (out_count - cancel_count) {
2454 2514
 
2455 2515
 			operation_time := time.Now().Unix()
2456 2516
 
@@ -2484,9 +2544,9 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2484 2544
 
2485 2545
 			manufactureName, _ := GetManufactureById(warehouse.Manufacturer)
2486 2546
 			dealer, _ := GetDealerById(warehouse.Dealer)
2487
-			cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
2547
+			//cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
2488 2548
 			cancelStockInfo := models.DrugCancelStockInfo{
2489
-				OrderNumber:      cancelInfo.OrderNumber,
2549
+				OrderNumber:      lastDrugCancelStock.OrderNumber,
2490 2550
 				CancelStockId:    lastDrugCancelStock.ID,
2491 2551
 				DrugId:           advice.DrugId,
2492 2552
 				Count:            (out_count - cancel_count) - deliver_number,
@@ -2658,17 +2718,21 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2658 2718
 			OrderId:                 warehouseout.OrderId,
2659 2719
 		}
2660 2720
 		//查询是否存在出库数据
2661
-		_, errCode := GetSigleDrugWarehouseOutInfo(advice.PatientId, advice.AdviceDate, orgID)
2662
-		if errCode == gorm.ErrRecordNotFound {
2721
+
2722
+		lastDrugOutInfoTwo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
2723
+		//_, errCode := GetSigleDrugWarehouseOutInfo(advice.PatientId, advice.AdviceDate, orgID)
2724
+		//fmt.Println("errcoedee232233223233232323232323233223232323322323232323232323",errCode)
2725
+		if lastDrugOutInfoTwo.ID == 0 {
2663 2726
 
2664 2727
 			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
2665 2728
 			if errOne != nil {
2666 2729
 				return errOne
2667 2730
 			}
2668 2731
 		}
2669
-		if errCode == nil {
2732
+		if lastDrugOutInfoTwo.ID > 0 {
2670 2733
 
2671 2734
 			lastDrugOutInfo, _ := GetSigleDrugWarehouseOutInfoOne(advice.PatientId, advice.AdviceDate, orgID)
2735
+			fmt.Println("中国人民肌肤32323223332332232322323喔", lastDrugOutInfo)
2672 2736
 			var his_count int64
2673 2737
 			if lastDrugOutInfo.CountUnit == drup.MaxUnit {
2674 2738
 				his_count = lastDrugOutInfo.Count * drup.MinNumber
@@ -2676,7 +2740,10 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2676 2740
 			if lastDrugOutInfo.CountUnit == drup.MinUnit {
2677 2741
 				his_count = lastDrugOutInfo.Count
2678 2742
 			}
2743
+			fmt.Println("deliver_number3232323232wowooww", deliver_number)
2744
+			fmt.Println("his_count99999992i2222wo", his_count)
2679 2745
 			if deliver_number != his_count {
2746
+
2680 2747
 				errThree := UpdateSingleDrugWarehouseOutInfoSix(advice.PatientId, advice.AdviceDate, orgID, warehouseOutInfo, advice.ID)
2681 2748
 				if errThree != nil {
2682 2749
 					return errThree
@@ -2727,6 +2794,9 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2727 2794
 			cancel_count += item.Count
2728 2795
 		}
2729 2796
 
2797
+		fmt.Println("出库数量", deliver_number)
2798
+		fmt.Println("out_coutn233232322323wo", cancel_count)
2799
+		fmt.Println("out_count99988233232", out_count)
2730 2800
 		//如果本次出库数据大于历史出库数据 新增1条流水
2731 2801
 		if deliver_number > (out_count - cancel_count) {
2732 2802
 
@@ -2768,6 +2838,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2768 2838
 		}
2769 2839
 
2770 2840
 		if deliver_number < (out_count - cancel_count) {
2841
+			fmt.Println("即那里3232232323")
2771 2842
 			operation_time := time.Now().Unix()
2772 2843
 
2773 2844
 			ctime := time.Now().Unix()
@@ -2880,8 +2951,9 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2880 2951
 
2881 2952
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
2882 2953
 		advice.PrescribingNumberUnit = drup.MinUnit
2954
+		fmt.Println("剩余库存9999999233232", overPlusNumber)
2883 2955
 
2884
-		HisSettleDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice)
2956
+		HisSettleDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, prescribingCount)
2885 2957
 	}
2886 2958
 
2887 2959
 	return

+ 23 - 0
service/stock_service.go Dosyayı Görüntüle

@@ -8380,3 +8380,26 @@ func GetWarehouseOutInfoIsExistSix(good_id int64, patient_id int64, record_time
8380 8380
 	}
8381 8381
 	return &info, nil
8382 8382
 }
8383
+
8384
+func GetNewGoodWarehouseInfo(startime int64, endtime int64, orgid int64, good_id []int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
8385
+
8386
+	db := XTReadDB().Model(&info).Where("status = 1")
8387
+
8388
+	if startime > 0 {
8389
+		db = db.Where("ctime>=?", startime)
8390
+	}
8391
+	if endtime > 0 {
8392
+		db = db.Where("ctime<=?", endtime)
8393
+	}
8394
+	if orgid > 0 {
8395
+		db = db.Where("org_id = ?", orgid)
8396
+	}
8397
+	if len(good_id) > 0 {
8398
+		db = db.Where("good_id in(?)", good_id)
8399
+	}
8400
+	if storehouse_id > 0 {
8401
+		db = db.Where("storehouse_id = ?", storehouse_id)
8402
+	}
8403
+	err = db.Find(&info).Error
8404
+	return info, err
8405
+}

+ 1 - 1
service/warhouse_service.go Dosyayı Görüntüle

@@ -12219,7 +12219,7 @@ func HisSettleDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctor
12219 12219
 		if drup.ID > 0 {
12220 12220
 			prescribingNumber := advice.PrescribingNumber
12221 12221
 
12222
-			HisSettleDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
12222
+			HisSettleDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber)
12223 12223
 
12224 12224
 		} else {
12225 12225
 			return errors.New("药品信息不存在")