zhangzengfei
2023-08-15 889b82369c9833a9b567dab02cf483210c006563
移除测试代码
2个文件已修改
59 ■■■■ 已修改文件
report/send.go 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
report/task.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
report/send.go
@@ -2,7 +2,6 @@
import (
    "encoding/json"
    "io/ioutil"
    "time"
    "kingdee-dbapi/cache"
@@ -146,10 +145,7 @@
func SendBom(fData bool) {
    // 上报bom
    bomList := kingdee.BomList(fData)
    logger.Debug("查询到%d条Bom数据", len(bomList))
    b, _ := json.Marshal(bomList)
    ioutil.WriteFile("bomList.tmp", b, 0644)
    logger.Debug("查询到%d条BOM数据", len(bomList))
    // 过滤数据, 判断是否已经上报过, 请求全量数据不过滤, 直接上报
    if !fData {
@@ -191,6 +187,7 @@
                successCnt = end
            }
        }
        logger.Debug("已上报%d条BOM数据", successCnt)
    }
@@ -200,34 +197,42 @@
    // 如果请求全量数据, 直接查询所有的数据并发送. 增量上报, 先判断bom是否有更新,然后按bom编码查询子项
    if fData {
        bomChildList = kingdee.BomChild(nil)
        b, _ := json.Marshal(bomChildList)
        ioutil.WriteFile("bomChdList.tmp", b, 0644)
    } else {
        if len(bomList) <= 0 {
            return
        }
        var bomIds []string
        for _, v := range bomList {
            bomIds = append(bomIds, v.FBOMNumber)
        }
        bomChildList = kingdee.BomChild(bomIds)
    }
    logger.Debug("查询到%d条BOM子项数据", len(bomList))
    if len(bomChildList) == 0 {
        logger.Debug("没有要更新的BOM子项数据.")
    } else {
        // 每次发 1000 条
        successCnt := 0
        for i := 0; i < len(bomChildList); i += 1000 {
            end := i + 1000
            if end > len(bomChildList) {
                end = len(bomChildList)
            }
            b, _ := json.Marshal(bomChildList[i:end])
            ok := nsqclient.Produce(config.Options.BomChildTopic, b)
            if !ok {
                logger.Warn("BOM数据上报失败")
            } else {
                successCnt = end
            }
        }
        logger.Debug("已上报%d条BOM子项数据", successCnt)
        return
    }
    // 每次发 1000 条
    successCnt := 0
    for i := 0; i < len(bomChildList); i += 1000 {
        end := i + 1000
        if end > len(bomChildList) {
            end = len(bomChildList)
        }
        b, _ := json.Marshal(bomChildList[i:end])
        ok := nsqclient.Produce(config.Options.BomChildTopic, b)
        if !ok {
            logger.Warn("BOM数据上报失败")
        } else {
            successCnt = end
        }
    }
    logger.Debug("已上报%d条BOM子项数据", successCnt)
}
report/task.go
@@ -42,7 +42,7 @@
            // 上报bom
            if config.Options.BomTopic != "" {
                SendBom(true)
                SendBom(false)
            }
            time.Sleep(time.Duration(config.Options.SyncInterval) * time.Second)