Browse Source

U9同步修改

master
陆晔 2 years ago
parent
commit
725f4e1858
  1. 2
      ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSDeliveryNotice.cs
  2. 2
      ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSMOIssue.cs
  3. 113
      ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSMo.cs

2
ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSDeliveryNotice.cs

@ -63,7 +63,7 @@ namespace ICSSoft.FromERP
0 as UnitPrice,
A1.CreatedBy as CreatePerson,
A1.CreatedOn as CreateDateTime,
1 as Status,
2 as Status,
ISNULL(A2.ModifiedOn ,A2.CreatedOn) as MTIME,
A1.ID as DNID,
isnull(A2.SrcDoc_SrcDoc_EntityID,'') as POID,

2
ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSMOIssue.cs

@ -88,7 +88,7 @@ namespace ICSSoft.FromERP
LEFT JOIN {1}.dbo.CBO_Wh G ON G.ID=B.Wh
LEFT JOIN {1}.dbo.Base_Organization H ON H.ID=A.Org
LEFT JOIN {1}.dbo.CBO_Project I ON I.ID=B.Project
where (A.IssueType=1 OR A.IssueType=2) AND A.DocState=3 AND H.Code='{0}' AND ISNULL(B.ModifiedOn,B.CreatedOn)>=@LastTime
where (A.IssueType=0 OR A.IssueType=1) AND A.DocState=3 AND H.Code='{0}' AND ISNULL(B.ModifiedOn,B.CreatedOn)>=@LastTime
update #TempRd set Colspan=isNULL(ProjectCode,'')+'~'+isNULL(cBatch,'')+'~'+isNULL(Version,'')+'~'+isNULL(Brand,'')+'~'+isNULL(cFree1,'')+'~'+isnull(cFree2,'')+'~'+isnull(cFree3,'')+'~'+isnull(cFree4,'')+'~'+isnull(cFree5,'')+'~'+isnull(cFree6,'')+'~'+isnull(cFree7,'')+'~'+isnull(cFree8,'')+'~'+isnull(cFree9,'')+'~'+isnull(cFree10,'')
select distinct

113
ICSSoft.FromU9ERP/ICSSoft.FromERP/ICSMo.cs

