...
|
...
|
@@ -3,8 +3,12 @@ package web_client |
|
|
import (
|
|
|
"fmt"
|
|
|
"io"
|
|
|
"net/http"
|
|
|
"net/http/httputil"
|
|
|
"net/url"
|
|
|
"strings"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
|
|
|
|
...
|
...
|
@@ -17,7 +21,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/service"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_manufacture"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -183,18 +186,31 @@ func (controller *ExcelDataController) FileImport() { |
|
|
importDividendsOrder(controller)
|
|
|
case domain.ImportDividendsReturnOrders:
|
|
|
importDividendsReturnedOrder(controller)
|
|
|
case "ImportProductRecordLevel2":
|
|
|
case "ImportProductRecordLevel2", "ImportAttendance", "ImportProductTrouble":
|
|
|
//车间制造-二级品审核导入
|
|
|
fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
fn(controller.Ctx)
|
|
|
case "ImportAttendance":
|
|
|
// 车间制造-工时管理导入
|
|
|
fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
fn(controller.Ctx)
|
|
|
case "ImportProductTrouble":
|
|
|
//车间制造-事故管理导入
|
|
|
fn := middleware.RedirectInternalService("/v1/web", allied_creation_manufacture.NewHttpLibAlliedCreationManufacture(domain.Operator{}))
|
|
|
fn(controller.Ctx)
|
|
|
target, err := url.Parse(constant.ALLIED_CREATION_MANUFACTURE_HOST)
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
tokenData, _ := middleware.FormCtxLoginToken(controller.Ctx)
|
|
|
controller.Ctx.Request.URL.Path = strings.Replace(controller.Ctx.Request.URL.Path, "/v1/web", "", 1)
|
|
|
newProxy := httputil.NewSingleHostReverseProxy(target)
|
|
|
directorFunc := newProxy.Director
|
|
|
newDirectorFunc := func(r *http.Request) {
|
|
|
r.Header.Add("orgId", fmt.Sprintf("%v", tokenData.OrgId))
|
|
|
r.Header.Add("companyId", fmt.Sprintf("%v", tokenData.CompanyId))
|
|
|
r.Header.Add("userId", fmt.Sprintf("%v", tokenData.UserId))
|
|
|
orgIdList := make([]string, 0)
|
|
|
for i := range tokenData.OrgIds {
|
|
|
orgIdList = append(orgIdList, fmt.Sprintf("%d", tokenData.OrgIds[i]))
|
|
|
}
|
|
|
r.Header.Add("orgIds", strings.Join(orgIdList, ","))
|
|
|
directorFunc(r)
|
|
|
r.Host = target.Host
|
|
|
}
|
|
|
newProxy.Director = newDirectorFunc
|
|
|
newProxy.ServeHTTP(controller.Ctx.ResponseWriter, controller.Ctx.Request)
|
|
|
|
|
|
default:
|
|
|
defaultImport(controller)
|
|
|
}
|
...
|
...
|
|