XMLWAN пре 2 година
родитељ
комит
cb853295c2

+ 65 - 1
controllers/dialysis_api_controller.go Прегледај датотеку

85
 	beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
85
 	beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
86
 
86
 
87
 	beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
87
 	beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
88
+
89
+	beego.Router("/api/patient/getdialysisadvicescheduelist", &DialysisApiController{}, "Get:GetDialysisAdviceSchedulist")
90
+
91
+	beego.Router("/api/patient/getdialysisparametergoodlist", &DialysisApiController{}, "Get:GetDialysisParameterGoodList")
88
 }
92
 }
89
 
93
 
90
 func (c *DialysisApiController) GetQueueCall() {
94
 func (c *DialysisApiController) GetQueueCall() {
4422
 
4426
 
4423
 	partion_type, _ := this.GetInt64("partion_type")
4427
 	partion_type, _ := this.GetInt64("partion_type")
4424
 
4428
 
4425
-	start_time := this.GetString("schedule_date")
4429
+	start_time := this.GetString("selected_date")
4426
 	timeLayout := "2006-01-02"
4430
 	timeLayout := "2006-01-02"
4427
 	loc, _ := time.LoadLocation("Local")
4431
 	loc, _ := time.LoadLocation("Local")
4428
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4432
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4439
 		return
4443
 		return
4440
 	}
4444
 	}
4441
 }
4445
 }
4446
+
4447
+func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
4448
+
4449
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4450
+
4451
+	schedule_type, _ := this.GetInt64("schedule_type")
4452
+
4453
+	partion_type, _ := this.GetInt64("partion_type")
4454
+
4455
+	start_time := this.GetString("selected_date")
4456
+	timeLayout := "2006-01-02"
4457
+	loc, _ := time.LoadLocation("Local")
4458
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4459
+
4460
+	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
4461
+	drug, _ := service.GetAllDrugMap(orgId)
4462
+	//获取长期医嘱
4463
+	adviceList, _ := service.GetAllLongAdviceList(orgId)
4464
+	//获取医嘱模版
4465
+	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4466
+	if err == nil {
4467
+		this.ServeSuccessJSON(map[string]interface{}{
4468
+			"list":         list,
4469
+			"drug":         drug,
4470
+			"adviceList":   adviceList,
4471
+			"templateList": templateList,
4472
+		})
4473
+		return
4474
+
4475
+	} else {
4476
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4477
+		return
4478
+	}
4479
+}
4480
+
4481
+func (this *DialysisApiController) GetDialysisParameterGoodList() {
4482
+
4483
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4484
+
4485
+	schedule_type, _ := this.GetInt64("schedule_type")
4486
+
4487
+	partion_type, _ := this.GetInt64("partion_type")
4488
+
4489
+	start_time := this.GetString("selected_date")
4490
+	timeLayout := "2006-01-02"
4491
+	loc, _ := time.LoadLocation("Local")
4492
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4493
+
4494
+	list, err := service.GetDialysisParameterGoodList(orgId, schedule_type, partion_type, startTime.Unix())
4495
+	if err == nil {
4496
+		this.ServeSuccessJSON(map[string]interface{}{
4497
+			"list": list,
4498
+		})
4499
+		return
4500
+
4501
+	} else {
4502
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4503
+		return
4504
+	}
4505
+}

+ 7 - 7
controllers/his_api_controller.go Прегледај датотеку

2009
 							p.HisPatientId = his_patient_id
2009
 							p.HisPatientId = his_patient_id
2010
 							p.Status = 1
2010
 							p.Status = 1
2011
 							p.StartTime = pTime
2011
 							p.StartTime = pTime