@ -48,50 +48,69 @@ namespace ICSSoft.FromERP
erpName = string.Format(erpName, WorkPoint);
#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,
select A.ID as ID,
A.DocNO as MOCODE,
1 as Sequence,
A7.Code as InvCode,
CASE WHEN A.IsStartMO != 1 THEN
(SELECT TOP 1 TotalStartQty FROM {1}.dbo.MO_MOStartInfo WHERE MO=A.ID ORDER BY StartDatetime DESC)
ELSE (SELECT TOP 1 ActualStartQty FROM {1}.dbo.MO_MOStartInfo WHERE MO=A.ID ORDER BY StartDatetime DESC) END as Quantity,
A.CreatedBy as CreatePerson,
A.CreatedOn as CreateDateTime,
0 as Amount,
0 as RCVQuantity,
A13.Code as DepCode,
A22.Code as WHCode,
'1' as MOStatus,
b.Remark as MOMemo,
A2.Description as MOMemo,
'2' 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 b.Free1 ELSE '' END) as cFree1,
(case WHEN inv.bFree2=1 THEN b.Free2 ELSE '' END) as cFree2,
(case WHEN inv.bFree3=1 THEN b.Free3 ELSE '' END) as cFree3,
(case WHEN inv.bFree4=1 THEN b.Free4 ELSE '' END) as cFree4,
(case WHEN inv.bFree5=1 THEN b.Free5 ELSE '' END) as cFree5,
(case WHEN inv.bFree6=1 THEN b.Free6 ELSE '' END) as cFree6,
(case WHEN inv.bFree7=1 THEN b.Free7 ELSE '' END) as cFree7,
(case WHEN inv.bFree8=1 THEN b.Free8 ELSE '' END) as cFree8,
(case WHEN inv.bFree9=1 THEN b.Free9 ELSE '' END) as cFree9,
(case WHEN inv.bFree10=1 THEN b.Free10 ELSE '' END) as cFree10,CAST('' AS NVARCHAR(500)) as Colspan
,'{0}' as WorkPoint
,(CASE WHEN b.MoClass<>1 then '1' else '0' end ) EATTRIBUTE1
A.StartDate as StartDate,
A.CompleteDate as DueDate,
A.ID as MOID,
A.ID as MODetailID,
ISNULL(A.ModifiedOn,A.BusinessCreatedOn) as MTIME,
isnull(A11.Code,'') ProjectCode,isnull(A19.LotCode,'') cBatch,'' version ,'' brand,
'' as cFree1,
'' as cFree2,
'' as cFree3,
'' as cFree4,
'' as cFree5,
'' as cFree6,
'' as cFree7,
'' as cFree8,
'' as cFree9,
'' as cFree10,CAST('' AS NVARCHAR(500)) as Colspan
,A12.Code as WorkPoint
,'0' AS EATTRIBUTE1
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.mom_orderdetail_extradefine d ON b.MoDId = d.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
--LEFT JOIN {1}.dbo.CusInvContrapose cusInv ON cusinv.cCusCode = b.CustCode AND b.InvCode = cusInv.cInvCode
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
update #TempMO set Colspan=isNULL(ProjectCode,'')+'~'+isNULL(cBatch,'')+'~'+isNULL(Version,'')+'~'+isNULL(Brand,'')+'~'+isNULL(cFree1,'')+'~'+isnull(cFree2,'')+'~'+isnull(cFree3,'')+'~'+isnull(cFree4,'')+'~'+isnull(cFree5,'')+'~'+isnull(cFree6,'')+'~'+isnull(cFree7,'')+'~'+isnull(cFree8,'')+'~'+isnull(cFree9,'')+'~'+isnull(cFree10,'')
from {1}.dbo.MO_MO as A
left join {1}.dbo.[MO_MOMemo] as A1 on (A.[ID] = A1.[MO])
left join {1}.dbo.[MO_MOMemo_Trl] as A2 on (A2.SysMlFlag = 'zh-CN') and (A1.[ID] = A2.[ID])
left join {1}.dbo.[MO_MODocType] as A3 on (A.[MODocType] = A3.[ID])
left join {1}.dbo.[MO_MODocType_Trl] as A4 on (A4.SysMlFlag = 'zh-CN') and (A3.[ID] = A4.[ID])
left join {1}.dbo.[MO_MOTaskPlan] as A5 on (A.[ID] = A5.[MO])
left join {1}.dbo.[Base_User] as A6 on (A.ModifiedBy = A6.Code)
left join {1}.dbo.[CBO_ItemMaster] as A7 on (A.[ItemMaster] = A7.[ID])
left join {1}.dbo.[MO_MO_Trl] as A8 on (A8.SysMlFlag = 'zh-CN') and (A.[ID] = A8.[ID])
left join {1}.dbo.[CBO_BOMVersion] as A9 on (A.[BOMVersion] = A9.[ID])
left join {1}.dbo.[CBO_ItemMaster_Trl] as A10 on (A10.SysMlFlag = 'zh-CN') and (A7.[ID] = A10.[ID])
left join {1}.dbo.[CBO_Project] as A11 on (A.[Project] = A11.[ID])
left join {1}.dbo.[Base_Organization] as A12 on (A.[Org] = A12.[ID])
left join {1}.dbo.[CBO_Department] as A13 on (A.[Department] = A13.[ID])
left join {1}.dbo.[CBO_Department_Trl] as A14 on (A14.SysMlFlag = 'zh-CN') and (A13.[ID] = A14.[ID])
left join {1}.dbo. MO_MO As A16 on A16.[MODocType]=1001603110990023 and A.[Project]=A16.Project and A.ItemMaster=A16.ItemMaster
left join {1}.dbo.[CBO_ItemMaster] as A17 on (A16.[ItemMaster] = A17.[ID])
left join {1}.dbo.[CBO_ItemMaster_Trl] as A18 on (A18.SysMlFlag = 'zh-CN') and (A17.[ID] = A16.[ID])
left join {1}.dbo.[MO_MOLot] as A19 on (A16.[ID] = A19.[MO])
left join (select * from (select ROW_NUMBER() over( partition by dept order by code desc ) row,* from {1}.dbo.CBO_Operators with(nolock) ) bb
where bb.row='1' )as A20 on A20.dept=A.Department and a20.Org=a.Org
left join {1}.dbo.[MO_IssueDoc] as A21 on A21.[SourceDoc_SrcDocNo]=A.DocNo
LEFT JOIN {1}.dbo.[CBO_Wh] AS A22 ON A22.ID=A.CompleteWh
where (A.DocState=2 OR A.DocState=3) 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.Code='{0}'
update #TempMO set Colspan=isNULL(ProjectCode,'')+'~'+isNULL(cBatch,'')+'~'+isNULL(Version,'')+'~'+isNULL(Brand,'')+'~'+isNULL(cFree1,'')+'~'+isnull(cFree2,'')+'~'+isnull(cFree3,'')+'~'+isnull(cFree4,'')+'~'+isnull(cFree5,'')+'~'+isnull(cFree6,'')+'~'+isnull(cFree7,'')+'~'+isnull(cFree8,'')+'~'+isnull(cFree9,'')+'~'+isnull(cFree10,'')
select distinct
Colspan,ProjectCode,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint,cBatch,version ,brand
INTO #TempExtensionMO
@ -130,13 +149,13 @@ namespace ICSSoft.FromERP
WHERE b.Colspan IS NULL";
sql += @"--删除数据
-- DELETE ICSMO WHERE MODetailID NOT IN (SELECT CAST(MoDId AS VARCHAR) FROM {1}.dbo.[mom_orderdetail])
SELECT a.MODetailID INTO #tableICSMO
FROM ICSMO a With(NoLock)
LEFT JOIN {1}.dbo.[mom_orderdetail] b With(NoLock) ON a.MODetailID=CAST(b.MoDId AS VARCHAR)
WHERE a.WorkPoint='{0}' and b.MoDId IS NULL
SELECT a.MODetailID INTO #tableICSMO
FROM ICSMO a With(NoLock)
LEFT JOIN {1}.dbo.[MO_MO] b With(NoLock) ON a.MODetailID=b.ID
WHERE a.WorkPoint='{0}' and b.ID IS NULL
DELETE ICSMO
WHERE WorkPoint='{0}' and MODetailID IN ( SELECT MODetailID from #tableICSMO)
DELETE ICSMO
WHERE WorkPoint='{0}' and MODetailID IN ( SELECT MODetailID from #tableICSMO)
";
Dictionary<string, string> values = new Dictionary<string, string>();
values.Add("MOCODE", "a.MOCODE");//工单号

Loading…
Cancel
Save