java-africa-app/bd-business/bd-business-scm/src/main/resources/mapper/scm/trans/IcTransInHMapper.xml

158 lines
8.1 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzs.scm.trans.mapper.IcTransInHMapper">
<!-- 通用查询映射结果 -->
<resultMap id="IcTransInHExt" type="com.hzs.common.domain.scm.trans.ext.IcTransInHExt">
<id column="PK_ID" property="pkId" />
<result column="CREATION_TIME" property="creationTime" />
<result column="MODIFIED_TIME" property="modifiedTime" />
<result column="DEL_FLAG" property="delFlag" />
<result column="PK_COUNTRY" property="pkCountry" />
<result column="PK_CREATOR" property="pkCreator" />
<result column="PK_MODIFIED" property="pkModified" />
<result column="PK_DEPT" property="pkDept" />
<result column="PK_WHSMANAGER" property="pkWhsmanager" />
<result column="ORDER_DATE" property="orderDate" />
<result column="ORDER_STATUS" property="orderStatus" />
<result column="PRINT_STATUS" property="printStatus" />
<result column="PK_OUT_CORP" property="pkOutCorp" />
<result column="PK_CORP" property="pkCorp" />
<result column="TOTAL_NUM" property="totalNum" />
<result column="ORDER_CODE" property="orderCode" />
<result column="REMARK" property="remark" />
<result column="CORP_NAME" property="corpName" />
<result column="PK_OUT_COUNTRY" property="pkOutCountry" />
<result column="DEPT_NAME" property="deptName" />
<result column="MANAGER_NAME" property="managerName" />
<result column="CORP_OUT_NAME" property="corpOutName" />
<result column="COUNTRY_OUT_NAME" property="countryOutName" />
<collection property="transInbExtList" ofType="com.hzs.common.domain.scm.trans.ext.IcTransInBExt">
<result column="PK_ITEM_ID" property="pkId"/>
<result column="PK_UNIT" property="pkUnit" />
<result column="PK_TRANSFER_OUT" property="pkTransferOut" />
<result column="PK_TRANSFER_OUT_B" property="pkTransferOutB" />
<result column="PK_TRANSFER_IN" property="pkTransferIn" />
<result column="PK_CLOCATION" property="pkClocation" />
<result column="PK_PRODUCT_BAS" property="pkProductBas" />
<result column="PK_PRODUCT" property="pkProduct" />
<result column="TRANS_TYPE" property="transType" />
<result column="BIZ_DATE" property="bizDate" />
<result column="PK_CUBASDOC" property="pkCubasdoc" />
<result column="PK_CUSTOMER" property="pkCustomer" />
<result column="PK_OUT_STOREHOUSE" property="pkOutStorehouse" />
<result column="PK_STOREHOUSE" property="pkStorehouse" />
<result column="PK_RATE" property="pkRate" />
<result column="NNUM" property="nnum" />
<result column="NORIGPRICE" property="norigprice" />
<result column="NTAXRATE" property="ntaxrate" />
<result column="NORIGTAXPRICE" property="norigtaxprice" />
<result column="NORIGMNY" property="norigmny" />
<result column="NTAX" property="ntax" />
<result column="NORIGTAXMNY" property="norigtaxmny" />
<result column="PK_BATCH_CODE" property="pkBatchCode" />
<result column="UNIT_NAME" property="unitName" />
<result column="CLOCATION_NAME" property="clocationName" />
<result column="STOREHOUSE_NAME" property="storehouseName" />
<result column="OUT_STOREHOUSE_NAME" property="outStorehouseName" />
<result column="BATCH_CODE" property="batchCode" />
<result column="PRODUCT_CODE" property="productCode" />
<result column="PRODUCT_NAME" property="productName" />
<result column="SPECS_NAME" property="specsName" />
<result column="CUBASDOC_NAME" property="cubasdocName" />
</collection>
</resultMap>
<select id="queryTransInById" resultMap="IcTransInHExt">
select ih.*,sc.corp_name,ib.pk_id pk_item_id,ib.pk_unit,ib.pk_clocation,ib.pk_product,ib.trans_type,ib.biz_date,
ib.pk_storehouse,ib.pk_rate,ib.nnum,ib.norigprice,ib.ntaxrate,ib.norigtaxprice,
ib.norigmny,ib.ntax,ib.norigtaxmny,ib.pk_batch_code from ic_transin_h ih
inner join ic_transin_b ib
on ih.pk_id=ib.pk_transfer_in
left join sys_corp sc
on ih.pk_corp=sc.pk_id
where ih.del_flag=0 and ib.del_flag=0
and ih.pk_id = #{pkId}
and ih.order_status= #{orderStatus}
</select>
<select id="queryDisTransInExtByCondition" resultMap="IcTransInHExt">
select ih.*,ib.pk_id pk_item_id,ib.pk_transfer_out,ib.pk_transfer_out_b,sd.dept_name,su.nick_name manager_name,sc.corp_name,bc.cust_name cubasdoc_name,
ib.pk_unit,ib.pk_clocation,ib.pk_product_bas,bct.name country_out_name,bcp.corp_name corp_out_name,
ib.pk_product,ib.biz_date,ib.pk_storehouse,ib.pk_cubasdoc,ib.pk_out_storehouse,
ib.pk_rate,ib.nnum,ib.norigprice,ib.ntaxrate,ib.norigtaxprice,
ib.norigmny,ib.ntax,ib.norigtaxmny,ib.pk_batch_code,bn.name unit_name,bh.name storehouse_name,ic.batch_code,
bp.product_code,bp.product_name,sp.specs_name,bcs.name out_storehouse_name from ic_transin_h ih
inner join ic_transin_b ib
on ih.pk_id=ib.pk_transfer_in
left join sys_dept sd
on ih.pk_dept=sd.dept_id
left join sys_user su
on ih.pk_whsmanager=su.user_id
left join sys_corp sc
on ih.pk_corp=sc.pk_id
left join bd_unit bn
on ib.pk_unit = bn.pk_id
left join bd_storehouse bh
on ib.pk_storehouse=bh.pk_id
left join ic_batch_code ic
on ib.pk_batch_code=ic.pk_id
left join bd_product bp
on ib.pk_product=bp.pk_id
left join bd_cubasdoc bc
on bc.pk_id=ib.pk_cubasdoc and bc.del_flag=0
left join bd_country bct
on bct.pk_id=ih.pk_out_country
left join sys_corp bcp
on bcp.pk_id=ih.pk_out_corp
left join bd_storehouse bcs
on bcs.pk_id =ib.pk_out_storehouse
left join (
select pk_order,pk_order_items,to_char(wm_concat(specs_name)) specs_name from scm_item_specs
where del_flag=0 and order_type=8
group by pk_order,pk_order_items) sp
on ib.pk_id=sp.pk_order_items
where ih.del_flag=0 and ib.del_flag=0
<if test="pkCountry != null">
and ih.pk_country=#{pkCountry}
</if>
<if test="pkId != null">
and ih.pk_id=#{pkId}
</if>
<if test="orderStatus != null">
and ih.order_status = #{orderStatus}
</if>
<if test="orderState != null">
and ih.order_status >= #{orderState}
</if>
<if test="pkCorp != null">
and ih.pk_corp = #{pkCorp}
</if>
<if test="orderCode != null and orderCode != ''">
and ih.order_code = #{orderCode}
</if>
<if test="startDate != null">
and ih.order_date >= #{startDate, jdbcType=DATE}
</if>
<if test="endDate != null">
and ih.order_date &lt; #{endDate, jdbcType=DATE}
</if>
<if test="productName != null and productName != ''">
and bp.product_name=#{productName}
</if>
order by ih.order_date desc
</select>
<select id="queryTransInByOrderItems" resultMap="IcTransInHExt">
<foreach collection="orderItemsParamList" item="item" index="index" separator=" union ">
select tr.*,ti.pk_id PK_ITEM_ID,ti.pk_product_bas,ti.pk_storehouse,ti.pk_unit,
ti.nnum,ti.norigprice,ti.ntaxrate,ti.norigtaxprice,ti.norigmny,ti.ntax,ti.norigtaxmny,
ti.pk_creator item_pk_creator from ic_transin_h tr
inner join ic_transin_b ti
on tr.pk_id=ti.pk_transfer_out
where tr.del_flag=0 and ti.del_flag=0
and tr.pk_id=#{item.pkTransferOut} and ti.pk_id=#{item.pkTransferOutB}
and ti.pk_product_bas=#{item.pkProductBas}
and tr.order_status =3
</foreach>
</select>
</mapper>