XMLWAN преди 4 години
родител
ревизия
df4839f8f2

+ 91 - 7
controllers/dialysis_parameter_api_controller.go Целия файл

@@ -22,6 +22,7 @@ func DialysisPrameteRoutes() {
22 22
 	beego.Router("/api/dialysis/getcollectlist", &DialysisPrameterApiController{}, "Get:GetCollectList")
23 23
 	beego.Router("/api/dialysis/getbatchcollection", &DialysisPrameterApiController{}, "Get:GetBatchCollection")
24 24
 	beego.Router("/api/dialysis/getgatherlist", &DialysisPrameterApiController{}, "Get:GetGatherList")
25
+	beego.Router("/api/dialysis/getanticoagulantcount", &DialysisPrameterApiController{}, "Get:GetAnticoagulantCount")
25 26
 }
26 27
 
27 28
 func (this *DialysisPrameterApiController) GetDialysisParameters() {
@@ -194,11 +195,12 @@ func (this *DialysisPrameterApiController) GetCollectList() {
194 195
 	start_time := this.GetString("start_time")
195 196
 	fmt.Println(start_time)
196 197
 	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
198
+	fmt.Println("startime", startime.Unix())
197 199
 	orgId := this.GetAdminUserInfo().CurrentOrgId
198 200
 	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
199 201
 	keyword := this.GetString("keyword")
200 202
 	//获取透析参数数据
201
-	schedule, err, total := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
203
+	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
202 204
 
203 205
 	//查询今日排班的病人
204 206
 	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit)
@@ -232,15 +234,76 @@ func (this *DialysisPrameterApiController) GetCollectList() {
232 234
 	//获取透析耗材数据
233 235
 	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
234 236
 
235
-	if err == nil {
237
+	//if err == nil {
238
+	// this.ServeSuccessJSON(map[string]interface{}{
239
+	//   "schedule":     schedule,
240
+	//   "total":        total,
241
+	//   "consumables":  consumables,
242
+	//   "prescription": vlist,
243
+	//   "reducelist":   clist,
244
+	// })
245
+	//}
246
+
247
+	_, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
248
+
249
+	goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
250
+
251
+	if errors == gorm.ErrRecordNotFound {
252
+
253
+		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
254
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
255
+
256
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
257
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
258
+			item.LastAutomaticReduceDetail = goodUser
259
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
260
+		}
236 261
 		this.ServeSuccessJSON(map[string]interface{}{
237
-			"schedule":     schedule,
238
-			"total":        total,
239
-			"consumables":  consumables,
240
-			"prescription": vlist,
241
-			"reducelist":   clist,
262
+			"dialysis_goods": dialysisGoods,
263
+			"good_type":      goodTypes,
264
+			"total":          total,
265
+			"schedule":       schedule,
266
+			"consumables":    consumables,
267
+			"prescription":   vlist,
268
+			"reducelist":     clist,
242 269
 		})
270
+		return
271
+
272
+	} else if err == nil {
273
+		//获取当天排班的每个患者的库存使用情况
274
+		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
275
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
276
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
277
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
278
+
279
+			fmt.Println(goodUser)
280
+			fmt.Println(lastGoodUserDetial)
281
+
282
+			item.LastAutomaticReduceDetail = goodUser
283
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
284
+		}
285
+		if err == nil {
286
+			this.ServeSuccessJSON(map[string]interface{}{
287
+				"dialysis_goods": dialysisGoods,
288
+				"good_type":      goodTypes,
289
+				"total":          total,
290
+				"schedule":       schedule,
291
+				"consumables":    consumables,
292
+				"prescription":   vlist,
293
+				"reducelist":     clist,
294
+			})
295
+			return
296
+
297
+		} else {
298
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
299
+			return
300
+		}
301
+	} else if err != nil {
302
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
303
+		return
304
+
243 305
 	}
306
+
244 307
 }
245 308
 
246 309
 func (this *DialysisPrameterApiController) GetBatchCollection() {
@@ -330,3 +393,24 @@ func (this *DialysisPrameterApiController) GetGatherList() {
330 393
 		})
331 394
 	}
332 395
 }
396
+
397
+func (this *DialysisPrameterApiController) GetAnticoagulantCount() {
398
+	timeLayout := "2006-01-02"
399
+	loc, _ := time.LoadLocation("Local")
400
+	adminUser := this.GetAdminUserInfo()
401
+	orgId := adminUser.CurrentOrgId
402
+	fmt.Println(orgId)
403
+	start_time := this.GetString("start_time")
404
+	end_time := this.GetString("end_time")
405
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
406
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
407
+	fmt.Println("开始时间2222", startime)
408
+	fmt.Println("结束时间3333", endtime)
409
+	//统计抗凝剂数据
410
+	count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
411
+	if err == nil {
412
+		this.ServeSuccessJSON(map[string]interface{}{
413
+			"count": count,
414
+		})
415
+	}
416
+}

+ 2 - 2
controllers/mobile_api_controllers/login_api_controller.go Целия файл

@@ -33,8 +33,8 @@ func (this *LoginAPIController) LoginByPwd() {
33 33
 		return
34 34
 	}
35 35
 	ip := utils.GetIP(this.Ctx.Request)
36
-	//ssoDomain := beego.AppConfig.String("sso_domain")
37
-	ssoDomain := "http://localhost:8091"
36
+	ssoDomain := beego.AppConfig.String("sso_domain")
37
+	//ssoDomain := "http://localhost:8091"
38 38
 	api := ssoDomain + "/m/login/pwd"
39 39
 	values := make(url.Values)
40 40
 	values.Set("mobile", mobile)

+ 67 - 7
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go Целия файл

@@ -153,7 +153,7 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
153 153
 	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
