diff --git a/ICSSoft.FromERP/ICSInventory_PaiNaWeiS.cs b/ICSSoft.FromERP/ICSInventory_PaiNaWeiS.cs index 2110d6d..24e3918 100644 --- a/ICSSoft.FromERP/ICSInventory_PaiNaWeiS.cs +++ b/ICSSoft.FromERP/ICSInventory_PaiNaWeiS.cs @@ -182,11 +182,11 @@ a.DescFlexField_PrivateDescSeg2 ItemDrawingNo opDic.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 opDic.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 bindSql += ICSHelper.InsertSQL("ICSOP", opDic) - +$@" #TempOp a + + $@" #TempOp a LEFT JOIN ICSOP b on a.OPCODE=b.OPCODE and b.TenantId='{TenantId}' WHERE 1=1 and b.OPCODE is null"; - bindSql+=$"\r\n select '{route}' as RouteCode,'{routeDesc}' as RouteName Into #TempRoute "; + bindSql += $"\r\n select '{route}' as RouteCode,'{routeDesc}' as RouteName Into #TempRoute "; Dictionary routeDic = new Dictionary(); routeDic.Add("RouteCode", "A.RouteCode"); routeDic.Add("RouteName", "A.RouteName"); @@ -199,7 +199,7 @@ a.DescFlexField_PrivateDescSeg2 ItemDrawingNo routeDic.Add("CreationTime", "GETDATE()");//操作时间 routeDic.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 routeDic.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 - bindSql+=ICSHelper.InsertSQL("ICSROUTE", routeDic) + bindSql += ICSHelper.InsertSQL("ICSROUTE", routeDic) + $@"#TempRoute a LEFT JOIN ICSROUTE b on a.ROUTECODE=b.ROUTECODE and b.TenantId='{TenantId}' WHERE 1=1 and b.ID is null "; @@ -237,7 +237,7 @@ a.DescFlexField_PrivateDescSeg2 ItemDrawingNo ItemRouteDic.Add("CreationTime", "GETDATE()");//操作时间 ItemRouteDic.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 ItemRouteDic.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 - bindSql += ICSHelper.InsertSQL("ICSITEM2ROUTE",ItemRouteDic) + bindSql += ICSHelper.InsertSQL("ICSITEM2ROUTE", ItemRouteDic) + $@"(select a.ItemCode,a.Id as ItemId,c.id as ROUTEID,c.routeCode from IcsInventory a --left join IcsItem2Route b on a.ItemCode=b.ItemCode and a.TenantId=b.TenantId left join IcsRoute c on c.routeCode='{route}' and c.TenantId=a.TenantId @@ -266,13 +266,15 @@ a.DescFlexField_PrivateDescSeg2 ItemDrawingNo ItemOpDic.Add("CreatorUserId", "'" + ConstWorkPoint.Muser + "'");//操作人 ItemOpDic.Add("CreatorUserName", "'" + ConstWorkPoint.Musername + "'");//操作人名称 - bindSql+=ICSHelper.InsertSQL("ICSITEMROUTE2OP", ItemOpDic) - + $@"(select a.ItemCode,a.Id as ItemId,c.id as RouteId,c.RouteCode,d.OpCode,d.OpId,d.OpSeq from IcsInventory a - left join IcsRoute c on c.routeCode='{route}' and c.TenantId=a.TenantId - left join IcsRoute2Op d on d.RouteCode=c.RouteCode and d.TenantId=a.TenantId - where a.TenantId='{TenantId}') a - LEFT JOIN ICSITEMROUTE2OP b on a.ROUTECODE=b.ROUTECODE and A.ITEMCODE=B.ITEMCODE AND A.OPCODE=B.OPCODE AND b.TenantId='{0}' - WHERE 1=1 and b.ID is null"; + bindSql += ICSHelper.InsertSQL("ICSITEMROUTE2OP", ItemOpDic) + + $@"(select a.ItemCode,a.Id as ItemId,c.id as RouteId,c.RouteCode,d.OpCode,d.OpId,d.OpSeq + from IcsInventory a + inner join IcsRoute c on c.routeCode='{route}' and c.TenantId=a.TenantId + inner join IcsRoute2Op d on d.RouteCode=c.RouteCode and d.TenantId=a.TenantId + where a.TenantId='{TenantId}' + and not exists (select 1 from ICSITEMROUTE2OP b where c.ROUTECODE=b.ROUTECODE and A.ITEMCODE=B.ITEMCODE + AND d.OPCODE=B.OPCODE AND b.TenantId='{TenantId}')) a + "; log.Info(bindSql); ICSHelper.ExecuteDate(conStr, bindSql); #endregion diff --git a/ICSSoft.FromERP/ICSMo.cs b/ICSSoft.FromERP/ICSMo.cs index de0d79a..0b90291 100644 --- a/ICSSoft.FromERP/ICSMo.cs +++ b/ICSSoft.FromERP/ICSMo.cs @@ -116,7 +116,7 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate left join {1}.dbo.[CBO_Department_Trl] as A14 With(NoLock) on (A14.SysMlFlag = 'zh-CN') and (A13.[ID] = A14.[ID]) LEFT JOIN {1}.dbo.[CBO_Wh] AS A22 With(NoLock) ON A22.ID=A.CompleteWh - where (A.DocState=2 OR A.DocState=3) and A.[BusinessType] != 50 and (A.[BusinessType] != 52) + where (A.DocState=2) and A.[BusinessType] != 50 and (A.[BusinessType] != 52) and (A.[BusinessType] != 2417) and (A.[IsMultiRouting] != 1) and A.[ItemMaster] is not null --and (A.[IsStartMO] != 1) and ISNULL(A.ModifiedOn,A.BusinessCreatedOn)>=@LastTime AND A12.id='{0}' @@ -184,10 +184,10 @@ else Convert(varchar(10),a.ActualCompleteDate,120 ) end as ActualCompleteDate INNER JOIN ICSMO b ON a.Mocode=b.Mocode WHERE b.TenantId='{0}' and a.Org={2} "; - // values.Add("ID", "NEWID()"); + // values.Add("ID", "NEWID()");. values.Add("MoType", "'normal'");//辅机数量 values.Add("MOVER", "'1'");//辅机数量 - values.Add("ProjectCode", "a.ProjectCode");//辅机数量 + values.Add("ProjectCode", "a.NeedType");//需求分类 values.Add("MOINPUTQTY", "0");//辅机数量 values.Add("MOSCRAPQTY", "0");//辅机数量