Commit 96ca737d by wang

增加测试连接脚本

parent 60dd16dd
...@@ -30,4 +30,5 @@ cmd.exe~ ...@@ -30,4 +30,5 @@ cmd.exe~
/cmd/http/redisTest /cmd/http/redisTest
/cmd/http /cmd/http
/cmd/test /cmd/test
/cmd/cron/mqtest /cmd/cron/mqtest
\ No newline at end of file /doc/JD
\ No newline at end of file
...@@ -3,7 +3,6 @@ package boot ...@@ -3,7 +3,6 @@ package boot
import ( import (
"go_supplier_task/pkg/config" "go_supplier_task/pkg/config"
"go_supplier_task/pkg/gredis" "go_supplier_task/pkg/gredis"
"go_supplier_task/pkg/mongo"
"go_supplier_task/pkg/mysql" "go_supplier_task/pkg/mysql"
) )
...@@ -19,10 +18,10 @@ func Boot(configPath string) (err error) { ...@@ -19,10 +18,10 @@ func Boot(configPath string) (err error) {
panic(err) panic(err)
return return
} }
if err = mongo.SetUp(); err != nil { /*if err = mongo.SetUp(); err != nil {
panic(err) panic(err)
return return
} }*/
//logger.Loginit() //logger.Loginit()
return return
} }
...@@ -4,6 +4,10 @@ import ( ...@@ -4,6 +4,10 @@ import (
"flag" "flag"
"fmt" "fmt"
"go_supplier_task/boot" "go_supplier_task/boot"
"go_supplier_task/pkg/common"
"go_supplier_task/pkg/gredis"
"go_supplier_task/pkg/mq"
"go_supplier_task/pkg/mysql"
"go_supplier_task/service" "go_supplier_task/service"
) )
...@@ -22,6 +26,14 @@ func main() { ...@@ -22,6 +26,14 @@ func main() {
if err := boot.Boot(path); err != nil { if err := boot.Boot(path); err != nil {
panic(err) panic(err)
} }
//service.NewServiceSupplier().MappingHandle(4)
//service.NewServiceSupplier().MappingHandle(3)
//return
//return
//service.NewServiceSupplier().MappingHandle(3)
//service.NewErpService().SyncErp()
//return
switch taskName { switch taskName {
case "supplierMerge": case "supplierMerge":
fmt.Println("供应商合并") fmt.Println("供应商合并")
...@@ -41,7 +53,52 @@ func main() { ...@@ -41,7 +53,52 @@ func main() {
//return //return
service.NewErpService().SyncErp() service.NewErpService().SyncErp()
break break
case "testConn":
fmt.Println("测试连接")
//return
testConfig()
break
}
}
func testConfig() {
testMysqlConn:=[]string{"supp","cms",
"sku_0",
"sku_1",
"sku_2",
"sku_3",
"sku_4",
"sku_5",
"sku_6",
"sku_7",
"sku_8",
"sku_9",
}
common.PrintStdout().Println("mysql配置连接测试")
for _,table:=range testMysqlConn{
mysql.Conn(table) //spu实例化链接
}
common.PrintStdout().Println("mysql配置连接测试成功")
common.PrintStdout().Println("redis配置连接测试")
redisWriteConn := gredis.Conn("search_w")
defer redisWriteConn.Close()
redisReadConn := gredis.Conn("search_r")
defer redisReadConn.Close()
_, err:= redisWriteConn.Do("PING")
if(err!=nil){
panic(err)
} }
_, err = redisReadConn.Do("PING")
if(err!=nil){
panic(err)
}
common.PrintStdout().Println("redis配置连接测试 成功\n")
common.PrintStdout().Println("rabbmit 配置连接测试")
mq.PushMsg("go_supplier_task_test_conn","1")
common.PrintStdout().Println("rabbmit 配置连接成功")
} }
......
;总配置信息
[web]
port = 60006
mode = debug
[sku_server]
;api_domain = http://192.168.1.237:60014
api_domain = http://localhost:60014
; 比如 sku_save,5000 路径 sku_save 即文件夹是 sku 文件名类似 是save_2020-12-10.log,5000代表队列的容量为5000
[log_config]
1=sku_query,5000
;存放mongodb连接信息
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize=8000
;存放rabmq连接信息 ;存放rabmq连接信息
[rabmq] [rabmq]
url = amqp://guest:guest@192.168.2.232:5672/ url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
wms_name = wms_service_test
...@@ -13,6 +13,7 @@ require ( ...@@ -13,6 +13,7 @@ require (
github.com/go-xorm/xorm v0.7.9 github.com/go-xorm/xorm v0.7.9
github.com/gogf/gf v1.14.5 github.com/gogf/gf v1.14.5
github.com/gogo/protobuf v1.3.1 // indirect github.com/gogo/protobuf v1.3.1 // indirect
github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9
github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/gorilla/websocket v1.4.2 // indirect github.com/gorilla/websocket v1.4.2 // indirect
...@@ -40,6 +41,7 @@ require ( ...@@ -40,6 +41,7 @@ require (
github.com/tidwall/gjson v1.6.1 github.com/tidwall/gjson v1.6.1
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
golang.org/x/text v0.3.3 // indirect golang.org/x/text v0.3.3 // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
......
...@@ -46,9 +46,13 @@ func Setup() error { ...@@ -46,9 +46,13 @@ func Setup() error {
func Conn(conName string) *xorm.Engine { func Conn(conName string) *xorm.Engine {
if value,ok:=DatabaseConMap[conName];ok{ if value,ok:=DatabaseConMap[conName];ok{
if(value!=nil){ if(value!=nil){
err:=value.Ping()
if(err!=nil){
panic("连接:"+conName+"出错:"+err.Error())
}
return value return value
} }
return value
} }
panic("连接:"+conName+"不存在") panic("连接:"+conName+"不存在")
} }
...@@ -17,7 +17,9 @@ type ErpService struct { ...@@ -17,7 +17,9 @@ type ErpService struct {
} }
var CurrencyMapping =map[int]interface{}{ // ""
//0 “”
var CurrencyMapping =map[int]string{
1: "CNY", 1: "CNY",
2 :"USD", 2 :"USD",
3 : "HKD", 3 : "HKD",
...@@ -25,7 +27,7 @@ var CurrencyMapping =map[int]interface{}{ ...@@ -25,7 +27,7 @@ var CurrencyMapping =map[int]interface{}{
5 : "GBP", 5 : "GBP",
6 : "CHF", 6 : "CHF",
} }
var StatusMapping=map[int]interface{}{ var StatusMapping=map[int]string{
2:"1", 2:"1",
-2:"2", -2:"2",
} }
...@@ -40,6 +42,15 @@ var SupplierGroup =map[int]interface{}{ ...@@ -40,6 +42,15 @@ var SupplierGroup =map[int]interface{}{
} }
type SupplierSyncLog struct {
Id int64 `json:"id"`
SupplierId int64 `json:"supplier_id"`
ErpSyncStatus int `json:"erp_sync_status"`
ErpSupplierName string `json:"erp_supplier_name"`
LastUpdateSource int `json:"last_update_source"`
AddTime int `json:"add_time" xorm:"created"`
UpdateTime int `json:"update_time" xorm:"updated"`
}
...@@ -52,6 +63,7 @@ func (this *ErpService) SyncErp() { ...@@ -52,6 +63,7 @@ func (this *ErpService) SyncErp() {
dbSpu:= mysql.Conn("supp") //spu实例化链接 dbSpu:= mysql.Conn("supp") //spu实例化链接
supplierId:=int64(0) supplierId:=int64(0)
supplierId=178
for{ for{
poolSupplierEntity:=&PoolSupplierEntity{} poolSupplierEntity:=&PoolSupplierEntity{}
count:=0 count:=0
...@@ -69,7 +81,7 @@ func (this *ErpService) SyncErp() { ...@@ -69,7 +81,7 @@ func (this *ErpService) SyncErp() {
} }
count++ count++
supplierId=gconv.Int64(poolSupplierEntity.SupplierId) supplierId=gconv.Int64(poolSupplierEntity.SupplierId)
this.pushErp(poolSupplierEntity) this.pushErp2(poolSupplierEntity)
} }
if(count==0){ if(count==0){
rows.Close() rows.Close()
...@@ -79,6 +91,68 @@ func (this *ErpService) SyncErp() { ...@@ -79,6 +91,68 @@ func (this *ErpService) SyncErp() {
} }
type ErpPushData struct {
Name string `json:"name,omitempty"`
ShortName string `json:"shortName,omitempty"`
CurrencyNumber string `json:"currencyNumber,omitempty"`
TaxRegisterNo string `json:"taxRegisterNo,omitempty"`
PTID string `json:"PTID,omitempty"`
STATUS string `json:"STATUS,omitempty"`
PersonName []string `json:"personName,omitempty"`
Address string `json:"address,omitempty"`
ContactPerson string `json:"contactPerson,omitempty"`
Phone string `json:"phone,omitempty"`
GroupNumber string `json:"groupNumber,omitempty"`
}
func (this *ErpService) pushErp2(poolSupplierEntity *PoolSupplierEntity) {
/**
{"name":"深圳市朋友有限責任公司",
"shortName":"朋友",
"currencyNumber":"CNY",
"groupNumber":"C",
"taxRegisterNo":"66666",
"personName":["张右辉","杨婷婷"],
"PTID":"12324",
"STATUS":"1",
"address":"深圳市龙岗区坂田街道",
"contactPerson":"张莹",
"phone":"15637258888"
}
*/
erpPushData:=ErpPushData{}
erpPushData.Name=poolSupplierEntity.SupplierName
erpPushData.CurrencyNumber=CurrencyMapping[poolSupplierEntity.Currency]
erpPushData.TaxRegisterNo=poolSupplierEntity.TaxNumber
erpPushData.PTID=poolSupplierEntity.SupplierCode
erpPushData.STATUS=StatusMapping[poolSupplierEntity.Status]
personName:=this.GetPersonNames(poolSupplierEntity)
erpPushData.PersonName=personName
erpPushData.Address=poolSupplierEntity.SupplierAddress
has,contactInfo:=this.GetContact(poolSupplierEntity.SupplierId)
if(!has){
common.PrintStdout().Printf("supplierID:%d,没有找到对应的contact 数据",poolSupplierEntity.SupplierId)
}else{
erpPushData.ContactPerson=contactInfo["supplier_consignee"]
erpPushData.Phone=contactInfo["supplier_telephone"]
}
erpPushData.GroupNumber=gconv.String(SupplierGroup[poolSupplierEntity.SupplierGroup])
bytes,err:=json.Marshal(erpPushData)
if(err!=nil){
syncLog.SyncInsertLog("erp_merger", ErpTaskName+"同步erp数据 json.Marshal 出错,err:"+err.Error())
panic(nil)
}
fmt.Println(string(bytes))
//this.recordErpPushLog(poolSupplierEntity.SupplierId)
mq.PushMsg("supplier_sync",string(bytes))
common.PrintStdout().Printf("supplierID:%d,压入队列成功\n",poolSupplierEntity.SupplierId)
//panic("推出一条就退出")
}
func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) { func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) {
/** /**
{"name":"深圳市朋友有限責任公司", {"name":"深圳市朋友有限責任公司",
...@@ -94,6 +168,7 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) { ...@@ -94,6 +168,7 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) {
"phone":"15637258888" "phone":"15637258888"
} }
*/ */
pushErpData:=make(map[string]interface{}) pushErpData:=make(map[string]interface{})
pushErpData["name"]=poolSupplierEntity.SupplierName pushErpData["name"]=poolSupplierEntity.SupplierName
pushErpData["shortName"]="" pushErpData["shortName"]=""
...@@ -114,7 +189,6 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) { ...@@ -114,7 +189,6 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) {
pushErpData["phone"]=contactInfo["supplier_telephone"] pushErpData["phone"]=contactInfo["supplier_telephone"]
} }
pushErpData["groupNumber"]=gconv.String(SupplierGroup[poolSupplierEntity.SupplierGroup]) pushErpData["groupNumber"]=gconv.String(SupplierGroup[poolSupplierEntity.SupplierGroup])
bytes,err:=json.Marshal(pushErpData) bytes,err:=json.Marshal(pushErpData)
...@@ -124,12 +198,12 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) { ...@@ -124,12 +198,12 @@ func (this *ErpService) pushErp(poolSupplierEntity *PoolSupplierEntity) {
} }
fmt.Println(string(bytes)) fmt.Println(string(bytes))
mq.PushMsg("supplier_sync",string(bytes)) mq.PushMsg("supplier_sync",string(bytes))
//fmt.Println(poolSupplierEntity) fmt.Println(poolSupplierEntity)
common.PrintStdout().Printf("supplierID:%d,压入队列成功\n",poolSupplierEntity.SupplierId) //common.PrintStdout().Printf("supplierID:%d,压入队列成功\n",poolSupplierEntity.SupplierId)
panic("推出一条就退出")
} }
/* /*
待续 获取联系信息
*/ */
func (this *ErpService) GetContact(supplierId int64) ( bool, map[string]string ){ func (this *ErpService) GetContact(supplierId int64) ( bool, map[string]string ){
dbSpu := mysql.Conn("supp") //spu实例化链接 dbSpu := mysql.Conn("supp") //spu实例化链接
...@@ -146,7 +220,7 @@ func (this *ErpService) GetContact(supplierId int64) ( bool, map[string]string ) ...@@ -146,7 +220,7 @@ func (this *ErpService) GetContact(supplierId int64) ( bool, map[string]string )
} }
} }
//获取采购员信息
func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]string{ func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]string{
//poolSupplierEntity.ChannelUid="1366,1363" //poolSupplierEntity.ChannelUid="1366,1363"
adminIds:=strings.Split(poolSupplierEntity.ChannelUid, ",") adminIds:=strings.Split(poolSupplierEntity.ChannelUid, ",")
...@@ -165,7 +239,6 @@ func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]s ...@@ -165,7 +239,6 @@ func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]s
syncLog.SyncInsertLog("mapping_insert",errmsg,syncLog.LogLevelFatal) syncLog.SyncInsertLog("mapping_insert",errmsg,syncLog.LogLevelFatal)
panic(nil) panic(nil)
} }
channelNameS:=make([]string,0) channelNameS:=make([]string,0)
for _,cmsOne:=range cmsEntitys{ for _,cmsOne:=range cmsEntitys{
channelNameS=append(channelNameS,cmsOne.Name) channelNameS=append(channelNameS,cmsOne.Name)
...@@ -173,3 +246,32 @@ func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]s ...@@ -173,3 +246,32 @@ func (this *ErpService)GetPersonNames(poolSupplierEntity *PoolSupplierEntity)[]s
return channelNameS return channelNameS
} }
//加入日志
func (this *ErpService)recordErpPushLog(supplierId int64) {
log:=SupplierSyncLog{SupplierId:supplierId}
dbSupp := mysql.Conn("supp") //spu实例化链接
has,err:=dbSupp.Table("lie_supplier_sync").Get(&log)
log.LastUpdateSource=2
log.ErpSyncStatus=0
if(err!=nil){
syncLog.SyncInsertLog("erp_merger", ErpTaskName+"查询 lie_supplier_sync 出错,err:"+err.Error())
panic(nil)
}
if(has){//修改
cols:=[]string{"update_time","last_update_source","erp_sync_status"}
_,err:= dbSupp.Table("lie_supplier_sync").Where("supplier_id=?",supplierId).Cols(cols...).Update(log)
if(err!=nil){
syncLog.SyncInsertLog("erp_merger", ErpTaskName+"修改 lie_supplier_sync 报错,err:"+err.Error())
panic(nil)
}
common.PrintStdout().Printf("supplierID:%d,修改日志成功\n",supplierId)
}else{//新增
_,err:=dbSupp.Table("lie_supplier_sync").Insert(log)
if(err!=nil){
syncLog.SyncInsertLog("erp_merger", ErpTaskName+"插入 lie_supplier_sync 报错,err:"+err.Error())
panic(nil)
}
common.PrintStdout().Printf("supplierID:%d,新增日志成功\n",supplierId)
}
}
\ No newline at end of file
...@@ -9,12 +9,13 @@ import ( ...@@ -9,12 +9,13 @@ import (
syncLog "go_supplier_task/pkg/logger/sync" syncLog "go_supplier_task/pkg/logger/sync"
"go_supplier_task/pkg/mysql" "go_supplier_task/pkg/mysql"
"strings" "strings"
"time"
) )
var TaskName string var TaskName string
var SupplierGroupCn =map[string]interface{}{ var SupplierGroupCn =map[string]interface{}{
"代理" : 1, "代理" : 1,
"贸易商" : 2, "贸易商" : 2,
"方案商IDH/IDM" : 3, "方案商IDH/IDM" : 3,
"原厂" : 4, "原厂" : 4,
...@@ -75,8 +76,8 @@ func (this *ServiceSupplier)MappingHandle(MappingType int) { ...@@ -75,8 +76,8 @@ func (this *ServiceSupplier)MappingHandle(MappingType int) {
NewMapping:=SupplierMappingEntity{ NewMapping:=SupplierMappingEntity{
OldSupplierCode:OldSupplier["canal"], OldSupplierCode:OldSupplier["canal"],
SupplierCode:dbSuplierInfo.SupplierCode, SupplierCode:dbSuplierInfo.SupplierCode,
OldSupplierName:OldSupplier["oldName"], OldSupplierName:strings.Replace(OldSupplier["oldName"],"?"," ",10),
SupplierName:dbSuplierInfo.SupplierName, SupplierName:strings.Replace(dbSuplierInfo.SupplierName,"?"," ",10),
SupplierId:int(dbSuplierInfo.SupplierId), SupplierId:int(dbSuplierInfo.SupplierId),
Source:MappingType, Source:MappingType,
} }
...@@ -92,7 +93,7 @@ func (this *ServiceSupplier)MappingHandle(MappingType int) { ...@@ -92,7 +93,7 @@ func (this *ServiceSupplier)MappingHandle(MappingType int) {
/** /**
获取指定 supplierName 的供应商详情(状态是2的,is_type=0的),没有就新增 获取指定 supplierName 的供应商详情,将其改成is_type =0,没有就新增
@purchaseNames 采购员s(excel 一个标准供应商有多个供应商,可能每个供应商都有采购员),用作新增供应商修改采购商 @purchaseNames 采购员s(excel 一个标准供应商有多个供应商,可能每个供应商都有采购员),用作新增供应商修改采购商
@groupName 分组名称 @groupName 分组名称
*/ */
...@@ -107,10 +108,17 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase ...@@ -107,10 +108,17 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
} }
has,poolSupplierEntity:=this.onlyOpenHandle(supplierName,poolSupplierEntitys) has,poolSupplierEntity:=this.onlyOpenHandle(supplierName,poolSupplierEntitys)
if(has==true){ if(has==true){
//组装采购员 //组装采购员
channelUidString:=this.assembleChannelUid(purchaseNames) oldUids:=php2go.Explode(",",poolSupplierEntity.ChannelUid)
channelUidString:=this.assembleChannelUid(purchaseNames,oldUids...)
poolSupplierEntity.ChannelUid=channelUidString poolSupplierEntity.ChannelUid=channelUidString
//分组
if gconv.Int(poolSupplierEntity.SupplierGroup)==0{
poolSupplierEntity.SupplierGroup= gconv.Int(SupplierGroupCn[groupName])
}
//审核人
this.AuditDataHandle(&poolSupplierEntity)
//修改 //修改
_,err= dbSpu.Table("lie_supplier_channel").Where("supplier_id=?",poolSupplierEntity.SupplierId).Update(&poolSupplierEntity) _,err= dbSpu.Table("lie_supplier_channel").Where("supplier_id=?",poolSupplierEntity.SupplierId).Update(&poolSupplierEntity)
if(err!=nil){ if(err!=nil){
...@@ -125,7 +133,7 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase ...@@ -125,7 +133,7 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
common.PrintStdout().Printf("不存在此标准供应商,供应商名:%s,进行新增",supplierName) common.PrintStdout().Printf("不存在此标准供应商,供应商名:%s,进行新增",supplierName)
poolSupplierEntity:=PoolSupplierEntity{} poolSupplierEntity:=PoolSupplierEntity{}
poolSupplierEntity.Status=2 poolSupplierEntity.Status=2
poolSupplierEntity.SupplierName=supplierName poolSupplierEntity.SupplierName=strings.Replace(supplierName,"?"," ",10)
_,err:= dbSpu.Table("lie_supplier_channel").Insert(&poolSupplierEntity) _,err:= dbSpu.Table("lie_supplier_channel").Insert(&poolSupplierEntity)
if(err!=nil){ if(err!=nil){
syncLog.SyncInsertLog("mapping_insert","[插入映射-新增标准]出错:"+"供应商标准名称:"+supplierName+err.Error(),syncLog.LogLevelFatal) syncLog.SyncInsertLog("mapping_insert","[插入映射-新增标准]出错:"+"供应商标准名称:"+supplierName+err.Error(),syncLog.LogLevelFatal)
...@@ -141,6 +149,9 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase ...@@ -141,6 +149,9 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
channelUidString:=this.assembleChannelUid(purchaseNames) channelUidString:=this.assembleChannelUid(purchaseNames)
poolSupplierEntity.ChannelUid=channelUidString poolSupplierEntity.ChannelUid=channelUidString
//end //end
//审核人
this.AuditDataHandle(&poolSupplierEntity)
//新增人 //新增人
poolSupplierEntity.CreateUid=1000 poolSupplierEntity.CreateUid=1000
poolSupplierEntity.CreateName="admin" poolSupplierEntity.CreateName="admin"
...@@ -158,8 +169,17 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase ...@@ -158,8 +169,17 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
} }
} }
//组装次啊够远 /**
func (this *ServiceSupplier) assembleChannelUid(purchaseNames []interface{}) string { 审核人
*/
func (this *ServiceSupplier) AuditDataHandle(poolSupplierEntity *PoolSupplierEntity) {
poolSupplierEntity.AuditName="符静"
poolSupplierEntity.AuditUid=10177
poolSupplierEntity.AuditTime=int(time.Now().Unix())
}
//组装采购员
func (this *ServiceSupplier) assembleChannelUid(purchaseNames []interface{},oldUidS ...string) string {
//组装采购员 //组装采购员
cmsEntitys:=[]CmsEntity{}//采购员 cmsDB数据 cmsEntitys:=[]CmsEntity{}//采购员 cmsDB数据
dbCms:= mysql.Conn("cms") //spu实例化链接 dbCms:= mysql.Conn("cms") //spu实例化链接
...@@ -179,6 +199,22 @@ func (this *ServiceSupplier) assembleChannelUid(purchaseNames []interface{}) str ...@@ -179,6 +199,22 @@ func (this *ServiceSupplier) assembleChannelUid(purchaseNames []interface{}) str
for _,cmsOne:=range cmsEntitys{ for _,cmsOne:=range cmsEntitys{
channelUidS=append(channelUidS,cmsOne.CodeId) channelUidS=append(channelUidS,cmsOne.CodeId)
} }
if(len(oldUidS)>0){
for _,uid:=range oldUidS{
if(uid!="0" && uid!=""){
skip:=false
for _,cmsOne:=range cmsEntitys{
if cmsOne.CodeId==uid{
skip=true
}
}
if(skip==true){
continue
}
channelUidS=append(channelUidS,uid)
}
}
}
channelUidString=php2go.Implode(",",channelUidS) channelUidString=php2go.Implode(",",channelUidS)
return channelUidString return channelUidString
//end //end
...@@ -194,7 +230,7 @@ func (this *ServiceSupplier) InsertMapping(SupplierInfoOne SupplierMappingEntity ...@@ -194,7 +230,7 @@ func (this *ServiceSupplier) InsertMapping(SupplierInfoOne SupplierMappingEntity
触发唯一索引 触发唯一索引
UNIQUE KEY `source_name_unique` (`old_supplier_name`,`source`) UNIQUE KEY `source_name_unique` (`old_supplier_name`,`source`)
*/ */
if(mysqlErr.Number==1062 && strings.Contains(mysqlErr.Message,"source_name_unique")){// if(mysqlErr.Number==1062 && strings.Contains(mysqlErr.Message,"source_code_unique")){//
errMsg:=fmt.Sprintf(TaskName+"[插入映射]跳过:有重复的映射关系 type:%d,标准名称:%s,标准ID:%d,errmsg:%s",SupplierInfoOne.Source,SupplierInfoOne.SupplierName,SupplierInfoOne.SupplierId,err.Error()) errMsg:=fmt.Sprintf(TaskName+"[插入映射]跳过:有重复的映射关系 type:%d,标准名称:%s,标准ID:%d,errmsg:%s",SupplierInfoOne.Source,SupplierInfoOne.SupplierName,SupplierInfoOne.SupplierId,err.Error())
syncLog.SyncInsertLog("mapping_insert",errMsg,syncLog.LogLevelFatal) syncLog.SyncInsertLog("mapping_insert",errMsg,syncLog.LogLevelFatal)
return return
......
...@@ -59,6 +59,9 @@ func (this *ServiceSupplier)MergerCriteria() { ...@@ -59,6 +59,9 @@ func (this *ServiceSupplier)MergerCriteria() {
common.PrintStdout().Printf("[整合标准数据]完成\n") common.PrintStdout().Printf("[整合标准数据]完成\n")
} }
//新供应商 审核时间,更新时间
//启用唯一一个供应商处理 //启用唯一一个供应商处理
func (this *ServiceSupplier) onlyOpenHandle(groupName string,PoolSupplierEntitys []PoolSupplierEntity,updateCols ...string)(isExis bool,oneSupplierEntity PoolSupplierEntity){ func (this *ServiceSupplier) onlyOpenHandle(groupName string,PoolSupplierEntitys []PoolSupplierEntity,updateCols ...string)(isExis bool,oneSupplierEntity PoolSupplierEntity){
/** /**
......
...@@ -29,6 +29,11 @@ type PoolSupplierEntity struct { ...@@ -29,6 +29,11 @@ type PoolSupplierEntity struct {
CreateName string `json:"create_name" ` CreateName string `json:"create_name" `
CreateUid int `json:"create_uid" ` CreateUid int `json:"create_uid" `
//激活的供应商 更改
AuditUid int `json:"audit_uid" `//审核人
AuditTime int `json:"audit_time"`//审核时间
AuditName string `json:"audit_name" `//审核人名字
} }
//映射表 //映射表
......
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