Commit 58701b79 by yinyong

财务手续费数据拉取统计

parent 041c7d4a
package com.bailuntec;
import com.alibaba.druid.pool.DruidDataSource;
import com.bailuntec.job.CashWithdrawDetail;
import com.bailuntec.job.CashierJob;
import com.bailuntec.job.InterestJob;
import com.bailuntec.job.SalesPlatformJob;
import com.bailuntec.job.*;
import com.bailuntec.listener.CashierJobListener;
import com.bailuntec.utils.PropertiesUtil;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
......@@ -32,7 +29,7 @@ public class Application {
new JobScheduler(createRegistryCenter(), createJobConfiguration1(),createJobEventConfiguration()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration2(), createJobEventConfiguration()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration3(), createJobEventConfiguration()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration4(), createJobEventConfiguration()).init();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
......@@ -69,6 +66,13 @@ public class Application {
return simpleJobRootConfig;
}
private static LiteJobConfiguration createJobConfiguration4() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(propertiesUtil.getPropertyAsString("HANDLEFEE_JOB_NAME"), propertiesUtil.getPropertyAsString("HANDLEFEE_JOB_CRON"), propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, HandleFeeJob.class.getCanonicalName());
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static JobEventConfiguration createJobEventConfiguration() {
JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
return jobEventRdbConfig;
......
package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.bailuntec.domain.DcBaseFinanceHandlefeeInfo;
import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.entity.DcBaseFinanceHandlefee;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.mapper.DcBaseFinanceHandlefeeMapper;
import com.bailuntec.support.PointJob;
import com.bailuntec.utils.OkHttpUtil;
import com.bailuntec.utils.PropertiesUtil;
import com.bailuntec.utils.SessionUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.List;
@Slf4j
public class HandleFeeJob extends PointJob {
private OkHttpClient okHttpClient = OkHttpUtil.getInstance();
private PropertiesUtil propertiesUtil = PropertiesUtil.getInstance("const");
@Override
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
LinkedHashMap<String, String> map = new LinkedHashMap<>(4);
map.put("beginTime", DateTimeFormatter.ofPattern(CommonConstant.TIME_FORMAT).format(jobPointLog.getStartTime().minusHours(3L)));
map.put("endTime", DateTimeFormatter.ofPattern(CommonConstant.TIME_FORMAT).format(jobPointLog.getEndTime()));
Response response = null;
String palResultStr = null;
try {
Request request = new Request.Builder()
.get()
.url(OkHttpUtil.attachHttpGetParams(propertiesUtil.getPropertyAsString("HANDLEFEE_URL"), map))
.addHeader("Content-Type", "application/json")
.build();
response = okHttpClient.newCall(request).execute();
palResultStr = response.body().string();
} catch (IOException e) {
throw new RuntimeException(map + "请求财务手续费接口同步百伦接口失败" + response, e);
} finally {
if (response != null) {
response.close();
}
}
if (StringUtils.isNoneBlank(palResultStr)) {
List<DcBaseFinanceHandlefeeInfo> dcBaseFinanceHandlefeeInfoList = JSON.parseArray(palResultStr, DcBaseFinanceHandlefeeInfo.class);
if (dcBaseFinanceHandlefeeInfoList != null && dcBaseFinanceHandlefeeInfoList.size() > 0) {
DcBaseFinanceHandlefee dcBaseFinanceHandlefee = new DcBaseFinanceHandlefee();
for(DcBaseFinanceHandlefeeInfo dcBaseFinanceHandlefeeInfo : dcBaseFinanceHandlefeeInfoList) {
try {
DcBaseFinanceHandlefeeMapper dcBaseFinanceHandlefeeMapper = SessionUtil.getSession().getMapper(DcBaseFinanceHandlefeeMapper.class);
BeanUtils.copyProperties(dcBaseFinanceHandlefee, dcBaseFinanceHandlefeeInfo);
dcBaseFinanceHandlefeeMapper.upsertSelective(dcBaseFinanceHandlefee);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("BeanUtils.copyProperties失败");
}finally {
SessionUtil.closeSession();
}
}
} else {
log.warn("请求结果:" + palResultStr + "请求参数:" + map.toString());
}
} else {
throw new RuntimeException("调用财务手续费接口同步百伦流水失败, 响应为null, 请求参数" + map.toString());
}
jobPointLog.setPageIndex(0);
jobPointLog.setStartTime(jobPointLog.getEndTime());
jobPointLog.setEndTime(jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()).isAfter(LocalDateTime.now()) ? LocalDateTime.now() : jobPointLog.getEndTime().plusDays(jobPointLog.getIntervalTime()));
}
}
......@@ -2,4 +2,5 @@ CASHIER_URL=http://cw.bailuntec.com/API/API/GetCashiers
WITHDRAW_DETAIL=http://cw.bailuntec.com/API/API/GetWithdrawDetailPages
SALES_PLATFORM=http://www.bailuntec.com/api/PlatformSite/GetPlatform
INTEREST_URL=http://cw.bailuntec.com/api/api/GetRepayPlanDetails
HANDLEFEE_URL=http://cw.bailuntec.com/API/API/GetHandleFeeTradeRecords
......@@ -17,4 +17,6 @@ SALESPLATFORM_JOB_NAME=base-sync-salesplatform
SALESPLATFORM_JOB_CRON=0 0 12 * * ? *
INTEREST_JOB_NAME=base-sync-interest
INTEREST_JOB_CRON=0 0 9,12 * * ? *
HANDLEFEE_JOB_NAME=base-sync-handlefee
HANDLEFEE_JOB_CRON=0 0 0/2 * * ? *
SHARDING_TOTAL_COUNT=1
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcBaseFinanceHandlefee;
import com.bailuntec.domain.example.DcBaseFinanceHandlefeeExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseFinanceHandlefeeMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
long countByExample(DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int deleteByExample(DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int insert(DcBaseFinanceHandlefee record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int insertSelective(DcBaseFinanceHandlefee record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseFinanceHandlefee selectOneByExample(DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
List<DcBaseFinanceHandlefee> selectByExample(DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
DcBaseFinanceHandlefee selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcBaseFinanceHandlefee record, @Param("example") DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcBaseFinanceHandlefee record, @Param("example") DcBaseFinanceHandlefeeExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcBaseFinanceHandlefee record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
*/
int updateByPrimaryKey(DcBaseFinanceHandlefee record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcBaseFinanceHandlefee record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_handlefee
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcBaseFinanceHandlefee record);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment