<?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.prolog.cs.biz.inbound.dao.task.TaskQcDetailMapper">
	<resultMap id="map"
		type="com.prolog.cs.biz.inbound.dto.task.TaskQcDetailDTO">
		<result column="task_rqc_id" property="taskRqcId" />
		<result column="enterprise_id" property="enterpriseId" />
		<result column="mtl_owner_id" property="mtlOwnerId" />
		<result column="warehouse_id" property="warehouseId" />
		<result column="src_bill_type" property="srcBillType" />
		<result column="src_header_id" property="srcHeaderId" />
		<result column="src_line_id" property="srcLineId" />
		<result column="asn_header_id" property="asnHeaderId" />
		<result column="asn_line_id" property="asnLineId" />
		<result column="rcv_header_id" property="rcvHeaderId" />
		<result column="rcv_line_id" property="rcvLineId" />
		<result column="item_id" property="itemId" />
		<result column="qty" property="qty" />
		<result column="uom" property="uom" />
		<result column="conversion_rate" property="conversionRate" />
		<result column="piece_qty" property="pieceQty" />
		<result column="batch_id" property="batchId" />
		<result column="batch_num" property="batchNum" />
		<result column="vendor_batch_num" property="vendorBatchNum" />
		<result column="active_flag" property="activeFlag" />
		<result column="remain_qty" property="remainQty" />
		<result column="comments" property="comments" />
		<result column="manufacturer_lot_num"
			property="manufacturerLotNum" />
		<result column="executor" property="executor" />
		<result column="container_code" property="containerCode" />
		<result column="goods_case_code" property="goodsCaseCode" />
		<result column="status" property="status" />
		<result column="times" property="times" />
		<result column="item_health_is_double"
			property="itemHealthIsDouble" />
		<result column="data_version" property="dataVersion"/>
		<result column="is_lock" property="isLock"/>
		
		<result column="odd_piece_qty" property="oddPieceQty" />
		<result column="ITEM_VOLUME" property="itemVolume" />
		<result column="ITEM_WEIGHT" property="itemWeight" />
		<result column="ITEM_HEALTH_TWOVOTEFLAG"
			property="itemHealthTwovoflag" />
		<result column="WAREHOUSE_NAME" property="warehouseName" />
		<result column="WAREHOUSE_AREA_NAME"
			property="warehouseAreaName" />
		<result column="ITEM_NUM" property="itemNum" />
		<result column="ITEM_NAME" property="itemName" />
		<result column="CATEGORY_NAME" property="categoryName" />
		<result column="ITEM_BARCODE" property="itemBarcode" />
		<result column="qc_result2" property="qcResult2" />
		<result column="qc_reason2" property="qcReason2" />
		<result column="qc_opcode2" property="qcOpcode2" />
		<result column="qc_date2" property="qcDate2" />
		<result column="WAREHOUSE_NUM" property="warehouseCode" />
		
	</resultMap>
	
	<resultMap id="rcvMap"
		type="com.prolog.cs.biz.inbound.dto.rcv.RcvHDTO">
		<result column="rcv_header_id" property="rcvHeaderId"/>
		<result column="auto_bill_num" property="autoBillNum"/>
		<result column="custom_bill_num" property="customBillNum"/>
		<result column="executor_user" property="executorUser"/>
		
		<result column="rcv_date" property="rcvDate"/>
		<result column="rcv_type" property="rcvType"/>
		<result column="status" property="status"/>
		<result column="case_qty" property="caseQty"/>
		<result column="piece_qty" property="pieceQty"/>
		<result column="access_level" property="accessLevel"/>
		<result column="comments" property="comments"/>
		<result column="mtl_owner_id" property="mtlOwnerId"/>
		<result column="warehouse_id" property="warehouseId"/>
		<result column="asn_header_id" property="asnHeaderId"/>
		
		<result column="print_count" property="printCount"/>
		<result column="print_date" property="printDate"/>
		<result column="audit_date" property="auditDate"/>
		<result column="confirm_date" property="confirmDate"/>
		<result column="audited_name" property="auditedName"/>
		<result column="printed_name" property="printedName"/>
		<result column="confirmed_name" property="confirmedName"/>
		<result column="vendor_id" property="vendorId"/>
		<result column="src_bill_type" property="srcBillType"/>
		<result column="src_header_id" property="srcHeaderId"/>
		<!-- profile字段 -->
		<result column="ship_type" property="shipType"/>
		<result column="arrival_mode" property="arrivalMode"/>
		<result column="vendor_name" property="vendorName"/>
		<result column="warehouse_name" property="warehouseName"/>
		<result column="buyer_mane" property="buyerMane"/>
		<result column="customer_name" property="customerName"/>
		<result column="mtl_owner_name" property="mtlOwnerName"/>

		<!-- <result column="asn_auto_bill_num" property="asnAutoBillNum"/>
		<result column="buyer_id" property="buyerId"/>
		<result column="src_orgn_id" property="srcOrgnId"/>
		<result column="src_warehouse_id" property="srcWarehouseId"/>
		<result column="src_mtl_owner_id" property="srcMtlOwnerId"/>
		<result column="enterprise_id" property="enterpriseId"/>
		<result column="src_auto_bill_num" property="srcAutoBillNum"/>
		<result column="audited_by" property="auditedBy"/>
		<result column="confirmed_by" property="confirmedBy"/>
		<result column="printed_by" property="printedBy"/>
		<result column="status_as" property="statusAs"/>
		<result column="orgn_id" property="orgnId"/>
		<result column="customer_id" property="customerId"/>
		<result column="gmt_create" property="gmtCreate"/>
		<result column="creator" property="creator"/>
		<result column="creator_name" property="creatorName"/>
		<result column="gmt_modified" property="gmtModified"/>
		<result column="modifier" property="modifier"/>
		<result column="modifier_name" property="modifierName"/> -->
	</resultMap>

	<sql id="clomuns">
		t1.task_rqc_id,
		t1.mtl_owner_id,
		t1.warehouse_id,
		t1.src_bill_type,
		t1.src_header_id,
		t1.src_line_id,
		t1.asn_header_id,
		t1.asn_line_id,
		t1.rcv_header_id,
		t1.rcv_line_id,
		t1.item_id,
		t1.qty,
		floor(nvl(t1.qty,0)) as oddCaseQty,
		floor(nvl(t1.qty,0)) as caseQty,
		mod(nvl(t1.piece_qty,0),nvl(t1.conversion_rate,1)) as odd_piece_qty,
		t1.uom,
		t1.conversion_rate,
		t1.piece_qty,
		t1.batch_id,
		t1.batch_num,
		t1.vendor_batch_num,
		t1.active_flag,
		t1.remain_qty,
		t1.comments,
		t1.result,
		t1.reason,
		t1.manufacturer_lot_num,
		t1.executor,
		t1.container_code,
		t1.goods_case_code,
		t1.status,
		t1.times,
		t1.ENTERPRISE_ID,
		t1.GMT_CREATE as gmtCreate,
		t1.CREATOR,
		t1.CREATOR_NAME as creatorName,
		t1.GMT_MODIFIED as gmtModified,
		t1.MODIFIER,
		t1.MODIFIER_NAME as modifierName,
		t1.data_version,
		t1.is_lock,
		t1.pre_node_line_id as preNodeLineId,
		t1.REF_BILL_ID as refBillId,
		t1.REF_TYPE as refBillType,
		t1.REF_LINE_ID as refLineId,
		t1.REF_BILL_NO as refBillNo,
	</sql>
	<!-- 任务提取 -->
	<select id="findList" resultMap="map">
		select
		distinct
		<include refid="clomuns"></include>
		t1.IS_RECHECKED as isRechecked,
		t6.qc_result2,
		t6.qc_reason2,
		t6.qc_opcode2, <!-- 前端 -->
		t6.qc_date2,
		t2.WAREHOUSE_AREA_CODES as warehouseAreaCodes,
		nvl(t2.ITEM_IS_PIECE_OR_CASE,'0' )as itemIsPieceOrCase,
		t2.WAREHOUSE_AREA_CATEGORYS as warehouseAreaCategorys,
		t2.ITEM_VOLUME,
		t2.ITEM_WEIGHT,
		t2.ITEM_HEALTH_TWOVOTEFLAG,
		t2.WAREHOUSE_NAME,
		t2.WAREHOUSE_AREA_NAME,
		t2.batch_production_date as  batchProductionDate,
		t2.batch_expired_date as batchExpiredDate,
		t2.ERP_BATCH_NUM as erpBatchNum,
		t2.PRODUCTION_PLACE as productionPlace,
		t3.ITEM_NUM,
		t3.ITEM_NAME,
		t3.CATEGORY_ID as categoryId,
		t3.CATEGORY_NAME,
		t3.ITEM_BARCODE,
		t3.PIECE_PRICE_TI as piecePriceTi,
		t3.PIECE_PRICE_TE as piecePriceTe,
		TRUNC(
			decode(
				nvl( t3.PIECE_PRICE_TI, 1 ),
				0,
				0,
				nvl( t3.PIECE_PRICE_TE, 0 ) / nvl( t3.PIECE_PRICE_TI, 1 ) 
			),
			4 
		) * 100 AS taxRate,
		<!-- TRUNC(nvl(t3.PIECE_PRICE_TE,0)/nvl(t3.PIECE_PRICE_TI,1), 4) * 100 as taxRate, -->
		t4.VENDOR_ID as vendorId,
		t4.ORGN_ID as orgId,
		t5.WAREHOUSE_NUM,
		t3.specification as specification,
		t3.ITEM_HEALTH_LISTED_LICENSOR as itemHealthListedLicensor,
		t3.ITEM_HEALTH_PRODUCE_LICENSE as itemHealthProduceLicense,
		<!-- t3.ITEM_HEALTH_STORE_CATEGORY as itemHealthStoreCategory, -->
		t3.ITEM_IS_RECHECK as itemIsRecheck,
		t3.IS_INSTRUMENT as isInstrument,
		t3.ITEM_IS_IMPORTED as itemIsImported,
		
		t3.MANUFACTURER_ID as manufacturerId,
		t3.MANUFACTURER_CODE as manufacturerCode,
		t3.MANUFACTURER_NAME as manufacturerName,
		t3.ITEM_HEALTH_REGISTER_NBR as itemHealthRegisterNbr,
		t3.ITEM_HEALTH_COMMON_NAME as itemHealthCommonName,
		t3.RETURN_INFO as returnInfo,
		t3.RETURN_COLD_QUALITY as returnColdQuality,
		t3.RETURN_EXPLAIN as returnExplain,
		t3.IS_LOCK as itemIsLock,
		t3.IS_HOSTED as isHosted,
		t3.ITEM_IS_SPECIAL as itemIsSpecial,
		t3.IS_BACTERIA as isBacteria,
		t3.SHELF_LIFE_DAYS as shelfLifeDays,
		t3.SHELF_LIFE_UNIT as shelfLifeUnit,
		
		t2.bldg_name as bldgName,
		t2.bldg_code as bldgCode,
		
		t2.DELEGATION_PARTY_ID as delegationPartyId,
		t2.DELEGATION_PARTY_NAME as delegationPartyName,
		t2.SHOW_PRODUCTION_DATE as showProductionDate,
		t2.SHOW_EXPIRED_DATE as showExpiredDate,
		t2.WAREHOUSE_ROOM_CODES as warehouseRoomCodes,
		t2.PIECE_CONVERSION_RATE as pieceConversionRate,
		t2.ASN_LINE_REMARK as asnLineRemark,
		t2.ITEM_ZJM as itemZjm,
		
		coalesce(t1.item_health_is_double,t2.ITEM_HEALTH_IS_DOUBLE,0) as item_health_is_double,
		
		<!-- 处理意见 -->
		t7.handling_suggestion as handlingSuggestion,
		t4.rcv_type as rcvType,
		t3.STORE_TEMPERATURE as storeTemperature,
		
		t2.is_delegate as isDelegate,
		t2.is_retrospect as isRetrospect,
		
		t2.rcv_reason1 as rcvReason1,
		t2.rcv_reason2 as rcvReason2,
		t2.rcv_reason3 as rcvReason3,
		t2.rcv_rt_reason as rcvRtReason,
		t2.approval_number as approvalNumber,
		CASE
		t2.ITEM_IS_PIECE_OR_CASE 
		WHEN '0' THEN
		'整散合一' 
		WHEN '1' THEN
		'整散分开' ELSE '整散合一' 
	END AS itemHealthStoreCategory,
	nvl((SELECT re.STOCK_STATUS FROM WMS_IN_RQC_RE_LINES re WHERE t1.REF_LINE_ID = re.RQC_RE_LINE_ID),'N/A') AS reCheckResult, 
	'N/A' as manufacturerRegisterNo,
	<!-- 处理原因、不足原因、不足原因补充 -->
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason1
				WHEN 1 THEN
				t8.handling_reason
				WHEN 2 THEN
				t7.handling_reason
				ELSE t2.rcv_reason1 
			END AS handlingReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason2
				WHEN 1 THEN
				t8.def_reason
				WHEN 2 THEN
				t7.def_reason
				ELSE t2.rcv_reason2
			END AS defReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason3
				WHEN 1 THEN
				t8.def_reason_ext
				WHEN 2 THEN
				t7.def_reason_ext
				ELSE t2.rcv_reason3 
			END AS defReasonExt,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				''
				WHEN 1 THEN
				t8.HANDLING_MEASURE
				WHEN 2 THEN
				t7.HANDLING_MEASURE
				ELSE '' 
			END AS handlingMeasure,
			t1.RESULT as stockStatus,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				'收货'
				WHEN 1 THEN
				'一次质检'
				WHEN 2 THEN
				'复检'
				ELSE '收货' 
			END AS sourceType,
			t2.RQC_REPORT_NO as rqcReportNo,
			t1.ref_type as refType,
			t3.allow_decimal as allowDecimal,
			t2.HOST_LOCATOR_ID as hostLocatorId,
			t2.is_retrospect as isSupervise,
			t2.WH_LOCATOR_ID as whLocatorId,
			t2.WH_LOCATOR_CODE as whLocatorCode,
			t2.WH_AREA_CODE as whAreaCode,
			t2.WH_AREA_CATEGORY_CODE as whAreaCategoryCode,
			t4.ASN_AUTO_BILL_NUM as asnAutoBillNum,
			t5.VENDOR_NAME as vendorName
		FROM
		wms_in_task_qc_detail t1
		LEFT JOIN
		WMS_IN_RCV_LINES t2
		on t1.rcv_line_id = t2.RCV_LINE_ID
		LEFT JOIN
		WMS_IN_RCV_LINES_PROFILES t3
		on t1.rcv_line_id = t3.RCV_LINE_ID
		LEFT JOIN
		wms_in_rcv_headers  t4
		on t4.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RCV_HEADERS_PROFILES  t5
		on t5.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RQC_LINES t6
		on t1.task_rqc_id = t6.task_rqc_id
		LEFT JOIN
		WMS_IN_RQC_RE_LINES t7
		on t1.ref_line_id = t7.rqc_re_line_id
		LEFT JOIN WMS_IN_RQC_LINES t8 ON t1.pre_node_line_id = t8.rqc_line_id 
		where
		1=1
		<if test="enterpriseId != null  and enterpriseId !=''">
			and t1.enterprise_id = #{enterpriseId}
		</if>
		<if test="warehouseId != null  and warehouseId !=''">
			and t1.warehouse_id = #{warehouseId}
		</if>
		<if test="mtlOwnerId != null  and mtlOwnerId !=''">
			and t1.mtl_owner_id = #{mtlOwnerId}
		</if>
		<if test="rcvHeaderId != null  and rcvHeaderId !=''">
			and t1.rcv_header_id = #{rcvHeaderId}
		</if>
		<if test="taskRqcId != null  and taskRqcId !=''">
			and t1.task_rqc_id = #{taskRqcId}
		</if>
		<if test="itemId != null  and itemId !=''">
			and t1.item_id = #{itemId}
		</if>
		<if test="rcvLineId != null  and rcvLineId !=''">
			and t1.rcv_line_id = #{rcvLineId}
		</if>
		<if test="status != null  and status !=''">
			and t1.status = #{status}
		</if>
		<if test="containerCode != null  and containerCode !=''">
			AND UPPER(t1.CONTAINER_CODE) like CONCAT(CONCAT('%',UPPER(#{containerCode})),'%') 
		</if>
		<if test="itemCondition != null  and itemCondition !=''">     
			and ( UPPER(t2.ITEM_ZJM) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%') or UPPER(t3.ITEM_NUM) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%')
					or UPPER(t3.ITEM_NAME) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%') or UPPER(t3.ITEM_BARCODE) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%')
			  )
		</if>
		AND ( ( t1.item_health_is_double = 1 AND (t1.executor &lt;&gt;
		#{executor}or t1.executor is NULL) )
		OR
		t1.item_health_is_double = 0 or t1.item_health_is_double is null)
		and t1.piece_qty  &lt;&gt; 0
		order by t1.gmt_modified
		desc
	</select>
	
	<select id="findList2" resultMap="map">
		select
		distinct
		<include refid="clomuns"></include>
		t6.qc_result2,
		t6.qc_reason2,
		t6.qc_opcode2, <!-- 前端 -->
		t6.qc_date2,
		t2.WAREHOUSE_AREA_CODES as warehouseAreaCodes,
		t2.ITEM_IS_PIECE_OR_CASE as itemIsPieceOrCase,
		t2.WAREHOUSE_AREA_CATEGORYS as warehouseAreaCategorys,
		t2.ITEM_VOLUME,
		t2.ITEM_WEIGHT,
		t2.ITEM_HEALTH_TWOVOTEFLAG,
		t2.WAREHOUSE_NAME,
		t2.WAREHOUSE_AREA_NAME,
		t2.batch_production_date as  batchProductionDate,
		t2.batch_expired_date as batchExpiredDate,
		t2.ERP_BATCH_NUM as erpBatchNum,
		t2.PRODUCTION_PLACE as productionPlace,
		t3.ITEM_NUM,
		t3.ITEM_NAME,
		t3.CATEGORY_ID as categoryId,
		t3.CATEGORY_NAME,
		t3.ITEM_BARCODE,
		t3.PIECE_PRICE_TI as piecePriceTi,
		t3.PIECE_PRICE_TE as piecePriceTe,
		TRUNC(
			decode(
				nvl( t3.PIECE_PRICE_TI, 1 ),
				0,
				0,
				nvl( t3.PIECE_PRICE_TE, 0 ) / nvl( t3.PIECE_PRICE_TI, 1 ) 
			),
			4 
		) * 100 AS taxRate,
		<!-- TRUNC(nvl(t3.PIECE_PRICE_TE,0)/nvl(t3.PIECE_PRICE_TI,1), 4) * 100 as taxRate, -->
		t4.VENDOR_ID as vendorId,
		t4.ORGN_ID as orgId,
		t5.WAREHOUSE_NUM,
		t3.specification as specification,
		t3.ITEM_HEALTH_LISTED_LICENSOR as itemHealthListedLicensor,
		t3.ITEM_HEALTH_PRODUCE_LICENSE as itemHealthProduceLicense,
		t3.ITEM_HEALTH_STORE_CATEGORY as itemHealthStoreCategory,
		t3.ITEM_IS_RECHECK as itemIsRecheck,
		t3.IS_INSTRUMENT as isInstrument,
		t3.ITEM_IS_IMPORTED as itemIsImported,
		
		t3.MANUFACTURER_ID as manufacturerId,
		t3.MANUFACTURER_CODE as manufacturerCode,
		t3.MANUFACTURER_NAME as manufacturerName,
		t3.ITEM_HEALTH_REGISTER_NBR as itemHealthRegisterNbr,
		t3.ITEM_HEALTH_COMMON_NAME as itemHealthCommonName,
		t3.RETURN_INFO as returnInfo,
		t3.RETURN_COLD_QUALITY as returnColdQuality,
		t3.RETURN_EXPLAIN as returnExplain,
		t3.IS_LOCK as isLock,
		t3.IS_HOSTED as isHosted,
		t3.ITEM_IS_SPECIAL as itemIsSpecial,
		t3.IS_BACTERIA as isBacteria,
		t3.SHELF_LIFE_DAYS as shelfLifeDays,
		t3.SHELF_LIFE_UNIT as shelfLifeUnit,
		
		t2.bldg_name as bldgName,
		t2.bldg_code as bldgCode,
		
		t2.DELEGATION_PARTY_ID as delegationPartyId,
		t2.DELEGATION_PARTY_NAME as delegationPartyName,
		t2.SHOW_PRODUCTION_DATE as showProductionDate,
		t2.SHOW_EXPIRED_DATE as showExpiredDate,
		t2.WAREHOUSE_ROOM_CODES as warehouseRoomCodes,
		t2.PIECE_CONVERSION_RATE as pieceConversionRate,
		t2.ASN_LINE_REMARK as asnLineRemark,
		t2.ITEM_ZJM as itemZjm
		
		FROM
		wms_in_task_qc_detail t1
		LEFT JOIN
		WMS_IN_RCV_LINES t2
		on t1.rcv_line_id = t2.RCV_LINE_ID
		LEFT JOIN
		WMS_IN_RCV_LINES_PROFILES t3
		on t1.rcv_line_id = t3.RCV_LINE_ID
		LEFT JOIN
		wms_in_rcv_headers  t4
		on t4.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RCV_HEADERS_PROFILES  t5
		on t5.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RQC_LINES t6
		on t1.task_rqc_id = t6.task_rqc_id
		where
		1=1
		<if test="enterpriseId != null  and enterpriseId !=''">
			and t1.enterprise_id = #{enterpriseId}
		</if>
		<if test="warehouseId != null  and warehouseId !=''">
			and t1.warehouse_id = #{warehouseId}
		</if>
		<if test="mtlOwnerId != null  and mtlOwnerId !=''">
			and t1.mtl_owner_id = #{mtlOwnerId}
		</if>
		<if test="rcvHeaderId != null  and rcvHeaderId !=''">
			and t1.rcv_header_id = #{rcvHeaderId}
		</if>
		<if test="itemId != null  and itemId !=''">
			and t1.item_id = #{itemId}
		</if>
		<if test="rcvLineId != null  and rcvLineId !=''">
			and t1.rcv_line_id = #{rcvLineId}
		</if>
		<if test="status != null  and status !=''">
			and t1.status = #{status}
		</if>
		and t1.piece_qty  &lt;&gt; 0
		<!-- and t4.rcv_type not in ('5','12','13','14','15') -->
		order by t1.gmt_modified
		desc
	</select>
	<select id="extractRcvHWithNativeSql" resultMap="rcvMap">
		SELECT
			t1.rcv_header_id,
			t1.auto_bill_num,
			t1.custom_bill_num,
			t1.executor_user,
			t1.rcv_date,
			t1.rcv_type,
			t1.status,
			t1.case_qty,
			t1.piece_qty,
			t1.access_level,
			t1.comments,
			t1.mtl_owner_id,
			t1.warehouse_id,
			t1.asn_header_id,
			t1.vendor_id,
			t1.src_header_id,
			t1.src_bill_type,
			t1.print_count,
			t1.print_date,
			t1.audit_date,
			t1.confirm_date,
			t1.audited_name,
			t1.printed_name,
			t1.confirmed_name,
			t2.mtl_owner_num as mtlOwnerNum,
			t2.ship_type,
			t2.arrival_mode,
			t2.vendor_name,
			t2.warehouse_name,
			t2.buyer_mane,
			t2.customer_name,
			t2.mtl_owner_name,
			nvl(t1.need_user,t2.BUYER_MANE) as needUser,
			nvl(t1.need_dept,t2.ORGN_NAME) as needDept,
			t2.ORGN_NAME as orgnName,
			t1.AGENT  as agent,
			t1.ASN_REMARK as asnRemark,
			nvl(t2.vendor_num, t1.vendor_id)as vendorNum,
			t2.orgn_num as orgnNum,
			t1.shipper_zjm as shipperZjm,
			t1.ASN_AUTO_BILL_NUM as asnBillNum,
			t1.ASN_AUTO_BILL_NUM as asnAutoBillNum,
			
			t2.transportation_party as transportationParty,
			t2.carriername as carriername,
			t2.ship_from_date as shipFromDate,
			t2.ship_from_add as shipFromAdd,
			t2.on_passage_days as onPassageDays,
			t2.ship_arrive_tem_perature as shipArriveTemPerature,
			t2.ship_arrive_time as shipArriveTime,
			t2.ship_tem_perature as shipTemPerature,
			t2.ship_date as shipDate,
			t2.device_no as deviceNo,
			t2.tempcontrol_mode as tempcontrolMode,
			t2.tempcontrol_status as tempcontrolStatus,
			t1.EXECUTOR_USER as rcvUser,
			t1.auto_bill_num as rcvNo,
			t1.COMMENTS as rcvRemark,
			(select h.shipperid from OMS_ASN_BILL_H h where h.billid = t1.ASN_HEADER_ID) as shipperid,
			(select h.shipper_type from OMS_ASN_BILL_H h where h.billid = t1.ASN_HEADER_ID) as shipperType
			
		FROM
			wms_in_rcv_headers t1,
			wms_in_rcv_headers_profiles t2 
		WHERE
			t1.rcv_header_id = t2.RCV_HEADER_ID 
			and t1.rcv_header_id IN (
			<!-- 6.11新加 -->
				SELECT DISTINCT
					t1.RCV_HEADER_ID 
				FROM
					WMS_IN_TASK_QC_DETAIL t1 
					LEFT JOIN WMS_IN_RCV_LINES t2 ON t1.RCV_LINE_ID = t2.RCV_LINE_ID
				WHERE
					1 = 1
					<if test="itemZjm != null  and itemZjm !=''">
					and UPPER(t2.ITEM_ZJM) like CONCAT(CONCAT('%',UPPER(#{itemZjm})),'%') 
					</if>
					<if test="bldgId != null  and bldgId !=''">
					AND t2.BLDG_ID  = #{bldgId}
					</if>
					<if test="containerCode != null  and containerCode !=''">
					AND UPPER(t1.CONTAINER_CODE) like CONCAT(CONCAT('%',UPPER(#{containerCode})),'%') 
					</if>
					and
					( t1.status = '1' OR t1.status IS NULL ) 
					AND (
						( t1.item_health_is_double = 1 AND ( t1.executor &lt;&gt; #{excuteUser} OR t1.executor IS NULL ) ) 
					OR t1.item_health_is_double = 0 
					OR t1.item_health_is_double IS NULL 
				) 
				AND t1.RCV_HEADER_ID IS NOT NULL 
				AND t1.ENTERPRISE_ID = #{enterpriseId}
				and t1.piece_qty  &lt;&gt; 0
				GROUP BY
					t1.RCV_HEADER_ID 
			<!-- 6.11新加 -->
			<!-- SELECT RCV_HEADER_ID FROM WMS_IN_TASK_QC_DETAIL where (status = '1' or status is null) 
			 AND ( ( item_health_is_double = 1 AND ( executor &lt;&gt; #{excuteUser} OR executor IS NULL ) )
			  OR item_health_is_double = 0  or item_health_is_double is null) 
			 AND RCV_HEADER_ID is NOT NULL and ENTERPRISE_ID = #{enterpriseId} -->
			<!-- <if test="times != null ">
				and TIMES &lt; #{times}
			</if>  --> 
			<!-- GROUP BY RCV_HEADER_ID -->
			)
		<if test="rcvUser != null  and rcvUser !=''">
			and UPPER(t1.EXECUTOR_USER) like CONCAT(CONCAT('%',UPPER(#{rcvUser})),'%')
		</if>
		<if test="enterpriseId != null  and enterpriseId !=''">
			and t1.enterprise_id = #{enterpriseId}
		</if>
		<!-- 6.11新加 -->
		<if test="rcvNo != null  and rcvNo !=''">
			and UPPER(t1.auto_bill_num) like CONCAT(CONCAT('%',UPPER(#{rcvNo})),'%') 
		</if>
		<if test="billNo != null  and billNo !=''">
			and UPPER(t1.ASN_AUTO_BILL_NUM) like CONCAT(CONCAT('%',UPPER(#{billNo})),'%') 
		</if>
		<if test="shipperZjm != null  and shipperZjm !=''">
			and UPPER(t1.SHIPPER_ZJM) like CONCAT(CONCAT('%',UPPER(#{shipperZjm})),'%') 
		</if>
		<if test="startTime != null">
			and t1.rcv_date &gt;= #{startTime}
		</if>
		<if test="endTime != null">
			and t1.rcv_date &lt;= #{endTime}
		</if>
		<!-- 6.11新加 -->
		
		<if test="warehouseId != null  and warehouseId !=''">
			and t1.warehouse_id = #{warehouseId}
		</if>
		<if test="mtlOwnerId != null  and mtlOwnerId !=''">
			and t1.mtl_owner_id = #{mtlOwnerId}
		</if>
	
		<if test="status != null  and status !=''">
			and t1.status = #{status}
		</if>
		<if test="autoBillNum != null  and autoBillNum !=''">
			and UPPER(t1.auto_bill_num) like CONCAT(CONCAT('%',UPPER(#{autoBillNum})),'%')  
		</if>
		<if test="rcvType != null  and rcvType !=''">
			and t1.rcv_type = #{rcvType}
		</if>
		<if test="customBillNum != null  and customBillNum !=''">
			and UPPER(t1.custom_bill_num) like CONCAT(CONCAT('%',UPPER(#{customBillNum})),'%')
		</if>
		<if test="asnAutoBillNum != null  and asnAutoBillNum !=''">
			and UPPER(t1.asn_auto_bill_num) like CONCAT(CONCAT('%',UPPER(#{asnAutoBillNum})),'%')
		</if>
		<choose>
	        <when test="rcvTypeCodes != null and rcvTypeCodes.size() > 0">
	            and t1.rcv_type not in
				<foreach collection="rcvTypeCodes" item="item" open="("
					separator="," close=")">
					#{item}
				</foreach>
	        </when>
	        <otherwise>
	            <!-- 需要加入rcvType类型,过滤掉其他的不需要看的数据任务 -->
	            and t1.rcv_type not in ('5','12','13','14','15')
	        </otherwise>
    	</choose>
		
		order by t1.rcv_date desc,t1.ASN_AUTO_BILL_NUM desc
	</select>
	
	<select id="findList3" resultMap="map">
		select
		distinct
		<include refid="clomuns"></include>
		t6.qc_result2,
		t6.qc_reason2,
		t6.qc_opcode2, <!-- 前端 -->
		t6.qc_date2,
		t2.WAREHOUSE_AREA_CODES as warehouseAreaCodes,
		t2.ITEM_IS_PIECE_OR_CASE as itemIsPieceOrCase,
		t2.WAREHOUSE_AREA_CATEGORYS as warehouseAreaCategorys,
		t2.ITEM_VOLUME,
		t2.ITEM_WEIGHT,
		t2.ITEM_HEALTH_TWOVOTEFLAG,
		t2.WAREHOUSE_NAME,
		t2.WAREHOUSE_AREA_NAME,
		t2.batch_production_date as  batchProductionDate,
		t2.batch_expired_date as batchExpiredDate,
		t2.ERP_BATCH_NUM as erpBatchNum,
		t2.PRODUCTION_PLACE as productionPlace,
		t3.ITEM_NUM,
		t3.ITEM_NAME,
		t3.CATEGORY_ID as categoryId,
		t3.CATEGORY_NAME,
		t3.ITEM_BARCODE,
		t3.PIECE_PRICE_TI as piecePriceTi,
		t3.PIECE_PRICE_TE as piecePriceTe,
		TRUNC(
			decode(
				nvl( t3.PIECE_PRICE_TI, 1 ),
				0,
				0,
				nvl( t3.PIECE_PRICE_TE, 0 ) / nvl( t3.PIECE_PRICE_TI, 1 ) 
			),
			4 
		) * 100 AS taxRate,
		<!-- TRUNC(nvl(t3.PIECE_PRICE_TE,0)/nvl(t3.PIECE_PRICE_TI,1), 4) * 100 as taxRate, -->
		t4.VENDOR_ID as vendorId,
		t4.ORGN_ID as orgId,
		t5.WAREHOUSE_NUM,
		t3.specification as specification,
		t3.ITEM_HEALTH_LISTED_LICENSOR as itemHealthListedLicensor,
		t3.ITEM_HEALTH_PRODUCE_LICENSE as itemHealthProduceLicense,
		t3.ITEM_HEALTH_STORE_CATEGORY as itemHealthStoreCategory,
		t3.ITEM_IS_RECHECK as itemIsRecheck,
		t3.IS_INSTRUMENT as isInstrument,
		t3.ITEM_IS_IMPORTED as itemIsImported,
		
		t3.MANUFACTURER_ID as manufacturerId,
		t3.MANUFACTURER_CODE as manufacturerCode,
		t3.MANUFACTURER_NAME as manufacturerName,
		t3.ITEM_HEALTH_REGISTER_NBR as itemHealthRegisterNbr,
		t3.ITEM_HEALTH_COMMON_NAME as itemHealthCommonName,
		t3.RETURN_INFO as returnInfo,
		t3.RETURN_COLD_QUALITY as returnColdQuality,
		t3.RETURN_EXPLAIN as returnExplain,
		t3.IS_LOCK as itemIsLock,
		t3.IS_HOSTED as isHosted,
		t3.ITEM_IS_SPECIAL as itemIsSpecial,
		t3.IS_BACTERIA as isBacteria,
		t3.SHELF_LIFE_DAYS as shelfLifeDays,
		t3.SHELF_LIFE_UNIT as shelfLifeUnit,
		
		t2.bldg_name as bldgName,
		t2.bldg_code as bldgCode,
		
		t2.DELEGATION_PARTY_ID as delegationPartyId,
		t2.DELEGATION_PARTY_NAME as delegationPartyName,
		t2.SHOW_PRODUCTION_DATE as showProductionDate,
		t2.SHOW_EXPIRED_DATE as showExpiredDate,
		t2.WAREHOUSE_ROOM_CODES as warehouseRoomCodes,
		t2.PIECE_CONVERSION_RATE as pieceConversionRate,
		t2.ASN_LINE_REMARK as asnLineRemark,
		t2.ITEM_ZJM as itemZjm,
		t3.allow_decimal as allowDecimal
		
		FROM
		wms_in_task_qc_detail t1
		LEFT JOIN
		WMS_IN_RCV_LINES t2
		on t1.rcv_line_id = t2.RCV_LINE_ID
		LEFT JOIN
		WMS_IN_RCV_LINES_PROFILES t3
		on t1.rcv_line_id = t3.RCV_LINE_ID
		LEFT JOIN
		wms_in_rcv_headers  t4
		on t4.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RCV_HEADERS_PROFILES  t5
		on t5.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RQC_LINES t6
		on t1.task_rqc_id = t6.task_rqc_id
		where
		1=1
		<if test="enterpriseId != null  and enterpriseId !=''">
			and t1.enterprise_id = #{enterpriseId}
		</if>
		<if test="warehouseId != null  and warehouseId !=''">
			and t1.warehouse_id = #{warehouseId}
		</if>
		<if test="mtlOwnerId != null  and mtlOwnerId !=''">
			and t1.mtl_owner_id = #{mtlOwnerId}
		</if>
		<if test="rcvHeaderId != null  and rcvHeaderId !=''">
			and t1.rcv_header_id = #{rcvHeaderId}
		</if>
		<if test="itemId != null  and itemId !=''">
			and t1.item_id = #{itemId}
		</if>
		<if test="rcvLineId != null  and rcvLineId !=''">
			and t1.rcv_line_id = #{rcvLineId}
		</if>
		<if test="status != null  and status !=''">
			and t1.status = #{status}
		</if>
		<if test="includeHids != null and includeHids.size() >0 ">
            and t1.rcv_header_id in
            <foreach collection="includeHids" item="item" open="("
                     separator="," close=")">
                #{item}
            </foreach>
        </if>
		<if test="excludeHids != null and excludeHids.size() >0 ">
            and t1.rcv_header_id not in
            <foreach collection="excludeHids" item="item" open="("
                     separator="," close=")">
                #{item}
            </foreach>
        </if>
		<if test="includeIds != null and includeIds.size() >0 ">
            and t1.task_rqc_id in
            <foreach collection="includeIds" item="item" open="("
                     separator="," close=")">
                #{item}
            </foreach>
        </if>
		<if test="excludeIds != null and excludeIds.size() >0 ">
            and t1.task_rqc_id not in
            <foreach collection="excludeIds" item="item" open="("
                     separator="," close=")">
                #{item}
            </foreach>
        </if>
        and t1.piece_qty  &lt;&gt; 0
		order by t1.gmt_modified
		desc
	</select>
	<update id="updateExcuterAndTimes" >  
		UPDATE WMS_IN_TASK_QC_DETAIL set  times = times+1,EXECUTOR = #{userName}  WHERE TASK_RQC_ID in  
		 <foreach collection="taskIds" item="item" open="("
                     separator="," close=")">
                #{item}
            </foreach>
	</update>
	<update id="updatePreNodeLineId" >  
		UPDATE WMS_IN_TASK_QC_DETAIL set EXECUTOR = #{userName},REF_TYPE = 1, PRE_NODE_LINE_ID = (select RQC_LINE_ID FROM WMS_IN_RQC_LINES WHERE TASK_RQC_ID = #{taskId} )  WHERE TASK_RQC_ID = #{taskId} 
	</update>
	
	<!-- 任务提取 不过滤执行者-->
	<select id="findListWithNoExcuter" resultMap="map">
		select
		distinct
		<include refid="clomuns"></include>
		t1.IS_RECHECKED as isRechecked,
		t6.qc_result2,
		t6.qc_reason2,
		t6.qc_opcode2, <!-- 前端 -->
		t6.qc_date2,
		t2.WAREHOUSE_AREA_CODES as warehouseAreaCodes,
		nvl(t2.ITEM_IS_PIECE_OR_CASE,'0' )as itemIsPieceOrCase,
		t2.WAREHOUSE_AREA_CATEGORYS as warehouseAreaCategorys,
		t2.ITEM_VOLUME,
		t2.ITEM_WEIGHT,
		t2.ITEM_HEALTH_TWOVOTEFLAG,
		t2.WAREHOUSE_NAME,
		t2.WAREHOUSE_AREA_NAME,
		t2.batch_production_date as  batchProductionDate,
		t2.batch_expired_date as batchExpiredDate,
		t2.ERP_BATCH_NUM as erpBatchNum,
		t2.PRODUCTION_PLACE as productionPlace,
		t3.ITEM_NUM,
		t3.ITEM_NAME,
		t3.CATEGORY_ID as categoryId,
		t3.CATEGORY_NAME,
		t3.ITEM_BARCODE,
		t3.PIECE_PRICE_TI as piecePriceTi,
		t3.PIECE_PRICE_TE as piecePriceTe,
		TRUNC(
			decode(
				nvl( t3.PIECE_PRICE_TI, 1 ),
				0,
				0,
				nvl( t3.PIECE_PRICE_TE, 0 ) / nvl( t3.PIECE_PRICE_TI, 1 ) 
			),
			4 
		) * 100 AS taxRate,
		<!-- TRUNC(nvl(t3.PIECE_PRICE_TE,0)/nvl(t3.PIECE_PRICE_TI,1), 4) * 100 as taxRate, -->
		t4.VENDOR_ID as vendorId,
		t4.ORGN_ID as orgId,
		t5.WAREHOUSE_NUM,
		t3.specification as specification,
		t3.ITEM_HEALTH_LISTED_LICENSOR as itemHealthListedLicensor,
		t3.ITEM_HEALTH_PRODUCE_LICENSE as itemHealthProduceLicense,
		<!-- t3.ITEM_HEALTH_STORE_CATEGORY as itemHealthStoreCategory, -->
		t3.ITEM_IS_RECHECK as itemIsRecheck,
		t3.IS_INSTRUMENT as isInstrument,
		t3.ITEM_IS_IMPORTED as itemIsImported,
		
		t3.MANUFACTURER_ID as manufacturerId,
		t3.MANUFACTURER_CODE as manufacturerCode,
		t3.MANUFACTURER_NAME as manufacturerName,
		t3.ITEM_HEALTH_REGISTER_NBR as itemHealthRegisterNbr,
		t3.ITEM_HEALTH_COMMON_NAME as itemHealthCommonName,
		t3.RETURN_INFO as returnInfo,
		t3.RETURN_COLD_QUALITY as returnColdQuality,
		t3.RETURN_EXPLAIN as returnExplain,
		t3.IS_LOCK as itemIsLock,
		t3.IS_HOSTED as isHosted,
		t3.ITEM_IS_SPECIAL as itemIsSpecial,
		t3.IS_BACTERIA as isBacteria,
		t3.SHELF_LIFE_DAYS as shelfLifeDays,
		t3.SHELF_LIFE_UNIT as shelfLifeUnit,
		
		t2.bldg_name as bldgName,
		t2.bldg_code as bldgCode,
		
		t2.DELEGATION_PARTY_ID as delegationPartyId,
		t2.DELEGATION_PARTY_NAME as delegationPartyName,
		t2.SHOW_PRODUCTION_DATE as showProductionDate,
		t2.SHOW_EXPIRED_DATE as showExpiredDate,
		t2.WAREHOUSE_ROOM_CODES as warehouseRoomCodes,
		t2.PIECE_CONVERSION_RATE as pieceConversionRate,
		t2.ASN_LINE_REMARK as asnLineRemark,
		t2.ITEM_ZJM as itemZjm,
		
		coalesce(t1.item_health_is_double,t2.ITEM_HEALTH_IS_DOUBLE,0) as item_health_is_double,
		
		<!-- 处理意见 -->
		t7.handling_suggestion as handlingSuggestion,
		t4.rcv_type as rcvType,
		t3.STORE_TEMPERATURE as storeTemperature,
		
		t2.is_delegate as isDelegate,
		t2.is_retrospect as isRetrospect,
		
		t2.rcv_reason1 as rcvReason1,
		t2.rcv_reason2 as rcvReason2,
		t2.rcv_reason3 as rcvReason3,
		t2.rcv_rt_reason as rcvRtReason,
		t2.approval_number as approvalNumber,
		CASE
		t2.ITEM_IS_PIECE_OR_CASE 
		WHEN '0' THEN
		'整散合一' 
		WHEN '1' THEN
		'整散分开' ELSE '整散合一' 
	END AS itemHealthStoreCategory,
	nvl((SELECT re.STOCK_STATUS FROM WMS_IN_RQC_RE_LINES re WHERE t1.REF_LINE_ID = re.RQC_RE_LINE_ID),'N/A') AS reCheckResult, 
	'N/A' as manufacturerRegisterNo,
	<!-- 处理原因、不足原因、不足原因补充 -->
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason1
				WHEN 1 THEN
				t8.handling_reason
				WHEN 2 THEN
				t7.handling_reason
				ELSE t2.rcv_reason1 
			END AS handlingReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason2
				WHEN 1 THEN
				t8.def_reason
				WHEN 2 THEN
				t7.def_reason
				ELSE t2.rcv_reason2
			END AS defReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason3
				WHEN 1 THEN
				t8.def_reason_ext
				WHEN 2 THEN
				t7.def_reason_ext
				ELSE t2.rcv_reason3 
			END AS defReasonExt,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				''
				WHEN 1 THEN
				t8.HANDLING_MEASURE
				WHEN 2 THEN
				t7.HANDLING_MEASURE
				ELSE '' 
			END AS handlingMeasure,
			t1.RESULT as stockStatus,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				'收货'
				WHEN 1 THEN
				'一次质检'
				WHEN 2 THEN
				'复检'
				ELSE '收货' 
			END AS sourceType,
			t2.RQC_REPORT_NO as rqcReportNo,
			t1.ref_type as refType,
			t3.allow_decimal as allowDecimal,
			t2.is_retrospect as isSupervise,
			t2.WH_LOCATOR_ID as whLocatorId,
			t2.WH_LOCATOR_CODE as whLocatorCode,
			t2.WH_AREA_CODE as whAreaCode,
			t2.WH_AREA_CATEGORY_CODE as whAreaCategoryCode

			

		FROM
		wms_in_task_qc_detail t1
		LEFT JOIN
		WMS_IN_RCV_LINES t2
		on t1.rcv_line_id = t2.RCV_LINE_ID
		LEFT JOIN
		WMS_IN_RCV_LINES_PROFILES t3
		on t1.rcv_line_id = t3.RCV_LINE_ID
		LEFT JOIN
		wms_in_rcv_headers  t4
		on t4.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RCV_HEADERS_PROFILES  t5
		on t5.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RQC_LINES t6
		on t1.task_rqc_id = t6.task_rqc_id
		LEFT JOIN
		WMS_IN_RQC_RE_LINES t7
		on t1.ref_line_id = t7.rqc_re_line_id
		LEFT JOIN WMS_IN_RQC_LINES t8 ON t1.pre_node_line_id = t8.rqc_line_id 
		where
		1=1
		<if test="enterpriseId != null  and enterpriseId !=''">
			and t1.enterprise_id = #{enterpriseId}
		</if>
		<if test="warehouseId != null  and warehouseId !=''">
			and t1.warehouse_id = #{warehouseId}
		</if>
		<if test="mtlOwnerId != null  and mtlOwnerId !=''">
			and t1.mtl_owner_id = #{mtlOwnerId}
		</if>
		<if test="rcvHeaderId != null  and rcvHeaderId !=''">
			and t1.rcv_header_id = #{rcvHeaderId}
		</if>
		<if test="itemId != null  and itemId !=''">
			and t1.item_id = #{itemId}
		</if>
		<if test="rcvLineId != null  and rcvLineId !=''">
			and t1.rcv_line_id = #{rcvLineId}
		</if>
		<if test="status != null  and status !=''">
			and t1.status = #{status}
		</if>
		<if test="containerCode != null  and containerCode !=''">
			AND UPPER(t1.CONTAINER_CODE) like CONCAT(CONCAT('%',UPPER(#{containerCode})),'%') 
		</if>
		<if test="itemCondition != null  and itemCondition !=''">     
			and ( UPPER(t2.ITEM_ZJM) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%') or UPPER(t3.ITEM_NUM) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%')
					or UPPER(t3.ITEM_NAME) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%') or UPPER(t3.ITEM_BARCODE) like CONCAT(CONCAT('%',UPPER(#{itemCondition})),'%')
			  )
		</if>
		and t1.piece_qty  &lt;&gt; 0
		order by t1.gmt_modified
		desc
	</select>
	<select id="findByPKId" resultMap="map">
		select
		distinct
		<include refid="clomuns"></include>
		t1.IS_RECHECKED as isRechecked,
		t6.qc_result2,
		t6.qc_reason2,
		t6.qc_opcode2, <!-- 前端 -->
		t6.qc_date2,
		t2.WAREHOUSE_AREA_CODES as warehouseAreaCodes,
		nvl(t2.ITEM_IS_PIECE_OR_CASE,'0' )as itemIsPieceOrCase,
		t2.WAREHOUSE_AREA_CATEGORYS as warehouseAreaCategorys,
		t2.ITEM_VOLUME,
		t2.ITEM_WEIGHT,
		t2.ITEM_HEALTH_TWOVOTEFLAG,
		t2.WAREHOUSE_NAME,
		t2.WAREHOUSE_AREA_NAME,
		t2.batch_production_date as  batchProductionDate,
		t2.batch_expired_date as batchExpiredDate,
		t2.ERP_BATCH_NUM as erpBatchNum,
		t2.PRODUCTION_PLACE as productionPlace,
		t3.ITEM_NUM,
		t3.ITEM_NAME,
		t3.CATEGORY_ID as categoryId,
		t3.CATEGORY_NAME,
		t3.ITEM_BARCODE,
		t3.PIECE_PRICE_TI as piecePriceTi,
		t3.PIECE_PRICE_TE as piecePriceTe,
		TRUNC(
			decode(
				nvl( t3.PIECE_PRICE_TI, 1 ),
				0,
				0,
				nvl( t3.PIECE_PRICE_TE, 0 ) / nvl( t3.PIECE_PRICE_TI, 1 ) 
			),
			4 
		) * 100 AS taxRate,
		<!-- TRUNC(nvl(t3.PIECE_PRICE_TE,0)/nvl(t3.PIECE_PRICE_TI,1), 4) * 100 as taxRate, -->
		t4.VENDOR_ID as vendorId,
		t4.ORGN_ID as orgId,
		t5.WAREHOUSE_NUM,
		t3.specification as specification,
		t3.ITEM_HEALTH_LISTED_LICENSOR as itemHealthListedLicensor,
		t3.ITEM_HEALTH_PRODUCE_LICENSE as itemHealthProduceLicense,
		<!-- t3.ITEM_HEALTH_STORE_CATEGORY as itemHealthStoreCategory, -->
		t3.ITEM_IS_RECHECK as itemIsRecheck,
		t3.IS_INSTRUMENT as isInstrument,
		t3.ITEM_IS_IMPORTED as itemIsImported,
		
		t3.MANUFACTURER_ID as manufacturerId,
		t3.MANUFACTURER_CODE as manufacturerCode,
		t3.MANUFACTURER_NAME as manufacturerName,
		t3.ITEM_HEALTH_REGISTER_NBR as itemHealthRegisterNbr,
		t3.ITEM_HEALTH_COMMON_NAME as itemHealthCommonName,
		t3.RETURN_INFO as returnInfo,
		t3.RETURN_COLD_QUALITY as returnColdQuality,
		t3.RETURN_EXPLAIN as returnExplain,
		t3.IS_LOCK as itemIsLock,
		t3.IS_HOSTED as isHosted,
		t3.ITEM_IS_SPECIAL as itemIsSpecial,
		t3.IS_BACTERIA as isBacteria,
		t3.SHELF_LIFE_DAYS as shelfLifeDays,
		t3.SHELF_LIFE_UNIT as shelfLifeUnit,
		
		t2.bldg_name as bldgName,
		t2.bldg_code as bldgCode,
		
		t2.DELEGATION_PARTY_ID as delegationPartyId,
		t2.DELEGATION_PARTY_NAME as delegationPartyName,
		t2.SHOW_PRODUCTION_DATE as showProductionDate,
		t2.SHOW_EXPIRED_DATE as showExpiredDate,
		t2.WAREHOUSE_ROOM_CODES as warehouseRoomCodes,
		t2.PIECE_CONVERSION_RATE as pieceConversionRate,
		t2.ASN_LINE_REMARK as asnLineRemark,
		t2.ITEM_ZJM as itemZjm,
		
		coalesce(t1.item_health_is_double,t2.ITEM_HEALTH_IS_DOUBLE,0) as item_health_is_double,
		
		<!-- 处理意见 -->
		t7.handling_suggestion as handlingSuggestion,
		t4.rcv_type as rcvType,
		t3.STORE_TEMPERATURE as storeTemperature,
		
		t2.is_delegate as isDelegate,
		t2.is_retrospect as isRetrospect,
		
		t2.rcv_reason1 as rcvReason1,
		t2.rcv_reason2 as rcvReason2,
		t2.rcv_reason3 as rcvReason3,
		t2.rcv_rt_reason as rcvRtReason,
		t2.approval_number as approvalNumber,
		CASE
		t2.ITEM_IS_PIECE_OR_CASE 
		WHEN '0' THEN
		'整散合一' 
		WHEN '1' THEN
		'整散分开' ELSE '整散合一' 
	END AS itemHealthStoreCategory,
	nvl((SELECT re.STOCK_STATUS FROM WMS_IN_RQC_RE_LINES re WHERE t1.REF_LINE_ID = re.RQC_RE_LINE_ID),'N/A') AS reCheckResult, 
	'N/A' as manufacturerRegisterNo,
	<!-- 处理原因、不足原因、不足原因补充 -->
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason1
				WHEN 1 THEN
				t8.handling_reason
				WHEN 2 THEN
				t7.handling_reason
				ELSE t2.rcv_reason1 
			END AS handlingReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason2
				WHEN 1 THEN
				t8.def_reason
				WHEN 2 THEN
				t7.def_reason
				ELSE t2.rcv_reason2
			END AS defReason, 
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				t2.rcv_reason3
				WHEN 1 THEN
				t8.def_reason_ext
				WHEN 2 THEN
				t7.def_reason_ext
				ELSE t2.rcv_reason3 
			END AS defReasonExt,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				''
				WHEN 1 THEN
				t8.HANDLING_MEASURE
				WHEN 2 THEN
				t7.HANDLING_MEASURE
				ELSE '' 
			END AS handlingMeasure,
			t1.RESULT as stockStatus,
			CASE t1.REF_TYPE 
				WHEN 0 THEN
				'收货'
				WHEN 1 THEN
				'一次质检'
				WHEN 2 THEN
				'复检'
				ELSE '收货' 
			END AS sourceType,
			t2.RQC_REPORT_NO as rqcReportNo,
			t1.ref_type as refType,
			t3.allow_decimal as allowDecimal,
			t2.is_retrospect as isSupervise,
			t2.WH_LOCATOR_ID as whLocatorId,
			t2.WH_LOCATOR_CODE as whLocatorCode,
			t2.WH_AREA_CODE as whAreaCode,
			t2.WH_AREA_CATEGORY_CODE as whAreaCategoryCode
		FROM
		wms_in_task_qc_detail t1
		LEFT JOIN
		WMS_IN_RCV_LINES t2
		on t1.rcv_line_id = t2.RCV_LINE_ID
		LEFT JOIN
		WMS_IN_RCV_LINES_PROFILES t3
		on t1.rcv_line_id = t3.RCV_LINE_ID
		LEFT JOIN
		wms_in_rcv_headers  t4
		on t4.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RCV_HEADERS_PROFILES  t5
		on t5.rcv_header_id = t1.rcv_header_id
		LEFT JOIN
		WMS_IN_RQC_LINES t6
		on t1.task_rqc_id = t6.task_rqc_id
		LEFT JOIN
		WMS_IN_RQC_RE_LINES t7
		on t1.ref_line_id = t7.rqc_re_line_id
		LEFT JOIN WMS_IN_RQC_LINES t8 ON t1.pre_node_line_id = t8.rqc_line_id 
		where
		1=1
		<if test="taskRqcId != null  and taskRqcId !=''">
			and t1.task_rqc_id = #{taskRqcId}
		</if>
		order by t1.gmt_modified
		desc
	</select>
	<select id="queryDictInfo" resultType="java.util.Map">
		SELECT DISTINCT
		t.type_code,d.dict_code,d.dict_name
		FROM
		upcloud_base_common_qingniu.base_common_dict d,
		upcloud_base_common_qingniu.base_common_dicttype t
		WHERE
		d.dicttype_id = t.type_id
		AND d.is_enable = 1
		AND t.is_enable = 1
		<if test="typeCodes != null and typeCodes.size() >0 ">
			AND t.type_code in
			<foreach collection="typeCodes" item="item" open="("
					 separator="," close=")">
				#{item}
			</foreach>
		</if>
	</select>
</mapper>