diff --git a/MpsFormalBatch/src/main/java/com/gtsoft/mps/batch/processor/biz/BIZ022Processor.java b/MpsFormalBatch/src/main/java/com/gtsoft/mps/batch/processor/biz/BIZ022Processor.java index 2bca062..5e212f0 100644 --- a/MpsFormalBatch/src/main/java/com/gtsoft/mps/batch/processor/biz/BIZ022Processor.java +++ b/MpsFormalBatch/src/main/java/com/gtsoft/mps/batch/processor/biz/BIZ022Processor.java @@ -70,13 +70,22 @@ public class BIZ022Processor extends AbstractBusinessProcessor { * 验证营销记录有效性 */ private int validateMarketingRecords(Connection connection, String batchMonth) throws SQLException { - String sql = "UPDATE mps_market m " + - "SET check_flag = CASE " + + String sql = "UPDATE mps_market m " + + "SET check_flag = CASE " + " WHEN EXISTS ( " + - " SELECT 1 FROM mps_import_water s " + - " WHERE s.customer_code = m.heating_no ) " + - " THEN '1' ELSE '9' END " + - "WHERE SUBSTR(entry_date, 1, 7) = ? and subcategory_id = 'BIZ022' and del_flag='0' "; + " SELECT 1 " + + " FROM ( " + + " SELECT customer_code " + + " FROM mps_import_water " + + " GROUP BY customer_code " + + " HAVING SUM(CAST(NULLIF(TRIM(current_payment_amount), '') AS DECIMAL(18,2))) > 20 " + + " ) s " + + " WHERE s.customer_code = m.heating_no " + + " ) THEN '1' ELSE '9' END " + + "WHERE " + + " SUBSTR(entry_date, 1, 7) = ? " + + " AND subcategory_id = 'BIZ022' " + + " AND del_flag = '0' "; return executeParameterizedSql(connection, sql, batchMonth); }