into_id ,into_no, into_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty,
return_amt, into_date, remarks, annex_paths, make_staff, make_time,
receivable_id, payable_id, flg_valid, cp_id, op_create_time, op_create_user_id,
op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,wh_id,
into_reason,flg_auto_handle,flg_handle_setting
tpi.into_id, tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id,
tpi.cus_id, tpi.sup_id, tpi.into_status, tpi.intoing_qty, tpi.intoing_amt, tpi.into_qty,
tpi.into_amt, tpi.return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths,
tpi.make_staff, tpi.make_time, tpi.receivable_id, tpi.payable_id, tpi.flg_valid, tpi.cp_id,
tpi.wh_id,tpi.into_reason,flg_auto_handle,flg_handle_setting
tpi.into_id
, tpi.into_no, tpi.into_type, tpi.from_id, tpi.from_no, tpi.org_id, tpi.staff_id, tpi.cus_id, tpi.sup_id, tpi.into_status, tpi.intoing_qty, tpi.intoing_amt,
tpi.into_qty, tpi.into_amt, tpi.return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths, tpi.make_staff, tpi.make_time,
tpi.receivable_id, tpi.payable_id, tpi.flg_valid, tpi.cp_id
AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
AND tpi.into_type LIKE concat('%',my_ex.likequery(#{intoType}),'%')
AND tpi.into_type =any(#{intoTypes,typeHandler=StringListTypeHandler})
AND tpi.into_reason =any(#{intoReasonList,typeHandler=UuidListTypeHandler})
AND (
tpi.into_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tpi.from_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tmp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
)
AND tpi.from_id = #{fromId}::uuid
AND tpi.from_no LIKE concat('%',my_ex.likequery(#{fromNo}),'%')
AND tpi.org_id = #{orgId}::uuid
AND tpi.staff_id = #{staffId}::uuid
AND tpi.cus_id = #{cusId}::uuid
AND tpi.sup_id = #{supId}::uuid
AND tpi.make_staff = #{makeStaff}
AND tpi.make_time = #{makeTime}
AND tpi.receivable_id = #{receivableId}
AND tpi.payable_id = #{payableId}
AND tpi.flg_valid = #{flgValid}
AND tpi.cp_id = #{cpId}
AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
AND tmo.org_id =any(#{orgIdList, typeHandler=uuidListTypeHandler})
AND tms.staff_id =any(#{staffIdList, typeHandler=uuidListTypeHandler})
AND tpi.make_time >= #{makeTimeStart}::timestamp with time zone
AND tpi.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
AND tpi.into_status =
any(#{intoStatusList, typeHandler= StringListTypeHandler})
AND tpi.into_status LIKE concat('%',my_ex.likequery(#{intoStatus}),'%')
and exists (select 1 from dkic_b.t_psi_inbound_item tpii
left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
where
tpi.into_id = tpii.into_id
and tpii.flg_valid
AND position(#{skuModel} in tmgs.sku_model) > 0
)
and exists (select 1 from dkic_b.t_psi_inbound_item tpii
left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
where
tpi.into_id = tpii.into_id
and tpii.flg_valid
AND position(#{skuCode} in tmgs.sku_code) > 0
)
and exists (select 1 from dkic_b.t_psi_inbound_item tpii
left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tpii.sku_id
where
tpi.into_id = tpii.into_id
and tpii.flg_valid
AND position(#{skuName} in tmgs.sku_name) > 0
)
WHERE into_id in
#{item}
Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
left join t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
insert into dkic_b.t_psi_inbound
(
into_no,
into_type,
from_id,
from_no,
org_id,
staff_id,
cus_id,
sup_id,
into_status,
intoing_qty,
intoing_amt,
into_qty,
into_amt,
return_qty,
return_amt,
into_date,
remarks,
annex_paths,
make_staff,
make_time,
receivable_id,
payable_id,
cp_id,
op_app_code,
wh_id,
entry_reason,
)
values
(
#{item.intoNo},
#{item.intoType},
#{item.fromId}::uuid,
#{item.fromNo},
#{item.orgId}::uuid,
#{item.staffId}::uuid,
#{item.cusId}::uuid,
#{item.supId}::uuid,
#{item.intoStatus},
#{item.intoingQty},
#{item.intoingAmt},
#{item.intoQty},
#{item.intoAmt},
#{item.returnQty},
#{item.returnAmt},
#{item.intoDate},
#{item.remarks},
#{item.annexPaths},
#{item.makeStaff}::uuid,
#{item.makeTime},
#{item.receivableId}::uuid,
#{item.payableId}::uuid,
#{item.cpId},
#{item.opAppCode},
#{item.whId},
#{item.intoReason}::uuid,
)
tpii
.
item_id
AS list_item_id,
tpii.item_id AS list_into_item_Id,
tpii.into_id AS list_into_id,
tpii.into_type AS list_into_type,
tpii.from_id AS list_from_id,
tpii.from_item_id AS list_from_item_id,
tpii.item_index AS list_item_index,
tpii.sku_id AS list_sku_id,
tpii.price_into AS list_price_into,
tpii.non_std_code AS list_non_std_code,
tpii.into_status AS list_into_status,
tpii.intoing_qty AS list_intoing_qty,
tpii.intoing_amt AS list_intoing_amt,
tpii.into_qty AS list_into_qty,
tpii.into_amt AS list_into_amt,
tpii.return_qty AS list_return_qty,
tpii.return_amt AS list_return_amt,
tpii.remarks AS list_remarks,
tpii.inv_id AS list_inv_id,
tpii.cost_price AS list_cost_price,
tpii.cost_amt AS list_cost_amt,
tpii.out_qty AS list_out_qty,
tpii.inv_qty AS list_inv_qty,
tpii.flg_valid AS list_flg_valids,
tpii.cp_id AS list_cp_id,
tmgs.sku_code AS list_sku_code,
tmgs.sku_name AS list_sku_name,
tmgs.sku_model AS list_sku_model,
tmgs.price_purchase AS list_price_purchase,
tmgs.sku_images AS list_sku_images,
( tpii.into_qty - tpii.return_qty) AS list_reject_qty,
-- tpit.usable_qty AS list_usable_qty,
-- tpit.inv_qty AS list_inv_qty,
-- tpit.outing_qty AS list_outing_qty
-- ,
tmgs.price_standard AS list_price_std,
i.inv_id as list_inv_id,
i.wh_id as list_wh_id,
i.inv_qty as list_inv_qty,
i.usable_qty as list_usable_qty,
i.wh_name as list_wh_name
update dkic_b.t_psi_inbound
return_qty= #{returnQty},
return_amt = #{returnAmt},
where into_id = #{intoId}::uuid
tpi.into_id,
tpi.into_no,
tpi.into_type,
tpi.from_id,
tpi.from_no,
tpi.org_id,
tpi.staff_id,
tpi.cus_id,
tpi.sup_id,
tpi.into_status,
tpi.intoing_qty,
tpi.intoing_amt,
tpi.into_qty,
tpi.into_amt,
tpi.return_qty,
tpi.return_amt,
tpi.into_date,
tpi.remarks,
tpi.annex_paths,
tpi.make_staff,
tpi.make_time,
tpi.wh_id,
tpi.into_reason
tpo.out_id as into_id,
tpo.out_no as into_no,
tpo.out_type as into_type,
tpo.from_id,
tpo.from_no,
tpo.org_id,
tpo.staff_id,
tpo.cus_id,
tpo.sup_id,
tpo.out_status,
tpo.outing_qty as intoing_qty,
tpo.outing_amt as intoing_amt,
tpo.out_qty as into_qty,
tpo.out_amt as into_amt,
tpo.return_qty,
tpo.return_amt,
tpo.out_date as into_date,
tpo.remarks,
tpo.annex_paths,
tpo.make_staff,
tpo.make_time,
null as wh_id,
tpo.out_reason as into_reason
Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpi.make_staff
LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
left join dkic_b.t_mst_customer tmc on tpi.cus_id = tmc.cus_id
left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
Left join dkic_b.t_mst_org tmo on tmo.org_id = tpo.org_id
Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpo.sup_id
Left join dkic_b.t_mst_staff tms on tms.staff_id = tpo.staff_id
Left join dkic_b.t_mst_staff makestaff on makestaff.staff_id = tpo.make_staff
LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpo.out_status
LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpo.out_type
left join dkic_b.t_mst_customer tmc on tpo.cus_id = tmc.cus_id
left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpo.out_reason
update dkic_b.t_psi_inbound
into_status= #{intoStatus},
where into_id = #{intoId}::uuid
Left join dkic_b.t_mst_org tmo on tmo.org_id = tpi.org_id
Left join dkic_b.t_mst_supplier tmp on tmp.sup_id = tpi.sup_id
Left join dkic_b.t_mst_staff tms on tms.staff_id = tpi.staff_id
Left join dkic_b.t_mst_staff tms1 on tms1.staff_id = tpi.make_staff
LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tpi.into_status
LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = tpi.into_type
Left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
left join t_mac_account_item tmai on tmai.item_id = tpi.receivable_id