154 154
 	keyword := this.GetString("keyword")
155 155
 	//获取透析参数数据
156
-	schedule, err, total := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
156
+	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
157 157
 	//查询今日排班的病人
158 158
 	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit)
159 159
 	var vlist []interface{}
@@ -184,15 +184,75 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
184 184
 	}
185 185
 	//获取透析耗材数据
186 186
 	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
187
-	if err == nil {
187
+
188
+	_, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
189
+
190
+	goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
191
+
192
+	if errors == gorm.ErrRecordNotFound {
193
+
194
+		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
195
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
196
+
197
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
198
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
199
+			item.LastAutomaticReduceDetail = goodUser
200
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
201
+		}
188 202
 		this.ServeSuccessJSON(map[string]interface{}{
189
-			"schedule":     schedule,
190
-			"total":        total,
191
-			"consumables":  consumables,
192
-			"prescription": vlist,
193
-			"reducelist":   clist,
203
+			"dialysis_goods": dialysisGoods,
204
+			"good_type":      goodTypes,
205
+			"total":          total,
206
+			"schedule":       schedule,
207
+			"consumables":    consumables,
208
+			"prescription":   vlist,
209
+			"reducelist":     clist,
194 210
 		})
211
+		return
212
+
213
+	} else if err == nil {
214
+		//获取当天排班的每个患者的库存使用情况
215
+		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
216
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
217
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
218
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
219
+
220
+			fmt.Println(goodUser)
221
+			fmt.Println(lastGoodUserDetial)
222
+
223
+			item.LastAutomaticReduceDetail = goodUser
224
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
225
+		}
226
+		if err == nil {
227
+			this.ServeSuccessJSON(map[string]interface{}{
228
+				"dialysis_goods": dialysisGoods,
229
+				"good_type":      goodTypes,
230
+				"total":          total,
231
+				"schedule":       schedule,
232
+				"consumables":    consumables,
233
+				"prescription":   vlist,
234
+				"reducelist":     clist,
235
+			})
236
+			return
237
+
238
+		} else {
239
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
240
+			return
241
+		}
242
+	} else if err != nil {
243
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
244
+		return
245
+
195 246
 	}
247
+	//if err == nil {
248
+	//	this.ServeSuccessJSON(map[string]interface{}{
249
+	//		"schedule":     schedule,
250
+	//		"total":        total,
251
+	//		"consumables":  consumables,
252
+	//		"prescription": vlist,
253
+	//		"reducelist":   clist,
254
+	//	})
255
+	//}
196 256
 }
197 257
 
198 258
 func (this *DialysisParamerterApiController) GetMobileGatherList() {

+ 69 - 0
service/dialysis_parameter_service.go Целия файл

@@ -302,3 +302,72 @@ func GetMaticeReduceByPatientId(patientid int64, orgid int64, startime int64, en
302 302
 	err := XTReadDB().Model(&detail).Where("patient_id = ? and org_id = ? and record_time >=? and record_time<=? and status =1", patientid, orgid, startime, endtime).Find(&detail).Error
303 303
 	return detail, err
304 304
 }
305
+
306
+func PCGetDialysisGoodsTwo(orgID int64, scheduleDate int64, schedule_type int64, partition_id int64, page int64, limit int64, keywords string) ([]*MDialysisGoodsVM, error, int64) {
307
+	var vms []*MDialysisGoodsVM
308
+	var total int64
309
+
310
+	db := readDb.
311
+		Model(&models.Schedule{}).
312
+		Select("patient_id,mode_id").
313
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
314
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
315
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
316
+		Preload("DialysisBeforePrepare", func(db *gorm.DB) *gorm.DB {
317
+			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)
318
+		}).
319
+		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
320
+			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 record_time = ?  AND count > 0", orgID, scheduleDate)
321
+		}).Where("xt_schedule.status = 1 AND xt_schedule.user_org_id = ?", orgID)
322
+
323
+	if scheduleDate != 0 {
324
+		db = db.Where("schedule_date = ?", scheduleDate)
325
+	}
326
+	if len(keywords) != 0 {
327
+		keywords = "%" + keywords + "%"
328
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
329
+	} else {
330
+		if schedule_type != 0 {
331
+			db = db.Where("schedule_type = ?", schedule_type)
332
+		}
333
+		if partition_id != 0 {
334
+			db = db.Where("partition_id = ?", partition_id)
335
+		}
336
+
337
+		db = db.Count(&total)
338
+		offset := (page - 1) * limit
339
+
340
+		db = db.Offset(offset).Limit(limit)
341
+
342
+	}
343
+
344
+	err := db.Find(&vms).Error
345
+
346
+	return vms, err, total
347
+}
348
+
349
+func PCGetDialysisGoodsThree(orgID int64, scheduleDate int64) ([]*MDialysisGoodsVM, error) {
350
+
351
+	var vms []*MDialysisGoodsVM
352
+
353
+	db := readDb.
354
+		Model(&models.Schedule{}).
355
+		Select("patient_id,mode_id").
356
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
357
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
358
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
359
+		Preload("DialysisBeforePrepare", func(db *gorm.DB) *gorm.DB {
360
+			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)
361
+		}).
362
+		Preload("AutomaticReduceDetail", func(db *gorm.DB) *gorm.DB {
363
+			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 record_time = ?  AND count > 0", orgID, scheduleDate)
364
+		}).Where("xt_schedule.status = 1 AND xt_schedule.user_org_id = ?", orgID)
365
+
366
+	if scheduleDate != 0 {
367
+		db = db.Where("schedule_date = ?", scheduleDate)
368
+	}
369
+
370
+	err = db.Find(&vms).Error
371
+
372
+	return vms, err
373
+}