XMLWAN преди 3 години
родител
ревизия
36cccd6aa9

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

@@ -19,6 +19,9 @@ qiniu_bucket = syhclub-storage
19 19
 
20 20
 
21 21
 
22
+
23
+
24
+
22 25
 aes_key = "xuetou-201807319"
23 26
 
24 27
 wxtoken = gh_ac6cd0cdde3d

+ 156 - 21
controllers/drug_stock_api_contorller.go Целия файл

@@ -543,6 +543,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
543 543
 						BatchNumber:      batch_number,
544 544
 						MaxUnit:          max_unit,
545 545
 						MinUnit:          min_unit,
546
+						StockMaxNumber:   warehousing_count,
546 547
 					}
547 548
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
548 549
 
@@ -567,7 +568,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
567 568
 						Dealer:           dealer,
568 569
 						RetailPrice:      last_price,
569 570
 						RetailTotalPrice: retail_price_total,
570
-						StockMaxNumber:   warehousing_count,
571 571
 						MaxUnit:          max_unit,
572 572
 						MinUnit:          min_unit,
573 573
 						BatchNumber:      batch_number,
@@ -576,7 +576,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
576 576
 
577 577
 					drugflow := &models.DrugFlow{
578 578
 						WarehousingOrder: warehousing.WarehousingOrder,
579
-						WarehousingId:    warehousing.ID,
579
+						WarehousingId:    id,
580 580
 						DrugId:           drug_id,
581 581
 						Number:           number,
582 582
 						ProductDate:      productDates,
@@ -638,8 +638,34 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
638 638
 				Total: minNumber,
639 639
 			}
640 640
 			service.UpdateBaseDrug(&lib, item.DrugId)
641
+			warehouseInfo, _ := service.FindeLastWarehouseInfo(item.ID)
642
+			fmt.Println("hhhhh23hh32h232332323223", warehouseInfo)
643
+			var total int64
644
+			//比较大小(加)
645
+			if item.WarehousingCount > warehouseInfo.WarehousingCount {
646
+				total = item.WarehousingCount - warehouseInfo.WarehousingCount
647
+			}
648
+			item.StockMaxNumber = warehouseInfo.StockMaxNumber + total
649
+			if item.WarehousingCount < warehouseInfo.WarehousingCount {
650
+				total = warehouseInfo.WarehousingCount - item.WarehousingCount
651
+			}
652
+			item.StockMaxNumber = warehouseInfo.StockMaxNumber - total
653
+			if item.WarehousingCount == warehouseInfo.StockMaxNumber {
654
+
655
+				item.StockMaxNumber = item.WarehousingCount
656
+			}
641 657
 			errs = service.UpDateDrugWarehousingInfo(item)
642
-			service.CreateDrugFlow(drugFlow)
658
+
659
+		}
660
+	}
661
+
662
+	if len(drugFlow) > 0 {
663
+		for _, item := range drugFlow {
664
+			flow := models.DrugFlow{
665
+				Count: item.Count,
666
+			}
667
+			parseDateErr := service.UpdateDrugFlow(flow, item.DrugId, item.WarehousingId)
668
+			fmt.Println(parseDateErr)
643 669
 		}
644 670
 	}
645 671
 
@@ -1152,11 +1178,13 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1152 1178
 				remark := items["remark"].(string)
1153 1179
 				max_unit := items["max_unit"].(string)
1154 1180
 				dealer := int64(items["dealer"].(float64))
1155
-				fmt.Println("dealer2222222222222222222", dealer)
1181
+
1156 1182
 				manufacturer := int64(items["manufacturer"].(float64))
1157
-				fmt.Println("manufacturer22222222222222", manufacturer)
1183
+
1158 1184
 				number := items["number"].(string)
1159 1185
 				batch_number := items["batch_number"].(string)
1186
+
1187
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1160 1188
 				var productDates int64
1161 1189
 				var expiryDates int64
1162 1190
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
@@ -1209,6 +1237,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1209 1237
 					Number:                  number,
1210 1238
 					BatchNumber:             batch_number,
1211 1239
 					IsSys:                   0,
1240
+					WarehouseInfoId:         warehouse_info_id,
1212 1241
 				}
1213 1242
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1214 1243
 
@@ -1242,17 +1271,26 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1242 1271
 	//调用出库逻辑
1243 1272
 	for _, item := range warehousingOutInfo {
1244 1273
 		//获取药品库存
1245
-		info, _ := service.GetDrugTotalCount(item.DrugId, item.OrgId)
1274
+		info, _ := service.GetDrugTotalCountOne(item.DrugId, item.OrgId, item.WarehouseInfoId)
1246 1275
 		//查询改药品信息
1247 1276
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1277
+		total_count = info.StockMaxNumber*medical.MinNumber + info.StockMinNumber
1278
+		//for _, it := range info{
1279
+		//  if medical.MaxUnit == it.MaxUnit{
1280
+		//    it.Count = it.StockMaxNumber * medical.MinNumber
1281
+		//  }
1282
+		//  if medical.MinUnit == it.MinUnit{
1283
+		//    it.Count = it.StockMinNumber
1284
+		//  }
1285
+		//  total_count += it.Count
1286
+		//}
1287
+		fmt.Println("总库存23232323232232332232332223", total_count)
1248 1288
 		//判断单位是否相等
1249 1289
 		if medical.MaxUnit == item.CountUnit {
1250 1290
 			//转化为最小单位
1251
-			total_count = info.Count * medical.MinNumber
1252 1291
 			prescribing_number_total = item.Count * medical.MinNumber
1253 1292
 		}
1254 1293
 		if medical.MinUnit == item.CountUnit {
1255
-			total_count = info.Count
1256 1294
 			prescribing_number_total = item.Count
1257 1295
 		}
1258 1296
 
@@ -1521,7 +1559,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1521 1559
 				batch_number := items["batch_number"].(string)
1522 1560
 				number := items["number"].(string)
1523 1561
 				max_unit := items["count_unit"].(string)
1524
-
1562
+				warehouse_info_id := int64(items["warehouse_info_id"].(float64))
1525 1563
 				var productDates int64
1526 1564
 				var expiryDates int64
1527 1565
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
@@ -1551,8 +1589,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1551 1589
 					}
1552 1590
 
1553 1591
 				}
1554
-				fmt.Println("生产日期22222222222222222222222222", expiryDates)
1555
-				fmt.Println("生产日期22222222222222222222222222", productDates)
1592
+
1556 1593
 				if id == 0 {
1557 1594
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1558 1595
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1577,6 +1614,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1577 1614
 						ProductDate:             productDates,
1578 1615
 						ExpiryDate:              expiryDates,
1579 1616
 						CountUnit:               count_unit,
1617
+						WarehouseInfoId:         warehouse_info_id,
1580 1618
 					}
1581 1619
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1582 1620
 
@@ -1601,7 +1639,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1601 1639
 						Creator:                 adminUserInfo.AdminUser.Id,
1602 1640
 						IsSys:                   0,
1603 1641
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1604
-						WarehouseOutId:          warehouseOut.ID,
1642
+						WarehouseOutId:          id,
1605 1643
 					}
1606 1644
 
1607 1645
 					drugFlow = append(drugFlow, drugflow)
@@ -1646,6 +1684,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1646 1684
 						ProductDate:             productDates,
1647 1685
 						ExpiryDate:              expiryDates,
1648 1686
 						CountUnit:               count_unit,
1687
+						WarehouseInfoId:         warehouse_info_id,
1649 1688
 					}
1650 1689
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1651 1690
 
@@ -2147,6 +2186,8 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2147 2186
 	//扣减库存逻辑
