Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
fcab4bb436

+ 17 - 0
controllers/his_api_controller.go View File

@@ -897,6 +897,7 @@ func (c *HisApiController) CreateHisPrescription() {
897 897
 									project_name = project.(map[string]interface{})["project_name"].(string)
898 898
 
899 899
 								}
900
+								fmt.Println("id3232322332232323323223322323", id)
900 901
 								if project_type == 3 {
901 902
 
902 903
 									//查找该耗材的出库记录
@@ -905,6 +906,7 @@ func (c *HisApiController) CreateHisPrescription() {
905 906
 									//for _, it := range goodWarehouseInfo {
906 907
 									//	total_count += it.Count
907 908
 									//}
909
+
908 910
 									if len(goodWarehouseInfo) == 0 {
909 911
 										//查询耗材库存
910 912
 										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
@@ -918,11 +920,22 @@ func (c *HisApiController) CreateHisPrescription() {
918 920
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
919 921
 											return
920 922
 										}
923
+										//查找今日该患者已经出库的所有耗材
924
+										goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
925
+										fmt.Println("goodList3323223232323232323", goodList)
926
+										for _, item := range goodList {
927
+											//回退库存
928
+											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
929
+										}
930
+										//删除记录
931
+										service.DeleteAutoWarehouse(patient_id, recordDateTime)
921 932
 									}
922 933
 									if len(goodWarehouseInfo) > 0 {
923 934
 										//查询该患者耗材的历史数据
924 935
 										ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
936
+										fmt.Println("ordOr2323233232323232323223232", ordProject)
925 937
 										count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
938
+										fmt.Println("id3232322332232323323223322323", id)
926 939
 										fmt.Println("parsetotal33223232323232323", parsetotal)
927 940
 										fmt.Println("count2332322332232332", count)
928 941
 										//数量发生改变
@@ -2355,6 +2368,10 @@ func (c *HisApiController) DeleteProject() {
2355 2368
 	service.CreateHisLabelRecord(&label)
2356 2369
 
2357 2370
 	if stockConfig.IsOpen == 1 {
2371
+		if project.Type == 2 {
2372
+			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
2373
+			fmt.Println(err)
2374
+		}
2358 2375
 		if project.Type == 3 {
2359 2376
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2360 2377
 			f_count, _ := strconv.ParseFloat(project.Count, 64)

+ 7 - 2
controllers/print_data_api_controller.go View File

@@ -39,10 +39,15 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
39 39
 	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
40 40
 	for _, item := range schedules {
41 41
 		list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
42
-		if this.GetAdminUserInfo().CurrentOrgId != 10101 {
42
+		if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
43 43
 			item.Count = list.Count
44 44
 		}
45
-
45
+		if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
46
+			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
47
+			fmt.Println("dialysis_count322333223322323", dialysis_count)
48
+			item.Patient.TotalDialysis = dialysis_count
49
+			item.Count = dialysis_count
50
+		}
46 51
 	}
47 52
 	if getScheduleErr != nil {
48 53
 		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)

+ 10 - 6
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -63,10 +63,10 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
63 63
 			item.Patient.TotalDialysis = dialysis_count
64 64
 
65 65
 		}
66
-		if orgID == 10101 {
67
-			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
68
-			item.Patient.TotalDialysis = dialysis_count
69
-		}
66
+		//if orgID == 10101 {
67
+		//	dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
68
+		//	item.Patient.TotalDialysis = dialysis_count
69
+		//}
70 70
 	}
71 71
 	return schedules, nil
72 72
 }
@@ -211,11 +211,15 @@ func GetDialysisOrderCountSeven(patient_id int64, recordDate int64) (models.VmDi
211 211
 	return order, err
212 212
 }
213 213
 
214
+//func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
215
+//	err = p_service.XTReadDB().Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
216
+//	return
217
+//}
218
+
214 219
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
215
-	err = p_service.XTReadDB().Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
220
+	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
216 221
 	return
217 222
 }
218
-
219 223
 func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
220 224
 
221 225
 	err = p_service.XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error