| | |
| | | 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 {
|
| | |
| | | return extractAuditRecordMapper.getbyExtractId(extractId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CountUserInfo> getAuditCount(Date startTime, Date endTime, Integer state) throws Exception {
|
| | | // 重新查询统计今日以及空缺
|
| | | initAuditCount();
|
| | | |
| | | return countUserInfoDao.query(CountUserEnum.extractAuditNumber, startTime, endTime, state);
|
| | | }
|
| | |
|
| | | // 初始化统计
|
| | | @Override
|
| | | 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);
|
| | | public Long countAuditNumberByDay(int state, String preDay) {
|
| | | return extractAuditRecordMapper.countAuditTotal(state, preDay);
|
| | | }
|
| | |
|
| | | // 初始化统计
|
| | | |
| | | @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();
|
| | | }
|
| | | public BigDecimal countApplyMoneyByDay(String preDay) {
|
| | | return extractAuditRecordMapper.countApplyExtractMoney(preDay);
|
| | | }
|
| | |
|
| | | 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<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();
|
| | | }
|
| | | public Long countApplyNumberByDay(String preDay) {
|
| | | return extractAuditRecordMapper.countApplyNumberByDay(preDay);
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|