XMLWAN преди 3 години
родител
ревизия
55db3fee22
променени са 4 файла, в които са добавени 37 реда и са изтрити 18 реда
  1. 29 17
      controllers/his_api_controller.go
  2. 1 0
      controllers/schedule_api_controller.go
  3. 1 1
      service/schedule_service.go
  4. 6 0
      service/stock_service.go

+ 29 - 17
controllers/his_api_controller.go Целия файл

@@ -860,6 +860,7 @@ func (c *HisApiController) CreateHisPrescription() {
860 860
 	if stockConfig.IsOpen == 1 {
861 861
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
862 862
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
863
+
863 864
 			if len(prescriptions) > 0 {
864 865
 				for _, item := range prescriptions {
865 866
 
@@ -867,12 +868,19 @@ func (c *HisApiController) CreateHisPrescription() {
867 868
 					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
868 869
 						projects := items["project"].([]interface{})
869 870
 						if len(projects) > 0 {
871
+
870 872
 							for _, project := range projects {
873
+
871 874
 								var project_id int64
872 875
 								var project_type int64
873 876
 								var totals float64
874 877
 								var project_name string
875 878
 								var parsetotal int64
879
+								var id int64
880
+
881
+								if project.(map[string]interface{})["id"] != nil || reflect.TypeOf(project.(map[string]interface{})["id"]).String() == "float64" {
882
+									id = int64(project.(map[string]interface{})["id"].(float64))
883
+								}
876 884
 								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
877 885
 									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
878 886
 								}
@@ -884,17 +892,19 @@ func (c *HisApiController) CreateHisPrescription() {
884 892
 									totals, _ = strconv.ParseFloat(total, 64)
885 893
 									parsetotal, _ = strconv.ParseInt(total, 10, 64)
886 894
 								}
895
+
887 896
 								if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
888 897
 									project_name = project.(map[string]interface{})["project_name"].(string)
889 898
 
890 899
 								}
891 900
 								if project_type == 3 {
901
+
892 902
 									//查找该耗材的出库记录
893 903
 									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
894
-									var total_count int64
895
-									for _, it := range goodWarehouseInfo {
896
-										total_count += it.Count
897
-									}
904
+									//var total_count int64
905
+									//for _, it := range goodWarehouseInfo {
906
+									//	total_count += it.Count
907
+									//}
898 908
 									if len(goodWarehouseInfo) == 0 {
899 909
 										//查询耗材库存
900 910
 										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
@@ -911,21 +921,23 @@ func (c *HisApiController) CreateHisPrescription() {
911 921
 									}
912 922
 									if len(goodWarehouseInfo) > 0 {
913 923
 										//查询该患者耗材的历史数据
914
-										ordProject, _ := service.GetHisProjectPrescriptionByPatientId(patient_id, recordDateTime)
915
-										if total_count > 0 {
916
-											//数量发生改变
917
-											if parsetotal != total_count || len(ordProject) != len(projects) {
918
-												//查找今日该患者已经出库的所有耗材
919
-												goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
920
-												fmt.Println("goodList3323223232323232323", goodList)
921
-												for _, item := range goodList {
922
-													//回退库存
923
-													service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
924
-												}
925
-												//删除记录
926
-												service.DeleteAutoWarehouse(patient_id, recordDateTime)
924
+										ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
925
+										count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
926
+										fmt.Println("parsetotal33223232323232323", parsetotal)
927
+										fmt.Println("count2332322332232332", count)
928
+										//数量发生改变
929
+										if parsetotal != count {
930
+											//查找今日该患者已经出库的所有耗材
931
+											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
932
+											fmt.Println("goodList3323223232323232323", goodList)
933
+											for _, item := range goodList {
934
+												//回退库存
935
+												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
927 936
 											}
937
+											//删除记录
938
+											service.DeleteAutoWarehouse(patient_id, recordDateTime)
928 939
 										}
940
+
929 941
 									}
930 942
 								}
931 943
 							}

+ 1 - 0
controllers/schedule_api_controller.go Целия файл

@@ -2946,6 +2946,7 @@ func (c *ScheduleApiController) GetSolutionSchedule() {
2946 2946
 
2947 2947
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2948 2948
 	solution, _ := service.GetSolutionSchedule(orgId)
2949
+	fmt.Println("solution33232323223233233323232332323232", solution)
2949 2950
 	c.ServeSuccessJSON(map[string]interface{}{
2950 2951
 		"solution": solution,
2951 2952
 	})

+ 1 - 1
service/schedule_service.go Целия файл

@@ -1103,6 +1103,6 @@ func GetPatientScheduleTempalate(orgid int64) (models.PatientScheduleTemplateMod
1103 1103
 
1104 1104
 func GetSolutionSchedule(orgid int64) (solution []*models.DialysisSolution, err error) {
1105 1105
 
1106
-	err = XTReadDB().Model(&solution).Where("org_id = ? and status = 1", orgid).Group("mode_id").Order("created_time desc").Find(&solution).Error
1106
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time desc").Find(&solution).Error
1107 1107
 	return solution, err
1108 1108
 }

+ 6 - 0
service/stock_service.go Целия файл

@@ -3569,6 +3569,12 @@ func GetHisProjectPrescriptionByPatientId(patientid int64, recorddate int64) (pr
3569 3569
 	return project, err
3570 3570
 }
3571 3571
 
3572
+func GetHisProjectPrescriptionByPatientIdOne(id int64) (models.HisPrescriptionProject, error) {
3573
+	project := models.HisPrescriptionProject{}
3574
+	err = XTReadDB().Model(&project).Where("id = ? and status =1", id).Find(&project).Error
3575
+	return project, err
3576
+}
3577
+
3572 3578
 func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfoNight, err error) {
3573 3579
 
3574 3580
 	err = XTReadDB().Select("count,warehouse_info_id").Where(" patient_id = ? and sys_record_time = ?  and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error