2012
-
2012
+							p.IsOut = 2
2013
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
2013
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
2014
 							if errcode > 0 {
2014
 							if errcode > 0 {
2015
 								c.ServeFailJSONWithSGJErrorCode(errcode)
2015
 								c.ServeFailJSONWithSGJErrorCode(errcode)
2524
 		for _, item := range projects {
2524
 		for _, item := range projects {
2525
 			service.DeletePrintInfo(item.ID) //删除打印信息
2525
 			service.DeletePrintInfo(item.ID) //删除打印信息
2526
 			if stockConfig.IsOpen == 1 {
2526
 			if stockConfig.IsOpen == 1 {
2527
-				if item.Type == 3 {
2527
+				if item.Type == 3 && item.IsOut == 1 {
2528
 					good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
2528
 					good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
2529
 					f_count, _ := strconv.ParseFloat(item.Count, 64)
2529
 					f_count, _ := strconv.ParseFloat(item.Count, 64)
2530
 					good.Total = good.Total + f_count
2530
 					good.Total = good.Total + f_count
2659
 							service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2659
 							service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2660
 						}
2660
 						}
2661
 
2661
 
2662
-						////删除出库表
2663
-						//service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2664
-
2665
 						//退库数量增加
2662
 						//退库数量增加
2666
 						service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
2663
 						service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
2667
 						//出库数量减少
2664
 						//出库数量减少
2932
 			fmt.Println(err)
2929
 			fmt.Println(err)
2933
 		}
2930
 		}
2934
 
2931
 
2935
-		if project.Type == 3 {
2932
+		if project.Type == 3 && project.IsOut == 1 {
2936
 			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2933
 			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2937
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2934
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2938
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2935
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
3016
 					Count:                   prescribingNumber,
3013
 					Count:                   prescribingNumber,
3017
 					UserOrgId:               adminInfo.CurrentOrgId,
3014
 					UserOrgId:               adminInfo.CurrentOrgId,
3018
 					PatientId:               project.PatientId,
3015
 					PatientId:               project.PatientId,
3019
-					SystemTime:              time.Now().Unix(),
3016
+					SystemTime:              info.SysRecordTime,
3020
 					ConsumableType:          7,
3017
 					ConsumableType:          7,
3021
 					IsSys:                   0,
3018
 					IsSys:                   0,
3022
 					WarehousingOrder:        "",
3019
 					WarehousingOrder:        "",
3175
 			}
3172
 			}
3176
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3173
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3177
 			fmt.Println(err)
3174
 			fmt.Println(err)
3175
+		} else {
3176
+			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3177
+			fmt.Println(err)
3178
 		}
3178
 		}
3179
 
3179
 
3180
 	}
3180
 	}

+ 8 - 0
controllers/mobile_api_controllers/patient_api_controller.go Прегледај датотеку

777
 												sum_count += its.StockMaxNumber + its.StockMinNumber
777
 												sum_count += its.StockMaxNumber + its.StockMinNumber
778
 											}
778
 											}
779
 											service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
779
 											service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
780
+											//剩余库存
781
+											service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
780
 										}
782
 										}
781
 									}
783
 									}
782
 								} else {
784
 								} else {
798
 											sum_count += its.StockMaxNumber + its.StockMinNumber
800
 											sum_count += its.StockMaxNumber + its.StockMinNumber
799
 										}
801
 										}
800
 										service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
802
 										service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
803
+										//剩余库存
804
+										service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
801
 									}
805
 									}
802
 								}
806
 								}
803
 							}
807
 							}
899
 										sum_count += its.StockMaxNumber + its.StockMinNumber
903
 										sum_count += its.StockMaxNumber + its.StockMinNumber
900
 									}
904
 									}
901
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
905
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
906
+									//剩余库存
907
+									service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
902
 									c.ServeSuccessJSON(map[string]interface{}{
908
 									c.ServeSuccessJSON(map[string]interface{}{
903
 										"msg":    "1",
909
 										"msg":    "1",
904
 										"advice": advice,
910
 										"advice": advice,
1214
 										sum_count += its.StockMaxNumber + its.StockMinNumber
1220
 										sum_count += its.StockMaxNumber + its.StockMinNumber
1215
 									}
1221
 									}
1216
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1222
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1223
+									//剩余库存
1224
+									service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1217
 								}
1225
 								}
1218
 
1226
 
1219
 							}
1227
 							}

