Commit 8936a131 by wang

更改一些bug

parent 46e21aca
......@@ -22,6 +22,8 @@ func main() {
if err := boot.Boot(path); err != nil {
panic(err)
}
//service.NewServiceSupplier().MergerCriteria()
//return
//service.NewServiceLy().Merger()
//service.NewErpService().SyncErp()
//return
......
[xorm]
ShowSQL = true
ShowSQL = false
[pool_class]
user_name = root
......
......@@ -13,7 +13,7 @@ type LySkuEntity struct {
GoodsId string `json:"goods_id"`
Encoded string `json:"encoded"`//内部编码
Canal string `json:"canal" form:"canal" `//供应商编码-渠道标签
UpdateTime int `json:"update_time" xorm:"created"`
UpdateTime int `json:"update_time" xorm:"updated"`
}
//将 LySkuEntity 的值赋值到 SkuRedisInfo(两个结构字段和类型不一样不会赋值)
......
......@@ -562,7 +562,7 @@
6297,深圳市禾耀科技发展有限公司,深圳市禾耀科技发展有限公司,ZY0000015,,代理,
6301,深圳市鸿源精密器材有限公司,深圳市鸿源精密器材有限公司,ZY0000220,,原厂,
6311,深圳市因德尔科技有限公司,深圳市因德尔科技有限公司,ZY0000230,,代理,
6327,深圳市同泰科技有限公司,深圳市同泰科技有限公司,ZY0000270,,代理,
6333,山东宝乘电子有限公司,山东宝乘电子有限公司,ZY0000261,,原厂,
6363,深圳市天微电子股份有限公司,深圳市天微电子股份有限公司,ZY0000057,,原厂,
6385,深圳市金碧电子科技有限公司,深圳市金碧电子科技有限公司,ZY0000121,,代理,
......
package service
/**
(9462, 'L0009462', 'SURLINK INTERNATIONAL LTD', 'L0007633', '', 1, 0, 0, 0, '', 1, '', 0, 0, 0, 1368, 0, 2, 0, 10141, 10141, 0, 0, '', '', '', '', '', '', '1.00', '1.00', 1, 0),
(9463, 'L0009463', 'UNICHEER TECHNOLOGY CO.,LIMITED', 'L0007648', '', 1, 0, 0, 0, '', 1, '', 0, 0, 0, 1368, 0, 2, 1, 10141,
*/
import (
"encoding/json"
"fmt"
......@@ -10,6 +15,7 @@ import (
"go_supplier_task/pkg/common"
syncLog "go_supplier_task/pkg/logger/sync"
"go_supplier_task/pkg/mysql"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"strings"
"time"
......@@ -37,16 +43,20 @@ func (this *ServiceLy) Merger() {
maxNumTable:=10
maxNumDataBase:=10
for dataBaseNum:=0;dataBaseNum<maxNumDataBase;dataBaseNum++ {
common.PrintStdout().Printf("%s,第%d个数据库开始",LyTaskName,dataBaseNum)
for tableNum:=0;tableNum<maxNumTable;tableNum++ {
common.PrintStdout().Printf("%s,第%d个表开始",LyTaskName,tableNum)
dataBaseConn:=fmt.Sprintf("sku_%d",dataBaseNum)
tableName:=fmt.Sprintf("lie_sku_%d",tableNum)
skuDb:= mysql.Conn(dataBaseConn) //连接
totalNum,err:=skuDb.Table(tableName).Where("supplier_id=? and canal!=''",17).Count()
//countRes,err:=skuDb.QueryString("SELECT count(*) count from ? where supplier_id=? and canal!=''",tableName,17)
if err != nil {
syncLog.SyncInsertLog("ly_merger",LyTaskName+"查询sku出错,err:"+err.Error())
panic(nil)
}
common.PrintStdout().Printf("%s,||||||||||||||||||||||第%d个库第%d个表开始,需处理数据%d条||||||||||||\n",LyTaskName,dataBaseNum,tableNum,totalNum)
goodsId:=int64(0)
for {
count:=0
lYSkuEntity:= &model.LySkuEntity{}
rows,err:= skuDb.Table(tableName).Where("goods_id>? and supplier_id=? and canal!=''",goodsId,17).OrderBy("goods_id",).Limit(10).Rows(lYSkuEntity)
if err != nil {
......@@ -61,6 +71,7 @@ func (this *ServiceLy) Merger() {
}
count++
goodsId=gconv.Int64(lYSkuEntity.GoodsId)
common.PrintStdout().Printf("%s,goodsid:%d 处理中\n",LyTaskName,goodsId)
this.updateDBRedisMongo(lYSkuEntity,skuDb,tableName)//修改redis、mongoDb、mysqldb、日志
}
if(count==0){
......@@ -124,14 +135,23 @@ func (this *ServiceLy) updateDBRedisMongo(lySkuEntity *model.LySkuEntity,dbconn
update:=bson.M{"canal": canal}
err=skuCache.MongoUpdateSku(lySkuEntity.GoodsId,update)
if(err!=nil){
msg:=fmt.Sprintf("%s 修改mongosku数据出错,goodsId:%s,err:%s,updateData:%s",LyTaskName,lySkuEntity.GoodsId,err.Error(),update)
syncLog.SyncInsertLog("ly_merger",msg)
if(err==mgo.ErrNotFound){
msg:=fmt.Sprintf("%s 在mongo sku不存在,goodsId:%s,err:%s,updateData:%s",LyTaskName,lySkuEntity.GoodsId,err.Error(),update)
syncLog.SyncInsertLog("ly_merger",msg)
}else{
msg:=fmt.Sprintf("%s 修改mongosku数据出错,goodsId:%s,err:%s,updateData:%s",LyTaskName,lySkuEntity.GoodsId,err.Error(),update)
syncLog.SyncInsertLog("ly_merger",msg)
}
//回滚redis
common.PrintStdout().Printf("因mongodb错误,正在回滚redis\n")
oldSkuRedisInfoMap["canal"]=lySkuEntity.Canal
this.insertRedisSkuInfo(lySkuEntity.GoodsId,newSkuRedisInfoMap)
common.PrintStdout().Printf("回滚redis成功, 程序结束\n")
panic(nil)
common.PrintStdout().Printf("回滚redis成功,\n")
if(err!=mgo.ErrNotFound){
panic(nil)
}
return
}
//=====================修改mongo end======================
......@@ -173,7 +193,7 @@ func (this *ServiceLy) updateDBRedisMongo(lySkuEntity *model.LySkuEntity,dbconn
panic(nil)
}
common.PrintStdout().Printf("goodsId:%s,操作成功",lySkuEntity.GoodsId)
panic(nil)
//panic(nil)
//===================修改DB 和增加日志end====================
}else{//没有映射数据
......
......@@ -127,6 +127,9 @@ func (this *ServiceSupplier) GetStatus2SupplierInfo(supplierName string,purchase
//组装采购员
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)
......
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