Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
6f09724f05

+ 0 - 5
conf/app.conf View File

@@ -127,11 +127,6 @@ redispasswrod = 1Q2W3e4r!@#$
127 127
 redisdb = 1
128 128
 
129 129
 
130
-
131
-
132
-
133
-
134
-
135 130
 niprocart =  63
136 131
 jms = 58
137 132
 fistula_needle_set = 65

+ 11 - 0
controllers/drug_stock_api_contorller.go View File

@@ -1499,6 +1499,17 @@ func (c *StockDrugApiController) DeleteDrugWarehouseOut() {
1499 1499
 
1500 1500
 	idArray := strings.Split(ids, ",")
1501 1501
 	err := service.DeleteDrugWarehouseOut(idArray)
1502
+
1503
+	list, _ := service.GetDrugWarhouseOutByIds(idArray)
1504
+	for _, item := range list {
1505
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1506
+		if item.CountUnit == medical.MaxUnit {
1507
+			service.UpdateDrugInfoByIds(item.WarehouseInfoId, item.Count)
1508
+		}
1509
+		if medical.MaxUnit != medical.MinUnit && item.CountUnit == medical.MinUnit {
1510
+			service.UpdateDrugInfoByIdsOne(item.WarehouseInfoId, item.Count)
1511
+		}
1512
+	}
1502 1513
 	if err != nil {
1503 1514
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1504 1515
 	} else {

+ 16 - 13
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -741,17 +741,18 @@ func (c *PatientApiController) ExecDoctorAdvice() {
741 741
 							}
742 742
 							if prescribing_number_total <= total {
743 743
 								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
744
-								c.ServeSuccessJSON(map[string]interface{}{
745
-									"msg":    "1",
746
-									"advice": advice,
747
-									"ids":    ids,
748
-								})
749
-								return
744
+
750 745
 							}
751 746
 
752 747
 						}
753 748
 					}
754 749
 				}
750
+				c.ServeSuccessJSON(map[string]interface{}{
751
+					"msg":    "1",
752
+					"advice": advice,
753
+					"ids":    ids,
754
+				})
755
+				return
755 756
 			} else {
756 757
 
757 758
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
@@ -781,7 +782,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
781 782
 								count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
782 783
 								//转化为最小单位
783 784
 								total = list.Count*medical.MinNumber + list.StockMinNumber
784
-								fmt.Println("美国疫情2332323233232323232332323232233232323232", total)
785
+
785 786
 								prescribing_number_total = count * medical.MinNumber
786 787
 							}
787 788
 
@@ -920,6 +921,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
920 921
 						}
921 922
 					}
922 923
 				}
924
+				c.ServeSuccessJSON(map[string]interface{}{
925
+					"msg":    "1",
926
+					"advice": advice,
927
+					"ids":    ids,
928
+				})
929
+				return
923 930
 			}
924 931
 		}
925 932
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -1042,12 +1049,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1042 1049
 					}
1043 1050
 					if prescribing_number_total <= total {
1044 1051
 						service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1045
-						c.ServeSuccessJSON(map[string]interface{}{
1046
-							"msg":    "1",
1047
-							"advice": advice,
1048
-							"ids":    ids,
1049
-						})
1050
-						return
1052
+
1051 1053
 					}
1052 1054
 				}
1053 1055
 			}
@@ -1063,6 +1065,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1063 1065
 		} else {
1064 1066
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1065 1067
 		}
1068
+
1066 1069
 	}
1067 1070
 }
1068 1071
 

+ 6 - 0
controllers/stock_in_api_controller.go View File

@@ -1432,7 +1432,13 @@ func (c *StockManagerApiController) DeleteWarehouseOut() {
1432 1432
 	}
1433 1433
 
1434 1434
 	idArray := strings.Split(ids, ",")
1435
+
1435 1436
 	err := service.DeleteWarehouseOut(idArray)
1437
+	list, _ := service.GetWarehouseOutInfoByIds(idArray)
1438
+	for _, item := range list {
1439
+		//添加库存
1440
+		service.UpdateWarehouseInfoById(item.WarehouseInfotId, item.Count)
1441
+	}
1436 1442
 	if err != nil {
1437 1443
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1438 1444
 	} else {

+ 27 - 0
service/stock_service.go View File

@@ -2220,6 +2220,33 @@ func DeleteWarehouseOut(ids []string) (err error) {
2220 2220
 	return
2221 2221
 }
2222 2222
 
2223
+func GetWarehouseOutInfoByIds(ids []string) (info []*models.WarehouseOutInfo, err error) {
2224
+
2225
+	err = XTReadDB().Where("warehouse_out_id in(?) and status = 0", ids).Find(&info).Error
2226
+	return info, err
2227
+}
2228
+
2229
+func UpdateWarehouseInfoById(id int64, count int64) error {
2230
+	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
2231
+	return err
2232
+}
2233
+
2234
+func GetDrugWarhouseOutByIds(ids []string) (info []*models.DrugWarehouseOutInfo, err error) {
2235
+
2236
+	err = XTReadDB().Where("warehouse_out_id in(?) and status = 0", ids).Find(&info).Error
2237
+	return info, err
2238
+}
2239
+
2240
+func UpdateDrugInfoByIds(id int64, count int64) error {
2241
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
2242
+	return err
2243
+}
2244
+
2245
+func UpdateDrugInfoByIdsOne(id int64, count int64) error {
2246
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
2247
+	return err
2248
+}
2249
+
2223 2250
 func DeleteDrugWarehouseOut(ids []string) (err error) {
2224 2251
 	ut := writeDb.Begin()
2225 2252
 	err = ut.Model(&models.DrugWarehouseOut{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error