即时库存原创
26人赞赏了该文章
152次浏览
编辑于2024年09月30日 16:33:52
SELECT M.FMATERIALID '物料ID',M.FNUMBER '物料编码',ML.FNAME '物料名称',TSK.FSTOCKID '仓库ID',TSK.FNUMBER '仓库编码',TSL.FNAME '仓库名称',TI.FBASEQTY '即时库存' FROM T_STK_INVENTORY TI LEFT JOIN T_ORG_ORGANIZATIONS_L OL ON TI.FSTOCKORGID = OL.FORGID AND OL.FLOCALEID = 2052 --组织名称表 INNER JOIN T_BD_MATERIAL M ON M.FMASTERID = TI.FMATERIALID AND ( M.FUSEORGID = TI.FSTOCKORGID OR EXISTS ( SELECT 1 FROM T_META_BASEDATATYPE BT WHERE BT.FBASEDATATYPEID = 'BD_MATERIAL' AND BT.FSTRATEGYTYPE = 1)) --物料类型 1==外购 INNER JOIN T_BD_MATERIALBASE AS m2 ON M.FMATERIALID = m2.FMATERIALID LEFT JOIN T_BD_MATERIAL_L ML ON ( M.FMATERIALID = ML.FMATERIALID AND ML.FLOCALEID = 2052) INNER JOIN T_BD_MATERIALSTOCK TMS ON M.FMATERIALID = TMS.FMATERIALID INNER JOIN T_BD_MATERIALPRODUCE MP ON M.FMATERIALID = MP.FMATERIALID LEFT JOIN T_ENG_BOM TB ON ( TB.FMASTERID = TI.FBOMID AND ( TB.FUSEORGID = TI.FSTOCKORGID OR EXISTS ( SELECT 1 FROM T_META_BASEDATATYPE BT WHERE ( BT.FBASEDATATYPEID = 'ENG_BOM' AND BT.FSTRATEGYTYPE = 1)))) ------库存状态 LEFT JOIN T_BD_STOCKSTATUS_L TSSL ON ( TI.FSTOCKSTATUSID = TSSL.FSTOCKSTATUSID AND TSSL.FLOCALEID = 2052) LEFT JOIN T_BD_LOTMASTER TL ON ( ( TI.FLOT = TL.FMASTERID AND TI.FSTOCKORGID = TL.FUSEORGID) AND TL.FBIZTYPE = '1') LEFT JOIN T_BD_UNIT TUS ON TMS.FSTOREUNITID = TUS.FUNITID LEFT JOIN T_BD_UNIT_L TUL0 ON ( TMS.FSTOREUNITID = TUL0.FUNITID AND TUL0.FLOCALEID = 2052) INNER JOIN T_BD_STOCK TSK ON ( TSK.FMASTERID = TI.FSTOCKID AND ( TSK.FUSEORGID = TI.FSTOCKORGID OR EXISTS ( SELECT 1 FROM T_META_BASEDATATYPE BT WHERE ( BT.FBASEDATATYPEID = 'BD_STOCK' AND BT.FSTRATEGYTYPE = 1)))) LEFT JOIN T_BD_STOCK_L TSL ON ( TSL.FSTOCKID = TI.FSTOCKID AND TSL.FLOCALEID = 2052) LEFT JOIN T_BD_STOCKGROUP TSKG ON TSK.FGROUP = TSKG.FID LEFT JOIN T_BD_STOCKGROUP_L TSKGL ON TSKG.FID = TSKGL.FID LEFT JOIN T_BD_UNIT_L TUL1 ON ( TI.FBASEUNITID = TUL1.FUNITID AND TUL1.FLOCALEID = 2052) LEFT JOIN T_BD_UNIT TUE ON TMS.FAUXUNITID = TUE.FUNITID LEFT JOIN T_BD_UNIT_L TUL2 ON ( TI.FSECUNITID = TUL2.FUNITID AND TUL2.FLOCALEID = 2052) LEFT JOIN V_ITEMCLASS_OWNER VO ON ( ( VO.fmasterid = TI.FOWNERID AND VO.fformid = TI.FOWNERTYPEID) AND ( VO.fuseorgid = TI.FSTOCKORGID OR VO.fuseorgid = 0 OR EXISTS ( SELECT 1 FROM T_META_BASEDATATYPE BT WHERE ( BT.FBASEDATATYPEID = VO.fformid AND BT.FSTRATEGYTYPE = 1)))) LEFT JOIN V_ITEMCLASS_OWNER_L VO_L ON ( VO.fitemid = VO_L.fitemid AND VO_L.FLOCALEID = 2052) LEFT JOIN V_ITEMCLASS_KEEPER VK ON ( ( VK.fmasterid = TI.FKEEPERID AND VK.fformid = TI.FKEEPERTYPEID) AND ( VK.fuseorgid = TI.FSTOCKORGID OR VK.fuseorgid = 0 OR EXISTS ( SELECT 1 FROM T_META_BASEDATATYPE BT WHERE ( BT.FBASEDATATYPEID = VK.fformid AND BT.FSTRATEGYTYPE = 1)))) LEFT JOIN V_ITEMCLASS_KEEPER_L VK_L ON ( VK.fitemid = VK_L.fitemid AND VK_L.FLOCALEID = 2052);
赞 26
26人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读