Commit 27c85f17 authored by chenzhao's avatar chenzhao Committed by hezhuozhi

工行代扣下载接口修改

parent ae13f19c
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
<artifactId>bcpkix-jdk15on</artifactId> <artifactId>bcpkix-jdk15on</artifactId>
<version>1.70</version> <version>1.70</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
......
...@@ -11,12 +11,26 @@ public enum UploadStatusEnum { ...@@ -11,12 +11,26 @@ public enum UploadStatusEnum {
未生成("未生成","未生成"), 未生成("未生成","未生成"),
成功("成功","成功"), 成功("成功","成功"),
失败("失败","失败"), 失败("失败","失败"),
代扣成功("成功","0"),
代扣失败("失败","1"),
代扣中("处理中","99"),
代扣处理中("代扣处理中","代扣处理中"); 代扣处理中("代扣处理中","代扣处理中");
private String name; private String name;
private String code; private String code;
public static UploadStatusEnum getNodeByCode(String code) {
UploadStatusEnum anEnum = null;
for (UploadStatusEnum type : UploadStatusEnum.values()) {
if (type.getCode() == code) {
anEnum = type;
break;
}
}
return anEnum;
}
} }
package com.yeejoin.amos.boot.module.hygf.api.dto; package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
*
*
* @author system_generator * @author system_generator
* @date 2024-12-06 * @date 2024-12-06
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="IcbcWithholdRecordDto", description="") @ApiModel(value = "IcbcWithholdRecordDto", description = "")
public class IcbcWithholdRecordDto extends BaseDto { public class IcbcWithholdRecordDto extends BaseDto {
@ExcelIgnore
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "农户姓名") @ExcelIgnore
protected Long sequenceNbr;
@ExcelProperty(value = "户主姓名", index = 0)
@ApiModelProperty(value = "户主姓名")
private String custName; private String custName;
/**
* 身份证号
*/
@ExcelProperty(value = "区域公司", index = 1)
@ApiModelProperty(value = "区域公司")
private String regionalCompaniesName;
/**
* 手机号码
*/
@ExcelProperty(value = "手机号", index = 2)
@ApiModelProperty(value = "手机号码")
private String phone;
@ExcelProperty(value = "身份证号", index = 3)
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String idCard; private String idCard;
private String phone;
/**
* 聚富通电子账户账号
*/
@ExcelProperty(value = "银行卡号", index = 4)
@ApiModelProperty(value = "聚富通电子账户账号")
private String mediumId;
/**
* 开户状态, 00-初始,01-开户中,02-开户成功,03-开户失败
*/
@ExcelProperty(value = "开户状态", index = 5)
@ApiModelProperty(value = "开户状态, 00-初始,01-开户中,02-开户成功,03-开户失败")
private String openAccountStatus;
/**
* 协议状态, 0-未生效,1-已生效,2-过期,3-作废,4-待短信确认
*/
@ExcelProperty(value = "协议状态", index = 6)
@ApiModelProperty(value = "协议状态, 0-未生效,1-已生效,2-过期,3-作废,4-待短信确认")
private String protocolStatus;
@ExcelProperty(value = "协议状态", index = 7)
@ApiModelProperty(value = "批次号") @ApiModelProperty(value = "批次号")
private String batchNo; private String batchNo;
@ApiModelProperty(value = "聚富通电子账户账号")
private String mediumId;
@ExcelProperty(value = "项目编号", index = 8)
@ApiModelProperty(value = "项目编号") @ApiModelProperty(value = "项目编号")
private String projectId; private String projectId;
@ExcelProperty(value = "付款金额", index = 9)
@ApiModelProperty(value = "付款金额") @ApiModelProperty(value = "付款金额")
private int paymentAmount; private double paymentAmount;
@ExcelProperty(value = "代扣状态", index = 10)
@ApiModelProperty(value = "代扣状态") @ApiModelProperty(value = "代扣状态")
private String withholdStatus; private String withholdStatus;
@ExcelIgnore
@ApiModelProperty(value = "上传时间") @ApiModelProperty(value = "上传时间")
private Date withholdTime; private Date withholdTime;
@ExcelProperty(value = "缴费时间", index = 11)
@ApiModelProperty(value = "缴费时间") @ApiModelProperty(value = "缴费时间")
private Date paymentTime; private Date paymentTime;
@ExcelIgnore
@ApiModelProperty(value = "缴费开始时间") @ApiModelProperty(value = "缴费开始时间")
private String paymentStartTime; private String paymentStartTime;
@ExcelIgnore
@ApiModelProperty(value = "缴费结束时间") @ApiModelProperty(value = "缴费结束时间")
private String paymentEndTime; private String paymentEndTime;
@ExcelIgnore
private String outUserId; private String outUserId;
@ExcelIgnore
private String amosUserId; private String amosUserId;
@ExcelIgnore
private String regionalCompaniesCode; private String regionalCompaniesCode;
/*
* 区域公司名称
* */
private String regionalCompaniesName;
} }
...@@ -17,5 +17,5 @@ import java.util.List; ...@@ -17,5 +17,5 @@ import java.util.List;
*/ */
public interface IcbcWithholdRecordMapper extends BaseMapper<IcbcWithholdRecord> { public interface IcbcWithholdRecordMapper extends BaseMapper<IcbcWithholdRecord> {
@UserEmpower (field = {"ph.regional_companies_code"}, dealerField = {"ph.developer_code", "ph.regional_companies_code", "ph.developer_user_id"}, fieldConditions = {"in", "in", "in"}, relationship = "and",specific=false) @UserEmpower (field = {"ph.regional_companies_code"}, dealerField = {"ph.developer_code", "ph.regional_companies_code", "ph.developer_user_id"}, fieldConditions = {"in", "in", "in"}, relationship = "and",specific=false)
List<IcbcWithholdRecordDto> exportTotal(String developerCode, String regionalCompaniesCode, String province, String city, String district, String year, String month, List<String> quarter, @Param("dto")IcbcWithholdRecordDto dto); List<IcbcWithholdRecordDto> exportTotal(String developerCode, String regionalCompaniesCode, String province, String city, String district, String year, String month, List<String> quarters, @Param("dto")IcbcWithholdRecordDto dto);
} }
...@@ -17,7 +17,6 @@ public class FileUtil { ...@@ -17,7 +17,6 @@ public class FileUtil {
InputStream fileInputStream = null; InputStream fileInputStream = null;
try { try {
response.reset(); response.reset();
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
......
package com.yeejoin.amos.boot.module.hygf.api.util; package com.yeejoin.amos.boot.module.hygf.api.util;
import com.yeejoin.amos.component.robot.BadRequest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URLEncoder;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer; import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode; import java.nio.channels.FileChannel.MapMode;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
public class FileUtils { public class FileUtils {
...@@ -250,5 +260,122 @@ public class FileUtils { ...@@ -250,5 +260,122 @@ public class FileUtils {
} }
} }
public static void createZipFile(Path folderPath, String zipFilePath, HttpServletResponse response) {
try (ServletOutputStream out = response.getOutputStream();
ZipOutputStream zos = new ZipOutputStream(out)) {
addFolderToZip(folderPath.toFile(), "", zos);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void addFolderToZip(File folder, String parentFolder, ZipOutputStream zos) throws IOException {
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
addFolderToZip(file, parentFolder + file.getName() + "/", zos);
} else {
addFileToZip(file, parentFolder, zos);
}
}
}
}
private static void addFileToZip(File sourceFile, String parentFolder, ZipOutputStream zipOut) throws IOException {
FileInputStream fin = new FileInputStream(sourceFile);
String zipEntryName = parentFolder + sourceFile.getName();
zipOut.putNextEntry(new ZipEntry(zipEntryName));
byte[] buffer = new byte[1024];
int length;
while ((length = fin.read(buffer)) >= 0) {
zipOut.write(buffer, 0, length);
}
zipOut.closeEntry();
fin.close();
}
public static MultipartFile convertZipToMultipartFile(File zipFile) throws IOException {
try (FileInputStream input = new FileInputStream(zipFile)) {
return new MockMultipartFile(
zipFile.getName(), // name
zipFile.getName(), // originalFilename
"application/zip", // contentType
FileCopyUtils.copyToByteArray(input) // bytes
);
}
}
public static boolean unzipAndUpload( String localZipFilePath,HttpServletResponse response) throws Exception {
boolean success = false;
File tempDir = null;
try {
// 创建临时目录用于解压
tempDir = Files.createTempDirectory("unzip_temp_").toFile();
tempDir.deleteOnExit(); // 确保 JVM 退出时删除临时目录
// 解压本地 ZIP 文件到临时目录
unzipLocalFile(localZipFilePath, tempDir.getAbsolutePath());
// 获取解压后的文件列表
File[] files = tempDir.listFiles();
if (files == null || files.length == 0) {
throw new IOException("No files found after unzipping.");
}
createZipFile(tempDir.toPath(),tempDir.getPath(),response);
success = true;
} catch (Exception e) {
throw e;
} finally {
// 清理临时文件和断开连接
if (tempDir != null) {
com.yeejoin.amos.boot.module.hygf.api.util.FileUtils.cleanup(tempDir.toPath());
}
}
return success;
}
private static void unzipLocalFile(String zipFilePath, String destDir) throws IOException {
byte[] buffer = new byte[1024];
Path zipFilePathObj = Paths.get(zipFilePath);
Path destDirObj = Paths.get(destDir);
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePathObj.toFile()))) {
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
Path newFilePath = destDirObj.resolve(zipEntry.getName());
if (!zipEntry.isDirectory()) {
// 如果是文件,则创建新文件并写入内容
Files.createDirectories(newFilePath.getParent());
try (FileOutputStream fos = new FileOutputStream(newFilePath.toFile())) {
int len;
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
}
} else {
// 如果是目录,则创建目录
Files.createDirectories(newFilePath);
}
zipEntry = zis.getNextEntry();
}
zis.closeEntry();
}
}
} }
\ No newline at end of file
...@@ -184,21 +184,23 @@ ...@@ -184,21 +184,23 @@
FROM FROM
`hygf_peasant_household` ph `hygf_peasant_household` ph
LEFT JOIN hygf_icbc_record re ON re.amos_user_id = ph.amos_user_id LEFT JOIN hygf_icbc_record re ON re.amos_user_id = ph.amos_user_id
<if test="developerCode != null and developerCode != ''"> <where>
AND ph.developer_code = #{developerCode} <if test="developerCode != null and developerCode != ''">
</if> AND ph.developer_code = #{developerCode}
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''"> </if>
AND ph.regional_companies_code = #{regionalCompaniesCode} <if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
</if> AND ph.regional_companies_code = #{regionalCompaniesCode}
<if test="province != null and province != ''"> </if>
AND ph.project_address LIKE CONCAT ('%',#{province},'%') <if test="province != null and province != ''">
</if> AND ph.project_address LIKE CONCAT ('%',#{province},'%')
<if test="city != null and city != ''"> </if>
AND ph.project_address LIKE CONCAT ('%',#{city},'%') <if test="city != null and city != ''">
</if> AND ph.project_address LIKE CONCAT ('%',#{city},'%')
<if test="district != null and district != ''"> </if>
AND ph.project_address LIKE CONCAT ('%',#{district},'%') <if test="district != null and district != ''">
</if> AND ph.project_address LIKE CONCAT ('%',#{district},'%')
</if>
</where>
GROUP BY GROUP BY
ph.amos_user_id ph.amos_user_id
</select> </select>
......
...@@ -107,11 +107,12 @@ ...@@ -107,11 +107,12 @@
</if> </if>
<if test="month != null and month != ''"> <if test="month != null and month != ''">
AND EXTRACT(MONTH FROM re.withhold_time) = #{month} AND TO_CHAR(re.withhold_time, 'YYYY-MM') = #{month}
</if> </if>
<if test="quarter != null and quarter.size() > 1"> <if test="quarters != null and quarters.size() > 1">
AND ph.withhold_time BETWEEN <foreach collection="quarter" item="item" separator="and"> AND TO_CHAR(re.withhold_time, 'YYYY-MM') in <foreach collection="quarters" item="item" separator="," open="(" close=")">
#{item}
</foreach> </foreach>
</if> </if>
...@@ -122,7 +123,9 @@ ...@@ -122,7 +123,9 @@
<if test="dto.batchNo != null and dto.batchNo != ''"> <if test="dto.batchNo != null and dto.batchNo != ''">
AND re.batch_no = #{dto.batchNo} AND re.batch_no = #{dto.batchNo}
</if> </if>
<if test="dto.withholdStatus != null and dto.withholdStatus != ''">
AND re.withhold_status = #{dto.withholdStatus}
</if>
<if test="dto.paymentStartTime != null and dto.paymentStartTime != ''"> <if test="dto.paymentStartTime != null and dto.paymentStartTime != ''">
AND re.payment_time > #{dto.paymentStartTime} AND re.payment_time > #{dto.paymentStartTime}
</if> </if>
......
...@@ -103,7 +103,7 @@ public class IcbcWithholdController extends BaseController { ...@@ -103,7 +103,7 @@ public class IcbcWithholdController extends BaseController {
* @param current 每页大小 * @param current 每页大小
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询") @ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询")
public ResponseModel<Page<IcbcWithholdDto>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<IcbcWithholdDto>> queryForPage(@RequestParam(value = "current") int current,
...@@ -124,7 +124,7 @@ public class IcbcWithholdController extends BaseController { ...@@ -124,7 +124,7 @@ public class IcbcWithholdController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/test") @GetMapping(value = "/test")
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询") @ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询")
public ResponseModel<Page<IcbcWithholdDto>> test() { public ResponseModel<Page<IcbcWithholdDto>> test() {
...@@ -189,7 +189,7 @@ public class IcbcWithholdController extends BaseController { ...@@ -189,7 +189,7 @@ public class IcbcWithholdController extends BaseController {
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息回盘文件获取", notes = " 聚富通代扣信息回盘文件获取") @ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息回盘文件获取", notes = " 聚富通代扣信息回盘文件获取")
@GetMapping(value = "/updateWithholdStatus") @GetMapping(value = "/updateWithholdStatus")
public ResponseModel updateWithholdStatus( ) throws Exception { public ResponseModel updateWithholdStatus( ) throws Exception {
...@@ -202,11 +202,23 @@ public class IcbcWithholdController extends BaseController { ...@@ -202,11 +202,23 @@ public class IcbcWithholdController extends BaseController {
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = "批次人员信息下载", notes = "批次人员信息下载") @ApiOperation(httpMethod = "POST",value = "批次人员信息下载", notes = "批次人员信息下载")
@PostMapping(value = "/export") @PostMapping(value = "/export")
public void downTemplate(HttpServletResponse response, @RequestBody IcbcWithhold model ) { public void downTemplate(HttpServletResponse response, @RequestBody IcbcWithhold model ) {
icbcWithholdServiceImpl.exportData(response,model); icbcWithholdServiceImpl.exportData(response,model);
} }
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "文件下载", notes = "文件下载")
@GetMapping(value = "/downloadFile")
public void downTemplate(HttpServletResponse response, String fileUrl, String batchNo,String type ) throws Exception {
icbcWithholdServiceImpl.downloadAndSaveZipFile(fileUrl,batchNo,type,response);
}
} }
package com.yeejoin.amos.boot.module.hygf.biz.controller; package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits; import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List; import java.util.List;
import java.util.Map;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.IcbcWithholdRecordServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.IcbcWithholdRecordServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto; import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto;
...@@ -112,4 +117,39 @@ public class IcbcWithholdRecordController extends BaseController { ...@@ -112,4 +117,39 @@ public class IcbcWithholdRecordController extends BaseController {
public ResponseModel<List<IcbcWithholdRecordDto>> selectForList() { public ResponseModel<List<IcbcWithholdRecordDto>> selectForList() {
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.queryForIcbcWithholdRecordList()); return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.queryForIcbcWithholdRecordList());
} }
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping (value = "/exportTotal")
@ApiOperation (httpMethod = "GET", value = "导出聚富通开卡统计", notes = "导出聚富通开卡统计")
public ResponseModel<Map<String,Object>> exportTotal(@ApiParam(value = "经销商公司code",example = "87*253*775")@RequestParam(required = false) String developerCode,
@ApiParam(value = "区域公司code",example = "87*253*652") @RequestParam(required = false) String regionalCompaniesCode,
@ApiParam(value = "省份",example = "610000") @RequestParam(required = false) String province,
@ApiParam(value = "市",example = "610700") @RequestParam(required = false) String city,
@ApiParam(value = "区",example = "610116") @RequestParam(required = false) String district,
@RequestParam(required = false)String year,
@RequestParam(required = false)String month,
@RequestParam(required = false)String quarter ) {
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.paymentAmount(developerCode,regionalCompaniesCode,province,city,district,year,month,quarter));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "存量合同电站下载", notes = "存量合同电站下载")
@GetMapping(value = "/export")
public void exportData(HttpServletResponse response, @ApiParam(value = "经销商公司code",example = "87*253*775")@RequestParam(required = false) String developerCode,
@ApiParam(value = "区域公司code",example = "87*253*652") @RequestParam(required = false) String regionalCompaniesCode,
@ApiParam(value = "省份",example = "610000") @RequestParam(required = false) String province,
@ApiParam(value = "市",example = "610700") @RequestParam(required = false) String city,
@ApiParam(value = "区",example = "610116") @RequestParam(required = false) String district,
@RequestParam(required = false)String year,
@RequestParam(required = false)String month,
@RequestParam(required = false)String quarter ) {
icbcWithholdRecordServiceImpl.exportData(response,developerCode,regionalCompaniesCode,province,city,district,year,month,quarter);
}
} }
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithholdRecord; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithholdRecord;
import com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdRecordMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdRecordMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IIcbcWithholdRecordService; import com.yeejoin.amos.boot.module.hygf.api.service.IIcbcWithholdRecordService;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto; import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -63,9 +64,15 @@ public class IcbcWithholdRecordServiceImpl extends BaseService<IcbcWithholdRecor ...@@ -63,9 +64,15 @@ public class IcbcWithholdRecordServiceImpl extends BaseService<IcbcWithholdRecor
} }
public void exportData(HttpServletResponse response, String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,List<String> quarter ){ public void exportData(HttpServletResponse response, String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,String quarter ){
List<String> quarters = null;
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarter,null); if (StringUtils.isNotEmpty(quarter)){
String[] split = quarter.split("-");
quarters = DateUtils.getMonthsInQuarterAsString(Integer.parseInt(split[0]),Integer.parseInt(split[1]));
}
IcbcWithholdRecordDto dto = new IcbcWithholdRecordDto();
dto.setWithholdStatus("成功");
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarters,dto);
if (CollectionUtil.isNotEmpty(dtos)){ if (CollectionUtil.isNotEmpty(dtos)){
ExcelUtil.createTemplate(response,"结算金额","结算金额",dtos, IcbcWithholdRecordDto.class,null,false); ExcelUtil.createTemplate(response,"结算金额","结算金额",dtos, IcbcWithholdRecordDto.class,null,false);
} }
...@@ -73,10 +80,17 @@ public class IcbcWithholdRecordServiceImpl extends BaseService<IcbcWithholdRecor ...@@ -73,10 +80,17 @@ public class IcbcWithholdRecordServiceImpl extends BaseService<IcbcWithholdRecor
} }
public Map<String, Object> paymentAmount(String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,List<String> quarter ){ public Map<String, Object> paymentAmount(String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,String quarter ){
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarter,null); List<String> quarters = null;
int totalPaymentAmount = dtos.stream() if (StringUtils.isNotEmpty(quarter)){
.mapToInt(IcbcWithholdRecordDto::getPaymentAmount) String[] split = quarter.split("-");
quarters = DateUtils.getMonthsInQuarterAsString(Integer.parseInt(split[0]),Integer.parseInt(split[1]));
}
IcbcWithholdRecordDto dto = new IcbcWithholdRecordDto();
dto.setWithholdStatus("成功");
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarters,dto);
double totalPaymentAmount = dtos.stream()
.mapToDouble(IcbcWithholdRecordDto::getPaymentAmount)
.sum(); .sum();
Map<String, Object> paymentAmount = MapBuilder.<String, Object>create().put("paymentAmount", totalPaymentAmount).build(); Map<String, Object> paymentAmount = MapBuilder.<String, Object>create().put("paymentAmount", totalPaymentAmount).build();
return paymentAmount; return paymentAmount;
......
...@@ -33,6 +33,7 @@ import com.yeejoin.amos.boot.module.hygf.api.util.SFTPUtil; ...@@ -33,6 +33,7 @@ import com.yeejoin.amos.boot.module.hygf.api.util.SFTPUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -50,6 +51,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -50,6 +51,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
...@@ -137,6 +139,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -137,6 +139,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
WithholdLoopField withholdLoopField = new WithholdLoopField(); WithholdLoopField withholdLoopField = new WithholdLoopField();
withholdLoopField.setBillNo(++billNo); withholdLoopField.setBillNo(++billNo);
recordDTO.setBatchNo(batchNo); recordDTO.setBatchNo(batchNo);
recordDTO.setProjectId(projectId);
withholdLoopField.setBusiCode(recordDTO.getOutUserId()); withholdLoopField.setBusiCode(recordDTO.getOutUserId());
withholdLoopField.setBusiAcct(recordDTO.getMediumId()); withholdLoopField.setBusiAcct(recordDTO.getMediumId());
withholdLoopField.setBusiName(recordDTO.getCustName()); withholdLoopField.setBusiName(recordDTO.getCustName());
...@@ -179,7 +182,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -179,7 +182,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
addFileToZip(dirPath.toString() + "/" + fileName + ".sign", fileName + ".sign", zos); addFileToZip(dirPath.toString() + "/" + fileName + ".sign", fileName + ".sign", zos);
addFileToZip(dirPath.toString() + "/" + fileName + ".check", fileName + ".check", zos); addFileToZip(dirPath.toString() + "/" + fileName + ".check", fileName + ".check", zos);
MultipartFile multipartFile = fileToMultipartFile(new File(dirPath.toString() + "/" + fileName + ".zip")); MultipartFile multipartFile = convertZipToMultipartFile(new File(dirPath.toString() + "/" + fileName + ".zip"));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile); FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
if (result != null) { if (result != null) {
for (String url : result.getResult().keySet()) { for (String url : result.getResult().keySet()) {
...@@ -200,7 +203,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -200,7 +203,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
model.setUploadFileName(fileName); model.setUploadFileName(fileName);
model.setProjectNumber(model.getRecordDTOS().get(0).getProjectId()); model.setProjectNumber(model.getRecordDTOS().get(0).getProjectId());
model.getRecordDTOS().stream().forEach(e->e.setSequenceNbr(null)); model.getRecordDTOS().stream().forEach(e->e.setSequenceNbr(null));
if (!Objects.isNull(model.getSequenceNbr())){ if (Objects.isNull(model.getSequenceNbr())){
icbcWithholdRecordService.saveBatch(model.getRecordDTOS()); icbcWithholdRecordService.saveBatch(model.getRecordDTOS());
} }
this.saveOrUpdate(model); this.saveOrUpdate(model);
...@@ -217,8 +220,10 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -217,8 +220,10 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
model.getRecordDTOS().forEach(e->{ model.getRecordDTOS().forEach(e->{
e.setSequenceNbr(null); e.setSequenceNbr(null);
e.setBatchNo(batch); e.setBatchNo(batch);
e.setProjectId(projectId);
}); });
icbcWithholdRecordService.saveBatch(model.getRecordDTOS()); icbcWithholdRecordService.saveBatch(model.getRecordDTOS());
model.setProjectNumber(projectId);
model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS())); model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS()));
model.setBatchNo(batch); model.setBatchNo(batch);
model.setUploadStatus(UploadStatusEnum.未生成.getName()); model.setUploadStatus(UploadStatusEnum.未生成.getName());
...@@ -522,7 +527,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -522,7 +527,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
// bizContent.setBatchNo("20241216JO00400005");//批次号 // bizContent.setBatchNo("20241216JO00400005");//批次号
bizContent.setCorpCis("211590000183323"); bizContent.setCorpCis("211590000183323");
// bizContent.setBillNo("1");//序号 // bizContent.setBillNo("1");//序号
bizContent.setTrxDate("2024-12-17");//交易日期 bizContent.setTrxDate(DateUtils.getDateNowShortStr());//交易日期
// bizContent.setBusiCode("14948822"); // bizContent.setBusiCode("14948822");
bizContent.setCurPage("1");//查询页码 bizContent.setCurPage("1");//查询页码
request.setBizContent(bizContent); request.setBizContent(bizContent);
...@@ -536,8 +541,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -536,8 +541,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo()); updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo());
updateWrapper.eq(IcbcWithholdRecord::getOutUserId,e.getBusiCode()); updateWrapper.eq(IcbcWithholdRecord::getOutUserId,e.getBusiCode());
updateWrapper.set(IcbcWithholdRecord::getWithholdStatus,e.getStatus()); updateWrapper.set(IcbcWithholdRecord::getWithholdStatus,UploadStatusEnum.getNodeByCode(e.getStatus()).getName());
updateWrapper.set(IcbcWithholdRecord::getWithholdTime,e.getTrxTime()); updateWrapper.set(IcbcWithholdRecord::getWithholdTime,e.getTrxTime());
updateWrapper.set(IcbcWithholdRecord::getPaymentTime,e.getTrxTime());
icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper); icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper);
}); });
} else { } else {
...@@ -568,4 +574,17 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -568,4 +574,17 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
} }
} }
public void downloadAndSaveZipFile(String fileUrl,String batchNo,String type, HttpServletResponse response) throws Exception {
Path currentWorkingDir = Paths.get("");
Path dirPath = currentWorkingDir.resolve(batchNo);
downloadAndSaveZipFile(fileUrl,dirPath);
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode( batchNo +"-"+type+".zip", "UTF-8"));
unzipAndUpload(dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1),response);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment