ID_, REF_ID_, F_date, F_org_name, F_org_id, F_org_type, F_yesterday_account_balance, F_today_account_balance, F_account_balance_difference, F_today_net_cash_flow, F_today_freeze_amount, F_today_freezing, F_insp_status_name, F_insp_time, F_insp_notes, F_insp_by, F_insp_id, F_create_by, F_create_id, F_create_time, F_update_by, F_update_id, F_update_time, F_form_data_rev_, F_order_no INSERT into w_daily_funds(ID_,F_date,F_org_id,F_org_name,F_org_type,F_order_no,F_insp_status_name) SELECT REPLACE(UUID(), '-', '') as ID_,#{fDate,jdbcType=TIMESTAMP} as F_date,org.ID_ as F_org_id,org.NAME_ as F_org_name,orgParams.VALUE_ as F_org_type,org.ORDER_NO_ as F_order_no,'待复核' as F_insp_status_name FROM uc_org org JOIN uc_org_params orgParams on orgParams.ORG_ID_= org.ID_ WHERE orgParams.VALUE_ !='' and orgParams.VALUE_ IS NOT NULL UPDATE w_daily_funds funds SET F_yesterday_account_balance =( SELECT SUM(c.F_account_balance) FROM w_current c WHERE F_date =(SELECT DATE_SUB(funds.F_date, INTERVAL 1 DAY)) AND c.F_org_id = funds.F_org_id ), F_today_account_balance =( SELECT SUM(c.F_account_balance) FROM w_current c WHERE c.F_date =funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_net_cash_flow= ( SELECT SUM(c.F_total_net_cash_flow) * 10000 FROM w_finance c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_freeze_amount=( SELECT SUM(c.F_freeze_amount) FROM w_current c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_freezing=( SELECT SUM(c.F_freezing) FROM w_current c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_account_balance_difference = (IFNULL(funds.F_today_account_balance,0)- IFNULL(funds.F_yesterday_account_balance,0)), F_update_by = #{fUpdateBy,jdbcType=VARCHAR}, F_update_id = #{fUpdateId,jdbcType=VARCHAR}, F_update_time = #{fUpdateTime,jdbcType=TIMESTAMP}, f_insp_status_name = '待复核', f_insp_time = null, f_insp_notes = null WHERE funds.F_date = #{fDate,jdbcType=TIMESTAMP} and funds.F_org_id in #{item.F_org_id} UPDATE w_daily_funds funds SET F_yesterday_account_balance =( SELECT SUM(c.F_account_balance) FROM w_current c WHERE F_date =(SELECT DATE_SUB(funds.F_date, INTERVAL 1 DAY)) AND c.F_org_id = funds.F_org_id ), F_today_account_balance =( SELECT SUM(c.F_account_balance) FROM w_current c WHERE c.F_date =funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_net_cash_flow= ( SELECT SUM(c.F_total_net_cash_flow) * 10000 FROM w_finance c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_freeze_amount=( SELECT SUM(c.F_freeze_amount) FROM w_current c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_today_freezing=( SELECT SUM(c.F_freezing) FROM w_current c WHERE c.F_date = funds.F_date AND c.F_org_id = funds.F_org_id ), F_account_balance_difference = (IFNULL(funds.F_today_account_balance,0)- IFNULL(funds.F_yesterday_account_balance,0)) WHERE funds.F_date = #{fDate,jdbcType=TIMESTAMP}