Browse Source

11月8日库存管理

XMLWAN 2 years ago
parent
commit
4734b02df9

+ 102 - 6
controllers/his_api_controller.go View File

@@ -2123,6 +2123,16 @@ func (c *HisApiController) DeletePrescription() {
2123 2123
 								}
2124 2124
 								//出库
2125 2125
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2126
+								//查询默认仓库
2127
+								houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2128
+								goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
2129
+								var sum_count int64
2130
+								var sum_in_count int64
2131
+								for _, it := range goodList {
2132
+									sum_count += it.StockCount
2133
+									sum_in_count += it.WarehousingCount
2134
+								}
2135
+								service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
2126 2136
 							} else if err == nil {
2127 2137
 
2128 2138
 								prepare := &models.DialysisBeforePrepare{
@@ -2136,6 +2146,16 @@ func (c *HisApiController) DeletePrescription() {
2136 2146
 								}
2137 2147
 								//出库
2138 2148
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2149
+								//查询默认仓库
2150
+								houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2151
+								goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
2152
+								var sum_count int64
2153
+								var sum_in_count int64
2154
+								for _, it := range goodList {
2155
+									sum_count += it.StockCount
2156
+									sum_in_count += it.WarehousingCount
2157
+								}
2158
+								service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
2139 2159
 							}
2140 2160
 
2141 2161
 						}
@@ -2182,7 +2202,7 @@ func (c *HisApiController) DeletePrescription() {
2182 2202
 						}
2183 2203
 
2184 2204
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2185
-						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, warehouseInfo.OrgId)
2205
+
2186 2206
 						adminUserInfo := c.GetAdminUserInfo()
2187 2207
 						operation_time := time.Now().Unix()
2188 2208
 						creater := adminUserInfo.AdminUser.Id
@@ -2279,6 +2299,24 @@ func (c *HisApiController) DeletePrescription() {
2279 2299
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, item.ID)
2280 2300
 						//删除流水
2281 2301
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2302
+
2303
+						//查询默认仓库
2304
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2305
+						//查询默认仓库剩余多少库存
2306
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2307
+						var sum_count int64
2308
+						var sum_in_count int64
2309
+						for _, it := range list {
2310
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2311
+							if it.MaxUnit == baseDrug.MaxUnit {
2312
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2313
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2314
+
2315
+							}
2316
+							sum_count += it.StockMaxNumber + it.StockMinNumber
2317
+							sum_in_count += it.WarehousingCount
2318
+						}
2319
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2282 2320
 					} else {
2283 2321
 						floatPrescrip := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 32)
2284 2322
 
@@ -2290,9 +2328,7 @@ func (c *HisApiController) DeletePrescription() {
2290 2328
 								StorehouseId:   houseConfig.DrugStorehouseOut,
2291 2329
 							}
2292 2330
 							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2293
-							var sum_count int64
2294
-							sum_count = prescribingNumber * drug.MinNumber
2295
-							service.ModifyDrugAddInformation(info.DrugId, sum_count, info.OrgId)
2331
+
2296 2332
 						}
2297 2333
 
2298 2334
 						adminUserInfo := c.GetAdminUserInfo()
@@ -2393,6 +2429,23 @@ func (c *HisApiController) DeletePrescription() {
2393 2429
 						//删除流水
2394 2430
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2395 2431
 
2432
+						//查询默认仓库
2433
+						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2434
+						//查询默认仓库剩余多少库存
2435
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2436
+						var sum_count int64
2437
+						var sum_in_count int64
2438
+						for _, it := range list {
2439
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2440
+							if it.MaxUnit == baseDrug.MaxUnit {
2441
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2442
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2443
+
2444
+							}
2445
+							sum_count += it.StockMaxNumber + it.StockMinNumber
2446
+							sum_in_count += it.WarehousingCount
2447
+						}
2448
+						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
2396 2449
 					}
2397 2450
 				}
2398 2451
 
@@ -2454,7 +2507,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2454 2507
 						}
2455 2508
 
2456 2509
 						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2457
-						service.ModifyDrugAddInformation(info.DrugId, warehouseInfo.StockMinNumber, info.OrgId)
2510
+
2458 2511
 						adminUserInfo := c.GetAdminUserInfo()
2459 2512
 						operation_time := time.Now().Unix()
2460 2513
 						creater := adminUserInfo.AdminUser.Id
