From 93d204c6d20a653582452620da7183aef72d26c5 Mon Sep 17 00:00:00 2001 From: xusc Date: Thu, 8 Aug 2024 15:35:35 +0800 Subject: [PATCH] .. --- .vs/ICSSoft.FromERP/v16/.suo | Bin 252928 -> 226816 bytes ICSSoft.FromERP/ICSMOBOM.cs | 157 ++++++++++++++----------- ICSSoft.FromERP/ICSSoft.FromERP.csproj | 1 + 3 files changed, 89 insertions(+), 69 deletions(-) diff --git a/.vs/ICSSoft.FromERP/v16/.suo b/.vs/ICSSoft.FromERP/v16/.suo index 0656a8c130b560ddf969f4b892a37b99240f41b8..936cdd9811ab88ab8d62c96a205f96960c7dfddf 100644 GIT binary patch delta 8219 zcmeI1e_YhXy2tmK@9wg|f`}*}zZO(n5fE@iO~nOK5Pu=4QJMjQn!kU5r$AwEYF1iD z8Qn3n!qxD{&6Bdms+q24U5_`-vdm0L&CJR=c0y0mQSN7!Md@6-b+*12f=<)d}roPh?918L6NP2;rWZkV=1~W}}Htkl7#u^n#uXh9Mmf@_=kX2RRV= z#gInOA3O-UgDg-0o&>W{=W&n&9)La#6e2xZN+8>cf$S=K+8+h$p*#ZyxeNC}&I0q? z`Xa~*ce;{)sEN=|f%XTm3`ldW%<;{U=GqIr*<2K7zpiaZl^W#8p-ZbTMS2PNS0Fp# z;g&KjFKN8F-~*rqCxFavG2VO7r2&48@m4n9%a`eV;$#~Gpu3IMbh^2$>3K+Lvt6LY zW=;H{x@XWPca0WidZvCuV%DU2C8{N9Jm&}vb zS4e*kK5dnE8EI)RS)S{bT_HbKse0VGQQAw+ZHv8RWwX1ow3jTqrsAhGF_ok=FFeI9 zHIQ0&S_kRrPJ6qh52UXI5{)(%=w z1&d+)Mo@+JGMqV6;bp;Pm65n%DO7p=FAV;^)}#NY25RdpDwR;#8~bX#Jf;7pp)`;uhPNw__11y~zyKZxPk~_YN3aUu zhNi2K379A!NGpf~&w&6C3)X=bfvme6(i6M{Ht zM^$|1xqkkCM~z$HwyX(MWWPO_v8t#N_Z)h~VGQk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I<$E%7~FUnazrWcxb znOaF(!nTol4@?z!OuCBqcTzv|KFXBNk}q1kBzkf90ELNZb$GXA^OuIXpMBK#2D~QlmDs%|(tn~?_8g@7|Vn9U(MTeS4V9~vt#K7tGe9h()>>9dj17+dV>7j0rhLV>$vpQ zj*j2`Ojmfhb=gwnm@)sYekP}R{Qt%ibc1u?*YHzZ*}%KZkv6mWjit@&{Rs`H&#`Xyr_NuvNF-A}-@Q9U(SM9DEbXqTIDD5N?mtaK z)noEuB&vifoKvlSsWh8k3a%<~?=E~mW!=TX6rGt_J*1y1A}FJv$Y_{Zl$T?iS&$z( zBs8Ts2QU3*=G$Fa*3YH62bYzod7Fjt7nW+2_%-Y;7wN(JMz$bU!@@<#8s^GZqsTF$LyzN=trs?syAtok-s&j!xVuagYnH;FR`v+fD8|ifiAzMY>7z+WGCO)elCD9$n%yZc3j|4FZ;Pl7jb(N%&Ie6h1u* zdV^)VIp5v{mo+``&p071;6JcrJ8RD~9obqYbS+J@B36y2v1;A-jO>k4bpK!<5IrhP a|6pO=of|P{)-3s{uslRoJ#}|(`2PZM<(J+7 diff --git a/ICSSoft.FromERP/ICSMOBOM.cs b/ICSSoft.FromERP/ICSMOBOM.cs index 9acecc1..3effdd0 100644 --- a/ICSSoft.FromERP/ICSMOBOM.cs +++ b/ICSSoft.FromERP/ICSMOBOM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using Quartz; @@ -8,9 +9,9 @@ using Quartz; namespace ICSSoft.FromERP { /// - /// 备料表(工单BOM) + /// 工单备料表(锐腾) /// - public class ICSMOBOM : IJob + public class ICSMoBom : IJob { private static object key = new object(); private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -35,82 +36,100 @@ namespace ICSSoft.FromERP { try { - string conStr = ICSHelper.GetConnectString(); string Namespace = this.GetType().Namespace; - string Class = this.GetType().Name; - #region SQL - string sql = @"SELECT a.MoCode AS MOCODE , - b.InvCode AS ITEMCODE, - b.SortSeq AS SEQ, - c.InvCode AS MOBITEMCODE, - CAST(c.AllocateId AS NVARCHAR(50)) AS MOBITEMECN, - d.cInvName AS MOBITEMNAME, - d.cInvStd AS MOBITEMDESC, - '1' AS MOBITEMSTATUS, + //string Class = this.GetType().Name; + DataTable dt = ICSHelper.GetERPDB(conStr); + foreach (DataRow dr in dt.Rows) + { + string erpName = ICSHelper.GetConfigString()["ERPDB"]; + string TenantId = dr["TenantId"].ToString();//mes 组织 + string TenantCode = dr["TenantCode"].ToString(); + string ErpId = dr["ErpID"].ToString(); //erpID + string Class = this.GetType().Name + TenantCode; + erpName = string.Format(erpName, TenantId); + #region SQL + string sql = @"SELECT top 2000 A1.DocNo AS MOCODE , + A5.Code AS ITEMCODE, + 1 AS SEQ, + A4.Code AS MOBITEMCODE, + CAST(A3.ID AS NVARCHAR(50)) AS MOBITEMECN, + A4.Name AS MOBITEMNAME, + A4.SPECS AS MOBITEMDESC, + A1.DocState AS MOBITEMSTATUS, GETDATE() AS MOBITEMEFFTIME, GETDATE() AS MOBITEMINVTIME, - CASE WHEN d.bCutMantissa='1' AND d.bKCCutMantissa='1' THEN CEILING(c.Qty) ELSE c.Qty END AS MOBITEMQTY, - c.WhCode AS MOBITEMLOCATION, - CASE WHEN c.WIPType='1' THEN '1' ELSE '0' END AS MOBOMITEMUOM, - '' AS MOFAC, - c.SortSeq AS MOBOMLINE, - CASE WHEN ISNULL(a.ModifyTime, a.CreateTime)>ISNULL(b.CloseTime,ISNULL(b.RelsTime,ISNULL(a.ModifyTime, a.CreateTime))) THEN ISNULL(a.ModifyTime, a.CreateTime) ELSE ISNULL(b.CloseTime,ISNULL(b.RelsTime,ISNULL(a.ModifyTime, a.CreateTime))) END as MTIME - into #TempBOM - FROM {0}.dbo.mom_order a - INNER JOIN {0}.dbo.mom_orderdetail b ON a.MoId = b.MoId - INNER JOIN {0}.dbo.mom_moallocate c ON b.MoDId = c.MoDId - INNER JOIN {0}.dbo.Inventory d ON c.InvCode = d.cInvCode - LEFT JOIN {0}.dbo.bom_parent e ON b.BomId = e.BomId - LEFT JOIN {0}.dbo.bom_bom f ON e.BomId = f.BomId - LEFT JOIN {0}.dbo.ComputationUnit unit ON d.cComUnitCode = unit.cComunitCode - WHERE ISNULL (b.RelsUser,'') <> '' - and CASE WHEN ISNULL(a.ModifyTime, a.CreateTime)>ISNULL(b.CloseTime,ISNULL(b.RelsTime,ISNULL(a.ModifyTime, a.CreateTime))) THEN ISNULL(a.ModifyTime, a.CreateTime) ELSE ISNULL(b.CloseTime,ISNULL(b.RelsTime,ISNULL(a.ModifyTime, a.CreateTime))) END>=@LastTime + A3.ActualReqQty AS MOBITEMQTY, + A3.IssueStyle AS MOBITEMLOCATION, + c.code AS MOFAC, + A6.Code AS MOBOMITEMUOM, + CAST(A3.DocLineNO AS NVARCHAR(50)) AS MOBOMLINE, + A12.Code as WorkPoint, + ISNULL(A3.ModifiedOn,A3.CreatedOn) AS MTIME + into #TempPick + FROM {0}.dbo.MO_MO A1 + INNER JOIN {0}.dbo.MO_MOPickList A3 ON A3.MO=A1.ID + LEFT JOIN {0}.dbo.CBO_ItemMaster A4 ON A3.ItemMaster=A4.ID + LEFT JOIN {0}.dbo.CBO_ItemMaster A5 ON A1.ItemMaster=A5.ID + LEFT JOIN {0}.dbo.Base_UOM A6 ON A3.IssueUOM=A6.ID + LEFT JOIN {0}.dbo.[Base_Organization] as A12 on (A1.[Org] = A12.[ID]) + LEFT JOIN {0}.dbo.CBO_Wh c on A3.SupplyWh=c.id and A1.org=c.org + WHERE A3.IsPhantomPart!=1 + and ISNULL(A3.ModifiedOn,A3.CreatedOn)>=@LastTime + and a12.id='{1}' order by ISNULL(A3.ModifiedOn,A3.CreatedOn) - IF NOT EXISTS(SELECT * FROM #TempBOM) + IF NOT EXISTS(SELECT * FROM #TempPick) RETURN"; - sql = ICSHelper.Time(Namespace, Class, WorkPoint, sql, "#TempBOM"); - sql += "\r\n"; - sql += @"--删除数据 - DELETE ICSMOBOM WHERE MOBITEMECN NOT IN (SELECT AllocateId FROM {0}.dbo.mom_moallocate) "; - Dictionary values = new Dictionary(); - values.Add("MOCODE", "a.MOCODE"); - values.Add("ITEMCODE", "a.ITEMCODE"); - values.Add("SEQ", "a.SEQ"); - values.Add("MOBITEMCODE", "a.MOBITEMCODE"); - values.Add("MOBITEMNAME", "a.MOBITEMNAME"); - values.Add("MOBITEMDESC", "a.MOBITEMDESC"); - values.Add("MOBITEMSTATUS", "a.MOBITEMSTATUS"); - values.Add("MOBITEMEFFTIME", "a.MOBITEMEFFTIME"); - values.Add("MOBITEMINVTIME", "a.MOBITEMEFFTIME"); - values.Add("MOBITEMQTY", "a.MOBITEMQTY"); - values.Add("MOBOMITEMUOM", "a.MOBOMITEMUOM");//供应类型:1:入库到冲 - values.Add("MOBOMLINE", "a.MOBOMLINE"); - values.Add("MOBITEMLOCATION", "a.MOBITEMLOCATION"); - values.Add("MTIME", "a.MTIME"); - values.Add("MOFAC", "a.MOFAC"); - //values.Add("WorkPoint", "a.WorkPoint"); - //更新存在数据 - sql += ICSHelper.UpdateSQL("b", values) - + @" #TempBOM a - INNER JOIN ICSMOBOM b ON a.MOBITEMECN=b.MOBITEMECN + sql = string.Format(sql, erpName, ErpId); + sql = ICSHelper.Time(Namespace, Class, TenantId, sql, "#TempPick"); + Dictionary value = new Dictionary(); + + + sql += "\r\n"; + sql += @"--删除数据 + DELETE ICSMOBOM WHERE Default1 NOT IN (SELECT ID FROM {0}.dbo.MO_MOPickList) AND ICSMOBOM.TenantId='{1}'"; + Dictionary values = new Dictionary(); + values.Add("MOCODE", "a.MOCODE"); + values.Add("ITEMCODE", "a.ITEMCODE"); + values.Add("MOBITEMCODE", "a.MOBITEMCODE"); + values.Add("MOBITEMNAME", "a.MOBITEMNAME"); + values.Add("MoBItemSpec", "a.MOBITEMDESC"); + values.Add("MOBITEMSTATUS", "a.MOBITEMSTATUS"); + values.Add("MOBITEMEFFTIME", "a.MOBITEMEFFTIME"); + values.Add("MOBITEMINVTIME", "a.MOBITEMEFFTIME"); + values.Add("MOBITEMQTY", "a.MOBITEMQTY"); + values.Add("MOBOMITEMUOM", "a.MOBOMITEMUOM"); + values.Add("MOBOMLINE", "a.MOBOMLINE"); + values.Add("MOBITEMLOCATION", "a.MOBITEMLOCATION"); + values.Add("LastModifierUserId", "'" + ConstWorkPoint.Muser + "'"); + values.Add("LastModifierUserName", "'" + ConstWorkPoint.Musername + "'"); + values.Add("LastModificationTime", "a.Mtime");//操作时间 + values.Add("MOFAC", "a.MOFAC"); + //更新存在数据 + sql += ICSHelper.UpdateSQL("b", values) + + @" #TempPick a + INNER JOIN ICSMOBOM b ON a.MOBITEMECN=b.Default1 AND B.TenantId='{1}' "; - values.Add("MOBITEMECN", "a.MOBITEMECN"); - values.Add("MUSER", "'" + ConstWorkPoint.Muser + "'"); - values.Add("MUSERName", "'" + ConstWorkPoint.Musername + "'"); - values.Add("WorkPoint", "'" + WorkPoint + "'"); - sql += "\r\n"; - //插入新增数据 - sql += ICSHelper.InsertSQL("ICSMOBOM", values) - + @" #TempBOM a - LEFT JOIN ICSMOBOM b ON a.MOBITEMECN=b.MOBITEMECN - WHERE b.MOBITEMECN IS NULL + values.Add("Default1", "a.MOBITEMECN"); + values.Add("CreationTime", "a.MTime");//操作人 + values.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 + values.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 + values.Add("TenantId", "'" + TenantId + "'");//站点 + + sql += "\r\n"; + //插入新增数据 + sql += ICSHelper.InsertSQL("ICSMOBOM", values) + + @" #TempPick a + LEFT JOIN ICSMOBOM b ON a.MOBITEMECN=b.Default1 AND B.TenantId='{1}' + WHERE b.Default1 IS NULL "; - sql += "DROP TABLE #TempBOM"; - sql = string.Format(sql, WorkPoint); - ICSHelper.ExecuteDate(conStr, sql); - #endregion + sql += "DROP TABLE #TempPick"; + sql = string.Format(sql, erpName, TenantId); + //return; + ICSHelper.ExecuteDate(conStr, sql); + #endregion + } } catch (Exception ex) { diff --git a/ICSSoft.FromERP/ICSSoft.FromERP.csproj b/ICSSoft.FromERP/ICSSoft.FromERP.csproj index abe9feb..640371f 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj +++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj @@ -102,6 +102,7 @@ +