Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否能在导入的时候,判断某个字段没有进行新增 #358

Open
99tian opened this issue Aug 7, 2024 · 1 comment
Open

Comments

@99tian
Copy link

99tian commented Aug 7, 2024

public override WebResponseContent Import(List<IFormFile> files)
{
    //导入保存前处理(可以对list设置新的值)
    ImportOnExecuting = (List<Ware_ProductionKanban> list) =>
    {
        var productIds = list.Select(x => x.ProductName).Distinct().ToList();
        foreach (var item in productIds)
        {
            Base_Product defectItemExtendData = (Base_Product)_productRepository.FindAsIQueryable(x => x.ProductName == item);
            if (defectItemExtendData == null)
            {
                Base_Product extendData = new Base_Product();
                extendData.ProductName = item;
                extendData.ProductCode = GetProductCode(1);
                extendData.WhetherQuality = 1;
                extendData.ProductAttribute = "selfControl";
                _productRepository.Add(extendData, true);
            }
        }
        // 获取已存在的产品ID列表
        for (int i = 0; i < list.Count; i++)
        {
            if (string.IsNullOrWhiteSpace(list[i].WorkOrderNumber))
                list[i].WorkOrderNumber = GetPurchaseOrderCode(1);
            if (i > 0)
            {
                list[i].WorkOrderNumber = GetPurchaseOrderCode(i + 1);
            }

            list[i].AuditStatus = 0;
        }
        return webResponse.OK();
    };
    //导入后处理(已经写入到数据库了)
    ImportOnExecuted = (List<Ware_ProductionKanban> list) =>
    {
        return webResponse.OK();
    };
    return base.Import(files);
}

没有运行到ImportOnExecuting就报错
微信图片_20240807165414

怎么解决

@cq-panda
Copy link
Owner

cq-panda commented Aug 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants