|
|
|
@ -1,18 +1,34 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.apsKYC.domain.service.Impl;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.apsKYC.domain.entity.ApsNotice;
|
|
|
|
|
import au.com.royalpay.payment.manage.apsKYC.domain.entity.ApsNoticeClient;
|
|
|
|
|
import au.com.royalpay.payment.manage.apsKYC.domain.repository.ApsNoticeClientRepository;
|
|
|
|
|
import au.com.royalpay.payment.manage.apsKYC.domain.service.ApsNoticeClientsService;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.apskyc.ApsNoticeMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -30,6 +46,9 @@ public class ApsNoticeClientsServiceImpl implements ApsNoticeClientsService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ApsNoticeMapper apsNoticeMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageList<JSONObject> getApsNoticeClients(String id, String clientStatus, PageBounds pageBounds) {
|
|
|
|
|
PageList<JSONObject> apsNoticeClients = apsNoticeClientRepository.getApsNoticeClients(id, clientStatus, pageBounds);
|
|
|
|
@ -57,4 +76,171 @@ public class ApsNoticeClientsServiceImpl implements ApsNoticeClientsService {
|
|
|
|
|
}
|
|
|
|
|
return apsNoticeClients;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportApsNoticeClients(String id, String clientStatus, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
List<ApsNoticeClient> apsNoticeClients = apsNoticeClientRepository.apsNoticeClients(id, clientStatus);
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
OutputStream os = null;
|
|
|
|
|
XSSFWorkbook xWorkbook = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ApsNotice apsNotice = apsNoticeMapper.getApsNoticesById(id);
|
|
|
|
|
String fileName = apsNotice.getTitle() + "(" + df.format(new Date()) + ").xlsx";
|
|
|
|
|
os = response.getOutputStream();
|
|
|
|
|
response.reset();
|
|
|
|
|
response.setHeader("Content-disposition", "attachment; filename = " + URLEncoder.encode(fileName, "UTF-8"));
|
|
|
|
|
response.setContentType("application/octet-streem");
|
|
|
|
|
|
|
|
|
|
//创建表格工作空间
|
|
|
|
|
xWorkbook = new XSSFWorkbook();
|
|
|
|
|
//创建一个新表格
|
|
|
|
|
XSSFSheet xSheet = xWorkbook.createSheet("商户列表");
|
|
|
|
|
//set Sheet页头部
|
|
|
|
|
setSheetHeader(xWorkbook, xSheet);
|
|
|
|
|
//set Sheet页内容
|
|
|
|
|
setSheetContent(xWorkbook, xSheet, apsNoticeClients);
|
|
|
|
|
xWorkbook.write(os);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
if (null != os) {
|
|
|
|
|
try {
|
|
|
|
|
os.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null != xWorkbook) {
|
|
|
|
|
try {
|
|
|
|
|
xWorkbook.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setSheetContent(XSSFWorkbook xWorkbook, XSSFSheet xSheet, List<ApsNoticeClient> apsNoticeClients) {
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
//创建内容样式(头部以下的样式)
|
|
|
|
|
CellStyle cs = xWorkbook.createCellStyle();
|
|
|
|
|
cs.setWrapText(true);
|
|
|
|
|
|
|
|
|
|
//设置水平垂直居中
|
|
|
|
|
cs.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
|
|
|
|
|
|
|
|
|
|
if (null != apsNoticeClients && apsNoticeClients.size() > 0) {
|
|
|
|
|
for (int i = 0; i < apsNoticeClients.size(); i++) {
|
|
|
|
|
XSSFRow xRow = xSheet.createRow(i + 1);
|
|
|
|
|
//设置第一列
|
|
|
|
|
XSSFCell xCell0 = xRow.createCell(0);
|
|
|
|
|
xCell0.setCellStyle(cs);
|
|
|
|
|
xCell0.setCellValue(apsNoticeClients.get(i).getPartnerCode());
|
|
|
|
|
//设置第二列
|
|
|
|
|
XSSFCell xCell1 = xRow.createCell(1);
|
|
|
|
|
xCell1.setCellStyle(cs);
|
|
|
|
|
JSONObject clinet = clientMapper.findClientByMoniker(apsNoticeClients.get(i).getPartnerCode());
|
|
|
|
|
if (clinet != null && clinet.containsKey("bd_user_name") && StringUtils.isNotBlank(clinet.getString("bd_user_name"))) {
|
|
|
|
|
xCell1.setCellValue(clinet.getString("bd_user_name"));
|
|
|
|
|
} else {
|
|
|
|
|
xCell1.setCellValue("未配置BD");
|
|
|
|
|
}
|
|
|
|
|
//设置第三列
|
|
|
|
|
XSSFCell xCell2 = xRow.createCell(2);
|
|
|
|
|
xCell2.setCellStyle(cs);
|
|
|
|
|
xCell2.setCellValue(apsNoticeClients.get(i).getStatus());
|
|
|
|
|
String userName = "未知";
|
|
|
|
|
if (StringUtils.isNotBlank(apsNoticeClients.get(i).getUserId())) {
|
|
|
|
|
if (!apsNoticeClients.get(i).getUserId().equals("0")) {
|
|
|
|
|
JSONObject user = clientAccountMapper.findDetail(apsNoticeClients.get(i).getUserId());
|
|
|
|
|
if (user != null) {
|
|
|
|
|
userName = user.getString("username");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
switch (apsNoticeClients.get(i).getStatus()) {
|
|
|
|
|
case 0: {
|
|
|
|
|
xCell2.setCellValue("未读");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
xCell2.setCellValue("已读(" + userName + ":" + df.format(apsNoticeClients.get(i).getReadTime()) + ")");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: {
|
|
|
|
|
xCell2.setCellValue("同意(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: {
|
|
|
|
|
xCell2.setCellValue("拒绝(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//设置第四列
|
|
|
|
|
XSSFCell xCell3 = xRow.createCell(3);
|
|
|
|
|
xCell3.setCellStyle(cs);
|
|
|
|
|
switch (apsNoticeClients.get(i).getHandle()) {
|
|
|
|
|
case 0: {
|
|
|
|
|
xCell3.setCellValue("未处理");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1: {
|
|
|
|
|
if (StringUtils.isNotBlank(apsNoticeClients.get(i).getModifier())) {
|
|
|
|
|
JSONObject modifier = managerMapper.findDetail(apsNoticeClients.get(i).getModifier());
|
|
|
|
|
if (modifier != null) {
|
|
|
|
|
xCell3.setCellValue("已处理(" + modifier.getString("username") + ":" + df.format(apsNoticeClients.get(i).getModifyTime()) + ")");
|
|
|
|
|
} else {
|
|
|
|
|
xCell3.setCellValue("已处理(未知用户:" + df.format(apsNoticeClients.get(i).getModifyTime()) + ")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setSheetHeader(XSSFWorkbook xWorkbook, XSSFSheet xSheet) {
|
|
|
|
|
//设置表格的宽度 xSheet.setColumnWidth(0, 20 * 256); 中的数字 20 自行设置为自己适用的
|
|
|
|
|
xSheet.setColumnWidth(0, 10 * 256);
|
|
|
|
|
xSheet.setColumnWidth(1, 25 * 256);
|
|
|
|
|
xSheet.setColumnWidth(2, 40 * 256);
|
|
|
|
|
xSheet.setColumnWidth(3, 40 * 256);
|
|
|
|
|
//创建表格的样式
|
|
|
|
|
CellStyle cs = xWorkbook.createCellStyle();
|
|
|
|
|
//设置水平、垂直居中
|
|
|
|
|
cs.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
cs.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
|
|
|
|
|
//设置字体
|
|
|
|
|
Font headerFont = xWorkbook.createFont();
|
|
|
|
|
headerFont.setFontHeightInPoints((short) 12);
|
|
|
|
|
/*headerFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);*/
|
|
|
|
|
headerFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
|
|
|
|
|
headerFont.setFontName("宋体");
|
|
|
|
|
cs.setFont(headerFont);
|
|
|
|
|
cs.setWrapText(true);//是否自动换行
|
|
|
|
|
|
|
|
|
|
//创建一行
|
|
|
|
|
XSSFRow xRow0 = xSheet.createRow(0);
|
|
|
|
|
//设置每一列
|
|
|
|
|
XSSFCell xCell0 = xRow0.createCell(0);
|
|
|
|
|
xCell0.setCellStyle(cs);
|
|
|
|
|
xCell0.setCellValue("商户名称");
|
|
|
|
|
|
|
|
|
|
XSSFCell xCell1 = xRow0.createCell(1);
|
|
|
|
|
xCell1.setCellStyle(cs);
|
|
|
|
|
xCell1.setCellValue("所属BD");
|
|
|
|
|
|
|
|
|
|
XSSFCell xCell2 = xRow0.createCell(2);
|
|
|
|
|
xCell2.setCellStyle(cs);
|
|
|
|
|
xCell2.setCellValue("商户操作状态");
|
|
|
|
|
|
|
|
|
|
XSSFCell xCell3 = xRow0.createCell(3);
|
|
|
|
|
xCell3.setCellStyle(cs);
|
|
|
|
|
xCell3.setCellValue("运营操作状态");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|