Merge branch 'develop'

master
taylor.dang 6 years ago
commit f2104e2af5

@ -49,6 +49,8 @@ public interface CleanService {
void settlementAba(Date date, HttpServletResponse response) throws IOException;
void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException;
List<JSONObject> getCleanLogs(ClearingLogQuery query, JSONObject manager);
JSONObject getCleanLogsInClients(ClearingLogQuery query, JSONObject manager);

@ -382,20 +382,24 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
ZipOutputStream zos = new ZipOutputStream(ous);
logger.info("using newest version test");
for (JSONObject log : logs) {
String dateString = DateFormatUtils.format(log.getDate("operate_time"), "yyyyMMddHHmmss");
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
List<String> bankList = details.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
for (String bank : bankList) {
String filename = "Merchant_Settlement_Info_" + dateString + "_" + bank + ".xlsx";
zos.putNextEntry(new ZipEntry(filename));
byte[] xlsx = generateSettleXlsxFile(dt, details, bank);
IOUtils.write(xlsx, zos);
}
exportAllBankXlsFiles(zos, details, log.getDate("operate_time"));
}
zos.flush();
IOUtils.closeQuietly(zos);
}
private void exportAllBankXlsFiles(ZipOutputStream zos, List<JSONObject> details, Date operateTime) throws IOException {
String dateString = DateFormatUtils.format(operateTime, "yyyyMMddHHmmss");
List<String> bankList = details.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
for (String bank : bankList) {
String filename = "Merchant_Settlement_Info_" + dateString + "_" + bank + ".xlsx";
zos.putNextEntry(new ZipEntry(filename));
byte[] xlsx = generateSettleXlsxFile(operateTime, details, bank);
IOUtils.write(xlsx, zos);
}
}
@Override
public List<JSONObject> getXlsx(Date dt, String bank) throws IOException {
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
@ -441,26 +445,27 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> settlements, String bank) throws IOException {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMM"));
int rowNum = 0;
for (JSONObject settle : settlements) {
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
if (bank != null && !Objects.equals(settle.getString("settle_bank"), bank)) {
continue;
try (Workbook wb = new XSSFWorkbook()) {
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd"));
int rowNum = 0;
for (JSONObject settle : settlements) {
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
if (bank != null && !Objects.equals(settle.getString("settle_bank"), bank)) {
continue;
}
Row row = sheet.createRow(rowNum++);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("bsb_no"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_no"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_name"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
}
Row row = sheet.createRow(rowNum++);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("bsb_no"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_no"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_name"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
wb.write(bos);
bos.flush();
return bos.toByteArray();
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
wb.write(bos);
bos.flush();
return bos.toByteArray();
}
@Override
@ -501,6 +506,32 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
}
@Override
public void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException {
int clearingId = Integer.parseInt(batchId);
JSONObject clearing = clearingLogMapper.findById(clearingId);
if (clearing == null) {
throw new NotFoundException("Clearing batch " + batchId + " not found");
}
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(clearingId);
Date settleDate = clearing.getDate("settle_date");
Date opTime = clearing.getDate("operate_time");
String zipName = "Merchant_Settlement_Info_" + DateFormatUtils.format(opTime, "yyyyMMddHHmmss") + "_all.zip";
resp.setContentType("application/octet-stream;");
resp.addHeader("Content-Disposition", "attachment; filename=" + zipName);
OutputStream ous = resp.getOutputStream();
List<ABAFile> abaFiles = generateSettleAbaFiles(settleDate, details, opTime);
try (ZipOutputStream zos = new ZipOutputStream(ous)) {
for (ABAFile aba : abaFiles) {
zos.putNextEntry(new ZipEntry(aba.filename()));
IOUtils.write(aba.output(1), zos);
}
exportAllBankXlsFiles(zos, details, opTime);
zos.flush();
}
}
private List<ABAFile> generateSettleAbaFiles(Date dt, List<JSONObject> settlements, Date operateTime) {
List<String> banks = settlements.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
return banks.stream().map(bank -> generateSettleAbaFile(bank, dt, settlements)).peek(file -> file.setOperateTime(operateTime)).collect(Collectors.toList());

@ -156,6 +156,11 @@ public class SettlementDevController {
}
}
@RequestMapping("/settle_batches/{batchId}/settle_files")
public void getSettlementFilesForBatch(@PathVariable String batchId, HttpServletResponse resp) throws IOException {
cleanService.getSettlementFilesForBatch(batchId, resp);
}
@RequestMapping("/details/{detailId}")
public JSONObject settlementDetail(@PathVariable int detailId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return cleanService.getCleanLogTransactions(detailId, manager);

@ -23,13 +23,13 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}).state('date_setting', {
url: '/date_setting',
templateUrl: '/static/analysis/templates/settle_date_config.html',
/* onEnter: ['$uibModal', function ($uibModal) {
$uibModal.open({
templateUrl: '/static/analysis/templates/settle_date_config.html',
controller: 'settleDateConfigCtrl',
size: 'lg'
})
}],*/
/* onEnter: ['$uibModal', function ($uibModal) {
$uibModal.open({
templateUrl: '/static/analysis/templates/settle_date_config.html',
controller: 'settleDateConfigCtrl',
size: 'lg'
})
}],*/
controller: 'settleDateConfigCtrl',
}).state('clearingLogs.settlementDetail', {
url: '/settles/{date}',
@ -247,9 +247,9 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.noticeResend = false;
$scope.analysisFilter = {};
$scope.currentAnalysis = $scope.detail;
$scope.pageCtrl = {visible:{}};
$scope.pageCtrl = {visible: {}};
function getAnalysisTemplate() {
function getAnalysisTemplate() {
return [
{settleDays: 1, clients: 0, settleAmount: 0, settles: []},
{settleDays: 2, clients: 0, settleAmount: 0, settles: []},
@ -257,6 +257,10 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
];
}
$scope.reloadPage = function () {
$state.reload();
};
$scope.settleAnalysis = getAnalysisTemplate();
$scope.batchAnalysis = {
@ -269,7 +273,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.endIndexMap = {};
$scope.initEndIndex = 20;
$scope.more = function(key) {
$scope.more = function (key) {
var endIndex = $scope.endIndexMap[key] + $scope.initEndIndex;
$scope.endIndexMap[key] = endIndex;
@ -279,7 +283,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
};
$scope.packup = function(key) {
$scope.packup = function (key) {
$scope.endIndexMap[key] = $scope.initEndIndex;
var length = $scope.clientsMap[key].clients;
if (length <= $scope.initEndIndex)
@ -292,7 +296,6 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
};
angular.forEach($scope.detail.details, function (settleItem) {
var settleDays = settleItem.clear_days;
attachAnalysis($scope.settleAnalysis[Math.min(settleDays - 1, 2)]);
@ -305,14 +308,14 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
}
});
$scope.clientsMap = $scope.settleAnalysis;
$scope.clientsMap = $scope.settleAnalysis;
for (var key in $scope.clientsMap) {
$scope.endIndexMap[key] = $scope.initEndIndex;
var length = $scope.clientsMap[key].clients;
if (length <= $scope.initEndIndex)
$scope.endIndexMap[key] = length;
}
for (var key in $scope.clientsMap) {
$scope.endIndexMap[key] = $scope.initEndIndex;
var length = $scope.clientsMap[key].clients;
if (length <= $scope.initEndIndex)
$scope.endIndexMap[key] = length;
}
var nowStr = $filter('date')(new Date(), "yyyy-MM-dd");

@ -40,6 +40,9 @@
ng-disabled="noticeResend">
Send Settlement Notice
</button>
<button class="btn btn-success pull-right" ng-click="reloadPage()">
<i class="fa fa-refresh"></i>Reload
</button>
</div>
</div>
@ -152,6 +155,11 @@
</div>
</div>
</div>
<div class="box-footer" ng-if="analysisFilter.clearing_id!=null">
<a class="btn btn-primary" ng-href="/sys/settlement/settle_batches/{{analysisFilter.clearing_id}}/settle_files" target="_blank">
Download Files
</a>
</div>
</div>
<div class="row">

Loading…
Cancel
Save