|
|
|
@ -0,0 +1,418 @@
|
|
|
|
|
|
|
|
package com.nmgs.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
|
|
import com.nmgs.entity.Cafter;
|
|
|
|
|
|
|
|
import com.nmgs.entity.IntegralCheck;
|
|
|
|
|
|
|
|
import com.nmgs.entity.User;
|
|
|
|
|
|
|
|
import com.nmgs.mapper.petrol.CafterMapper;
|
|
|
|
|
|
|
|
import com.nmgs.mapper.petrol.IntegralCheckMapper;
|
|
|
|
|
|
|
|
import com.nmgs.mapper.petrol.PetrolMapper;
|
|
|
|
|
|
|
|
import com.nmgs.service.IAddService;
|
|
|
|
|
|
|
|
import com.nmgs.service.ICafterService;
|
|
|
|
|
|
|
|
import com.nmgs.service.ICheckService;
|
|
|
|
|
|
|
|
import com.nmgs.util.PropertiesUtil;
|
|
|
|
|
|
|
|
import org.apache.commons.codec.Charsets;
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFColor;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
|
|
@Transactional(timeout = 100)
|
|
|
|
|
|
|
|
public class CheckServiceImpl implements ICheckService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IntegralCheckMapper integralCheckMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Logger logger = LoggerFactory.getLogger(CheckServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Page<IntegralCheck> getCheckPage(Map<String, Object> params) {
|
|
|
|
|
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
|
|
|
|
|
params.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置分页
|
|
|
|
|
|
|
|
Integer pageNum = (Integer) params.get("pageNum");
|
|
|
|
|
|
|
|
Integer pageSize = (Integer) params.get("pageSize");
|
|
|
|
|
|
|
|
Page<IntegralCheck> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page = integralCheckMapper.getCheckPage(page, params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* ENABLEINTEGRATION int 0 0 0 0 0 0 截至今日0点,用户的总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* OGINTEGRATION int 0 0 0 0 0 0 截至今日0点,用户的可用加油加气总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* CPINTEGRATION int 0 0 0 0 0 0 截至今日0点,用户的可用餐饮商超总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* RESTINTEGRALTIONBEFORE int 0 0 -1 0 0 0 截至昨日0点,用户的总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* OGINTEGRATIONBEFORE int 0 0 -1 0 0 0 截至昨日0点,用户的可用加油加气总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* CPINTEGRATIONBEFORE int 0 0 -1 0 0 0 截至昨日0点,用户的可用餐饮商超总积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* RESTINTEGRALTIONDECODE int 0 0 -1 0 0 0 截至今日0点,昨天用户的总消费积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* OGINTEGRATIONDECODE int 0 0 -1 0 0 0 截至今日0点,昨天用户的总消费加油加气积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* CPINTEGRATIONDECODE int 0 0 -1 0 0 0 截至今日0点,昨天用户的总消费餐饮商超积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* OGINTEGRATIONADD int 0 0 -1 0 0 0 截至今日0点,昨天用户的总累计加油加气积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* CPINTEGRATIONADD int 0 0 -1 0 0 0 截至今日0点,昨天用户的总累计加油加气积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
* RESTTEGRALTIONADD int 0 0 -1 0 0 0 截至今日0点,昨天用户的总累计积分 0 0 0 0 0 0 0
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
//获取数据,判断用户积分是否正确,没有异常 01 0 23 2 45 4
|
|
|
|
|
|
|
|
List<IntegralCheck> records = page.getRecords();
|
|
|
|
|
|
|
|
List<IntegralCheck> newRecords = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0 ; i < records.size();i=i+2){
|
|
|
|
|
|
|
|
IntegralCheck integralCheckNew = new IntegralCheck();
|
|
|
|
|
|
|
|
IntegralCheck integralCheckBMP = records.get(i);
|
|
|
|
|
|
|
|
IntegralCheck integralCheckGSY = records.get(i+1);
|
|
|
|
|
|
|
|
integralCheckNew.setEnableintegration(integralCheckGSY.getEnableintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegration(integralCheckGSY.getOgintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegration(integralCheckGSY.getCpintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setRestintegraltionbefore(integralCheckGSY.getRestintegraltionbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationbefore(integralCheckGSY.getOgintegrationbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationbefore(integralCheckGSY.getCpintegrationbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setClassdate(integralCheckGSY.getClassdate());
|
|
|
|
|
|
|
|
integralCheckNew.setRestintegraltiondecode(integralCheckBMP.getRestintegraltiondecode());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationdecode(integralCheckBMP.getCpintegrationdecode());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationdecode(integralCheckBMP.getOgintegrationdecode());
|
|
|
|
|
|
|
|
integralCheckNew.setResttegraltionadd(integralCheckGSY.getResttegraltionadd());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationadd(integralCheckGSY.getOgintegrationadd());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationadd(integralCheckGSY.getCpintegrationadd());
|
|
|
|
|
|
|
|
integralCheckNew.setUserRealName(integralCheckGSY.getUserRealName());
|
|
|
|
|
|
|
|
integralCheckNew.setUserId(integralCheckGSY.getUserId());
|
|
|
|
|
|
|
|
integralCheckNew.setOpenid(integralCheckGSY.getOpenid());
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("Y");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//先判断剩余积分是否准确
|
|
|
|
|
|
|
|
if(integralCheckBMP.getEnableintegration().intValue() == integralCheckGSY.getEnableintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getOgintegration().intValue() == integralCheckGSY.getOgintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getCpintegration().intValue() == integralCheckGSY.getCpintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getRestintegraltionbefore().intValue() == integralCheckGSY.getRestintegraltionbefore().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getOgintegrationbefore().intValue() == integralCheckGSY.getOgintegrationbefore().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getCpintegrationbefore().intValue() == integralCheckGSY.getCpintegrationbefore().intValue()){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int OGFee = integralCheckBMP.getOgintegrationdecode().intValue();
|
|
|
|
|
|
|
|
int CPFee = integralCheckBMP.getCpintegrationdecode().intValue();
|
|
|
|
|
|
|
|
int OGAdd = integralCheckGSY.getOgintegrationadd().intValue();
|
|
|
|
|
|
|
|
int CPAdd = integralCheckGSY.getCpintegrationadd().intValue();
|
|
|
|
|
|
|
|
int feeTotal = (OGFee+CPFee);
|
|
|
|
|
|
|
|
int addTotal = (OGAdd+CPAdd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 加油加汽核销积分 + 餐饮商超核销积分 是否等于总核销积分
|
|
|
|
|
|
|
|
if(integralCheckNew.getRestintegraltiondecode().intValue() != feeTotal){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断 加油加汽增加积分 + 餐饮商超增加积分 是否等于总增加积分
|
|
|
|
|
|
|
|
if(integralCheckNew.getResttegraltionadd().intValue() != addTotal){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getRestintegraltionbefore().intValue()+feeTotal+addTotal) != integralCheckNew.getEnableintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getOgintegrationbefore().intValue()+OGFee+OGAdd) != integralCheckNew.getOgintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getCpintegrationbefore().intValue()+CPFee+CPAdd) != integralCheckNew.getCpintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(integralCheckNew.getEnableintegration().intValue() < 0 || integralCheckNew.getOgintegration().intValue() < 0 || integralCheckNew.getCpintegration().intValue() < 0){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newRecords.add(integralCheckNew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
page.setRecords(newRecords);
|
|
|
|
|
|
|
|
return page;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void exportCheckListExcle(String searchForm, HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
//设置金额的格式
|
|
|
|
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.00");
|
|
|
|
|
|
|
|
//设置导出文件名称
|
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
String filename = "积分检查表-" + simpleDateFormat.format(date) + ".xlsx";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果传进来的参数有值,拼接参数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null != searchForm && !"".equals(searchForm)) {
|
|
|
|
|
|
|
|
paramsMap = JSON.parseObject(searchForm, HashMap.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从配置文件中读取数据库连接类型
|
|
|
|
|
|
|
|
paramsMap.put("DBTYPE", PropertiesUtil.getValue("DBType"));
|
|
|
|
|
|
|
|
//设置分页
|
|
|
|
|
|
|
|
Integer pageNum = (Integer) paramsMap.get("pageNum");
|
|
|
|
|
|
|
|
Page<IntegralCheck> page = new Page<>(pageNum,100000);
|
|
|
|
|
|
|
|
page = integralCheckMapper.getCheckPage(page, paramsMap);
|
|
|
|
|
|
|
|
//获取数据,判断用户积分是否正确,没有异常 01 0 23 2 45 4
|
|
|
|
|
|
|
|
List<IntegralCheck> records = page.getRecords();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IntegralCheck> newRecords = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0 ; i < records.size();i=i+2){
|
|
|
|
|
|
|
|
IntegralCheck integralCheckNew = new IntegralCheck();
|
|
|
|
|
|
|
|
IntegralCheck integralCheckBMP = records.get(i);
|
|
|
|
|
|
|
|
IntegralCheck integralCheckGSY = records.get(i+1);
|
|
|
|
|
|
|
|
integralCheckNew.setEnableintegration(integralCheckGSY.getEnableintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegration(integralCheckGSY.getOgintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegration(integralCheckGSY.getCpintegration());
|
|
|
|
|
|
|
|
integralCheckNew.setRestintegraltionbefore(integralCheckGSY.getRestintegraltionbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationbefore(integralCheckGSY.getOgintegrationbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationbefore(integralCheckGSY.getCpintegrationbefore());
|
|
|
|
|
|
|
|
integralCheckNew.setClassdate(integralCheckGSY.getClassdate());
|
|
|
|
|
|
|
|
integralCheckNew.setRestintegraltiondecode(integralCheckBMP.getRestintegraltiondecode());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationdecode(integralCheckBMP.getCpintegrationdecode());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationdecode(integralCheckBMP.getOgintegrationdecode());
|
|
|
|
|
|
|
|
integralCheckNew.setResttegraltionadd(integralCheckGSY.getResttegraltionadd());
|
|
|
|
|
|
|
|
integralCheckNew.setOgintegrationadd(integralCheckGSY.getOgintegrationadd());
|
|
|
|
|
|
|
|
integralCheckNew.setCpintegrationadd(integralCheckGSY.getCpintegrationadd());
|
|
|
|
|
|
|
|
integralCheckNew.setUserRealName(integralCheckGSY.getUserRealName());
|
|
|
|
|
|
|
|
integralCheckNew.setUserId(integralCheckGSY.getUserId());
|
|
|
|
|
|
|
|
integralCheckNew.setOpenid(integralCheckGSY.getOpenid());
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("Y");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//先判断剩余积分是否准确
|
|
|
|
|
|
|
|
if(integralCheckBMP.getEnableintegration().intValue() == integralCheckGSY.getEnableintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getOgintegration().intValue() == integralCheckGSY.getOgintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getCpintegration().intValue() == integralCheckGSY.getCpintegration().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getRestintegraltionbefore().intValue() == integralCheckGSY.getRestintegraltionbefore().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getOgintegrationbefore().intValue() == integralCheckGSY.getOgintegrationbefore().intValue()
|
|
|
|
|
|
|
|
&& integralCheckBMP.getCpintegrationbefore().intValue() == integralCheckGSY.getCpintegrationbefore().intValue()){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int OGFee = integralCheckBMP.getOgintegrationdecode().intValue();
|
|
|
|
|
|
|
|
int CPFee = integralCheckBMP.getCpintegrationdecode().intValue();
|
|
|
|
|
|
|
|
int OGAdd = integralCheckGSY.getOgintegrationadd().intValue();
|
|
|
|
|
|
|
|
int CPAdd = integralCheckGSY.getCpintegrationadd().intValue();
|
|
|
|
|
|
|
|
int feeTotal = (OGFee+CPFee);
|
|
|
|
|
|
|
|
int addTotal = (OGAdd+CPAdd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 加油加汽核销积分 + 餐饮商超核销积分 是否等于总核销积分
|
|
|
|
|
|
|
|
if(integralCheckNew.getRestintegraltiondecode().intValue() != feeTotal){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断 加油加汽增加积分 + 餐饮商超增加积分 是否等于总增加积分
|
|
|
|
|
|
|
|
if(integralCheckNew.getResttegraltionadd().intValue() != addTotal){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getRestintegraltionbefore().intValue()+feeTotal+addTotal) != integralCheckNew.getEnableintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getOgintegrationbefore().intValue()+OGFee+OGAdd) != integralCheckNew.getOgintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断 前日剩余 累计 核销积分和增加积分后,是否等于昨日剩余积分情况
|
|
|
|
|
|
|
|
if((integralCheckNew.getCpintegrationbefore().intValue()+CPFee+CPAdd) != integralCheckNew.getCpintegration().intValue() ){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(integralCheckNew.getEnableintegration().intValue() < 0 || integralCheckNew.getOgintegration().intValue() < 0 || integralCheckNew.getCpintegration().intValue() < 0){
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
integralCheckNew.setIsRight("N");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newRecords.add(integralCheckNew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Collections.sort(newRecords, new Comparator<IntegralCheck>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int compare(IntegralCheck p1, IntegralCheck p2) {
|
|
|
|
|
|
|
|
return p1.getIsRight().compareTo(p2.getIsRight());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建一个Excel表格
|
|
|
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建sheet页面
|
|
|
|
|
|
|
|
Sheet sheet = wb.createSheet("积分检查");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null == newRecords) {
|
|
|
|
|
|
|
|
//导出Excel
|
|
|
|
|
|
|
|
writeToExcel(response, wb, filename);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定义一个标题数组
|
|
|
|
|
|
|
|
String[] title = {"积分状态", "用户","统计日期", "前日剩余可用积分", "昨日消费积分","昨日增加积分","昨日剩余可用积分", "前日加油加气剩余可用积分", "昨日加油加气消费积分","昨日加油加气增加积分","昨日加油加气剩余可用积分", "前日餐饮商超剩余可用积分", "昨日餐饮商超消费积分","昨日餐饮商超增加积分","昨日餐饮商超剩余可用积分"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置统计时间日期格式
|
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormatClassData = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormatDt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定义内容数据
|
|
|
|
|
|
|
|
List<String[]> rowValues = new ArrayList<>();
|
|
|
|
|
|
|
|
for (IntegralCheck check: newRecords) {
|
|
|
|
|
|
|
|
String[] rowValue = {
|
|
|
|
|
|
|
|
null == check.getIsRight()? "" : check.getIsRight().equals("Y")?"正常":"异常",
|
|
|
|
|
|
|
|
null == check.getUserRealName()? "" : check.getUserRealName(),
|
|
|
|
|
|
|
|
null == check.getClassdate()? "" : simpleDateFormatClassData.format(check.getClassdate()),
|
|
|
|
|
|
|
|
null == check.getRestintegraltionbefore()? "" : String.valueOf(check.getRestintegraltionbefore().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getRestintegraltiondecode()? "" : String.valueOf(check.getRestintegraltiondecode().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getResttegraltionadd()? "" : String.valueOf(check.getResttegraltionadd().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getEnableintegration()? "" : String.valueOf(check.getEnableintegration().intValue()/100.00),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
null == check.getOgintegrationbefore()? "" : String.valueOf(check.getOgintegrationbefore().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getOgintegrationdecode()? "" : String.valueOf(check.getOgintegrationdecode().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getOgintegrationadd()? "" : String.valueOf(check.getOgintegrationadd().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getOgintegration()? "" : String.valueOf(check.getOgintegration().intValue()/100.00),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
null == check.getCpintegrationbefore()? "" : String.valueOf(check.getCpintegrationbefore().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getCpintegrationdecode()? "" : String.valueOf(check.getCpintegrationdecode().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getCpintegrationadd()? "" : String.valueOf(check.getCpintegrationadd().intValue()/100.00),
|
|
|
|
|
|
|
|
null == check.getCpintegration()? "" : String.valueOf(check.getCpintegration().intValue()/100.00),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
rowValues.add(rowValue);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置标题单元格式
|
|
|
|
|
|
|
|
CellStyle cellStyleTitle = wb.createCellStyle();
|
|
|
|
|
|
|
|
cellStyleTitle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//设置背景色
|
|
|
|
|
|
|
|
cellStyleTitle.setFillPattern((short) 1);//必须设置 否则无效
|
|
|
|
|
|
|
|
//设置水平垂直居中
|
|
|
|
|
|
|
|
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
cellStyleTitle.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
// 设置边框样式
|
|
|
|
|
|
|
|
cellStyleTitle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleTitle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleTitle.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleTitle.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
//定义标题内容
|
|
|
|
|
|
|
|
Row currentRow = sheet.createRow(0);
|
|
|
|
|
|
|
|
// 往Excel表格中添加标题的数据
|
|
|
|
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
|
|
|
|
if(j > 6){
|
|
|
|
|
|
|
|
// 设置列宽
|
|
|
|
|
|
|
|
sheet.setColumnWidth(j, 12000);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
// 设置列宽
|
|
|
|
|
|
|
|
sheet.setColumnWidth(j, 8000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cell cell = currentRow.createCell(j);
|
|
|
|
|
|
|
|
cell.setCellStyle(cellStyleTitle);
|
|
|
|
|
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
|
|
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
|
|
|
|
|
cell.setCellValue(title[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//往Excel表格中添加具体数据
|
|
|
|
|
|
|
|
for (int i = 0; i < rowValues.size(); i++) {
|
|
|
|
|
|
|
|
String status = rowValues.get(i)[0];
|
|
|
|
|
|
|
|
//设置内容单元格式
|
|
|
|
|
|
|
|
CellStyle cellStyleValue = wb.createCellStyle();
|
|
|
|
|
|
|
|
if(status.equals("正常")){
|
|
|
|
|
|
|
|
//设置水平垂直居中
|
|
|
|
|
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
// 设置边框样式
|
|
|
|
|
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
|
|
|
cellStyleValue.setFillBackgroundColor(IndexedColors.LIME.getIndex());
|
|
|
|
|
|
|
|
cellStyleValue.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//设置水平垂直居中
|
|
|
|
|
|
|
|
cellStyleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
cellStyleValue.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
// 设置边框样式
|
|
|
|
|
|
|
|
cellStyleValue.setBorderBottom(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderLeft(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderRight(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setBorderTop(XSSFCellStyle.BORDER_THIN);
|
|
|
|
|
|
|
|
cellStyleValue.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
|
|
|
cellStyleValue.setFillBackgroundColor(IndexedColors.CORAL.getIndex());
|
|
|
|
|
|
|
|
cellStyleValue.setFillForegroundColor(IndexedColors.CORAL.getIndex());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Row Row = sheet.createRow((i + 1));
|
|
|
|
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
|
|
|
|
if(j > 6){
|
|
|
|
|
|
|
|
// 设置列宽
|
|
|
|
|
|
|
|
sheet.setColumnWidth(j, 12000);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
// 设置列宽
|
|
|
|
|
|
|
|
sheet.setColumnWidth(j, 8000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell cell = Row.createCell(j);
|
|
|
|
|
|
|
|
cell.setCellStyle(cellStyleValue);
|
|
|
|
|
|
|
|
//每个单元格的值目前做 String 处理
|
|
|
|
|
|
|
|
//cell.setCellType(CellType.STRING);
|
|
|
|
|
|
|
|
cell.setCellValue(rowValues.get(i)[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//导出Excel
|
|
|
|
|
|
|
|
writeToExcel(response, wb, filename);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 把Excel写到response里,返回前端
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
|
|
* @param wb
|
|
|
|
|
|
|
|
* @param fileName
|
|
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void writeToExcel(HttpServletResponse response, Workbook wb, String fileName) throws Exception {
|
|
|
|
|
|
|
|
OutputStream os = null;
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
|
|
|
response.setCharacterEncoding(Charsets.UTF_8.name());
|
|
|
|
|
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
|
|
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=%s", new String(URLEncoder.encode(fileName, Charsets.UTF_8.name())
|
|
|
|
|
|
|
|
.getBytes(Charsets.UTF_8), Charsets.ISO_8859_1)));
|
|
|
|
|
|
|
|
os = response.getOutputStream();
|
|
|
|
|
|
|
|
wb.write(os);
|
|
|
|
|
|
|
|
os.flush();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|