|
|
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"
|
...
|
...
|
@@ -523,16 +524,25 @@ func (srv *PullDataK3CloudService) SyncDataProductPlan(ptr *pgTransaction.Transa |
|
|
continue
|
|
|
}
|
|
|
// 计划信息
|
|
|
plan, err = productPlanRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "batchNumber": v.BillNo})
|
|
|
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()
|
|
|
//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 {
|
|
|
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,
|
|
|
OrgId: oid,
|
|
|
BatchNumber: v.BillNo,
|
|
|
BatchNumber: batchNumber,
|
|
|
ProductDate: v.PlanStartDate,
|
|
|
Workshop: workshop.CloneSample(),
|
|
|
WorkOn: 0,
|
...
|
...
|
@@ -557,6 +567,7 @@ func (srv *PullDataK3CloudService) SyncDataProductPlan(ptr *pgTransaction.Transa |
|
|
ProductCode: product.ProductCode,
|
|
|
ProductName: product.ProductName,
|
|
|
DevotedUnit: "份",
|
|
|
ErpBillNo: v.BillNo,
|
|
|
})
|
|
|
plan.PlanProductName = product.ProductName
|
|
|
plan.Remark = v.Description
|
...
|
...
|
|