Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
0913173510

+ 7 - 0
controllers/dialysis_api_controller.go View File

@@ -3763,6 +3763,13 @@ func (this *DialysisApiController) GetTodayMonitor() {
3763 3763
 				ultrafiltration_rate = value
3764 3764
 				record.UltrafiltrationRate = ultrafiltration_rate
3765 3765
 			}
3766
+
3767
+			if adminInfo.CurrentOrgId == 10395 {
3768
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3769
+
3770
+				record.UltrafiltrationRate = ultrafiltration_rate
3771
+			}
3772
+
3766 3773
 		}
3767 3774
 	}
3768 3775
 	// record.UltrafiltrationRate = ultrafiltration_rate

+ 1 - 1
controllers/drug_stock_api_contorller.go View File

@@ -267,7 +267,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
267 267
 					IsCheck:          2,
268 268
 					StockMinNumber:   0,
269 269
 				}
270
-				fmt.Println(warehouseInfo)
270
+				//fmt.Println(warehouseInfo)
271 271
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
272 272
 			}
273 273
 		}

+ 19 - 10
controllers/his_api_controller.go View File

@@ -1109,7 +1109,7 @@ func (c *HisApiController) CreateHisPrescription() {
1109 1109
 												return
1110 1110
 											}
1111 1111
 
