服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-05-29 04f06cc5578208caeebc126e74b909921ceb7789
Tiger.Business/MES/SMT/Biz.SmtTool.cs
@@ -70,44 +70,54 @@
                    //DataTable dt = JsonConvert.DeserializeObject<DataTable>(paras.ToString());
                    List<smtWoTableIn> currentList = new List<smtWoTableIn>();
                    if (paras.Count > 0)
                    if (paras?.Count > 0)
                    {
                        var duplicateWo = paras.GroupBy(p => p.关联工单号)
                                         .Where(g => g.Count() > 1)
                                         .Select(g => g.Key)
                                         .ToList();
                        if (duplicateWo.Count() > 0)//存在重复数据
                        {
                            string WORK_ORDER = string.Empty;
                            foreach (var item in duplicateWo)
                            {
                                WORK_ORDER += item;
                            }
                            WORK_ORDER = WORK_ORDER.TrimEnd(';');
                            result.IsSuccessed = false;
                            result.Message = $"导入的物料中有重复数据:关联工单:{WORK_ORDER}";
                        }
                        else
                        //var duplicateWo = paras.GroupBy(p => p.关联工单号)
                        //                 .Where(g => g.Count() > 1)
                        //                 .Select(g => g.Key)
                        //                 .ToList();
                        //if (duplicateWo.Count() > 0)//存在重复数据
                        //{
                        //    string WORK_ORDER = string.Empty;
                        //    foreach (var item in duplicateWo)
                        //    {
                        //        WORK_ORDER += item;
                        //    }
                        //    WORK_ORDER = WORK_ORDER.TrimEnd(';');
                        //    result.IsSuccessed = false;
                        //    result.Message = $"导入的物料中有重复数据:关联工单:{WORK_ORDER}";
                        //}
                        //else
                        {
                            foreach (var item in paras)
                            {
                                item.处理方式 = "新增";
                                item.原因 = null;
                                if (item.关联工单号 == null)
                                if (item.关联工单号 == null|| item.关联工单号 == " ")
                                {
                                    item.处理方式 = "数据异常";
                                    item.原因 += "工单号空或不存在!";
                                }
                                if (item.产品编码 == null)
                                if (item.产品编码 == null || item.产品编码 == " ")
                                {
                                    item.处理方式 = "数据异常";
                                    item.原因 += $"产品编码为空!";
                                }
                                if (item.物料编码 == null || item.物料编码 == " ")
                                {
                                    item.处理方式 = "数据异常";
                                    item.原因 += $"物料编码为空!";
                                }
                                if (item.站位号 == null || item.站位号 == " ")
                                {
                                    item.处理方式 = "数据异常";
                                    item.原因 += $"站位号为空!";
                                }
                                currentList.Add(item);
                                if (await Db.Queryable<SMT_WO_TABLE>().AnyAsync(x => x.WORK_ORDER == item.关联工单号))
                                if (await Db.Queryable<SMT_WO_TABLE>().AnyAsync(x => x.WORK_ORDER == item.关联工单号 && x.ITEM_CODE == item.物料编码 && x.SLOT_NO==item.站位号&&x.SMT_CODE==item.贴片机编码))
                                {
                                    item.处理方式 = "修改";
                                    item.原因 += $"工单{item.关联工单号}与数据库重复!";
                                    item.原因 += $"工单{item.关联工单号},物料编码{item.物料编码},站位号{item.站位号},贴片机编码{item.贴片机编码}与数据库重复!";
                                }
                            }
                            //for (int i = 0; i < item..Count; i++)
@@ -116,12 +126,17 @@
                        }
                    }
                    else
                    {
                        result.IsSuccessed = false;
                        result.Message = $"导入的物料不能为空";
                    }
                    result.Data = currentList;
                }
                catch (Exception ex)
                {
                    result.CatchException(ex, $"验证导入发料计划排程异常");
                    result.CatchException(ex, $"验证导入工单料站表异常");
                }
                return result;
            }