@@ -2551,6 +2604,24 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2551 2604
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2552 2605
 						//删除流水
2553 2606
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2607
+
2608
+						//查询默认仓库
2609
+						houseConfig, _ := service.GetAllStoreHouseConfig(info.OrgId)
2610
+						//查询默认仓库剩余多少库存
2611
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, info.OrgId, info.DrugId)
2612
+						var sum_count int64
2613
+						var sum_in_count int64
2614
+						for _, it := range list {
2615
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2616
+							if it.MaxUnit == baseDrug.MaxUnit {
2617
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2618
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2619
+
2620
+							}
2621
+							sum_count += it.StockMaxNumber + it.StockMinNumber
2622
+							sum_in_count += it.WarehousingCount
2623
+						}
2624
+						service.UpdateMedicalSumCount(info.DrugId, sum_count, sum_in_count, info.OrgId)
2554 2625
 					} else {
2555 2626
 
2556 2627
 						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
@@ -2662,7 +2733,23 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2662 2733
 						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2663 2734
 						//删除流水
2664 2735
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2736
+						//查询默认仓库
2737
+						houseConfig, _ := service.GetAllStoreHouseConfig(info.OrgId)
2738
+						//查询默认仓库剩余多少库存
2739
+						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, info.OrgId, info.DrugId)
2740
+						var sum_count int64
2741
+						var sum_in_count int64
2742
+						for _, it := range list {
2743
+							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2744
+							if it.MaxUnit == baseDrug.MaxUnit {
2745
+								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2746
+								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2665 2747
 
2748
+							}
2749
+							sum_count += it.StockMaxNumber + it.StockMinNumber
2750
+							sum_in_count += it.WarehousingCount
2751
+						}
2752
+						service.UpdateMedicalSumCount(info.DrugId, sum_count, sum_in_count, info.OrgId)
2666 2753
 					}
2667 2754
 				}
2668 2755
 			}
@@ -2813,7 +2900,16 @@ func (c *HisApiController) DeleteProject() {
2813 2900
 				}
2814 2901
 				//回退库存
2815 2902
 				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2816
-				service.ModifyGoodAddInformation(info.GoodId, total_count, info.OrgId)
2903
+				//查询默认仓库
2904
+				houseConfig, _ := service.GetAllStoreHouseConfig(project.UserOrgId)
2905
+				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, project.ProjectId, project.UserOrgId)
2906
+				var sum_count int64
2907
+				var sum_in_count int64
2908
+				for _, it := range goodList {
2909
+					sum_count += it.StockCount
2910
+					sum_in_count += it.WarehousingCount
2911
+				}
2912
+				service.UpdateGoodByGoodId(project.ProjectId, sum_count, sum_in_count, project.UserOrgId)
2817 2913
 				//查询今日该耗材退库数量
2818 2914
 				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2819 2915
 				var cancel_count int64

+ 2 - 0
controllers/patient_api_controller.go View File

@@ -576,6 +576,8 @@ func (c *PatientApiController) EditPatient() {
576 576
 	key := "scheduals_" + today + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
577 577
 	redis.Set(key, "", time.Second*60*60*18)
578 578
 
579
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":patient_info"
580
+	redis.Set(keyOne, "", time.Second*60*60*18)
579 581
 	if len(record_date) > 0 {
580 582
 		var recordTime int64
581 583
 		timeLayout := "2006-01-02"

+ 1 - 3
controllers/secondary_order_api_contorller.go View File

@@ -1449,8 +1449,6 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1449 1449
 				total_count = item.Count
1450 1450
 			}
1451 1451
 
1452
-			fmt.Println("total_count2332323223233232332", total_count)
1453
-			fmt.Println("total2323322332322332233", total)
1454 1452
 			if total_count <= total {
1455 1453
 
1456 1454
 				//回退库存,查询该订单出库记录
@@ -1479,7 +1477,7 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1479 1477
 
1480 1478
 					//查询出单
1481 1479
 					storeWarehouseOut, _ := service.GetStoreDrugWarehouseOutById(it.WarehouseOutId, it.OrgId)
1482
-					fmt.Println("ss喊出232323232332232323232332232333333333333333333333")
1480
+
1483 1481
 					//删除出库单
1484 1482
 					service.DeleteStoreWarehouseOut(storeWarehouseOut.ID, storeWarehouseOut.OrgId, item.ProjectId)
1485 1483
 				}