VueWebCoreApi/Tools/ImportExcelData.cs
@@ -1349,7 +1349,7 @@
                return Message;
            }
            else if (excelTable[0].Columns.Count != 5)
            else if (excelTable[0].Columns.Count != 6)
            {
                code = "301";
                Message = "工序设置模板不符合规范,请检查列名字段数";
@@ -1383,6 +1383,12 @@
            {
                code = "301";
                Message = "工序设置模板:表头信息不符合规范,第2列应为{描述}";
                return Message;
            }
            else if (excelTable[0].Columns[5].ColumnName != "设备供方/编码")
            {
                code = "301";
                Message = "工序设置模板:表头信息不符合规范,第2列应为{设备供方/编码}";
                return Message;
            }
            else
@@ -3913,6 +3919,63 @@
                        list.Add(erro);
                    }
                }
                if (excelTable[0].Rows[k][5].ToString().Trim() != null && excelTable[0].Rows[k][5].ToString().Trim() != "")
                {
                    string[] eqpcodelist = Array.ConvertAll<string, string>(excelTable[0].Rows[k][5].ToString().Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
                    if (excelTable[0].Rows[k][5].ToString().Trim() == "自制")
                    {
                        for (int i = 0; i < eqpcodelist.Length; i++)
                        {
                            sql = @"select *  from TEqpInfo where code=@code";
                            dynamicParams.Add("@code", eqpcodelist[i].ToString());
                            dt = DapperHelper.selectdata(sql, dynamicParams);
                            if (dt.Rows.Count<=0)
                            {
                                ExcelErro erro = new ExcelErro();
                                erro.RoeNumber = "/";
                                erro.ErrorField = "{设备供方/编码}";
                                erro.ErrorCont = "工序类型为自制时,应填写有效的设备编码或工位编码,当前{*工序编号(唯一)}:"+ excelTable[0].Rows[k][0].ToString().Trim() + ",对应的{设备供方/编码}:"+ excelTable[0].Rows[k][5].ToString().Trim() + "存在不合理的值!";
                                list.Add(erro);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < eqpcodelist.Length; i++)
                        {
                            sql = @"select *  from TCustomer where code=@code";
                            dynamicParams.Add("@code", eqpcodelist[i].ToString());
                            dt = DapperHelper.selectdata(sql, dynamicParams);
                            if (dt.Rows.Count <= 0)
                            {
                                ExcelErro erro = new ExcelErro();
                                erro.RoeNumber = "/";
                                erro.ErrorField = "{设备供方/编码}";
                                erro.ErrorCont = "工序类型为外协时,应填写有效的外协供应商编码,当前{*工序编号(唯一)}:" + excelTable[0].Rows[k][0].ToString().Trim() + ",对应的{设备供方/编码}:" + excelTable[0].Rows[k][5].ToString().Trim() + "存在不合理的值!";
                                list.Add(erro);
                            }
                        }
                    }
                }
            }
            // 使用匿名对象来组合多个字段的值,并对其进行分组
            var groupedRows = excelTable[0].AsEnumerable()
                .GroupBy(row => new
                {
                    StepCode = row.Field<string>("*工序编号(唯一)")
                })
                // 筛选出那些包含多于一个元素的组(即重复的组合)
                .Where(group => group.Count() > 1)
                // 选择每个组中的所有行(即重复的行)
                .SelectMany(group => group);
            List<DataRow> listRow = groupedRows.ToList();
            if (listRow.Count > 0)
            {
                ExcelErro erro = new ExcelErro();
                erro.RoeNumber = "/";
                erro.ErrorField = "{*工序编号(唯一)}";
                erro.ErrorCont = "*工序编号(唯一)在导入文件中存在重复值";
                list.Add(erro);
            }
            if (list.Count > 0)
            {
@@ -5706,6 +5769,8 @@
                //导入工序
                for (int i = 0; i < excelTable[0].Rows.Count; i++)
                {
                    string[] eqpcodelist = Array.ConvertAll<string, string>(excelTable[0].Rows[i][5].ToString().Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
                    //写入工序表
                    sql = @"insert into TStep(stepcode,stepname,enable,descr,flwtype,lm_user,lm_date) 
                            values(@stepcode,@stepname,@enable,@descr,@flwtype,@lm_user,@lm_date)";
                    list.Add(new
@@ -5722,6 +5787,24 @@
                            lm_date = DateTime.Now.ToString()
                        }
                    });
                    //写入工序关联工作站表
                    for (int j = 0; j < eqpcodelist.Length; j++)
                    {
                        sql = @"insert into TFlw_Rteqp(eqp_code,step_code,style,lm_user,lm_date)
                            values(@eqp_code,@step_code,@style,@lm_user,@lm_date)";
                        list.Add(new
                        {
                            str = sql,
                            parm = new
                            {
                                eqp_code = eqpcodelist[j].ToString(),
                                step_code = excelTable[0].Rows[i][0].ToString().Trim(),
                                style = excelTable[0].Rows[i][2].ToString().Trim(),
                                lm_user = us.usercode,
                                lm_date = DateTime.Now.ToString()
                            }
                        });
                    }
                }
                bool aa = DapperHelper.DoTransaction(list);
                if (aa)
@@ -5850,7 +5933,7 @@
                        message = "导入失败!";
                    }
                    //查询工序节拍表中:产品+工艺路线+工序+设备是否存在
                    sql = @"select *  from TPrteEqp_Stad
                    sql = @"select *  from TPrteStep_Price
                        where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode";
                    dynamicParams.Add("@partcode", partcode);
                    dynamicParams.Add("@routecode", routecode);
@@ -5859,7 +5942,7 @@
                    var data6 = DapperHelper.selectdata(sql, dynamicParams);
                    if (data6.Rows.Count > 0)
                    {
                        sql = @"update TPrteEqp_Stad set stand_value=@stand_value,eqp_value=@eqp_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
                        sql = @"update TPrteStep_Price set stand_value=@stand_value,eqp_value=@eqp_value,cavity_qty=@cavity_qty,unprice=@unprice,lm_user=@username,lm_date=@userdate
                            where materiel_code=@partcode and route_code=@routecode and step_code=@stepcode and eqp_code=@eqpcode ";
                        list.Add(new
                        {
@@ -5881,7 +5964,7 @@
                    }
                    else
                    {
                        sql = @"insert into TPrteEqp_Stad(materiel_code,eqp_code,stand_value,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,step_code)
                        sql = @"insert into TPrteStep_Price(materiel_code,eqp_code,stand_value,route_code,unprice,eqp_value,cavity_qty,wkspcode,lm_user,lm_date,step_code)
                              values(@partcode,@eqpcode,@stand_value,@routecode,@unprice,@eqp_value,@cavity_qty,@wkspcode,@username,@userdate,@stepcode)";
                        list.Add(new
                        {