Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
3ab3465755

+ 221 - 3
controllers/dialysis_api_controller.go View File

@@ -44,6 +44,8 @@ func DialysisApiRegistRouters() {
44 44
 	beego.Router("/api/dialysis/treatmentsummary", &DialysisApiController{}, "Post:PostTreatmentSummary")
45 45
 
46 46
 	beego.Router("/api/dialysis/advice_remind", &DialysisApiController{}, "Get:GetLongAdvice")
47
+	beego.Router("/api/dialysis/advice_remind/one", &DialysisApiController{}, "Get:GetLongAdviceOne")
48
+	beego.Router("/api/dialysis/advice_remind/two", &DialysisApiController{}, "Get:GetLongAdviceTwo")
47 49
 	beego.Router("/api/advice_remind/create", &DialysisApiController{}, "Post:CreateRemindDoctorAdvice")
48 50
 
49 51
 	beego.Router("/api/solution/get", &DialysisApiController{}, "Get:GetSolution")
@@ -66,6 +68,9 @@ func DialysisApiRegistRouters() {
66 68
 	beego.Router("/api/get/getrolelist", &DialysisApiController{}, "Get:GetRoleList")
67 69
 
68 70
 	beego.Router("/api/getinitprintdata", &DialysisApiController{}, "Get:GetInitPrintData")
71
+
72
+	beego.Router("/api/schedule/getorderdoctoradvice", &DialysisApiController{}, "Get:GetOrderDoctorAdvice")
73
+
69 74
 }
70 75
 
71 76
 func (c *DialysisApiController) GetQueueCall() {
@@ -2973,9 +2978,207 @@ func (c *DialysisApiController) GetLongAdvice() {
2973 2978
 		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
2974 2979
 		var advice_three []*models.DoctorAdvice
2975 2980
 		//groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
2976
-		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id)
2977
-		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id)
2981
+		recordDateStr := time.Now().Format("2006-01-02")
2982
+		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
2983
+
2984
+		nowtime := recordDate.Unix()
2985
+
2986
+		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, nowtime)
2987
+		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, nowtime)
2988
+
2989
+		for _, advice := range advices {
2990
+			if advice.FrequencyType == 3 {
2991
+				t := time.Now()
2992
+				week := int(t.Weekday())
2993
+
2994
+				switch week {
2995
+				case 1:
2996
+					if strings.Index(advice.WeekDay, "周一") == -1 {
2997
+						advice_three = append(advice_three, advice)
2998
+					}
2999
+
3000
+					break
3001
+				case 2:
3002
+					if strings.Index(advice.WeekDay, "周二") == -1 {
3003
+						advice_three = append(advice_three, advice)
3004
+					}
3005
+
3006
+					break
3007
+				case 3:
3008
+					if strings.Index(advice.WeekDay, "周三") == -1 {
3009
+						advice_three = append(advice_three, advice)
3010
+					}
3011
+
3012
+					break
3013
+				case 4:
3014
+					if strings.Index(advice.WeekDay, "周四") == -1 {
3015
+						advice_three = append(advice_three, advice)
3016
+					}
3017
+					break
3018
+				case 5:
3019
+					if strings.Index(advice.WeekDay, "周五") == -1 {
3020
+						advice_three = append(advice_three, advice)
3021
+					}
3022
+					break
3023
+				case 6:
3024
+					if strings.Index(advice.WeekDay, "周六") == -1 {
3025
+						advice_three = append(advice_three, advice)
3026
+					}
3027
+
3028
+					break
3029
+				case 0:
3030
+					if strings.Index(advice.WeekDay, "周日") == -1 {
3031
+						advice_three = append(advice_three, advice)
3032
+					}
3033
+					break
3034
+				}
3035
+			}
3036
+		}
3037
+
3038
+		for _, advice := range advices_two {
3039
+			p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
3040
+			now := p.Unix()
3041
+			dayStr := strconv.FormatInt(advice.DayCount, 10)
3042
+			dayStr2 := "-" + dayStr
3043
+			count, _ := strconv.ParseInt(dayStr2, 10, 64)
3044
+			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
3045
+			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
3046
+
3047
+			for _, ad := range advices {
3048
+				advice_three = append(advice_three, ad)
3049
+			}
3050
+		}
3051
+		if err == nil {
3052
+			c.ServeSuccessJSON(map[string]interface{}{
3053
+				"status":         "2",
3054
+				"advices":        advices,
3055
+				"advices_two":    RemoveRepeatedElement(advice_three),
3056
+				"is_open_remind": config.IsOpenRemind,
3057
+			})
3058
+		}
3059
+	}
3060
+
3061
+}
3062
+
3063
+func (c *DialysisApiController) GetLongAdviceOne() {
3064
+	patient_id, _ := c.GetInt64("patient_id")
3065
+	schedule_date := c.GetString("schedule_date")
3066
+	adminUserInfo := c.GetAdminUserInfo()
3067
+	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
3068
+	timeLayout := "2006-01-02"
3069
+	loc, _ := time.LoadLocation("Local")
3070
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
3071
+	//patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
3072
+	if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有	不开启推送功能,不做任何处理
3073
+		c.ServeSuccessJSON(map[string]interface{}{
3074
+			"status": "1",
3075
+		})
3076
+		return
3077
+	} else { //开启推送提醒
3078
+		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
3079
+		var advice_three []*models.DoctorAdvice
3080
+		//groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
3081
+		//recordDateStr := time.Now().Format("2006-01-02")
3082
+		//recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3083
+		//
3084
+		//nowtime := recordDate.Unix()
3085
+
3086
+		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
3087
+		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
3088
+		fmt.Println("advice23323232233232233223232332232323322323wodee", theTime.Unix())
3089
+		for _, advice := range advices {
3090
+			if advice.FrequencyType == 3 {
3091
+				t := time.Now()
3092
+				week := int(t.Weekday())
2978 3093
 
3094
+				switch week {
3095
+				case 1:
3096
+					if strings.Index(advice.WeekDay, "周一") == -1 {
3097
+						advice_three = append(advice_three, advice)
3098
+					}
3099
+
3100
+					break
3101
+				case 2:
3102
+					if strings.Index(advice.WeekDay, "周二") == -1 {
3103
+						advice_three = append(advice_three, advice)
3104
+					}
3105
+
3106
+					break
3107
+				case 3:
3108
+					if strings.Index(advice.WeekDay, "周三") == -1 {
3109
+						advice_three = append(advice_three, advice)
3110
+					}
3111
+
3112
+					break
3113
+				case 4:
3114
+					if strings.Index(advice.WeekDay, "周四") == -1 {
3115
+						advice_three = append(advice_three, advice)
3116
+					}
3117
+					break
3118
+				case 5:
3119
+					if strings.Index(advice.WeekDay, "周五") == -1 {
3120
+						advice_three = append(advice_three, advice)
3121
+					}
3122
+					break
3123
+				case 6:
3124
+					if strings.Index(advice.WeekDay, "周六") == -1 {
3125
+						advice_three = append(advice_three, advice)
3126
+					}
3127
+
3128
+					break
3129
+				case 0:
3130
+					if strings.Index(advice.WeekDay, "周日") == -1 {
3131
+						advice_three = append(advice_three, advice)
3132
+					}
3133
+					break
3134
+				}
3135
+			}
3136
+		}
3137
+
3138
+		for _, advice := range advices_two {
3139
+			p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
3140
+			now := p.Unix()
3141
+			dayStr := strconv.FormatInt(advice.DayCount, 10)
3142
+			dayStr2 := "-" + dayStr
3143
+			count, _ := strconv.ParseInt(dayStr2, 10, 64)
3144
+			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
3145
+			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
3146
+
3147
+			for _, ad := range advices {
3148
+				advice_three = append(advice_three, ad)
3149
+			}
3150
+		}
3151
+		if err == nil {
3152
+			c.ServeSuccessJSON(map[string]interface{}{
3153
+				"status":         "2",
3154
+				"advices":        advices,
3155
+				"advices_two":    RemoveRepeatedElement(advice_three),
3156
+				"is_open_remind": config.IsOpenRemind,
3157
+			})
3158
+		}
3159
+	}
3160
+
3161
+}
3162
+
3163
+func (c *DialysisApiController) GetLongAdviceTwo() {
3164
+	patient_id, _ := c.GetInt64("patient_id")
3165
+	schedule_date, _ := c.GetInt64("schedule_date")
3166
+	adminUserInfo := c.GetAdminUserInfo()
3167
+	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
3168
+
3169
+	//patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
3170
+	if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有	不开启推送功能,不做任何处理
3171
+		c.ServeSuccessJSON(map[string]interface{}{
3172
+			"status": "1",
3173
+		})
3174
+		return
3175
+	} else { //开启推送提醒
3176
+		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
3177
+		var advice_three []*models.DoctorAdvice
3178
+		//groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
3179
+		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
3180
+		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
3181
+		fmt.Println("advice23323232233232233223232332232323322323wodee", schedule_date)
2979 3182
 		for _, advice := range advices {
2980 3183
 			if advice.FrequencyType == 3 {
2981 3184
 				t := time.Now()
@@ -3729,17 +3932,32 @@ func (this *DialysisApiController) GetFuncPurview() {
3729 3932
 	}
3730 3933
 }
3731 3934
 
3935
+func (this *DialysisApiController) GetOrderDoctorAdvice() {
3936
+	patient_id, _ := this.GetInt64("patient_id", 0)
3937
+	advice_date, _ := this.GetInt64("advice_date")
3938
+	adminUserInfo := this.GetAdminUserInfo()
3939
+	doctorAdvice, _ := service.GetBloodDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
3940
+	hisDoctorAdvice, _ := service.GetHisDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
3941
+
3942
+	this.ServeSuccessJSON(map[string]interface{}{
3943
+
3944
+		"doctorAdvice":    doctorAdvice,
3945
+		"hisDoctorAdvice": hisDoctorAdvice,
3946
+	})
3947
+
3948
+}
3949
+
3732 3950
 func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
3733 3951
 	change_type, _ := this.GetInt64("type", 0)
3734 3952
 	record_date := this.GetString("record_time")
3735 3953
 	patient_id, _ := this.GetInt64("patient_id", 0)
3736
-
3737 3954
 	timeLayout := "2006-01-02"
3738 3955
 	loc, _ := time.LoadLocation("Local")
3739 3956
 	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
3740 3957
 	record_time := theAdviceRecordTime.Unix()
3741 3958
 	adminUserInfo := this.GetAdminUserInfo()
3742 3959
 	advices, sch, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
3960
+
3743 3961
 	if err == nil {
3744 3962
 		if len(advices) == 0 {
3745 3963
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)

+ 143 - 114
controllers/his_api_controller.go View File

@@ -1001,7 +1001,7 @@ func (c *HisApiController) CreateHisPrescription() {
1001 1001
 				if id > 0 {
1002 1002
 					new_prescription, err := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
1003 1003
 					if err != nil {
1004
-						if new_prescription.OrderStatus == 2 || new_prescription.OrderStatus == 4 {
1004
+						if new_prescription.OrderStatus == 4 {
1005 1005
 							isCharge = true
1006 1006
 						}
1007 1007
 					}
@@ -1093,14 +1093,14 @@ func (c *HisApiController) CreateHisPrescription() {
1093 1093
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1094 1094
 
1095 1095
 								//查询最新批次库存
1096
-								//info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1097
-								//var batch_number_count int64
1098
-								//batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
1099
-								//batch_number_counts := strconv.FormatInt(batch_number_count, 10)
1096
+								info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1097
+								var batch_number_count int64
1098
+								batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
1099
+								batch_number_counts := strconv.FormatInt(batch_number_count, 10)
1100 1100
 								//新增处方
1101 1101
 								if advicelist.ID == 0 {
1102 1102
 									all_count, _ := strconv.ParseFloat(totals, 64)
1103
-									//batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1103
+									batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1104 1104
 									if prescribingNumberUnit == drug.MinUnit {
1105 1105
 
1106 1106
 										if drug.IsUse != 1 {
@@ -1109,10 +1109,12 @@ func (c *HisApiController) CreateHisPrescription() {
1109 1109
 												return
1110 1110
 											}
1111 1111
 
1112
-											//if prescribing_number > batch_number_all_count {
1113
-											//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1114
-											//	return
1115
-											//}
1112
+											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1113
+												if prescribing_number > batch_number_all_count {
1114
+													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1115
+													return
1116
+												}
1117
+											}
1116 1118
 
1117 1119
 										}
1118 1120
 
@@ -1124,11 +1126,13 @@ func (c *HisApiController) CreateHisPrescription() {
1124 1126
 												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1125 1127
 												return
1126 1128
 											}
1129
+											if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1130
+												if num > batch_number_all_count {
1131
+													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1132
+													return
1133
+												}
1134
+											}
1127 1135
 
1128
-											//if num > batch_number_all_count {
1129
-											//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1130
-											//	return
1131
-											//}
1132 1136
 										}
1133 1137
 									}
1134 1138
 								}
@@ -1182,6 +1186,7 @@ func (c *HisApiController) CreateHisPrescription() {
1182 1186
 											var batch_number_count int64
1183 1187
 											batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
1184 1188
 											batch_number_counts := strconv.FormatInt(batch_number_count, 10)
1189
+
1185 1190
 											all_count, _ := strconv.ParseFloat(totals, 64)
1186 1191
 											if prescribingNumberUnit == drug.MinUnit {
1187 1192
 												batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
@@ -1190,12 +1195,13 @@ func (c *HisApiController) CreateHisPrescription() {
1190 1195
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1191 1196
 														return
1192 1197
 													}
1193
-													fmt.Println("prescribing_number2332323323323", prescribing_number)
1194
-													fmt.Println("batch_number_all_count", batch_number_all_count)
1195
-													//if prescribing_number > batch_number_all_count {
1196
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1197
-													//	return
1198
-													//}
1198
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1199
+														if prescribing_number > batch_number_all_count {
1200
+															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1201
+															return
1202
+														}
1203
+													}
1204
+
1199 1205
 												}
1200 1206
 
1201 1207
 											} else {
@@ -1207,12 +1213,13 @@ func (c *HisApiController) CreateHisPrescription() {
1207 1213
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1208 1214
 															return
1209 1215
 														}
1210
-														fmt.Println("prescribing_number2332323323323", prescribing_number)
1211
-														fmt.Println("batch_number_all_count", batch_number_all_count)
1212
-														//if prescribing_number > batch_number_all_count {
1213
-														//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1214
-														//	return
1215
-														//}
1216
+														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1217
+															if prescribing_number > batch_number_all_count {
1218
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1219
+																return
1220
+															}
1221
+														}
1222
+
1216 1223
 													}
1217 1224
 
1218 1225
 												}
@@ -1257,44 +1264,51 @@ func (c *HisApiController) CreateHisPrescription() {
1257 1264
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1258 1265
 														return
1259 1266
 													}
1260
-													fmt.Println("number_count", number_count)
1261
-													fmt.Println("device_number", device_number)
1262
-													fmt.Println("batch_number_count", batch_number_count)
1263 1267
 
1264
-													//if (number_count - device_number) > batch_number_count {
1265
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1266
-													//	return
1267
-													//}
1268
+													if (number_count - device_number) > batch_number_count {
1269
+														c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1270
+														return
1271
+													}
1272
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1273
+														// 查询该药品最后一次出库记录
1274
+														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1268 1275
 
1269
-													// 查询该药品最后一次出库记录
1270
-													//outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1271
-													//var out_count int64
1272
-													//var in_count int64
1273
-													//var stock_max_number int64
1274
-													//var stock_min_number int64
1275
-													//for _, it := range outInfo {
1276
-													//	if it.CountUnit == drug.MaxUnit {
1277
-													//		it.Count = it.Count * drug.MinNumber
1278
-													//	}
1279
-													//	out_count += it.Count
1280
-													//	warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
1281
-													//	fmt.Println("warehouseInfoList233323232332323232",warehouseInfoList)
1282
-													//	stock_max_number = warehouseInfoList.StockMaxNumber
1283
-													//	stock_min_number = warehouseInfoList.StockMinNumber
1284
-													//	if warehouseInfoList.MaxUnit == drug.MaxUnit {
1285
-													//		in_count = warehouseInfoList.WarehousingCount * drug.MinNumber
1286
-													//	}
1287
-													//	if warehouseInfoList.MaxUnit == drug.MinUnit {
1288
-													//		in_count = warehouseInfoList.WarehousingCount
1289
-													//	}
1290
-													//}
1291
-													//fmt.Println("out_count",out_count)
1292
-													//fmt.Println("number_count - device_number",number_count - device_number)
1293
-													//fmt.Println("in_countwowowowowowow",in_count)
1294
-													//if (out_count + (number_count - device_number)) > in_count {
1295
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
1296
-													//	return
1297
-													//}
1276
+														var out_count int64
1277
+														var in_count int64
1278
+														var stock_max_number int64
1279
+														var stock_min_number int64
1280
+														for _, it := range outInfo {
1281
+															if it.CountUnit == drug.MaxUnit {
1282
+																it.Count = it.Count * drug.MinNumber
1283
+															}
1284
+															out_count += it.Count
1285
+															warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
1286
+
1287
+															stock_max_number = warehouseInfoList.StockMaxNumber
1288
+															stock_min_number = warehouseInfoList.StockMinNumber
1289
+															in_count = warehouseInfoList.StockMaxNumber*drug.MinNumber + warehouseInfoList.StockMinNumber
1290
+
1291
+														}
1292
+
1293
+														if out_count > 0 {
1294
+															if (number_count - device_number) > in_count {
1295
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
1296
+																return
1297
+															}
1298
+														}
1299
+														// 未出库
1300
+														if out_count == 0 {
1301
+															var sum_in_count int64
1302
+															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1303
+															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
1304
+															fmt.Println("sum_in_count", sum_in_count)
1305
+															//如果修改的数量大于有库存的第一个批次
1306
+															if number_count > sum_in_count {
1307
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
1308
+																return
1309
+															}
1310
+														}
1311
+													}
1298 1312
 
1299 1313
 												}
1300 1314
 
@@ -1394,38 +1408,43 @@ func (c *HisApiController) CreateHisPrescription() {
1394 1408
 										//新增处方
1395 1409
 										if advicelist.ID == 0 {
1396 1410
 											//查询最新批次库存
1397
-											//info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1398
-											//var batch_number_count int64
1399
-											//batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
1400
-											//batch_number_counts := strconv.FormatInt(batch_number_count, 10)
1411
+											info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1412
+											var batch_number_count int64
1413
+											batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
1414
+											batch_number_counts := strconv.FormatInt(batch_number_count, 10)
1401 1415
 											all_count, _ := strconv.ParseFloat(totals, 64)
1402 1416
 											if prescribingNumberUnit == drug.MinUnit {
1403
-												//batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1417
+												batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1404 1418
 												if drug.IsUse != 1 {
1405 1419
 													if prescribing_number > all_count {
1406 1420
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1407 1421
 														return
1408 1422
 													}
1409
-													//if prescribing_number > batch_number_all_count {
1410
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1411
-													//	return
1412
-													//}
1423
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1424
+														if prescribing_number > batch_number_all_count {
1425
+															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1426
+															return
1427
+														}
1428
+													}
1429
+
1413 1430
 												}
1414 1431
 
1415 1432
 											} else {
1416 1433
 												if prescribingNumberUnit == drug.MaxUnit {
1417
-													//batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1434
+													batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
1418 1435
 													num := prescribing_number * float64(drug.MinNumber)
1419 1436
 													if drug.IsUse != 1 {
1420 1437
 														if num > all_count {
1421 1438
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1422 1439
 															return
1423 1440
 														}
1441
+														if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1442
+															if prescribing_number > batch_number_all_count {
1443
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1444
+																return
1445
+															}
1446
+														}
1424 1447
 
1425
-														//if prescribing_number > batch_number_all_count {
1426
-														//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1427
-														//	return
1428
-														//}
1429 1448
 													}
1430 1449
 
1431 1450
 												}
@@ -1468,43 +1487,53 @@ func (c *HisApiController) CreateHisPrescription() {
1468 1487
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1469 1488
 														return
1470 1489
 													}
1471
-													fmt.Println("number_count", number_count)
1472
-													fmt.Println("device_number", device_number)
1473
-													fmt.Println("batch_number_count", batch_number_count)
1474
-													//if (number_count - device_number) > batch_number_count {
1475
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1476
-													//	return
1477
-													//}
1478
-
1479
-													//查询历史出库数据总批次
1480
-													// 查询该药品最后一次出库记录
1481
-													//outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1482
-													//var out_count int64
1483
-													//var in_count int64
1484
-													//var stock_max_number int64
1485
-													//var stock_min_number int64
1486
-													//for _, it := range outInfo {
1487
-													//	if it.CountUnit == drug.MaxUnit {
1488
-													//		it.Count = it.Count * drug.MinNumber
1489
-													//	}
1490
-													//	out_count += it.Count
1491
-													//	warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
1492
-													//	stock_max_number = warehouseInfoList.StockMaxNumber
1493
-													//	stock_min_number = warehouseInfoList.StockMinNumber
1494
-													//	if warehouseInfoList.MaxUnit == drug.MaxUnit {
1495
-													//		in_count = warehouseInfoList.WarehousingCount * drug.MinNumber
1496
-													//	}
1497
-													//	if warehouseInfoList.MaxUnit == drug.MinUnit {
1498
-													//		in_count = warehouseInfoList.WarehousingCount
1499
-													//	}
1500
-													//}
1501
-													//fmt.Println("out_count",out_count)
1502
-													//fmt.Println("number_count - device_number",number_count - device_number)
1503
-													//fmt.Println("in_count",in_count)
1504
-													//if (out_count + (number_count - device_number)) > in_count {
1505
-													//	c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
1506
-													//	return
1507
-													//}
1490
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1491
+														if (number_count - device_number) > batch_number_count {
1492
+															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1493
+															return
1494
+														}
1495
+													}
1496
+
1497
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1498
+														//查询历史出库数据总批次
1499
+														// 查询该药品最后一次出库记录
1500
+														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1501
+														var out_count int64
1502
+														var in_count int64
1503
+														var stock_max_number int64
1504
+														var stock_min_number int64
1505
+														for _, it := range outInfo {
1506
+															if it.CountUnit == drug.MaxUnit {
1507
+																it.Count = it.Count * drug.MinNumber
1508
+															}
1509
+															out_count += it.Count
1510
+															warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
1511
+															stock_max_number = warehouseInfoList.StockMaxNumber
1512
+															stock_min_number = warehouseInfoList.StockMinNumber
1513
+															in_count = warehouseInfoList.StockMaxNumber*drug.MinNumber + warehouseInfoList.StockMinNumber
1514
+
1515
+														}
1516
+
1517
+														if out_count > 0 {
1518
+															if (number_count - device_number) > in_count {
1519
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
1520
+																return
1521
+															}
1522
+														}
1523
+
1524
+														// 未出库
1525
+														if out_count == 0 {
1526
+															var sum_in_count int64
1527
+															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
1528
+															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
1529
+
1530
+															//如果修改的数量大于有库存的第一个批次
1531
+															if number_count > sum_in_count {
1532
+																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
1533
+																return
1534
+															}
1535
+														}
1536
+													}
1508 1537
 
1509 1538
 												}
1510 1539
 											}
@@ -2386,7 +2415,7 @@ func (c *HisApiController) DeletePrescription() {
2386 2415
 	}
2387 2416
 
2388 2417
 	for _, item := range new_prescriptions {
2389
-		if item.OrderStatus == 2 || item.OrderStatus == 4 {
2418
+		if item.OrderStatus == 4 {
2390 2419
 			isCharge = true
2391 2420
 		}
2392 2421
 	}

+ 119 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -3314,10 +3314,126 @@ func (c *DialysisAPIController) GetLongAdvice() {
3314 3314
 	} else { //开启推送提醒
3315 3315
 		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
3316 3316
 		var advice_three []*models.DoctorAdvice
3317
+		recordDateStr := time.Now().Format("2006-01-02")
3318
+		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3319
+
3320
+		nowtime := recordDate.Unix()
3321
+		//advices, err := service.GetLastLongAdviceByGroupNoOne(adminUserInfo.Org.Id, patient_id,nowtime)
3322
+		//fmt.Println("advices232333232323323233232333223233232322332",advices)
3323
+		//advices_two, err := service.GetLastLongAdviceByGroupNoFour(adminUserInfo.Org.Id, patient_id,nowtime)
3324
+		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, nowtime)
3325
+		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, nowtime)
3326
+		for _, advice := range advices {
3327
+			if advice.FrequencyType == 3 {
3328
+				t := time.Now()
3329
+				week := int(t.Weekday())
3330
+				fmt.Println(t.Weekday())
3331
+
3332
+				fmt.Println(week)
3317 3333
 
3318
-		advices, err := service.GetLastLongAdviceByGroupNoOne(adminUserInfo.Org.Id, patient_id)
3319
-		advices_two, err := service.GetLastLongAdviceByGroupNoFour(adminUserInfo.Org.Id, patient_id)
3334
+				switch week {
3335
+				case 1:
3336
+					if strings.Index(advice.WeekDay, "周一") == -1 {
3337
+						advice_three = append(advice_three, advice)
3338
+					}
3339
+					break
3340
+				case 2:
3341
+					if strings.Index(advice.WeekDay, "周二") == -1 {
3342
+						advice_three = append(advice_three, advice)
3343
+					}
3344
+					break
3345
+				case 3:
3346
+					if strings.Index(advice.WeekDay, "周三") == -1 {
3347
+						advice_three = append(advice_three, advice)
3348
+					}
3349
+					break
3350
+				case 4:
3351
+					if strings.Index(advice.WeekDay, "周四") == -1 {
3352
+						advice_three = append(advice_three, advice)
3353
+					}
3354
+					break
3355
+				case 5:
3356
+					if strings.Index(advice.WeekDay, "周五") == -1 {
3357
+						advice_three = append(advice_three, advice)
3358
+					}
3359
+					break
3360
+				case 6:
3361
+					if strings.Index(advice.WeekDay, "周六") == -1 {
3362
+						advice_three = append(advice_three, advice)
3363
+					}
3364
+					break
3365
+				case 0:
3366
+					if strings.Index(advice.WeekDay, "周日") == -1 {
3367
+						advice_three = append(advice_three, advice)
3368
+					}
3369
+					break
3370
+				}
3371
+			}
3372
+		}
3320 3373
 
