|
@@ -38,13 +38,77 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user |
|
@@ -38,13 +38,77 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user |
38
|
// FROM chance AS a
|
38
|
// FROM chance AS a
|
39
|
// JOIN user_company AS c ON c.id = a.user_id
|
39
|
// JOIN user_company AS c ON c.id = a.user_id
|
40
|
// JOIN user AS d ON c.user_id = d.id
|
40
|
// JOIN user AS d ON c.user_id = d.id
|
|
|
41
|
+ var (
|
|
|
42
|
+ reserveTypeIdMap = map[int]struct{}{}
|
|
|
43
|
+ chanceTypeIdMap = map[int]struct{}{}
|
|
|
44
|
+ auditTemplateIdMap = map[int64]struct{}{}
|
|
|
45
|
+ departmentIdMap = map[int64]struct{}{}
|
|
|
46
|
+ )
|
|
|
47
|
+ for i := range soureData {
|
|
|
48
|
+ reserveTypeIdStr := fmt.Sprint(soureData[i]["reserve_type_id"])
|
|
|
49
|
+ reserveTypeId, _ := strconv.Atoi(reserveTypeIdStr)
|
|
|
50
|
+ reserveTypeIdMap[reserveTypeId] = struct{}{}
|
|
|
51
|
+ chanceTypeIdStr := fmt.Sprint(soureData[i]["chance_type_id"])
|
|
|
52
|
+ chanceTypeId, _ := strconv.Atoi(chanceTypeIdStr)
|
|
|
53
|
+ chanceTypeIdMap[chanceTypeId] = struct{}{}
|
|
|
54
|
+ auditTemplateIdStr := fmt.Sprint(soureData[i]["audit_template_id"])
|
|
|
55
|
+ auditTemplateId, _ := strconv.ParseInt(auditTemplateIdStr, 10, 64)
|
|
|
56
|
+ auditTemplateIdMap[auditTemplateId] = struct{}{}
|
|
|
57
|
+ departmentIdStr := fmt.Sprint(soureData[i]["department_id"])
|
|
|
58
|
+ departmentId, _ := strconv.ParseInt(departmentIdStr, 10, 64)
|
|
|
59
|
+ departmentIdMap[departmentId] = struct{}{}
|
|
|
60
|
+ }
|
|
|
61
|
+ var (
|
|
|
62
|
+ reserveTypeIds []int
|
|
|
63
|
+ chanceTypeIds []int
|
|
|
64
|
+ auditTemplateIds []int64
|
|
|
65
|
+ departmentIds []int64
|
|
|
66
|
+ )
|
|
|
67
|
+ for k := range reserveTypeIdMap {
|
|
|
68
|
+ reserveTypeIds = append(reserveTypeIds, k)
|
|
|
69
|
+ }
|
|
|
70
|
+ for k := range chanceTypeIdMap {
|
|
|
71
|
+ chanceTypeIds = append(chanceTypeIds, k)
|
|
|
72
|
+ }
|
|
|
73
|
+ for k := range auditTemplateIdMap {
|
|
|
74
|
+ auditTemplateIds = append(auditTemplateIds, k)
|
|
|
75
|
+ }
|
|
|
76
|
+ for k := range departmentIdMap {
|
|
|
77
|
+ departmentIds = append(departmentIds, k)
|
|
|
78
|
+ }
|
|
|
79
|
+ var (
|
|
|
80
|
+ reserveTypes []models.ChanceReserveType
|
|
|
81
|
+ chanceTypes []models.ChanceType
|
|
|
82
|
+ auditTemplates []models.AuditTemplate
|
|
|
83
|
+ departments []models.Department
|
|
|
84
|
+ )
|
|
|
85
|
+ reserveTypes, _ = models.GetChanceReserveTypeByIds(reserveTypeIds)
|
|
|
86
|
+ chanceTypes, _ = models.GetChanceTypeByIds(chanceTypeIds)
|
|
|
87
|
+ auditTemplates, _ = models.GetAuditTemplateByIds(auditTemplateIds)
|
|
|
88
|
+ departments, _ = models.GetDepartmentByIds(departmentIds)
|
41
|
//进行数据整理
|
89
|
//进行数据整理
|
42
|
var (
|
90
|
var (
|
43
|
- reserveTypeCache = make(map[string]*models.ChanceReserveType)
|
|
|
44
|
- chanceTypeCache = make(map[string]*models.ChanceType)
|
|
|
45
|
- auditTemplateCache = make(map[string]*models.AuditTemplate)
|
|
|
46
|
- departmentCache = make(map[string]*models.Department)
|
91
|
+ reserveTypeCache = make(map[string]models.ChanceReserveType)
|
|
|
92
|
+ chanceTypeCache = make(map[string]models.ChanceType)
|
|
|
93
|
+ auditTemplateCache = make(map[string]models.AuditTemplate)
|
|
|
94
|
+ departmentCache = make(map[string]models.Department)
|
47
|
)
|
95
|
)
|
|
|
96
|
+ for i := range reserveTypes {
|
|
|
97
|
+ idString := strconv.Itoa(reserveTypes[i].Id)
|
|
|
98
|
+ reserveTypeCache[idString] = reserveTypes[i]
|
|
|
99
|
+ }
|
|
|
100
|
+ for i := range chanceTypes {
|
|
|
101
|
+ idString := strconv.Itoa(chanceTypes[i].Id)
|
|
|
102
|
+ chanceTypeCache[idString] = chanceTypes[i]
|
|
|
103
|
+ }
|
|
|
104
|
+ for i := range auditTemplates {
|
|
|
105
|
+ idString := strconv.Itoa(int(auditTemplates[i].Id))
|
|
|
106
|
+ auditTemplateCache[idString] = auditTemplates[i]
|
|
|
107
|
+ }
|
|
|
108
|
+ for i := range departments {
|
|
|
109
|
+ idString := strconv.Itoa(int(departments[i].Id))
|
|
|
110
|
+ departmentCache[idString] = departments[i]
|
|
|
111
|
+ }
|
48
|
for i := range soureData {
|
112
|
for i := range soureData {
|
49
|
storeTypeS := fmt.Sprint(soureData[i]["type"])
|
113
|
storeTypeS := fmt.Sprint(soureData[i]["type"])
|
50
|
storeType, _ := strconv.ParseInt(storeTypeS, 10, 8)
|
114
|
storeType, _ := strconv.ParseInt(storeTypeS, 10, 8)
|
|
@@ -53,57 +117,62 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user |
|
@@ -53,57 +117,62 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user |
53
|
soureData[i]["reserve_type"] = "未设置"
|
117
|
soureData[i]["reserve_type"] = "未设置"
|
54
|
if reserveType, ok := reserveTypeCache[reserveTypeIdS]; ok {
|
118
|
if reserveType, ok := reserveTypeCache[reserveTypeIdS]; ok {
|
55
|
soureData[i]["reserve_type"] = reserveType.Name
|
119
|
soureData[i]["reserve_type"] = reserveType.Name
|
56
|
- } else {
|
|
|
57
|
- reserveTypeId, _ := strconv.Atoi(reserveTypeIdS)
|
|
|
58
|
- if reserveTypeId > 0 {
|
|
|
59
|
- reserveType, err := models.GetChanceReserveTypeById(reserveTypeId)
|
|
|
60
|
- if err == nil {
|
|
|
61
|
- reserveTypeCache[reserveTypeIdS] = reserveType
|
|
|
62
|
- soureData[i]["reserve_type"] = reserveType.Name
|
|
|
63
|
- }
|
|
|
64
|
- }
|
|
|
65
|
}
|
120
|
}
|
|
|
121
|
+ // else {
|
|
|
122
|
+ // reserveTypeId, _ := strconv.Atoi(reserveTypeIdS)
|
|
|
123
|
+ // if reserveTypeId > 0 {
|
|
|
124
|
+ // reserveType, err := models.GetChanceReserveTypeById(reserveTypeId)
|
|
|
125
|
+ // if err == nil {
|
|
|
126
|
+ // reserveTypeCache[reserveTypeIdS] = reserveType
|
|
|
127
|
+ // soureData[i]["reserve_type"] = reserveType.Name
|
|
|
128
|
+ // }
|
|
|
129
|
+ // }
|
|
|
130
|
+ // }
|
66
|
chanceTypeIdS := fmt.Sprint(soureData[i]["chance_type_id"])
|
131
|
chanceTypeIdS := fmt.Sprint(soureData[i]["chance_type_id"])
|
67
|
soureData[i]["chance_type"] = ""
|
132
|
soureData[i]["chance_type"] = ""
|
|
|
133
|
+ //TODO
|
68
|
if chanceType, ok := chanceTypeCache[chanceTypeIdS]; ok {
|
134
|
if chanceType, ok := chanceTypeCache[chanceTypeIdS]; ok {
|
69
|
soureData[i]["chance_type"] = chanceType.Name
|
135
|
soureData[i]["chance_type"] = chanceType.Name
|
70
|
- } else {
|
|
|
71
|
- chanceTypeId, _ := strconv.Atoi(chanceTypeIdS)
|
|
|
72
|
- if chanceTypeId > 0 {
|
|
|
73
|
- chanceType, err := models.GetChanceTypeById(chanceTypeId)
|
|
|
74
|
- if err == nil {
|
|
|
75
|
- chanceTypeCache[chanceTypeIdS] = chanceType
|
|
|
76
|
- soureData[i]["chance_type"] = chanceType.Name
|
|
|
77
|
- }
|
|
|
78
|
- }
|
|
|
79
|
}
|
136
|
}
|
|
|
137
|
+ // else {
|
|
|
138
|
+ // chanceTypeId, _ := strconv.Atoi(chanceTypeIdS)
|
|
|
139
|
+ // if chanceTypeId > 0 {
|
|
|
140
|
+ // chanceType, err := models.GetChanceTypeById(chanceTypeId)
|
|
|
141
|
+ // if err == nil {
|
|
|
142
|
+ // chanceTypeCache[chanceTypeIdS] = chanceType
|
|
|
143
|
+ // soureData[i]["chance_type"] = chanceType.Name
|
|
|
144
|
+ // }
|
|
|
145
|
+ // }
|
|
|
146
|
+ // }
|
80
|
auditTemplateIdS := fmt.Sprint(soureData[i]["audit_template_id"])
|
147
|
auditTemplateIdS := fmt.Sprint(soureData[i]["audit_template_id"])
|
81
|
soureData[i]["audit_template"] = ""
|
148
|
soureData[i]["audit_template"] = ""
|
82
|
if auditTempalte, ok := auditTemplateCache[auditTemplateIdS]; ok {
|
149
|
if auditTempalte, ok := auditTemplateCache[auditTemplateIdS]; ok {
|
83
|
soureData[i]["audit_template"] = auditTempalte.Name
|
150
|
soureData[i]["audit_template"] = auditTempalte.Name
|
84
|
- } else {
|
|
|
85
|
- auditTemplateId, _ := strconv.ParseInt(auditTemplateIdS, 10, 64)
|
|
|
86
|
- if auditTemplateId > 0 {
|
|
|
87
|
- auditTempalte, err := models.GetAuditTemplateById(auditTemplateId)
|
|
|
88
|
- if err == nil {
|
|
|
89
|
- auditTemplateCache[auditTemplateIdS] = auditTempalte
|
|
|
90
|
- soureData[i]["audit_template"] = auditTempalte.Name
|
|
|
91
|
- }
|
|
|
92
|
- }
|
|
|
93
|
}
|
151
|
}
|
|
|
152
|
+ // else {
|
|
|
153
|
+ // auditTemplateId, _ := strconv.ParseInt(auditTemplateIdS, 10, 64)
|
|
|
154
|
+ // if auditTemplateId > 0 {
|
|
|
155
|
+ // auditTempalte, err := models.GetAuditTemplateById(auditTemplateId)
|
|
|
156
|
+ // if err == nil {
|
|
|
157
|
+ // auditTemplateCache[auditTemplateIdS] = auditTempalte
|
|
|
158
|
+ // soureData[i]["audit_template"] = auditTempalte.Name
|
|
|
159
|
+ // }
|
|
|
160
|
+ // }
|
|
|
161
|
+ // }
|
94
|
departmentIdS := fmt.Sprint(soureData[i]["department_id"])
|
162
|
departmentIdS := fmt.Sprint(soureData[i]["department_id"])
|
95
|
if department, ok := departmentCache[departmentIdS]; ok {
|
163
|
if department, ok := departmentCache[departmentIdS]; ok {
|
96
|
soureData[i]["department"] = department.Name
|
164
|
soureData[i]["department"] = department.Name
|
97
|
- } else {
|
|
|
98
|
- departmentId, _ := strconv.ParseInt(departmentIdS, 10, 64)
|
|
|
99
|
- if departmentId > 0 {
|
|
|
100
|
- department, err := models.GetDepartmentById(departmentId)
|
|
|
101
|
- if err == nil {
|
|
|
102
|
- departmentCache[departmentIdS] = department
|
|
|
103
|
- soureData[i]["department"] = department.Name
|
|
|
104
|
- }
|
|
|
105
|
- }
|
|
|
106
|
}
|
165
|
}
|
|
|
166
|
+ // else {
|
|
|
167
|
+ // departmentId, _ := strconv.ParseInt(departmentIdS, 10, 64)
|
|
|
168
|
+ // if departmentId > 0 {
|
|
|
169
|
+ // department, err := models.GetDepartmentById(departmentId)
|
|
|
170
|
+ // if err == nil {
|
|
|
171
|
+ // departmentCache[departmentIdS] = department
|
|
|
172
|
+ // soureData[i]["department"] = department.Name
|
|
|
173
|
+ // }
|
|
|
174
|
+ // }
|
|
|
175
|
+ // }
|
107
|
reviewStatusS := fmt.Sprint(soureData[i]["review_status"])
|
176
|
reviewStatusS := fmt.Sprint(soureData[i]["review_status"])
|
108
|
reviewStatus, _ := strconv.ParseInt(reviewStatusS, 10, 8)
|
177
|
reviewStatus, _ := strconv.ParseInt(reviewStatusS, 10, 8)
|
109
|
soureData[i]["review_status"] = models.ChanceReviewStatusMap[int8(reviewStatus)]
|
178
|
soureData[i]["review_status"] = models.ChanceReviewStatusMap[int8(reviewStatus)]
|