|
@@ -3,8 +3,12 @@ package web_client |
|
@@ -3,8 +3,12 @@ package web_client |
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
5
|
"io"
|
5
|
"io"
|
|
|
6
|
+ "net/http"
|
|
|
7
|
+ "net/http/httputil"
|
|
|
8
|
+ "net/url"
|
6
|
"strings"
|
9
|
"strings"
|
7
|
|
10
|
|
|
|
11
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
|
10
|
|
14
|
|
|
@@ -17,7 +21,6 @@ import ( |
|
@@ -17,7 +21,6 @@ import ( |
17
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
21
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
18
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/service"
|
22
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/service"
|
19
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
|
23
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
|
20
|
- "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
|
|
|
21
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
24
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
22
|
)
|
25
|
)
|
23
|
|
26
|
|
|
@@ -183,18 +186,31 @@ func (controller *ExcelDataController) FileImport() { |
|
@@ -183,18 +186,31 @@ func (controller *ExcelDataController) FileImport() { |
183
|
importDividendsOrder(controller)
|
186
|
importDividendsOrder(controller)
|
184
|
case domain.ImportDividendsReturnOrders:
|
187
|
case domain.ImportDividendsReturnOrders:
|
185
|
importDividendsReturnedOrder(controller)
|
188
|
importDividendsReturnedOrder(controller)
|
186
|
- case "ImportProductRecordLevel2":
|
189
|
+ case "ImportProductRecordLevel2", "ImportAttendance", "ImportProductTrouble":
|
187
|
//车间制造-二级品审核导入
|
190
|
//车间制造-二级品审核导入
|
188
|
- fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
189
|
- fn(controller.Ctx)
|
|
|
190
|
- case "ImportAttendance":
|
|
|
191
|
- // 车间制造-工时管理导入
|
|
|
192
|
- fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
193
|
- fn(controller.Ctx)
|
|
|
194
|
- case "ImportProductTrouble":
|
|
|
195
|
- //车间制造-事故管理导入
|
|
|
196
|
- fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
197
|
- fn(controller.Ctx)
|
191
|
+ target, err := url.Parse(constant.ALLIED_CREATION_MANUFACTURE_HOST)
|
|
|
192
|
+ if err != nil {
|
|
|
193
|
+ panic(err)
|
|
|
194
|
+ }
|
|
|
195
|
+ tokenData, _ := middleware.FormCtxLoginToken(controller.Ctx)
|
|
|
196
|
+ controller.Ctx.Request.URL.Path = strings.Replace(controller.Ctx.Request.URL.Path, "/v1/web", "", 1)
|
|
|
197
|
+ newProxy := httputil.NewSingleHostReverseProxy(target)
|
|
|
198
|
+ directorFunc := newProxy.Director
|
|
|
199
|
+ newDirectorFunc := func(r *http.Request) {
|
|
|
200
|
+ r.Header.Add("orgId", fmt.Sprintf("%v", tokenData.OrgId))
|
|
|
201
|
+ r.Header.Add("companyId", fmt.Sprintf("%v", tokenData.CompanyId))
|
|
|
202
|
+ r.Header.Add("userId", fmt.Sprintf("%v", tokenData.UserId))
|
|
|
203
|
+ orgIdList := make([]string, 0)
|
|
|
204
|
+ for i := range tokenData.OrgIds {
|
|
|
205
|
+ orgIdList = append(orgIdList, fmt.Sprintf("%d", tokenData.OrgIds[i]))
|
|
|
206
|
+ }
|
|
|
207
|
+ r.Header.Add("orgIds", strings.Join(orgIdList, ","))
|
|
|
208
|
+ directorFunc(r)
|
|
|
209
|
+ r.Host = target.Host
|
|
|
210
|
+ }
|
|
|
211
|
+ newProxy.Director = newDirectorFunc
|
|
|
212
|
+ newProxy.ServeHTTP(controller.Ctx.ResponseWriter, controller.Ctx.Request)
|
|
|
213
|
+
|
198
|
default:
|
214
|
default:
|
199
|
defaultImport(controller)
|
215
|
defaultImport(controller)
|
200
|
}
|
216
|
}
|