From a68210003e80bee37efdd2a13082971c26fc3e2c Mon Sep 17 00:00:00 2001 From: xuli Date: Thu, 31 Oct 2024 17:50:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=B8=BF=E5=9F=BA-=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=90=8C=E6=AD=A5FromU8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/ICSSoft.FromERP/v14/.suo | Bin 258048 -> 258048 bytes ICSSoft.FromERP/ICSMoFromU8_XinHJ.cs | 213 +++++++++++++++++++++++++ ICSSoft.FromERP/ICSSoft.FromERP.csproj | 1 + 3 files changed, 214 insertions(+) create mode 100644 ICSSoft.FromERP/ICSMoFromU8_XinHJ.cs diff --git a/.vs/ICSSoft.FromERP/v14/.suo b/.vs/ICSSoft.FromERP/v14/.suo index a8549eae55835bc5abde7fd81f7456e63e550d3d..ba85d59a15a8b21a1dbafa33a076473ab4e66b7c 100644 GIT binary patch delta 8904 zcmeI13tZG?y2s~z-x)w98K#j?5eJ+U1pzO4S4JT-yaA$-nIIy8$yGGGGLoB@+`{?S zJXu;a*S3kZA*?9QroK9WS4P><<|Veh=c2H$gUmKA;N-0?kT}_P(Gbq!K}IFad;vK+qm2 z<=Q}_9AX4AQu;x5lohA6fguynuN?Pl$YCfP1;&6pFdEEObRD{vJcg77{1#75g8UXO zQXtJ>GDrm-fGqz{$R5B4Aln?@B4Z#ETGC1AN7hY6ewHk6$$y4)4#)&gfGjYHVPf*( zrN~IR8!{g}4{||bOJi9lKNDN>zd+qWrC{~FJ}Z!tHOe=-%8))VMmUhG?h6^&l8%P# zC)2xT4R;&*>Zd8Aq@hdE`g=pWZu=P6MAK5i>66Nu_EE-}NJ&!_gFiFXA5ieOOtnbS>3Xs2O2PK~*5~^w2|C{r3!2D@ z$azZrx29vEq6Nqof?1$9^6gsc@7BK=b?Gg2($06QKL+()DDMHJ&3hpK2qe@Ws#%Cc zHjsv00+sFF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AK&=%zHW-0{YKs!so#+|eVplMJmXGY$aR!xJXNjAYskGHDfxp{{tWS4qYI}hUl zCto9HUxC;W8-n|sva78;OLWAAc;z*H{ zbs_vCP3tXk64iXK^DO(Dy*X7}+7yHKbF}(2wUhJFHl~WmULG*1G^CS19&h$|98uWa zx@lBqIQa(KD`FnZ#l~NdgPTtBYHU8ii=``;iXG<-#K-dg4S%OIB}Y&&#qf3#{d*ZN z?HjUQqn#a{hdm*;cQe%Zi5;g&p|opIm-8vunM7fy8sR*z^z7R@&(RDfA}^KV5W^;W zqE5l-T(LL7Pr1@T`vwfYz&Ar3#tLGCuJhbXJ@in86%RUj0j&kX=(j+O7{wDCj`1M( yVv_)oZVJK9%giLn`)@29=K9ddr2Kn?{MUo)9nK`M^#Y4gV&3PMbXd}p_5E*Dc_vK& diff --git a/ICSSoft.FromERP/ICSMoFromU8_XinHJ.cs b/ICSSoft.FromERP/ICSMoFromU8_XinHJ.cs new file mode 100644 index 0000000..296b0e3 --- /dev/null +++ b/ICSSoft.FromERP/ICSMoFromU8_XinHJ.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using Quartz; + + +namespace ICSSoft.FromERP +{ + /// + /// 工单(来源U8) -新鸿基 + /// + public class ICSMoFromU8_XinHJ : IJob + { + private static object key = new object(); + private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public void Execute(IJobExecutionContext context) + { + try + { + lock (key) + { + log.Info("开始……………………………………………………………………"); + Execute(); + log.Info("结束……………………………………………………………………"); + } + } + catch (Exception ex) + { + log.Error(ex.ToString()); + } + } + + public void Execute() + { + try + { + string conStr = ICSHelper.GetConnectString(); + string Namespace = this.GetType().Namespace; + //string Class = this.GetType().Name; + DataTable dt = ICSHelper.GetERPDB(conStr); + + string erpNames = ICSHelper.GetConfigString()["Workpoint_ERPDB"]; + List DBS = erpNames.Split(',').ToList(); + List ListDB = new List(); + foreach (string DB in DBS) + { + if (DB.Split('|') != null && DB.Split('|').Count() > 1) + { + WorkpointERPDBLink wd = new WorkpointERPDBLink(); + wd.Workpoint = DB.Split('|')[0]; + wd.ERPDB = DB.Split('|')[1]; + ListDB.Add(wd); + } + } + + 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; + + WorkpointERPDBLink dblink = ListDB.FindLast(a => a.Workpoint == TenantCode); + if (dblink == null) + { + return; + } + string erpName = dblink.ERPDB; + + //erpName = string.Format(erpName, TenantId); + #region SQL + string sql = @" + + + select CAST(b.MoDId as VARCHAR(50)) as ID, + a.MoCode as MOCODE, + b.SortSeq as Sequence, + b.InvCode as InvCode, + b.Qty as Quantity, + a.CreateUser as CreatePerson, + a.CreateTime as CreateDateTime, + isnull(b.AuxQty,0) as Amount, + isnull(b.QualifiedInQty,0) as RCVQuantity, + b.MDeptCode as DepCode, + b.WhCode as WHCode, + case when b.CloseUser is not null then 'mostatus_initial' else 'mostatus_close' end as MOStatus, + b.Remark as MOMemo, + case when b.CloseUser is not null then '3' else '2' end as ERPStatus, + c.StartDate as StartDate, + c.DueDate as DueDate, + a.MoId as MOID, + b.MoDId as MODetailID, + + 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, + isnull(b.CostItemCode,'') ProjectCode,isnull(b.MoLotCode,'') cBatch,'' version ,'' brand, + (case WHEN inv.bFree1=1 THEN isnull(b.Free1,'') ELSE '' END) as cFree1, + (case WHEN inv.bFree2=1 THEN isnull(b.Free2,'') ELSE '' END) as cFree2, + (case WHEN inv.bFree3=1 THEN isnull(b.Free3,'') ELSE '' END) as cFree3, + (case WHEN inv.bFree4=1 THEN isnull(b.Free4,'') ELSE '' END) as cFree4, + (case WHEN inv.bFree5=1 THEN isnull(b.Free5,'') ELSE '' END) as cFree5, + (case WHEN inv.bFree6=1 THEN isnull(b.Free6,'') ELSE '' END) as cFree6, + (case WHEN inv.bFree7=1 THEN isnull(b.Free7,'') ELSE '' END) as cFree7, + (case WHEN inv.bFree8=1 THEN isnull(b.Free8,'') ELSE '' END) as cFree8, + (case WHEN inv.bFree9=1 THEN isnull(b.Free9,'') ELSE '' END) as cFree9, + (case WHEN inv.bFree10=1 THEN isnull(b.Free10,'') ELSE '' END) as cFree10, + CAST('' AS NVARCHAR(500)) as Colspan, + b.MoLotCode 生产批号,b.Free1 零件版本,b.Free2 图纸版本 + + INTO #TempMO + FROM {1}.dbo.mom_order a + INNER JOIN {1}.dbo.mom_orderdetail b ON a.MoId = b.MoId + INNER JOIN {1}.dbo.mom_morder c ON b.MoDId = c.MoDId + LEFT JOIN {1}.dbo.Inventory inv ON b.InvCode = inv.cInvCode + LEFT JOIN {1}.dbo.Customer cus ON b.CustCode = cus.cCusCode + LEFT JOIN {1}.dbo.SO_SODetails so ON b.OrderDId = so.iSOsID + + 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 + + IF NOT EXISTS(SELECT * FROM #TempMO) + begin + DROP TABLE #TempMO + RETURN + + end"; + sql = string.Format(sql, ErpId, erpName); + sql = ICSHelper.Time(Namespace, Class, TenantId, sql, "#TempMO"); + Dictionary value = new Dictionary(); + + + sql += @"--删除数据 + + SELECT a.ID INTO #tableICSMO + FROM ICSMO a With(NoLock) + LEFT JOIN {1}.dbo.[mom_order] b With(NoLock) ON a.Mocode=b.MoCode + left JOIN {1}.dbo.mom_orderdetail b2 ON b.MoId = b2.MoId AND A.MoSeq=B2.SortSeq + WHERE a.TenantId='{0}' and B2.SortSeq IS NULL + + DELETE FROM ICSMO + WHERE TenantId='{0}' and ID IN ( SELECT ID from #tableICSMO ) + "; + Dictionary values = new Dictionary(); + values.Add("MoCode", "a.MOCODE");//工单号 + values.Add("MoSeq", "a.Sequence");//工单行号 + values.Add("ItemCode", "a.InvCode");//物料代码 + values.Add("MoPlanQty", "a.Quantity");//数量 + values.Add("Amount", "a.Amount"); + values.Add("DepCode", "a.DepCode"); + values.Add("SegCode", "a.DepCode"); + values.Add("WHCode", "a.WHCode");//仓库 + values.Add("MoPlanStartDate", "a.StartDate");//开工日 + values.Add("MoPlanEndDate", "a.DueDate");//完工日 + + values.Add("MOMemo", "a.MOMemo");//生产订单状态 + values.Add("MoUser", "a.CreatePerson");//生产订单状态 + values.Add("MODOWNDATE", "a.CreateDateTime");//生产订单状态 + values.Add("MOID", "a.MoId");//生产订单状态 + values.Add("MODetailID", "a.MODetailID");//生产订单状态 + values.Add("LastModifierUserId", "'" + ConstWorkPoint.Muser + "'"); + values.Add("LastModifierUserName", "'" + ConstWorkPoint.Musername + "'"); + values.Add("LastModificationTime", "a.Mtime");//操作时间 + values.Add("Defaultl", "a.生产批号");//完工日 + values.Add("Default2", "a.零件版本");//完工日 + values.Add("Default3", "a.图纸版本");//完工日 + + //更新存在数据 + sql += ICSHelper.UpdateSQL("b", values) + + @" #TempMO a + INNER JOIN ICSMO b ON a.Mocode=b.Mocode AND A.Sequence=B.MoSeq + WHERE b.TenantId='{0}' "; + + // values.Add("ID", "NEWID()"); + values.Add("MoType", "'normal'");//辅机数量 + values.Add("MOVER", "'1'");//辅机数量 + values.Add("ProjectCode", "a.ProjectCode");//辅机数量 + + values.Add("MOINPUTQTY", "0");//辅机数量 + values.Add("MOSCRAPQTY", "0");//辅机数量 + values.Add("MOACTQTY", "0");//辅机数量 + values.Add("CollectModel", "'SS'");//辅机数量 + values.Add("CollectType", "'collecttype_one'");//辅机数量 + values.Add("MoBom", "'1'");//辅机数量 + values.Add("CreationTime", "a.MTime");//操作人 + values.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 + values.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 + values.Add("TenantId", "'" + TenantId + "'");//站点 + values.Add("MOSTATUS", "a.MOStatus");//生产订单状态 + //插入新增数据 + sql += ICSHelper.InsertSQL("ICSMO", values) + + @" #TempMO a + LEFT JOIN ICSMO b on a.Mocode=b.Mocode AND A.Sequence=B.MoSeq and b.TenantId='{0}' + WHERE 1=1 and b.MoCode is null "; + sql += "DROP TABLE #TempMO"; + sql += " DROP TABLE #tableICSMO "; + sql = string.Format(sql, TenantId, erpName, ErpId); + //return; + ICSHelper.ExecuteDate(conStr, sql); + #endregion + } + } + catch (Exception ex) + { + log.Error(ex.ToString()); + } + } + } +} diff --git a/ICSSoft.FromERP/ICSSoft.FromERP.csproj b/ICSSoft.FromERP/ICSSoft.FromERP.csproj index 5fe1025..06b9c9a 100644 --- a/ICSSoft.FromERP/ICSSoft.FromERP.csproj +++ b/ICSSoft.FromERP/ICSSoft.FromERP.csproj @@ -107,6 +107,7 @@ +