|
|
package syncdata
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/redis"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
...
|
...
|
@@ -526,18 +526,13 @@ func (srv *PullDataK3CloudService) SyncDataProductPlan(ptr *pgTransaction.Transa |
|
|
// 计划信息
|
|
|
plan, err = productPlanRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "erpBillNo": v.BillNo, "productCode": v.MaterialNumber})
|
|
|
if err == nil && plan != nil {
|
|
|
//plan.UpdatedAt = time.Now()
|
|
|
continue
|
|
|
}
|
|
|
count, _, errFindPlan := productPlanRepository.Find(map[string]interface{}{"companyId": cid, "orgId": oid, "erpBillNo": v.BillNo, "productCode": v.MaterialNumber})
|
|
|
if errFindPlan != nil {
|
|
|
batchNumber, genBatchNumberErr := redis.GenCode(redis.NewBillNoCodeCache(cid, v.BillNo))
|
|
|
if genBatchNumberErr != nil {
|
|
|
log.Logger.Error(err.Error(), map[string]interface{}{"id": v.RowId, "err": "gen batch number error"})
|
|
|
continue
|
|
|
}
|
|
|
/* ERP系统BillNO + MaterialNumber 唯一 会重复,需要做自增格式化处理*/
|
|
|
batchNumber := fmt.Sprintf("%v-1", v.BillNo)
|
|
|
if count >= 1 {
|
|
|
batchNumber = fmt.Sprintf("%v-%v", v.BillNo, count)
|
|
|
}
|
|
|
if err == domain.ErrorNotFound {
|
|
|
plan = &domain.ProductPlan{
|
|
|
CompanyId: cid,
|
...
|
...
|
@@ -556,7 +551,7 @@ func (srv *PullDataK3CloudService) SyncDataProductPlan(ptr *pgTransaction.Transa |
|
|
// 更新数据
|
|
|
plan.PlanDevoted = &domain.UnitQuantity{
|
|
|
Unit: product.ProductSpec.Unit,
|
|
|
Quantity: 0,
|
|
|
Quantity: v.Qty,
|
|
|
Weight: product.ProductWeigh(0),
|
|
|
UnitWeight: product.ProductSpec.UnitWeight,
|
|
|
}
|
...
|
...
|
|