- 打卡等级:无名新人
- 打卡总天数:2
- 打卡月天数:2
- 打卡总奖励:6
- 最近打卡:2024-12-18 13:57:37
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
SELECT TOP 10000 [Inventory].code AS Inventory_Code, [Inventory].name AS Inventory_Name, [Inventory].priuserdefnvc4 AS Inventory_priuserdefnvc4, [Unit].name AS Unit_Name, [PurchaseRequisitionDetailDTO].quantity AS Quantity
, [PurchaseRequisitionDetailDTO].cumExecuteQuantity AS cumExecuteQuantity
, CASE
WHEN [PurchaseRequisitionDetailDTO].quantity < isnull([PurchaseRequisitionDetailDTO].cumExecuteQuantity, 0) THEN 0
ELSE [PurchaseRequisitionDetailDTO].quantity - isnull([PurchaseRequisitionDetailDTO].cumExecuteQuantity, 0)
END AS CurrentArrivalQuantity, [PurchaseRequisitionDetailDTO].requireDate AS RequireDate, [PurchaseRequisitionDetailDTO].id AS ID, [PurchaseRequisitionDetailDTO].idPurchaseRequisitionDTO AS IdpurchaseRequisitionDTO, [PurchaseRequisitionDetailDTO].code AS code
, [PurchaseRequisition].code AS PurchaseRequisition_code, [PurchaseRequisition].id AS PurchaseRequisition_id, [Unit].id AS Unit_id, [Inventory].id AS Inventory_id
FROM [Pu_PurchaseRequisition_b] [PurchaseRequisitionDetailDTO]
LEFT JOIN [Pu_PurchaseRequisition] [PurchaseRequisition] ON [PurchaseRequisitionDetailDTO].idPurchaseRequisitionDTO = [PurchaseRequisition].id
LEFT JOIN [V_AA_Partner] [PurchaseRequisition.SuggPartner] ON [PurchaseRequisition].idsuggpartner = [PurchaseRequisition.SuggPartner].id
LEFT JOIN [AA_Unit] [Unit] ON [PurchaseRequisitionDetailDTO].idunit = [Unit].id
LEFT JOIN [V_AA_Inventory] [Inventory] ON [PurchaseRequisitionDetailDTO].idinventory = [Inventory].id
WHERE 1 = 1
AND ( --是否劳务费用 --请购单明细DTO数量不为空且等于0
([Inventory].IsLaborCost = 1 AND isnull(PurchaseRequisitionDetailDTO.quantity, 0) = 0)
OR --是否单计量 --数量绝对值是否大于等于累计执行数量
([Unit].IsSingleUnit = 1 AND ABS(PurchaseRequisitionDetailDTO.Quantity) > ABS(isnull(PurchaseRequisitionDetailDTO.cumExecuteQuantity, 0)))
OR
([Unit].IsSingleUnit = 0 --不为单计量
AND [Unit].ChangeType1 = N'24' --变动类型 是否为24
AND (ABS(PurchaseRequisitionDetailDTO.Quantity) > ABS(isnull(PurchaseRequisitionDetailDTO.cumExecuteQuantity, 0))
AND ABS(PurchaseRequisitionDetailDTO.Quantity2) > ABS(isnull(PurchaseRequisitionDetailDTO.cumExecuteQuantity2, 0)))) --数量1、2绝对值是否大于等于累计执行数量1、2
OR ([Unit].IsSingleUnit = 0 --不为单计量
AND [Unit].ChangeType1 = N'152' --变动类型 是否为152
AND (ABS(PurchaseRequisitionDetailDTO.Quantity) > ABS(isnull(PurchaseRequisitionDetailDTO.cumExecuteQuantity, 0))
OR ABS(PurchaseRequisitionDetailDTO.Quantity2) > ABS(isnull(PurchaseRequisitionDetailDTO.cumExecuteQuantity2, 0)))) --数量1、2绝对值是否大于等于累计执行数量1、2
)
AND PurchaseRequisitionDetailDTO.IsPraRequire = 0
AND PurchaseRequisitionDetailDTO.IsClose = 0
AND [PurchaseRequisition].VoucherState = N'189'
AND ([PurchaseRequisition.SuggPartner].Disabled = 0
OR [PurchaseRequisition].idSuggPartner IS NULL)
AND [Inventory].Disabled = 0
AND (
SELECT COUNT(dbo.XT_QueryPrice_b.id)
FROM dbo.XT_QueryPrice_b
WHERE dbo.XT_QueryPrice_b.sourceVoucherDetailId = PurchaseRequisitionDetailDTO.id
AND dbo.XT_QueryPrice_b.idsourcevouchertype = N'101'
) = 0
AND 1 = 1
AND ([Inventory].IsLaborCost = N'0'
OR [Inventory].IsLaborCost IS NULL)
AND ([PurchaseRequisition].Code >= N'PQ-2024-12-0352'
AND [PurchaseRequisition].Code <= N'PQ-2024-12-0352')
AND [PurchaseRequisition].IdmarketingOrgan = N'1'
ORDER BY [PurchaseRequisition].Code, PurchaseRequisitionDetailDTO.Code |
|