3374
+		for _, advice := range advices_two {
3375
+			p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
3376
+			now := p.Unix()
3377
+			dayStr := strconv.FormatInt(advice.DayCount, 10)
3378
+			dayStr2 := "-" + dayStr
3379
+			count, _ := strconv.ParseInt(dayStr2, 10, 64)
3380
+			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
3381
+			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.Org.Id, advice.TemplateId)
3382
+
3383
+			for _, ad := range advices {
3384
+				advice_three = append(advice_three, ad)
3385
+			}
3386
+		}
3387
+		if err == nil {
3388
+			c.ServeSuccessJSON(map[string]interface{}{
3389
+				"status":            "2",
3390
+				"advices":           advices,
3391
+				"advices_two":       RemoveRepeatedElement(advice_three),
3392
+				"is_open_remind":    config.IsOpenRemind,
3393
+				"his_config_open":   hisConfig.IsOpen,
3394
+				"is_advice_open":    is_advice_open.IsAdviceOpen,
3395
+				"prescription_open": prescription_open.IsOpen,
3396
+			})
3397
+		}
3398
+	}
3399
+
3400
+}
3401
+
3402
+func (c *DialysisAPIController) GetLongAdviceOne() {
3403
+	patient_id, _ := c.GetInt64("id")
3404
+	startTime := c.GetString("schedule_date")
3405
+	timeLayout := "2006-01-02"
3406
+	loc, _ := time.LoadLocation("Local")
3407
+
3408
+	var theStartTime int64
3409
+	if len(startTime) > 0 {
3410
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
3411
+		if err != nil {
3412
+			utils.ErrorLog(err.Error())
3413
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3414
+			return
3415
+		}
3416
+		theStartTime = theTime.Unix()
3417
+	}
3418
+	adminUserInfo := c.GetMobileAdminUserInfo()
3419
+	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.Org.Id)
3420
+	_, hisConfig := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
3421
+	is_advice_open, _ := service.FindAdviceSettingById(adminUserInfo.Org.Id)
3422
+
3423
+	prescription_open, _ := service.FindPrescriptionConfigById(adminUserInfo.Org.Id)
3424
+	//patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
3425
+	if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有	不开启推送功能,不做任何处理
3426
+		c.ServeSuccessJSON(map[string]interface{}{
3427
+			"status": "1",
3428
+		})
3429
+		return
3430
+	} else { //开启推送提醒
3431
+		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
3432
+		var advice_three []*models.DoctorAdvice
3433
+
3434
+		fmt.Println("theStartTime23434343433434433443434343434334", theStartTime)
3435
+		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
3436
+		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
3321 3437
 		for _, advice := range advices {
3322 3438
 			if advice.FrequencyType == 3 {
3323 3439
 				t := time.Now()
@@ -3393,6 +3509,7 @@ func (c *DialysisAPIController) GetLongAdvice() {
3393 3509
 	}
3394 3510
 
3395 3511
 }
3512
+
3396 3513
 func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
3397 3514
 	newArr = make([]*models.DoctorAdvice, 0)
3398 3515
 	for i := 0; i < len(arr); i++ {

+ 1 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -111,6 +111,7 @@ func MobileAPIControllersRegisterRouters() {
111 111
 	beego.Router("/m/api/warehouse/query", &StockApiController{}, "get:GetWarehouse")
112 112
 
113 113
 	beego.Router("/m/api/dialysis/advice_remind", &DialysisAPIController{}, "Get:GetLongAdvice")
114
+	beego.Router("/m/api/dialysis/advice_remind/one", &DialysisAPIController{}, "Get:GetLongAdviceOne")
114 115
 	beego.Router("/m/api/advice_remind/create", &DialysisAPIController{}, "Post:CreateRemindDoctorAdvice")
115 116
 	beego.Router("/m/api/dryweight/commit", &DialysisAPIController{}, "Post:UploadDryWeight")
116 117
 

File diff suppressed because it is too large
+ 829 - 211
controllers/patient_api_controller.go


+ 97 - 7
controllers/role_controller.go View File

@@ -221,7 +221,8 @@ func (this *RoleAPIController) EditPurviewInitData() {
221 221
 	purviews_func, _ := service.GetAllGeneralFuncPurviewVMsProcessed()
222 222
 
223 223
 	//门诊
224
-	outpatientRegistration, _, _ := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientRegistration/manage")
224
+	_, _, outpatientRegistration := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientRegistration/manage")
225
+	fmt.Println(outpatientRegistration)
225 226
 	//电子病历
226 227
 	_, _, originEle := service.GetOtherAllGeneralPurviewVMsProcessed("/patinets/ele")
227 228
 	//透析管理
@@ -232,12 +233,14 @@ func (this *RoleAPIController) EditPurviewInitData() {
232 233
 	//_, _, orginConfig := service.GetOtherAllGeneralPurviewVMsProcessed("/config/manage")
233 234
 
234 235
 	//门诊管理
236
+	_, _, YajinPurview := service.GetOtherAllGeneralPurviewVMsProcessed("DepositManagement")
237
+	//_, _, YaofangPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/api/pharmacy")
238
+	_, _, DengjiPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/hospitalRecord/index")
239
+	_, _, GongjuPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/hisTool")
240
+	_, _, ShoufeiPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/hospitalCharges")
235 241
 	_, _, outpatientRegistrationPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientRegistration/index")
236
-
237 242
 	_, _, outpatientRegistrationPurviewTwo := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientDoctorStation")
238
-
239 243
 	_, _, outpatientRegistrationPurviewThree := service.GetOtherAllGeneralPurviewVMsProcessed("/outpatientCharges")
240
-
241 244
 	_, _, outpatientRegistrationPurviewFour := service.GetOtherAllGeneralPurviewVMsProcessed("/hospitalStation")
242 245
 
243 246
 	//透析管理
@@ -266,13 +269,66 @@ func (this *RoleAPIController) EditPurviewInitData() {
266 269
 
267 270
 	//门诊管理
268 271
 
272
+	subYajinPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
269 273
 	subPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
270
-
271 274
 	subPurviewTreeViewModelTwo := []*service.PurviewTreeViewModel{}
272 275
 	subPurviewTreeViewModelThree := []*service.PurviewTreeViewModel{}
276
+	//subYaoFangPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
277
+	subDengjiPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
273 278
 	subPurviewTreeViewModelFour := []*service.PurviewTreeViewModel{}
274
-
275 279
 	subPurviewTreeViewModelFive := []*service.PurviewTreeViewModel{}
280
+	subGongJuPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
281
+	subShouFeiPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
282
+
283
+	for _, item := range YajinPurview {
284
+		temp := &service.PurviewTreeViewModel{
285
+			ID:     item.Id,
286
+			PID:    item.Parentid,
287
+			Name:   item.Name,
288
+			Number: 1,
289
+		}
290
+		subYajinPurviewTreeViewModel = append(subYajinPurviewTreeViewModel, temp)
291
+	}
292
+
293
+	//for _, item := range YaofangPurview {
294
+	//	temp := &service.PurviewTreeViewModel{
295
+	//		ID:     item.Id,
296
+	//		PID:    item.Parentid,
297
+	//		Name:   item.Name,
298
+	//		Number: 1,
299
+	//	}
300
+	//	subYaoFangPurviewTreeViewModel = append(subYaoFangPurviewTreeViewModel, temp)
301
+	//}
302
+
303
+	for _, item := range DengjiPurview {
304
+		temp := &service.PurviewTreeViewModel{
305
+			ID:     item.Id,
306
+			PID:    item.Parentid,
307
+			Name:   item.Name,
308
+			Number: 1,
309
+		}
310
+		subDengjiPurviewTreeViewModel = append(subDengjiPurviewTreeViewModel, temp)
311
+	}
312
+
313
+	for _, item := range GongjuPurview {
314
+		temp := &service.PurviewTreeViewModel{
315
+			ID:     item.Id,
316
+			PID:    item.Parentid,
317
+			Name:   item.Name,
318
+			Number: 1,
319
+		}
320
+		subGongJuPurviewTreeViewModel = append(subGongJuPurviewTreeViewModel, temp)
321
+	}
322
+
323
+	for _, item := range ShoufeiPurview {
324
+		temp := &service.PurviewTreeViewModel{
325
+			ID:     item.Id,
326
+			PID:    item.Parentid,
327
+			Name:   item.Name,
328
+			Number: 1,
329
+		}
330
+		subShouFeiPurviewTreeViewModel = append(subShouFeiPurviewTreeViewModel, temp)
331
+	}
276 332
 
277 333
 	for _, item := range outpatientRegistrationPurview {
278 334
 		temp := &service.PurviewTreeViewModel{
@@ -325,7 +381,23 @@ func (this *RoleAPIController) EditPurviewInitData() {
325 381
 		subPurviewTreeViewModelFive = append(subPurviewTreeViewModelFive, temp)
326 382
 	}
327 383
 
384
+	//透析管理
385
+	subOutpatientPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
328 386
 	for _, item := range outpatientRegistration {
387
+		temp := &service.PurviewTreeViewModel{
388
+			ID:     item.Id,
389
+			PID:    item.Parentid,
390
+			Name:   item.Name,
391
+			Number: 1,
392
+		}
393
+		subOutpatientPurviewTreeViewModel = append(subOutpatientPurviewTreeViewModel, temp)
394
+	}
395
+
396
+	for _, item := range subOutpatientPurviewTreeViewModel {
397
+		if item.Name == "押金管理" {
398
+			item.Childs = append(item.Childs, subYajinPurviewTreeViewModel...)
399
+		}
400
+
329 401
 		if item.Name == "门诊挂号" {
330 402
 			item.Childs = append(item.Childs, subPurviewTreeViewModel...)
331 403
 		}
@@ -335,12 +407,30 @@ func (this *RoleAPIController) EditPurviewInitData() {
335 407
 		}
336 408
 
337 409
 		if item.Name == "门诊收费" {
410
+
338 411
 			item.Childs = append(item.Childs, subPurviewTreeViewModelThree...)
339 412
 		}
413
+		//if item.Name == "药房管理" {
414
+		//	item.Childs = append(item.Childs, subYaoFangPurviewTreeViewModel...)
415
+		//}
416
+
417
+		if item.Name == "住院登记" {
418
+			item.Childs = append(item.Childs, subDengjiPurviewTreeViewModel...)
419
+		}
340 420
 
341 421
 		if item.Name == "住院工作站" {
422
+
342 423
 			item.Childs = append(item.Childs, subPurviewTreeViewModelFour...)
343 424
 		}
425
+
426
+		if item.Name == "住院收费" {
427
+			item.Childs = append(item.Childs, subShouFeiPurviewTreeViewModel...)
428
+		}
429
+
430
+		if item.Name == "HIS工具" {
431
+
432
+			item.Childs = append(item.Childs, subGongJuPurviewTreeViewModel...)
433
+		}
344 434
 	}
345 435
 
346 436
 	//电子病历
@@ -643,7 +733,7 @@ func (this *RoleAPIController) EditPurviewInitData() {
643 733
 		PID:    0,
644 734
 		Name:   "门诊管理",
645 735
 		Number: 3,
646
-		Childs: outpatientRegistration,
736
+		Childs: subOutpatientPurviewTreeViewModel,
647 737
 	}
648 738
 	purviews = append(purviews, menzhen)
649 739
 

+ 393 - 0
controllers/self_drug_api_congtroller.go View File

@@ -85,6 +85,20 @@ func SelfDrugRouters() {
85 85
 	beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
86 86
 
87 87
 	beego.Router("/api/drug/getinventorymodelist", &SelfDrugApiController{}, "Get:GetInventoryModeList")
88
+
89
+	//耗材库存优化接口
90
+	beego.Router("/api/drug/getstorehouselist", &SelfDrugApiController{}, "Get:GetStorehouseList")
91
+	beego.Router("/api/drug/getgoodnewquery", &SelfDrugApiController{}, "Get:GetGoodNewQuery")
92
+	beego.Router("/api/drug/getgoodwarehouseoutinfobyid", &SelfDrugApiController{}, "Get:GetGoodWarehouseOutInfoByIdList")
93
+	beego.Router("/api/good/getgoodpatientlist", &SelfDrugApiController{}, "Get:GetGoodPatientList")
94
+	beego.Router("/api/good/getwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetWarehouseOutDetailByPatientId")
95
+	beego.Router("/api/good/getgoodexpirydatequery", &SelfDrugApiController{}, "Get:GetGoodExpiryDateQuery")
96
+	beego.Router("/api/good/getpurchasestockquery", &SelfDrugApiController{}, "Get:GetGoodPurchaseStockQuery")
97
+
98
+	//药品库存优化接口
99
+	beego.Router("/api/good/getdrugwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetDrugWarehouseOutDetailByPatientId")
100
+	beego.Router("/api/drug/getdrugexpirydatequery", &SelfDrugApiController{}, "Get:GetDrugExpiryDateQuery")
101
+
88 102
 }
89 103
 
90 104
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -2683,3 +2697,382 @@ func (this *SelfDrugApiController) GetInventoryModeList() {
2683 2697
 		"manufacturerList": manufacturerList,
2684 2698
 	})
2685 2699
 }
2700
+
2701
+//库存优化接口
2702
+func (this *SelfDrugApiController) GetStorehouseList() {
2703
+
2704
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2705
+
2706
+	list, err := service.GetAllStoreHouseList(orgId)
2707
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2708
+	goodType, _ := service.GetAllGoodType(orgId)
2709
+	patientList, _ := service.GetAllpatient(orgId)
2710
+	if err != nil {
2711
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取仓库失败")
2712
+		return
2713
+	}
2714
+
2715
+	this.ServeSuccessJSON(map[string]interface{}{
2716
+		"list":             list,
2717
+		"manufacturerList": manufacturerList,
2718
+		"goodTypeList":     goodType,
2719
+		"patientList":      patientList,
2720
+	})
2721
+}
2722
+
2723
+func (this *SelfDrugApiController) GetGoodNewQuery() {
2724
+
2725
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2726
+	storehouse_id, _ := this.GetInt64("storehouse_id")
2727
+	good_type, _ := this.GetInt64("good_type")
2728
+	keyword := this.GetString("keyword")
2729
+	page, _ := this.GetInt64("page")
2730
+	limit, _ := this.GetInt64("limit")
2731
+	start_time := this.GetString("start_time")
2732
+	end_time := this.GetString("end_time")
2733
+	timeLayout := "2006-01-02"
2734
+	loc, _ := time.LoadLocation("Local")
2735
+	var startTime int64
2736
+	if len(start_time) > 0 {
2737
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2738
+		if err != nil {
2739
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2740
+			return
2741
+		}
2742
+		startTime = theTime.Unix()
2743
+	}
2744
+	var endTime int64
2745
+	if len(end_time) > 0 {
2746
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2747
+		if err != nil {
2748
+			utils.ErrorLog(err.Error())
2749
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2750
+			return
2751
+		}
2752
+		endTime = theTime.Unix()
2753
+	}
2754
+	var ids []int64
2755
+	var goodIds []int64
2756
+	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2757
+	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId)
2758
+	for _, it := range manufacturerList {
2759
+		ids = append(ids, it.ID)
2760
+	}
2761
+	for _, it := range infoList {
2762
+		goodIds = append(goodIds, it.GoodId)
2763
+	}
2764
+	list, total, err := service.GetGoodNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
2765
+	if err != nil {
2766
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
2767
+		return
2768
+	}
2769
+
2770
+	this.ServeSuccessJSON(map[string]interface{}{
2771
+		"total": total,
2772
+		"list":  list,
2773
+	})
2774
+}
2775
+
2776
+func (this *SelfDrugApiController) GetGoodWarehouseOutInfoByIdList() {
2777
+
2778
+	good_id, _ := this.GetInt64("good_id")
2779
+	limit, _ := this.GetInt64("limit")
2780
+	page, _ := this.GetInt64("page")
2781
+	start_time := this.GetString("start_first_time")
2782
+	end_time := this.GetString("end_first_time")
2783
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2784
+	timeLayout := "2006-01-02"
2785
+	loc, _ := time.LoadLocation("Local")
2786
+	var startTime int64
2787
+	if len(start_time) > 0 {
2788
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2789
+		if err != nil {
2790
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2791
+			return
2792
+		}
2793
+		startTime = theTime.Unix()
2794
+	}
2795
+	var endTime int64
2796
+	if len(end_time) > 0 {
2797
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2798
+		if err != nil {
2799
+			utils.ErrorLog(err.Error())
2800
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2801
+			return
2802
+		}
2803
+		endTime = theTime.Unix()
2804
+	}
2805
+	list, total, err := service.GetGoodWarehouseOutInfoByIdList(good_id, limit, page, orgId, startTime, endTime)
2806
+	if err != nil {
2807
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查寻出库信息失败")
2808
+		return
2809
+	}
2810
+
2811
+	this.ServeSuccessJSON(map[string]interface{}{
2812
+		"total": total,
2813
+		"list":  list,
2814
+	})
2815
+}
2816
+
2817
+func (this *SelfDrugApiController) GetGoodPatientList() {
2818
+
2819
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2820
+	keyword := this.GetString("keyword")
2821
+	list, err := service.GetGoodPatientList(orgId, keyword)
2822
+	if err != nil {
2823
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
2824
+		return
2825
+	}
2826
+
2827
+	this.ServeSuccessJSON(map[string]interface{}{
2828
+		"list": list,
2829
+	})
2830
+}
2831
+
2832
+func (this *SelfDrugApiController) GetWarehouseOutDetailByPatientId() {
2833
+
2834
+	patient_id, _ := this.GetInt64("patient_id")
2835
+	start_time := this.GetString("start_first_time")
2836
+	end_time := this.GetString("end_first_time")
2837
+	limit, _ := this.GetInt64("limit")
2838
+	page, _ := this.GetInt64("page")
2839
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2840
+	timeLayout := "2006-01-02"
2841
+	loc, _ := time.LoadLocation("Local")
2842
+	var startTime int64
2843
+	if len(start_time) > 0 {
2844
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2845
+		if err != nil {
2846
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2847
+			return
2848
+		}
2849
+		startTime = theTime.Unix()
2850
+	}
2851
+	var endTime int64
2852
+	if len(end_time) > 0 {
2853
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2854
+		if err != nil {
2855
+			utils.ErrorLog(err.Error())
2856
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2857
+			return
2858
+		}
2859
+		endTime = theTime.Unix()
2860
+	}
2861
+	list, total, err := service.GetWarehouseOutDetailByPatientId(orgId, patient_id, startTime, endTime, limit, page)
2862
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2863
+	if err != nil {
2864
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
2865
+		return
2866
+	}
2867
+
2868
+	this.ServeSuccessJSON(map[string]interface{}{
2869
+		"list":             list,
2870
+		"manufacturerList": manufacturerList,
2871
+		"total":            total,
2872
+	})
2873
+}
2874
+
2875
+func (this *SelfDrugApiController) GetGoodExpiryDateQuery() {
2876
+
2877
+	storehouse_id, _ := this.GetInt64("storehouse_id")
2878
+	expiry_type, _ := this.GetInt64("expiry_type")
2879
+	keyword := this.GetString("keyword")
2880
+	page, _ := this.GetInt64("page")
2881
+	limit, _ := this.GetInt64("limit")
2882
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2883
+	start_time := this.GetString("start_time")
2884
+	timeLayout := "2006-01-02"
2885
+	loc, _ := time.LoadLocation("Local")
2886
+	var endTime int64
2887
+	if len(start_time) > 0 {
2888
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2889
+		if err != nil {
2890
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2891
+			return
2892
+		}
2893
+		endTime = theTime.Unix()
2894
+	}
2895
+	recordDateStr := time.Now().Format("2006-01-02")
2896
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
2897
+	fmt.Scan("parseDateErr", parseDateErr)
2898
+	nowtime := recordDate.Unix()
2899
+
2900
+	var ids []int64
2901
+	var goodIds []int64
2902
+
2903
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2904
+	for _, it := range manufacturers {
2905
+		ids = append(ids, it.ID)
2906
+	}
2907
+	goodList, _ := service.GetGoodNameByword(orgId, keyword)
2908
+	for _, it := range goodList {
2909
+		goodIds = append(goodIds, it.ID)
2910
+	}
2911
+	list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
2912
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2913
+
2914
+	if err != nil {
2915
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
2916
+		return
2917
+	}
2918
+
2919
+	this.ServeSuccessJSON(map[string]interface{}{
2920
+		"list":             list,
2921
+		"manufacturerList": manufacturerList,
2922
+		"total":            total,
2923
+		"nowtime":          nowtime,
2924
+	})
2925
+}
2926
+
2927
+func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
2928
+
2929
+	good_type, _ := this.GetInt64("good_type")
2930
+
2931
+	keyword := this.GetString("keyword")
2932
+
2933
+	page, _ := this.GetInt64("page")
2934
+
2935
+	limit, _ := this.GetInt64("limit")
2936
+
2937
+	start_time := this.GetString("start_first_time")
2938
+	end_time := this.GetString("end_first_time")
2939
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2940
+	timeLayout := "2006-01-02"
2941
+	loc, _ := time.LoadLocation("Local")
2942
+	var startTime int64
2943
+	if len(start_time) > 0 {
2944
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2945
+		if err != nil {
2946
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2947
+			return
2948
+		}
2949
+		startTime = theTime.Unix()
2950
+	}
2951
+	var endTime int64
2952
+	if len(end_time) > 0 {
2953
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2954
+		if err != nil {
2955
+			utils.ErrorLog(err.Error())
2956
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2957
+			return
2958
+		}
2959
+		endTime = theTime.Unix()
2960
+	}
2961
+	var ids []int64
2962
+	var infoIds []int64
2963
+
2964
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2965
+	for _, it := range manufacturers {
2966
+		ids = append(ids, it.ID)
2967
+	}
2968
+	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId)
2969
+	for _, it := range infoList {
2970
+		infoIds = append(infoIds, it.GoodId)
2971
+	}
2972
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2973
+	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
2974
+	fmt.Println("list233323233233232332233232", list)
2975
+	if err != nil {
2976
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
2977
+		return
2978
+	}
2979
+
2980
+	this.ServeSuccessJSON(map[string]interface{}{
2981
+		"list":             list,
2982
+		"manufacturerList": manufacturerList,
2983
+		"total":            total,
2984
+	})
2985
+}
2986
+
2987
+func (this *SelfDrugApiController) GetDrugWarehouseOutDetailByPatientId() {
2988
+
2989
+	patient_id, _ := this.GetInt64("patient_id")
2990
+	start_time := this.GetString("start_time")
2991
+	end_time := this.GetString("end_time")
2992
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2993
+	limit, _ := this.GetInt64("limit")
2994
+	page, _ := this.GetInt64("page")
2995
+	timeLayout := "2006-01-02"
2996
+	loc, _ := time.LoadLocation("Local")
2997
+	var startTime int64
2998
+	if len(start_time) > 0 {
2999
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3000
+		if err != nil {
3001
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3002
+			return
3003
+		}
3004
+		startTime = theTime.Unix()
3005
+	}
3006
+	var endTime int64
3007
+	if len(end_time) > 0 {
3008
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3009
+		if err != nil {
3010
+			utils.ErrorLog(err.Error())
3011
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3012
+			return
3013
+		}
3014
+		endTime = theTime.Unix()
3015
+	}
3016
+
3017
+	list, total, _ := service.GetDrugWarehouseOutDetailByPatientId(patient_id, orgId, startTime, endTime, page, limit)
3018
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3019
+	this.ServeSuccessJSON(map[string]interface{}{
3020
+		"list":             list,
3021
+		"total":            total,
3022
+		"manufacturerList": manufacturerList,
3023
+	})
3024
+}
3025
+
3026
+func (this *SelfDrugApiController) GetDrugExpiryDateQuery() {
3027
+	storehouse_id, _ := this.GetInt64("storehouse_id")
3028
+	expiry_type, _ := this.GetInt64("expiry_type")
3029
+	keyword := this.GetString("keyword")
3030
+	page, _ := this.GetInt64("page")
3031
+	limit, _ := this.GetInt64("limit")
3032
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3033
+	start_time := this.GetString("start_time")
3034
+	timeLayout := "2006-01-02"
3035
+	loc, _ := time.LoadLocation("Local")
3036
+	var endTime int64
3037
+	if len(start_time) > 0 {
3038
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3039
+		if err != nil {
3040
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3041
+			return
3042
+		}
3043
+		endTime = theTime.Unix()
3044
+	}
3045
+	recordDateStr := time.Now().Format("2006-01-02")
3046
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3047
+	fmt.Scan("parseDateErr", parseDateErr)
3048
+	nowtime := recordDate.Unix()
3049
+
3050
+	var ids []int64
3051
+	var goodIds []int64
3052
+
3053
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3054
+	for _, it := range manufacturers {
3055
+		ids = append(ids, it.ID)
3056
+	}
3057
+	drugList, _ := service.GetDrugNameByword(orgId, keyword)
3058
+	for _, it := range drugList {
3059
+		goodIds = append(goodIds, it.ID)
3060
+	}
3061
+	list, total, err := service.GetDrugExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
3062
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3063
+	var drugType = "药品类型"
3064
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3065
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3066
+	if err != nil {
3067
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3068
+		return
3069
+	}
3070
+
3071
+	this.ServeSuccessJSON(map[string]interface{}{
3072
+		"list":             list,
3073
+		"manufacturerList": manufacturerList,
3074
+		"total":            total,
3075
+		"nowtime":          nowtime,
3076
+		"drugTypeList":     drugTypeList,
3077
+	})
3078
+}

+ 9 - 14
controllers/stock_in_api_controller.go View File

@@ -152,7 +152,6 @@ func StockManagerApiRegistRouters() {
152 152
 func (c *StockManagerApiController) CreateWarehouse() {
153 153
 
154 154
 	warehousing_time := c.GetString("warehousing_time")
155
-	fmt.Println("warehousing_time我的", warehousing_time)
156 155
 	types, _ := c.GetInt64("type", 0)
157 156
 	storehouse_id, _ := c.GetInt64("storehouse_id")
158 157
 	warehousing_info_id, _ := c.GetInt64("warehousing_info_id")
@@ -7016,10 +7015,13 @@ func (this *StockManagerApiController) ReturnCheckWarehouseOut() {
7016 7015
 func (this *StockManagerApiController) CheckWarehouseInfo() {
7017 7016
 
7018 7017
 	warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
7018
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7019
+	//查询默认仓库
7020
+	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7019 7021
 	//更改审核状态
7020 7022
 	err := service.UpdateCheckWarehouseInfo(warehousing_info_id)
7021 7023
 	if err == nil {
7022
-		orgId := this.GetAdminUserInfo().CurrentOrgId
7024
+
7023 7025
 		list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7024 7026
 		Creator := this.GetAdminUserInfo().AdminUser.Id
7025 7027
 		for _, item := range list {
@@ -7059,20 +7061,19 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7059 7061
 				AdminUserId:             0,
7060 7062
 				BuyPrice:                item.Price,
7061 7063
 				StockCount:              "",
7064
+				BatchNumberCount:        item.WarehousingCount,
7062 7065
 			}
7063 7066
 			//创建出库流水
7064 7067
 			service.CreateStockFlowOne(stockFlow)
7065
-
7066 7068
 			orgId := this.GetAdminUserInfo().CurrentOrgId
7067
-			//查询默认仓库
7068
-			storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7069
+			//查询该耗材剩余库存库
7069 7070
 			stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7070 7071
 			var total_count int64
7071 7072
 			for _, it := range stockList {
7072 7073
 				total_count += it.StockCount
7073 7074
 			}
7074 7075
 			//基础库插入数据
7075
-			service.UpdateGoodInfoSumCount(item.GoodId, total_count, orgId)
7076
+			service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId)
7076 7077
 		}
7077 7078
 	}
7078 7079
 
@@ -7090,11 +7091,6 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
7090 7091
 	//查询入库数据
7091 7092
 	list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7092 7093
 	for _, item := range list {
7093
-		//nightInfo, _ := service.GetWarehouseInfoByIdNight(item.ID)
7094
-		//if nightInfo.WarehousingCount != nightInfo.StockCount {
7095
-		//   this.ServeFailJSONWithSGJErrorCode(enums.ErrorCheckGoodParamWrong)
7096
-		//   return
7097
-		//}
7098 7094
 		//查询该耗材 是否有出库数据
7099 7095
 		outlist, _ := service.GetWarehouseOutByWarehouseInfoId(item.ID, item.GoodId, item.OrgId)
7100 7096
 
@@ -7112,14 +7108,13 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
7112 7108
 
7113 7109
 		//查询默认仓库
7114 7110
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7111
+		//查询该耗材剩余多少库存
7115 7112
 		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7116 7113
 		var sum_count int64
7117
-		var sum_in_count int64
7118 7114
 		for _, it := range stockList {
7119 7115
 			sum_count += it.StockCount
7120
-			sum_in_count += it.WarehousingCount
7121 7116
 		}
7122
-		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, orgId)
7117
+		service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId)
7123 7118
 	}
7124 7119
 	err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7125 7120
 	if err == nil {

+ 1 - 1
main.go View File

@@ -11,7 +11,7 @@ func init() {
11 11
 }
12 12
 
13 13
 func main() {
14
-	//service.BeginAutoCreateWeekSchedulesJob()
14
+	service.BeginAutoCreateWeekSchedulesJob()
15 15
 	//service.BeginAutoCreateWeekDisinfectionJob()
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()

+ 3 - 1
models/dialysis.go View File

@@ -397,6 +397,7 @@ type DoctorAdvices struct {
397 397
 	AnticoagulantZongliang     float64         `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
398 398
 	DialysisDialyszers         string          `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
399 399
 	DialysisIrrigation         string          `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
400
+	PushStartTime              int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
400 401
 }
401 402
 
402 403
 type DoctorAdvice struct {
@@ -449,7 +450,8 @@ type DoctorAdvice struct {
449 450
 	Way                   int64           `gorm:"column:way" json:"way" form:"way"`
450 451
 	DrugId                int64           `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
451 452
 	DrugNameId            int64           `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
452
-	IsMedicine			  int64			  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
453
+	IsMedicine            int64           `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
454
+	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
453 455
 }
454 456
 
455 457
 func (DoctorAdvice) TableName() string {

+ 1 - 0
models/good_models.go View File

@@ -90,6 +90,7 @@ type GoodInfo struct {
90 90
 	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
91 91
 	SumInCount                  int64                `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
92 92
 	WarehousingInfo             []*WarehousingInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
93
+	WarehouseOutInfo            []*WarehouseOutInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_out_info"`
93 94
 }
94 95
 
95 96
 func (GoodInfo) TableName() string {

+ 2 - 0
models/patient_models.go View File

@@ -191,6 +191,7 @@ type Patients struct {
191 191
 	ContagionIds             []int64 `gorm:"-"`
192 192
 	DryWeight                float64 `gorm:"-"`
193 193
 	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
194
+	TreatmentPlan            string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
194 195
 }
195 196
 
196 197
 func (Patients) TableName() string {
@@ -746,6 +747,7 @@ type XtPatientsNew struct {
746 747
 	OutReason                    string  `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
747 748
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
748 749
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
750
+	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
749 751
 }
750 752
 
751 753
 func (XtPatientsNew) TableName() string {

+ 74 - 0
models/self_drug_models.go View File

@@ -980,3 +980,77 @@ type PatientDrugWarehouseInfo struct {
980 980
 	Manufacturer   int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
981 981
 	Dealer         int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
982 982
 }
983
+
984
+type NewGoodInformation struct {
985
+	ID                          int64               `gorm:"column:id" json:"id" form:"id"`
986
+	GoodCode                    string              `gorm:"column:good_code" json:"good_code" form:"good_code"`
987
+	SpecificationName           string              `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
988
+	GoodTypeId                  int64               `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
989
+	GoodUnit                    int64               `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
990
+	BuyPrice                    float64             `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
991
+	SellPrice                   float64             `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
992
+	Remark                      string              `gorm:"column:remark" json:"remark" form:"remark"`
993
+	Ctime                       int64               `gorm:"column:ctime" json:"ctime" form:"ctime"`
994
+	Mtime                       int64               `gorm:"column:mtime" json:"mtime" form:"mtime"`
995
+	Manufacturer                int64               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
996
+	Dealer                      int64               `gorm:"column:dealer" json:"dealer" form:"dealer"`
997
+	ExpiryDateWarnDayCount      int64               `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
998
+	StockWarnCount              int64               `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
999
+	IsReuse                     int64               `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
1000
+	Status                      int64               `gorm:"column:status" json:"status" form:"status"`
1001
+	FilmArea                    string              `gorm:"column:film_area" json:"film_area" form:"film_area"`
1002
+	IsUse                       int64               `gorm:"column:is_use" json:"is_use" form:"is_use"`
1003
+	FilmMaterialQuality         string              `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
1004
+	OrgId                       int64               `gorm:"column:org_id" json:"org_id" form:"org_id"`
1005
+	Modifier                    int64               `gorm:"column:modifier" json:"modifier" form:"modifier"`
1006
+	Creater                     int64               `gorm:"column:creater" json:"creater" form:"creater"`
1007
+	GoodName                    string              `gorm:"column:good_name" json:"good_name" form:"good_name"`
1008
+	Pinyin                      string              `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1009
+	Wubi                        string              `gorm:"column:wubi" json:"wubi" form:"wubi"`
1010
+	GoodKind                    int64               `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
1011
+	MedicalInsuranceLevel       int64               `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
1012
+	RetailPrice                 float64             `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1013
+	MedicalInsuranceNumber      string              `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
1014
+	IsSpecialDiseases           int64               `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
1015
+	IsRecord                    int64               `gorm:"column:is_record" json:"is_record" form:"is_record"`
1016
+	StatisticsCategory          int64               `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
1017
+	GoodStatus                  string              `gorm:"column:good_status" json:"good_status" form:"good_status"`
1018
+	DefaultCount                int64               `gorm:"column:default_count" json:"default_count" form:"default_count"`
1019
+	IsDefault                   int64               `gorm:"column:is_default" json:"is_default" form:"is_default"`
1020
+	IsChargeUse                 int64               `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
1021
+	IsChargePredict             int64               `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
1022
+	IsStatisticsWork            int64               `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
1023
+	Sign                        int64               `gorm:"column:sign" json:"sign" form:"sign"`
1024
+	Sort                        int64               `gorm:"column:sort" json:"sort" form:"sort"`
1025
+	IsDoctorUse                 int64               `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
1026
+	Agent                       string              `gorm:"column:agent" json:"agent" form:"agent"`
1027
+	GoodNumber                  string              `gorm:"column:good_number" json:"good_number" form:"good_number"`
1028
+	CommdityCode                string              `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1029
+	SocialSecurityDirectoryCode string              `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
1030
+	ProductionType              string              `gorm:"column:production_type" json:"production_type" form:"production_type"`
1031
+	SpecialMedical              string              `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
1032
+	IsMark                      int64               `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
1033
+	Total                       float64             `gorm:"column:total" json:"total" form:"total"`
1034
+	MinNumber                   int64               `gorm:"column:min_number" json:"min_number" form:"min_number"`
1035
+	PackingUnit                 string              `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1036
+	PackingPrice                float64             `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1037
+	DefaultCountUnit            string              `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
1038
+	MinUnit                     string              `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
1039
+	RegisterNumber              string              `gorm:"column:register_number" json:"register_number" form:"register_number"`
1040
+	ProvincesCode               string              `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
1041
+	IsUser                      int64               `gorm:"column:is_user" json:"is_user" form:"is_user"`
1042
+	Number                      string              `gorm:"column:number" json:"number" form:"number"`
1043
+	IsWarehouse                 string              `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
1044
+	BatchRetaiPrice             float64             `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
1045
+	SumCount                    int64               `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
1046
+	SumInCount                  int64               `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
1047
+	ManufacturerName            string              `gorm:"column:manufacturer_name" json:"manufacturer_name" form:"manufacturer_name"`
1048
+	StWarehousingInfo           []*WarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
1049
+	CancelStockInfo             []*CancelStockInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
1050
+	WarehousingInfo             []*WarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
1051
+	WarehouseOutInfo            []*WarehouseOutInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_out_info"`
1052
+}
1053
+
1054
+func (NewGoodInformation) TableName() string {
1055
+	return "xt_good_information"
1056
+}

+ 2 - 0
models/stock_models.go View File

@@ -193,6 +193,7 @@ type VmWarehousingInfo struct {
193 193
 	PackingPrice      float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
194 194
 	StorehouseId      int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
195 195
 	IsCheck           int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
196
+	BatchNumberCount  int64       `gorm:"column:batch_number_count" json:"batch_number_count" form:"batch_number_count"`
196 197
 }
197 198
 
198 199
 type WarehouseOut struct {
@@ -633,6 +634,7 @@ type VmStockFlow struct {
633 634
 	BuyPrice                  float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
634 635
 	StockCount                string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
635 636
 	RegisterNumber            string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
637
+	BatchNumberCount          int64   `gorm:"column:batch_number_count" json:"batch_number_count" form:"batch_number_count"`
636 638
 }
637 639
 
638 640
 func (VmStockFlow) TableName() string {

+ 4 - 0
service/auto_create_week_schedules_service.go View File

@@ -19,6 +19,7 @@ func init() {
19 19
 	utils.InfoLog("开启自动排班定时任务")
20 20
 	createWeekSchedulesCronJob = cron.New()
21 21
 	spec := "0 0 0 ? * MON" // 每周一凌晨0点生成排班
22
+	//spec := "0 */1 * * * ?"
22 23
 	createWeekSchedulesCronJob.AddFunc(spec, func() {
23 24
 		AutoCreateWeekSchedules()
24 25
 	})
@@ -129,6 +130,7 @@ func AutoCreateWeekSchedules() {
129 130
 func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.Time, templateItems []*models.PatientScheduleTemplateItem, deviceNumberMap map[int64]*DeviceNumberViewModel) error {
130 131
 	if deviceNumberMap == nil {
131 132
 		deviceNumbers, getDeviceNumbersErr := GetAllValidDeviceNumbers(orgID)
133
+		//fmt.Println("getDeviceNumbersErr3232322332323232323323223232323",getDeviceNumbersErr)
132 134
 		if getDeviceNumbersErr != nil {
133 135
 			return getDeviceNumbersErr
134 136
 		}
@@ -141,6 +143,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
141 143
 	now := time.Now()
142 144
 	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&week)
143 145
 	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "mtime": now.Unix()}).Error
146
+	//fmt.Println("disableErr323232332323232233222332232332",disableErr)
144 147
 	if disableErr != nil {
145 148
 		return disableErr
146 149
 	}
@@ -173,6 +176,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
173 176
 
174 177
 		sql := fmt.Sprintf("INSERT INTO xt_schedule (user_org_id, partition_id, bed_id, patient_id, schedule_date, schedule_week, schedule_type, mode_id, status, created_time, updated_time) VALUES %v;", strings.Join(valueStrs, ", "))
175 178
 		if insertErr := tx.Exec(sql, values...).Error; insertErr != nil {
179
+			//fmt.Println("insertErr232332233223332232323222222www",insertErr)
176 180
 			return insertErr
177 181
 		}
178 182
 	}

+ 37 - 12
service/dialysis_service.go View File

@@ -350,16 +350,38 @@ func ExceDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) err
350 350
 	return err
351 351
 }
352 352
 
353
+func ExecBatchDoctorAdvice(patient_id int64, orgid int64, ids []string, creater int64) error {
354
+
355
+	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND   user_org_id = ? and id in(?) AND status = 1 ", patient_id, orgid, ids).Updates(map[string]interface{}{"execution_time": time.Now().Unix(), "execution_staff": creater, "execution_state": 1}).Error
356
+	return err
357
+}
358
+
353 359
 func ExceHidDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
354 360
 	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
355 361
 	return err
356 362
 }
357 363
 
364
+func ExceHisBatchDotorAdvice(patientid int64, orgid int64, ids []string, creater int64) error {
365
+
366
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND user_org_id = ? and id in(?) AND status = 1 ", patientid, orgid, ids).Updates(map[string]interface{}{"execution_time": time.Now().Unix(), "execution_staff": creater, "execution_state": 1}).Error
367
+	return err
368
+}
369
+
358 370
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
359 371
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
360 372
 	return err
361 373
 }
362 374
 
375
+func CheckHisBathDoctorAdviceById(patientId int64, orgid int64, creater int64, ids []string) error {
376
+	err := writeDb.Model(&models.HisDoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and id in(?)", patientId, orgid, ids).Updates(map[string]interface{}{"check_time": time.Now().Unix(), "checker": creater, "check_state": 1}).Error
377
+	return err
378
+}
379
+
380
+func CheckBatchDoctorAdviceById(patientId int64, ids []string, orgid int64, creater int64) error {
381
+	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and id in(?)", patientId, orgid, ids).Updates(map[string]interface{}{"check_time": time.Now().Unix(), "checker": creater, "check_state": 1}).Error
382
+	return err
383
+}
384
+
363 385
 func CheckHisDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
364 386
 	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
365 387
 	return err
@@ -721,7 +743,7 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
721 743
 			}).
722 744
 			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, start, end).
723 745
 			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
724
-		db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
746
+		db = db.Where("xt_schedule.status = 1")
725 747
 	}
726 748
 	if schedulDate > 0 {
727 749
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
@@ -734,7 +756,7 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
734 756
 			}).
735 757
 			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, schedulDate, schedulDate).
736 758
 			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
737
-		db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
759
+		db = db.Where("xt_schedule.status = 1")
738 760
 		db = db.Where("schedule_date = ?", schedulDate)
739 761
 	}
