From e6337e01bfdabd34f3ce31da4b3da5ac3be8c342 Mon Sep 17 00:00:00 2001 From: fly-l <1420031550@qq.com> Date: Mon, 19 Jun 2023 15:46:50 +0800 Subject: [PATCH] 2023-06-19 --- .vs/SGGL_SeDin/v17/.wsuo | Bin 250368 -> 251904 bytes .../HJGL/WeldingManage/PipelineMatIn.aspx.cs | 142 +++++++++++++++--- 2 files changed, 124 insertions(+), 18 deletions(-) diff --git a/.vs/SGGL_SeDin/v17/.wsuo b/.vs/SGGL_SeDin/v17/.wsuo index fb4f7890ff2c711feb74fdc85c297bd04d910f8f..b4dc2591b91c74b833a1c72ca30120004a626d62 100644 GIT binary patch delta 1960 zcmdVaUu;uV90%}w&b`~Z?snZuSJ`a4flD{$I=Z#6fdhv$Ko(?8=^F`1Ck3uU1p$!&82-=|o!VrNauoOC>3zorhcnrE>g`$)wD>0z! z_N}Q+7;J_uuoa$$XJ8v_haIpJcEN7whdAtky)XcS@GR_u=U@n)hZo>QcnO9f0WZTV zupg3g@dq$C2(Q8+cnw~MH{dWFfe}bS8t&ES*t+a5F#jLpOWyRc32E~=Mu8~!?#&gs(l`m>d(MA7ZQS&u@9M9^3Rq%vDr4_yZzY1sU zHX{(#WzKyd^IO<(fj$S5d)2B|J~|zU>BZZoaB0)%$L=W0Z`y}v-J>R_%c3?E1x4D) zZFJbPPWK=x4+QIx=Cns=4H`D0Rb<(hU|x1Nb{W0NTBq2Yk290Ceayk+pB|cZ+qy|c ztKIE1?TyhH9-^dgqiufC6*TSpzA+pc2=@<0mIOQYMmmF$!SJ$RJQRut2jc^gaK}Jr z7kawte~M|es{XUgLT)r@=6l*coMNrjzhGfixZ@S{zrxH|{}!WpolTxmay>Flyh)*h z&EMI0QH+v{`W%YyR($#NVq#T$45~+YP3Zkcqud4^#P+QmpNAjU0A3$TPWi4!aZkytoK#4 zL?&LN8#TRh9o8qewy>y{Ne7c(rIkUM(h_-&+vxP#8nd$d8q4(X%t}t}Yd#@g^huMi zp0WMiM44Cp^O&(dJCUvAE7+SGPHbQwWqLGms!9!rsk7?H#P}_?on@k>CphQgXszm| zsoy>H`KPY8x^+I$t*d9gH1-6SGk*6@LP}HfX8< delta 2927 zcmeI!dstIt9Ki9tXCMO(Y;0`Y+0X@OQ4A-SoQ1U%lN^PWl_dkgE>>1(S=LrocA=6T zi!!rXM0XQc(LD;a>;_m?c0s$@(;xLm5C8N>*!P9uvmUD_`5NE2q#(0Xgp^v5q!lRkM3bpuXyfL+!l|uP`qfF%i3i!VL8DV^ z)wc5y+Uxm^nH}_LFG0``vLP#BTrcXzD@5VfcB; zzh+L@;J0wh_}VNry2(5;ceH!Z5N*qI86O*u$&AT!Nq}4@o%omYZTA-)Iujmz6fVU8SxW&CQWtYAqt(#=A#y;VF7%o!|6B!^;n2A zaTd=lsAK&6Te2*XSBV?WXiD=@W%w9D!<{=%c&Su|O zaWL1ZvexBBCyed1w1o<53`)$HVi4M@!rcb>bjxjQUXd?F$md`FJB*LU&!nT*ez(p) zlIk{175u&I6YVRq<2hakZKP<9Dy#2kx pds, int count) + { + Model.ResponeData responeData = new Model.ResponeData(); + List result = new List(); + + if (count < 4) + { + responeData.code = 0; + responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列"; + return responeData; + } + if (pds.Count > 0 && pds != null) + { + + for (int i = 0; i < pds.Count; i++) + { + HJGL_PipeLineMat item = new HJGL_PipeLineMat(); + + #region 数据验证和赋值 + + + string unitworkId = string.Empty; + unitworkId = Request.Params["UnitWorkId"]; + string PipeArea = string.Empty;//管线划分 1工厂预制 2现场施工 + + if (pds[i].A != null && !string.IsNullOrEmpty(pds[i].A.ToString())) + { + string pipelineCode = pds[i].A.ToString(); + var pipeline = from x in Funs.DB.HJGL_Pipeline where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitWorkId == unitworkId && x.PipelineCode == pipelineCode select x; + if (pipeline.Count() > 0) + { + item.PipelineId = pipeline.First().PipelineId; + PipeArea = pipeline.First().PipeArea; + } + else + { + result.Add("不存在此管线号-" + pds[i].A.ToString()); + + } + + } + else + { + result.Add((i + 2) + "Line, [管线号] 不能为空
"); + } + + + if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString())) + { + string materialCode = pds[i].C.ToString(); + var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == materialCode select x; + if (lib.Count() > 0) + { + item.MaterialCode = pds[i].C.ToString(); + } + else + { + result.Add("不存在此材料编码-" + pds[i].C.ToString()); + + } + + } + else + { + result.Add((i + 2) + "Line, [材料编码] 不能为空
"); + } + + if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString())) + { + try + { + var number = Funs.GetNewDecimal(pds[i].D.ToString()); + item.Number = number; + } + catch (Exception) + { + result.Add("第" + (i + 2).ToString() + "行," + "数量格式输入有误
"); + } + + } + else + { + result.Add((i + 2) + "Line, [数量] 不能为空
"); + } + + if (PipeArea == "1") + { + if (pds[i].B != null && !string.IsNullOrEmpty(pds[i].B.ToString())) + { + item.PrefabricatedComponents = pds[i].B.ToString(); + + } + else + { + result.Add((i + 2) + "Line, [预制组件] 不能为空
"); + } + } + var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents); + if (model.Count() == 0) + { + matList.Add(item); + + } + + #endregion + } + + } + else + { + responeData.code = 0; + responeData.message = "导入数据为空!"; + } + + return responeData; } #endregion @@ -344,7 +462,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage return; } string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower(); - if (IsXls != ".xls" && IsXls != ".xlsx") + if (IsXls != ".xlsx") { ShowNotify("只能选择Excel文件!", MessageBoxIcon.Warning); return; @@ -365,26 +483,14 @@ namespace FineUIPro.Web.HJGL.WeldingManage //文件上传服务器后的名称 string fileName = rootPath + initPath + this.hdFileName.Text; //读取Excel - DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true); - - //验证Excel读取是否有误 - if (!string.IsNullOrEmpty(errorInfos)) - { - Alert alert = new Alert - { - Message = errorInfos, - Target = Target.Self - }; - alert.Show(); - //ShowNotify(errorInfos, MessageBoxIcon.Warning); - return; - } - var reposedata= AddDatasetToSQL(ds.Tables[0], 4); + var ds = MiniExcel.Query(fileName).ToList(); + var columns = MiniExcel.GetColumns(fileName); + var cnt = columns.Count; + var reposedata = AddDatasetToSQL(ds, cnt); if (reposedata.code == 1) { State = (int)ButtonState.Import; ShowNotify("审核完成请点击导入"); - } else { @@ -394,7 +500,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage Target = Target.Self }; alert.Show(); - //ShowNotify(reposedata.message); + //ShowNotify(reposedata.message); } } #region 导入