+ 1 - 0
models/his_models.go Прегледај датотеку

859
 	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
859
 	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
860
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
860
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
861
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
861
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
862
+	IsOut                int64        `gorm:"column:is_out" json:"is_out" form:"is_out"` //新增字段
862
 }
863
 }
863
 
864
 
864
 func (HisPrescriptionProject) TableName() string {
865
 func (HisPrescriptionProject) TableName() string {

+ 2 - 0
models/schedule_models.go Прегледај датотеку

308
 	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
308
 	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
309
 	DialysisPrescription       DialysisPrescription       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"dialysis_prescription"`
309
 	DialysisPrescription       DialysisPrescription       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"dialysis_prescription"`
310
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,AssessmentDate" json:"assessment_befor_dislysis"`
310
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,AssessmentDate" json:"assessment_befor_dislysis"`
311
+	XtDoctorAdvice             XtDoctorAdvice             `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,AdviceDate" json:"xt_doctor_advice"`
312
+	HisDoctorAdvice            HisDoctorAdvice            `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,AdviceDate" json:"his_doctor_advice"`
311
 }
313
 }
312
 
314
 
313
 func (VmBloodSchedule) TableName() string {
315
 func (VmBloodSchedule) TableName() string {

+ 58 - 0
service/dialysis_solution_service.go Прегледај датотеку

188
 	return schedule, err
188
 	return schedule, err
189
 
189
 
190
 }
190
 }
191
+
192
+func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
193
+
194
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
195
+
196
+	if scheduleDate > 0 {
197
+		db = db.Where("schedule_date = ?", scheduleDate)
198
+	}
199
+	if schedule_type > 0 {
200
+		db = db.Where("schedule_type = ?", schedule_type)
201
+	}
202
+	if partition_id > 0 {
203
+		db = db.Where("partition_id = ?", partition_id)
204
+	}
205
+	if orgID > 0 {
206
+		db = db.Where("user_org_id  = ?", orgID)
207
+	}
208
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
209
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
210
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
211
+		Preload("HisDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
212
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
213
+
214
+	return schedule, err
215
+
216
+}
217
+
218
+func GetAllDrugMap(org_id int64) (list []*BaseDrugLib, err error) {
219
+
220
+	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
221
+	return list, err
222
+}
223
+
224
+func GetDialysisParameterGoodList(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
225
+
226
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
227
+
228
+	if scheduleDate > 0 {
229
+		db = db.Where("schedule_date = ?", scheduleDate)
230
+	}
231
+	if schedule_type > 0 {
232
+		db = db.Where("schedule_type = ?", schedule_type)
233
+	}
234
+	if partition_id > 0 {
235
+		db = db.Where("partition_id = ?", partition_id)
236
+	}
237
+	if orgID > 0 {
238
+		db = db.Where("user_org_id  = ?", orgID)
239
+	}
240
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
241
+		Preload("DialysisPrescription", "status = 1 and user_org_id = ?", orgID).
242
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
243
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
244
+		Preload("HisDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
245
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
246
+
247
+	return schedule, err
248
+}

+ 62 - 13
service/new_warehouse_service.go Прегледај датотеку

14
 //耗材出库
14
 //耗材出库
15
 func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
15
 func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
16
 
16
 
17
-	fmt.Println("出库数量2333333333333333333333333333333333hhha", goods.Count)
17
+	//fmt.Println("出库数量2333333333333333333333333333333333hhha", goods.Count)
18
 	//开事务
18
 	//开事务
19
 	var deliver_number int64 = 0
19
 	var deliver_number int64 = 0
20
 	var stock_number int64 = 0
20
 	var stock_number int64 = 0
47
 		if errThree != nil {
47
 		if errThree != nil {
48
 			return errThree
48
 			return errThree
49
 		}
49
 		}
50
+		//更新his_prescripton_project出库状态值
51
+		UpdateHisPrescriptionProjectStatus(goods.GoodId, record_time, orgID, patient_id)
50
 
52
 
51
 		//查询剩余库存
53
 		//查询剩余库存
52
 		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID)