740 762
 	if schedulType > 0 {
@@ -746,6 +768,9 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
746 768
 	if end > 0 {
747 769
 		db = db.Where("schedule_date <= ?", end)
748 770
 	}
771
+	if orgID > 0 {
772
+		db = db.Where("user_org_id = ?", orgID)
773
+	}
749 774
 	if partitionType > 0 {
750 775
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ?", partitionType)
751 776
 		// db = db.Where("partition_id = ?", partitionType)
@@ -1171,12 +1196,12 @@ func GetMaxLongAdviceGroupID(orgId int64, patient_id int64) (group int64) {
1171 1196
 	return
1172 1197
 }
1173 1198
 
1174
-func GetLastLongAdviceByGroupNo(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1175
-	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1199
+func GetLastLongAdviceByGroupNo(orgId int64, patient_id int64, advice_date int64) (advice []*models.DoctorAdvice, err error) {
1200
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0 and (push_start_time >=? or push_start_time = 0) ", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1 and (push_start_time >=? or push_start_time = 0)", advice_date).Find(&advice).Error
1176 1201
 	return
1177 1202
 }
1178 1203
 
1179
-func GetLastLongAdviceByGroupNoOne(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1204
+func GetLastLongAdviceByGroupNoOne(orgId int64, patient_id int64, advice_date int64) (advice []*models.DoctorAdvice, err error) {
1180 1205
 
1181 1206
 	redis := RedisClient()
1182 1207
 	defer redis.Close()
@@ -1184,7 +1209,7 @@ func GetLastLongAdviceByGroupNoOne(orgId int64, patient_id int64) (advice []*mod
1184 1209
 	long_advice_str, _ := redis.Get(key).Result()
1185 1210
 
1186 1211
 	if len(long_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1187
-		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1212
+		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0 and (push_start_time >=? or push_start_time = 0) ", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1 and (push_start_time >=? or push_start_time = 0) ", advice_date).Find(&advice).Error
1188 1213
 		if err != nil {
1189 1214
 			if err == gorm.ErrRecordNotFound {
1190 1215
 				return nil, nil
@@ -1213,16 +1238,16 @@ func GetLastLongAdviceByGroupNoOne(orgId int64, patient_id int64) (advice []*mod
1213 1238
 			return advice, nil
1214 1239
 		}
1215 1240
 	}
1216
-	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1241
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0 and (push_start_time >=? or push_start_time = 0) ", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1 and (push_start_time >=? or push_start_time = 0) ", advice_date).Find(&advice).Error
1217 1242
 	return
1218 1243
 }
1219 1244
 
1220
-func GetLastLongAdviceByGroupNoThree(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1221
-	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1245
+func GetLastLongAdviceByGroupNoThree(orgId int64, patient_id int64, advice_date int64) (advice []*models.DoctorAdvice, err error) {
1246
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 and (push_start_time>=? or push_start_time = 0) ", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1 and (push_start_time>=? or push_start_time = 0) ", advice_date).Find(&advice).Error
1222 1247
 	return
1223 1248
 }
1224 1249
 
1225
-func GetLastLongAdviceByGroupNoFour(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1250
+func GetLastLongAdviceByGroupNoFour(orgId int64, patient_id int64, advice_date int64) (advice []*models.DoctorAdvice, err error) {
1226 1251
 	//err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1227 1252
 	//return
1228 1253
 
@@ -1232,7 +1257,7 @@ func GetLastLongAdviceByGroupNoFour(orgId int64, patient_id int64) (advice []*mo
1232 1257
 	long_advice_str, _ := redis.Get(key).Result()
1233 1258
 
1234 1259
 	if len(long_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1235
-		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1260
+		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 and  (push_start_time >=? or push_start_time = 0)", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1  and  (push_start_time >=? or push_start_time = 0)", advice_date).Find(&advice).Error
1236 1261
 		if err != nil {
1237 1262
 			if err == gorm.ErrRecordNotFound {
1238 1263
 				return nil, nil
@@ -1261,7 +1286,7 @@ func GetLastLongAdviceByGroupNoFour(orgId int64, patient_id int64) (advice []*mo
1261 1286
 			return advice, nil
1262 1287
 		}
1263 1288
 	}
1264
-	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1289
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0  and  (push_start_time >=? or push_start_time = 0)", orgId, patient_id, advice_date).Preload("ChildDoctorAdvice", "status = 1  and  (push_start_time >=? or push_start_time = 0)", advice_date).Find(&advice).Error
1265 1290
 	return
1266 1291
 }
1267 1292
 

+ 11 - 0
service/doctor_advice_service.go View File

@@ -480,3 +480,14 @@ func GetDict(orgid int64) (drugways []*models.DrugwayDic, total int64, err error
480 480
 	err = readDb.Model(&models.DrugwayDic{}).Where("(org_id =? or org_id = 0) and status=1", orgid).Count(&total).Order("id desc").Find(&drugways).Error
481 481
 	return
482 482
 }
483
+
484
+func GetBloodDoctorAdvice(record_time int64, org_id int64, patient_id int64) (advice []*DoctorAdvice, err error) {
485
+
486
+	err = XTReadDB().Where("advice_date = ? and user_org_id = ? and patient_id = ? and status = 1", record_time, org_id, patient_id).Order("created_time asc").Find(&advice).Error
487
+	return advice, err
488
+}
489
+
490
+func GetHisDoctorAdvice(record_time int64, org_id int64, patient_id int64) (advice []*models.HisDoctorAdvice, err error) {
491
+	err = XTReadDB().Where("advice_date = ? and user_org_id = ? and patient_id = ? and status = 1", record_time, org_id, patient_id).Order("created_time asc").Find(&advice).Error
492
+	return advice, err
493
+}

+ 1 - 1
service/his_hospital_service.go View File

@@ -342,7 +342,7 @@ func GetHisHospitalUnUploadPrescriptionDetailPatientList(org_id int64, record_da
342 342
 	db = db.Joins("join xt_schedule as sch ON sch.patient_id = his_hospital_check_record.patient_id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ?", org_id, record_date)
343 343
 
344 344
 	if sch_type > 0 {
345
-		db = db.Joins("join xt_schedule as sch ON sch.patient_id = his_hospital_check_record.patient_id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? AND sch.schedule_type = ? ", org_id, record_date, sch_type)
345
+		db = db.Joins("join xt_schedule as schs ON schs.patient_id = his_hospital_check_record.patient_id AND schs.status = 1 AND schs.user_org_id = ? AND schs.schedule_date = ? AND schs.schedule_type = ? ", org_id, record_date, sch_type)
346 346
 	}
347 347
 	db = db.Where("his_hospital_check_record.user_org_id = ? AND his_hospital_check_record.status = 1 AND his_hospital_check_record.in_hospital_status = 1 AND his_hospital_check_record.out_hospital_status = 0", org_id)
348 348
 	err = db.Group("number").Find(&patients).Error

+ 1 - 1
service/his_service.go View File

@@ -1489,7 +1489,7 @@ func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, pat
1489 1489
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1490 1490
 					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
1491 1491
 				})
1492
-		}).Find(&advice).Error
1492
+		}).Order("record_date desc").Find(&advice).Error
1493 1493
 
1494 1494
 	return
1495 1495
 }

+ 5 - 5
service/mobile_dialysis_service.go View File

@@ -814,7 +814,7 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
814 814
 	defer redis.Close()
815 815
 
816 816
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
817
-
817
+	redis.Set(key, "", time.Second)
818 818
 	dialysis_order_str, _ := redis.Get(key).Result()
819 819
 	if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
820 820
 		err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
@@ -2742,10 +2742,10 @@ func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64
2742 2742
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2743 2743
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2744 2744
 		Preload("DialysisBeforePrepare", func(db *gorm.DB) *gorm.DB {
2745
-			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ?  AND count > 0 ", orgID, scheduleDate)
2745
+			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? and find_in_set('停用',good_status) = 0", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Where("status = 1 AND user_org_id = ? AND record_date = ?  AND count > 0 ", orgID, scheduleDate)
2746 2746
 		}).
2747 2747
 		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
2748
-			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ?", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND count > 0 AND record_time >= ? AND record_time <= ?  ", orgID, scheduleDate, end_time).Group("patient_id,good_id")
2748
+			return db.Preload("VMGoodInfo", "status = 1 AND org_id = ? and find_in_set('停用',good_status) = 0", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Where("status = 1 AND org_id = ? AND count > 0 AND record_time >= ? AND record_time <= ?  ", orgID, scheduleDate, end_time).Group("patient_id,good_id")
2749 2749
 		}).Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
