增加季报、年报的处理
This commit is contained in:
parent
a15577d9d6
commit
0ec0a53cfe
@ -468,7 +468,7 @@ public class MpsFormalBatchMain {
|
||||
String message = "初始化业务程序执行失败";
|
||||
batchStatusService.updateBatchStatus(
|
||||
batchMonth,
|
||||
BatchStatusService.BATCH_TYPE_PRE,
|
||||
BatchStatusService.BATCH_TYPE_AFTER,
|
||||
BatchStatusService.STATUS_FAILED,
|
||||
message
|
||||
);
|
||||
@ -480,7 +480,7 @@ public class MpsFormalBatchMain {
|
||||
String message = "业务指标加工程序执行失败";
|
||||
batchStatusService.updateBatchStatus(
|
||||
batchMonth,
|
||||
BatchStatusService.BATCH_TYPE_PRE,
|
||||
BatchStatusService.BATCH_TYPE_AFTER,
|
||||
BatchStatusService.STATUS_FAILED,
|
||||
message
|
||||
);
|
||||
@ -492,7 +492,7 @@ public class MpsFormalBatchMain {
|
||||
String message = "汇总程序执行失败";
|
||||
batchStatusService.updateBatchStatus(
|
||||
batchMonth,
|
||||
BatchStatusService.BATCH_TYPE_PRE,
|
||||
BatchStatusService.BATCH_TYPE_AFTER,
|
||||
BatchStatusService.STATUS_FAILED,
|
||||
message
|
||||
);
|
||||
@ -514,7 +514,7 @@ public class MpsFormalBatchMain {
|
||||
logger.error("正式批量执行异常: {}", batchMonth, e);
|
||||
batchStatusService.updateBatchStatus(
|
||||
batchMonth,
|
||||
BatchStatusService.BATCH_TYPE_PRE,
|
||||
BatchStatusService.BATCH_TYPE_AFTER,
|
||||
BatchStatusService.STATUS_FAILED,
|
||||
"正式批量异常: " + e.getMessage()
|
||||
);
|
||||
@ -748,6 +748,8 @@ public class MpsFormalBatchMain {
|
||||
afterBusinessCodes = new String[]{
|
||||
"TOTAL001",
|
||||
"TOTAL002",
|
||||
"TOTAL003",
|
||||
"TOTAL004",
|
||||
// 其他汇总业务程序
|
||||
};
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ public abstract class AbstractBusinessProcessor {
|
||||
"marketing_performance_h",
|
||||
"marketing_performance_m_d",
|
||||
"marketing_performance_m",
|
||||
"marketing_performance_q",
|
||||
"marketing_performance_y",
|
||||
"marketing_valid_invalid",
|
||||
"mps_market",
|
||||
"mps_magneticcard",
|
||||
"mps_traffic"
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.gtsoft.mps.batch.processor;
|
||||
|
||||
import com.gtsoft.mps.batch.processor.init.DeptTransferProcessor;
|
||||
import com.gtsoft.mps.batch.processor.total.CntAndAmtTotalProcessor;
|
||||
import com.gtsoft.mps.batch.processor.total.*;
|
||||
import com.gtsoft.mps.batch.processor.biz.*;
|
||||
import com.gtsoft.mps.batch.processor.init.InitInsertProcessor;
|
||||
import com.gtsoft.mps.batch.processor.total.MarketerTotalProcessor;
|
||||
import com.gtsoft.mps.batch.processor.init.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -69,7 +67,9 @@ public class BusinessProcessorFactory {
|
||||
|
||||
// ------------------ 处理手工计价,特殊计价,以及汇总栏位 ------------------
|
||||
PROCESSOR_MAP.put("TOTAL001", CntAndAmtTotalProcessor.class); // 汇总员工计价信息
|
||||
PROCESSOR_MAP.put("TOTAL002", MarketerTotalProcessor.class); // 汇总员工计价信息
|
||||
PROCESSOR_MAP.put("TOTAL002", MarketerMonthTotalProcessor.class); // 汇总员工计价信息
|
||||
PROCESSOR_MAP.put("TOTAL003", MarketerQuarterTotalProcessor.class); // 季度报表
|
||||
PROCESSOR_MAP.put("TOTAL004", MarketerYearTotalProcessor.class); // 年度报表
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
logger.info("查询到 {} 条商户记录", merchantRecords.size());
|
||||
|
||||
// 5. 计算奖励并更新绩效
|
||||
totalProcessedCount = calculateAndUpdateRewards(connection, merchantRecords, rewardRules, branchPercentages, quarterRange, tableName);
|
||||
totalProcessedCount = calculateAndUpdateRewards(connection, merchantRecords, rewardRules, branchPercentages, quarterRange, tableName, batchMonth);
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
@ -98,8 +98,8 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
logger.info("当前季度初以及季度末: {} {}", firstDay, lastDay);
|
||||
|
||||
// 截取月份
|
||||
String startMonth = firstDay.substring(0, 7).replace("-", "");
|
||||
String endMonth = lastDay.substring(0, 7).replace("-", "");
|
||||
String startMonth = firstDay.substring(0, 7);
|
||||
String endMonth = lastDay.substring(0, 7);
|
||||
|
||||
return new QuarterRange(startMonth, endMonth);
|
||||
} catch (Exception e) {
|
||||
@ -250,7 +250,7 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
*/
|
||||
private int calculateAndUpdateRewards(Connection connection, List<MerchantRecord> records,
|
||||
List<RewardRule> rewardRules, Map<String, BranchPercentage> branchPercentages,
|
||||
QuarterRange quarterRange, String tableName) throws SQLException {
|
||||
QuarterRange quarterRange, String tableName, String batchMonth) throws SQLException {
|
||||
|
||||
if (records.isEmpty()) {
|
||||
logger.info("没有商户记录需要处理");
|
||||
@ -258,6 +258,7 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
}
|
||||
|
||||
int updatedCount = 0;
|
||||
// 获取季度标识,例如 2025Q3
|
||||
String quarterId = getQuarterIdentifier(quarterRange.startMonth);
|
||||
|
||||
// 按员工分组计算奖励
|
||||
@ -291,15 +292,17 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
// 更新记录
|
||||
String updateSql = String.format("UPDATE %s " +
|
||||
"SET zhi_e_individual_count = zhi_e_individual_count + ?, " +
|
||||
" zhi_e_individual_amount = zhi_e_individual_amount + ? " +
|
||||
" zhi_e_individual_amount = zhi_e_individual_amount + ?, " +
|
||||
" fill1 = ? " +
|
||||
"WHERE marketer_code = ? AND branch_id = ? AND record_date = ?", tableName);
|
||||
|
||||
updatedCount += executeParameterizedSql(connection, updateSql,
|
||||
String.valueOf(summary.recordCount),
|
||||
summary.totalReward.toString(),
|
||||
quarterId,
|
||||
summary.marketerCode,
|
||||
summary.branchId,
|
||||
quarterId);
|
||||
batchMonth);
|
||||
}
|
||||
|
||||
return updatedCount;
|
||||
@ -351,15 +354,15 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
*/
|
||||
private String getQuarterIdentifier(String startMonth) {
|
||||
int year = Integer.parseInt(startMonth.substring(0, 4));
|
||||
int month = Integer.parseInt(startMonth.substring(4, 6));
|
||||
int month = Integer.parseInt(startMonth.substring(5, 7));
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
return year + "Q" + quarter;
|
||||
}
|
||||
|
||||
// 数据对象定义
|
||||
private static class QuarterRange {
|
||||
final String startMonth; // 格式: yyyyMM
|
||||
final String endMonth; // 格式: yyyyMM
|
||||
final String startMonth; // 格式: yyyy-MM
|
||||
final String endMonth; // 格式: yyyy-MM
|
||||
|
||||
QuarterRange(String startMonth, String endMonth) {
|
||||
this.startMonth = startMonth;
|
||||
@ -413,4 +416,15 @@ public class BIZ006Processor extends AbstractBusinessProcessor {
|
||||
this.totalReward = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String startMonth="2025-08";
|
||||
|
||||
int year = Integer.parseInt(startMonth.substring(0, 4));
|
||||
int month = Integer.parseInt(startMonth.substring(5, 7));
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
String tmp = year + "Q" + quarter;
|
||||
System.out.println(tmp);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 处理手工计价金额和汇总计价金额
|
||||
* 处理汇总计价金额
|
||||
*
|
||||
* @author mps-batch
|
||||
* @version 1.0
|
||||
@ -26,7 +26,7 @@ public class CntAndAmtTotalProcessor extends AbstractBusinessProcessor {
|
||||
|
||||
@Override
|
||||
protected void doProcess(Connection connection, String batchMonth, ProcessResult result, String batchType) throws Exception {
|
||||
logger.info("开始更新手工计价结果和汇总员工总计价金额信息,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
logger.info("开始处理员工总计价金额信息,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
|
||||
int totalProcessedCount = 0;
|
||||
|
||||
@ -39,19 +39,11 @@ public class CntAndAmtTotalProcessor extends AbstractBusinessProcessor {
|
||||
}
|
||||
|
||||
try {
|
||||
// 从mps_manual_pricing取值,更新BIZ007 BIZ023 BIZ024 BIZ025 BIZ026 BIZ027 BIZ028 BIZ029 BIZ030 BIZ032计价金额
|
||||
int validatedCount = updateShouGongJiJia(connection, batchMonth, tableName);
|
||||
logger.info("完成手工计价指标处理,更新记录数: {}", validatedCount);
|
||||
|
||||
// 更新特殊项数据
|
||||
int jbUpdated = updateTeShuJiJia(connection, batchMonth, tableName);
|
||||
logger.info("完成特殊项计价处理,更新记录数: {}", jbUpdated);
|
||||
totalProcessedCount += jbUpdated;
|
||||
|
||||
// 更新总笔数、总金额
|
||||
int yxUpdated = updateToTalCntAmt(connection, batchMonth, tableName);
|
||||
logger.info("完成总金额、总笔数处理,更新记录数: {}", yxUpdated);
|
||||
totalProcessedCount += yxUpdated;
|
||||
int updateCount = updateToTalCntAmt(connection, batchMonth, tableName);
|
||||
logger.info("完成总金额、总笔数处理,更新记录数: {}", updateCount);
|
||||
totalProcessedCount += updateCount;
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
@ -62,73 +54,7 @@ public class CntAndAmtTotalProcessor extends AbstractBusinessProcessor {
|
||||
}
|
||||
|
||||
result.setProcessedCount(totalProcessedCount);
|
||||
logger.info("更新手工计价结果和汇总员工总计价金额处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取手工录入的计价信息
|
||||
*/
|
||||
private int updateShouGongJiJia(Connection connection, String batchMonth, String tableName) throws SQLException {
|
||||
String sql = String.format("UPDATE %s mp " +
|
||||
"JOIN ( " +
|
||||
" select " +
|
||||
" branch " +
|
||||
" ,idcard_no " +
|
||||
" ,name " +
|
||||
" ,marketing_code as marketer_code " +
|
||||
" ,import_time as record_date " +
|
||||
" ,merchant_retention_rate " +
|
||||
" ,new_party_fee_units " +
|
||||
" ,new_union_fee_units " +
|
||||
" ,new_property_fee_units " +
|
||||
" ,new_catering_fee_units " +
|
||||
" ,new_foreign_accounts " +
|
||||
" ,new_individual_treasury " +
|
||||
" ,new_corporate_treasury " +
|
||||
" ,treasury_transactions " +
|
||||
" ,regular_products " +
|
||||
" ,new_housing_fund " +
|
||||
" from mps_manual_pricing " +
|
||||
" where import_time=? " +
|
||||
") AS source_data " +
|
||||
"ON " +
|
||||
//" mp.branch_id = source_data.branch_id " +
|
||||
" mp.marketer_code = source_data.marketer_code " +
|
||||
" AND mp.record_date = source_data.record_date " +
|
||||
"SET " +
|
||||
" mp.existing_merchant_retention_amount = source_data.merchant_retention_rate " +
|
||||
" ,mp.new_party_fee_unit_amount = source_data.new_party_fee_units " +
|
||||
" ,mp.new_union_fee_unit_amount = source_data.new_union_fee_units " +
|
||||
" ,mp.new_property_fee_unit_amount = source_data.new_property_fee_units " +
|
||||
" ,mp.new_meal_fee_unit_amount = source_data.new_catering_fee_units " +
|
||||
" ,mp.new_foreign_account_amount = source_data.new_foreign_accounts " +
|
||||
" ,mp.new_personal_wealth_amount = source_data.new_individual_treasury " +
|
||||
" ,mp.new_corporate_wealth_amount = source_data.new_corporate_treasury " +
|
||||
" ,mp.wealth_sales_amount = source_data.treasury_transactions " +
|
||||
" ,mp.fixed_term_wealth_amount = source_data.regular_products " +
|
||||
" ,mp.new_housing_fund_customer_amount = source_data.new_housing_fund " +
|
||||
"WHERE " +
|
||||
" mp.record_date = ? ", tableName);
|
||||
|
||||
return executeParameterizedSql(connection, sql, batchMonth, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新经办人员奖金
|
||||
*/
|
||||
private int updateTeShuJiJia(Connection connection, String batchMonth, String tableName) throws SQLException {
|
||||
String sql = String.format("update %s a " +
|
||||
"set a.add_item=COALESCE(" +
|
||||
" ( select " +
|
||||
" sum(add_item) " +
|
||||
" from mps_emp_add_items b " +
|
||||
" where substr(b.record_month,1,7) = ? and a.marketer_code=b.marketing_code " +
|
||||
" group by b.marketing_code" +
|
||||
" )" +
|
||||
" ,0)" +
|
||||
"where a.record_date=? ", tableName);
|
||||
|
||||
return executeParameterizedSql(connection, sql, batchMonth, batchMonth);
|
||||
logger.info("更新员工总计价金额处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,413 @@
|
||||
package com.gtsoft.mps.batch.processor.total;
|
||||
|
||||
import com.gtsoft.mps.batch.processor.AbstractBusinessProcessor;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 处理手工计价金额和汇总计价金额
|
||||
*
|
||||
* @author mps-batch
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MarketerMonthTotalProcessor extends AbstractBusinessProcessor {
|
||||
|
||||
@Override
|
||||
public String getBusinessCode() {
|
||||
return "TOTAL002";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBusinessName() {
|
||||
return "员工计价营销号汇总信息处理";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doProcess(Connection connection, String batchMonth, ProcessResult result, String batchType) throws Exception {
|
||||
logger.info("开始根据营销编号汇总计价信息,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
|
||||
int totalProcessedCount = 0;
|
||||
|
||||
try {
|
||||
|
||||
// 按营销号汇总成一条记录
|
||||
int insertCount = insertMarketingPerformanceM(connection, batchMonth);
|
||||
logger.info("共插入员工汇总记录: {}", insertCount);
|
||||
totalProcessedCount += insertCount;
|
||||
|
||||
// 从mps_manual_pricing取值,更新BIZ007 BIZ023 BIZ024 BIZ025 BIZ026 BIZ027 BIZ028 BIZ029 BIZ030 BIZ032计价金额
|
||||
int shouGongCount = updateShouGongJiJia(connection, batchMonth);
|
||||
logger.info("完成手工计价指标处理,更新记录数: {}", shouGongCount);
|
||||
|
||||
// 更新特殊项数据
|
||||
int teShuUpdated = updateTeShuJiJia(connection, batchMonth);
|
||||
logger.info("完成特殊项计价处理,更新记录数: {}", teShuUpdated);
|
||||
totalProcessedCount += teShuUpdated;
|
||||
|
||||
// 按营销号汇总成一条记录
|
||||
int totalCount = updateToTalCntAmt(connection, batchMonth);
|
||||
logger.info("共插入员工汇总记录: {}", totalCount);
|
||||
totalProcessedCount += totalCount;
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("处理过程中发生未知异常", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
result.setProcessedCount(totalProcessedCount);
|
||||
logger.info("根据营销编号汇总计价信息处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新营销人员奖金
|
||||
*/
|
||||
private int insertMarketingPerformanceM(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "INSERT INTO marketing_performance_m ( \n" +
|
||||
"\tbranch_name \n" +
|
||||
"\t,branch_id \n" +
|
||||
"\t,marketer_name \n" +
|
||||
"\t,marketer_id_card \n" +
|
||||
"\t,marketer_code \n" +
|
||||
"\t,marketer_position \n" +
|
||||
"\t,zhi_e_individual_count \n" +
|
||||
"\t,zhi_e_individual_amount \n" +
|
||||
"\t,zhi_e_inactive_count \n" +
|
||||
"\t,zhi_e_inactive_amount \n" +
|
||||
"\t,zhi_e_enterprise_count \n" +
|
||||
"\t,zhi_e_enterprise_amount \n" +
|
||||
"\t,corporate_mobile_bank_count \n" +
|
||||
"\t,corporate_mobile_bank_amount \n" +
|
||||
"\t,new_merchant_first_month_count \n" +
|
||||
"\t,new_merchant_first_month_amount \n" +
|
||||
"\t,new_merchant_retention_quarter_count \n" +
|
||||
"\t,new_merchant_retention_quarter_amount \n" +
|
||||
"\t,existing_merchant_retention_count \n" +
|
||||
"\t,existing_merchant_retention_amount \n" +
|
||||
"\t,online_payment_count \n" +
|
||||
"\t,online_payment_amount \n" +
|
||||
"\t,magnetic_to_ic_card_count \n" +
|
||||
"\t,magnetic_to_ic_card_amount \n" +
|
||||
"\t,new_bank_card_count \n" +
|
||||
"\t,new_bank_card_amount \n" +
|
||||
"\t,new_social_card_count \n" +
|
||||
"\t,new_social_card_amount \n" +
|
||||
"\t,loan_customer_social_card_count \n" +
|
||||
"\t,loan_customer_social_card_amount \n" +
|
||||
"\t,employee_social_card_count \n" +
|
||||
"\t,employee_social_card_amount \n" +
|
||||
"\t,activated_social_card_count \n" +
|
||||
"\t,activated_social_card_amount \n" +
|
||||
"\t,e_social_card_count \n" +
|
||||
"\t,e_social_card_amount \n" +
|
||||
"\t,medical_e_voucher_count \n" +
|
||||
"\t,medical_e_voucher_amount \n" +
|
||||
"\t,zhi_e_pay_count \n" +
|
||||
"\t,zhi_e_pay_amount \n" +
|
||||
"\t,huinong_farmer_count \n" +
|
||||
"\t,huinong_farmer_amount \n" +
|
||||
"\t,huinong_buyer_count \n" +
|
||||
"\t,huinong_buyer_amount \n" +
|
||||
"\t,water_fee_collection_count \n" +
|
||||
"\t,water_fee_collection_amount \n" +
|
||||
"\t,heat_fee_collection_count \n" +
|
||||
"\t,heat_fee_collection_amount \n" +
|
||||
"\t,electricity_fee_collection_count \n" +
|
||||
"\t,electricity_fee_collection_amount \n" +
|
||||
"\t,traffic_fine_collection_count \n" +
|
||||
"\t,traffic_fine_collection_amount \n" +
|
||||
"\t,new_party_fee_unit_count \n" +
|
||||
"\t,new_party_fee_unit_amount \n" +
|
||||
"\t,new_union_fee_unit_count \n" +
|
||||
"\t,new_union_fee_unit_amount \n" +
|
||||
"\t,new_property_fee_unit_count \n" +
|
||||
"\t,new_property_fee_unit_amount \n" +
|
||||
"\t,new_meal_fee_unit_count \n" +
|
||||
"\t,new_meal_fee_unit_amount \n" +
|
||||
"\t,new_foreign_account_count \n" +
|
||||
"\t,new_foreign_account_amount \n" +
|
||||
"\t,new_personal_wealth_count \n" +
|
||||
"\t,new_personal_wealth_amount \n" +
|
||||
"\t,new_corporate_wealth_count \n" +
|
||||
"\t,new_corporate_wealth_amount \n" +
|
||||
"\t,wealth_sales_count \n" +
|
||||
"\t,wealth_sales_amount \n" +
|
||||
"\t,fixed_term_wealth_count \n" +
|
||||
"\t,fixed_term_wealth_amount \n" +
|
||||
"\t,new_housing_fund_customer_count \n" +
|
||||
"\t,new_housing_fund_customer_amount \n" +
|
||||
"\t,housing_fund_customer_count \n" +
|
||||
"\t,housing_fund_customer_amount \n" +
|
||||
"\t,add_item \n" +
|
||||
"\t,total_count \n" +
|
||||
"\t,total_amount \n" +
|
||||
"\t,record_date \n" +
|
||||
"\t,report_type \n" +
|
||||
"\t,tenant_id \n" +
|
||||
"\t,create_by \n" +
|
||||
"\t,create_dept \n" +
|
||||
"\t,create_time \n" +
|
||||
"\t,update_by \n" +
|
||||
"\t,update_time) \n" +
|
||||
"\tSELECT \n" +
|
||||
"\te.dept_name AS branch_name \n" +
|
||||
"\t,e.dept_category AS branch_id \n" +
|
||||
"\t,b.nick_name AS marketer_name \n" +
|
||||
"\t,b.id_card AS marketer_id_card \n" +
|
||||
"\t,b.mkt_no AS marketer_code \n" +
|
||||
"\t,'' \n" +
|
||||
"\t,SUM(zhi_e_individual_count) \n" +
|
||||
"\t,SUM(zhi_e_individual_amount) \n" +
|
||||
"\t,SUM(zhi_e_inactive_count) \n" +
|
||||
"\t,SUM(zhi_e_inactive_amount) \n" +
|
||||
"\t,SUM(zhi_e_enterprise_count) \n" +
|
||||
"\t,SUM(zhi_e_enterprise_amount) \n" +
|
||||
"\t,SUM(corporate_mobile_bank_count) \n" +
|
||||
"\t,SUM(corporate_mobile_bank_amount) \n" +
|
||||
"\t,SUM(new_merchant_first_month_count) \n" +
|
||||
"\t,SUM(new_merchant_first_month_amount) \n" +
|
||||
"\t,SUM(new_merchant_retention_quarter_count) \n" +
|
||||
"\t,SUM(new_merchant_retention_quarter_amount) \n" +
|
||||
"\t,SUM(existing_merchant_retention_count) \n" +
|
||||
"\t,SUM(existing_merchant_retention_amount) \n" +
|
||||
"\t,SUM(online_payment_count) \n" +
|
||||
"\t,SUM(online_payment_amount) \n" +
|
||||
"\t,SUM(magnetic_to_ic_card_count) \n" +
|
||||
"\t,SUM(magnetic_to_ic_card_amount) \n" +
|
||||
"\t,SUM(new_bank_card_count) \n" +
|
||||
"\t,SUM(new_bank_card_amount) \n" +
|
||||
"\t,SUM(new_social_card_count) \n" +
|
||||
"\t,SUM(new_social_card_amount) \n" +
|
||||
"\t,SUM(loan_customer_social_card_count) \n" +
|
||||
"\t,SUM(loan_customer_social_card_amount) \n" +
|
||||
"\t,SUM(employee_social_card_count) \n" +
|
||||
"\t,SUM(employee_social_card_amount) \n" +
|
||||
"\t,SUM(activated_social_card_count) \n" +
|
||||
"\t,SUM(activated_social_card_amount) \n" +
|
||||
"\t,SUM(e_social_card_count) \n" +
|
||||
"\t,SUM(e_social_card_amount) \n" +
|
||||
"\t,SUM(medical_e_voucher_count) \n" +
|
||||
"\t,SUM(medical_e_voucher_amount) \n" +
|
||||
"\t,SUM(zhi_e_pay_count) \n" +
|
||||
"\t,SUM(zhi_e_pay_amount) \n" +
|
||||
"\t,SUM(huinong_farmer_count) \n" +
|
||||
"\t,SUM(huinong_farmer_amount) \n" +
|
||||
"\t,SUM(huinong_buyer_count) \n" +
|
||||
"\t,SUM(huinong_buyer_amount) \n" +
|
||||
"\t,SUM(water_fee_collection_count) \n" +
|
||||
"\t,SUM(water_fee_collection_amount) \n" +
|
||||
"\t,SUM(heat_fee_collection_count) \n" +
|
||||
"\t,SUM(heat_fee_collection_amount) \n" +
|
||||
"\t,SUM(electricity_fee_collection_count) \n" +
|
||||
"\t,SUM(electricity_fee_collection_amount) \n" +
|
||||
"\t,SUM(traffic_fine_collection_count) \n" +
|
||||
"\t,SUM(traffic_fine_collection_amount) \n" +
|
||||
"\t,SUM(new_party_fee_unit_count) \n" +
|
||||
"\t,SUM(new_party_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_union_fee_unit_count) \n" +
|
||||
"\t,SUM(new_union_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_property_fee_unit_count) \n" +
|
||||
"\t,SUM(new_property_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_meal_fee_unit_count) \n" +
|
||||
"\t,SUM(new_meal_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_foreign_account_count) \n" +
|
||||
"\t,SUM(new_foreign_account_amount) \n" +
|
||||
"\t,SUM(new_personal_wealth_count) \n" +
|
||||
"\t,SUM(new_personal_wealth_amount) \n" +
|
||||
"\t,SUM(new_corporate_wealth_count) \n" +
|
||||
"\t,SUM(new_corporate_wealth_amount) \n" +
|
||||
"\t,SUM(wealth_sales_count) \n" +
|
||||
"\t,SUM(wealth_sales_amount) \n" +
|
||||
"\t,SUM(fixed_term_wealth_count) \n" +
|
||||
"\t,SUM(fixed_term_wealth_amount) \n" +
|
||||
"\t,SUM(new_housing_fund_customer_count) \n" +
|
||||
"\t,SUM(new_housing_fund_customer_amount) \n" +
|
||||
"\t,SUM(housing_fund_customer_count) \n" +
|
||||
"\t,SUM(housing_fund_customer_amount) \n" +
|
||||
"\t,SUM(add_item) \n" +
|
||||
"\t,SUM(total_count) \n" +
|
||||
"\t,SUM(total_amount) \n" +
|
||||
"\t,? AS record_date \n" +
|
||||
"\t,'m' AS report_type \n" +
|
||||
"\t,b.tenant_id AS tenant_id \n" +
|
||||
"\t,null AS create_by \n" +
|
||||
"\t,b.dept_id AS create_dept \n" +
|
||||
"\t,? AS create_time \n" +
|
||||
"\t,null AS update_by \n" +
|
||||
"\t,null AS update_time \n" +
|
||||
"from marketing_performance_m_d d \n" +
|
||||
"left join sys_user b on b.mkt_no=d.marketer_code \n" +
|
||||
"LEFT JOIN sys_dept e ON b.dept_id = e.dept_id \n" +
|
||||
"where \n" +
|
||||
"\tb.del_flag = '0' \n" +
|
||||
"\tand d.record_date=?\n" +
|
||||
"group by \n" +
|
||||
"\te.dept_name \n" +
|
||||
"\t,e.dept_category \n" +
|
||||
"\t,b.nick_name \n" +
|
||||
"\t,b.id_card \n" +
|
||||
"\t,b.mkt_no \n" +
|
||||
"\t,b.tenant_id \n" +
|
||||
"\t,b.dept_id ";
|
||||
|
||||
Timestamp now = Timestamp.valueOf(LocalDateTime.now());
|
||||
String nowDate = now.toString();
|
||||
return executeParameterizedSql(connection, sql, batchMonth, nowDate, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取手工录入的计价信息
|
||||
*/
|
||||
private int updateShouGongJiJia(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "UPDATE marketing_performance_m mp \n" +
|
||||
"JOIN ( \n" +
|
||||
" select \n" +
|
||||
" branch \n" +
|
||||
" ,idcard_no \n" +
|
||||
" ,name \n" +
|
||||
" ,marketing_code as marketer_code \n" +
|
||||
" ,import_time as record_date \n" +
|
||||
" ,merchant_retention_rate \n" +
|
||||
" ,new_party_fee_units \n" +
|
||||
" ,new_union_fee_units \n" +
|
||||
" ,new_property_fee_units \n" +
|
||||
" ,new_catering_fee_units \n" +
|
||||
" ,new_foreign_accounts \n" +
|
||||
" ,new_individual_treasury \n" +
|
||||
" ,new_corporate_treasury \n" +
|
||||
" ,treasury_transactions \n" +
|
||||
" ,regular_products \n" +
|
||||
" ,new_housing_fund \n" +
|
||||
" from mps_manual_pricing \n" +
|
||||
" where import_time=? \n" +
|
||||
") AS source_data \n" +
|
||||
"ON \n" +
|
||||
//" mp.branch_id = source_data.branch_id \n" +
|
||||
" mp.marketer_code = source_data.marketer_code \n" +
|
||||
" AND mp.record_date = source_data.record_date \n" +
|
||||
"SET \n" +
|
||||
" mp.existing_merchant_retention_amount = source_data.merchant_retention_rate \n" +
|
||||
" ,mp.new_party_fee_unit_amount = source_data.new_party_fee_units \n" +
|
||||
" ,mp.new_union_fee_unit_amount = source_data.new_union_fee_units \n" +
|
||||
" ,mp.new_property_fee_unit_amount = source_data.new_property_fee_units \n" +
|
||||
" ,mp.new_meal_fee_unit_amount = source_data.new_catering_fee_units \n" +
|
||||
" ,mp.new_foreign_account_amount = source_data.new_foreign_accounts \n" +
|
||||
" ,mp.new_personal_wealth_amount = source_data.new_individual_treasury \n" +
|
||||
" ,mp.new_corporate_wealth_amount = source_data.new_corporate_treasury \n" +
|
||||
" ,mp.wealth_sales_amount = source_data.treasury_transactions \n" +
|
||||
" ,mp.fixed_term_wealth_amount = source_data.regular_products \n" +
|
||||
" ,mp.new_housing_fund_customer_amount = source_data.new_housing_fund \n" +
|
||||
"WHERE \n" +
|
||||
" mp.record_date = ? ";
|
||||
|
||||
return executeParameterizedSql(connection, sql, batchMonth, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新经办人员奖金
|
||||
*/
|
||||
private int updateTeShuJiJia(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "update marketing_performance_m a \n" +
|
||||
"set a.add_item=COALESCE(\n" +
|
||||
" ( select \n" +
|
||||
" sum(add_item) \n" +
|
||||
" from mps_emp_add_items b \n" +
|
||||
" where substr(b.record_month,1,7) = ? and a.marketer_code=b.marketing_code \n" +
|
||||
" group by b.marketing_code\n" +
|
||||
" )\n" +
|
||||
" ,0)\n" +
|
||||
"where a.record_date=? ";
|
||||
|
||||
return executeParameterizedSql(connection, sql, batchMonth, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新营销人员奖金
|
||||
*/
|
||||
private int updateToTalCntAmt(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "update marketing_performance_m \n" +
|
||||
"set \n" +
|
||||
"total_count=(\n" +
|
||||
" zhi_e_individual_count \n" +
|
||||
" + zhi_e_inactive_count \n" +
|
||||
" + zhi_e_enterprise_count \n" +
|
||||
" + corporate_mobile_bank_count \n" +
|
||||
" + new_merchant_first_month_count \n" +
|
||||
" + new_merchant_retention_quarter_count \n" +
|
||||
" + existing_merchant_retention_count \n" +
|
||||
" + online_payment_count \n" +
|
||||
" + magnetic_to_ic_card_count \n" +
|
||||
" + new_bank_card_count \n" +
|
||||
" + new_social_card_count \n" +
|
||||
" + loan_customer_social_card_count \n" +
|
||||
" + employee_social_card_count \n" +
|
||||
" + activated_social_card_count \n" +
|
||||
" + e_social_card_count \n" +
|
||||
" + medical_e_voucher_count \n" +
|
||||
" + zhi_e_pay_count \n" +
|
||||
" + huinong_farmer_count \n" +
|
||||
" + huinong_buyer_count \n" +
|
||||
" + water_fee_collection_count \n" +
|
||||
" + heat_fee_collection_count \n" +
|
||||
" + electricity_fee_collection_count \n" +
|
||||
" + traffic_fine_collection_count \n" +
|
||||
" + new_party_fee_unit_count \n" +
|
||||
" + new_union_fee_unit_count \n" +
|
||||
" + new_property_fee_unit_count \n" +
|
||||
" + new_meal_fee_unit_count \n" +
|
||||
" + new_foreign_account_count \n" +
|
||||
" + new_personal_wealth_count \n" +
|
||||
" + new_corporate_wealth_count \n" +
|
||||
" + wealth_sales_count \n" +
|
||||
" + fixed_term_wealth_count \n" +
|
||||
" + new_housing_fund_customer_count \n" +
|
||||
" + housing_fund_customer_count \n" +
|
||||
") \n" +
|
||||
",total_amount=\n" +
|
||||
"(\n" +
|
||||
" zhi_e_individual_amount \n" +
|
||||
" + zhi_e_inactive_amount \n" +
|
||||
" + zhi_e_enterprise_amount \n" +
|
||||
" + corporate_mobile_bank_amount \n" +
|
||||
" + new_merchant_first_month_amount \n" +
|
||||
" + new_merchant_retention_quarter_amount \n" +
|
||||
" + existing_merchant_retention_amount \n" +
|
||||
" + online_payment_amount \n" +
|
||||
" + magnetic_to_ic_card_amount \n" +
|
||||
" + new_bank_card_amount \n" +
|
||||
" + new_social_card_amount \n" +
|
||||
" + loan_customer_social_card_amount \n" +
|
||||
" + employee_social_card_amount \n" +
|
||||
" + activated_social_card_amount \n" +
|
||||
" + e_social_card_amount \n" +
|
||||
" + medical_e_voucher_amount \n" +
|
||||
" + zhi_e_pay_amount \n" +
|
||||
" + huinong_farmer_amount \n" +
|
||||
" + huinong_buyer_amount \n" +
|
||||
" + water_fee_collection_amount \n" +
|
||||
" + heat_fee_collection_amount \n" +
|
||||
" + electricity_fee_collection_amount \n" +
|
||||
" + traffic_fine_collection_amount \n" +
|
||||
" + new_party_fee_unit_amount \n" +
|
||||
" + new_union_fee_unit_amount \n" +
|
||||
" + new_property_fee_unit_amount \n" +
|
||||
" + new_meal_fee_unit_amount \n" +
|
||||
" + new_foreign_account_amount \n" +
|
||||
" + new_personal_wealth_amount \n" +
|
||||
" + new_corporate_wealth_amount \n" +
|
||||
" + wealth_sales_amount \n" +
|
||||
" + fixed_term_wealth_amount \n" +
|
||||
" + new_housing_fund_customer_amount \n" +
|
||||
" + housing_fund_customer_amount \n" +
|
||||
" + add_item\n" +
|
||||
") \n" +
|
||||
"where record_date=? ";
|
||||
|
||||
return executeParameterizedSql(connection, sql, batchMonth);
|
||||
}
|
||||
}
|
@ -0,0 +1,320 @@
|
||||
package com.gtsoft.mps.batch.processor.total;
|
||||
|
||||
import com.gtsoft.mps.batch.processor.AbstractBusinessProcessor;
|
||||
import com.gtsoft.mps.batch.util.DateUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 生成营销编号汇总的季度报表
|
||||
*
|
||||
* @author mps-batch
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MarketerQuarterTotalProcessor extends AbstractBusinessProcessor {
|
||||
|
||||
@Override
|
||||
public String getBusinessCode() {
|
||||
return "TOTAL003";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBusinessName() {
|
||||
return "营销编号汇总的季度报表处理";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doProcess(Connection connection, String batchMonth, ProcessResult result, String batchType) throws Exception {
|
||||
logger.info("开始生成营销编号汇总的季度报表,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
|
||||
int totalProcessedCount = 0;
|
||||
|
||||
try {
|
||||
|
||||
// 1. 确定季度范围
|
||||
QuarterRange quarterRange = getQuarterRange(batchMonth);
|
||||
logger.info("处理季度范围: {} 至 {}", quarterRange.startMonth, quarterRange.endMonth);
|
||||
|
||||
if (!batchMonth.equals(quarterRange.endMonth)) {
|
||||
logger.info("当前月份 {} 非季度末,季度报表不处理,程序退出", batchMonth);
|
||||
return;
|
||||
}
|
||||
|
||||
// 支持重跑,清理现有数据
|
||||
int deleteCount = deleteMarketingPerformanceQ(connection, batchMonth);
|
||||
logger.info("共删除员工汇总记录: {}", deleteCount);
|
||||
totalProcessedCount += deleteCount;
|
||||
|
||||
// 插入季度表
|
||||
int insertCount = insertMarketingPerformanceQ(connection, batchMonth, quarterRange);
|
||||
logger.info("共插入员工汇总记录: {}", insertCount);
|
||||
totalProcessedCount += insertCount;
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("处理过程中发生未知异常", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
result.setProcessedCount(totalProcessedCount);
|
||||
logger.info("生成营销编号汇总的季度报表处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持重跑,清理现有数据
|
||||
*/
|
||||
private int deleteMarketingPerformanceQ(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "delete from marketing_performance_q where record_date=?";
|
||||
return executeParameterizedSql(connection, sql, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入季度汇总结果表
|
||||
*/
|
||||
private int insertMarketingPerformanceQ(Connection connection, String batchMonth, QuarterRange quarterRange) throws SQLException {
|
||||
|
||||
// 获取季度标识,例如 2025Q3
|
||||
String quarterId = getQuarterIdentifier(quarterRange.startMonth);
|
||||
|
||||
String sql = "INSERT INTO marketing_performance_q ( \n" +
|
||||
"\tbranch_name \n" +
|
||||
"\t,branch_id \n" +
|
||||
"\t,marketer_name \n" +
|
||||
"\t,marketer_id_card \n" +
|
||||
"\t,marketer_code \n" +
|
||||
"\t,marketer_position \n" +
|
||||
"\t,zhi_e_individual_count \n" +
|
||||
"\t,zhi_e_individual_amount \n" +
|
||||
"\t,zhi_e_inactive_count \n" +
|
||||
"\t,zhi_e_inactive_amount \n" +
|
||||
"\t,zhi_e_enterprise_count \n" +
|
||||
"\t,zhi_e_enterprise_amount \n" +
|
||||
"\t,corporate_mobile_bank_count \n" +
|
||||
"\t,corporate_mobile_bank_amount \n" +
|
||||
"\t,new_merchant_first_month_count \n" +
|
||||
"\t,new_merchant_first_month_amount \n" +
|
||||
"\t,new_merchant_retention_quarter_count \n" +
|
||||
"\t,new_merchant_retention_quarter_amount \n" +
|
||||
"\t,existing_merchant_retention_count \n" +
|
||||
"\t,existing_merchant_retention_amount \n" +
|
||||
"\t,online_payment_count \n" +
|
||||
"\t,online_payment_amount \n" +
|
||||
"\t,magnetic_to_ic_card_count \n" +
|
||||
"\t,magnetic_to_ic_card_amount \n" +
|
||||
"\t,new_bank_card_count \n" +
|
||||
"\t,new_bank_card_amount \n" +
|
||||
"\t,new_social_card_count \n" +
|
||||
"\t,new_social_card_amount \n" +
|
||||
"\t,loan_customer_social_card_count \n" +
|
||||
"\t,loan_customer_social_card_amount \n" +
|
||||
"\t,employee_social_card_count \n" +
|
||||
"\t,employee_social_card_amount \n" +
|
||||
"\t,activated_social_card_count \n" +
|
||||
"\t,activated_social_card_amount \n" +
|
||||
"\t,e_social_card_count \n" +
|
||||
"\t,e_social_card_amount \n" +
|
||||
"\t,medical_e_voucher_count \n" +
|
||||
"\t,medical_e_voucher_amount \n" +
|
||||
"\t,zhi_e_pay_count \n" +
|
||||
"\t,zhi_e_pay_amount \n" +
|
||||
"\t,huinong_farmer_count \n" +
|
||||
"\t,huinong_farmer_amount \n" +
|
||||
"\t,huinong_buyer_count \n" +
|
||||
"\t,huinong_buyer_amount \n" +
|
||||
"\t,water_fee_collection_count \n" +
|
||||
"\t,water_fee_collection_amount \n" +
|
||||
"\t,heat_fee_collection_count \n" +
|
||||
"\t,heat_fee_collection_amount \n" +
|
||||
"\t,electricity_fee_collection_count \n" +
|
||||
"\t,electricity_fee_collection_amount \n" +
|
||||
"\t,traffic_fine_collection_count \n" +
|
||||
"\t,traffic_fine_collection_amount \n" +
|
||||
"\t,new_party_fee_unit_count \n" +
|
||||
"\t,new_party_fee_unit_amount \n" +
|
||||
"\t,new_union_fee_unit_count \n" +
|
||||
"\t,new_union_fee_unit_amount \n" +
|
||||
"\t,new_property_fee_unit_count \n" +
|
||||
"\t,new_property_fee_unit_amount \n" +
|
||||
"\t,new_meal_fee_unit_count \n" +
|
||||
"\t,new_meal_fee_unit_amount \n" +
|
||||
"\t,new_foreign_account_count \n" +
|
||||
"\t,new_foreign_account_amount \n" +
|
||||
"\t,new_personal_wealth_count \n" +
|
||||
"\t,new_personal_wealth_amount \n" +
|
||||
"\t,new_corporate_wealth_count \n" +
|
||||
"\t,new_corporate_wealth_amount \n" +
|
||||
"\t,wealth_sales_count \n" +
|
||||
"\t,wealth_sales_amount \n" +
|
||||
"\t,fixed_term_wealth_count \n" +
|
||||
"\t,fixed_term_wealth_amount \n" +
|
||||
"\t,new_housing_fund_customer_count \n" +
|
||||
"\t,new_housing_fund_customer_amount \n" +
|
||||
"\t,housing_fund_customer_count \n" +
|
||||
"\t,housing_fund_customer_amount \n" +
|
||||
"\t,add_item \n" +
|
||||
"\t,total_count \n" +
|
||||
"\t,total_amount \n" +
|
||||
"\t,record_date \n" +
|
||||
"\t,report_type \n" +
|
||||
"\t,tenant_id \n" +
|
||||
"\t,create_by \n" +
|
||||
"\t,create_dept \n" +
|
||||
"\t,create_time \n" +
|
||||
"\t,update_by \n" +
|
||||
"\t,update_time \n" +
|
||||
"\t,fill1 \n" +
|
||||
") \n" +
|
||||
"SELECT \n" +
|
||||
"\te.dept_name AS branch_name \n" +
|
||||
"\t,e.dept_category AS branch_id \n" +
|
||||
"\t,b.nick_name AS marketer_name \n" +
|
||||
"\t,b.id_card AS marketer_id_card \n" +
|
||||
"\t,b.mkt_no AS marketer_code \n" +
|
||||
"\t,'' \n" +
|
||||
"\t,SUM(zhi_e_individual_count) \n" +
|
||||
"\t,SUM(zhi_e_individual_amount) \n" +
|
||||
"\t,SUM(zhi_e_inactive_count) \n" +
|
||||
"\t,SUM(zhi_e_inactive_amount) \n" +
|
||||
"\t,SUM(zhi_e_enterprise_count) \n" +
|
||||
"\t,SUM(zhi_e_enterprise_amount) \n" +
|
||||
"\t,SUM(corporate_mobile_bank_count) \n" +
|
||||
"\t,SUM(corporate_mobile_bank_amount) \n" +
|
||||
"\t,SUM(new_merchant_first_month_count) \n" +
|
||||
"\t,SUM(new_merchant_first_month_amount) \n" +
|
||||
"\t,SUM(new_merchant_retention_quarter_count) \n" +
|
||||
"\t,SUM(new_merchant_retention_quarter_amount) \n" +
|
||||
"\t,SUM(existing_merchant_retention_count) \n" +
|
||||
"\t,SUM(existing_merchant_retention_amount) \n" +
|
||||
"\t,SUM(online_payment_count) \n" +
|
||||
"\t,SUM(online_payment_amount) \n" +
|
||||
"\t,SUM(magnetic_to_ic_card_count) \n" +
|
||||
"\t,SUM(magnetic_to_ic_card_amount) \n" +
|
||||
"\t,SUM(new_bank_card_count) \n" +
|
||||
"\t,SUM(new_bank_card_amount) \n" +
|
||||
"\t,SUM(new_social_card_count) \n" +
|
||||
"\t,SUM(new_social_card_amount) \n" +
|
||||
"\t,SUM(loan_customer_social_card_count) \n" +
|
||||
"\t,SUM(loan_customer_social_card_amount) \n" +
|
||||
"\t,SUM(employee_social_card_count) \n" +
|
||||
"\t,SUM(employee_social_card_amount) \n" +
|
||||
"\t,SUM(activated_social_card_count) \n" +
|
||||
"\t,SUM(activated_social_card_amount) \n" +
|
||||
"\t,SUM(e_social_card_count) \n" +
|
||||
"\t,SUM(e_social_card_amount) \n" +
|
||||
"\t,SUM(medical_e_voucher_count) \n" +
|
||||
"\t,SUM(medical_e_voucher_amount) \n" +
|
||||
"\t,SUM(zhi_e_pay_count) \n" +
|
||||
"\t,SUM(zhi_e_pay_amount) \n" +
|
||||
"\t,SUM(huinong_farmer_count) \n" +
|
||||
"\t,SUM(huinong_farmer_amount) \n" +
|
||||
"\t,SUM(huinong_buyer_count) \n" +
|
||||
"\t,SUM(huinong_buyer_amount) \n" +
|
||||
"\t,SUM(water_fee_collection_count) \n" +
|
||||
"\t,SUM(water_fee_collection_amount) \n" +
|
||||
"\t,SUM(heat_fee_collection_count) \n" +
|
||||
"\t,SUM(heat_fee_collection_amount) \n" +
|
||||
"\t,SUM(electricity_fee_collection_count) \n" +
|
||||
"\t,SUM(electricity_fee_collection_amount) \n" +
|
||||
"\t,SUM(traffic_fine_collection_count) \n" +
|
||||
"\t,SUM(traffic_fine_collection_amount) \n" +
|
||||
"\t,SUM(new_party_fee_unit_count) \n" +
|
||||
"\t,SUM(new_party_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_union_fee_unit_count) \n" +
|
||||
"\t,SUM(new_union_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_property_fee_unit_count) \n" +
|
||||
"\t,SUM(new_property_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_meal_fee_unit_count) \n" +
|
||||
"\t,SUM(new_meal_fee_unit_amount) \n" +
|
||||
"\t,SUM(new_foreign_account_count) \n" +
|
||||
"\t,SUM(new_foreign_account_amount) \n" +
|
||||
"\t,SUM(new_personal_wealth_count) \n" +
|
||||
"\t,SUM(new_personal_wealth_amount) \n" +
|
||||
"\t,SUM(new_corporate_wealth_count) \n" +
|
||||
"\t,SUM(new_corporate_wealth_amount) \n" +
|
||||
"\t,SUM(wealth_sales_count) \n" +
|
||||
"\t,SUM(wealth_sales_amount) \n" +
|
||||
"\t,SUM(fixed_term_wealth_count) \n" +
|
||||
"\t,SUM(fixed_term_wealth_amount) \n" +
|
||||
"\t,SUM(new_housing_fund_customer_count) \n" +
|
||||
"\t,SUM(new_housing_fund_customer_amount) \n" +
|
||||
"\t,SUM(housing_fund_customer_count) \n" +
|
||||
"\t,SUM(housing_fund_customer_amount) \n" +
|
||||
"\t,SUM(add_item) \n" +
|
||||
"\t,SUM(total_count) \n" +
|
||||
"\t,SUM(total_amount) \n" +
|
||||
"\t,? AS record_date \n" +
|
||||
"\t,'q' AS report_type \n" +
|
||||
"\t,b.tenant_id AS tenant_id \n" +
|
||||
"\t,null AS create_by \n" +
|
||||
"\t,b.dept_id AS create_dept \n" +
|
||||
"\t,? AS create_time \n" +
|
||||
"\t,null AS update_by \n" +
|
||||
"\t,null AS update_time \n" +
|
||||
"\t,? AS fill1 \n" +
|
||||
"from marketing_performance_m d \n" +
|
||||
"left join sys_user b on b.mkt_no=d.marketer_code \n" +
|
||||
"LEFT JOIN sys_dept e ON b.dept_id = e.dept_id \n" +
|
||||
"where \n" +
|
||||
"\tb.del_flag = '0' \n" +
|
||||
"\tand d.record_date>= ? and d.record_date<=?\n" +
|
||||
"group by \n" +
|
||||
"\te.dept_name \n" +
|
||||
"\t,e.dept_category \n" +
|
||||
"\t,b.nick_name \n" +
|
||||
"\t,b.id_card \n" +
|
||||
"\t,b.mkt_no \n" +
|
||||
"\t,b.tenant_id \n" +
|
||||
"\t,b.dept_id ";
|
||||
|
||||
Timestamp now = Timestamp.valueOf(LocalDateTime.now());
|
||||
String nowDate = now.toString();
|
||||
return executeParameterizedSql(connection, sql, batchMonth, nowDate, quarterId, quarterRange.startMonth, quarterRange.endMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定季度范围
|
||||
*/
|
||||
private QuarterRange getQuarterRange(String batchMonth) {
|
||||
try {
|
||||
// 获取季度第一天和最后一天
|
||||
String firstDay = DateUtils.getFirstDayOfCurrentQuarterYyyy_Mm_Dd();
|
||||
String lastDay = DateUtils.getLastDayOfCurrentQuarterYyyy_Mm_Dd();
|
||||
logger.info("当前季度初以及季度末: {} {}", firstDay, lastDay);
|
||||
|
||||
// 截取月份
|
||||
String startMonth = firstDay.substring(0, 7);
|
||||
String endMonth = lastDay.substring(0, 7);
|
||||
|
||||
return new QuarterRange(startMonth, endMonth);
|
||||
} catch (Exception e) {
|
||||
logger.error("确定季度范围时发生异常,batchMonth: {}", batchMonth, e);
|
||||
throw new RuntimeException("无法确定季度范围", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取季度标识
|
||||
*/
|
||||
private String getQuarterIdentifier(String startMonth) {
|
||||
int year = Integer.parseInt(startMonth.substring(0, 4));
|
||||
int month = Integer.parseInt(startMonth.substring(5, 7));
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
return year + "Q" + quarter;
|
||||
}
|
||||
|
||||
// 数据对象定义
|
||||
private static class QuarterRange {
|
||||
final String startMonth; // 格式: yyyy-MM
|
||||
final String endMonth; // 格式: yyyy-MM
|
||||
|
||||
QuarterRange(String startMonth, String endMonth) {
|
||||
this.startMonth = startMonth;
|
||||
this.endMonth = endMonth;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
package com.gtsoft.mps.batch.processor.total;
|
||||
|
||||
import com.gtsoft.mps.batch.processor.AbstractBusinessProcessor;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 处理手工计价金额和汇总计价金额
|
||||
*
|
||||
* @author mps-batch
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MarketerTotalProcessor extends AbstractBusinessProcessor {
|
||||
|
||||
@Override
|
||||
public String getBusinessCode() {
|
||||
return "TOTAL002";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBusinessName() {
|
||||
return "员工计价营销号汇总信息处理";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doProcess(Connection connection, String batchMonth, ProcessResult result, String batchType) throws Exception {
|
||||
logger.info("开始根据营销编号汇总计价信息,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
|
||||
int totalProcessedCount = 0;
|
||||
|
||||
try {
|
||||
// 按营销号汇总成一条记录
|
||||
int insertCount = insertMarketingPerformanceM(connection, batchMonth);
|
||||
logger.info("共插入员工汇总记录: {}", insertCount);
|
||||
totalProcessedCount += insertCount;
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("处理过程中发生未知异常", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
result.setProcessedCount(totalProcessedCount);
|
||||
logger.info("根据营销编号汇总计价信息处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新营销人员奖金
|
||||
*/
|
||||
private int insertMarketingPerformanceM(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "INSERT INTO marketing_performance_m ( " +
|
||||
" branch_name " +
|
||||
" ,branch_id " +
|
||||
" ,marketer_name " +
|
||||
" ,marketer_id_card " +
|
||||
" ,marketer_code " +
|
||||
" ,marketer_position " +
|
||||
" ,zhi_e_individual_count " +
|
||||
" ,zhi_e_individual_amount " +
|
||||
" ,zhi_e_inactive_count " +
|
||||
" ,zhi_e_inactive_amount " +
|
||||
" ,zhi_e_enterprise_count " +
|
||||
" ,zhi_e_enterprise_amount " +
|
||||
" ,corporate_mobile_bank_count " +
|
||||
" ,corporate_mobile_bank_amount " +
|
||||
" ,new_merchant_first_month_count " +
|
||||
" ,new_merchant_first_month_amount " +
|
||||
" ,new_merchant_retention_quarter_count " +
|
||||
" ,new_merchant_retention_quarter_amount " +
|
||||
" ,existing_merchant_retention_count " +
|
||||
" ,existing_merchant_retention_amount " +
|
||||
" ,online_payment_count " +
|
||||
" ,online_payment_amount " +
|
||||
" ,magnetic_to_ic_card_count " +
|
||||
" ,magnetic_to_ic_card_amount " +
|
||||
" ,new_bank_card_count " +
|
||||
" ,new_bank_card_amount " +
|
||||
" ,new_social_card_count " +
|
||||
" ,new_social_card_amount " +
|
||||
" ,loan_customer_social_card_count " +
|
||||
" ,loan_customer_social_card_amount " +
|
||||
" ,employee_social_card_count " +
|
||||
" ,employee_social_card_amount " +
|
||||
" ,activated_social_card_count " +
|
||||
" ,activated_social_card_amount " +
|
||||
" ,e_social_card_count " +
|
||||
" ,e_social_card_amount " +
|
||||
" ,medical_e_voucher_count " +
|
||||
" ,medical_e_voucher_amount " +
|
||||
" ,zhi_e_pay_count " +
|
||||
" ,zhi_e_pay_amount " +
|
||||
" ,huinong_farmer_count " +
|
||||
" ,huinong_farmer_amount " +
|
||||
" ,huinong_buyer_count " +
|
||||
" ,huinong_buyer_amount " +
|
||||
" ,water_fee_collection_count " +
|
||||
" ,water_fee_collection_amount " +
|
||||
" ,heat_fee_collection_count " +
|
||||
" ,heat_fee_collection_amount " +
|
||||
" ,electricity_fee_collection_count " +
|
||||
" ,electricity_fee_collection_amount " +
|
||||
" ,traffic_fine_collection_count " +
|
||||
" ,traffic_fine_collection_amount " +
|
||||
" ,new_party_fee_unit_count " +
|
||||
" ,new_party_fee_unit_amount " +
|
||||
" ,new_union_fee_unit_count " +
|
||||
" ,new_union_fee_unit_amount " +
|
||||
" ,new_property_fee_unit_count " +
|
||||
" ,new_property_fee_unit_amount " +
|
||||
" ,new_meal_fee_unit_count " +
|
||||
" ,new_meal_fee_unit_amount " +
|
||||
" ,new_foreign_account_count " +
|
||||
" ,new_foreign_account_amount " +
|
||||
" ,new_personal_wealth_count " +
|
||||
" ,new_personal_wealth_amount " +
|
||||
" ,new_corporate_wealth_count " +
|
||||
" ,new_corporate_wealth_amount " +
|
||||
" ,wealth_sales_count " +
|
||||
" ,wealth_sales_amount " +
|
||||
" ,fixed_term_wealth_count " +
|
||||
" ,fixed_term_wealth_amount " +
|
||||
" ,new_housing_fund_customer_count " +
|
||||
" ,new_housing_fund_customer_amount " +
|
||||
" ,housing_fund_customer_count " +
|
||||
" ,housing_fund_customer_amount " +
|
||||
" ,add_item " +
|
||||
" ,total_count " +
|
||||
" ,total_amount " +
|
||||
" ,record_date " +
|
||||
" ,report_type " +
|
||||
" ,tenant_id " +
|
||||
" ,create_by " +
|
||||
" ,create_dept " +
|
||||
" ,create_time " +
|
||||
" ,update_by " +
|
||||
" ,update_time) " +
|
||||
"SELECT " +
|
||||
" e.dept_name AS branch_name " +
|
||||
" ,e.dept_category AS branch_id " +
|
||||
" ,b.nick_name AS marketer_name " +
|
||||
" ,b.id_card AS marketer_id_card " +
|
||||
" ,b.mkt_no AS marketer_code " +
|
||||
" ,'' " +
|
||||
" ,SUM(zhi_e_individual_count) " +
|
||||
" ,SUM(zhi_e_individual_amount) " +
|
||||
" ,SUM(zhi_e_inactive_count) " +
|
||||
" ,SUM(zhi_e_inactive_amount) " +
|
||||
" ,SUM(zhi_e_enterprise_count) " +
|
||||
" ,SUM(zhi_e_enterprise_amount) " +
|
||||
" ,SUM(corporate_mobile_bank_count) " +
|
||||
" ,SUM(corporate_mobile_bank_amount) " +
|
||||
" ,SUM(new_merchant_first_month_count) " +
|
||||
" ,SUM(new_merchant_first_month_amount) " +
|
||||
" ,SUM(new_merchant_retention_quarter_count) " +
|
||||
" ,SUM(new_merchant_retention_quarter_amount) " +
|
||||
" ,SUM(existing_merchant_retention_count) " +
|
||||
" ,SUM(existing_merchant_retention_amount) " +
|
||||
" ,SUM(online_payment_count) " +
|
||||
" ,SUM(online_payment_amount) " +
|
||||
" ,SUM(magnetic_to_ic_card_count) " +
|
||||
" ,SUM(magnetic_to_ic_card_amount) " +
|
||||
" ,SUM(new_bank_card_count) " +
|
||||
" ,SUM(new_bank_card_amount) " +
|
||||
" ,SUM(new_social_card_count) " +
|
||||
" ,SUM(new_social_card_amount) " +
|
||||
" ,SUM(loan_customer_social_card_count) " +
|
||||
" ,SUM(loan_customer_social_card_amount) " +
|
||||
" ,SUM(employee_social_card_count) " +
|
||||
" ,SUM(employee_social_card_amount) " +
|
||||
" ,SUM(activated_social_card_count) " +
|
||||
" ,SUM(activated_social_card_amount) " +
|
||||
" ,SUM(e_social_card_count) " +
|
||||
" ,SUM(e_social_card_amount) " +
|
||||
" ,SUM(medical_e_voucher_count) " +
|
||||
" ,SUM(medical_e_voucher_amount) " +
|
||||
" ,SUM(zhi_e_pay_count) " +
|
||||
" ,SUM(zhi_e_pay_amount) " +
|
||||
" ,SUM(huinong_farmer_count) " +
|
||||
" ,SUM(huinong_farmer_amount) " +
|
||||
" ,SUM(huinong_buyer_count) " +
|
||||
" ,SUM(huinong_buyer_amount) " +
|
||||
" ,SUM(water_fee_collection_count) " +
|
||||
" ,SUM(water_fee_collection_amount) " +
|
||||
" ,SUM(heat_fee_collection_count) " +
|
||||
" ,SUM(heat_fee_collection_amount) " +
|
||||
" ,SUM(electricity_fee_collection_count) " +
|
||||
" ,SUM(electricity_fee_collection_amount) " +
|
||||
" ,SUM(traffic_fine_collection_count) " +
|
||||
" ,SUM(traffic_fine_collection_amount) " +
|
||||
" ,SUM(new_party_fee_unit_count) " +
|
||||
" ,SUM(new_party_fee_unit_amount) " +
|
||||
" ,SUM(new_union_fee_unit_count) " +
|
||||
" ,SUM(new_union_fee_unit_amount) " +
|
||||
" ,SUM(new_property_fee_unit_count) " +
|
||||
" ,SUM(new_property_fee_unit_amount) " +
|
||||
" ,SUM(new_meal_fee_unit_count) " +
|
||||
" ,SUM(new_meal_fee_unit_amount) " +
|
||||
" ,SUM(new_foreign_account_count) " +
|
||||
" ,SUM(new_foreign_account_amount) " +
|
||||
" ,SUM(new_personal_wealth_count) " +
|
||||
" ,SUM(new_personal_wealth_amount) " +
|
||||
" ,SUM(new_corporate_wealth_count) " +
|
||||
" ,SUM(new_corporate_wealth_amount) " +
|
||||
" ,SUM(wealth_sales_count) " +
|
||||
" ,SUM(wealth_sales_amount) " +
|
||||
" ,SUM(fixed_term_wealth_count) " +
|
||||
" ,SUM(fixed_term_wealth_amount) " +
|
||||
" ,SUM(new_housing_fund_customer_count) " +
|
||||
" ,SUM(new_housing_fund_customer_amount) " +
|
||||
" ,SUM(housing_fund_customer_count) " +
|
||||
" ,SUM(housing_fund_customer_amount) " +
|
||||
" ,SUM(add_item) " +
|
||||
" ,SUM(total_count) " +
|
||||
" ,SUM(total_amount) " +
|
||||
" ,? AS record_date " +
|
||||
" ,'m' AS report_type " +
|
||||
" ,b.tenant_id AS tenant_id " +
|
||||
" ,null AS create_by " +
|
||||
" ,b.dept_id AS create_dept " +
|
||||
" ,? AS create_time " +
|
||||
" ,null AS update_by " +
|
||||
" ,null AS update_time " +
|
||||
"from sys_user b " +
|
||||
"LEFT JOIN sys_dept e ON b.dept_id = e.dept_id " +
|
||||
"left join marketing_performance_m_d d on b.mkt_no=d.marketer_code " +
|
||||
"where " +
|
||||
" b.del_flag = '0' " +
|
||||
" and exists (select 1 from mps_market a where a.del_flag = '0' and substr(a.entry_date,1,7)=? and (a.jb_id = b.mkt_no or a.yx_id=b.mkt_no)) " +
|
||||
"group by " +
|
||||
" e.dept_name " +
|
||||
" ,e.dept_category " +
|
||||
" ,b.nick_name " +
|
||||
" ,b.id_card " +
|
||||
" ,b.mkt_no " +
|
||||
" ,b.tenant_id " +
|
||||
" ,b.dept_id ";
|
||||
|
||||
Timestamp now = Timestamp.valueOf(LocalDateTime.now());
|
||||
String nowDate = now.toString();
|
||||
return executeParameterizedSql(connection, sql, batchMonth, nowDate, batchMonth);
|
||||
}
|
||||
}
|
@ -0,0 +1,305 @@
|
||||
package com.gtsoft.mps.batch.processor.total;
|
||||
|
||||
import com.gtsoft.mps.batch.processor.AbstractBusinessProcessor;
|
||||
import com.gtsoft.mps.batch.util.DateUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 生成营销编号汇总的年报表
|
||||
*
|
||||
* @author mps-batch
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MarketerYearTotalProcessor extends AbstractBusinessProcessor {
|
||||
|
||||
@Override
|
||||
public String getBusinessCode() {
|
||||
return "TOTAL004";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBusinessName() {
|
||||
return "营销编号汇总的年报表处理";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doProcess(Connection connection, String batchMonth, ProcessResult result, String batchType) throws Exception {
|
||||
logger.info("开始生成营销编号汇总的年报表,月份: {},批量模式: {}", batchMonth, batchType);
|
||||
|
||||
int totalProcessedCount = 0;
|
||||
|
||||
try {
|
||||
|
||||
// 1. 确定年范围
|
||||
YearRange yearRange = getQuarterRange(batchMonth);
|
||||
logger.info("处理年范围: {} 至 {}", yearRange.startMonth, yearRange.endMonth);
|
||||
|
||||
if (!batchMonth.equals(yearRange.endMonth)) {
|
||||
logger.info("当前月份 {} 非年末,年报表不处理,程序退出", batchMonth);
|
||||
return;
|
||||
}
|
||||
|
||||
// 支持重跑,清理现有数据
|
||||
int deleteCount = deleteMarketingPerformanceQ(connection, batchMonth);
|
||||
logger.info("共删除员工汇总记录: {}", deleteCount);
|
||||
totalProcessedCount += deleteCount;
|
||||
|
||||
// 插入年表
|
||||
int insertCount = insertMarketingPerformanceY(connection, batchMonth, yearRange);
|
||||
logger.info("共插入员工汇总记录: {}", insertCount);
|
||||
totalProcessedCount += insertCount;
|
||||
|
||||
} catch (SQLException e) {
|
||||
logger.error("处理过程中发生SQL异常", e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("处理过程中发生未知异常", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
result.setProcessedCount(totalProcessedCount);
|
||||
logger.info("生成营销编号汇总的年报表处理完成,总处理记录数: {}", totalProcessedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持重跑,清理现有数据
|
||||
*/
|
||||
private int deleteMarketingPerformanceQ(Connection connection, String batchMonth) throws SQLException {
|
||||
String sql = "delete from marketing_performance_y where record_date=?";
|
||||
return executeParameterizedSql(connection, sql, batchMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入年汇总结果表
|
||||
*/
|
||||
private int insertMarketingPerformanceY(Connection connection, String batchMonth, YearRange yearRange) throws SQLException {
|
||||
String sql = "INSERT INTO marketing_performance_y ( \n" +
|
||||
"\t branch_name \n" +
|
||||
"\t ,branch_id \n" +
|
||||
"\t ,marketer_name \n" +
|
||||
"\t ,marketer_id_card \n" +
|
||||
"\t ,marketer_code \n" +
|
||||
"\t ,marketer_position \n" +
|
||||
"\t ,zhi_e_individual_count \n" +
|
||||
"\t ,zhi_e_individual_amount \n" +
|
||||
"\t ,zhi_e_inactive_count \n" +
|
||||
"\t ,zhi_e_inactive_amount \n" +
|
||||
"\t ,zhi_e_enterprise_count \n" +
|
||||
"\t ,zhi_e_enterprise_amount \n" +
|
||||
"\t ,corporate_mobile_bank_count \n" +
|
||||
"\t ,corporate_mobile_bank_amount \n" +
|
||||
"\t ,new_merchant_first_month_count \n" +
|
||||
"\t ,new_merchant_first_month_amount \n" +
|
||||
"\t ,new_merchant_retention_quarter_count \n" +
|
||||
"\t ,new_merchant_retention_quarter_amount \n" +
|
||||
"\t ,existing_merchant_retention_count \n" +
|
||||
"\t ,existing_merchant_retention_amount \n" +
|
||||
"\t ,online_payment_count \n" +
|
||||
"\t ,online_payment_amount \n" +
|
||||
"\t ,magnetic_to_ic_card_count \n" +
|
||||
"\t ,magnetic_to_ic_card_amount \n" +
|
||||
"\t ,new_bank_card_count \n" +
|
||||
"\t ,new_bank_card_amount \n" +
|
||||
"\t ,new_social_card_count \n" +
|
||||
"\t ,new_social_card_amount \n" +
|
||||
"\t ,loan_customer_social_card_count \n" +
|
||||
"\t ,loan_customer_social_card_amount \n" +
|
||||
"\t ,employee_social_card_count \n" +
|
||||
"\t ,employee_social_card_amount \n" +
|
||||
"\t ,activated_social_card_count \n" +
|
||||
"\t ,activated_social_card_amount \n" +
|
||||
"\t ,e_social_card_count \n" +
|
||||
"\t ,e_social_card_amount \n" +
|
||||
"\t ,medical_e_voucher_count \n" +
|
||||
"\t ,medical_e_voucher_amount \n" +
|
||||
"\t ,zhi_e_pay_count \n" +
|
||||
"\t ,zhi_e_pay_amount \n" +
|
||||
"\t ,huinong_farmer_count \n" +
|
||||
"\t ,huinong_farmer_amount \n" +
|
||||
"\t ,huinong_buyer_count \n" +
|
||||
"\t ,huinong_buyer_amount \n" +
|
||||
"\t ,water_fee_collection_count \n" +
|
||||
"\t ,water_fee_collection_amount \n" +
|
||||
"\t ,heat_fee_collection_count \n" +
|
||||
"\t ,heat_fee_collection_amount \n" +
|
||||
"\t ,electricity_fee_collection_count \n" +
|
||||
"\t ,electricity_fee_collection_amount \n" +
|
||||
"\t ,traffic_fine_collection_count \n" +
|
||||
"\t ,traffic_fine_collection_amount \n" +
|
||||
"\t ,new_party_fee_unit_count \n" +
|
||||
"\t ,new_party_fee_unit_amount \n" +
|
||||
"\t ,new_union_fee_unit_count \n" +
|
||||
"\t ,new_union_fee_unit_amount \n" +
|
||||
"\t ,new_property_fee_unit_count \n" +
|
||||
"\t ,new_property_fee_unit_amount \n" +
|
||||
"\t ,new_meal_fee_unit_count \n" +
|
||||
"\t ,new_meal_fee_unit_amount \n" +
|
||||
"\t ,new_foreign_account_count \n" +
|
||||
"\t ,new_foreign_account_amount \n" +
|
||||
"\t ,new_personal_wealth_count \n" +
|
||||
"\t ,new_personal_wealth_amount \n" +
|
||||
"\t ,new_corporate_wealth_count \n" +
|
||||
"\t ,new_corporate_wealth_amount \n" +
|
||||
"\t ,wealth_sales_count \n" +
|
||||
"\t ,wealth_sales_amount \n" +
|
||||
"\t ,fixed_term_wealth_count \n" +
|
||||
"\t ,fixed_term_wealth_amount \n" +
|
||||
"\t ,new_housing_fund_customer_count \n" +
|
||||
"\t ,new_housing_fund_customer_amount \n" +
|
||||
"\t ,housing_fund_customer_count \n" +
|
||||
"\t ,housing_fund_customer_amount \n" +
|
||||
"\t ,add_item \n" +
|
||||
"\t ,total_count \n" +
|
||||
"\t ,total_amount \n" +
|
||||
"\t ,record_date \n" +
|
||||
"\t ,report_type \n" +
|
||||
"\t ,tenant_id \n" +
|
||||
"\t ,create_by \n" +
|
||||
"\t ,create_dept \n" +
|
||||
"\t ,create_time \n" +
|
||||
"\t ,update_by \n" +
|
||||
"\t ,update_time \n" +
|
||||
"\t ,fill1) \n" +
|
||||
"SELECT \n" +
|
||||
"\t e.dept_name AS branch_name \n" +
|
||||
"\t ,e.dept_category AS branch_id \n" +
|
||||
"\t ,b.nick_name AS marketer_name \n" +
|
||||
"\t ,b.id_card AS marketer_id_card \n" +
|
||||
"\t ,b.mkt_no AS marketer_code \n" +
|
||||
"\t ,'' \n" +
|
||||
"\t ,SUM(zhi_e_individual_count) \n" +
|
||||
"\t ,SUM(zhi_e_individual_amount) \n" +
|
||||
"\t ,SUM(zhi_e_inactive_count) \n" +
|
||||
"\t ,SUM(zhi_e_inactive_amount) \n" +
|
||||
"\t ,SUM(zhi_e_enterprise_count) \n" +
|
||||
"\t ,SUM(zhi_e_enterprise_amount) \n" +
|
||||
"\t ,SUM(corporate_mobile_bank_count) \n" +
|
||||
"\t ,SUM(corporate_mobile_bank_amount) \n" +
|
||||
"\t ,SUM(new_merchant_first_month_count) \n" +
|
||||
"\t ,SUM(new_merchant_first_month_amount) \n" +
|
||||
"\t ,SUM(new_merchant_retention_quarter_count) \n" +
|
||||
"\t ,SUM(new_merchant_retention_quarter_amount) \n" +
|
||||
"\t ,SUM(existing_merchant_retention_count) \n" +
|
||||
"\t ,SUM(existing_merchant_retention_amount) \n" +
|
||||
"\t ,SUM(online_payment_count) \n" +
|
||||
"\t ,SUM(online_payment_amount) \n" +
|
||||
"\t ,SUM(magnetic_to_ic_card_count) \n" +
|
||||
"\t ,SUM(magnetic_to_ic_card_amount) \n" +
|
||||
"\t ,SUM(new_bank_card_count) \n" +
|
||||
"\t ,SUM(new_bank_card_amount) \n" +
|
||||
"\t ,SUM(new_social_card_count) \n" +
|
||||
"\t ,SUM(new_social_card_amount) \n" +
|
||||
"\t ,SUM(loan_customer_social_card_count) \n" +
|
||||
"\t ,SUM(loan_customer_social_card_amount) \n" +
|
||||
"\t ,SUM(employee_social_card_count) \n" +
|
||||
"\t ,SUM(employee_social_card_amount) \n" +
|
||||
"\t ,SUM(activated_social_card_count) \n" +
|
||||
"\t ,SUM(activated_social_card_amount) \n" +
|
||||
"\t ,SUM(e_social_card_count) \n" +
|
||||
"\t ,SUM(e_social_card_amount) \n" +
|
||||
"\t ,SUM(medical_e_voucher_count) \n" +
|
||||
"\t ,SUM(medical_e_voucher_amount) \n" +
|
||||
"\t ,SUM(zhi_e_pay_count) \n" +
|
||||
"\t ,SUM(zhi_e_pay_amount) \n" +
|
||||
"\t ,SUM(huinong_farmer_count) \n" +
|
||||
"\t ,SUM(huinong_farmer_amount) \n" +
|
||||
"\t ,SUM(huinong_buyer_count) \n" +
|
||||
"\t ,SUM(huinong_buyer_amount) \n" +
|
||||
"\t ,SUM(water_fee_collection_count) \n" +
|
||||
"\t ,SUM(water_fee_collection_amount) \n" +
|
||||
"\t ,SUM(heat_fee_collection_count) \n" +
|
||||
"\t ,SUM(heat_fee_collection_amount) \n" +
|
||||
"\t ,SUM(electricity_fee_collection_count) \n" +
|
||||
"\t ,SUM(electricity_fee_collection_amount) \n" +
|
||||
"\t ,SUM(traffic_fine_collection_count) \n" +
|
||||
"\t ,SUM(traffic_fine_collection_amount) \n" +
|
||||
"\t ,SUM(new_party_fee_unit_count) \n" +
|
||||
"\t ,SUM(new_party_fee_unit_amount) \n" +
|
||||
"\t ,SUM(new_union_fee_unit_count) \n" +
|
||||
"\t ,SUM(new_union_fee_unit_amount) \n" +
|
||||
"\t ,SUM(new_property_fee_unit_count) \n" +
|
||||
"\t ,SUM(new_property_fee_unit_amount) \n" +
|
||||
"\t ,SUM(new_meal_fee_unit_count) \n" +
|
||||
"\t ,SUM(new_meal_fee_unit_amount) \n" +
|
||||
"\t ,SUM(new_foreign_account_count) \n" +
|
||||
"\t ,SUM(new_foreign_account_amount) \n" +
|
||||
"\t ,SUM(new_personal_wealth_count) \n" +
|
||||
"\t ,SUM(new_personal_wealth_amount) \n" +
|
||||
"\t ,SUM(new_corporate_wealth_count) \n" +
|
||||
"\t ,SUM(new_corporate_wealth_amount) \n" +
|
||||
"\t ,SUM(wealth_sales_count) \n" +
|
||||
"\t ,SUM(wealth_sales_amount) \n" +
|
||||
"\t ,SUM(fixed_term_wealth_count) \n" +
|
||||
"\t ,SUM(fixed_term_wealth_amount) \n" +
|
||||
"\t ,SUM(new_housing_fund_customer_count) \n" +
|
||||
"\t ,SUM(new_housing_fund_customer_amount) \n" +
|
||||
"\t ,SUM(housing_fund_customer_count) \n" +
|
||||
"\t ,SUM(housing_fund_customer_amount) \n" +
|
||||
"\t ,SUM(add_item) \n" +
|
||||
"\t ,SUM(total_count) \n" +
|
||||
"\t ,SUM(total_amount) \n" +
|
||||
"\t ,? AS record_date \n" +
|
||||
"\t ,'y' AS report_type \n" +
|
||||
"\t ,b.tenant_id AS tenant_id \n" +
|
||||
"\t ,null AS create_by \n" +
|
||||
"\t ,b.dept_id AS create_dept \n" +
|
||||
"\t ,? AS create_time \n" +
|
||||
"\t ,null AS update_by \n" +
|
||||
"\t ,null AS update_time \n" +
|
||||
"\t ,? AS fill1 \n" +
|
||||
"from marketing_performance_m d \n" +
|
||||
"left join sys_user b on b.mkt_no=d.marketer_code \n" +
|
||||
"LEFT JOIN sys_dept e ON b.dept_id = e.dept_id \n" +
|
||||
"where \n" +
|
||||
"\tb.del_flag = '0' \n" +
|
||||
"\tand record_date>= ? and record_date<=?\n" +
|
||||
"group by \n" +
|
||||
"\t e.dept_name \n" +
|
||||
"\t,e.dept_category \n" +
|
||||
"\t,b.nick_name \n" +
|
||||
"\t,b.id_card \n" +
|
||||
"\t,b.mkt_no \n" +
|
||||
"\t,b.tenant_id \n" +
|
||||
"\t,b.dept_id ";
|
||||
|
||||
Timestamp now = Timestamp.valueOf(LocalDateTime.now());
|
||||
String nowDate = now.toString();
|
||||
return executeParameterizedSql(connection, sql, batchMonth, nowDate, batchMonth.substring(0,4), yearRange.startMonth, yearRange.endMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定年范围
|
||||
*/
|
||||
private YearRange getQuarterRange(String batchMonth) {
|
||||
try {
|
||||
// 获取年第一天和最后一天
|
||||
String firstDay = DateUtils.getFirstDayOfCurrentYearYyyy_Mm_Dd();
|
||||
String lastDay = DateUtils.getLastDayOfCurrentYearYyyy_Mm_Dd();
|
||||
logger.info("当前年初以及年末: {} {}", firstDay, lastDay);
|
||||
|
||||
// 截取月份
|
||||
String startMonth = firstDay.substring(0, 7);
|
||||
String endMonth = lastDay.substring(0, 7);
|
||||
|
||||
return new YearRange(startMonth, endMonth);
|
||||
} catch (Exception e) {
|
||||
logger.error("确定年范围时发生异常,batchMonth: {}", batchMonth, e);
|
||||
throw new RuntimeException("无法确定年范围", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 数据对象定义
|
||||
private static class YearRange {
|
||||
final String startMonth; // 格式: yyyy-MM
|
||||
final String endMonth; // 格式: yyyy-MM
|
||||
|
||||
YearRange(String startMonth, String endMonth) {
|
||||
this.startMonth = startMonth;
|
||||
this.endMonth = endMonth;
|
||||
}
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ public class BusinessControlService {
|
||||
try {
|
||||
connection = dbConnection.getConnection();
|
||||
String sql = "SELECT type_id, name, status FROM business_subcategory " +
|
||||
"WHERE status = '0' " +
|
||||
"WHERE status = '0' and entry_status='0' " +
|
||||
"ORDER BY type_id";
|
||||
|
||||
stmt = connection.prepareStatement(sql);
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user