54
 		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID)
83
 			OverCount:               sum_count,
85
 			OverCount:               sum_count,
84
 		}
86
 		}
85
 		warehouseOutInfo.Count = count
87
 		warehouseOutInfo.Count = count
86
-
88
+		if orgID == 9671 || orgID == 10265 {
89
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
90
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
91
+		}
87
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
92
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
88
-		fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
93
+		//fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
89
 		if errcodes == gorm.ErrRecordNotFound {
94
 		if errcodes == gorm.ErrRecordNotFound {
90
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
95
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
91
 			if errOne != nil {
96
 			if errOne != nil {
94
 		} else if errcodes == nil {
99
 		} else if errcodes == nil {
95
 
100
 
96
 			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
101
 			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
97
-			fmt.Println("goods.cout23323233223232323w", count)
98
-			fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
102
+			//fmt.Println("goods.cout23323233223232323w", count)
103
+			//fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
99
 			if count != outInfoOne.Count {
104
 			if count != outInfoOne.Count {
100
 				UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
105
 				UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
101
 			}
106
 			}
116
 		for _, item := range flowGoodTwo {
121
 		for _, item := range flowGoodTwo {
117
 			out_count_one += item.Count
122
 			out_count_one += item.Count
118
 		}
123
 		}
119
-		fmt.Println("deliver_number", deliver_number)
120
-		fmt.Println("out_count", out_count)
121
-		fmt.Println("count", count)
122
-		fmt.Println("cancel_out_count2333233", out_count_one)
124
+		//fmt.Println("deliver_number", deliver_number)
125
+		//fmt.Println("out_count", out_count)
126
+		//fmt.Println("count", count)
127
+		//fmt.Println("cancel_out_count2333233", out_count_one)
123
 		//如果本次出库数据大于历史出库数据 新增1条流水
128
 		//如果本次出库数据大于历史出库数据 新增1条流水
124
 		if count > (out_count - out_count_one) {
129
 		if count > (out_count - out_count_one) {
130
+
125
 			flow := models.VmStockFlow{
131
 			flow := models.VmStockFlow{
126
 				WarehouseOutId:          warehouseOut.ID,
132
 				WarehouseOutId:          warehouseOut.ID,
127
 				WarehousingId:           warehouse.ID,
133
 				WarehousingId:           warehouse.ID,
151
 				OverCount:               sum_count,
157
 				OverCount:               sum_count,
152
 				BuyPrice:                warehouse.Price,
158
 				BuyPrice:                warehouse.Price,
153
 			}
159
 			}
160
+			if orgID == 9671 || orgID == 10265 {
161
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
162
+				flow.Price = goodsInfo.PackingPrice
163
+				flow.BuyPrice = goodsInfo.BuyPrice
164
+			}
154
 			errThre := CreateStockFlowOne(flow)
165
 			errThre := CreateStockFlowOne(flow)
155
 			if errThre != nil {
166
 			if errThre != nil {
156
 				return errThre
167
 				return errThre
217
 				StorehouseId:    goods.StorehouseId,
228
 				StorehouseId:    goods.StorehouseId,
218
 				IsCheck:         1,
229
 				IsCheck:         1,
219
 			}
230
 			}
220
-
231
+			if orgID == 9671 || orgID == 10265 {
232
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
233
+				cancelStockInfo.Price = goodsInfo.PackingPrice
234
+			}
221
 			CreateCancelStockInfoOne(&cancelStockInfo)
235
 			CreateCancelStockInfoOne(&cancelStockInfo)
222
 
236
 
223
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
237
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
256
 				BuyPrice:                warehouse.Price,
270
 				BuyPrice:                warehouse.Price,
257
 				ProjectId:               goods.ProjectId,
271
 				ProjectId:               goods.ProjectId,
258
 			}
272
 			}
273
+			if orgID == 9671 || orgID == 10265 {
274
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
275
+				flow.Price = goodsInfo.PackingPrice
276
+				flow.BuyPrice = goodsInfo.BuyPrice
277
+			}
259
 			CreateStockFlowOne(flow)
278
 			CreateStockFlowOne(flow)
260
 		}
279
 		}
261
 
280
 
330
 			OverCount:               sum_count,
349
 			OverCount:               sum_count,
331
 		}
350
 		}
332
 		warehouseOutInfo.Count = stock_number
351
 		warehouseOutInfo.Count = stock_number
333
-
352
+		if orgID == 9671 || orgID == 10265 {
353
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
354
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
355
+		}
334
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
356
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
335
-		fmt.Println("errcodes23332322332323223", errcodes, goods.ProjectId)
357
+		//fmt.Println("errcodes23332322332323223", errcodes, goods.ProjectId)
336
 		if errcodes == gorm.ErrRecordNotFound {
358
 		if errcodes == gorm.ErrRecordNotFound {
337
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
359
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
338
 			if errOne != nil {
360
 			if errOne != nil {
391
 				OverCount:               sum_count,
413
 				OverCount:               sum_count,
392
 				BuyPrice:                warehouse.Price,
414
 				BuyPrice:                warehouse.Price,
393
 			}
415
 			}
416
+			if orgID == 9671 || orgID == 10265 {
417
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
418
+				flow.Price = goodsInfo.PackingPrice
419
+				flow.BuyPrice = goodsInfo.BuyPrice
420
+			}
394
 			errThre := CreateStockFlowOne(flow)
421
 			errThre := CreateStockFlowOne(flow)
395
 			if errThre != nil {
422
 			if errThre != nil {
396
 				return errThre
423
 				return errThre
453
 				StorehouseId:    goods.StorehouseId,
480
 				StorehouseId:    goods.StorehouseId,
454
 				IsCheck:         1,
481
 				IsCheck:         1,
455
 			}
482
 			}
456
-
483
+			if orgID == 9671 || orgID == 10265 {
484
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
485
+				cancelStockInfo.Price = goodsInfo.PackingPrice
486
+			}
457
 			CreateCancelStockInfoOne(&cancelStockInfo)
487
 			CreateCancelStockInfoOne(&cancelStockInfo)
458
 
488
 
459
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
489
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
492
 				BuyPrice:                warehouse.Price,
522
 				BuyPrice:                warehouse.Price,
493
 				ProjectId:               goods.ProjectId,
523
 				ProjectId:               goods.ProjectId,
494
 			}
524
 			}
525
+			if orgID == 9671 || orgID == 10265 {
526
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
527
+				flow.Price = goodsInfo.PackingPrice
528
+				flow.BuyPrice = goodsInfo.BuyPrice
529
+			}
495
 			CreateStockFlowOne(flow)
530
 			CreateStockFlowOne(flow)
496
 		}
531
 		}
497
 
532
 
2024
 	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", patient_id, advice_date, orgid).Update(map[string]interface{}{"count": info.Count, "count_unit": info.CountUnit}).Error
2059
 	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", patient_id, advice_date, orgid).Update(map[string]interface{}{"count": info.Count, "count_unit": info.CountUnit}).Error
2025
 	return err
2060
 	return err
2026
 }
2061
 }
2062
+
2063
+func FindeGoodInfo(orgid int64, id int64) (models.GoodInformation, error) {
2064
+
2065
+	information := models.GoodInformation{}
2066
+	err := XTReadDB().Where("org_id = ? and id = ? and status = 1", orgid, id).Find(&information).Error
2067
+	return information, err
2068
+}
2069
+
2070
+func UpdateHisPrescriptionProjectStatus(project_id int64, record_time int64, user_org_id int64, patient_id int64) (models.HisPrescriptionProject, error) {
2071
+
2072
+	project := models.HisPrescriptionProject{}
2073
+	err := XTWriteDB().Model(&project).Where("project_id  = ? and record_date = ? and user_org_id = ? and patient_id = ? and status = 1", project_id, record_time, user_org_id, patient_id).Update(map[string]interface{}{"is_out": 2}).Error
2074
+	return project, err
2075
+}