瀏覽代碼

11月8日库存管理

XMLWAN 3 年之前
父節點
當前提交
6f09724f05

+ 0 - 5
conf/app.conf 查看文件

127
 redisdb = 1
127
 redisdb = 1
128
 
128
 
129
 
129
 
130
-
131
-
132
-
133
-
134
-
135
 niprocart =  63
130
 niprocart =  63
136
 jms = 58
131
 jms = 58
137
 fistula_needle_set = 65
132
 fistula_needle_set = 65

+ 11 - 0
controllers/drug_stock_api_contorller.go 查看文件

1499
 
1499
 
1500
 	idArray := strings.Split(ids, ",")
1500
 	idArray := strings.Split(ids, ",")
1501
 	err := service.DeleteDrugWarehouseOut(idArray)
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
 	if err != nil {
1513
 	if err != nil {
1503
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1514
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1504
 	} else {
1515
 	} else {

+ 16 - 13
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

741
 							}
741
 							}
742
 							if prescribing_number_total <= total {
742
 							if prescribing_number_total <= total {
743
 								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
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
 			} else {
756
 			} else {
756
 
757
 
757
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
758
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
781
 								count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
782
 								count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
782
 								//转化为最小单位
783
 								//转化为最小单位
783
 								total = list.Count*medical.MinNumber + list.StockMinNumber
784
 								total = list.Count*medical.MinNumber + list.StockMinNumber
784
-								fmt.Println("美国疫情2332323233232323232332323232233232323232", total)
785
+
785
 								prescribing_number_total = count * medical.MinNumber
786
 								prescribing_number_total = count * medical.MinNumber
786
 							}
787
 							}
787
 
788
 
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
 		c.ServeSuccessJSON(map[string]interface{}{
932
 		c.ServeSuccessJSON(map[string]interface{}{
1042
 					}
1049
 					}
1043
 					if prescribing_number_total <= total {
1050
 					if prescribing_number_total <= total {
1044
 						service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
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
 		} else {
1065
 		} else {
1064
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1066
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1065
 		}
1067
 		}
1068
+
1066
 	}
1069
 	}
1067
 }
1070
 }
1068
 
1071
 

+ 6 - 0
controllers/stock_in_api_controller.go 查看文件

1432
 	}
1432
 	}
1433
 
1433
 
1434
 	idArray := strings.Split(ids, ",")
1434
 	idArray := strings.Split(ids, ",")
1435
+
1435
 	err := service.DeleteWarehouseOut(idArray)
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
 	if err != nil {
1442
 	if err != nil {
1437
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1443
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1438
 	} else {
1444
 	} else {

+ 27 - 0
service/stock_service.go 查看文件

2220
 	return
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
 func DeleteDrugWarehouseOut(ids []string) (err error) {
2250
 func DeleteDrugWarehouseOut(ids []string) (err error) {
2224
 	ut := writeDb.Begin()
2251
 	ut := writeDb.Begin()
2225
 	err = ut.Model(&models.DrugWarehouseOut{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
2252
 	err = ut.Model(&models.DrugWarehouseOut{}).Where("id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error