作者 Your Name

处理导入

... ... @@ -15,16 +15,16 @@ var LOG_PREFIX = "[allied-creation-gateway]"
var FileStatic = "./static"
var HTTP_PORT int = 8083
var HTTP_PORT int = 8080
var ALLIED_CREATION_GATEWAY_HOST = "http://localhost:8080"
//天联共创基础模块
// 天联共创基础模块
var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"
//天联共创用户模块
// 天联共创用户模块
var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"
//天联共创业务模块
// 天联共创业务模块
var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"
// 天联共创 生产制造模块
... ... @@ -33,10 +33,10 @@ var ALLIED_CREATION_MANUFACTURE_HOST = "http://localhost:8083"
// 版本更新模块
var SUPLUS_ADMIN_BASE_HOST = "http://suplus-admin-base-dev.fjmaimaimai.com"
//通用模块短信服务
// 通用模块短信服务
var SMS_SERVE_HOST = "https://sms.fjmaimaimai.com:9897"
//素加销售导航服务
// 素加销售导航服务
var SUPLUS_SALE_APP = "http://suplus-sale-app-gateway-test.fjmaimaimai.com"
// TODO:特殊短信验证码,不验证,正式环境注入空
... ...
... ... @@ -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)
}
... ...