update ic_on_hand_num set product_date=#{productDate, jdbcType=DATE},
expire_date=#{expireDate, jdbcType=DATE},nonhandnum = nonhandnum + #{nonhandnum},
pk_modified=#{pkModified},modified_time=#{modifiedTime}
where del_flag=0 and pk_id=#{pkId}
merge into ic_on_hand_num a
using(
select #{item.pkId} pk_id,#{item.nonhandnum} nonhandnum,
#{item.pkModified} pk_modified,#{item.modifiedTime} modified_time from dual
) b
on (a.pk_id=b.pk_id)
when matched then
update set a.nonhandnum = a.nonhandnum + b.nonhandnum,
a.pk_modified=b.pk_modified,a.modified_time=b.modified_time
where a.del_flag=0 and a.nonhandnum + b.nonhandnum >=0
merge into ic_on_hand_num a
using(
select pk_onhandnum pk_id,sum(nnum) nnum,#{pkMember} pk_modified,sysdate modified_time from (
select #{item.pkOnhandnum} pk_onhandnum,#{item.nnum} nnum from dual
)
group by pk_onhandnum
) b
on (a.pk_id=b.pk_id)
when matched then
update set a.nonhandnum = a.nonhandnum + b.nnum,
a.pk_modified=b.pk_modified,a.modified_time=b.modified_time
SELECT IC_ON_HAND_NUM_SEQ.NEXTVAL FROM DUAL
select ih.*,ips.pk_specs_type,ips.pk_specs,ips.specs_name from ic_on_hand_num ih
inner join (
select pk_onhandnum,max(r) pk_specs from
(select pk_onhandnum,to_char(wm_concat(pk_specs) over (partition by pk_onhandnum order by pk_specs)) r
from ic_on_hand_specs
where del_flag = 0)
group by pk_onhandnum
) ip
on ih.pk_id=ip.pk_onhandnum
inner join ic_on_hand_specs ips
on ih.pk_id= ips.pk_onhandnum
where ih.del_flag=0 and ips.del_flag=0 and ih.pk_country = #{icOnHandNum.pkCountry}
and ih.pk_product=#{icOnHandNum.pkProduct} and ih.pk_storehouse=#{icOnHandNum.pkStorehouse}
and ih.pk_batch_code=#{icOnHandNum.pkBatchCode}
and ip.pk_specs = #{pkSpecs}
order by ih.pk_product,ih.pk_storehouse,ih.expire_date,ips.pk_specs
select ih.*,ip.h_specs_name from ic_on_hand_num ih
inner join (
select pk_onhandnum,max(r) h_specs_name from
(select pk_onhandnum,to_char(wm_concat(pk_specs) over (partition by pk_onhandnum order by pk_specs)) r
from ic_on_hand_specs
where del_flag = 0)
group by pk_onhandnum) ip
on ih.pk_id=ip.pk_onhandnum
where ih.del_flag=0
and ih.pk_country = #{icOnHandNum.pkCountry}
and ih.pk_product=#{icOnHandNum.pkProduct} and ih.pk_storehouse=#{icOnHandNum.pkStorehouse}
and ih.pk_batch_code=#{icOnHandNum.pkBatchCode}
order by ih.pk_product,ih.pk_storehouse,ih.expire_date
select ih.*,ip.h_specs_name,bp.product_code,bp.product_name,sc.corp_name,bh.name storehouse_name,
bc.cust_name cubasdoc_name,bn.name unit_name,ib.valid_period,ib.batch_code,
(case when ih.expire_date-sysdate <b.warn_period then 0 else 1 end) display_red,bp.shipping_channel from ic_on_hand_num ih
inner join (
select pk_onhandnum,max(r) h_specs_name from
(select pk_onhandnum,to_char(wm_concat(specs_name) over (partition by pk_onhandnum order by pk_specs)) r
from ic_on_hand_specs
where del_flag = 0)
group by pk_onhandnum
) ip
on ih.pk_id=ip.pk_onhandnum
inner join bd_product bp
on ih.pk_product=bp.pk_id
inner join bd_product_bas bba
on ih.pk_product_bas=bba.pk_id and bba.del_flag=0
left join bd_cubasdoc bc
on ih.pk_cubasdoc=bc.pk_id and bc.del_flag=0
left join bd_unit bn
on ih.pk_unit = bn.pk_id and bn.del_flag=0
left join ic_batch_code ib
on ih.pk_batch_code=ib.pk_id and ib.del_flag=0
left join sys_corp sc
on ih.pk_corp=sc.pk_id and sc.del_flag=0
left join bd_storehouse bh
on ih.pk_storehouse=bh.pk_id and bh.del_flag=0
left join(
select pk_product_bas,warn_period,bs.specs_name from ic_warn_config ic
inner join (
select pk_warn_config,max(r) specs_name from
(select pk_warn_config,to_char(wm_concat(specs_name) over (partition by pk_warn_config order by pk_specs)) r
from ic_warn_config_specs
where del_flag = 0)
group by pk_warn_config
) bs
on ic.pk_id=bs.pk_warn_config
where ic.del_flag=0
) b
on ih.pk_product_bas=b.pk_product_bas and ip.h_specs_name=b.specs_name
where ih.del_flag=0 and bp.del_flag=0
and ih.pk_country=#{pkCountry}
and ih.pk_corp = #{pkCorp}
and ih.pk_cubasdoc = #{pkCubasdoc}
and bp.product_code like '%' || #{productCode} || '%'
and bp.shipping_channel=#{shippingChannel}
and bp.product_name like '%' || #{productName} || '%'
and ih.pk_storehouse=#{pkStorehouse}
and ib.batch_code=#{batchCode}
and ih.pk_storehouse=#{pkWarehouse}
select ih.*,ip.pk_specs_type,ip.pk_specs,ip.specs_name from ic_on_hand_num ih
inner join ic_on_hand_specs ip
on ih.pk_id= ip.pk_onhandnum
where ih.del_flag=0 and ip.del_flag=0 and ih.pk_id in
#{item}