Commit c0a6bfc1 by yinyong

数据中心--同步财务系统利息支出

parent 73c2a9c9
...@@ -3,6 +3,7 @@ package com.bailuntec; ...@@ -3,6 +3,7 @@ package com.bailuntec;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.bailuntec.job.CashWithdrawDetail; import com.bailuntec.job.CashWithdrawDetail;
import com.bailuntec.job.CashierJob; import com.bailuntec.job.CashierJob;
import com.bailuntec.job.InterestJob;
import com.bailuntec.job.SalesPlatformJob; import com.bailuntec.job.SalesPlatformJob;
import com.bailuntec.listener.CashierJobListener; import com.bailuntec.listener.CashierJobListener;
import com.bailuntec.utils.PropertiesUtil; import com.bailuntec.utils.PropertiesUtil;
...@@ -30,6 +31,8 @@ public class Application { ...@@ -30,6 +31,8 @@ public class Application {
new JobScheduler(createRegistryCenter(), createJobConfiguration(),createJobEventConfiguration(), new CashierJobListener()).init(); new JobScheduler(createRegistryCenter(), createJobConfiguration(),createJobEventConfiguration(), new CashierJobListener()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration1(),createJobEventConfiguration()).init(); new JobScheduler(createRegistryCenter(), createJobConfiguration1(),createJobEventConfiguration()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration2(), createJobEventConfiguration()).init(); new JobScheduler(createRegistryCenter(), createJobConfiguration2(), createJobEventConfiguration()).init();
new JobScheduler(createRegistryCenter(), createJobConfiguration3(), createJobEventConfiguration()).init();
} }
private static CoordinatorRegistryCenter createRegistryCenter() { private static CoordinatorRegistryCenter createRegistryCenter() {
...@@ -59,6 +62,13 @@ public class Application { ...@@ -59,6 +62,13 @@ public class Application {
return simpleJobRootConfig; return simpleJobRootConfig;
} }
private static LiteJobConfiguration createJobConfiguration3() {
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder(propertiesUtil.getPropertyAsString("INTEREST_JOB_NAME"), propertiesUtil.getPropertyAsString("INTEREST_JOB_CRON"), propertiesUtil.getPropertyAsInt("SHARDING_TOTAL_COUNT")).build();
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, InterestJob.class.getCanonicalName());
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
private static JobEventConfiguration createJobEventConfiguration() { private static JobEventConfiguration createJobEventConfiguration() {
JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource()); JobEventConfiguration jobEventRdbConfig = new JobEventRdbConfiguration(setUpEventTraceDataSource());
return jobEventRdbConfig; return jobEventRdbConfig;
......
package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.bailuntec.domain.constant.CommonConstant;
import com.bailuntec.domain.entity.DcBaseFinanceInterest;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.example.DcBaseFinanceInterestExample;
import com.bailuntec.mapper.DcBaseFinanceInterestMapper;
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.lang3.StringUtils;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.List;
@Slf4j
public class InterestJob 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("startDate", DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT).format(jobPointLog.getStartTime()));
map.put("endDate", DateTimeFormatter.ofPattern(CommonConstant.DATE_FORMAT).format(jobPointLog.getEndTime()));
Response response = null;
String palResultStr = null;
try {
Request request = new Request.Builder()
.get()
.url(OkHttpUtil.attachHttpGetParams(propertiesUtil.getPropertyAsString("INTEREST_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<DcBaseFinanceInterest> dcBaseFinanceInterestList = JSON.parseObject(palResultStr, new TypeReference<List<DcBaseFinanceInterest>>(){});
if (dcBaseFinanceInterestList != null && dcBaseFinanceInterestList.size() > 0) {
DcBaseFinanceInterestMapper dcBaseFinanceInterestMapper = SessionUtil.getSession().getMapper(DcBaseFinanceInterestMapper.class);
dcBaseFinanceInterestMapper.deleteByExample(DcBaseFinanceInterestExample.newAndCreateCriteria().andActualRepayTimeBetween(LocalDateTime.of(jobPointLog.getStartTime().toLocalDate(), LocalTime.MIN), LocalDateTime.of(jobPointLog.getEndTime().toLocalDate(), LocalTime.MIN)).example());
for(DcBaseFinanceInterest dcBaseFinanceInterest : dcBaseFinanceInterestList) {
try {
dcBaseFinanceInterestMapper = SessionUtil.getSession().getMapper(DcBaseFinanceInterestMapper.class);
dcBaseFinanceInterestMapper.insertSelective(dcBaseFinanceInterest);
} catch (Exception e) {
log.warn("Mybatis 操作失败!", e);
throw new RuntimeException("MyBatis 操作失败!");
}finally {
SessionUtil.closeSession();
}
}
}
} 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()));
}
}
CASHIER_URL=http://cw.bailuntec.com/API/API/GetCashiers CASHIER_URL=http://cw.bailuntec.com/API/API/GetCashiers
WITHDRAW_DETAIL=http://cw.bailuntec.com/API/API/GetWithdrawDetailPages WITHDRAW_DETAIL=http://cw.bailuntec.com/API/API/GetWithdrawDetailPages
SALES_PLATFORM=http://www.bailuntec.com/api/PlatformSite/GetPlatform SALES_PLATFORM=http://www.bailuntec.com/api/PlatformSite/GetPlatform
INTEREST_URL=http://cw.bailuntec.com/api/api/GetRepayPlanDetails
...@@ -14,5 +14,7 @@ JOB_CRON=0/1 * * * * ? * ...@@ -14,5 +14,7 @@ JOB_CRON=0/1 * * * * ? *
WITHDRAW_JOB_NAME=base_sync-withdraw WITHDRAW_JOB_NAME=base_sync-withdraw
WITHDRAW_JOB_CRON=0/1 * * * * ? * WITHDRAW_JOB_CRON=0/1 * * * * ? *
SALESPLATFORM_JOB_NAME=base-sync-salesplatform SALESPLATFORM_JOB_NAME=base-sync-salesplatform
SALESPLATFORM_JOB_CRON=0 0 0 1,15 * ? * SALESPLATFORM_JOB_CRON=0 0 12 * * ? *
INTEREST_JOB_NAME=base-sync-interest
INTEREST_JOB_CRON=0 0 9,12 * * ? *
SHARDING_TOTAL_COUNT=1 SHARDING_TOTAL_COUNT=1
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.bailuntec; ...@@ -3,6 +3,7 @@ package com.bailuntec;
import com.bailuntec.domain.entity.JobPointLog; import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.job.CashWithdrawDetail; import com.bailuntec.job.CashWithdrawDetail;
import com.bailuntec.job.CashierJob; import com.bailuntec.job.CashierJob;
import com.bailuntec.job.InterestJob;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -24,4 +25,13 @@ public class CashierTest { ...@@ -24,4 +25,13 @@ public class CashierTest {
LocalDateTime.of(2019,10,05,0,0))); LocalDateTime.of(2019,10,05,0,0)));
} }
@Test
public void test2() {
InterestJob interestJob = new InterestJob();
JobPointLog jobPointLog = new JobPointLog();
jobPointLog.setStartTime(LocalDateTime.now());
jobPointLog.setEndTime(LocalDateTime.now());
interestJob.executeJob(null, jobPointLog);
}
} }
package com.bailuntec.domain.entity;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class DcBaseFinanceInterest {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.id
*
* @mbg.generated
*/
private Integer id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.company_val
*
* @mbg.generated
*/
private Integer companyVal;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.company
*
* @mbg.generated
*/
private String company;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.bank_card
*
* @mbg.generated
*/
private String bankCard;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.bank_card_user
*
* @mbg.generated
*/
private String bankCardUser;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.bank_name
*
* @mbg.generated
*/
private String bankName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.creditor
*
* @mbg.generated
*/
private String creditor;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.repay_interest
*
* @mbg.generated
*/
private BigDecimal repayInterest;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.repay_interest_rmb
*
* @mbg.generated
*/
private BigDecimal repayInterestRmb;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.actual_repay_time
*
* @mbg.generated
*/
private LocalDateTime actualRepayTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.gmt_create
*
* @mbg.generated
*/
private LocalDateTime gmtCreate;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_finance_interest.gmt_modify
*
* @mbg.generated
*/
private LocalDateTime gmtModify;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", companyVal=").append(companyVal);
sb.append(", company=").append(company);
sb.append(", bankCard=").append(bankCard);
sb.append(", bankCardUser=").append(bankCardUser);
sb.append(", bankName=").append(bankName);
sb.append(", creditor=").append(creditor);
sb.append(", repayInterest=").append(repayInterest);
sb.append(", repayInterestRmb=").append(repayInterestRmb);
sb.append(", actualRepayTime=").append(actualRepayTime);
sb.append(", gmtCreate=").append(gmtCreate);
sb.append(", gmtModify=").append(gmtModify);
sb.append("]");
return sb.toString();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
DcBaseFinanceInterest other = (DcBaseFinanceInterest) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getCompanyVal() == null ? other.getCompanyVal() == null : this.getCompanyVal().equals(other.getCompanyVal()))
&& (this.getCompany() == null ? other.getCompany() == null : this.getCompany().equals(other.getCompany()))
&& (this.getBankCard() == null ? other.getBankCard() == null : this.getBankCard().equals(other.getBankCard()))
&& (this.getBankCardUser() == null ? other.getBankCardUser() == null : this.getBankCardUser().equals(other.getBankCardUser()))
&& (this.getBankName() == null ? other.getBankName() == null : this.getBankName().equals(other.getBankName()))
&& (this.getCreditor() == null ? other.getCreditor() == null : this.getCreditor().equals(other.getCreditor()))
&& (this.getRepayInterest() == null ? other.getRepayInterest() == null : this.getRepayInterest().equals(other.getRepayInterest()))
&& (this.getRepayInterestRmb() == null ? other.getRepayInterestRmb() == null : this.getRepayInterestRmb().equals(other.getRepayInterestRmb()))
&& (this.getActualRepayTime() == null ? other.getActualRepayTime() == null : this.getActualRepayTime().equals(other.getActualRepayTime()))
&& (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
&& (this.getGmtModify() == null ? other.getGmtModify() == null : this.getGmtModify().equals(other.getGmtModify()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getCompanyVal() == null) ? 0 : getCompanyVal().hashCode());
result = prime * result + ((getCompany() == null) ? 0 : getCompany().hashCode());
result = prime * result + ((getBankCard() == null) ? 0 : getBankCard().hashCode());
result = prime * result + ((getBankCardUser() == null) ? 0 : getBankCardUser().hashCode());
result = prime * result + ((getBankName() == null) ? 0 : getBankName().hashCode());
result = prime * result + ((getCreditor() == null) ? 0 : getCreditor().hashCode());
result = prime * result + ((getRepayInterest() == null) ? 0 : getRepayInterest().hashCode());
result = prime * result + ((getRepayInterestRmb() == null) ? 0 : getRepayInterestRmb().hashCode());
result = prime * result + ((getActualRepayTime() == null) ? 0 : getActualRepayTime().hashCode());
result = prime * result + ((getGmtCreate() == null) ? 0 : getGmtCreate().hashCode());
result = prime * result + ((getGmtModify() == null) ? 0 : getGmtModify().hashCode());
return result;
}
}
\ No newline at end of file
package com.bailuntec.mapper;
import com.bailuntec.domain.entity.DcBaseFinanceInterest;
import com.bailuntec.domain.example.DcBaseFinanceInterestExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DcBaseFinanceInterestMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
long countByExample(DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int deleteByExample(DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int insert(DcBaseFinanceInterest record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int insertSelective(DcBaseFinanceInterest record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseFinanceInterest selectOneByExample(DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
List<DcBaseFinanceInterest> selectByExample(DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
DcBaseFinanceInterest selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") DcBaseFinanceInterest record, @Param("example") DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int updateByExample(@Param("record") DcBaseFinanceInterest record, @Param("example") DcBaseFinanceInterestExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(DcBaseFinanceInterest record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
*/
int updateByPrimaryKey(DcBaseFinanceInterest record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsert(DcBaseFinanceInterest record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_finance_interest
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcBaseFinanceInterest 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