test_user před 1 rokem
rodič
revize
3580df2174

+ 16 - 2
controllers/his_charge_api_controller.go Zobrazit soubor

@@ -299,7 +299,7 @@ func (c *HisChargeApiController) GetHisInspectionList() {
299 299
 	is_print, _ := c.GetInt64("is_print")
300 300
 	page, _ := c.GetInt64("page")
301 301
 	limit, _ := c.GetInt64("limit")
302
-	//tube_color, _ := c.GetInt64("tube_color")
302
+	tube_color, _ := c.GetInt64("tube_color")
303 303
 
304 304
 	adminUser := c.GetAdminUserInfo()
305 305
 
@@ -310,7 +310,21 @@ func (c *HisChargeApiController) GetHisInspectionList() {
310 310
 
311 311
 	}
312 312
 	record_time := startTime.Unix()
313
-	labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, 0)
313
+	var labels []*models.HisLabelPrintInfo
314
+	var labels_two []*models.HisLabelPrintInfo
315
+
316
+	var total int64
317
+	var total_two int64
318
+	//var err error
319
+	if tube_color == 0 {
320
+		labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
321
+	} else {
322
+		labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
323
+		labels_two, total_two, err = service.GetLabelPrintListTwo(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
324
+		total = total + total_two
325
+		labels = append(labels, labels_two...)
326
+	}
327
+
314 328
 	if err == nil {
315 329
 
316 330
 		c.ServeSuccessJSON(map[string]interface{}{

+ 25 - 1
service/his_charge_service.go Zobrazit soubor

@@ -251,7 +251,31 @@ func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time i
251 251
 		db = db.Where("patient_name Like ?", keywors)
252 252
 
253 253
 	}
254
-	err = db.Where("user_org_id = ? AND record_date = ? AND status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
254
+	if tube_color > 0 {
255
+		db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?", tube_color)
256
+		//db = db.Joins("Right join xt_his_project as pro on pro.id = his_label_print_info.project_id AND his_label_print_info.item_id = 0 and  his_label_print_info.project_id > 0 and pro.status = 1 and pro.tube_color = ?",tube_color)
257
+	}
258
+
259
+	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
260
+	return
261
+}
262
+func GetLabelPrintListTwo(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
263
+	offset := (page - 1) * limit
264
+	db := readDb.Model(&models.HisLabelPrintInfo{})
265
+	if is_print > 0 {
266
+		db = db.Where("is_print = ?", is_print)
267
+	}
268
+	if len(keywors) > 0 {
269
+		keywors = "%" + keywors + "%"
270
+		db = db.Where("patient_name Like ?", keywors)
271
+
272
+	}
273
+	if tube_color > 0 {
274
+		//db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?",tube_color)
275
+		db = db.Joins("Right join xt_his_project as pro on pro.id = his_label_print_info.project_id AND his_label_print_info.item_id = 0 and  his_label_print_info.project_id > 0 and pro.status = 1 and pro.tube_color = ?", tube_color)
276
+	}
277
+
278
+	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
255 279
 	return
256 280
 }
257 281