Ver código fonte

历史排班

28169 1 mês atrás
pai
commit
667fade288

+ 1 - 1
controllers/dialysis_api_controller.go Ver arquivo

@@ -7150,7 +7150,7 @@ func (this *DialysisApiController) GetDialysisPatientsFlow() {
7150 7150
 
7151 7151
 	} else {
7152 7152
 		dialysisSchedule, err, total := service.GetDialysisWatchFlow(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
7153
-		fmt.Println("dialysisSchedule-----------------------", dialysisSchedule)
7153
+
7154 7154
 		if err == nil {
7155 7155
 			this.ServeSuccessJSON(map[string]interface{}{
7156 7156
 				"schedule": dialysisSchedule,

+ 6 - 8
controllers/manage_api_controller.go Ver arquivo

@@ -2881,7 +2881,6 @@ func (this *MachineApiController) GetPatientDetail() {
2881 2881
 
2882 2882
 func (this *MachineApiController) SaveReminder() {
2883 2883
 	id, _ := this.GetInt64("id")
2884
-	fmt.Print("码字", id)
2885 2884
 	info := this.GetAdminUserInfo()
2886 2885
 	orgId := info.CurrentOrgId
2887 2886
 	remander := models.DeviceRemander{
@@ -2892,8 +2891,7 @@ func (this *MachineApiController) SaveReminder() {
2892 2891
 	}
2893 2892
 	data, errs := service.GetRemanderData(orgId)
2894 2893
 	if errs == gorm.ErrRecordNotFound {
2895
-		err := service.CreateRemander(&remander).Error()
2896
-		fmt.Print(err)
2894
+		service.CreateRemander(&remander).Error()
2897 2895
 	} else if errs == nil {
2898 2896
 		deviceRemander := models.DeviceRemander{
2899 2897
 			ID:        data.ID,
@@ -2902,11 +2900,11 @@ func (this *MachineApiController) SaveReminder() {
2902 2900
 			UserOrgId: orgId,
2903 2901
 			Mtime:     time.Now().Unix(),
2904 2902
 		}
2905
-		err := service.UpdateRemander(&deviceRemander)
2906
-		if err != nil {
2907
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2908
-			return
2909
-		}
2903
+		service.UpdateRemander(&deviceRemander)
2904
+		//if err != nil {
2905
+		//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2906
+		//	return
2907
+		//}
2910 2908
 	}
2911 2909
 	this.ServeSuccessJSON(map[string]interface{}{
2912 2910
 		"id": id,

+ 17 - 0
controllers/schedule_api_controller.go Ver arquivo

@@ -2023,6 +2023,23 @@ func (c *ScheduleApiController) DeleteSchedule() {
2023 2023
 		}
2024 2024
 	}
2025 2025
 
2026
+	//如果使用的是保存出库功能
2027
+	drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
2028
+	//退库
2029
+	if drugOutConfig.IsOpen == 1 {
2030
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2031
+		for _, item := range hisAdvice {
2032
+			creater := adminINfo.AdminUser.Id
2033
+			err = service.DrugAutoAddCancelInfo(item, creater)
2034
+			if err != nil {
2035
+				err = fmt.Errorf("!:%v", err)
2036
+				return
2037
+			}
2038
+		}
2039
+		//查询是否有出库记录
2040
+		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2041
+	}
2042
+
2026 2043
 	redis := service.RedisClient()
2027 2044
 
2028 2045
 	//处方

+ 46 - 56
controllers/self_drug_api_congtroller.go Ver arquivo

@@ -3858,10 +3858,25 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3858 3858
 
3859 3859
 			//期间减少
3860 3860
 			banceOutList, _ := service.GetInitOutBanceList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3861
+
3861 3862
 			for _, it := range banceOutList {
3862 3863
 				item.WarehouseOutInfoTenty = append(item.WarehouseOutInfoTenty, it)
3863 3864
 			}
3864 3865
 
3866
+			//期间盘盈
3867
+			infoFlow, _ := service.GetInitInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3868
+
3869
+			for _, it := range infoFlow {
3870
+				item.WareStartInStockFlow = append(item.WareStartInStockFlow, it)
3871
+			}
3872
+
3873
+			//期间盘亏
3874
+			outInfoFlow, _ := service.GetInitOutInfoFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3875
+
3876
+			for _, it := range outInfoFlow {
3877
+				item.WareStartOutStockFlow = append(item.WareStartOutStockFlow, it)
3878
+			}
3879
+
3865 3880
 		}
3866 3881
 
3867 3882
 		if err != nil {
@@ -3940,41 +3955,6 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3940 3955
 		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
3941 3956
 
3942 3957
 		item.DrugEndFlow = endFlow
3943
-		//获取期初结余入库数量
3944
-		//startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)
3945
-		//for _, it := range startDrugInfo {
3946
-		//  item.DrugWarehouseInfoStart = append(item.DrugWarehouseInfoStart, it)
3947
-		//}
3948
-		//
3949
-		////获取期初结余出库数量
3950
-		//flowOutList, _ := service.GetDrugFlowOut(item.ID, orgId, startTime)
3951
-		//for _, it := range flowOutList {
3952
-		//  item.DrugWarehouseOutInfoStart = append(item.DrugWarehouseOutInfoStart, it)
3953
-		//}
3954
-		//
3955
-		////获取期初结余退库数量
3956
-		//cancelInfo, _ := service.GetStartDrugFlowCancelInfo(item.ID, orgId, startTime)
3957
-		//for _, it := range cancelInfo {
3958
-		//  item.WareStartStockCancelInfo = append(item.WareStartStockCancelInfo, it)
3959
-		//}
3960
-		//
3961
-		////获取期末结余入库数量
3962
-		//drugwarehouseinfoend, _ := service.DrugWarehouseInfoEnd(item.ID, orgId, endTime)
3963
-		//for _, it := range drugwarehouseinfoend {
3964
-		//  item.DrugWarehouseInfoEnd = append(item.DrugWarehouseInfoEnd, it)
3965
-		//}
3966
-
3967
-		////获取期末出库结余
3968
-		//endDrugInfo, _ := service.DrugWarehouseOutInfoEnd(item.ID, orgId, endTime)
3969
-		//for _, it := range endDrugInfo {
3970
-		//  item.DrugWarehouseOutInfoEnd = append(item.DrugWarehouseOutInfoEnd, it)
3971
-		//}
3972
-		//
3973
-		////获取期末退库数量
3974
-		//flowCancelInfo, _ := service.GetEndDrugFlowCancelInfo(item.ID, orgId, endTime)
3975
-		//for _, it := range flowCancelInfo {
3976
-		//  item.WareEndStockCancelInfo = append(item.WareEndStockCancelInfo, it)
3977
-		//}
3978 3958
 
3979 3959
 		//期中增加
3980 3960
 		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
@@ -3995,27 +3975,6 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3995 3975
 			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
3996 3976
 		}
3997 3977
 
3998
-		////获取期初盘盈
3999
-		//startProfit, _ := service.GetDrugFlowStartProfit(item.ID, orgId, startTime)
4000
-		//for _, it := range startProfit {
4001
-		//  item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
4002
-		//}
4003
-		////获取期初盘亏
4004
-		//startLosses, _ := service.GetDrugFlowStartLosses(item.ID, orgId, startTime)
4005
-		//for _, it := range startLosses {
4006
-		//  item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
4007
-		//}
4008
-		////获取期末盘盈
4009
-		//endProfit, _ := service.GetDrugFlowEndProfit(item.ID, orgId, endTime)
4010
-		//for _, it := range endProfit {
4011
-		//  item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
4012
-		//}
4013
-		////获取期末盘亏
4014
-		//losses, _ := service.GetDrugFlowEndLosses(item.ID, orgId, endTime)
4015
-		//for _, it := range losses {
4016
-		//  item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
4017
-		//}
4018
-
4019 3978
 		//获取期中盘盈
4020 3979
 		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
4021 3980
 		for _, it := range profit {
@@ -4027,6 +3986,37 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
4027 3986
 		for _, it := range endLosses {
4028 3987
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
4029 3988
 		}
3989
+
3990
+		//获取入库
3991
+		infoFLow, _ := service.GetNewDrugFlowInWarehouseInfo(item.ID, orgId, startTime)
3992
+
3993
+		for _, it := range infoFLow {
3994
+			item.NewDrugFlowInWarehouseInfo = append(item.NewDrugFlowInWarehouseInfo, it)
3995
+		}
3996
+		//获取盘盈
3997
+		infoProfitFlow, _ := service.GetNewDrugFlowPofitWarehouseInfo(item.ID, orgId, startTime)
3998
+
3999
+		for _, it := range infoProfitFlow {
4000
+			item.NewDrugFlowPofitWarehouseInfo = append(item.NewDrugFlowPofitWarehouseInfo, it)
4001
+		}
4002
+		//获取出库
4003
+		infoOutFlow, _ := service.GetNewDrugFlowOutWarehouseInfo(item.ID, orgId, startTime)
4004
+		for _, it := range infoOutFlow {
4005
+			item.NewDrugFlowOutWarehouseInfo = append(item.NewDrugFlowOutWarehouseInfo, it)
4006
+		}
4007
+
4008
+		//获取退库
4009
+		infoCacelFlow, _ := service.GetNewDrugFlowCacelWarehouseInfo(item.ID, orgId, startTime)
4010
+		for _, it := range infoCacelFlow {
4011
+			item.NewDrugFlowNoCancelWarehouseInfo = append(item.NewDrugFlowNoCancelWarehouseInfo, it)
4012
+		}
4013
+
4014
+		//获取盘亏
4015
+		infoNoPofitFlow, _ := service.GetNewDrugFlowNoPofitWarehouseInfo(item.ID, orgId, startTime)
4016
+		for _, it := range infoNoPofitFlow {
4017
+			item.NewDrugFlowNoPofitWarehouseInfo = append(item.NewDrugFlowNoPofitWarehouseInfo, it)
4018
+		}
4019
+
4030 4020
 	}
4031 4021
 	if err != nil {
4032 4022
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")

+ 10 - 1
models/new_stock_models.go Ver arquivo

@@ -288,7 +288,10 @@ type GoodInfoTwenty struct {
288 288
 	StartFlowWarehouseInfo []*VmStockFlowTwenty //本期增加
289 289
 
290 290
 	StWarehousingInfoTwo  []*StWarehousingInfoOne  `gorm:"json:"new_warehouse_info_start"` //期间增加
291
-	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`
291
+	WarehouseOutInfoTenty []*WarehouseOutInfoTenty `gorm:"json:"new_warehouse_out_info"`   //减少
292
+	WareStartInStockFlow  []*VmStockFlowTwenty     `gorm:"json:"new_stock_in_flow"`        //盘盈
293
+	WareStartOutStockFlow []*VmStockFlowTwenty     `gorm:"json:"new_stock_out_flow"`       //盘亏
294
+
292 295
 	//期初结余
293 296
 	StartFlowInfo    []*VmStockFlowTwenty
294 297
 	StartOutFlowInfo []*VmStockFlowTwenty
@@ -433,6 +436,12 @@ type VmBaseDrugTwenty struct {
433 436
 
434 437
 	DrugStatFlow DrugFlowTwenty
435 438
 	DrugEndFlow  DrugFlowTwenty
439
+
440
+	NewDrugFlowInWarehouseInfo       []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_in_flow_info"`
441
+	NewDrugFlowOutWarehouseInfo      []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_out_flow_info"`
442
+	NewDrugFlowPofitWarehouseInfo    []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_profit_flow_info"`
443
+	NewDrugFlowNoPofitWarehouseInfo  []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_no_profit_flow_info"`
444
+	NewDrugFlowNoCancelWarehouseInfo []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"new_drug_cancel_flow_info"`
436 445
 }
437 446
 
438 447
 func (VmBaseDrugTwenty) TableName() string {

+ 6 - 0
service/manage_center_service.go Ver arquivo

@@ -1070,3 +1070,9 @@ func DeletePatientDiagnose(id int64) error {
1070 1070
 	err := XTWriteDB().Model(&models.XtPatientDiagnose{}).Where("id=? and status= 1", id).Updates(map[string]interface{}{"status": 0}).Error
1071 1071
 	return err
1072 1072
 }
1073
+
1074
+func GetPatientGoodStockCount(patient_id int64, record_time int64, user_org_id int64) (auto []*models.XtAutomaticReduceDetail, err error) {
1075
+
1076
+	err = XTReadDB().Where("patient_id = ? and record_time =? and user_org_id = ? and status=1", patient_id, record_time, user_org_id).Find(&auto).Error
1077
+	return auto, err
1078
+}

+ 6 - 0
service/schedule_service.go Ver arquivo

@@ -1798,6 +1798,12 @@ func GetHisDoctorAdviceListTwenty(patient_id int64, schedule_date int64, user_or
1798 1798
 	return advice, err
1799 1799
 }
1800 1800
 
1801
+func GetHisDoctorAdviceListTwentyOne(patient_id int64, schedule_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
1802
+
1803
+	err = XTReadDB().Where("patient_id = ? and advice_date = ? and user_org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&advice).Error
1804
+	return advice, err
1805
+}
1806
+
1801 1807
 func GetHisPrescriptionProjectList(patient_id int64, record_date int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
1802 1808
 	err = XTReadDB().Where("patient_id = ? and record_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Find(&project).Error
1803 1809
 	return project, err

+ 136 - 3
service/self_drug_service.go Ver arquivo

@@ -3015,7 +3015,7 @@ func GetPurchaseStockQueryList(good_type int64, keyword string, page int64, limi
3015 3015
 
3016 3016
 func GetInitBalanceList(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.StWarehousingInfoOne, err error) {
3017 3017
 
3018
-	db := XTReadDB().Model(&list).Where("status=1")
3018
+	db := XTReadDB().Model(&list).Where("status=1 and is_check=1")
3019 3019
 
3020 3020
 	if good_id > 0 {
3021 3021
 		db = db.Where("good_id = ?", good_id)
@@ -3025,7 +3025,7 @@ func GetInitBalanceList(good_id int64, user_org_id int64, start_time int64, end_
3025 3025
 	}
3026 3026
 
3027 3027
 	if start_time > 0 {
3028
-		db = db.Where("ctime<=?", start_time)
3028
+		db = db.Where("ctime<?", start_time)
3029 3029
 	}
3030 3030
 
3031 3031
 	if storehouse_id > 0 {
@@ -3050,7 +3050,7 @@ func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end
3050 3050
 	}
3051 3051
 
3052 3052
 	if start_time > 0 {
3053
-		db = db.Where("ctime<=?", start_time)
3053
+		db = db.Where("ctime<?", start_time)
3054 3054
 	}
3055 3055
 
3056 3056
 	if storehouse_id > 0 {
@@ -3061,3 +3061,136 @@ func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end
3061 3061
 
3062 3062
 	return list, err
3063 3063
 }
3064
+
3065
+func GetInitInfoFlow(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.VmStockFlowTwenty, err error) {
3066
+
3067
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type =10")
3068
+
3069
+	if good_id > 0 {
3070
+		db = db.Where("good_id = ?", good_id)
3071
+	}
3072
+	if user_org_id > 0 {
3073
+		db = db.Where("user_org_id = ?", user_org_id)
3074
+	}
3075
+
3076
+	if start_time > 0 {
3077
+		db = db.Where("ctime<?", start_time)
3078
+	}
3079
+
3080
+	if storehouse_id > 0 {
3081
+		db = db.Where("storehouse_id = ?", storehouse_id)
3082
+	}
3083
+
3084
+	err = db.Find(&list).Error
3085
+
3086
+	return list, err
3087
+}
3088
+
3089
+func GetInitOutInfoFlow(good_id int64, user_org_id int64, start_time int64, end_time int64, storehouse_id int64) (list []*models.VmStockFlowTwenty, err error) {
3090
+
3091
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type =11")
3092
+
3093
+	if good_id > 0 {
3094
+		db = db.Where("good_id = ?", good_id)
3095
+	}
3096
+	if user_org_id > 0 {
3097
+		db = db.Where("user_org_id = ?", user_org_id)
3098
+	}
3099
+
3100
+	if start_time > 0 {
3101
+		db = db.Where("ctime<?", start_time)
3102
+	}
3103
+
3104
+	if storehouse_id > 0 {
3105
+		db = db.Where("storehouse_id = ?", storehouse_id)
3106
+	}
3107
+
3108
+	err = db.Find(&list).Error
3109
+
3110
+	return list, err
3111
+}
3112
+
3113
+func GetNewDrugFlowInWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3114
+
3115
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=1")
3116
+
3117
+	if drug_id > 0 {
3118
+		db = db.Where("drug_id = ?", drug_id)
3119
+	}
3120
+	if user_org_id > 0 {
3121
+		db = db.Where("user_org_id = ?", user_org_id)
3122
+	}
3123
+	if start_time > 0 {
3124
+		db = db.Where("ctime<?", start_time)
3125
+	}
3126
+	err = db.Find(&list).Error
3127
+	return list, err
3128
+}
3129
+
3130
+func GetNewDrugFlowPofitWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3131
+
3132
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=10")
3133
+
3134
+	if drug_id > 0 {
3135
+		db = db.Where("drug_id = ?", drug_id)
3136
+	}
3137
+	if user_org_id > 0 {
3138
+		db = db.Where("user_org_id = ?", user_org_id)
3139
+	}
3140
+	if start_time > 0 {
3141
+		db = db.Where("ctime<?", start_time)
3142
+	}
3143
+	err = db.Find(&list).Error
3144
+	return list, err
3145
+}
3146
+
3147
+func GetNewDrugFlowOutWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3148
+
3149
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=3")
3150
+
3151
+	if drug_id > 0 {
3152
+		db = db.Where("drug_id = ?", drug_id)
3153
+	}
3154
+	if user_org_id > 0 {
3155
+		db = db.Where("user_org_id = ?", user_org_id)
3156
+	}
3157
+	if start_time > 0 {
3158
+		db = db.Where("ctime<?", start_time)
3159
+	}
3160
+	err = db.Find(&list).Error
3161
+	return list, err
3162
+}
3163
+
3164
+func GetNewDrugFlowCacelWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3165
+
3166
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=7")
3167
+
3168
+	if drug_id > 0 {
3169
+		db = db.Where("drug_id = ?", drug_id)
3170
+	}
3171
+	if user_org_id > 0 {
3172
+		db = db.Where("user_org_id = ?", user_org_id)
3173
+	}
3174
+	if start_time > 0 {
3175
+		db = db.Where("ctime<?", start_time)
3176
+	}
3177
+	err = db.Find(&list).Error
3178
+	return list, err
3179
+}
3180
+
3181
+func GetNewDrugFlowNoPofitWarehouseInfo(drug_id int64, user_org_id int64, start_time int64) (list []*models.DrugFlowTwenty, err error) {
3182
+
3183
+	db := XTReadDB().Model(&list).Where("status=1 and consumable_type=11")
3184
+
3185
+	if drug_id > 0 {
3186
+		db = db.Where("drug_id = ?", drug_id)
3187
+	}
3188
+	if user_org_id > 0 {
3189
+		db = db.Where("user_org_id = ?", user_org_id)
3190
+	}
3191
+	if start_time > 0 {
3192
+		db = db.Where("ctime<?", start_time)
3193
+	}
3194
+	err = db.Find(&list).Error
3195
+	return list, err
3196
+}