1112
-											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1112
+											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1113 1113
 												if prescribing_number > batch_number_all_count {
1114 1114
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1115 1115
 													return
@@ -1126,7 +1126,7 @@ func (c *HisApiController) CreateHisPrescription() {
1126 1126
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1127 1127
 												return
1128 1128
 											}
1129
-											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1129
+											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1130 1130
 												if num > batch_number_all_count {
1131 1131
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1132 1132
 													return
@@ -1195,7 +1195,7 @@ func (c *HisApiController) CreateHisPrescription() {
1195 1195
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1196 1196
 														return
1197 1197
 													}
1198
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1198
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1199 1199
 														if prescribing_number > batch_number_all_count {
1200 1200
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1201 1201
 															return
@@ -1213,7 +1213,7 @@ func (c *HisApiController) CreateHisPrescription() {
1213 1213
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1214 1214
 															return
1215 1215
 														}
1216
-														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1216
+														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1217 1217
 															if prescribing_number > batch_number_all_count {
1218 1218
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1219 1219
 																return
@@ -1269,7 +1269,7 @@ func (c *HisApiController) CreateHisPrescription() {
1269 1269
 														c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1270 1270
 														return
1271 1271
 													}
1272
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1272
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1273 1273
 														// 查询该药品最后一次出库记录
1274 1274
 														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1275 1275
 
@@ -1990,6 +1990,7 @@ func (c *HisApiController) CreateHisPrescription() {
1990 1990
 					projects := items["project"].([]interface{})
1991 1991
 					if len(projects) > 0 {
1992 1992
 						for _, project := range projects {
1993
+
1993 1994
 							var p models.HisPrescriptionProject
1994 1995
 							p.PrescriptionId = tempPrescription.ID
1995 1996
 							p.Ctime = time.Now().Unix()
@@ -2001,13 +2002,20 @@ func (c *HisApiController) CreateHisPrescription() {
2001 2002
 							p.HisPatientId = his_patient_id
2002 2003
 							p.Status = 1
2003 2004
 							p.StartTime = pTime
2004
-							p.IsOut = 2
2005
+
2005 2006
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
2006 2007
 							if errcode > 0 {
2007 2008
 								c.ServeFailJSONWithSGJErrorCode(errcode)
2008 2009
 								return
2009 2010
 							}
2010
-
2011
+							fmt.Println("projext22222222222222", p.ID)
2012
+							if p.ID == 0 {
2013
+								p.IsOut = 2
2014
+							}
2015
+							if p.ID > 0 {
2016
+								projectDetail, _ := service.GetHisPrescriptonProjectById(p.ID)
2017
+								p.IsOut = projectDetail.IsOut
2018
+							}
2011 2019
 							service.CreateHisProjectTwo(&p)
2012 2020
 							projectList = append(projectList, p)
2013 2021
 							var randNum int
@@ -2640,7 +2648,7 @@ func (c *HisApiController) DeletePrescription() {
2640 2648
 						service.CreateStockFlowOne(flow)
2641 2649
 
2642 2650
 						//查询已出库数量
2643
-						dialysisInfo, _ := service.GetGoodDialysisOutInfo(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2651
+						dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2644 2652
 
2645 2653
 						if prescribingNumber < dialysisInfo.Count {
2646 2654
 							//改变数量
@@ -3034,13 +3042,14 @@ func (c *HisApiController) DeleteProject() {
3034 3042
 				service.CreateStockFlowOne(flow)
3035 3043
 
3036 3044
 				//查询已出库数量
3037
-				dialysisInfo, _ := service.GetGoodDialysisOutInfo(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3045
+				dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3038 3046
 
3039 3047
 				if prescribingNumber < dialysisInfo.Count {
3040 3048
 					//改变数量
3041 3049
 					service.UpdateAutoGood(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId, id, prescribingNumber)
3042 3050
 				}
3043
-
3051
+				fmt.Println("prescribingNumber", prescribingNumber)
3052
+				fmt.Println("Count2332333223qw", dialysisInfo.Count)
3044 3053
 				if prescribingNumber == dialysisInfo.Count {
3045 3054
 					//删除出库表
3046 3055
 					service.DeleteAutoRedeceDetailTen(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)

+ 7 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2959,6 +2959,11 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2959 2959
 				record.UltrafiltrationRate = ultrafiltration_rate
2960 2960
 			}
2961 2961
 
2962
+			if adminInfo.Org.Id == 10395 {
2963
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
2964
+
2965
+				record.UltrafiltrationRate = ultrafiltration_rate
2966
+			}
2962 2967
 			//if template.TemplateId == 47 {
2963 2968
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2964 2969
 			//	record.UltrafiltrationRate = ultrafiltration_rate
@@ -2985,8 +2990,10 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2985 2990
 	}
2986 2991
 
2987 2992
 	if adminInfo.Org.Id == 10395 {
2993
+
2988 2994
 		if ultrafiltration_rate > 0 {
2989 2995
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate / 1000)
2996
+
2990 2997
 			record.UltrafiltrationVolume = ultrafiltration_volume
2991 2998
 		}
2992 2999
 

+ 18 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1227,6 +1227,24 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1227 1227
 							}
1228 1228
 						}
1229 1229
 					}
1230
+
1231
+					//if config.IsOpen == 1 && item.UserOrgId == 10318 {
1232
+					//
1233
+					//  service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1234
+					//  //更新字典里面的库存
1235
+					//  stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1236
+					//  var sum_count int64
1237
+					//  for _, its := range stockInfo {
1238
+					//    if its.MaxUnit == medical.MaxUnit {
1239
+					//      its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1240
+					//    }
1241
+					//    sum_count += its.StockMaxNumber + its.StockMinNumber
1242
+					//  }
1243
+					//  service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1244
+					//  //剩余库存
1245
+					//  service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1246
+					//}
1247
+
1230 1248
 				}
1231 1249
 			}
1232 1250
 			for _, item := range advices {

+ 31 - 0
controllers/self_drug_api_congtroller.go View File

@@ -110,6 +110,8 @@ func SelfDrugRouters() {
110 110
 	//新数据
111 111
 	beego.Router("/api/stock/getnewpurchasestockquery", &SelfDrugApiController{}, "Get:GetGoodNewPurchaseStockQuery")
112 112
 	beego.Router("/api/stock/getpurchasenewdrugquery", &SelfDrugApiController{}, "Get:GetPurchaseNewDrugQuery")
113
+	beego.Router("/api/stock/getgoodovercount", &SelfDrugApiController{}, "Get:GetGoodOverCount")
114
+	beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
113 115
 }
114 116
 
115 117
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -3961,3 +3963,32 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3961 3963
 		"drugTypeList":     drugTypeList,
3962 3964
 	})
3963 3965
 }
3966
+
3967
+func (this *SelfDrugApiController) GetGoodOverCount() {
3968
+
3969
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3970
+
3971
+	list, _ := service.GetAllStockCount(orgId)
3972
+	for _, item := range list {
3973
+		flow, _ := service.GetLastStockFlow(item.GoodId)
3974
+		service.ModifyStockFlowById(flow.ID, item.FlushCount)
3975
+	}
3976
+	returnData := make(map[string]interface{}, 0)
3977
+	returnData["msg"] = "ok"
3978
+	this.ServeSuccessJSON(returnData)
3979
+	return
3980
+}
3981
+
3982
+func (this *SelfDrugApiController) GetDrugOverCount() {
3983
+
3984
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3985
+	list, _ := service.GetAllDrugCount(orgId)
3986
+	for _, item := range list {
3987
+		service.GetLastDrugFlow(item.DrugId)
3988
+		service.ModifyDrugFlowById(item.ID, item.FlushCount)
3989
+	}
3990
+	returnData := make(map[string]interface{}, 0)
3991
+	returnData["msg"] = "ok"
3992
+	this.ServeSuccessJSON(returnData)
3993
+	return
3994
+}

+ 1 - 1
controllers/stock_in_api_controller.go View File

@@ -2416,7 +2416,7 @@ func (this *StockManagerApiController) DeleteCancelStock() {
2416 2416
 }
2417 2417
 func (this *StockManagerApiController) DeleteCancelStockInfo() {
2418 2418
 	id, _ := this.GetInt64("id", 0)
2419
-	fmt.Println(id)
2419
+	//fmt.Println(id)
2420 2420
 	if id == 0 {
2421 2421
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2422 2422
 		return

+ 1 - 0
models/new_stock_models.go View File

@@ -393,6 +393,7 @@ type DrugFlowTwenty struct {
393 393
 	DrugWarehouseInfoOne   DrugWarehouseInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
394 394
 	IsRead                 int64                  `gorm:"column:is_read" json:"is_read" form:"is_read"`
395 395
 	IsCheck                int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
396
+	OverCount              int64                  `gorm:"column:over_count" json:"over_count" form:"over_count"`
396 397
 	XtDrugWarehouseOutInfo XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
397 398
 }
398 399
 

+ 1 - 0
service/dialysis_solution_service.go View File

@@ -183,6 +183,7 @@ func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id in
183 183
 	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
184 184
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
185 185
 		Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
186
+		Preload("DialysisSolution", "status = 1 AND user_org_id = ? AND solution_status = 1", orgID).
186 187
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
187 188
 
188 189
 	return schedule, err

+ 8 - 0
service/his_service.go View File

@@ -2532,3 +2532,11 @@ func UpDateOrderTwo(order *models.HisOrder) (err error) {
2532 2532
 	err = writeDb.Save(&order).Error
2533 2533
 	return
2534 2534
 }
2535
+
2536
+func GetHisPrescriptonProjectById(id int64) (models.HisPrescriptionProject, error) {
2537
+
2538
+	project := models.HisPrescriptionProject{}
2539
+
2540
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&project).Error
2541
+	return project, err
2542
+}

+ 40 - 0
service/self_drug_service.go View File

@@ -2635,3 +2635,43 @@ func GetDrugEndFlow(drug_id int64, user_org_id int64, endtime int64) (models.Dru
2635 2635
 	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<=? and status = 1", drug_id, user_org_id, endtime).Last(&flow).Error
2636 2636
 	return flow, err
2637 2637
 }
2638
+
2639
+func GetAllStockCount(orgid int64) (stock []*models.XtGoodStockCount, err error) {
2640
+
2641
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&stock).Error
2642
+	return stock, err
2643
+}
2644
+func GetLastStockFlow(good_id int64) (models.VmStockFlow, error) {
2645
+
2646
+	flow := models.VmStockFlow{}
2647
+
2648
+	err := XTReadDB().Where("good_id = ? and status =1  and ctime<=1667231999", good_id).Last(&flow).Error
2649
+
2650
+	return flow, err
2651
+}
2652
+
2653
+func ModifyStockFlowById(id int64, over_count int64) error {
2654
+
2655
+	err := XTWriteDB().Model(&models.VmStockFlow{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"over_count": over_count}).Error
2656
+	return err
2657
+}
2658
+
2659
+func GetAllDrugCount(user_org_id int64) (drug []*models.XtDrugStockCount, err error) {
2660
+
2661
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&drug).Error
2662
+	return drug, err
2663
+}
2664
+
2665
+func GetLastDrugFlow(drug_id int64) (models.DrugFlow, error) {
2666
+
2667
+	flow := models.DrugFlow{}
2668
+	err := XTReadDB().Where("drug_id = ? and status =1  and ctime<=1667231999", drug_id).Last(&flow).Error
2669
+
2670
+	return flow, err
2671
+}
2672
+
2673
+func ModifyDrugFlowById(id int64, over_count int64) error {
2674
+
2675
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"over_count": over_count}).Error
2676
+	return err
2677
+}

+ 7 - 0
service/stock_service.go View File

@@ -7913,6 +7913,13 @@ func GetGoodDialysisOutInfo(orgid int64, patient_id int64, sys_record_time int64
7913 7913
 	return detail, err
7914 7914
 }
7915 7915
 
7916
+func GetGoodDialysisOutInfoSix(orgid int64, patient_id int64, sys_record_time int64, good_id int64) (models.WarehouseOutInfo, error) {
7917
+
7918
+	detail := models.WarehouseOutInfo{}
7919
+	err := XTReadDB().Where("org_id =? and patient_id = ? and sys_record_time = ? and good_id = ? and status= 1", orgid, patient_id, sys_record_time, good_id).Find(&detail).Error
7920
+	return detail, err
7921
+}
7922
+
7916 7923
 func GetGoodSumCount(storehouse_id int64, good_id int64, orgid int64) (models.XtGoodStockCount, error) {
7917 7924
 
7918 7925
 	stock := models.XtGoodStockCount{}