Ver código fonte

提交代码

陈少旭 7 meses atrás
pai
commit
23781d4842

+ 8 - 1
controllers/gobal_config_api_controller.go Ver arquivo

@@ -1686,6 +1686,7 @@ func (c *GobalConfigApiController) GetExportData() {
1686 1686
 	start_time := c.GetString("start_time")
1687 1687
 	end_time := c.GetString("end_time")
1688 1688
 	p_type, _ := c.GetInt64("p_type")
1689
+	ex_type, _ := c.GetInt64("sort_type")
1689 1690
 
1690 1691
 	timeLayout := "2006-01-02"
1691 1692
 	loc, _ := time.LoadLocation("Local")
@@ -1710,7 +1711,13 @@ func (c *GobalConfigApiController) GetExportData() {
1710 1711
 		endTime = theTime.Unix()
1711 1712
 	}
1712 1713
 	adminInfo := c.GetAdminUserInfo()
1713
-	order, _ := service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime, p_type)
1714
+	var order []*models.HisOrder
1715
+	if ex_type == 1 {
1716
+		order, _ = service.GetExportHisOrderList(adminInfo.CurrentOrgId, startTime, endTime, p_type)
1717
+	} else {
1718
+		order, _ = service.GetExportHisOrderListBySetlTIME(adminInfo.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", p_type)
1719
+	}
1720
+
1714 1721
 	c.ServeSuccessJSON(map[string]interface{}{
1715 1722
 		"order": order,
1716 1723
 	})

+ 29 - 0
service/gobal_config_service.go Ver arquivo

@@ -288,6 +288,35 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64,
288 288
 	return
289 289
 }
290 290
 
291
+func GetExportHisOrderListBySetlTIME(user_org_id int64, start_time string, end_time string, p_type int64) (order []*models.HisOrder, err error) {
292
+	db := readDb.Model(&models.HisOrder{})
293
+	if len(start_time) > 0 {
294
+		db = db.Where("his_order.setl_time >= ?", start_time)
295
+	}
296
+	if len(end_time) > 0 {
297
+		db = db.Where("his_order.setl_time <= ?", end_time)
298
+	}
299
+
300
+	if p_type > 0 {
301
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2 AND p_type = ? ", user_org_id, p_type)
302
+
303
+	} else {
304
+
305
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2", user_org_id)
306
+
307
+	}
308
+
309
+	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
310
+		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
311
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
312
+		Preload("HisHospitalCheckRecord", "status = 1 AND user_org_id = ? AND in_hospital_status = 1 AND out_hospital_status = 1 ", user_org_id).
313
+		Preload("HisPrescriptionInfo", func(db *gorm.DB) *gorm.DB {
314
+			return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("XtHisDepartment", "status = 1")
315
+		})
316
+	err = db.Order("setl_time asc").Find(&order).Error
317
+	return
318
+}
319
+
291 320
 func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
292 321
 
293 322
 	likeKey := "%" + keyword + "%"