...
|
...
|
@@ -846,6 +846,8 @@ func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.Transacti |
|
|
return err
|
|
|
}
|
|
|
log.Logger.Debug(fmt.Sprintf("【同步物料数据】查询数据条数:%v", len(records)))
|
|
|
_, materialsFromDb, _ := productMaterialRepository.Find(map[string]interface{}{"companyId": cid, "limit": 20000})
|
|
|
mapMaterialsFromDb := domain.ProductMaterials(materialsFromDb).ToMapByNumber()
|
|
|
for index, item := range records {
|
|
|
var (
|
|
|
material *domain.ProductMaterial
|
...
|
...
|
@@ -854,14 +856,13 @@ func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.Transacti |
|
|
attribute string //物料属性
|
|
|
category string //物料类别
|
|
|
)
|
|
|
if materialGroup, ok = mapMaterialGroup[item.MaterialGroupNumber]; !ok {
|
|
|
if item.UseOrgName != "素天下" {
|
|
|
continue
|
|
|
}
|
|
|
material, err = productMaterialRepository.FindOne(map[string]interface{}{"companyId": cid, "materialNumber": item.Number})
|
|
|
if err == nil && material != nil {
|
|
|
if materialGroup, ok = mapMaterialGroup[item.MaterialGroupNumber]; !ok {
|
|
|
continue
|
|
|
}
|
|
|
if err != domain.ErrorNotFound {
|
|
|
if _, ok := mapMaterialsFromDb[item.Number]; ok {
|
|
|
continue
|
|
|
}
|
|
|
if v, ok := mapMaterialCategory[item.FCategoryID]; ok {
|
...
|
...
|
@@ -889,7 +890,8 @@ func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.Transacti |
|
|
Ext: domain.NewExt(org.OrgName),
|
|
|
}
|
|
|
if material, err = productMaterialRepository.Save(material); err != nil {
|
|
|
return err
|
|
|
log.Logger.Debug(fmt.Sprintf("同步失败 序号:%v 物料数据 id:%v number:%v name:%v 错误:%v", index, material.ProductMaterialId, material.MaterialNumber, material.MaterialName, err.Error()))
|
|
|
continue
|
|
|
}
|
|
|
log.Logger.Debug(fmt.Sprintf("同步 序号:%v 物料数据 id:%v number:%v name:%v", index, material.ProductMaterialId, material.MaterialNumber, material.MaterialName))
|
|
|
}
|
...
|
...
|
|