Commit 07f9e654 by mushishixian

对接接口

parent ed352464
...@@ -58,8 +58,8 @@ func SyncCustomerData(customer model.Customer) bool { ...@@ -58,8 +58,8 @@ func SyncCustomerData(customer model.Customer) bool {
"erp_client_sn": customer.ErpClientCode, "erp_client_sn": customer.ErpClientCode,
"customer_name": customer.Name, "customer_name": customer.Name,
"erp_customer_id": customer.ErpId, "erp_customer_id": customer.ErpId,
"admin_name": "admin@ichunt.com", "admin_name": "系统",
"admin_id": 1000, "admin_id": 1,
} }
url = configs.BasicApiUrl + "/basic/api/ApiInsertCustomerInfo" url = configs.BasicApiUrl + "/basic/api/ApiInsertCustomerInfo"
req.Debug = true req.Debug = true
......
...@@ -58,8 +58,8 @@ func SyncSupplierData(supplier model.Supplier) bool { ...@@ -58,8 +58,8 @@ func SyncSupplierData(supplier model.Supplier) bool {
"erp_supplier_sn": supplier.ErpSupplierCode, "erp_supplier_sn": supplier.ErpSupplierCode,
"supplier_name": supplier.Name, "supplier_name": supplier.Name,
"erp_supplier_id": supplier.ErpId, "erp_supplier_id": supplier.ErpId,
"admin_name": "admin@ichunt.com", "admin_name": "系统",
"admin_id": 1000, "admin_id": 1,
} }
url = configs.BasicApiUrl + "/basic/api/ApiInsertSupplierInfo" url = configs.BasicApiUrl + "/basic/api/ApiInsertSupplierInfo"
req.Debug = true req.Debug = true
......
package main package main
import ( import (
"scm_server/internal/dao"
"scm_server/internal/model"
"fmt" "fmt"
"github.com/tiaguinho/gosoap"
"log"
) )
func main() { func main() {
fmt.Println(1) //soap, err := gosoap.SoapClient("http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl")
//测试数据库连接 soap, err := gosoap.SoapClient("http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl")
var user_info model.UserInfo
var user_company model.UserCompany
//查找公司名称
err := dao.GetDb().QueryRowx("select com_name from lie_user_company where user_id = ?",1).StructScan(&user_company)
if err != nil { if err != nil {
fmt.Println(err) log.Fatalf("SoapClient error: %s", err)
}
//(userName, password, slnName, dcName, language, dbType, authPattern)
//("WBYH", "123456", "eas", "demo", "L2", 1, "BaseDB")
//params := gosoap.Params{
// "userName": "WBYH",
// "password": "123456",
// "slnName": "eas",
// "dcName": "demo",
// "language": "L2",
// "dbType": 1,
// "authPattern": "BaseDB",
//}
params:=gosoap.Params{
"json":`{"FType":"material", "FID":"ET9WHFzYagYZf0="}`,
} }
fmt.Println(user_company.Com_name)
//查找手机号 err = soap.Call("synRewriteErpBaseDataStatus", params)
err = dao.GetCmsDb().QueryRowx("select mobile from user_info where userId = ?",1599).StructScan(&user_info)
if err != nil { if err != nil {
fmt.Println(err) log.Fatalf("Call error: %s", err)
} }
fmt.Println(user_info.Mobile) fmt.Println(string(soap.Body))
} }
...@@ -126,8 +126,8 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) { ...@@ -126,8 +126,8 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
"erp_client_sn": customer.ErpClientCode, "erp_client_sn": customer.ErpClientCode,
"customer_name": customer.Name, "customer_name": customer.Name,
"erp_customer_id": customer.ErpId, "erp_customer_id": customer.ErpId,
"admin_name": "admin@ichunt.com", "admin_name": "系统",
"admin_id": 1000, "admin_id": 1,
} }
//更新和插入接口不同 //更新和插入接口不同
......
...@@ -18,12 +18,13 @@ import ( ...@@ -18,12 +18,13 @@ import (
type RecvPro struct { type RecvPro struct {
} }
type SupplierQueueMessage struct { type GoodsQueueMessage struct {
Type string Type string
Data struct { Data struct {
FID string FID string
FNUMBER string FGoods string
CFNAME string FBrand string
FModel string
} }
} }
...@@ -33,9 +34,9 @@ func init() { ...@@ -33,9 +34,9 @@ func init() {
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message SupplierQueueMessage message GoodsQueueMessage
err error err error
supplier model.Supplier goods model.Goods
operateType string operateType string
syncLog model.SyncLog syncLog model.SyncLog
) )
...@@ -45,29 +46,31 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -45,29 +46,31 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
//转换成supplier数据 //转换成supplier数据
supplier.ErpId = message.Data.FID goods.ErpId = message.Data.FID
supplier.ErpSupplierCode = message.Data.FNUMBER goods.BrandName = message.Data.FBrand
supplier.Name = message.Data.CFNAME goods.GoodsCnName = message.Data.FGoods
goods.GoodsName = message.Data.FModel
//判断操作类型 //判断操作类型
switch message.Type { switch message.Type {
case "save": case "save":
//先去查询是否存在,不存在才去插入,已经存在即是修改 //先去查询是否存在,不存在才去插入,已经存在即是修改
if logic.CheckSupplierExist(supplier.ErpId) { fmt.Println(goods.ErpId)
if logic.CheckGoodsExist(goods.ErpId) {
operateType = "update" operateType = "update"
if err = logic.UpdateSupplier(supplier); err != nil { if err = logic.UpdateGoods(goods); err != nil {
goto ERR goto ERR
} }
} else { } else {
operateType = "insert" operateType = "insert"
if err = logic.InsertSupplier(supplier); err != nil { if err = logic.InsertGoods(goods); err != nil {
goto ERR goto ERR
} }
} }
case "delete": case "delete":
operateType = "delete" operateType = "delete"
if logic.CheckSupplierExist(supplier.ErpId) { if logic.CheckGoodsExist(goods.ErpId) {
//如果存在,才进行删除 //如果存在,才进行删除
if err = logic.DeleteSupplier(supplier.ErpId); err != nil { if err = logic.DeleteGoods(goods.ErpId); err != nil {
goto ERR goto ERR
} }
} else { } else {
...@@ -79,15 +82,15 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -79,15 +82,15 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto ERR goto ERR
} }
//操作成功后还要去请求后端接口同步数据 //操作成功后还要去请求后端接口同步数据
if err = SyncSupplierData(operateType, supplier); err != nil { if err = SyncGoodsData(operateType, goods); err != nil {
goto ERR goto ERR
} }
fmt.Println("同步成功") fmt.Println("同步成功")
return nil return nil
ERR: ERR:
//不存在的erp_id不去操作对应的数据库 //不存在的erp_id不去操作对应的数据库
if supplier.ErpId != "" { if goods.ErpId != "" {
logSyncErrorToSupplier(supplier.ErpId, err.Error()) logSyncErrorToGoods(goods.ErpId, err.Error())
} }
//还要存到一个统一错误表 //还要存到一个统一错误表
...@@ -95,9 +98,9 @@ ERR: ...@@ -95,9 +98,9 @@ ERR:
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
SyncTime: time.Now().Unix(), SyncTime: time.Now().Unix(),
QueueMessage: string(dataByte), QueueMessage: string(dataByte),
UniqueId: supplier.ErpId, //有可能为 UniqueId: goods.ErpId, //有可能为
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "supplier", SyncName: "goods",
} }
logic.InsertSyncLog(syncLog) logic.InsertSyncLog(syncLog)
...@@ -116,27 +119,28 @@ func (t *RecvPro) FailAction(dataByte []byte) error { ...@@ -116,27 +119,28 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
} }
//同步数据 //同步数据
func SyncSupplierData(operate string, supplier model.Supplier) (err error) { func SyncGoodsData(operate string, goods model.Goods) (err error) {
var ( var (
resp *req.Resp resp *req.Resp
url string url string
respData common.Response respData common.Response
) )
param := req.Param{ param := req.Param{
"erp_supplier_sn": supplier.ErpSupplierCode, "goods_name": goods.GoodsName,
"supplier_name": supplier.Name, "goods_cn_name": goods.GoodsCnName,
"erp_supplier_id": supplier.ErpId, "brand_name": goods.BrandName,
"admin_name": "admin@ichunt.com", "erp_goods_id": goods.ErpId,
"admin_id": 1000, "admin_name": "系统",
"admin_id": 1,
} }
//更新和插入接口不同 //更新和插入接口不同
if operate == "update" { if operate == "update" {
url = configs.BasicApiUrl + "/basic/api/ApiUpdateSupplierInfo" url = configs.BasicApiUrl + "/basic/api/ApiUpdateGoodsInfo"
} else if operate == "insert" { } else if operate == "insert" {
url = configs.BasicApiUrl + "/basic/api/ApiInsertSupplierInfo" url = configs.BasicApiUrl + "/basic/api/ApiInsertGoodsInfo"
} else { } else {
url = configs.BasicApiUrl + "/basic/api/ApiDeleteSupplierInfo" url = configs.BasicApiUrl + "/basic/api/ApiDeleteGoodsInfo"
} }
req.Debug = false req.Debug = false
if operate == "update" || operate == "insert" { if operate == "update" || operate == "insert" {
...@@ -151,20 +155,41 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) { ...@@ -151,20 +155,41 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
return errors.New(respData.Errmsg) return errors.New(respData.Errmsg)
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态 //都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncSupplierSuccess(supplier.ErpId); err != nil { if err = logic.SyncGoodsSuccess(goods.ErpId, false); err != nil {
return return
} }
} else { } else {
//删除 url = configs.BasicApiUrl + "/basic/api/ApiUpdateGoodsStatus"
//删除,软删除
param := req.Param{
"status": 0,
"erp_goods_id": goods.ErpId,
"admin_name": "系统",
"admin_id": 1,
}
resp, err = req.Post(url, param)
if err != nil {
return
}
if err = resp.ToJSON(&respData); err != nil {
return
}
if respData.Errcode != 101100 {
return errors.New(respData.Errmsg)
}
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncGoodsSuccess(goods.ErpId, true); err != nil {
return
}
} }
return return
} }
func logSyncErrorToSupplier(erpId, syncError string) { func logSyncErrorToGoods(erpId, syncError string) {
var err error var err error
//请求失败的话,将原因存起来 //请求失败的话,将原因存起来
if err = logic.WriteSupplierSyncError(erpId, syncError); err != nil { if err = logic.WriteGoodsSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告 //数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error()) service.SendMessage(common.ErrorSendPhone, err.Error())
} }
...@@ -173,8 +198,8 @@ func logSyncErrorToSupplier(erpId, syncError string) { ...@@ -173,8 +198,8 @@ func logSyncErrorToSupplier(erpId, syncError string) {
func main() { func main() {
t := &RecvPro{} t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{ rabbitmq.Recv(rabbitmq.QueueExchange{
"store_supplier", "store_goods",
"store_supplier", "store_goods",
"store", "store",
"direct", "direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/", "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
......
...@@ -11,19 +11,20 @@ func main() { ...@@ -11,19 +11,20 @@ func main() {
message = map[string]interface{}{ message = map[string]interface{}{
"type": "save", "type": "save",
"data": map[string]string{ "data": map[string]string{
"FID": "Z8eVSzSLRXKa7ET9WHFzYagYZf0171=", "FID": "Z8eVSzSLRXKa7ET9WHFzYagYZf0171=",
"FNUMBER": "WT0050333", "FGoods": "WT0050333",
"CFNAME": "深圳市鼎驰达电子有限公司", "FBrand": "深圳市鼎驰达电子有限公司",
"FModel": "",
}, },
} }
data,err := json.Marshal(message) data, err := json.Marshal(message)
if err!=nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
body := string(data) body := string(data)
queueExchange := rabbitmq.QueueExchange{ queueExchange := rabbitmq.QueueExchange{
"store_supplier", "store_goods",
"store_supplier", "store_goods",
"store", "store",
"direct", "direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/", "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
......
package main
import (
"encoding/json"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
)
type RecvPro struct {
}
type QueueStatus struct {
SyncName string
Status int
ErpId string
}
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error {
var (
err error
message QueueStatus
)
//先去转换队列消息的json
if err = json.Unmarshal(dataByte, &message); err != nil {
goto ERR
}
//得到message以后,去请求金蝶的接口
//如果失败了,记录到表,并且发送钉钉消息
ERR:
fmt.Println(err)
return nil
}
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
func main() {
t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{
"store_sync_status",
"store_sync_status",
"store",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}, t, 3)
}
package main
import (
"encoding/json"
"fmt"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
)
func main() {
message := make(map[string]interface{})
message = map[string]interface{}{
"SyncName": "supplier",
"Status": 1,
"ErpId": "test123456",
}
data,err := json.Marshal(message)
if err!=nil {
fmt.Println(err)
}
body := string(data)
queueExchange := rabbitmq.QueueExchange{
"store_sync_status",
"store_sync_status",
"store",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
rabbitmq.Send(queueExchange, body)
}
...@@ -125,8 +125,8 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) { ...@@ -125,8 +125,8 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
"erp_supplier_sn": supplier.ErpSupplierCode, "erp_supplier_sn": supplier.ErpSupplierCode,
"supplier_name": supplier.Name, "supplier_name": supplier.Name,
"erp_supplier_id": supplier.ErpId, "erp_supplier_id": supplier.ErpId,
"admin_name": "admin@ichunt.com", "admin_name": "系统",
"admin_id": 1000, "admin_id": 1,
} }
//更新和插入接口不同 //更新和插入接口不同
......
package goods package goods
import ( import (
"encoding/json"
"fmt" "fmt"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/tealeg/xlsx" "github.com/tealeg/xlsx"
"scm_server/internal/logic" "scm_server/internal/logic"
"scm_server/internal/model" "scm_server/internal/model"
) )
var Exchange rabbitmq.QueueExchange
//导入委托方的信息(excel导入)
func init() {
Exchange = rabbitmq.QueueExchange{
"store_goods",
"store_goods",
"store",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
}
//导入委托方的信息(excel导入) //导入委托方的信息(excel导入)
func Import() { func Import() {
var ( var (
...@@ -25,16 +40,35 @@ func Import() { ...@@ -25,16 +40,35 @@ func Import() {
if key == 0 { if key == 0 {
continue continue
} }
goods.ErpGoodsId = row.Cells[0].String() goods.ErpId = row.Cells[0].String()
goods.GoodsName = row.Cells[1].String() goods.GoodsName = row.Cells[1].String()
goods.BrandName = row.Cells[2].String() goods.BrandName = row.Cells[2].String()
goods.GoodsCnName = row.Cells[3].String() goods.GoodsCnName = row.Cells[3].String()
if logic.CheckGoodsExist(goods.ErpGoodsId) { //如果品牌名称为空,跳过
if goods.BrandName == "" {
continue
}
if logic.CheckGoodsExist(goods.ErpId) {
fmt.Println("已存在,跳过")
continue continue
} }
if err = logic.InsertGoods(goods); err != nil { message := make(map[string]interface{})
message = map[string]interface{}{
"type": "save",
"data": map[string]string{
"FID": goods.ErpId,
"FGoods": goods.GoodsCnName,
"FBrand": goods.BrandName,
"FModel": goods.GoodsName,
},
}
fmt.Println(message)
data, err := json.Marshal(message)
if err != nil {
fmt.Println(err) fmt.Println(err)
} }
body := string(data)
rabbitmq.Send(Exchange, body)
} }
} }
} }
package main package main
import "scm_server/cmd/source/supplier" import "scm_server/cmd/source/goods"
func main() { func main() {
//forever := make(chan bool) //forever := make(chan bool)
//go supplier.Import() //go supplier.Import()
supplier.Import() //supplier.Import()
//<-forever //<-forever
//customer.Import() //customer.Import()
//goods.Import() goods.Import()
} }
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://192.168.2.253:6888/ormrpc/services/EASLogin" xmlns:intf="http://192.168.2.253:6888/ormrpc/services/EASLogin" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:client" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema targetNamespace="urn:client" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="WSContext">
<sequence>
<element name="slnName" nillable="true" type="xsd:string"/>
<element name="password" nillable="true" type="xsd:string"/>
<element name="dbType" type="xsd:int"/>
<element name="userName" nillable="true" type="xsd:string"/>
<element name="sessionId" nillable="true" type="xsd:string"/>
<element name="dcName" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="logoutResponse">
<wsdl:part name="logoutReturn" type="xsd:boolean">
</wsdl:part>
</wsdl:message>
<wsdl:message name="logoutRequest">
<wsdl:part name="userName" type="xsd:string">
</wsdl:part>
<wsdl:part name="slnName" type="xsd:string">
</wsdl:part>
<wsdl:part name="dcName" type="xsd:string">
</wsdl:part>
<wsdl:part name="language" type="xsd:string">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse2">
<wsdl:part name="loginReturn" type="tns1:WSContext">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest">
<wsdl:part name="userName" type="xsd:string">
</wsdl:part>
<wsdl:part name="password" type="xsd:string">
</wsdl:part>
<wsdl:part name="slnName" type="xsd:string">
</wsdl:part>
<wsdl:part name="dcName" type="xsd:string">
</wsdl:part>
<wsdl:part name="language" type="xsd:string">
</wsdl:part>
<wsdl:part name="dbType" type="xsd:int">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest1">
<wsdl:part name="userName" type="xsd:string">
</wsdl:part>
<wsdl:part name="password" type="xsd:string">
</wsdl:part>
<wsdl:part name="slnName" type="xsd:string">
</wsdl:part>
<wsdl:part name="dcName" type="xsd:string">
</wsdl:part>
<wsdl:part name="language" type="xsd:string">
</wsdl:part>
<wsdl:part name="dbType" type="xsd:int">
</wsdl:part>
<wsdl:part name="authPattern" type="xsd:string">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse">
<wsdl:part name="loginReturn" type="tns1:WSContext">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest2">
<wsdl:part name="userName" type="xsd:string">
</wsdl:part>
<wsdl:part name="password" type="xsd:string">
</wsdl:part>
<wsdl:part name="slnName" type="xsd:string">
</wsdl:part>
<wsdl:part name="dcName" type="xsd:string">
</wsdl:part>
<wsdl:part name="language" type="xsd:string">
</wsdl:part>
<wsdl:part name="dbType" type="xsd:int">
</wsdl:part>
<wsdl:part name="authPattern" type="xsd:string">
</wsdl:part>
<wsdl:part name="isEncodePwd" type="xsd:int">
</wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse1">
<wsdl:part name="loginReturn" type="tns1:WSContext">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="EASLoginProxy">
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType">
<wsdl:input message="intf:loginRequest" name="loginRequest">
</wsdl:input>
<wsdl:output message="intf:loginResponse" name="loginResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern">
<wsdl:input message="intf:loginRequest1" name="loginRequest1">
</wsdl:input>
<wsdl:output message="intf:loginResponse1" name="loginResponse1">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern isEncodePwd">
<wsdl:input message="intf:loginRequest2" name="loginRequest2">
</wsdl:input>
<wsdl:output message="intf:loginResponse2" name="loginResponse2">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout" parameterOrder="userName slnName dcName language">
<wsdl:input message="intf:logoutRequest" name="logoutRequest">
</wsdl:input>
<wsdl:output message="intf:logoutResponse" name="logoutResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EASLoginSoapBinding" type="intf:EASLoginProxy">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest1">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse1">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest2">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse2">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="logoutRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="logoutResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EASLoginProxyService">
<wsdl:port binding="intf:EASLoginSoapBinding" name="EASLogin">
<wsdlsoap:address location="http://192.168.2.253:6888/ormrpc/services/EASLogin"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
...@@ -4,10 +4,12 @@ go 1.13 ...@@ -4,10 +4,12 @@ go 1.13
require ( require (
github.com/go-kratos/kratos v0.4.2 github.com/go-kratos/kratos v0.4.2
github.com/hooklift/gowsdl v0.3.1
github.com/ichunt2019/go-rabbitmq v1.0.1 github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/imroc/req v0.3.0 github.com/imroc/req v0.3.0
github.com/jmoiron/sqlx v1.2.0 github.com/jmoiron/sqlx v1.2.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71 github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71
github.com/tealeg/xlsx v1.0.5 github.com/tealeg/xlsx v1.0.5
github.com/tiaguinho/gosoap v1.2.0
) )
...@@ -101,6 +101,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf ...@@ -101,6 +101,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hooklift/gowsdl v0.3.1 h1:tpc8hTwY3HjyucyB2W1qfQRcfMiStWQJE/CNQSqHM9c=
github.com/hooklift/gowsdl v0.3.1/go.mod h1:TYmt7jpe3F5zLlMtKGetjHLwUBIAF5JCd+NYq+mQ/Zk=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ichunt2019/go-rabbitmq v1.0.1 h1:qHhpGm9v7jnhSBo3f3viX+BSky9yugp9lCSV03eYsF4= github.com/ichunt2019/go-rabbitmq v1.0.1 h1:qHhpGm9v7jnhSBo3f3viX+BSky9yugp9lCSV03eYsF4=
github.com/ichunt2019/go-rabbitmq v1.0.1/go.mod h1:TQsZ1XWULyvm4UwpYHwNPtOXYbuVvLLI0GM7g/BRy68= github.com/ichunt2019/go-rabbitmq v1.0.1/go.mod h1:TQsZ1XWULyvm4UwpYHwNPtOXYbuVvLLI0GM7g/BRy68=
...@@ -233,6 +235,8 @@ github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= ...@@ -233,6 +235,8 @@ github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU= github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
github.com/templexxx/xor v0.0.0-20181023030647-4e92f724b73b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4= github.com/templexxx/xor v0.0.0-20181023030647-4e92f724b73b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
github.com/tiaguinho/gosoap v1.2.0 h1:K3L29Wk6PkgGob/u24bd4G/rDy5QGnsnDxljAGRRuUM=
github.com/tiaguinho/gosoap v1.2.0/go.mod h1:m/W/ocE01n6v6UkXstKa3ltZvsZLEaxJ9BIs5pRCrZA=
github.com/tjfoc/gmsm v1.0.1/go.mod h1:XxO4hdhhrzAd+G4CjDqaOkd0hUzmtPR/d3EiBBMn/wc= github.com/tjfoc/gmsm v1.0.1/go.mod h1:XxO4hdhhrzAd+G4CjDqaOkd0hUzmtPR/d3EiBBMn/wc=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
...@@ -277,6 +281,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL ...@@ -277,6 +281,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191011234655-491137f69257 h1:ry8e2D+cwaV6hk7lb3aRTjjZo24shrbK0e11QEOkTIg=
golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
...@@ -304,6 +309,7 @@ golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7w ...@@ -304,6 +309,7 @@ golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd h1:3x5uuvBgE6oaXJjCOvpCC1IpgJogqQ+PqGGU3ZxAgII= golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd h1:3x5uuvBgE6oaXJjCOvpCC1IpgJogqQ+PqGGU3ZxAgII=
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
......
...@@ -6,28 +6,62 @@ import ( ...@@ -6,28 +6,62 @@ import (
"time" "time"
) )
const CheckGoodsExistSql = "SELECT goods_id FROM lie_goods WHERE erp_goods_id = ?" const CheckGoodsExistSql = "SELECT goods_id FROM lie_goods WHERE erp_id = ? AND sync_status = 1"
const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`brand_name`,`erp_goods_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?,?)" const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`brand_name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?,?)"
const WriteSyncErrorSql = "UPDATE `lie_goods` SET sync_error = ? WHERE goods_id = ?" const UpdateGoodsSql = "UPDATE `lie_goods` SET `goods_name` = ? , `goods_cn_name` = ? , `brand_name` = ? , `update_time` = ? WHERE `erp_id` = ?"
const DeleteGoodsSql = "DELETE FROM `lie_goods` WHERE `erp_id` = ?"
const WriteGoodsSyncErrorSql = "UPDATE `lie_goods` SET sync_error = ? WHERE goods_id = ?"
const SyncGoodsSuccessSql = "UPDATE `lie_goods` SET sync_status = 1 , sync_time = ? WHERE erp_id = ?"
const SyncGoodsSuccessSqlWithStatus = "UPDATE `lie_goods` SET sync_status = 1 , sync_time = ? , status = ? WHERE erp_id = ?"
//检查物料是否存在 //检查物料是否存在
func CheckGoodsExist(erpId string) (exist bool) { func CheckGoodsExist(erpId string) (exist bool) {
var customerId int var goodsId int
dao.GetDb().QueryRowx(CheckGoodsExistSql, erpId).Scan(&customerId) dao.GetDb().QueryRowx(CheckGoodsExistSql, erpId).Scan(&goodsId)
return customerId > 0 return goodsId > 0
} }
//插入物料 //插入物料
func InsertGoods(goods model.Goods) (err error) { func InsertGoods(goods model.Goods) (err error) {
_, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName, _, err = dao.GetDb().Exec(InsertGoodsSql, goods.GoodsName, goods.GoodsCnName,
goods.BrandName, goods.ErpGoodsId, time.Now().Unix(), 0) goods.BrandName, goods.ErpId, time.Now().Unix(), 0)
return
}
//更新供应商
func UpdateGoods(goods model.Goods) (err error) {
_, err = dao.GetDb().Exec(UpdateGoodsSql, goods.GoodsName, goods.GoodsCnName, goods.BrandName, time.Now().Unix(), goods.ErpId)
if err != nil {
return
}
return nil
}
//删除供应商
func DeleteGoods(erpId string) (err error) {
_, err = dao.GetDb().Exec(DeleteGoodsSql, erpId)
return return
} }
//写入同步失败的原因 //写入同步失败的原因
func WriteSyncError(goodsId int, syncError string) (err error) { func WriteGoodsSyncError(erpId string, syncError string) (err error) {
_, err = dao.GetDb().Exec(WriteSyncErrorSql, syncError, goodsId) _, err = dao.GetDb().Exec(WriteGoodsSyncErrorSql, syncError, erpId)
return
}
//修改成功的同步状态
func SyncGoodsSuccess(erpId string, isDelete bool) (err error) {
//不是删除,不需要修改状态
if !isDelete {
_, err = dao.GetDb().Exec(SyncGoodsSuccessSql, time.Now().Unix(), erpId)
} else {
_, err = dao.GetDb().Exec(SyncGoodsSuccessSqlWithStatus, time.Now().Unix(), 0, erpId)
}
return return
} }
...@@ -4,7 +4,7 @@ type Goods struct { ...@@ -4,7 +4,7 @@ type Goods struct {
GoodsName string GoodsName string
GoodsCnName string GoodsCnName string
BrandName string BrandName string
ErpGoodsId string ErpId string
AddTime int AddTime int
SyncTime int SyncTime int
SyncStatus int SyncStatus int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment