zhangzengfei
2023-09-11 1873461012c99801f364bd07fae2c218d245048e
report/send.go
@@ -2,7 +2,6 @@
import (
   "encoding/json"
   "io/ioutil"
   "time"
   "kingdee-dbapi/cache"
@@ -147,6 +146,11 @@
   var bomList []kingdee.ICBom
   var bomChildList []kingdee.ICBomChild
   // 第一次启动, 上报全量
   if len(bomReportedCache) == 0 {
      fData = true
   }
   // 上报bom
   bomList = kingdee.BomList(fData)
   logger.Debug("查询到%d条BOM数据", len(bomList))
@@ -182,21 +186,19 @@
      }
      // 给bom添加组件
      for _, bom := range bomList {
         bom.Component = bomChildMap[bom.FInterID]
      for idx, bom := range bomList {
         bomList[idx].Component = bomChildMap[bom.FInterID]
      }
      // 每次发 1000 条
      // 每次发 200 条
      successCnt := 0
      for i := 0; i < len(bomList); i += 1000 {
         end := i + 1000
      for i := 0; i < len(bomList); i += 200 {
         end := i + 200
         if end > len(bomList) {
            end = len(bomList)
         }
         b, _ := json.Marshal(bomList[i:end])
         ioutil.WriteFile("bomList.tmp", b, 0644)
         ok := nsqclient.Produce(config.Options.BomTopic, b)
         if !ok {
@@ -214,48 +216,4 @@
      logger.Debug("已上报%d条BOM数据", successCnt)
   }
   //
   //// 上报bom子项
   //
   //// 如果请求全量数据, 直接查询所有的数据并发送. 增量上报, 先判断bom是否有更新,然后按bom编码查询子项
   //if fData {
   //   bomChildList = kingdee.BomChild(nil)
   //} 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子项数据.")
   //   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)
}