diff --git a/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/CronCollectionServiceImpl.java b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/CronCollectionServiceImpl.java index 32c1c4d7..c92c11ad 100644 --- a/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/CronCollectionServiceImpl.java +++ b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/CronCollectionServiceImpl.java @@ -4,8 +4,10 @@ import static com.infincash.util.Jdk8DateUtils.dateSubstract; import static com.infincash.util.Jdk8DateUtils.getDateAfter; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +22,7 @@ import com.xxl.job.core.log.XxlJobLogger; public class CronCollectionServiceImpl implements CronCollectionService { @Autowired - TBizCollectionMapper recordMapper; + TBizCollectionMapper collectionMapper; @Autowired TBizCollectionOverdueBucketMapper bucketMapper; @@ -30,7 +32,7 @@ public class CronCollectionServiceImpl implements CronCollectionService { //90天以上的是坏账 String badDebtDay = getDateAfter(-90); - List rList = recordMapper.queryAll(badDebtDay); + List rList = collectionMapper.queryAll(badDebtDay); if (rList == null || rList.size() == 0) { throw new InfintechException("recordMapper.queryAll(badDebtDay) empty! badDebtDay: " + badDebtDay); @@ -40,7 +42,32 @@ public class CronCollectionServiceImpl implements CronCollectionService { throw new InfintechException("bucketMapper.queryAll() empty!"); } - getWhichBucket(bList, rList); + Map> map = getWhichBucket(bList, rList); + List resultList = Lists.newLinkedList(); + for (Entry> entry : map.entrySet()) + { + String key = entry.getKey(); + List> userList = collectionMapper.queryUserByRoleId(key); + if (userList == null || userList.size()==0 ) { + throw new InfintechException("collectionMapper.queryUserByRoleId(key) empty! key:" + key); + } + int cycle = userList.size(); + //FIXME 存量怎么办 + List list = entry.getValue(); + int a = 0; + for (TBizCollection s : list) { + Map tmpMap = userList.get(a%cycle); + String userId = (String) tmpMap.get("user_id"); + String userRealName = (String) tmpMap.get("real_name"); + s.setFkSystemUser(userId); + s.setCollectorLoginName(userRealName); + a++; + } + //拼接List + resultList.addAll(list); + } + collectionMapper.insertBatch(resultList); + } private Map> getWhichBucket(List bList, List rList) diff --git a/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionRecordMapper.java b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionMapper.java similarity index 65% rename from infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionRecordMapper.java rename to infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionMapper.java index ac2e805c..6894c9fd 100644 --- a/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionRecordMapper.java +++ b/infintech-executors/executor-collection-dispatcher/src/main/java/com/infincash/cron/collection/mapper/TBizCollectionMapper.java @@ -1,19 +1,16 @@ package com.infincash.cron.collection.mapper; import java.util.List; +import java.util.Map; import com.infincash.cron.collection.table.TBizCollection; public interface TBizCollectionMapper { List queryAll(String badDebtDay); - - int deleteByPrimaryKey(Long id); - - int insert(TBizCollection record); - int insertSelective(TBizCollection record); - - TBizCollection selectByPrimaryKey(Long id); + List> queryUserByRoleId(String roleId); + + int insertBatch(List record); int updateByPrimaryKeySelective(TBizCollection record); diff --git a/infintech-executors/executor-collection-dispatcher/src/main/resources/application.properties b/infintech-executors/executor-collection-dispatcher/src/main/resources/application.properties index 7f47a2c6..cbeb5538 100644 --- a/infintech-executors/executor-collection-dispatcher/src/main/resources/application.properties +++ b/infintech-executors/executor-collection-dispatcher/src/main/resources/application.properties @@ -1,9 +1,9 @@ -spring.datasource.prd.url=jdbc:mysql://172.16.16.98:3306/microfinance?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false +spring.datasource.prd.url=jdbc:mysql://47.74.188.197:3306/microfinance?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false spring.datasource.prd.username=jobopr spring.datasource.prd.password=jobopr666 spring.datasource.prd.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.stats.url=jdbc:mysql://172.16.16.99:3306/microfinance1?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false +spring.datasource.stats.url=jdbc:mysql://47.74.188.197:3306/microfinance1?autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false spring.datasource.stats.username=jobopr spring.datasource.stats.password=jobopr666 spring.datasource.stats.driver-class-name=com.mysql.jdbc.Driver diff --git a/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/CronCollectionMapper.xml b/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/CronCollectionMapper.xml deleted file mode 100644 index 94a813d1..00000000 --- a/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/CronCollectionMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/TBizCollectionRecordMapper.xml b/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/TBizCollectionRecordMapper.xml index cff12a83..470c3a97 100644 --- a/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/TBizCollectionRecordMapper.xml +++ b/infintech-executors/executor-collection-dispatcher/src/main/resources/mapping/prd/TBizCollectionRecordMapper.xml @@ -1,6 +1,6 @@ - + @@ -49,7 +49,8 @@ t1.unit, t1.first_price_loan, t2.repayment_date - from t_project t1 inner join t_project_refund t2 on t1.id=t2.project_id and t1.status in ('7') where t1.loan_time > #{_parameter} + from t_project t1 inner join t_project_refund t2 on t1.id=t2.project_id and t1.status in ('7') + where t1.loan_time > #{_parameter} ) t_biz inner join t_user t_u ON t_u.user_id = t_biz.user_id @@ -57,7 +58,14 @@ t_user_basis t_ub on t_ub.user_id=t_u.user_id; - + + + insert into t_biz_collection_record @@ -130,77 +138,80 @@ histry_collection_count, - + VALUES + + ( - #{id,jdbcType=BIGINT}, + #{oneItem.id,jdbcType=BIGINT}, - #{fkTProject,jdbcType=VARCHAR}, + #{oneItem.fkTProject,jdbcType=VARCHAR}, - #{fkTUser,jdbcType=VARCHAR}, + #{oneItem.fkTUser,jdbcType=VARCHAR}, - #{fkSystemUser,jdbcType=VARCHAR}, + #{oneItem.fkSystemUser,jdbcType=VARCHAR}, - #{waitOrRecord,jdbcType=TINYINT}, + #{oneItem.waitOrRecord,jdbcType=TINYINT}, - #{projectNumber,jdbcType=VARCHAR}, + #{oneItem.projectNumber,jdbcType=VARCHAR}, - #{userLoginName,jdbcType=VARCHAR}, + #{oneItem.userLoginName,jdbcType=VARCHAR}, - #{userRealName,jdbcType=VARCHAR}, + #{oneItem.userRealName,jdbcType=VARCHAR}, - #{userPhone,jdbcType=VARCHAR}, + #{oneItem.userPhone,jdbcType=VARCHAR}, - #{loanTime,jdbcType=TIMESTAMP}, + #{oneItem.loanTime,jdbcType=TIMESTAMP}, - #{projectPeriod,jdbcType=VARCHAR}, + #{oneItem.projectPeriod,jdbcType=VARCHAR}, - #{firstPriceLoan,jdbcType=DECIMAL}, + #{oneItem.firstPriceLoan,jdbcType=DECIMAL}, - #{repaymentDate,jdbcType=TIMESTAMP}, + #{oneItem.repaymentDate,jdbcType=TIMESTAMP}, - #{overdueDayCount,jdbcType=SMALLINT}, + #{oneItem.overdueDayCount,jdbcType=SMALLINT}, - #{fkTBizCollectionOverdueBucketIntervalId,jdbcType=SMALLINT}, + #{oneItem.fkTBizCollectionOverdueBucketIntervalId,jdbcType=SMALLINT}, - #{collectorLoginName,jdbcType=VARCHAR}, + #{oneItem.collectorLoginName,jdbcType=VARCHAR}, - #{updateTime,jdbcType=TIMESTAMP}, + #{oneItem.updateTime,jdbcType=TIMESTAMP}, - #{updateBy,jdbcType=VARCHAR}, + #{oneItem.updateBy,jdbcType=VARCHAR}, - #{state,jdbcType=TINYINT}, + #{oneItem.state,jdbcType=TINYINT}, - #{fullRepayDate,jdbcType=TIMESTAMP}, + #{oneItem.fullRepayDate,jdbcType=TIMESTAMP}, - #{lastCollectionTime,jdbcType=TIMESTAMP}, + #{oneItem.lastCollectionTime,jdbcType=TIMESTAMP}, - #{nextCollectionTime,jdbcType=TIMESTAMP}, + #{oneItem.nextCollectionTime,jdbcType=TIMESTAMP}, - #{histryCollectionCount,jdbcType=SMALLINT}, + #{oneItem.histryCollectionCount,jdbcType=SMALLINT}, - + ) +