| | |
| | | import ( |
| | | "encoding/json" |
| | | "io/ioutil" |
| | | "kingdee-dbapi/logger" |
| | | "time" |
| | | |
| | | "kingdee-dbapi/cache" |
| | | "kingdee-dbapi/config" |
| | | "kingdee-dbapi/kingdee" |
| | | "kingdee-dbapi/logger" |
| | | "kingdee-dbapi/models" |
| | | "kingdee-dbapi/nsqclient" |
| | | ) |
| | |
| | | //ok := nsqclient.HttpPost(config.Options.OrderTopic, b) |
| | | |
| | | if len(list) == 0 { |
| | | logger.Debug("没有新的订单需要上报") |
| | | logger.Debug("没有新的订单数据") |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | logger.Debug("查询到%d条库存数据", len(list)) |
| | | |
| | | // 先过滤一遍数据, 格瑞米发现有同一个产品同批号同仓库, 有多条库存记录的情况 |
| | | // 将类似的数据库存数累计到一起 |
| | | var filterMap = make(map[string]float64, 0) |
| | | for i := 0; i < len(list); { |
| | | cacheKey := list[i].FNumber + list[i].FBatchNo + list[i].FStockNo |
| | | if qty, ok := filterMap[cacheKey]; ok { |
| | | filterMap[cacheKey] = list[i].FUnitQty + qty |
| | | list = append(list[:i], list[i+1:]...) |
| | | } else { |
| | | filterMap[cacheKey] = list[i].FUnitQty |
| | | i++ |
| | | } |
| | | } |
| | | |
| | | // 过滤数据, 判断是否已经上报过 |
| | | for i := 0; i < len(list); { |
| | | cacheKey := list[i].FNumber + list[i].FBatchNo + list[i].FStockNo |
| | | if qty, ok := invReportedCache[cacheKey]; ok && qty == list[i].FUnitQty { |
| | |
| | | i++ |
| | | } |
| | | } |
| | | |
| | | if len(list) == 0 { |
| | | logger.Debug("没有要更新的库存数据.") |
| | | return |
| | | } |
| | | } |
| | | |
| | | // 每次发 100 条 |
| | | // 每次发 1000 条 |
| | | successCnt := 0 |
| | | for i := 0; i < len(list); i += 1000 { |
| | | end := i + 1000 |