...
|
...
|
@@ -473,7 +473,44 @@ func (srv *PullDataK3CloudService) SyncDataProduct(ptr *pgTransaction.Transactio |
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return prdMoDao.SyncDataProductByTime(fromTime, org.OrgName)
|
|
|
materials, err := prdMoDao.SearchProductByTime(fromTime, "素天下") // 默认企业名称素天下、或者使用组织ID
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
var (
|
|
|
cid = constant.MANUFACTURE_DEFAULT_COMPANYID
|
|
|
oid = constant.MANUFACTURE_DEFAULT_ORGID
|
|
|
)
|
|
|
productRepository, _, _ := factory.FastPgProduct(ptr, 0)
|
|
|
for _, v := range materials {
|
|
|
var product *domain.Product
|
|
|
product, err = productRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "productCode": v.Number})
|
|
|
if err == nil && product != nil {
|
|
|
continue
|
|
|
}
|
|
|
if err == domain.ErrorNotFound {
|
|
|
err = nil
|
|
|
product = &domain.Product{
|
|
|
CompanyId: cid,
|
|
|
OrgId: oid,
|
|
|
ProductCode: v.Number,
|
|
|
ProductName: v.Name,
|
|
|
ProductCategory: v.MaterialGroupName,
|
|
|
ProductSpec: &domain.UnitQuantity{
|
|
|
Unit: v.Specification,
|
|
|
UnitWeight: 0,
|
|
|
},
|
|
|
CreatedAt: v.CreateDate,
|
|
|
UpdatedAt: time.Now(),
|
|
|
Ext: domain.NewExt(org.OrgName),
|
|
|
}
|
|
|
}
|
|
|
if product, err = productRepository.Save(product); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
//return prdMoDao.SyncDataProductByTime(fromTime, org.OrgName)
|
|
|
}
|
|
|
|
|
|
// 同步生产计划
|
...
|
...
|
|