From ddf5db7d31af51fcf697eac0cee7dd46ff73bcc1 Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期二, 18 二月 2020 12:50:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractAuditRecordServiceImpl.java | 155 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 146 insertions(+), 9 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractAuditRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractAuditRecordServiceImpl.java index 1675640..ed54d0b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractAuditRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractAuditRecordServiceImpl.java @@ -1,24 +1,34 @@ package com.yeshi.fanli.service.impl.money.extract; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.yeshi.utils.DateUtil; import com.google.gson.Gson; import com.yeshi.fanli.dao.mybatis.ExtractAuditRecordMapper; +import com.yeshi.fanli.dao.user.count.CountUserInfoDao; import com.yeshi.fanli.dto.ChartTDO; import com.yeshi.fanli.dto.money.ExtractOrderStatisticDTO; +import com.yeshi.fanli.entity.admin.count.CountUserInfo; +import com.yeshi.fanli.entity.admin.count.CountUserInfo.CountUserEnum; import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord; import com.yeshi.fanli.service.inter.money.extract.ExtractAuditRecordService; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.TimeUtil; @Service public class ExtractAuditRecordServiceImpl implements ExtractAuditRecordService { @Resource private ExtractAuditRecordMapper extractAuditRecordMapper; + + @Resource + private CountUserInfoDao countUserInfoDao; @Override public List<ExtractAuditRecord> getList(int pageIndex, int pageSize, String key, String startTime, String endTime) { @@ -106,21 +116,148 @@ } @Override - public List<ChartTDO> countAuditTotal(Integer state, Integer type, String years, String startTime, - String endTime) throws Exception { - return extractAuditRecordMapper.countAuditTotal(state, type, years, startTime, endTime); + public List<CountUserInfo> getAuditCount(Date startTime, Date endTime, Integer state) throws Exception { + // 閲嶆柊鏌ヨ缁熻浠婃棩浠ュ強绌虹己 + initAuditCount(); + + return countUserInfoDao.query(CountUserEnum.extractAuditNumber, startTime, endTime, state); } + // 鍒濆鍖栫粺璁� @Override - public List<ChartTDO> countExtractApplyMoney(Integer state, Integer type, String years, String startTime, - String endTime) throws Exception { - return extractAuditRecordMapper.countExtractMoney(state, type, years, startTime, endTime); + public void initAuditCount() { + try { + CountUserInfo lastRecord = countUserInfoDao.getMaxDate(CountUserEnum.extractAuditNumber); + Date lastDay = null; + if (lastRecord != null && lastRecord.getDay() != null) { + lastDay = lastRecord.getDay(); + } + + if (lastDay == null) { + lastDay = TimeUtil.parse("2017-07-19"); + } + + Date today = new Date(); + int betweenDays = DateUtil.daysBetween2(lastDay, today); + if (betweenDays > 0) { + for (int i = 0; i <= betweenDays; i++ ) { + addRecordAuditCount(DateUtil.plusDay(i, lastDay)); + } + } + // 閲嶆柊缁熻浠婃棩 + addRecordAuditCount(TimeUtil.getGernalTime(today.getTime())); + } catch (Exception e) { + e.printStackTrace(); + } } + + private void addRecordAuditCount(String preDay) throws Exception{ + for (int i = 1; i < 3; i++) { + int count = extractAuditRecordMapper.countAuditTotal(i, preDay); + CountUserInfo record = new CountUserInfo(); + record.setState(i); + record.setNum(count); + record.setId(StringUtil.Md5(preDay + CountUserEnum.extractAuditNumber.name())+ "-" + i); + record.setDay(TimeUtil.parse(preDay)); + record.setType(CountUserEnum.extractAuditNumber); + countUserInfoDao.save(record); + } + } + + + @Override + public List<CountUserInfo> getApplyMoney(Date startTime, Date endTime) throws Exception { + // 閲嶆柊鏌ヨ缁熻浠婃棩浠ュ強绌虹己 + initApplyMoneyCount(); + + return countUserInfoDao.query(CountUserEnum.extractApplyMoney, startTime, endTime); + } + + // 鍒濆鍖栫粺璁� + @Override + public void initApplyMoneyCount() { + try { + CountUserInfo lastRecord = countUserInfoDao.getMaxDate(CountUserEnum.extractApplyMoney); + Date lastDay = null; + if (lastRecord != null && lastRecord.getDay() != null) { + lastDay = lastRecord.getDay(); + } + + if (lastDay == null) { + lastDay = TimeUtil.parse("2017-07-19"); + } + + Date today = new Date(); + int betweenDays = DateUtil.daysBetween2(lastDay, today); + if (betweenDays > 0) { + for (int i = 0; i <= betweenDays; i++ ) { + addRecordApplyMoneyCount(DateUtil.plusDay(i, lastDay)); + } + } + // 閲嶆柊缁熻浠婃棩 + addRecordApplyMoneyCount(TimeUtil.getGernalTime(today.getTime())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void addRecordApplyMoneyCount(String preDay) throws Exception{ + BigDecimal money = extractAuditRecordMapper.countApplyExtractMoney(preDay); + if (money == null) + money = new BigDecimal(0); + CountUserInfo record = new CountUserInfo(); + record.setMoney(money); + record.setId(StringUtil.Md5(preDay + CountUserEnum.extractApplyMoney.name())); + record.setDay(TimeUtil.parse(preDay)); + record.setType(CountUserEnum.extractApplyMoney); + countUserInfoDao.save(record); + } @Override - public List<ChartTDO> countExtractApplyNumber(Integer state, Integer type, String years, - String startTime, String endTime) throws Exception { - return extractAuditRecordMapper.countExtractApplyNumber(state, type, years, startTime, endTime); + public List<CountUserInfo> geApplyNumber(Date startTime, Date endTime) throws Exception { + // 閲嶆柊鏌ヨ缁熻浠婃棩浠ュ強绌虹己 + initApplyNumberCount(); + + return countUserInfoDao.query(CountUserEnum.extractApplyNumber, startTime, endTime); + } + + + // 鍒濆鍖栫粺璁� + @Override + public void initApplyNumberCount() { + try { + CountUserInfo lastRecord = countUserInfoDao.getMaxDate(CountUserEnum.extractApplyNumber); + Date lastDay = null; + if (lastRecord != null && lastRecord.getDay() != null) { + lastDay = lastRecord.getDay(); + } + + if (lastDay == null) { + lastDay = TimeUtil.parse("2017-07-19"); + } + + Date today = new Date(); + int betweenDays = DateUtil.daysBetween2(lastDay, today); + if (betweenDays > 0) { + for (int i = 0; i <= betweenDays; i++ ) { + addRecordCount(DateUtil.plusDay(i, lastDay)); + } + } + // 閲嶆柊缁熻浠婃棩 + addRecordCount(TimeUtil.getGernalTime(today.getTime())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void addRecordCount(String preDay) throws Exception{ + int count = extractAuditRecordMapper.countApplyNumberByDay(preDay); + CountUserInfo record = new CountUserInfo(); + record.setNum(count); + record.setId(StringUtil.Md5(preDay + CountUserEnum.extractApplyNumber.name())); + record.setDay(TimeUtil.parse(preDay)); + record.setType(CountUserEnum.extractApplyNumber); + countUserInfoDao.save(record); } } -- Gitblit v1.8.0