h.company_code as "companyCode", <!-- 公司编码(预留) -->
ha.company_code as "companyCode",
h.company_name as "companyName", <!-- 公司名称(预留) -->
ha.company_name as "companyName",
h.proj_code as "projCode", <!-- 项目编码(预留) -->
ha.proj_code as "projCode",
h.proj_name as "projName", <!-- 项目名称(预留) -->
ha.proj_name as "projName",
ha.product_code as "productCode", <!-- 产品编号 -->
ha.product_code as "productCode",
ha.product_name as "productName", <!-- 产品名称 -->
ha.product_name as "productName",
ha.spec as "spec", <!-- 规格 -->
ha.spec as "spec",
ha.length as "length", <!-- 长 -->
ha.length as "length",
ha.width as "width", <!-- 宽 -->
ha.width as "width",
ha.thick as "thick", <!-- 厚 -->
ha.thick as "thick",
ha.quantity as "quantity", <!-- 数量 -->
ha.quantity as "quantity",
ha.single_weight as "singleWeight", <!-- 单重 -->
ha.single_weight as "singleWeight",
ha.total_weight as "totalWeight", <!-- 总重 -->
ha.total_weight as "totalWeight",
ha.DEPOSIT_DATE as "depositDate", <!-- 入库日期 -->
ha.DEPOSIT_DATE as "depositDate",
ha.INV_QTY as "invQty", <!-- 数量 -->
ha.INV_QTY as "invQty",
ha.INV_UNIT_WEIGHT as "invUnitWeight", <!-- 单重 -->
ha.INV_UNIT_WEIGHT as "invUnitWeight",
ha.INV_WEIGHT as "invWeight", <!-- 重量 -->
ha.INV_WEIGHT as "invWeight",
hb.product_code as "clproductCode" , <!-- 产品编号 -->
hb.product_name as "clproductName", <!-- 产品名称 -->
hb.product_code as "clproductCode" ,
hb.spec as "clspec", <!-- 规格 -->
hb.product_name as "clproductName",
hb.length as "cllength", <!-- 长 -->
hb.spec as "clspec",
hb.width as "clwidth", <!-- 宽 -->
hb.length as "cllength",
hb.thick as "clthick", <!-- 厚 -->
hb.width as "clwidth",
hb.quantity as "clquantity", <!-- 数量 -->
hb.thick as "clthick",
hb.total_weight as "cltotalWeight", <!-- 总重 -->
hb.quantity as "clquantity",
hb.RECEIPT_DATE as "receiptDate", <!-- 领料日期 -->
hb.total_weight as "cltotalWeight",
hb.INV_QTY as "llinvQty", <!-- 数量 -->
hb.INV_WEIGHT as "llinvWeight" <!-- 重量 -->
hb.RECEIPT_DATE as "receiptDate",
from hggp.hgsc004 h
hb.INV_QTY as "llinvQty",
join (
hb.INV_WEIGHT as "llinvWeight",
select
case when ifnull(ha.INV_WEIGHT,0)>0 and ifnull(hb.INV_WEIGHT,0)>0 then round((ifnull(ha.INV_WEIGHT,0)*1.0000) / (ifnull(hb.INV_WEIGHT,0)* 1.0000),4)*100 else 0 end "ccl"
h.id , <!-- 主键 -->
from
h.company_code , <!-- 公司编码(预留) -->
(
h.company_name , <!-- 公司名称(预留) -->
h.proj_code , <!-- 项目编码(预留) -->
h.proj_name , <!-- 项目名称(预留) -->
h.parent_prod_code , <!-- 父节点-产品编码 -->
h.parent_prod_name , <!-- 父节点-产品名称 -->
h.material_id , <!-- 物料清单id -->
h.product_id , <!-- 产品id -->
h.product_type , <!-- 产品类别 -->
h.product_code , <!-- 产品编号 -->
h.product_name , <!-- 产品名称 -->
h.invent_type , <!-- 档案类型 -->
h.spec , <!-- 规格 -->
h.length , <!-- 长 -->
h.width , <!-- 宽 -->
h.thick , <!-- 厚 -->
h.quantity , <!-- 数量 -->
h.single_weight , <!-- 单重 -->
h.total_weight , <!-- 总重 -->
h.approval_status , <!-- 审批状态 0:待审;1:审核中;2:已审 -->
h.leaf , <!-- 是否有叶子节点 -->
h.sort , <!-- 排序字段 -->
h.lv , <!-- 层级 -->
k.DEPOSIT_DATE , <!-- 入库日期 -->
k.INV_QTY , <!-- 数量 -->
k.INV_UNIT_WEIGHT , <!-- 单重 -->
k.INV_WEIGHT <!-- 重量 -->
from hggp.hgsc004a h
left join hggp.hgkc003 k on h.company_code = k.COMPANY_CODE and h.proj_code = k.PROJ_CODE
and h.product_code = k.PRDT_CODE
and k.DELETE_FLAG = 0
where h.product_status = 1 and h.lv = 3
<isNotEmptyprepend=" AND "property="accountCode">
h.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyCode">
h.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyName">
h.COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="projCode">
h.proj_code = #projCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="projName">
h.proj_name = #projName#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="productCode">
h.product_code = #productCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="depositDate">
k.DEPOSIT_DATE = #depositDate#
</isNotEmpty>
) ha on h.id = ha.material_id
join (
select
h.id ,<!-- 主键 -->
h.company_code ,<!-- 公司编码(预留) -->
h.company_name ,<!-- 公司名称(预留) -->
h.proj_code ,<!-- 项目编码(预留) -->
h.proj_name ,<!-- 项目名称(预留) -->
h.parent_prod_code ,<!-- 父节点-产品编码 -->
h.parent_prod_name ,<!-- 父节点-产品名称 -->
h.material_id ,<!-- 物料清单id -->
h.product_id ,<!-- 产品id -->
h.product_type ,<!-- 产品类别 -->
h.product_code ,<!-- 产品编号 -->
h.product_name ,<!-- 产品名称 -->
h.invent_type ,<!-- 档案类型 -->
h.spec ,<!-- 规格 -->
h.length ,<!-- 长 -->
h.width ,<!-- 宽 -->
h.thick ,<!-- 厚 -->
h.quantity ,<!-- 数量 -->
h.single_weight ,<!-- 单重 -->
h.total_weight ,<!-- 总重 -->
h.approval_status ,<!-- 审批状态 0:待审;1:审核中;2:已审 -->
h.leaf ,<!-- 是否有叶子节点 -->
h.sort ,<!-- 排序字段 -->
h.lv , <!-- 层级 -->
k.RECEIPT_DATE ,<!-- 入库日期 -->
k.INV_QTY ,<!-- 数量 -->
k.INV_WEIGHT<!-- 重量 -->
from hggp.hgsc004a h
left join (
select
select
k.COMPANY_CODE ,
h.id ,
k.PROJ_CODE ,
h.company_code ,
k1.RECEIPT_DATE ,<!-- 入库日期 -->
h.company_name ,
k.INVENT_CODE ,
h.proj_code ,
sum(k.INV_QTY) as INV_QTY,<!-- 数量 -->
h.proj_name ,
sum(k.INV_WEIGHT) as INV_WEIGHT<!-- 重量 -->
h.parent_prod_code ,
from hggp.hgkc008a k
h.parent_prod_name ,
join hggp.hgkc008 k1 on k.RECEIVE_ID = k1.id
h.material_id ,
where k.DELETE_FLAG = 0
h.product_id ,
<isNotEmptyprepend=" AND "property="accountCode">
h.product_type ,
k.ACCOUNT_CODE = #accountCode#
h.product_code ,
</isNotEmpty>
h.product_name ,
<isNotEmptyprepend=" AND "property="companyCode">
h.invent_type ,
k.COMPANY_CODE = #companyCode#
h.spec ,
</isNotEmpty>
h.length ,
<isNotEmptyprepend=" AND "property="companyName">
h.width ,
k.COMPANY_NAME = #companyName#
h.thick ,
</isNotEmpty>
h.quantity ,
<isNotEmptyprepend=" AND "property="receiptDate">
h.single_weight ,
k.RECEIPT_DATE = #receiptDate#
h.total_weight ,
</isNotEmpty>
h.approval_status ,
group by k.COMPANY_CODE, k.PROJ_CODE, k1.RECEIPT_DATE, k.INVENT_CODE
h.leaf ,
) k on h.company_code = k.COMPANY_CODE
h.sort ,
and h.proj_code = k.PROJ_CODE
h.lv ,
and h.product_code = k.INVENT_CODE
k.DEPOSIT_DATE ,
where h.lv = 4 and h.product_status = 1
k.MAT_ID ,
k.INV_QTY ,
k.INV_UNIT_WEIGHT ,
k.INV_WEIGHT
from
hggp.hgsc004a h
left join hggp.hgkc003 k on
h.company_code = k.COMPANY_CODE
and h.proj_code = k.PROJ_CODE
and h.material_id = k.MAT_ID
and h.product_code = k.PRDT_CODE
and k.DELETE_FLAG = 0
and h.lv = 3
and h.product_status = 1
where 1=1
<isNotEmptyprepend=" AND "property="accountCode">
h.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyCode">
h.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyName">
h.COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="projCode">
h.proj_code = #projCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="projName">
h.proj_name = #projName#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="productCode">
h.product_code = #productCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="depositDate">
k.DEPOSIT_DATE = #depositDate#
</isNotEmpty>
) ha
join (
select
h.id ,
h.company_code ,
h.company_name ,
h.proj_code ,
h.proj_name ,
h.parent_prod_code ,
h.parent_prod_name ,
h.material_id ,
h.product_id ,
h.product_type ,
h.product_code ,
h.product_name ,
h.invent_type ,
h.spec ,
h.length ,
h.width ,
h.thick ,
h.quantity ,
h.single_weight ,
h.total_weight ,
h.approval_status ,
h.leaf ,
h.sort ,
h.lv ,
k.RECEIPT_DATE ,
k.MAT_ID ,
k.INV_QTY ,
k.INV_WEIGHT
from
hggp.hgsc004a h
left join (
select
k.COMPANY_CODE ,
k.PROJ_CODE ,
k.INVENT_CODE ,
k.MAT_ID,
k.MAT_DETAIL_ID,
k1.RECEIPT_DATE ,
sum(k.INV_QTY) as INV_QTY,
sum(k.INV_WEIGHT) as INV_WEIGHT
from
hggp.hgkc008a k
join hggp.hgkc008 k1 on
k.RECEIVE_ID = k1.id
where
k.DELETE_FLAG = 0
and k1.status = '1'
<isNotEmptyprepend=" AND "property="accountCode">
k.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyCode">
k.COMPANY_CODE = #companyCode#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="companyName">
k.COMPANY_NAME = #companyName#
</isNotEmpty>
<isNotEmptyprepend=" AND "property="receiptDate">
k.RECEIPT_DATE = #receiptDate#
</isNotEmpty>
group by
k.COMPANY_CODE,
k.PROJ_CODE,
k1.RECEIPT_DATE,
k.INVENT_CODE ,
k.MAT_ID,
k.MAT_DETAIL_ID
) k on
h.company_code = k.COMPANY_CODE
and h.proj_code = k.PROJ_CODE
and h.product_code = k.INVENT_CODE
and h.material_id = k.MAT_ID
and h.ID = K.MAT_DETAIL_ID
and h.lv = 4
and h.product_status = 1
where 1=1
<isNotEmptyprepend=" AND "property="accountCode">
<isNotEmptyprepend=" AND "property="accountCode">
h.ACCOUNT_CODE = #accountCode#
h.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
</isNotEmpty>
...
@@ -160,8 +189,12 @@
...
@@ -160,8 +189,12 @@
<isNotEmptyprepend=" AND "property="inventCode">
<isNotEmptyprepend=" AND "property="inventCode">
h.product_code = #inventCode#
h.product_code = #inventCode#
</isNotEmpty>
</isNotEmpty>
) hb on h.id = hb.material_id and ha.product_code = hb.parent_prod_code