Browse Source

提交代码

陈少旭 1 month ago
parent
commit
17e5858005
1 changed files with 73 additions and 1 deletions
  1. 73 1
      controllers/his_export_data_controller.go

+ 73 - 1
controllers/his_export_data_controller.go View File

@@ -4,8 +4,12 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
+	"XT_New/utils"
8
+	"fmt"
7 9
 	"github.com/astaxie/beego"
8 10
 	"github.com/shopspring/decimal"
11
+	"strconv"
12
+	"strings"
9 13
 	"time"
10 14
 )
11 15
 
@@ -23,6 +27,50 @@ func HisExportDataApiRegistRouters() {
23 27
 	beego.Router("/api/export/10726/summary", &HisExportDataController{}, "Get:Get10726SummaryExportData")
24 28
 	beego.Router("/api/export/10697/summary", &HisExportDataController{}, "Get:Get10697SummaryExportData")
25 29
 
30
+	beego.Router("/api/export/10697/summary", &HisExportDataController{}, "Get:Get10697SummaryExportData")
31
+
32
+	beego.Router("/api/batch/orderlist", &HisExportDataController{}, "Get:GetBatchOrderDetail")
33
+
34
+}
35
+
36
+type Orders struct {
37
+	Order     models.HisOrder         `json:"order"`
38
+	OrderInfo []*service.HisOrderInfo `json:"order_info"`
39
+	Patient   *models.Patients        `json:"patient"`
40
+	AdminInfo models.UserAdminRole    `json:"admin_info"`
41
+}
42
+
43
+func (c *HisExportDataController) GetBatchOrderDetail() {
44
+	order_ids := c.GetString("id")
45
+
46
+	ids := strings.Split(order_ids, ",")
47
+
48
+	var oss []*Orders
49
+	for _, item := range ids {
50
+		var os Orders
51
+		new_id, _ := strconv.ParseInt(item, 10, 64)
52
+		order, _ := service.GetHisOrderByID(new_id)
53
+		if order.ID == 0 {
54
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
55
+			return
56
+		}
57
+		//record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
58
+		org_id := c.GetAdminUserInfo().CurrentOrgId
59
+		adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
60
+		patient, _ := service.GetFaPiaoPatientByID(org_id, order.PatientId)
61
+		order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
62
+		os.Order = order
63
+		os.OrderInfo = order_info
64
+		os.Patient = patient
65
+		os.AdminInfo = adminInfo
66
+		oss = append(oss, &os)
67
+	}
68
+	fmt.Println(oss)
69
+	c.ServeSuccessJSON(map[string]interface{}{
70
+		"orders": oss,
71
+	})
72
+	return
73
+
26 74
 }
27 75
 
28 76
 func (c *HisExportDataController) Get10726DetailExportData() {
@@ -47,7 +95,31 @@ func (c *HisExportDataController) Get10697SummaryExportData() {
47 95
 	start_time := c.GetString("start_time")
48 96
 	end_time := c.GetString("end_time")
49 97
 	ins := c.GetString("ins")
50
-	result, _ := service.GetHisOrderBy10697Summary(start_time, end_time, ins)
98
+
99
+	timeLayout := "2006-01-02"
100
+	loc, _ := time.LoadLocation("Local")
101
+	var startTime int64
102
+	if len(start_time) > 0 {
103
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
104
+		if err != nil {
105
+			fmt.Println(err)
106
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
107
+			return
108
+		}
109
+		startTime = theTime.Unix()
110
+	}
111
+	var endTime int64
112
+	if len(end_time) > 0 {
113
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
114
+		if err != nil {
115
+			utils.ErrorLog(err.Error())
116
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
117
+			return
118
+		}
119
+		endTime = theTime.Unix()
120
+	}
121
+
122
+	result, _ := service.GetHisOrderBy10697SummaryTwo(start_time, end_time, ins, startTime, endTime)
51 123
 	c.ServeSuccessJSON(map[string]interface{}{
52 124
 		"result": result,
53 125
 	})