add a+kyc通知增加表格导出

master
Todking 3 years ago
parent cbadf4070d
commit 80ead71db4

@ -6,6 +6,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import java.util.Date;
import java.util.List;
public interface ApsNoticeClientRepository {
void saveApsNoticeClient(ApsNoticeClient apsNoticeClient);
@ -17,4 +18,6 @@ public interface ApsNoticeClientRepository {
void updateApsNoticeClientByPartnerCode(Date modifyTime, String modifier, String partnerCode);
ApsNoticeClient getApsNoticeClientById(String id);
List<ApsNoticeClient> apsNoticeClients(String id, String clientStatus);
}

@ -4,6 +4,11 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface ApsNoticeClientsService {
PageList<JSONObject> getApsNoticeClients(String id, String clientStatus, PageBounds pageBounds);
void exportApsNoticeClients(String id, String clientStatus, HttpServletRequest request, HttpServletResponse response);
}

@ -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,159 @@ 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");
//创建内容样式(头部以下的样式)
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("未读");
case 1:
xCell2.setCellValue("已读(" + userName + ":" + df.format(apsNoticeClients.get(i).getReadTime()) + ")");
case 2:
xCell2.setCellValue("同意(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")");
case 3:
xCell2.setCellValue("拒绝(" + userName + ":" + df.format(apsNoticeClients.get(i).getStatusTime()) + ")");
}
//设置第四列
XSSFCell xCell3 = xRow.createCell(3);
xCell3.setCellStyle(cs);
switch (apsNoticeClients.get(i).getHandle()) {
case 0:
xCell3.setCellValue("未处理");
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()) + ")");
}
}
}
}
}
}
}
private void setSheetHeader(XSSFWorkbook xWorkbook, XSSFSheet xSheet) {
//设置表格的宽度 xSheet.setColumnWidth(0, 20 * 256); 中的数字 20 自行设置为自己适用的
xSheet.setColumnWidth(0, 10 * 256);
xSheet.setColumnWidth(1, 30 * 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("运营操作状态");
}
}

@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@Repository
public class ApsNoticeClientRepositoryImpl implements ApsNoticeClientRepository {
@ -41,4 +42,9 @@ public class ApsNoticeClientRepositoryImpl implements ApsNoticeClientRepository
public ApsNoticeClient getApsNoticeClientById(String id) {
return mapper.getApsNoticeClientById(id);
}
@Override
public List<ApsNoticeClient> apsNoticeClients(String id, String clientStatus) {
return mapper.apsNoticeClients(id, clientStatus);
}
}

@ -15,6 +15,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/aps/kyc")
@ -101,4 +103,15 @@ public class RestApsKYCController {
public void updateApsNoticeClient(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody ApsNoticeClient apsNoticeClient) {
apsNoticeService.updateApsNoticeClient(manager, apsNoticeClient);
}
/**
*
*
* @param id
* @param clientStatus
*/
@ManagerMapping(value = "/notice/clients/excel", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.SALES_MANAGER})
public void exportApsNoticeClients(@RequestParam String id, @RequestParam(required = false) String clientStatus, HttpServletRequest request, HttpServletResponse response) throws Exception {
apsNoticeClientsService.exportApsNoticeClients(id, clientStatus, request, response);
}
}

@ -10,6 +10,7 @@ import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
@AutoMapper(tablename = "sys_aps_notice_clients", pkName = "id")
public interface ApsNoticeClientMapper {
@ -31,4 +32,6 @@ public interface ApsNoticeClientMapper {
@AutoSql(SqlType.UPDATE)
void toUpdateApsKycClient(JSONObject updateReadTime);
List<ApsNoticeClient> apsNoticeClients(String id, String clientStatus);
}

@ -31,5 +31,14 @@
AND c.is_valid = 0
AND c.handle = 0
</select>
<select id="apsNoticeClients" resultType="au.com.royalpay.payment.manage.apsKYC.domain.entity.ApsNoticeClient">
SELECT *
FROM sys_aps_notice_clients
where notice_id = #{id}
<if test="clientStatus != null">
and `status` = #{clientStatus}
</if>
ORDER BY status_time DESC
</select>
</mapper>

@ -54,6 +54,13 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
that.loadApsNoticeClients(page);
}
};
that.download = function () {
var url = "/aps/kyc/notice/clients/excel?id=" + that.clientId
if (that.clientStatus != -1) {
url = url + "&clientStatus=" + that.clientStatus
}
return url;
}
that.getNoticeClients = function (title, id, page, index) {
that.selectIndex = index
that.showClients = true

@ -90,17 +90,17 @@
<div class="box box-danger" ng-if="showClients">
<div class="modal-body">
<div style="display: flex;align-items: center;justify-content: space-between">
<div>
<span style="font-size: 20px">{{clientTitle}}—商户列表</span>
<select style="width: 100px;height: 30px;margin-left: 20px" ng-model="clientStatus"
ng-change="changeClientStatus(clientStatus,1)"
ng-options="status.id as status.label for status in status">
</select>
</div>
<button class="btn btn-success" type="button" ng-click="download()" ng-if="noticeClients != null && noticeClients != '' && false">
<i class="fa fa-download"></i> 下载
</button>
<h3>{{clientTitle}}—商户列表</h3>
<div style="display: flex;align-items: center;">
<lable>商户操作状态:</lable>
<select ng-model="clientStatus" style="margin-right: 30px;width: 100px;height: 30px;"
ng-change="changeClientStatus(clientStatus,1)"
ng-options="status.id as status.label for status in status">
</select>
<a ng-href="{{ download() }}" class="btn btn-success" type="button"
ng-if="noticeClients != null && noticeClients != ''">
<i class="fa sa-download"></i> 导出EXCEL
</a>
</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-striped table-hover">

Loading…
Cancel
Save