2148 2187
 	for _, item := range cancelStockInfos {
2149 2188
 		var total_number int64
2189
+		var out_number int64
2190
+		var can_number int64
2150 2191
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
2151 2192
 		//将当前退库数转为最小单位
2152 2193
 		if item.MaxUnit == medical.MaxUnit {
@@ -2163,15 +2204,57 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2163 2204
 		total_count = infoWareInfo.StockMaxNumber*medical.MinNumber + infoWareInfo.StockMinNumber
2164 2205
 		fmt.Println("当前批次总库存", total_count)
2165 2206
 
2207
+		//查询该批次的出库数量
2208
+		outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2209
+		//查询该批次总的退库数量
2210
+
2211
+		canInfo, _ := service.GetCancelDrugStockOutInfo(item.BatchNumberId, item.DrugId)
2212
+		for _, item := range canInfo {
2213
+			if item.MaxUnit == medical.MaxUnit {
2214
+				item.Count = item.Count * medical.MinNumber
2215
+			}
2216
+			if item.MaxUnit == medical.MinUnit {
2217
+				item.Count = item.Count
2218
+			}
2219
+		}
2220
+		for _, item := range canInfo {
2221
+			can_number += item.Count
2222
+		}
2223
+
2224
+		for _, item := range outInfo {
2225
+			if item.CountUnit == medical.MaxUnit {
2226
+				item.Count = item.Count * medical.MinNumber
2227
+			}
2228
+			if item.CountUnit == medical.MinUnit {
2229
+				item.Count = item.Count
2230
+			}
2231
+		}
2232
+		for _, item := range outInfo {
2233
+			out_number += item.Count
2234
+		}
2235
+		fmt.Println("出库数量23232232323222332", out_number)
2236
+
2166 2237
 		//判断退库数量是否大于总入库数量
2167
-		if total_number > total_count {
2238
+		if total_number > out_number {
2239
+			service.UpdateDrugCancel(item.CancelStockId)
2240
+			c.ServeSuccessJSON(map[string]interface{}{
2241
+				"msg": "4",
2242
+			})
2243
+			return
2244
+		}
2245
+
2246
+		//判断总退库数量是否大于出库数量
2247
+		fmt.Println("hhhhhhhhhhh", can_number+total_number)
2248
+		if can_number+total_number > out_number {
2249
+			service.UpdateDrugCancel(item.CancelStockId)
2168 2250
 			c.ServeSuccessJSON(map[string]interface{}{
2169 2251
 				"msg": "2",
2170 2252
 			})
2171 2253
 			return
2172 2254
 		}
2255
+
2173 2256
 		//正常退库
2174
-		if total_number <= total_count {
2257
+		if total_number <= out_number {
2175 2258
 			//创建退库详情
2176 2259
 			errs := service.CreateDrugCancelStockInfo(cancelStockInfos)
2177 2260
 			//创建库存明细
@@ -2558,6 +2641,8 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2558 2641
 			infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2559 2642
 			fmt.Println("hhh2h3h2hh3233", item.MaxUnit, medical.MaxUnit)
2560 2643
 			var total_count int64
2644
+			var cancel_count int64
2645
+			var out_count int64
2561 2646
 			total_count = infoWareInfo.StockMaxNumber*medical.MinNumber + infoWareInfo.StockMinNumber
2562 2647
 			//转化为最小单位
2563 2648
 			var total_number int64
@@ -2567,13 +2652,46 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2567 2652
 			if item.MaxUnit == medical.MinUnit {
2568 2653
 				total_number = item.Count
2569 2654
 			}
2570
-			//if item.MaxUnit == medical.MaxUnit {
2571
-			//	total_count = infoWareInfo.WarehousingCount
2572
-			//}
2573
-			////转化为最小库存
2574
-			//if item.MaxUnit == medical.MinUnit {
2575
-			//	total_count = infoWareInfo.WarehousingCount * medical.MinNumber
2576
-			//}
2655
+
2656
+			//统计该批次的总出库数
2657
+			outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2658
+			for _, item := range outInfo {
2659
+				if item.CountUnit == medical.MaxUnit {
2660
+					item.Count = item.Count * medical.MinNumber
2661
+				}
2662
+				if item.CountUnit == medical.MinUnit {
2663
+					item.Count = item.Count
2664
+				}
2665
+			}
2666
+
2667
+			for _, item := range outInfo {
2668
+				out_count += item.Count
2669
+			}
2670
+			fmt.Println("out_count232233332232323223", out_count)
2671
+
2672
+			//判断退库数量是否大于出库数量
2673
+			cancelInfo, _ := service.GetCancelDrugStockOutInfo(item.BatchNumberId, item.DrugId)
2674
+			for _, item := range cancelInfo {
2675
+				if item.MaxUnit == medical.MaxUnit {
2676
+					item.Count = item.Count * medical.MinNumber
2677
+				}
2678
+				if item.MaxUnit == medical.MinUnit {
2679
+					item.Count = item.Count
2680
+				}
2681
+			}
2682
+
2683
+			for _, item := range cancelInfo {
2684
+				cancel_count += item.Count
2685
+			}
2686
+			fmt.Println("cancel_count", cancel_count)
2687
+			fmt.Println("hhhhhh23h2h332322323232", total_number+cancel_count)
2688
+			if total_number+cancel_count > out_count {
2689
+				c.ServeSuccessJSON(map[string]interface{}{
2690
+					"msg": "4",
2691
+				})
2692
+				return
2693
+			}
2694
+
2577 2695
 			//判断退库数量是否大于总入库数量
2578 2696
 			if total_number > total_count {
2579 2697
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -2655,12 +2773,29 @@ func (c *StockDrugApiController) EditDrugCancelStock() {
2655 2773
 
2656 2774
 	if len(upDateCancelStockInfos) > 0 {
2657 2775
 		var total int64
2776
+		var out_count int64
2658 2777
 		for _, item := range upDateCancelStockInfos {
2659 2778
 			errs = service.UpDateDrugCancelStockInfo(item)
2660 2779
 			//查询该批次最后一条退库记录
2661 2780
 			info, _ := service.GetLastCancelStockInfo(id)
2662 2781
 			//查询该药品的信息
2663 2782
 			medical, _ := service.GetBaseDrugMedical(item.DrugId)
2783
+			//统计该批次的总出库数
2784
+			outInfo, _ := service.GetDrugWarehouseOutInfo(item.BatchNumberId, item.DrugId)
2785
+			for _, item := range outInfo {
2786
+				if item.CountUnit == medical.MaxUnit {
2787
+					item.Count = item.Count * medical.MinNumber
2788
+				}
2789
+				if item.CountUnit == medical.MinUnit {
2790
+					item.Count = item.Count
2791
+				}
2792
+			}
2793
+
2794
+			for _, item := range outInfo {
2795
+				out_count += item.Count
2796
+			}
2797
+
2798
+			fmt.Println("out_count232233332232323223", out_count)
2664 2799
 
2665 2800
 			if item.MaxUnit == medical.MaxUnit {
2666 2801
 				item.Count = item.Count * medical.MinNumber

+ 13 - 6
controllers/gobal_config_api_controller.go Целия файл

@@ -1851,7 +1851,10 @@ func (c *GobalConfigApiController) GetDrugStockList() {
1851 1851
 	adminUserInfo := c.GetAdminUserInfo()
1852 1852
 
1853 1853
 	//查询入库数量
1854
-	list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1854
+	//list, total, err := service.GetDrugStockList(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1855
+
1856
+	list, total, err := service.GetAllBaseDurgListCount(page, limit, keyword, drug_type, startTime, endTime, adminUserInfo.CurrentOrgId)
1857
+	fmt.Println("total232323232323232232323", total)
1855 1858
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
1856 1859
 	if err != nil {
1857 1860
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
@@ -2007,18 +2010,19 @@ func (c *GobalConfigApiController) GetDrugCountList() {
2007 2010
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2008 2011
 	list, err := service.GetDrugCountList(startTime, endTime, orgId)
2009 2012
 	countList, err := service.GetMinCountList(startTime, endTime, orgId)
2010
-	outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2011
-	auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2013
+	//outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2014
+	//auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2012 2015
 	info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
2013 2016
 	cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
2017
+	//service.GetAllCountList(startTime,endTime,orgId)
2014 2018
 	if err != nil {
2015 2019
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2016 2020
 		return
2017 2021
 	}
2018 2022
 	c.ServeSuccessJSON(map[string]interface{}{
2019
-		"countList":       list,
2020
-		"outCountList":    outCountList,
2021
-		"auCountList":     auCountList,
2023
+		"countList": list,
2024
+		//"outCountList":    outCountList,
2025
+		//"auCountList":     auCountList,
2022 2026
 		"minCount":        countList,
2023 2027
 		"info":            info,
2024 2028
 		"cancelCountList": cancelCountList,
@@ -2028,11 +2032,13 @@ func (c *GobalConfigApiController) GetDrugCountList() {
2028 2032
 func (c *GobalConfigApiController) GetSingleOrderDetail() {
2029 2033
 
2030 2034
 	id, _ := c.GetInt64("id")
2035
+	start_time, _ := c.GetInt64("start_time")
2031 2036
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2032 2037
 	list, err := service.GetSingleOrderDetail(id, orgId)
2033 2038
 	outList, err := service.GetAllSingleDrugDetail(id, orgId)
2034 2039
 	dealerList, err := service.GetAllDealerList(orgId)
2035 2040
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2041
+	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2036 2042
 	if err != nil {
2037 2043
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2038 2044
 		return
@@ -2042,6 +2048,7 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2042 2048
 		"dealerList":       dealerList,
2043 2049
 		"manufacturerList": manufacturerList,
2044 2050
 		"outList":          outList,
2051
+		"drugFlowList":     drugFlowList,
2045 2052
 	})
2046 2053
 }
2047 2054
 

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

@@ -3866,7 +3866,7 @@ func (c *DialysisAPIController) EditConsumables() {
3866 3866
 					if err != nil {
3867 3867
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
3868 3868
 						c.ServeSuccessJSON(map[string]interface{}{
3869
-							"message":            "1",
3869
+							"message":            "2",
3870 3870
 							"good_name":          goodObj.GoodName,
3871 3871
 							"specification_name": goodObj.SpecificationName,
3872 3872
 						})
@@ -4591,9 +4591,43 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4591 4591
 			UpdateCreator:           creater,
4592 4592
 			PatientId:               patient_id,
4593 4593
 		}
4594
-		//创建流水表
4595
-		err := service.CreateStockFlowOne(stockFlow)
4596
-		fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
4594
+		exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
4595
+		if errflow == gorm.ErrRecordNotFound {
4596
+			//创建流水表
4597
+			err := service.CreateStockFlowOne(stockFlow)
4598
+			fmt.Println("h2h3h2323342i24i242i4u2i4242u42424", err)
4599
+		} else if errflow == nil {
4600
+			//插入详情明细表
4601
+			stockFlow := models.VmStockFlow{
4602
+				ID:                      exsit.ID,
4603
+				WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4604
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4605
+				WarehouseOutId:          warehouseOut.ID,
4606
+				GoodId:                  good_yc.GoodId,
4607
+				Number:                  warehouseOutInfos.Number,
4608
+				ProductDate:             stockInInfo.ProductDate,
4609
+				ExpireDate:              stockInInfo.ExpiryDate,
4610
+				Count:                   exsit.Count - delete_count,
4611
+				Price:                   stockInInfo.Price,
4612
+				Status:                  1,
4613
+				Ctime:                   time.Now().Unix(),
4614
+				UserOrgId:               good_yc.OrgId,
4615
+				Manufacturer:            stockInInfo.Manufacturer,
4616
+				Dealer:                  stockInInfo.Dealer,
4617
+				LicenseNumber:           stockInInfo.LicenseNumber,
4618
+				IsEdit:                  2,
4619
+				Creator:                 creater,
4620
+				SystemTime:              record_time,
4621
+				ConsumableType:          3,
4622
+				WarehousingDetailId:     0,
4623
+				IsSys:                   1,
4624
+				UpdateCreator:           creater,
4625
+				PatientId:               patient_id,
4626
+			}
4627
+
4628
+			service.UpdatedStockFlow(stockFlow)
4629
+		}
4630
+
4597 4631
 		if errOne != nil {
4598 4632
 			return errOne
4599 4633
 		}
@@ -4601,6 +4635,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4601 4635
 		service.UpdatedWarehouseOutInfo(warehouseOutInfo, good_yc.GoodId, good_yc.PatientId, record_time)
4602 4636
 		//插入详情明细表
4603 4637
 		stockFlow := models.VmStockFlow{
4638
+			WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4604 4639
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4605 4640
 			WarehouseOutId:          warehouseOut.ID,
4606 4641
 			GoodId:                  good_yc.GoodId,
@@ -4623,9 +4658,43 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
4623 4658
 			IsSys:                   1,
4624 4659
 			UpdateCreator:           creater,
4625 4660
 			PatientId:               patient_id,
4661
+			ReturnCount:             delete_count,
4626 4662
 		}
4627
-		//创建流水表
4628
-		service.CreateStockFlowOne(stockFlow)
4663
+		exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, good_yc.GoodId)
4664
+		if errflows == gorm.ErrRecordNotFound {
4665
+			//创建流水表
4666
+			service.CreateStockFlowOne(stockFlow)
4667
+		} else if errflows == nil {
4668
+			stockFlow := models.VmStockFlow{
4669
+				WarehousingId:           warehouseOutInfos.WarehouseInfotId,
4670
+				ID:                      exsit.ID,
4671
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
4672
+				WarehouseOutId:          warehouseOut.ID,
4673
+				GoodId:                  good_yc.GoodId,
4674
+				Number:                  warehouseOutInfos.Number,
4675
+				ProductDate:             stockInInfo.ProductDate,
4676
+				ExpireDate:              stockInInfo.ExpiryDate,
4677
+				Count:                   exsit.Count - delete_count,
4678
+				Price:                   stockInInfo.Price,
4679
+				Status:                  1,
4680
+				Ctime:                   time.Now().Unix(),
4681
+				UserOrgId:               good_yc.OrgId,
4682
+				Manufacturer:            stockInInfo.Manufacturer,
4683
+				Dealer:                  stockInInfo.Dealer,
4684
+				LicenseNumber:           stockInInfo.LicenseNumber,
4685
+				IsEdit:                  2,
4686
+				Creator:                 creater,
4687
+				SystemTime:              record_time,
4688
+				ConsumableType:          3,
4689
+				WarehousingDetailId:     0,
4690
+				IsSys:                   1,
4691
+				UpdateCreator:           creater,
4692
+				PatientId:               patient_id,
4693
+				ReturnCount:             delete_count,
4694
+			}
4695
+			service.UpdatedStockFlow(stockFlow)
4696
+		}
4697
+
4629 4698
 	}
4630 4699
 
4631 4700
 	//更改自动出库的表格

+ 37 - 8
controllers/stock_in_api_controller.go Целия файл

@@ -554,6 +554,7 @@ func (c *StockManagerApiController) EditWarehouse() {
554 554
 					stockFlow = append(stockFlow, flow)
555 555
 
556 556
 				} else {
557
+					fmt.Println("id23233232323232323232323223", id)
557 558
 					warehouseInfo := &models.WarehousingInfo{
558 559
 						ID:               id,
559 560
 						WarehousingOrder: warehouse.WarehousingOrder,
@@ -573,14 +574,13 @@ func (c *StockManagerApiController) EditWarehouse() {
573 574
 						Type:             types,
574 575
 						Manufacturer:     manufacturer,
575 576
 						Dealer:           dealer,
576
-						StockCount:       warehousing_count,
577 577
 						LicenseNumber:    license_number,
578 578
 					}
579 579
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
580 580
 
581 581
 					flow := &models.VmStockFlow{
582 582
 						WarehousingOrder:    warehousing.WarehousingOrder,
583
-						WarehousingId:       warehousing.ID,
583
+						WarehousingId:       id,
584 584
 						GoodId:              good_id,
585 585
 						Number:              number,
586 586
 						ProductDate:         productDates,
@@ -614,20 +614,31 @@ func (c *StockManagerApiController) EditWarehouse() {
614 614
 	if len(upDateWarehousingInfo) > 0 {
615 615
 
616 616
 		for _, item := range upDateWarehousingInfo {
617
+
617 618
 			var total int64
618 619
 			var all_total int64
619 620
 			//获取该批次该型号的库存
620
-			info, _ := service.GetLastWarehousingById(item.WarehousingId, item.GoodId)
621
-
621
+			info, _ := service.GetLastWarehousingByIdOne(item.ID, item.GoodId)
622
+			fmt.Println("oooooooooo", info.WarehousingCount)
622 623
 			//判断 该批次的入库数量
623 624
 			total = item.WarehousingCount - info.WarehousingCount
624
-
625
+			fmt.Println("total232323322332232332", total)
625 626
 			all_total = info.StockCount + total
626 627
 
627 628
 			item.StockCount = all_total
629
+			fmt.Println("hhhhhhhhhhhhh", item.StockCount)
630
+
628 631
 			errs = service.UpDateWarehousingInfo(item)
632
+		}
633
+	}
629 634
 
630
-			service.CreateStockFlow(stockFlow)
635
+	if len(stockFlow) > 0 {
636
+		for _, item := range stockFlow {
637
+			flow := models.VmStockFlow{
638
+				Count: item.Count,
639
+			}
640
+			parseDateErr := service.UpdateStockFlow(flow, item.GoodId, item.WarehousingId)
641
+			fmt.Println(parseDateErr)
631 642
 		}
632 643
 	}
633 644
 
@@ -1930,6 +1941,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
1930 1941
 		//统计该耗材的出库数量
1931 1942
 		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
1932 1943
 		if item.Count > info.Count {
1944
+			service.UpdateCancelInfo(item.CancelStockId)
1933 1945
 			c.ServeSuccessJSON(map[string]interface{}{
1934 1946
 				"msg": "2",
1935 1947
 			})
@@ -1958,6 +1970,14 @@ func (c *StockManagerApiController) CreateCancelStock() {
1958 1970
 				return
1959 1971
 			}
1960 1972
 
1973
+			//查询该批次的剩余库存
1974
+			wareouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
1975
+			if (wareouseinfo.StockCount + item.Count) > wareouseinfo.WarehousingCount {
1976
+				c.ServeSuccessJSON(map[string]interface{}{
1977
+					"msg": "5",
1978
+				})
1979
+				return
1980
+			}
1961 1981
 			//更改入库数量
1962 1982
 			errs = service.UpdateWareInfoById(item.WarehouseInfoId, item.Count)
1963 1983
 
@@ -2365,6 +2385,13 @@ func (c *StockManagerApiController) EditCancelStock() {
2365 2385
 				errs = service.UpDateCancelStockInfo(item)
2366 2386
 
2367 2387
 				service.CreateStockFlow(stockFlow)
2388
+				warehouseinfo, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
2389
+				if (warehouseinfo.StockCount + total) > warehouseinfo.StockCount {
2390
+					c.ServeSuccessJSON(map[string]interface{}{
2391
+						"msg": "5",
2392
+					})
2393
+					return
2394
+				}
2368 2395
 				parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total)
2369 2396
 				if parseDateErr != nil {
2370 2397
 					utils.ErrorLog(errs.Error())
@@ -2386,6 +2413,7 @@ func (c *StockManagerApiController) EditCancelStock() {
2386 2413
 				}
2387 2414
 				if item.Count <= infolist.WarehousingCount {
2388 2415
 					var total_count = info.Count - item.Count
2416
+
2389 2417
 					parseDateErr := service.UpdateWareInfoById(item.WarehouseInfoId, total_count)
2390 2418
 					if parseDateErr != nil {
2391 2419
 						utils.ErrorLog(errs.Error())
@@ -4281,7 +4309,8 @@ func (this *StockManagerApiController) GetAllStockList() {
4281 4309
 	adminUserInfo := this.GetAdminUserInfo()
4282 4310
 	orgId := adminUserInfo.CurrentOrgId
4283 4311
 
4284
-	list, total, _ := service.GetAllStockList(page, limit, startTime, endTime, types, keywords, orgId)
4312
+	list, total, _ := service.GetAllGoodInfoStockList(page, limit, startTime, endTime, types, keywords, orgId)
4313
+	fmt.Println("耗材总计23323232232323232323", total)
4285 4314
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4286 4315
 	this.ServeSuccessJSON(map[string]interface{}{
4287 4316
 		"list":             list,
@@ -4440,7 +4469,7 @@ func (this *StockManagerApiController) GetOrderDetailById() {
4440 4469
 	//手动出库
4441 4470
 	info, _ := service.GetWarehouseOutInfoById(id, good_id)
4442 4471
 
4443
-	stockFlowList, err := service.GetStockFlowBatchNumber(id, good_id)
4472
+	stockFlowList, err := service.GetStockFlowBatchNumberOne(id, good_id)
4444 4473
 	if err == nil {
4445 4474
 		this.ServeSuccessJSON(map[string]interface{}{
4446 4475
 			"list":          userDetails,

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

@@ -279,6 +279,7 @@ type VmDrugWarehouseInfo struct {
279 279
 	Count          int64  `gorm:"column:count" json:"count" form:"count"`
280 280
 	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
281 281
 	MinUnit        string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
282
+	CountUnit      string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
282 283
 	StockMinNumber int64  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
283 284
 	StockMaxNumber int64  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
284 285
 }

+ 2 - 1
models/good_models.go Целия файл

@@ -77,7 +77,8 @@ type GoodInfo struct {
77 77
 	DefaultCountUnit            string               `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
78 78
 	MinUnit                     string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
79 79
 	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
80
-	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:good_id;AssociationForeignKey:ID" json:"xt_warehouse_info"`
80
+	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
81
+	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
81 82
 }
82 83
 
83 84
 func (GoodInfo) TableName() string {

+ 2 - 2
models/self_drug_models.go Целия файл

@@ -365,9 +365,9 @@ type XtDrugAutomaticReduceDetail struct {
365 365
 	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
366 366
 	RecordTime              int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
367 367
 	OrgId                   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
368
-	GoodId                  int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
369
-	GoodTypeId              int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
368
+	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
370 369
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
370
+	CountUnit               string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
371 371
 }
372 372
 
373 373
 func (XtDrugAutomaticReduceDetail) TableName() string {

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

@@ -520,6 +520,7 @@ type VmStockFlow struct {
520 520
 	CancelOutDetailId       int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
521 521
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
522 522
 	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
523
+	ReturnCount             int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
523 524
 }
524 525
 
525 526
 func (VmStockFlow) TableName() string {
@@ -555,3 +556,195 @@ type CancelStockInfo struct {
555 556
 func (CancelStockInfo) TableName() string {
556 557
 	return "xt_cancel_stock_info"
557 558
 }
559
+
560
+type VmBaseDrug struct {
561
+	ID                          int64                     `gorm:"column:id" json:"id" form:"id"`
562
+	DrugName                    string                    `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
563
+	Pinyin                      string                    `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
564
+	Wubi                        string                    `gorm:"column:wubi" json:"wubi" form:"wubi"`
565
+	DrugAlias                   string                    `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
566
+	DrugAliasPinyin             string                    `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
567
+	DrugAliasWubi               string                    `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
568
+	DrugCategory                int64                     `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
569
+	DrugSpec                    string                    `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
570
+	DrugType                    int64                     `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
571
+	DrugStockLimit              string                    `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
572
+	DrugOriginPlace             string                    `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
573
+	DrugDosageForm              int64                     `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
574
+	MedicalInsuranceLevel       int64                     `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
575
+	MaxUnit                     string                    `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
576
+	MinNumber                   int64                     `gorm:"column:min_number" json:"min_number" form:"min_number"`
577
+	MinUnit                     string                    `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
578
+	Dose                        float64                   `gorm:"column:dose" json:"dose" form:"dose"`
579
+	DoseUnit                    string                    `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
580
+	UnitMatrixing               string                    `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
581
+	RetailPrice                 float64                   `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
582
+	MinPrice                    float64                   `gorm:"column:min_price" json:"min_price" form:"min_price"`
583
+	LastPrice                   float64                   `gorm:"column:last_price" json:"last_price" form:"last_price"`
584
+	DrugControl                 int64                     `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
585
+	Number                      string                    `gorm:"column:number" json:"number" form:"number"`
586
+	DrugClassify                string                    `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
587
+	DrugDose                    float64                   `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
588
+	DrugDoseUnit                int64                     `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
589
+	MedicalInsuranceNumber      string                    `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
590
+	Manufacturer                int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
591
+	PharmacologyCategory        int64                     `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
592
+	StatisticsCategory          int64                     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
593
+	Code                        string                    `gorm:"column:code" json:"code" form:"code"`
594
+	IsSpecialDiseases           int64                     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
595
+	IsRecord                    int64                     `gorm:"column:is_record" json:"is_record" form:"is_record"`
596
+	Agent                       string                    `gorm:"column:agent" json:"agent" form:"agent"`
597
+	DrugStatus                  string                    `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
598
+	LimitRemark                 string                    `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
599
+	DeliveryWay                 string                    `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
600
+	ExecutionFrequency          string                    `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
601
+	SingleDose                  float64                   `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
602
+	PrescribingNumber           float64                   `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
603
+	Label                       int64                     `gorm:"column:label" json:"label" form:"label"`
604
+	Sort                        int64                     `gorm:"column:sort" json:"sort" form:"sort"`
605
+	IsUseDoctorAdvice           int64                     `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
606
+	IsDefault                   int64                     `gorm:"column:is_default" json:"is_default" form:"is_default"`
607
+	IsChargePredict             int64                     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
608
+	IsStatisticsWork            int64                     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
609
+	IsChargeUse                 int64                     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
610
+	Status                      int64                     `gorm:"column:status" json:"status" form:"status"`
611
+	Ctime                       int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
612
+	Mtime                       int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
613
+	OrgId                       int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
614
+	DrugCode                    string                    `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
615
+	Dealer                      int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
616
+	PrescriptionMark            int64                     `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
617
+	RecordDate                  int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
618
+	DrugRemark                  string                    `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
619
+	SocialSecurityDirectoryCode string                    `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
620
+	DoseCode                    string                    `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
621
+	IsMark                      int64                     `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
622
+	HospApprFlag                int64                     `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
623
+	LmtUsedFlag                 int64                     `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
624
+	DrugDay                     string                    `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
625
+	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
626
+	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
627
+	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
628
+	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
629
+	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
630
+}
631
+
632
+func (VmBaseDrug) TableName() string {
633
+	return "xt_base_drug"
634
+}
635
+
636
+type VsDrugWarehouseInfo struct {
637
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
638
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
639
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
640
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
641
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
642
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
643
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
644
+	WarehouseingUnit string  `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
645
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
646
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
647
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
648
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
649
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
650
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
651
+	Dealer           int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
652
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
653
+	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
654
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
655
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
656
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
657
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
658
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
659
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
660
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
661
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
662
+	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
663
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
664
+}
665
+
666
+func (VsDrugWarehouseInfo) TableName() string {
667
+	return "xt_drug_warehouse_info"
668
+}
669
+
670
+type VsDrugCancelStockInfo struct {
671
+	ID               int64       `gorm:"column:id" json:"id" form:"id"`
672
+	DrugId           int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
673
+	CancelStockId    int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
674
+	Count            int64       `gorm:"column:count" json:"count" form:"count"`
675
+	Price            float64     `gorm:"column:price" json:"price" form:"price"`
676
+	Total            float64     `gorm:"column:total" json:"total" form:"total"`
677
+	ProductDate      int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
678
+	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
679
+	Ctime            int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
680
+	Mtime            int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
681
+	Status           int64       `gorm:"column:status" json:"status" form:"status"`
682
+	OrgId            int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
683
+	OrderNumber      string      `gorm:"column:order_number" json:"order_number" form:"order_number"`
684
+	Type             int64       `gorm:"column:type" json:"type" form:"type"`
685
+	Dealer           string      `gorm:"column:dealer" json:"dealer" form:"dealer"`
686
+	Manufacturer     string      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
687
+	RetailPrice      float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
688
+	RetailTotalPrice float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
689
+	Number           string      `gorm:"column:number" json:"number" form:"number"`
690
+	RegisterAccount  string      `gorm:"column:register_account" json:"register_account" form:"register_account"`
691
+	Remark           string      `gorm:"column:remark" json:"remark" form:"remark"`
692
+	BatchNumber      string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
693
+	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
694
+	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" `
695
+}
696
+
697
+func (VsDrugCancelStockInfo) TableName() string {
698
+	return "xt_drug_cancel_stock_info"
699
+}
700
+
701
+type VsDrugWarehouseOutInfo struct {
702
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
703
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
704
+	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
705
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
706
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
707
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
708
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
709
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
710
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
711
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
712
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
713
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
714
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
715
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
716
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
717
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
718
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
719
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
720
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
721
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
722
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
723
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
724
+	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
725
+	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
726
+}
727
+
728
+func (VsDrugWarehouseOutInfo) TableName() string {
729
+	return "xt_drug_warehouse_out_info"
730
+}
731
+
732
+type VmStockFlowOne struct {
733
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
734
+	WarehousingId           int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
735
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
736
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
737
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
738
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
739
+	SystemTime              int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
740
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
741
+	WarehousingOrder        string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
742
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
743
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
744
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
745
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
746
+	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
747
+	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
748
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
749
+	Name                    string  `gorm:"column:name" json:"name" form:"name"`
750
+}

+ 45 - 4
service/gobal_config_service.go Целия файл

@@ -499,7 +499,6 @@ func GetDrugWarehuseOrderInfo(orgid int64) (drug []*models.DrugWarehouseInfo, er
499 499
 func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
500 500
 	offset := (page - 1) * limit
501 501
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
502
-
503 502
 	likeKey := "%" + keyword + "%"
504 503
 	if orgid > 0 {
505 504
 		db = db.Where("x.org_id = ?", orgid)
@@ -537,6 +536,26 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
537 536
 	return list, total, err
538 537
 }
539 538
 
539
+func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
540
+
541
+	offset := (page - 1) * limit
542
+	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
543
+	likeKey := "%" + keyword + "%"
544
+	if orgid > 0 {
545
+		db = db.Where("org_id = ?", orgid)
546
+	}
547
+	if drugcategory > 0 {
548
+		db = db.Where("drug_type = ?", drugcategory)
549
+	}
550
+
551
+	if len(keyword) > 0 {
552
+		db = db.Where("drug_name like ?", likeKey)
553
+	}
554
+
555
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugCancelStockInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugWarehouseOutInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Find(&drug).Error
556
+	return drug, total, err
557
+}
558
+
540 559
 func GetDrugStockFlow(drugid int64, startime int64, endtime int64, page int64, limit int64, orgid int64) (list []*models.StDrugWarehouseInfo, total int64, err error) {
541 560
 
542 561
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
@@ -643,7 +662,7 @@ func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*mo
643 662
 	if orgid > 0 {
644 663
 		db = db.Where("x.org_id = ?", orgid)
645 664
 	}
646
-	err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
665
+	err = db.Select("x.count,x.drug_id,x.count_unit").Find(&info).Error
647 666
 	return info, err
648 667
 }
649 668
 
@@ -659,7 +678,7 @@ func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*m
659 678
 	if orgid > 0 {
660 679
 		db = db.Where("x.org_id = ?", orgid)
661 680
 	}
662
-	err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
681
+	err = db.Select("x.count,x.drug_id,x.count_unit").Find(&info).Error
663 682
 	return info, err
664 683
 
665 684
 }
@@ -681,6 +700,22 @@ func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []
681 700
 	return info, err
682 701
 }
683 702
 
703
+func GetAllCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
704
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
705
+
706
+	if startime > 0 {
707
+		db = db.Where("x.ctime >=?", startime)
708
+	}
709
+	if endtime > 0 {
710
+		db = db.Where("x.ctime<=?", endtime)
711
+	}
712
+	if orgid > 0 {
713
+		db = db.Where("x.org_id = ?", orgid)
714
+	}
715
+	err = db.Find(&info).Error
716
+	return info, err
717
+}
718
+
684 719
 func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
685 720
 
686 721
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
@@ -697,6 +732,12 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
697 732
 	return info, err
698 733
 }
699 734
 
735
+func GetDrugStockFlowDetail(id int64, orgid int64) (drugflow []*models.XtDrugAutomaticReduceDetail, err error) {
736
+
737
+	err = XTReadDB().Where("record_time = ? and org_id = ? and status = 1", id, orgid).Find(&drugflow).Error
738
+	return drugflow, err
739
+}
740
+
700 741
 func GetAllSingleDrugDetail(id int64, orgid int64) (outInfo []*models.VmDrugWarehouseOutInfo, err error) {
701 742
 
702 743
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
@@ -734,6 +775,6 @@ func FindeDrugWarehouserInfo(ware_out_id int64, drug_id int64, orgid int64) (out
734 775
 
735 776
 func GetDrugFlowBatch(ware_out_id int64, drug_id int64, orgid int64) (flow []*models.DrugFlow, err error) {
736 777
 
737
-	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Group("number").Find(&flow).Error
778
+	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
738 779
 	return flow, err
739 780
 }

+ 1 - 1
service/mobile_dialysis_service.go Целия файл

@@ -521,7 +521,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
521 521
 
522 522
 	err := readDb.
523 523
 		Model(&models.DoctorAdvice{}).
524
-		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and advice_type = 2", patientID, orgID, recordDate).
524
+		Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
525 525
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
526 526
 		Order("start_time asc, groupno desc, advice_order desc, id asc").
527 527
 		Scan(&records).Error

+ 147 - 0
service/stock_service.go Целия файл

@@ -505,6 +505,11 @@ func UpdateBaseDrug(lib *models.BaseDrugLib, id int64) error {
505 505
 	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"total": lib.Total}).Error
506 506
 	return err
507 507
 }
508
+func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
509
+	info := models.DrugWarehouseInfo{}
510
+	err := XTReadDB().Model(&info).Where("id=? and status = 1", id).Find(&info).Error
511
+	return info, err
512
+}
508 513
 
509 514
 func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
510 515
 	if len(drugflow) > 0 {
@@ -1397,6 +1402,7 @@ type DrugWarehouseOutInfo struct {
1397 1402
 	Number                  string  `gorm:"column:number" json:"number" form:"number"`
1398 1403
 	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1399 1404
 	Drug                    *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1405
+	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1400 1406
 }
1401 1407
 
1402 1408
 func (DrugWarehouseOutInfo) TableName() string {
@@ -1799,6 +1805,13 @@ func GetLastWarehousingById(warehousing_id int64, orgid int64) (models.Warehousi
1799 1805
 	return info, err
1800 1806
 }
1801 1807
 
1808
+func GetLastWarehousingByIdOne(warehousing_id int64, orgid int64) (models.WarehousingInfo, error) {
1809
+
1810
+	info := models.WarehousingInfo{}
1811
+	err = XTReadDB().Model(&info).Where("id = ? and good_id = ? and status = 1", warehousing_id, orgid).Find(&info).Error
1812
+	return info, err
1813
+}
1814
+
1802 1815
 func UpDateWarehousingInfo(info *models.WarehousingInfo) (err error) {
1803 1816
 	err = writeDb.Save(&info).Error
1804 1817
 	return err
@@ -3168,6 +3181,26 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
3168 3181
 	return info, total, err
3169 3182
 }
3170 3183
 
3184
+func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.GoodInfo, total int64, err error) {
3185
+
3186
+	offset := (page - 1) * limit
3187
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status= 1")
3188
+
3189
+	likeKey := "%" + keyword + "%"
3190
+	if len(likeKey) > 0 {
3191
+		db = db.Where("x.good_name like ?", likeKey)
3192
+	}
3193
+	if orgid > 0 {
3194
+		db = db.Where("x.org_id = ?", orgid)
3195
+	}
3196
+	if good_type > 0 {
3197
+		db = db.Where("x.good_type_id = ?", good_type)
3198
+	}
3199
+
3200
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Preload("CancelStockInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Find(&info).Error
3201
+	return info, total, err
3202
+}
3203
+
3171 3204
 func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
3172 3205
 
3173 3206
 	offset := (page - 1) * limit
@@ -3514,6 +3547,35 @@ func GetDrugTotalCount(drugid int64, orgid int64) (info models.VmDrugWarehouseIn
3514 3547
 	return info, err
3515 3548
 }
3516 3549
 
3550
+func GetDrugTotalCountSwx(id int64, orgid int64) (info models.VmDrugWarehouseInfo, err error) {
3551
+
3552
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3553
+	if id > 0 {
3554
+		db = db.Where("x.id = ?", id)
3555
+	}
3556
+	if orgid > 0 {
3557
+		db = db.Where("x.org_id = ?", orgid)
3558
+	}
3559
+	err = db.Select("x.drug_id,sum(x.stock_max_number) as count,sum(x.stock_min_number) as stock_min_number,x.max_unit,x.min_unit").Find(&info).Error
3560
+	return info, err
3561
+}
3562
+
3563
+func GetDrugTotalCountOne(drugid int64, orgid int64, id int64) (models.VmDrugWarehouseInfo, error) {
3564
+	info := models.VmDrugWarehouseInfo{}
3565
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3566
+	if id == 0 {
3567
+		db = db.Where("id = ?", id)
3568
+	}
3569
+	if drugid > 0 {
3570
+		db = db.Where("x.drug_id = ?", drugid)
3571
+	}
3572
+	if orgid > 0 {
3573
+		db = db.Where("x.org_id = ?", orgid)
3574
+	}
3575
+	err = db.Select("x.drug_id,x.stock_max_number,x.stock_min_number,x.max_unit,x.min_unit").Find(&info).Error
3576
+	return info, err
3577
+}
3578
+
3517 3579
 func GetDrugByGoodId(drugid int64) (models.BaseDrugLib, error) {
3518 3580
 
3519 3581
 	lib := models.BaseDrugLib{}
@@ -3668,6 +3730,12 @@ func GetWarehoureOrderInfoCount(goodid int64, orgid int64) (info models.Warehous
3668 3730
 	return info, err
3669 3731
 }
3670 3732
 
3733
+func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3734
+	stock := models.CancelStock{}
3735
+	err := XTWriteDB().Model(&stock).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
3736
+	return stock, err
3737
+}
3738
+
3671 3739
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3672 3740
 
3673 3741
 	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Group("number").Find(&info).Error
@@ -3686,6 +3754,25 @@ func GetStockFlowBatchNumber(id int64, goodid int64) (stock []*models.VmStockFlo
3686 3754
 	return stock, err
3687 3755
 }
3688 3756
 
3757
+func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
3758
+
3759
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1")
3760
+	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
3761
+	fmt.Println(table)
3762
+	tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
3763
+	fmt.Println(tableone)
3764
+	if id > 0 {
3765
+		db = db.Where("x.warehouse_out_id = ?", id)
3766
+	}
3767
+	if goodid > 0 {
3768
+		db = db.Where("x.good_id = ?", goodid)
3769
+	}
3770
+
3771
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
3772
+	//err = XTReadDB().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
3773
+	return stock, err
3774
+}
3775
+
3689 3776
 func GetDrugBatchNumber(drug_id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
3690 3777
 
3691 3778
 	err = XTReadDB().Model(&info).Where("drug_id = ? and org_id = ? and status = 1 and batch_number <>''", drug_id, orgid).Find(&info).Error
@@ -3814,6 +3901,25 @@ func CreateStockFlowOne(flow models.VmStockFlow) error {
3814 3901
 	return err
3815 3902
 }
3816 3903
 
3904
+func UpdatedStockFlow(flow models.VmStockFlow) error {
3905
+	err := XTWriteDB().Save(&flow).Error
3906
+	return err
3907
+}
3908
+
3909
+func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (*models.VmStockFlow, error) {
3910
+
3911
+	flow := models.VmStockFlow{}
3912
+	var err error
3913
+	err = XTReadDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&flow).Error
3914
+	if err == gorm.ErrRecordNotFound {
3915
+		return nil, err
3916
+	}
3917
+	if err != nil {
3918
+		return nil, err
3919
+	}
3920
+	return &flow, nil
3921
+}
3922
+
3817 3923
 func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
3818 3924
 
3819 3925
 	info := models.WarehouseOutInfo{}
@@ -4119,3 +4225,44 @@ func GetLastCancelInfo(id int64, goodid int64) (models.CancelStockInfo, error) {
4119 4225
 	err := XTReadDB().Model(&info).Where("warehouse_info_id  = ? and good_id = ? and status = 1", id, goodid).Find(&info).Error
4120 4226
 	return info, err
4121 4227
 }
4228
+
4229
+func UpdateStockFlow(flow models.VmStockFlow, goodid int64, warehousing_id int64) error {
4230
+
4231
+	err := XTWriteDB().Model(&flow).Where("good_id = ? and warehousing_id= ? and status = 1", goodid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4232
+	return err
4233
+}
4234
+
4235
+func UpdateDrugFlow(flow models.DrugFlow, drugid int64, warehousing_id int64) error {
4236
+
4237
+	drugFlow := models.DrugFlow{}
4238
+	err := XTWriteDB().Model(&drugFlow).Where("drug_id = ? and warehousing_id= ? and status = 1", drugid, warehousing_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4239
+	return err
4240
+}
4241
+
4242
+func UpdateDrugCancel(id int64) (models.DrugCancelStock, error) {
4243
+
4244
+	stock := models.DrugCancelStock{}
4245
+
4246
+	err := XTWriteDB().Model(&stock).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
4247
+	return stock, err
4248
+}
4249
+
4250
+func GetDrugWarehouseOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugWarehouseOutInfo, err error) {
4251
+
4252
+	db := XTReadDB().Model(&info)
4253
+	if warehouse_info_id > 0 {
4254
+		db = db.Where("warehouse_info_id = ?", warehouse_info_id)
4255
+	}
4256
+	if drug_id > 0 {
4257
+		db = db.Where("drug_id = ? and status =1", drug_id)
4258
+	}
4259
+
4260
+	err = db.Find(&info).Error
4261
+	return info, err
4262
+}
4263
+
4264
+func GetCancelDrugStockOutInfo(warehouse_info_id int64, drug_id int64) (info []*models.DrugCancelStockInfo, err error) {
4265
+
4266
+	err = XTReadDB().Model(&info).Where("batch_number_id =? and drug_id = ? and status = 1", warehouse_info_id, drug_id).Find(&info).Error
4267
+	return info, err
4268
+}

+ 218 - 44
service/warhouse_service.go Целия файл

@@ -141,6 +141,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
141 141
 			ExpiryDate:              warehouse.ExpiryDate,
142 142
 			PatientId:               advice.PatientId,
143 143
 			Count:                   count,
144
+			WarehouseInfoId:         warehouse.ID,
144 145
 		}
145 146
 
146 147
 		fmt.Println("单据号2232322323232323232323232323232323", warehouseout.WarehouseOutOrderNumber)
@@ -181,8 +182,8 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
181 182
 			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
182 183
 		}
183 184
 		details := &models.DrugAutomaticReduceDetail{
184
-			WarehouseOutId:          warehouseOutInfo.ID,
185
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
185
+			WarehouseOutId:          warehouseout.ID,
186
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
186 187
 			PatientId:               advice.PatientId,
187 188
 			Ctime:                   time.Now().Unix(),
188 189
 			Mtime:                   time.Now().Unix(),
@@ -256,38 +257,71 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
256 257
 			ExpiryDate:              warehouse.ExpiryDate,
257 258
 			PatientId:               advice.PatientId,
258 259
 			Count:                   count,
260
+			WarehouseInfoId:         warehouse.ID,
259 261
 		}
260
-
261
-		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
262
-		if errOne != nil {
263
-			return errOne
264
-		} else {
265
-			details := &models.DrugAutomaticReduceDetail{
266
-				WarehouseOutId:          warehouseOutInfo.ID,
267
-				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
268
-				PatientId:               advice.PatientId,
269
-				Ctime:                   time.Now().Unix(),
270
-				Mtime:                   time.Now().Unix(),
271
-				Status:                  1,
272
-				RecordTime:              advice.RecordDate,
273
-				OrgId:                   orgID,
274
-				DrugId:                  advice.DrugId,
275
-				Count:                   count,
276
-				CountUnit:               advice.PrescribingNumberUnit,
277
-			}
278
-			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
279
-			if errTwo != nil {
280
-				return errTwo
262
+		//查询是否存在数据
263
+		_, errcodes := GetDrugWarehouseOutInfoIsExit(advice.DrugId, advice.PatientId, advice.RecordDate)
264
+		if errcodes == gorm.ErrRecordNotFound {
265
+			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
266
+			if errOne != nil {
267
+				return errOne
281 268
 			}
269
+		} else if errcodes == nil {
270
+			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
282 271
 		}
272
+
273
+		details := &models.DrugAutomaticReduceDetail{
274
+			WarehouseOutId:          warehouseout.ID,
275
+			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
276
+			PatientId:               advice.PatientId,
277
+			Ctime:                   time.Now().Unix(),
278
+			Mtime:                   time.Now().Unix(),
279
+			Status:                  1,
280
+			RecordTime:              advice.RecordDate,
281
+			OrgId:                   orgID,
282
+			DrugId:                  advice.DrugId,
283
+			Count:                   stock_number,
284
+			CountUnit:               advice.PrescribingNumberUnit,
285
+		}
286
+		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
287
+		if errTwo != nil {
288
+			return errTwo
289
+		}
290
+
283 291
 		// 出库完成后,要将该批次库存清零
284 292
 		warehouse.StockMaxNumber = 0
285 293
 		warehouse.StockMinNumber = 0
286 294
 		warehouse.Mtime = time.Now().Unix()
287 295
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
296
+
288 297
 		if errThree != nil {
289 298
 			return errThree
290 299
 		}
300
+
301
+		drugflow := models.DrugFlow{
302
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
303
+			WarehouseOutId:          warehouseout.ID,
304
+			DrugId:                  advice.DrugId,
305
+			Number:                  warehouse.Number,
306
+			ProductDate:             warehouse.ProductDate,
307
+			ExpireDate:              warehouse.ExpiryDate,
308
+			Count:                   stock_number,
309
+			Price:                   baseInfo.RetailPrice,
310
+			Status:                  1,
311
+			Ctime:                   time.Now().Unix(),
312
+			UserOrgId:               orgID,
313
+			Manufacturer:            warehouse.Manufacturer,
314
+			Dealer:                  warehouse.Dealer,
315
+			BatchNumber:             warehouse.BatchNumber,
316
+			MaxUnit:                 advice.PrescribingNumberUnit,
317
+			ConsumableType:          3,
318
+			IsEdit:                  1,
319
+			Creator:                 advice.ExecutionStaff,
320
+			IsSys:                   1,
321
+			PatientId:               advice.PatientId,
322
+		}
323
+
324
+		CreateDrugFlowOne(drugflow)
291 325
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
292 326
 		prescribingNumber_two_temp := deliver_number - stock_number
293 327
 		overPlusNumber := float64(prescribingNumber_two_temp)
@@ -419,6 +453,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
419 453
 			ProductDate:             warehouse.ProductDate,
420 454
 			ExpiryDate:              warehouse.ExpiryDate,
421 455
 			PatientId:               advice.PatientId,
456
+			WarehouseInfoId:         warehouse.ID,
422 457
 		}
423 458
 
424 459
 		warehouseOutInfo.Count = count
@@ -461,8 +496,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
461 496
 		}
462 497
 
463 498
 		details := &models.DrugAutomaticReduceDetail{
464
-			WarehouseOutId:          warehouseOutInfo.ID,
465
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
499
+			WarehouseOutId:          warehouseout.ID,
500
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
466 501
 			PatientId:               advice.PatientId,
467 502
 			Ctime:                   time.Now().Unix(),
468 503
 			Mtime:                   time.Now().Unix(),
@@ -535,6 +570,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
535 570
 			ProductDate:             warehouse.ProductDate,
536 571
 			ExpiryDate:              warehouse.ExpiryDate,
537 572
 			PatientId:               advice.PatientId,
573
+			WarehouseInfoId:         warehouse.ID,
538 574
 		}
539 575
 
540 576
 		warehouseOutInfo.Count = count
@@ -548,7 +584,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
548 584
 			Number:                  warehouse.Number,
549 585
 			ProductDate:             warehouse.ProductDate,
550 586
 			ExpireDate:              warehouse.ExpiryDate,
551
-			Count:                   count,
587
+			Count:                   stock_number,
552 588
 			Price:                   baseInfo.RetailPrice,
553 589
 			Status:                  1,
554 590
 			Ctime:                   time.Now().Unix(),
@@ -577,8 +613,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
577 613
 			UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
578 614
 		}
579 615
 		details := &models.DrugAutomaticReduceDetail{
580
-			WarehouseOutId:          warehouseOutInfo.ID,
581
-			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
616
+			WarehouseOutId:          warehouseout.ID,
617
+			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
582 618
 			PatientId:               advice.PatientId,
583 619
 			Ctime:                   time.Now().Unix(),
584 620
 			Mtime:                   time.Now().Unix(),
@@ -668,6 +704,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
668 704
 			Count:                   advice.Count,
669 705
 			RetailPrice:             advice.RetailPrice,
670 706
 			Price:                   advice.Price,
707
+			WarehouseInfoId:         advice.WarehouseInfoId,
671 708
 		}
672 709
 
673 710
 		warehouseOutInfo.Count = prescribingNumber
@@ -872,6 +909,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
872 909
 func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
873 910
 
874 911
 	fmt.Println("count23232323232323232323232323", count)
912
+	fmt.Println("hhhh2h3h3h2h23h32hh23h32h23", goods.Count)
875 913
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
876 914
 	var deliver_number int64 = 0
877 915
 	var stock_number int64 = 0
@@ -885,8 +923,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
885 923
 	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId)
886 924
 	if err != nil {
887 925
 
888
-		fmt.Println("进来232323232323234343434343434343434343", warehouse.StockCount)
889
-
890 926
 		return errors.New("库存数量不足")
891 927
 	}
892 928
 
@@ -897,6 +933,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
897 933
 	info, _ := GetGoodInformationByGoodId(goods.GoodId)
898 934
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
899 935
 	if stock_number >= deliver_number {
936
+		fmt.Println("进来22323232323232323232233223323223322323")
900 937
 		warehouseOutInfo := &models.WarehouseOutInfo{
901 938
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
902 939
 			WarehouseOutId:          warehouseOut.ID,
@@ -974,14 +1011,47 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
974 1011
 				IsSys:                   1,
975 1012
 				PatientId:               patient_id,
976 1013
 			}
977
-			CreateStockFlowOne(flow)
1014
+			//查询流水是否存在
1015
+			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1016
+			fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
1017
+
1018
+			if errflow == gorm.ErrRecordNotFound {
1019
+				CreateStockFlowOne(flow)
1020
+			} else if errflow == nil {
1021
+				flow := models.VmStockFlow{
1022
+					ID:                      exsit.ID,
1023
+					WarehouseOutId:          warehouseOut.ID,
1024
+					WarehousingId:           warehouse.ID,
1025
+					GoodId:                  goods.GoodId,
1026
+					Number:                  warehouse.Number,
1027
+					ProductDate:             warehouse.ProductDate,
1028
+					ExpireDate:              warehouse.ExpiryDate,
1029
+					Count:                   exsit.Count + goods.Count,
1030
+					Price:                   info.PackingPrice,
1031
+					Status:                  1,
1032
+					Ctime:                   time.Now().Unix(),
1033
+					UserOrgId:               orgID,
1034
+					Manufacturer:            info.Manufacturer,
1035
+					Dealer:                  info.Dealer,
1036
+					LicenseNumber:           warehouse.LicenseNumber,
1037
+					IsEdit:                  2,
1038
+					Creator:                 warehouseOut.Creater,
1039
+					SystemTime:              record_time,
1040
+					ConsumableType:          3,
1041
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1042
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1043
+					IsSys:                   1,
1044
+					PatientId:               patient_id,
1045
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1046
+				}
1047
+				UpdatedStockFlow(flow)
1048
+			}
978 1049
 			if errTwo != nil {
979 1050
 				return errTwo
980 1051
 			}
981 1052
 		} else if errcode == nil {
982
-			DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
983
-			CreateAutoReduceRecord(&details)
984
-			//插入库存流水表
1053
+
1054
+			fmt.Println("wodeeeeeeeeeeewewewewewewewewweewewewewewweewewew")
985 1055
 			flow := models.VmStockFlow{
986 1056
 				WarehouseOutId:          warehouseOut.ID,
987 1057
 				WarehousingId:           warehouse.ID,
@@ -1006,7 +1076,44 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1006 1076
 				IsSys:                   1,
1007 1077
 				PatientId:               patient_id,
1008 1078
 			}
1009
-			CreateStockFlowOne(flow)
1079
+			//查询流水是否存在
1080
+			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1081
+			fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
1082
+
1083
+			if errflow == gorm.ErrRecordNotFound {
1084
+				CreateStockFlowOne(flow)
1085
+			} else if errflow == nil {
1086
+				flow := models.VmStockFlow{
1087
+					ID:                      exsit.ID,
1088
+					WarehouseOutId:          warehouseOut.ID,
1089
+					WarehousingId:           warehouse.ID,
1090
+					GoodId:                  goods.GoodId,
1091
+					Number:                  warehouse.Number,
1092
+					ProductDate:             warehouse.ProductDate,
1093
+					ExpireDate:              warehouse.ExpiryDate,
1094
+					Count:                   exsit.Count + goods.Count,
1095
+					Price:                   info.PackingPrice,
1096
+					Status:                  1,
1097
+					Ctime:                   time.Now().Unix(),
1098
+					UserOrgId:               orgID,
1099
+					Manufacturer:            info.Manufacturer,
1100
+					Dealer:                  info.Dealer,
1101
+					LicenseNumber:           warehouse.LicenseNumber,
1102
+					IsEdit:                  2,
1103
+					Creator:                 warehouseOut.Creater,
1104
+					SystemTime:              record_time,
1105
+					ConsumableType:          3,
1106
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1107
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1108
+					IsSys:                   1,
1109
+					PatientId:               patient_id,
1110
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1111
+				}
1112
+				UpdatedStockFlow(flow)
1113
+			}
1114
+			DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1115
+			CreateAutoReduceRecord(&details)
1116
+
1010 1117
 		}
1011 1118
 
1012 1119
 		maxNumber = goods.Count
@@ -1029,7 +1136,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1029 1136
 
1030 1137
 		return nil
1031 1138
 	} else {
1032
-
1139
+		fmt.Println("不进来22323232323232323232233223323223322323")
1033 1140
 		// 当刚批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1034 1141
 		warehouseOutInfo := &models.WarehouseOutInfo{
1035 1142
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1056,7 +1163,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1056 1163
 		warehouseOutInfo.Count = stock_number
1057 1164
 
1058 1165
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, goods.PatientId, record_time)
1059
-
1166
+		fmt.Println("hhhhh2h323233223232323", errcodes)
1060 1167
 		if errcodes == gorm.ErrRecordNotFound {
1061 1168
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
1062 1169
 
@@ -1072,7 +1179,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1072 1179
 				ProductDate:             warehouse.ProductDate,
1073 1180
 				ExpireDate:              warehouse.ExpiryDate,
1074 1181
 				Count:                   stock_number,
1075
-				Price:                   warehouse.Price,
1182
+				Price:                   info.PackingPrice,
1076 1183
 				Status:                  1,
1077 1184
 				Ctime:                   time.Now().Unix(),
1078 1185
 				UserOrgId:               orgID,
@@ -1088,11 +1195,46 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1088 1195
 				IsSys:                   1,
1089 1196
 				PatientId:               patient_id,
1090 1197
 			}
1091
-			CreateStockFlowOne(flow)
1198
+			//查询流水是否存在
1199
+			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1200
+
1201
+			if errflows == gorm.ErrRecordNotFound {
1202
+				CreateStockFlowOne(flow)
1203
+			} else if errflows == nil {
1204
+				flow := models.VmStockFlow{
1205
+					ID:                      exsit.ID,
1206
+					WarehouseOutId:          warehouseOut.ID,
1207
+					WarehousingId:           warehouse.ID,
1208
+					GoodId:                  goods.GoodId,
1209
+					Number:                  warehouse.Number,
1210
+					ProductDate:             warehouse.ProductDate,
1211
+					ExpireDate:              warehouse.ExpiryDate,
1212
+					Count:                   exsit.Count + goods.Count,
1213
+					Price:                   info.PackingPrice,
1214
+					Status:                  1,
1215
+					Ctime:                   time.Now().Unix(),
1216
+					UserOrgId:               orgID,
1217
+					Manufacturer:            info.Manufacturer,
1218
+					Dealer:                  info.Dealer,
1219
+					LicenseNumber:           warehouse.LicenseNumber,
1220
+					IsEdit:                  2,
1221
+					Creator:                 warehouseOut.Creater,
1222
+					SystemTime:              record_time,
1223
+					ConsumableType:          3,
1224
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1225
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1226
+					IsSys:                   1,
1227
+					PatientId:               patient_id,
1228
+					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1229
+				}
1230
+				UpdatedStockFlow(flow)
1231
+			}
1232
+
1092 1233
 		} else if errcodes == nil {
1234
+			fmt.Println("尽力3323232322323232323232323232323")
1093 1235
 			goods.Count = deliver_number - stock_number
1094
-			//更新数量为  刚批次剩余数量  + 还有未出的数量
1095
-			warehouseOutInfo.Count = goods.Count + stock_number
1236
+			//更新数量为  批次剩余数量  + 还有未出的数量
1237
+			warehouseOutInfo.Count = stock_number
1096 1238
 			UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, goods.PatientId, record_time)
1097 1239
 			//插入库存流水表
1098 1240
 			flow := models.VmStockFlow{
@@ -1102,8 +1244,8 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1102 1244
 				Number:                  warehouse.Number,
1103 1245
 				ProductDate:             warehouse.ProductDate,
1104 1246
 				ExpireDate:              warehouse.ExpiryDate,
1105
-				Count:                   goods.Count + stock_number,
1106
-				Price:                   warehouse.Price,
1247
+				Count:                   stock_number,
1248
+				Price:                   info.PackingPrice,
1107 1249
 				Status:                  1,
1108 1250
 				Ctime:                   time.Now().Unix(),
1109 1251
 				UserOrgId:               orgID,
@@ -1119,7 +1261,39 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1119 1261
 				IsSys:                   1,
1120 1262
 				PatientId:               patient_id,
1121 1263
 			}
1122
-			CreateStockFlowOne(flow)
1264
+			//查询流水是否存在
1265
+			exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
1266
+			if errflows == gorm.ErrRecordNotFound {
1267
+				CreateStockFlowOne(flow)
1268
+			} else if errflows == nil {
1269
+				fmt.Println("尽力3323232322323232323232323232323", exsit.Count+goods.Count)
1270
+				flow := models.VmStockFlow{
1271
+					ID:                      exsit.ID,
1272
+					WarehouseOutId:          warehouseOut.ID,
1273
+					WarehousingId:           warehouse.ID,
1274
+					GoodId:                  goods.GoodId,
1275
+					Number:                  warehouse.Number,
1276
+					ProductDate:             warehouse.ProductDate,
1277
+					ExpireDate:              warehouse.ExpiryDate,
1278
+					Count:                   exsit.Count + goods.Count,
1279
+					Price:                   info.PackingPrice,
1280
+					Status:                  1,
1281
+					Ctime:                   time.Now().Unix(),
1282
+					UserOrgId:               orgID,
1283
+					Manufacturer:            info.Manufacturer,
1284
+					Dealer:                  info.Dealer,
1285
+					LicenseNumber:           warehouse.LicenseNumber,
1286
+					IsEdit:                  2,
1287
+					Creator:                 warehouseOut.Creater,
1288
+					SystemTime:              record_time,
1289
+					ConsumableType:          3,
1290
+					WarehouseOutDetailId:    warehouseOutInfo.ID,
1291
+					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1292
+					IsSys:                   1,
1293
+					PatientId:               patient_id,
1294
+				}
1295
+				UpdatedStockFlow(flow)
1296
+			}
1123 1297
 		}
1124 1298
 
1125 1299
 		// 出库完成后,要将该批次库存清零