|
@@ -473,7 +473,44 @@ func (srv *PullDataK3CloudService) SyncDataProduct(ptr *pgTransaction.Transactio |
|
@@ -473,7 +473,44 @@ func (srv *PullDataK3CloudService) SyncDataProduct(ptr *pgTransaction.Transactio |
473
|
if err != nil {
|
473
|
if err != nil {
|
474
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
474
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
475
|
}
|
475
|
}
|
476
|
- return prdMoDao.SyncDataProductByTime(fromTime, org.OrgName)
|
476
|
+ materials, err := prdMoDao.SearchProductByTime(fromTime, "素天下") // 默认企业名称素天下、或者使用组织ID
|
|
|
477
|
+ if err != nil {
|
|
|
478
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
479
|
+ }
|
|
|
480
|
+ var (
|
|
|
481
|
+ cid = constant.MANUFACTURE_DEFAULT_COMPANYID
|
|
|
482
|
+ oid = constant.MANUFACTURE_DEFAULT_ORGID
|
|
|
483
|
+ )
|
|
|
484
|
+ productRepository, _, _ := factory.FastPgProduct(ptr, 0)
|
|
|
485
|
+ for _, v := range materials {
|
|
|
486
|
+ var product *domain.Product
|
|
|
487
|
+ product, err = productRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "productCode": v.Number})
|
|
|
488
|
+ if err == nil && product != nil {
|
|
|
489
|
+ continue
|
|
|
490
|
+ }
|
|
|
491
|
+ if err == domain.ErrorNotFound {
|
|
|
492
|
+ err = nil
|
|
|
493
|
+ product = &domain.Product{
|
|
|
494
|
+ CompanyId: cid,
|
|
|
495
|
+ OrgId: oid,
|
|
|
496
|
+ ProductCode: v.Number,
|
|
|
497
|
+ ProductName: v.Name,
|
|
|
498
|
+ ProductCategory: v.MaterialGroupName,
|
|
|
499
|
+ ProductSpec: &domain.UnitQuantity{
|
|
|
500
|
+ Unit: v.Specification,
|
|
|
501
|
+ UnitWeight: 0,
|
|
|
502
|
+ },
|
|
|
503
|
+ CreatedAt: v.CreateDate,
|
|
|
504
|
+ UpdatedAt: time.Now(),
|
|
|
505
|
+ Ext: domain.NewExt(org.OrgName),
|
|
|
506
|
+ }
|
|
|
507
|
+ }
|
|
|
508
|
+ if product, err = productRepository.Save(product); err != nil {
|
|
|
509
|
+ return err
|
|
|
510
|
+ }
|
|
|
511
|
+ }
|
|
|
512
|
+ return nil
|
|
|
513
|
+ //return prdMoDao.SyncDataProductByTime(fromTime, org.OrgName)
|
477
|
}
|
514
|
}
|
478
|
|
515
|
|
479
|
// 同步生产计划
|
516
|
// 同步生产计划
|