Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wang
/
go_supplier_task
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
60dd16dd
authored
Mar 17, 2021
by
wang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改供应商修改采购员
parent
8936a131
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
47 deletions
cmd/cron/merge/cron.go
readme.md
service/service_mapping.go
service/service_supplier.go
cmd/cron/merge/cron.go
View file @
60dd16dd
...
...
@@ -22,17 +22,32 @@ func main() {
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
panic
(
err
)
}
//service.NewServiceSupplier().MergerCriteria()
//return
//service.NewServiceLy().Merger()
//service.NewErpService().SyncErp()
//return
//service.NewServiceSupplier().MergerCriteria()
//service.NewServiceSupplier().MappingHandle(2)
//return
switch
taskName
{
case
"supplierMerge"
:
fmt
.
Println
(
"供应商合并"
)
service
.
NewServiceSupplier
()
.
MergerCriteria
()
service
.
NewServiceSupplier
()
.
MappingHandle
(
1
)
service
.
NewServiceSupplier
()
.
MappingHandle
(
2
)
service
.
NewServiceSupplier
()
.
MappingHandle
(
4
)
service
.
NewServiceSupplier
()
.
MappingHandle
(
3
)
break
case
"lySkuMerge"
:
fmt
.
Println
(
"联营sku整合"
)
//return
service
.
NewServiceLy
()
.
Merger
()
//联营sku整合
break
case
"erpSkuMerge"
:
fmt
.
Println
(
"erpSku整合"
)
//return
switch
taskName
{
service
.
NewErpService
()
.
SyncErp
()
break
}
}
func
back
()
{
/*switch taskName {
case "supplierMerge":
fmt.Println("供应商合并")
//return
...
...
@@ -65,11 +80,5 @@ func main() {
//return
service.NewErpService().SyncErp()
break
}
//fmt.Println("啥也没执行")
//service.NewServiceSupplier().MergerCriteria()//标准供应商处理
//service.NewServiceSupplier().MappingHandle(2)//映射处理(1,联营 2,erp 3,自营)
}*/
}
readme.md
View file @
60dd16dd
...
...
@@ -8,17 +8,11 @@ export GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go build -o ./cmd/cron/merge/cron ./cmd/cron/merge/cron.go
### 二:运行:在根目录运行(说明:须按照顺序执行)
##### 1.运行 供应商合并脚本(整理标准供应商,
禁用启用之类操作
)
##### 1.运行 供应商合并脚本(整理标准供应商,
整合erp映射,自营映射,联营映射
)
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=supplierMerge
##### 2.运行 ERP映射处理脚本(ERP供应商与标准联营映射处理)
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=erpMapping
##### 3.运行 自营映射处理脚本(自营供应商与标准联营映射处理)
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=zyMapping
##### 4.运行 联营映射处理脚本
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=lyMapping
##### 5.运行 同步到ERP脚本处理(将标准供应商压入到队列)
##### 2.运行 同步到ERP脚本处理(将标准供应商压入到队列)
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=erpSkuMerge
#####
6
运行 联营sku同步
#####
3
运行 联营sku同步
./cmd/cron/merge/cron -config=./conf/prod/ -taskName=lySkuMerge
...
...
service/service_mapping.go
View file @
60dd16dd
...
...
@@ -107,6 +107,19 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
}
has
,
poolSupplierEntity
:=
this
.
onlyOpenHandle
(
supplierName
,
poolSupplierEntitys
)
if
(
has
==
true
){
//组装采购员
channelUidString
:=
this
.
assembleChannelUid
(
purchaseNames
)
poolSupplierEntity
.
ChannelUid
=
channelUidString
//修改
_
,
err
=
dbSpu
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"supplier_id=?"
,
poolSupplierEntity
.
SupplierId
)
.
Update
(
&
poolSupplierEntity
)
if
(
err
!=
nil
){
errmsg
:=
fmt
.
Sprintf
(
TaskName
+
"[修改编码]出错:供应商标准名称:%s;%s;id:%d"
,
supplierName
,
err
.
Error
(),
poolSupplierEntity
.
SupplierId
)
syncLog
.
SyncInsertLog
(
"mapping_insert"
,
errmsg
,
syncLog
.
LogLevelFatal
)
panic
(
nil
)
//panic("[插入映射-修改编码]出错:"+"供应商标准名称:"+supplierName+err.Error())
}
//end
return
poolSupplierEntity
}
else
{
common
.
PrintStdout
()
.
Printf
(
"不存在此标准供应商,供应商名:%s,进行新增"
,
supplierName
)
...
...
@@ -125,25 +138,7 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
//end
//组装采购员
cmsEntitys
:=
[]
CmsEntity
{}
//采购员 cmsDB数据
dbCms
:=
mysql
.
Conn
(
"cms"
)
//spu实例化链接
if
(
len
(
purchaseNames
)
==
0
){
purchaseNames
=
append
(
purchaseNames
,
"0"
)
}
err
=
dbCms
.
Table
(
"user_info"
)
.
Join
(
"INNER"
,
"lie_intracode"
,
"user_info.userId=lie_intracode.admin_id"
)
.
In
(
"user_info.name"
,
purchaseNames
...
)
.
Find
(
&
cmsEntitys
)
if
(
err
!=
nil
){
errmsg
:=
fmt
.
Sprintf
(
TaskName
+
"[获取采购商编码]出错:供应商标准名称:%s;%s;id:%d"
,
poolSupplierEntity
.
SupplierName
,
err
.
Error
(),
poolSupplierEntity
.
SupplierId
)
syncLog
.
SyncInsertLog
(
"mapping_insert"
,
errmsg
,
syncLog
.
LogLevelFatal
)
panic
(
nil
)
}
channelUidString
:=
""
channelUidS
:=
make
([]
string
,
0
)
for
_
,
cmsOne
:=
range
cmsEntitys
{
channelUidS
=
append
(
channelUidS
,
cmsOne
.
CodeId
)
}
channelUidString
=
php2go
.
Implode
(
","
,
channelUidS
)
channelUidString
:=
this
.
assembleChannelUid
(
purchaseNames
)
poolSupplierEntity
.
ChannelUid
=
channelUidString
//end
//新增人
...
...
@@ -163,6 +158,31 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
}
}
//组装次啊够远
func
(
this
*
ServiceSupplier
)
assembleChannelUid
(
purchaseNames
[]
interface
{})
string
{
//组装采购员
cmsEntitys
:=
[]
CmsEntity
{}
//采购员 cmsDB数据
dbCms
:=
mysql
.
Conn
(
"cms"
)
//spu实例化链接
if
(
len
(
purchaseNames
)
==
0
){
purchaseNames
=
append
(
purchaseNames
,
"0"
)
}
err
:=
dbCms
.
Table
(
"user_info"
)
.
Join
(
"INNER"
,
"lie_intracode"
,
"user_info.userId=lie_intracode.admin_id"
)
.
In
(
"user_info.name"
,
purchaseNames
...
)
.
Find
(
&
cmsEntitys
)
if
(
err
!=
nil
){
errmsg
:=
fmt
.
Sprintf
(
TaskName
+
"[获取采购商编码]出错:获取采购员出错:"
+
fmt
.
Sprint
(
purchaseNames
))
syncLog
.
SyncInsertLog
(
"mapping_insert"
,
errmsg
,
syncLog
.
LogLevelFatal
)
panic
(
nil
)
}
channelUidString
:=
""
channelUidS
:=
make
([]
string
,
0
)
for
_
,
cmsOne
:=
range
cmsEntitys
{
channelUidS
=
append
(
channelUidS
,
cmsOne
.
CodeId
)
}
channelUidString
=
php2go
.
Implode
(
","
,
channelUidS
)
return
channelUidString
//end
}
//插入映射
func
(
this
*
ServiceSupplier
)
InsertMapping
(
SupplierInfoOne
SupplierMappingEntity
)
{
...
...
@@ -175,7 +195,7 @@ func (this *ServiceSupplier) InsertMapping(SupplierInfoOne SupplierMappingEntity
UNIQUE KEY `source_name_unique` (`old_supplier_name`,`source`)
*/
if
(
mysqlErr
.
Number
==
1062
&&
strings
.
Contains
(
mysqlErr
.
Message
,
"source_name_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
)
return
//不退出进程
...
...
service/service_supplier.go
View file @
60dd16dd
...
...
@@ -71,7 +71,7 @@ func (this *ServiceSupplier) onlyOpenHandle(groupName string,PoolSupplierEntity
criterionSupplierEntity
:=
PoolSupplierEntity
{}
//标准供应商
has
,
err
:=
dbSpu
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"status=? and supplier_name=?"
,
2
,
groupName
)
.
Get
(
&
criterionSupplierEntity
)
if
(
err
!=
nil
){
errMsg
:=
"[
整合标准数据][
插入映射-查询标准]查询标供应商出错:"
+
"供应商标准名称:"
+
groupName
+
err
.
Error
()
errMsg
:=
"[插入映射-查询标准]查询标供应商出错:"
+
"供应商标准名称:"
+
groupName
+
err
.
Error
()
syncLog
.
SyncInsertLog
(
"merger_criteria"
,
errMsg
,
syncLog
.
LogLevelFatal
)
panic
(
nil
)
...
...
@@ -79,7 +79,7 @@ func (this *ServiceSupplier) onlyOpenHandle(groupName string,PoolSupplierEntity
var
onlyOpenSupplier
PoolSupplierEntity
isUpdate
:=
false
//组里有状态为2(启用)的,并且对其更新了
if
(
has
){
common
.
PrintStdout
()
.
Printf
(
"
[整合标准数据]
已经存在标准供应商:"
+
groupName
+
""
)
common
.
PrintStdout
()
.
Printf
(
"已经存在标准供应商:"
+
groupName
+
""
)
isUpdate
=
true
onlyOpenSupplier
=
criterionSupplierEntity
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment