|
|
@ -6,15 +6,17 @@ import com.epmet.dao.stats.user.*; |
|
|
|
import com.epmet.dto.stats.user.*; |
|
|
|
import com.epmet.dto.stats.user.result.UserStatisticalData; |
|
|
|
import com.epmet.service.stats.user.UserStatisticalService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description |
|
|
@ -22,10 +24,10 @@ import java.util.List; |
|
|
|
* @Auth wangc |
|
|
|
* @Date 2020-06-23 14:27 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class UserStatisticalServiceImpl implements UserStatisticalService { |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(UserStatisticalServiceImpl.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FactParticipationUserAgencyDailyDao participationUserAgencyDailyDao; |
|
|
@ -51,104 +53,225 @@ public class UserStatisticalServiceImpl implements UserStatisticalService { |
|
|
|
@Autowired |
|
|
|
private FactRegUserGridMonthlyDao regUserGridMonthlyDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ExecutorService executorService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertUniquely(UserStatisticalData data) { |
|
|
|
if (null == data) return ; |
|
|
|
if (null == data) { |
|
|
|
return; |
|
|
|
} |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
if (StringUtils.isBlank(data.getDateId()) || StringUtils.isBlank(data.getMonthId())) { |
|
|
|
log.error("缺失重要参数:dateId或monthId"); |
|
|
|
return; |
|
|
|
} |
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(8); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertParticipationUserAgencyDaily(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertParticipationUserAgencyDaily exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if(StringUtils.isBlank(data.getDateId()) || StringUtils.isBlank(data.getMonthId())){ |
|
|
|
logger.warn("缺失重要参数:dateId或monthId"); |
|
|
|
return ; |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertParticipationUserAgencyMonthly(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertParticipationUserAgencyMonthly exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if(null != data.getPartiAgencyDailyList() && data.getPartiAgencyDailyList().size() > NumConstant.ZERO){ |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = participationUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserAgencyDailyDTO>> partition = ListUtils.partition(data.getPartiAgencyDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
participationUserAgencyDailyDao.insertBatch(p); |
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertParticipationUserGridMonthly(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertParticipationUserGridMonthly exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertParticipationUserGridDaily(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertParticipationUserGridDaily exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertRegUserAgencyDaily(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertRegUserAgencyDaily exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertRegUserAgencyMonthly(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertRegUserAgencyMonthly exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertRegUserGridDaily(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertRegUserGridDaily exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
executorService.submit(() -> { |
|
|
|
try { |
|
|
|
insertRegUserGridMonthly(data); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("insertRegUserGridMonthly exception", e); |
|
|
|
} finally { |
|
|
|
countDownLatch.countDown(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
countDownLatch.getCount(); |
|
|
|
|
|
|
|
/* insertParticipationUserAgencyDaily(data); |
|
|
|
insertParticipationUserAgencyMonthly(data); |
|
|
|
insertParticipationUserGridMonthly(data); |
|
|
|
insertParticipationUserGridDaily(data); |
|
|
|
insertRegUserAgencyDaily(data); |
|
|
|
insertRegUserAgencyMonthly(data); |
|
|
|
insertRegUserGridDaily(data); |
|
|
|
insertRegUserGridMonthly(data);*/ |
|
|
|
|
|
|
|
log.warn("执行完毕======总耗时:{}ms",System.currentTimeMillis()-start); |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getPartiAgencyMonthlyList() && data.getPartiAgencyMonthlyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertRegUserGridMonthly(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getRegGridMonthlyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = participationUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserAgencyMonthlyDTO>> partition = ListUtils.partition(data.getPartiAgencyMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = regUserGridMonthlyDao.deleteByParams(data.getMonthId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserGridMonthlyDTO>> partition = ListUtils.partition(data.getRegGridMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
participationUserAgencyMonthlyDao.insertBatch(p); |
|
|
|
regUserGridMonthlyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getPartiGridMonthlyList() && data.getPartiGridMonthlyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertRegUserGridDaily(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getRegGridDailyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = participationUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserGridMonthlyDTO>> partition = ListUtils.partition(data.getPartiGridMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = regUserGridDailyDao.deleteByParams(data.getDateId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserGridDailyDTO>> partition = ListUtils.partition(data.getRegGridDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
participationUserGridMonthlyDao.insertBatch(p); |
|
|
|
regUserGridDailyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getPartiGridDailyList() && data.getPartiGridDailyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertRegUserAgencyMonthly(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getRegAgencyMonthlyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = participationUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserGridDailyDTO>> partition = ListUtils.partition(data.getPartiGridDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = regUserAgencyMonthlyDao.deleteByParams(data.getMonthId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserAgencyMonthlyDTO>> partition = ListUtils.partition(data.getRegAgencyMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
participationUserGridDailyDao.insertBatch(p); |
|
|
|
regUserAgencyMonthlyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getRegAgencyDailyList() && data.getRegAgencyDailyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertRegUserAgencyDaily(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getRegAgencyDailyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = regUserAgencyDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
delNum = regUserAgencyDailyDao.deleteByParams(data.getDateId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserAgencyDailyDTO>> partition = ListUtils.partition(data.getRegAgencyDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
regUserAgencyDailyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getRegAgencyMonthlyList() && data.getRegAgencyMonthlyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertParticipationUserGridDaily(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getPartiGridDailyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = regUserAgencyMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserAgencyMonthlyDTO>> partition = ListUtils.partition(data.getRegAgencyMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = participationUserGridDailyDao.deleteByParams(data.getDateId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserGridDailyDTO>> partition = ListUtils.partition(data.getPartiGridDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
regUserAgencyMonthlyDao.insertBatch(p); |
|
|
|
participationUserGridDailyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getRegGridDailyList() && data.getRegGridDailyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertParticipationUserGridMonthly(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getPartiGridMonthlyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = regUserGridDailyDao.deleteByParams(data.getDateId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserGridDailyDTO>> partition = ListUtils.partition(data.getRegGridDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = participationUserGridMonthlyDao.deleteByParams(data.getMonthId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserGridMonthlyDTO>> partition = ListUtils.partition(data.getPartiGridMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
regUserGridDailyDao.insertBatch(p); |
|
|
|
participationUserGridMonthlyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(null != data.getRegGridMonthlyList() && data.getRegGridMonthlyList().size() > NumConstant.ZERO){ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertParticipationUserAgencyMonthly(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getPartiAgencyMonthlyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = regUserGridMonthlyDao.deleteByParams(data.getMonthId(),data.getCustomerId()); |
|
|
|
}while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactRegUserGridMonthlyDTO>> partition = ListUtils.partition(data.getRegGridMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
delNum = participationUserAgencyMonthlyDao.deleteByParams(data.getMonthId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserAgencyMonthlyDTO>> partition = ListUtils.partition(data.getPartiAgencyMonthlyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
regUserGridMonthlyDao.insertBatch(p); |
|
|
|
participationUserAgencyMonthlyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void insertParticipationUserAgencyDaily(UserStatisticalData data) { |
|
|
|
if (CollectionUtils.isNotEmpty(data.getPartiAgencyDailyList())) { |
|
|
|
Integer delNum; |
|
|
|
do { |
|
|
|
delNum = participationUserAgencyDailyDao.deleteByParams(data.getDateId(), data.getCustomerId()); |
|
|
|
} while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); |
|
|
|
List<List<FactParticipationUserAgencyDailyDTO>> partition = ListUtils.partition(data.getPartiAgencyDailyList(), NumConstant.ONE_HUNDRED); |
|
|
|
partition.forEach(p -> { |
|
|
|
participationUserAgencyDailyDao.insertBatch(p); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|