2750 2750
 	if scheduleDate != 0 {
2751 2751
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -2775,7 +2775,7 @@ func GetLastDialysisGoods(patient_id int64, orgID int64, record_time int64) (goo
2775 2775
 	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
2776 2776
 	if len(Id) > 0 {
2777 2777
 
2778
-		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
2778
+		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? and find_in_set('停用',good_status) = 0", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
2779 2779
 	}
2780 2780
 	return
2781 2781
 }
@@ -2784,7 +2784,7 @@ func GetLastDialysisBeforePrepare(patient_id int64, orgID int64, record_time int
2784 2784
 	var Id []*DialysisGoodsDate
2785 2785
 	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ? AND count > 0", patient_id, orgID, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
2786 2786
 	if len(Id) > 0 {
2787
-		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordDate).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Find(&goodUser).Error
2787
+		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordDate).Preload("VMGoodInfo", "status = 1 AND org_id = ? and find_in_set('停用',good_status) = 0", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Find(&goodUser).Error
2788 2788
 	}
2789 2789
 	return
2790 2790
 }

+ 22 - 2
service/patient_service.go View File

@@ -1118,11 +1118,31 @@ func FindDoctorAdvice(orgID, id int64) (advice models.DoctorAdvice, err error) {
1118 1118
 	return
1119 1119
 }
1120 1120
 
1121
+func FindDoctorAdviceOne(orgID, patient_id int64) (advice models.DoctorAdvice, err error) {
1122
+	err = readDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id=? and status = 1", patient_id, orgID).First(&advice).Error
1123
+	return
1124
+}
1125
+
1126
+func FindDoctorAdviceTwo(ids []string, orgID int64) (advice []*models.DoctorAdvice, err error) {
1127
+	err = readDb.Model(&models.DoctorAdvice{}).Where("id in(?) and user_org_id=? and status = 1", ids, orgID).First(&advice).Error
1128
+	return
1129
+}
1130
+
1121 1131
 func FindHisDoctorAdvice(orgID, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1122 1132
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
1123 1133
 	return
1124 1134
 }
1125 1135
 
1136
+func FindHisDoctorAdviceTwo(ids []string, orgID int64) (advice []*models.HisDoctorAdviceInfo, err error) {
1137
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id in(?) and user_org_id=? and status = 1", ids, orgID).First(&advice).Error
1138
+	return
1139
+}
1140
+
1141
+func FindHisDoctorAdviceOne(orgID, patient_id int64) (advice models.HisDoctorAdviceInfo, err error) {
1142
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? and user_org_id=? and status = 1", patient_id, orgID).First(&advice).Error
1143
+	return
1144
+}
1145
+
1126 1146
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
1127 1147
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
1128 1148
 	return
@@ -1202,7 +1222,7 @@ func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int6
1202 1222
 		db = db.Where("x.advice_name LIKE ?", likeKey)
1203 1223
 	}
1204 1224
 	offset := (page - 1) * limit
1205
-	err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&advices).Error
1225
+	err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,x.push_start_time,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&advices).Error
1206 1226
 	fmt.Print("err", err)
1207 1227
 	return
1208 1228
 }
@@ -1245,7 +1265,7 @@ func GetDoctorAdviceListTwo(orgID int64, patientID int64, advice_type int64, sto
1245 1265
 		db = db.Where("x.advice_name LIKE ?", likeKey)
1246 1266
 	}
1247 1267
 	offset := (page - 1) * limit
1248
-	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&advices).Error
1268
+	err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,x.push_start_time,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&advices).Error
1249 1269
 	fmt.Print("错误是什么", err)
1250 1270
 	return
1251 1271
 

+ 5 - 9
service/schedule_service.go View File

@@ -674,7 +674,7 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64,
674 674
 
675 675
 func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
676 676
 
677
-	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
677
+	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
678 678
 	if orgid > 0 {
679 679
 		db = db.Where("x.user_org_id = ?", orgid)
680 680
 	}
@@ -701,7 +701,7 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
701 701
 
702 702
 func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
703 703
 
704
-	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
704
+	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
705 705
 	if orgid > 0 {
706 706
 		db = db.Where("x.user_org_id = ?", orgid)
707 707
 	}
@@ -880,7 +880,7 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
880 880
 
881 881
 func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
882 882
 
883
-	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
883
+	db := readDb2.Table("xt_schedule as s ").Where("s.status =1")
884 884
 	if orgID > 0 {
885 885
 		db = db.Where("s.user_org_id = ?", orgID)
886 886
 	}
@@ -1168,17 +1168,13 @@ func GetInitPrintData(patient_id int64, scheduleDate int64, orgid int64) (list [
1168 1168
 		db = db.Where("x.user_org_id = ?", orgid)
1169 1169
 	}
1170 1170
 	if patient_id > 0 {
1171
-		db = db.Where("patient_id = ?", patient_id)
1171
+		db = db.Where("x.patient_id = ?", patient_id)
1172 1172
 	}
1173 1173
 	if scheduleDate > 0 {
1174 1174
 		db = db.Where("x.schedule_date >=? and x.schedule_date<=?", scheduleDate, scheduleDate)
1175 1175
 	}
1176
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
1177
-		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1 and patient_id = ?", patient_id)
1178
-	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ? and patient_id = ?", scheduleDate, patient_id).Preload("DialysisPrescription", "status = 1 and record_date = ? and patient_id = ?", scheduleDate, patient_id).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1176
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =? and patient_id = ?", scheduleDate, patient_id).Preload("DialysisPrescription", "status = 1 and record_date = ? and patient_id = ?", scheduleDate, patient_id).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1179 1177
 		return db.Where("status =1 and patient_id = ?", patient_id).Order("id asc")
1180
-	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1181
-		return db.Where("user_org_id = ? and status = 1 and assessment_date < ? and patient_id = ?", orgid, scheduleDate, patient_id)
1182 1178
 	}).Find(&list).Error
1183 1179
 
1184 1180
 	return list, err

+ 277 - 0
service/self_drug_service.go View File

@@ -1195,3 +1195,280 @@ func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo,
1195 1195
 	err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1196 1196
 	return info, err
1197 1197
 }
1198
+
1199
+func GetManufacturerListByKeyword(orgid int64, keyword string) (list []*models.Manufacturer, err error) {
1200
+
1201
+	likeKey := "%" + keyword + "%"
1202
+	db := XTReadDB().Model(&list).Where("status = 1")
1203
+	if orgid > 0 {
1204
+		db = db.Where("org_id = ?", orgid)
1205
+	}
1206
+	if len(keyword) > 0 {
1207
+		db = db.Where("manufacturer_name like ?", likeKey)
1208
+	}
1209
+	err = db.Find(&list).Error
1210
+	return list, err
1211
+}
1212
+
1213
+func GetGoodNameByword(orgid int64, keyword string) (list []*models.GoodInfo, err error) {
1214
+	likeKey := "%" + keyword + "%"
1215
+	db := XTReadDB().Model(&list).Where("status = 1")
1216
+	if orgid > 0 {
1217
+		db = db.Where("org_id = ?", orgid)
1218
+	}
1219
+	if len(keyword) > 0 {
1220
+		db = db.Where("good_name like ?", likeKey)
1221
+	}
1222
+	err = db.Find(&list).Error
1223
+	return list, err
1224
+}
1225
+
1226
+func GetDrugNameByword(orgid int64, keyword string) (list []*models.XtBaseDrug, err error) {
1227
+	likeKey := "%" + keyword + "%"
1228
+	db := XTReadDB().Model(&list).Where("status = 1")
1229
+	if orgid > 0 {
1230
+		db = db.Where("org_id = ?", orgid)
1231
+	}
1232
+	if len(keyword) > 0 {
1233
+		db = db.Where("drug_name like ?", likeKey)
1234
+	}
1235
+	err = db.Find(&list).Error
1236
+	return list, err
1237
+}
1238
+
1239
+func GetGoodWarehouseInfoByOrgId(orgid int64) (info []*models.WarehousingInfo, err error) {
1240
+
1241
+	err = XTReadDB().Where("org_id = ? and is_check =1 and status =1", orgid).Group("good_id").Find(&info).Error
1242
+	return info, err
1243
+}
1244
+
1245
+func GetGoodNewQuery(orgId int64, storehouse_id int64, good_type int64, keyword string, page int64, limit int64, ids []int64, goodIds []int64, startime int64, endtime int64) (good []*models.NewGoodInformation, total int64, err error) {
1246
+
1247
+	offset := (page - 1) * limit
1248
+	likeKey := "%" + keyword + "%"
1249
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1 and id in(?)", goodIds)
1250
+
1251
+	if storehouse_id > 0 {
1252
+		db = db.Preload("StWarehousingInfo", "org_id = ? and status = 1 and storehouse_id = ? and is_check = 1", orgId, storehouse_id)
1253
+
1254
+	} else {
1255
+		db = db.Preload("StWarehousingInfo", "org_id = ? and status = 1 and is_check = 1", orgId)
1256
+	}
1257
+
1258
+	if len(keyword) > 0 {
1259
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
1260
+	}
1261
+
1262
+	if orgId > 0 {
1263
+		db = db.Where("x.org_id = ?", orgId)
1264
+	}
1265
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("WarehousingInfo", func(db *gorm.DB) *gorm.DB {
1266
+		if startime > 0 {
1267
+			db = db.Where("ctime>=?", startime)
1268
+		}
1269
+		if endtime > 0 {
1270
+			db = db.Where("ctime<=?", endtime)
1271
+		}
1272
+		if storehouse_id > 0 {
1273
+			db = db.Where("storehouse_id = ?", storehouse_id)
1274
+		}
1275
+		return db.Where("status = 1").Group("good_id,storehouse_id")
1276
+	}).Preload("CancelStockInfo", func(db *gorm.DB) *gorm.DB {
1277
+		if startime > 0 {
1278
+			db = db.Where("ctime>=?", startime)
1279
+		}
1280
+		if endtime > 0 {
1281
+			db = db.Where("ctime<=?", endtime)
1282
+		}
1283
+		return db.Where("status = 1")
1284
+	}).Preload("WarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1285
+		if startime > 0 {
1286
+			db = db.Where("ctime>=?", startime)
1287
+		}
1288
+		if endtime > 0 {
1289
+			db = db.Where("ctime<=?", endtime)
1290
+		}
1291
+		return db.Where("status = 1")
1292
+	}).Find(&good).Error
1293
+
1294
+	return good, total, err
1295
+}
1296
+
1297
+func GetGoodWarehouseOutInfoByIdList(good_id int64, limit int64, page int64, orgid int64, startime int64, endtime int64) (info []*models.WarehouseOutInfo, total int64, err error) {
1298
+
1299
+	db := XTReadDB().Model(&info).Where("status = 1")
1300
+	offset := (page - 1) * limit
1301
+	if good_id > 0 {
1302
+		db = db.Where("good_id = ?", good_id)
1303
+	}
1304
+	if orgid > 0 {
1305
+		db = db.Where("org_id =?", orgid)
1306
+	}
1307
+	if startime > 0 {
1308
+		db = db.Where("ctime >=?", startime)
1309
+	}
1310
+	if endtime > 0 {
1311
+		db = db.Where("ctime<=?", endtime)
1312
+	}
1313
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&info).Error
1314
+	return info, total, err
1315
+}
1316
+
1317
+func GetGoodPatientList(orgid int64, keyword string) (patient []*models.XtPatients, err error) {
1318
+
1319
+	likeKey := "%" + keyword + "%"
1320
+	if len(keyword) > 0 {
1321
+		err = XTReadDB().Where("user_org_id = ? and status = 1 and name like ?", orgid, likeKey).Find(&patient).Error
1322
+	} else {
1323
+		err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&patient).Error
1324
+	}
1325
+	return patient, err
1326
+}
1327
+
1328
+func GetWarehouseOutDetailByPatientId(orgid int64, patient_id int64, startime int64, endtime int64, limit int64, page int64) (info []*models.WarehouseOutInfo, total int64, err error) {
1329
+
1330
+	db := XTReadDB().Model(&info).Where("status = 1 and is_sys = 1")
1331
+	offset := (page - 1) * limit
1332
+	if orgid > 0 {
1333
+		db = db.Where("org_id = ?", orgid)
1334
+	}
1335
+	if patient_id > 0 {
1336
+		db = db.Where("patient_id = ?", patient_id)
1337
+	}
1338
+	if startime > 0 {
1339
+		db = db.Where("ctime>=?", startime)
1340
+	}
1341
+	if endtime > 0 {
1342
+		db = db.Where("ctime<=?", endtime)
1343
+	}
1344
+	err = db.Preload("GoodInfo", "org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Find(&info).Error
1345
+	return info, total, err
1346
+}
1347
+
1348
+func GetGoodExpiryDateQuery(storehouse_id int64, expiry_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64, startime int64, endtime int64) (info []*models.WarehousingInfo, total int64, err error) {
1349
+
1350
+	offset := (page - 1) * limit
1351
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
1352
+
1353
+	if storehouse_id > 0 {
1354
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
1355
+	}
1356
+	//已过期
1357
+	if expiry_type == 1 {
1358
+		db = db.Where("x.expiry_date < ?", startime)
1359
+	}
1360
+
1361
+	if expiry_type > 1 {
1362
+		db = db.Where("x.expiry_date > ? and x.expiry_date<=?", startime, endtime)
1363
+	}
1364
+
1365
+	if orgid > 0 {
1366
+		db = db.Where("x.org_id = ?", orgid)
1367
+	}
1368
+
1369
+	if len(keyword) > 0 {
1370
+		db = db.Where("x.manufacturer in(?) or x.good_id in(?)", ids, goodIds)
1371
+	}
1372
+
1373
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&info).Error
1374
+	return info, total, err
1375
+}
1376
+
1377
+func GetGoodPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (goodinfo []*models.GoodInfo, total int64, err error) {
1378
+
1379
+	db := XTReadDB().Model(&goodinfo).Where("status = 1")
1380
+	offset := (page - 1) * limit
1381
+	likeKey := "%" + keyword + "%"
1382
+	if good_type > 0 {
1383
+		db = db.Where("good_type_id = ?", good_type)
1384
+	}
1385
+
1386
+	if orgid > 0 {
1387
+		db = db.Where("org_id = ?", orgid)
1388
+	}
1389
+
1390
+	if len(keyword) > 0 {
1391
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
1392
+	}
1393
+	if len(infos) > 0 {
1394
+		db = db.Where("id in(?)", infos)
1395
+	}
1396
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("WarehousingInfo", func(db *gorm.DB) *gorm.DB {
1397
+		if startime > 0 {
1398
+			db = db.Where("ctime>=?", startime)
1399
+		}
1400
+		if endtime > 0 {
1401
+			db = db.Where("ctime<=?", endtime)
1402
+		}
1403
+		return db.Where("status = 1").Group("good_id,storehouse_id")
1404
+	}).Preload("CancelStockInfo", func(db *gorm.DB) *gorm.DB {
1405
+		if startime > 0 {
1406
+			db = db.Where("ctime>=?", startime)
1407
+		}
1408
+		if endtime > 0 {
1409
+			db = db.Where("ctime<=?", endtime)
1410
+		}
1411
+		return db.Where("status = 1")
1412
+	}).Preload("WarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1413
+		if startime > 0 {
1414
+			db = db.Where("ctime>=?", startime)
1415
+		}
1416
+		if endtime > 0 {
1417
+			db = db.Where("ctime<=?", endtime)
1418
+		}
1419
+		return db.Where("status = 1")
1420
+	}).Find(&goodinfo).Error
1421
+
1422
+	return goodinfo, total, err
1423
+}
1424
+
1425
+func GetDrugWarehouseOutDetailByPatientId(patient_id int64, orgid int64, startime int64, endtime int64, page int64, limit int64) (info []*models.DrugWarehouseOutInfo, total int64, err error) {
1426
+	fmt.Println("startime232233232332322222wo", startime)
1427
+	fmt.Println("endtime232233232332322222wo", endtime)
1428
+	db := XTReadDB().Model(&info).Where("status = 1")
1429
+	offset := (page - 1) * limit
1430
+	if patient_id > 0 {
1431
+		db = db.Where("patient_id = ?", patient_id)
1432
+	}
1433
+	if orgid > 0 {
1434
+		db = db.Where("org_id = ?", orgid)
1435
+	}
1436
+	if startime > 0 {
1437
+		db = db.Where("sys_record_time >= ?", startime)
1438
+	}
1439
+	if endtime > 0 {
1440
+		db = db.Where("sys_record_time <= ?", endtime)
1441
+	}
1442
+
1443
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid).Find(&info).Error
1444
+	return
1445
+}
1446
+
1447
+func GetDrugExpiryDateQuery(storehouse_id int64, expiry_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64, startime int64, endtime int64) (info []*models.XtDrugWarehouseInfo, total int64, err error) {
1448
+
1449
+	offset := (page - 1) * limit
1450
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
1451
+
1452
+	if storehouse_id > 0 {
1453
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
1454
+	}
1455
+	//已过期
1456
+	if expiry_type == 1 {
1457
+		db = db.Where("x.expiry_date < ?", startime)
1458
+	}
1459
+
1460
+	if expiry_type > 1 {
1461
+		db = db.Where("x.expiry_date > ? and x.expiry_date<=?", startime, endtime)
1462
+	}
1463
+
1464
+	if orgid > 0 {
1465
+		db = db.Where("x.org_id = ?", orgid)
1466
+	}
1467
+
1468
+	if len(keyword) > 0 {
1469
+		db = db.Where("x.manufacturer in(?) or x.drug_id in(?)", ids, goodIds)
1470
+	}
1471
+
1472
+	err = db.Count(&total).Offset(offset).Limit(limit).Preload("XtBaseDrug", "org_id = ? and status = 1", orgid).Find(&info).Error
1473
+	return info, total, err
1474
+}

+ 10 - 3
service/stock_service.go View File

@@ -386,7 +386,7 @@ func FindAllGoodTypeOne(org_id int64) (goodType []*models.GoodsType, err error)
386 386
 }
387 387
 
388 388
 func FindAllGoodInfo(org_id int64) (goodInfo []*models.GoodInfo, err error) {
389
-	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 and is_warehouse = 1", org_id).Find(&goodInfo).Error
389
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 and is_warehouse = 1  and find_in_set('停用',good_status) = 0", org_id).Find(&goodInfo).Error
390 390
 	return goodInfo, err
391 391
 }
392 392
 
@@ -4069,7 +4069,8 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
4069 4069
 	offset := (page - 1) * limit
4070 4070
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1 and x.is_check = 1")
4071 4071
 	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4072
-	fmt.Println(table)
4072
+	tables := XTReadDB().Table("xt_stock_flow as f").Where("f.status = 1 and f.consumable_type = 1 and f.user_org_id = ?", orgid)
4073
+	fmt.Println(table, tables)
4073 4074
 	if startime > 0 {
4074 4075
 		db = db.Where("x.ctime>=?", startime)
4075 4076
 	}
@@ -4083,7 +4084,7 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
4083 4084
 	if good_id > 0 {
4084 4085
 		db = db.Where("x.good_id = ?", good_id)
4085 4086
 	}
4086
-	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Scan(&info).Error
4087
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price,f.batch_number_count").Joins("left join xt_good_information as t on t.id = x.good_id").Joins("left join xt_stock_flow as f on f.warehousing_detail_id = x.id").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Scan(&info).Error
4087 4088
 	return info, total, err
4088 4089
 
4089 4090
 }
@@ -7316,6 +7317,12 @@ func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) er
7316 7317
 	return err
7317 7318
 }
7318 7319
 
7320
+func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64) error {
7321
+
7322
+	err := XTReadDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7323
+	return err
7324
+}
7325
+
7319 7326
 func GetCancelStockInfo(id int64, orgid int64) (stock []*models.CancelStockInfo, err error) {
7320 7327
 
7321 7328
 	err = XTReadDB().Where("cancel_stock_id  = ? and org_id = ? and status  = 1", id, orgid).Preload("GoodInfo", "status = 1 and org_id = ?", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid).Find(&stock).Error

+ 12 - 10
service/warhouse_service.go View File

@@ -5054,6 +5054,7 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5054 5054
 			AdminUserId:             goods.AdminUserId,
5055 5055
 			BuyPrice:                warehouse.Price,
5056 5056
 			StockCount:              goods.StockCount,
5057
+			BatchNumberCount:        warehouse.StockCount - goods.Count,
5057 5058
 		}
5058 5059
 		//创建出库流水
5059 5060
 		CreateStockFlowOne(stockFlow)
@@ -5133,6 +5134,7 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5133 5134
 			AdminUserId:             goods.AdminUserId,
5134 5135
 			BuyPrice:                warehouse.Price,
5135 5136
 			StockCount:              goods.StockCount,
5137
+			BatchNumberCount:        0,
5136 5138
 		}
5137 5139
 		//创建出库流水
5138 5140
 		CreateStockFlowOne(stockFlow)
@@ -5140,16 +5142,16 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5140 5142
 	}
5141 5143
 
5142 5144
 	//查询该机构默认仓库
5143
-	storeConfig, _ := GetAllStoreHouseConfig(goods.OrgId)
5144
-	//查询剩余库存
5145
-	goodList, _ := GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, goods.GoodId, goods.OrgId)
5146
-	var sum_count int64
5147
-	var sum_in_count int64
5148
-	for _, item := range goodList {
5149
-		sum_count += item.StockCount
5150
-		sum_in_count += item.WarehousingCount
5151
-	}
5152
-	UpdateGoodByGoodId(goods.GoodId, sum_count, sum_in_count, goods.OrgId)
5145
+	//storeConfig, _ := GetAllStoreHouseConfig(goods.OrgId)
5146
+	////查询剩余库存
5147
+	//goodList, _ := GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, goods.GoodId, goods.OrgId)
5148
+	//var sum_count int64
5149
+	//var sum_in_count int64
5150
+	//for _, item := range goodList {
5151
+	//	sum_count += item.StockCount
5152
+	//	sum_in_count += item.WarehousingCount
5153
+	//}
5154
+	//UpdateGoodByGoodId(goods.GoodId, sum_count, sum_in_count, goods.OrgId)
5153 5155
 	// 出库完成后,要将该批次库存清零
5154 5156
 	warehouse.StockCount = 0
5155 5157
 	warehouse.Mtime = time.Now().Unix()