Commit 0d6d9e3e authored by chenzhao's avatar chenzhao

工行代扣

parent 3766188a
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 聚富通代扣信息表
*
* @author system_generator
* @date 2024-12-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="IcbcWithholdDto", description=" 聚富通代扣信息表")
public class IcbcWithholdDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "付款目标")
private String paymentTarget;
@ApiModelProperty(value = "项目编号")
private String projectNumber;
@ApiModelProperty(value = "付款总金额")
private String paymentAmount;
@ApiModelProperty(value = "说明")
private String desc;
@ApiModelProperty(value = "确认人员")
private String confirmator;
@ApiModelProperty(value = "确认时间")
private Date confirmationTime;
@ApiModelProperty(value = "上传人员")
private String uploader;
@ApiModelProperty(value = "上传时间")
private Date uploadTime;
@ApiModelProperty(value = "上传文件")
private String uploadFile;
@ApiModelProperty(value = "上传状态")
private String uploadStatus;
@ApiModelProperty(value = "代扣状态")
private String withholdStatus;
@ApiModelProperty(value = "失败原因")
private String errorDesc;
@ApiModelProperty(value = "户主icbcid")
private String icbcId;
@ApiModelProperty(value = "批次号")
private String batchNo;
@ApiModelProperty("所选商户冗余")
private String icbcRecordInfos;
private String uploadFileName;
/**
* 失败原因
*/
private String uploadErrorDesc;
/**
* 失败原因
*/
private String paymentErrorDesc;
@ApiModelProperty(value = "付款信息")
private List<HygfIcbcRecordDTO> recordDTOS;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2024-12-06
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="IcbcWithholdRecordDto", description="")
public class IcbcWithholdRecordDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "农户姓名")
private String custName;
@ApiModelProperty(value = "身份证号")
private String idCard;
private String phone;
@ApiModelProperty(value = "批次号")
private String batchNo;
@ApiModelProperty(value = "聚富通电子账户账号")
private String mediumId;
@ApiModelProperty(value = "项目编号")
private String projectId;
@ApiModelProperty(value = "付款金额")
private int paymentAmount;
@ApiModelProperty(value = "代扣状态")
private String withholdStatus;
@ApiModelProperty(value = "上传时间")
private Date withholdTime;
@ApiModelProperty(value = "缴费时间")
private Date paymentTime;
@ApiModelProperty(value = "缴费开始时间")
private String paymentStartTime;
@ApiModelProperty(value = "缴费结束时间")
private String paymentEndTime;
private String outUserId;
private String amosUserId;
private String regionalCompaniesCode;
/*
* 区域公司名称
* */
private String regionalCompaniesName;
}
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* 聚富通代扣信息表
*
* @author system_generator
* @date 2024-12-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("hygf_icbc_withhold")
public class IcbcWithhold extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 付款目标
*/
@TableField("payment_target")
private String paymentTarget;
/**
* 项目编号
*/
@TableField("project_number")
private String projectNumber;
/**
* 付款金额
*/
@TableField("payment_amount")
private String paymentAmount;
/**
* 说明
*/
@TableField("content")
private String desc;
/**
* 确认人员
*/
@TableField("confirmator")
private String confirmator;
/**
* 确认时间
*/
@TableField("confirmation_time")
private Date confirmationTime;
/**
* 上传人员
*/
@TableField("uploader")
private String uploader;
/**
* 上传时间
*/
@TableField("upload_time")
private Date uploadTime;
/**
* 上传文件
*/
@TableField("upload_file")
private String uploadFile;
/**
* 上传文件生成名称
*/
@TableField("upload_fileName")
private String uploadFileName;
/**
* 上传文件
*/
@TableField("receipt_file")
private String receiptFile;
/**
* 上传状态
*/
@TableField("upload_status")
private String uploadStatus;
/**
* 代扣状态
*/
@TableField("withhold_status")
private String withholdStatus;
/**
* 失败原因
*/
@TableField("upload_error_desc")
private String uploadErrorDesc;
/**
* 失败原因
*/
@TableField("payment_error_desc")
private String paymentErrorDesc;
/**
* 户主icbcid
*/
@TableField("icbc_id")
private String icbcId;
/**
* 批次号
*/
@TableField("batch_no")
private String batchNo;
/**
* 所选商户冗余
*/
@TableField("icbc_record_infos")
private String icbcRecordInfos;
/**
* 付款信息
*/
@TableField(exist = false)
private List<IcbcWithholdRecord> recordDTOS;
}
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2024-12-06
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("hygf_icbc_withhold_record")
public class IcbcWithholdRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 农户姓名
*/
@TableField("cust_name")
private String custName;
/**
* 身份证号
*/
@TableField("id_card")
private String idCard;
/**
* 批次号
*/
@TableField("batch_no")
private String batchNo;
/**
* 聚富通电子账户账号
*/
@TableField("medium_id")
private String mediumId;
/**
* 项目编号
*/
@TableField("project_id")
private String projectId;
/**
* 付款金额
*/
@TableField("payment_amount")
private double paymentAmount;
/**
* 代扣状态
*/
@TableField("withhold_status")
private String withholdStatus;
/**
* 上传时间
*/
@TableField("withhold_time")
private Date withholdTime;
/**
* 缴费时间
*/
@TableField("payment_time")
private Date paymentTime;
/**
* 用户编号
*/
@TableField("out_user_id")
private String outUserId;
/**
* 平台用户id
*/
@TableField("amos_user_id")
private String amosUserId;
/*
* 区域公司code
* */
@TableField("regional_companies_code")
private String regionalCompaniesCode;
/*
* 区域公司名称
* */
@TableField("regional_companies_name")
private String regionalCompaniesName;
/*
*
* */
@TableField("phone")
private String phone;
@TableField(exist = false)
private String openAccountStatusName;
@TableField(exist = false)
private String protocolStatusName;
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithhold;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* 聚富通代扣信息表 Mapper 接口
*
* @author system_generator
* @date 2024-12-02
*/
public interface IcbcWithholdMapper extends BaseMapper<IcbcWithhold> {
public List<IcbcWithholdDto> queryForIcbcWithholdPage( String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc);
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.config.UserEmpower;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordExportDTO;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithholdRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper 接口
*
* @author system_generator
* @date 2024-12-06
*/
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)
List<IcbcWithholdRecordDto> exportTotal(String developerCode, String regionalCompaniesCode, String province, String city, String district, String year, String month, List<String> quarter, @Param("dto")IcbcWithholdRecordDto dto);
}
package com.yeejoin.amos.boot.module.hygf.api.service;
/**
* 接口类
*
* @author system_generator
* @date 2024-12-06
*/
public interface IIcbcWithholdRecordService {
}
package com.yeejoin.amos.boot.module.hygf.api.service;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithhold;
import java.io.IOException;
/**
* 聚富通代扣信息表接口类
*
* @author system_generator
* @date 2024-12-02
*/
public interface IIcbcWithholdService {
void fileGeneration(IcbcWithhold model) throws IllegalAccessException, IOException, Exception;
void removeDataById(Long sequenceNbr, String uploader);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdMapper">
<select id="queryForIcbcWithholdPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdDto">
select *,
content as desc
from hygf_icbc_withhold
<where>
is_delete = 0
<if test="uploader != null and uploader != ''">
and uploader like concat('%',#{uploader},'%')
</if>
<if test="uploadStartTime != null and uploadStartTime != ''">
and upload_time > #{uploadStartTime}
</if>
<if test="uploadEndTime != null and uploadEndTime != ''">
and upload_time <![CDATA[<]]> #{uploadEndTime}
</if>
<if test="uploadStatus != null and uploadStatus != ''">
and upload_status = #{uploadStatus}
</if>
<if test="confirmator != null and confirmator != ''">
and confirmator like concat('%',#{confirmator},'%')
</if>
<if test="desc != null and desc != ''">
and uploader like concat('%',#{desc},'%')
</if>
<if test="confirmationStartTime != null and confirmationStartTime != ''">
and confirmation_time > #{confirmationStartTime}
</if>
<if test="confirmationEndTime != null and confirmationEndTime != ''">
and confirmation_time <![CDATA[<]]> #{confirmationEndTime}
</if>
</where>
order by hygf_icbc_withhold.sequence_nbr desc
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdRecordMapper">
<!-- <select id="exportTotal" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto">-->
<!-- SELECT-->
<!-- re.*-->
<!-- FROM hygf_icbc_withhold_record re-->
<!-- LEFT JOIN `hygf_peasant_household` ph ON re.amos_user_id = ph.amos_user_id-->
<!-- <where>-->
<!-- <if test="developerCode != null and developerCode != ''">-->
<!-- AND ph.developer_code = #{developerCode}-->
<!-- </if>-->
<!-- <if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">-->
<!-- AND ph.regional_companies_code = #{regionalCompaniesCode}-->
<!-- </if>-->
<!-- <if test="province != null and province != ''">-->
<!-- AND ph.project_address LIKE CONCAT ('%',#{province},'%')-->
<!-- </if>-->
<!-- <if test="city != null and city != ''">-->
<!-- AND ph.project_address LIKE CONCAT ('%',#{city},'%')-->
<!-- </if>-->
<!-- <if test="district != null and district != ''">-->
<!-- AND ph.project_address LIKE CONCAT ('%',#{district},'%')-->
<!-- </if>-->
<!-- <if test="year != null and year != ''">-->
<!-- AND EXTRACT(YEAR FROM re.withhold_time) = #{year}-->
<!-- </if>-->
<!-- <if test="month != null and month != ''">-->
<!-- AND EXTRACT(MONTH FROM re.withhold_time) = #{month}-->
<!-- </if>-->
<!-- <if test="quarter != null and quarter.size() > 1">-->
<!-- AND ph.withhold_time BETWEEN <foreach collection="quarter" item="item" separator="and">-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="dto.amosUserId != null and dto.amosUserId != ''">-->
<!-- AND re.amos_user_id = #{dto.amosUserId}-->
<!-- </if>-->
<!-- <if test="dto.batchNo != null and dto.batchNo != ''">-->
<!-- AND re.batch_no = #{dto.batchNo}-->
<!-- </if>-->
<!-- <if test="dto.paymentStartTime != null and dto.paymentStartTime != ''">-->
<!-- AND re.payment_time > #{dto.paymentStartTime}-->
<!-- </if>-->
<!-- <if test="dto.paymentEndTime != null and dto.paymentEndTime != ''">-->
<!-- AND re.payment_time &amp;lt #{dto.paymentEndTime}-->
<!-- </if>-->
<!-- </where>-->
<!-- GROUP BY-->
<!-- re.sequence_nbr-->
<!-- </select>-->
<select id="exportTotal" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto">
SELECT
re.*
FROM
(
SELECT
amos_user_id,
MAX(developer_code) AS developer_code,
MAX(regional_companies_code ) AS regional_companies_code ,
MAX(is_delete) AS is_delete,
MAX(owners_name) AS owners_name,
MAX(telephone) AS telephone,
MAX(id_card) AS id_card,
MAX(regional_companies_name) AS regional_companies_name,
MAX(project_address) AS project_address,
MAX(rec_date) AS rec_date
FROM hygf_peasant_household GROUP BY amos_user_id
) ph
LEFT JOIN hygf_icbc_withhold_record re ON ph.amos_user_id = re.amos_user_id
<where>
ph.is_delete = 0
<if test="developerCode != null and developerCode != ''">
AND ph.developer_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND ph.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="province != null and province != ''">
AND ph.project_address LIKE CONCAT ('%',#{province},'%')
</if>
<if test="city != null and city != ''">
AND ph.project_address LIKE CONCAT ('%',#{city},'%')
</if>
<if test="district != null and district != ''">
AND ph.project_address LIKE CONCAT ('%',#{district},'%')
</if>
<if test="year != null and year != ''">
AND EXTRACT(YEAR FROM re.withhold_time) = #{year}
</if>
<if test="month != null and month != ''">
AND EXTRACT(MONTH FROM re.withhold_time) = #{month}
</if>
<if test="quarter != null and quarter.size() > 1">
AND ph.withhold_time BETWEEN <foreach collection="quarter" item="item" separator="and">
</foreach>
</if>
<if test="dto.amosUserId != null and dto.amosUserId != ''">
AND re.amos_user_id = #{dto.amosUserId}
</if>
<if test="dto.batchNo != null and dto.batchNo != ''">
AND re.batch_no = #{dto.batchNo}
</if>
<if test="dto.paymentStartTime != null and dto.paymentStartTime != ''">
AND re.payment_time > #{dto.paymentStartTime}
</if>
<if test="dto.paymentEndTime != null and dto.paymentEndTime != ''">
AND re.payment_time <![CDATA[<]]> #{dto.paymentEndTime}
</if>
</where>
ORDER BY
re.rec_date DESC
</select>
</mapper>
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordDTO;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithhold;
import com.yeejoin.amos.boot.module.hygf.api.util.CommonResponseNewUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.io.IOException;
import java.util.List;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.IcbcWithholdServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
* 聚富通代扣信息表
*
* @author system_generator
* @date 2024-12-02
*/
@RestController
@Api(tags = " 聚富通代扣信息表Api")
@RequestMapping(value = "/icbc-withhold")
public class IcbcWithholdController extends BaseController {
@Autowired
IcbcWithholdServiceImpl icbcWithholdServiceImpl;
/**
* 新增 聚富通代扣信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增 聚富通代扣信息表", notes = "新增 聚富通代扣信息表")
public ResponseModel save(@RequestBody IcbcWithhold model) {
icbcWithholdServiceImpl.saveRecord(model);
return CommonResponseNewUtil.success();
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新 聚富通代扣信息表", notes = "根据sequenceNbr更新 聚富通代扣信息表")
public ResponseModel<IcbcWithholdDto> updateBySequenceNbrIcbcWithhold(@RequestBody IcbcWithholdDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(icbcWithholdServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/delete/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr删除 聚富通代扣信息表", notes = "根据sequenceNbr删除 聚富通代扣信息表")
public ResponseModel deleteBySequenceNbr(@PathVariable(value = "sequenceNbr") Long sequenceNbr, @RequestParam(value = "batchNo") String batchNo){
icbcWithholdServiceImpl.removeDataById(sequenceNbr,batchNo);
return CommonResponseNewUtil.success();
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个 聚富通代扣信息表", notes = "根据sequenceNbr查询单个 聚富通代扣信息表")
public ResponseModel<IcbcWithholdDto> selectOne(@PathVariable Long sequenceNbr) {
IcbcWithholdDto icbcWithholdDto = icbcWithholdServiceImpl.queryBySeq(sequenceNbr);
icbcWithholdDto.setRecordDTOS(JSONArray.parseArray(icbcWithholdDto.getIcbcRecordInfos(), HygfIcbcRecordDTO.class));
return ResponseHelper.buildResponse(icbcWithholdDto);
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询")
public ResponseModel<Page<IcbcWithholdDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "uploader",required = false) String uploader,
@RequestParam(value = "uploadStartTime",required = false) String uploadStartTime,
@RequestParam(value = "uploadEndTime",required = false) String uploadEndTime,
@RequestParam(value = "uploadStatus",required = false) String uploadStatus,
@RequestParam(value = "confirmator",required = false) String confirmator,
@RequestParam(value = "confirmationStartTime",required = false) String confirmationStartTime,
@RequestParam(value = "confirmationEndTime",required = false) String confirmationEndTime,
@RequestParam(value = "desc",required = false) String desc) {
return ResponseHelper.buildResponse(icbcWithholdServiceImpl.queryForIcbcWithholdPage(current,size,uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc));
} /**
* 列表分页查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/test")
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表分页查询", notes = " 聚富通代扣信息表分页查询")
public ResponseModel<Page<IcbcWithholdDto>> test() {
icbcWithholdServiceImpl.upIcbcWithholdRecordWithholdStatus();
return ResponseHelper.buildResponse(null);
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息表列表全部数据查询", notes = " 聚富通代扣信息表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<IcbcWithholdDto>> selectForList() {
return ResponseHelper.buildResponse(icbcWithholdServiceImpl.queryForIcbcWithholdList());
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = " 聚富通代扣信息文件生成", notes = " 聚富通代扣信息文件生成")
@PostMapping(value = "/fileGeneration")
public ResponseModel fileGeneration(@RequestBody IcbcWithhold model ) throws Exception {
icbcWithholdServiceImpl.fileGeneration(model);
return CommonResponseNewUtil.success();
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息文件上传", notes = " 聚富通代扣信息文件上传")
@GetMapping(value = "/sftpUploadAndUnzip")
public ResponseModel sftpUploadAndUnzip( String fileUrl,String batchNo ) throws Exception {
ReginParams reginParams = getSelectedOrgInfo();
icbcWithholdServiceImpl.sftpUploadAndUnzip(fileUrl,batchNo,reginParams.getUserModel().getRealName());
return CommonResponseNewUtil.success();
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息回盘文件获取", notes = " 聚富通代扣信息回盘文件获取")
@GetMapping(value = "/downLoadicbcFile")
public ResponseModel<String> downLoadicbcFile( Long sequenceNbr,String batchNo ) throws Exception {
return ResponseHelper.buildResponse(icbcWithholdServiceImpl.downLoadicbcFile(batchNo,sequenceNbr));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = " 聚富通代扣信息回盘文件获取", notes = " 聚富通代扣信息回盘文件获取")
@GetMapping(value = "/updateWithholdStatus")
public ResponseModel updateWithholdStatus( ) throws Exception {
icbcWithholdServiceImpl.updateWithholdStatus();
return CommonResponseNewUtil.success();
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "POST",value = "批次人员信息下载", notes = "批次人员信息下载")
@PostMapping(value = "/export")
public void downTemplate(HttpServletResponse response, @RequestBody IcbcWithhold model ) {
icbcWithholdServiceImpl.exportData(response,model);
}
}
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
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.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
*
*
* @author system_generator
* @date 2024-12-06
*/
@RestController
@Api(tags = "Api")
@RequestMapping(value = "/icbc-withhold-record")
public class IcbcWithholdRecordController extends BaseController {
@Autowired
IcbcWithholdRecordServiceImpl icbcWithholdRecordServiceImpl;
/**
* 新增
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增", notes = "新增")
public ResponseModel<IcbcWithholdRecordDto> save(@RequestBody IcbcWithholdRecordDto model) {
model = icbcWithholdRecordServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IcbcWithholdRecordDto> updateBySequenceNbrIcbcWithholdRecord(@RequestBody IcbcWithholdRecordDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除", notes = "根据sequenceNbr删除")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个")
public ResponseModel<IcbcWithholdRecordDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/page")
@ApiOperation(httpMethod = "POST",value = "分页查询", notes = "分页查询")
@UserLimits
public ResponseModel<Page<IcbcWithholdRecordDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestBody IcbcWithholdRecordDto dto) {
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.queryForIcbcWithholdRecordPage(current,size,dto));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<IcbcWithholdRecordDto>> selectForList() {
return ResponseHelper.buildResponse(icbcWithholdRecordServiceImpl.queryForIcbcWithholdRecordList());
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.hygf.api.dto.HistoryPeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordExportDTO;
import com.yeejoin.amos.boot.module.hygf.api.entity.FinancingRegional;
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.service.IIcbcWithholdRecordService;
import com.yeejoin.amos.boot.module.hygf.api.dto.IcbcWithholdRecordDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 服务实现类
*
* @author system_generator
* @date 2024-12-06
*/
@Service
public class IcbcWithholdRecordServiceImpl extends BaseService<IcbcWithholdRecordDto,IcbcWithholdRecord,IcbcWithholdRecordMapper> implements IIcbcWithholdRecordService {
/**
* 分页查询
*/
@Autowired
IcbcWithholdRecordMapper icbcWithholdRecordMapper;
public Page<IcbcWithholdRecordDto> queryForIcbcWithholdRecordPage(int current,int size,IcbcWithholdRecordDto dto) {
Page<IcbcWithholdRecordDto> page = new Page<>();
PageHelper.startPage(current,size);
List<IcbcWithholdRecordDto> dtos = icbcWithholdRecordMapper.exportTotal(null, null, null, null, null,null,null,null,dto);
PageInfo<IcbcWithholdRecordDto> pageInfo = new PageInfo<>(dtos);
page.setSize(pageInfo.getSize());
page.setCurrent(pageInfo.getPageNum());
page.setTotal(pageInfo.getTotal());
page.setRecords(dtos);
return page;
}
/**
* 列表查询 示例
*/
public List<IcbcWithholdRecordDto> queryForIcbcWithholdRecordList() {
return this.queryForList("" , false);
}
public void exportData(HttpServletResponse response, String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,List<String> quarter ){
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarter,null);
if (CollectionUtil.isNotEmpty(dtos)){
ExcelUtil.createTemplate(response,"结算金额","结算金额",dtos, IcbcWithholdRecordDto.class,null,false);
}
}
public Map<String, Object> paymentAmount(String developerCode, String regionalCompaniesCode, String province, String city, String district,String year,String month,List<String> quarter ){
List<IcbcWithholdRecordDto> dtos = this.getBaseMapper().exportTotal(developerCode, regionalCompaniesCode, province, city, district,year,month,quarter,null);
int totalPaymentAmount = dtos.stream()
.mapToInt(IcbcWithholdRecordDto::getPaymentAmount)
.sum();
Map<String, Object> paymentAmount = MapBuilder.<String, Object>create().put("paymentAmount", totalPaymentAmount).build();
return paymentAmount;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
import com.icbc.api.IcbcConstants;
import com.icbc.api.request.JftApiPayFeewithholdQuerydetailRequestV1;
import com.icbc.api.response.JftApiPayFeewithholdQuerydetailResponseV1;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.hygf.api.Enum.UploadStatusEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.*;
import com.yeejoin.amos.boot.module.hygf.api.entity.HistoryPeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithhold;
import com.yeejoin.amos.boot.module.hygf.api.entity.IcbcWithholdRecord;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdMapper;
import com.yeejoin.amos.boot.module.hygf.api.mapper.IcbcWithholdRecordMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IIcbcWithholdService;
import com.yeejoin.amos.boot.module.hygf.api.util.RSASignUtils;
import com.yeejoin.amos.boot.module.hygf.api.util.SFTPUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static com.yeejoin.amos.boot.biz.common.utils.WordConverterUtils.fileToMultipartFile;
import static com.yeejoin.amos.boot.biz.common.utils.WordConverterUtils.fileToMultipartFileZip;
import static com.yeejoin.amos.boot.module.hygf.api.util.FileUtils.addFileToZip;
import static com.yeejoin.amos.boot.module.hygf.api.util.FileUtils.cleanup;
/**
* 聚富通代扣信息表服务实现类
*
* @author system_generator
* @date 2024-12-02
*/
@Service
public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWithhold,IcbcWithholdMapper> implements IIcbcWithholdService {
private static final Logger logger = LoggerFactory.getLogger(IcbcWithholdServiceImpl.class);
@Value("${icbc.Withhold.projectId}")
private String projectId;
@Value("${icbc.Withhold.corpCis}")
private String corpCis;
@Value("${icbc.Withhold.partner.identification}")
public String partnerIdentification;
@Value("${icbc.Withhold.outVendorId}")
public String outVendorId;
@Value("${icbc.Withhold.sftpIp}")
public String sftpIp;
@Value("${icbc.Withhold.sftpPort}")
public int sftpPort;
@Value("${icbc.Withhold.sftpUserName}")
public String sftpUserName;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
private static int sequence = 0; // 当天的序列号
private static String uploadPath = "/JftFeeWithhold/upload"; // 上传地址
private static String downLoadPath = "/JftFeeWithhold/download"; // 下载地址
private static String file ="";
//private static String file ="amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/";
private static LocalDate lastDate = LocalDate.now(); // 上次生成批次号的日期
@Value("${urlHttp}")
private String urlPath;
@Autowired
private IcbcWithholdRecordServiceImpl icbcWithholdRecordService;
/**
* 分页查询
*/
public Page<IcbcWithholdDto> queryForIcbcWithholdPage(Page<IcbcWithholdDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<IcbcWithholdDto> queryForIcbcWithholdList() {
return this.queryForList("" , false);
}
/**
* 生成文件
*
*/
public void fileGeneration(IcbcWithhold model) throws Exception {
model.setUploadStatus(UploadStatusEnum.未上传.getName());
int billNo = 0;
int totalAmt = 0;
//生成批次号 若已从保存生成取原有批次号
String batchNo = StringUtil.isEmpty(model.getBatchNo())?generateBatchNumber():model.getBatchNo();
String loopField = "";
//判断接口调用来源 不为空时说明是先保存后在列表按钮上生成 可直取冗余数据
if (StringUtils.isNotEmpty(model.getIcbcRecordInfos())){
model.setRecordDTOS(JSONArray.parseArray(model.getIcbcRecordInfos(),IcbcWithholdRecord.class));
}
//生成循环行数据
for (IcbcWithholdRecord recordDTO : model.getRecordDTOS()) {
WithholdLoopField withholdLoopField = new WithholdLoopField();
withholdLoopField.setBillNo(++billNo);
recordDTO.setBatchNo(batchNo);
withholdLoopField.setBusiCode(recordDTO.getOutUserId());
withholdLoopField.setBusiAcct(recordDTO.getMediumId());
withholdLoopField.setBusiName(recordDTO.getCustName());
withholdLoopField.setBillDate(DateUtils.getDateNowShortNumberN());
withholdLoopField.setCaptAmount((int)(recordDTO.getPaymentAmount()*100));
totalAmt += (int)(recordDTO.getPaymentAmount()*100);
loopField += toEscapedString(withholdLoopField);
}
//生成第一行数据
WithholdFirstLinkField firstLinkField = new WithholdFirstLinkField();
firstLinkField.setTotalNum(model.getRecordDTOS().size());
firstLinkField.setTotalAmt(totalAmt);
firstLinkField.setBatchNo(batchNo);
firstLinkField.setCorpCis(corpCis);
firstLinkField.setProjectId(projectId);
String firstLink = toEscapedString(firstLinkField);
firstLink+=loopField;
String fileName ="gxjr"+"-"+projectId+"-ENTRUST-"+batchNo;
Path currentWorkingDir = Paths.get("");
Path dirPath = currentWorkingDir.resolve(batchNo);
System.out.println("Current working directory: " + System.getProperty("user.dir"));
writeStringToFile(firstLink,dirPath.toString()+"/"+fileName+".bin");
com.yeejoin.amos.boot.module.hygf.api.util.FileUtils.save2File(
dirPath.toString()+"/"+fileName+".sign",
RSASignUtils.signWithByte_New( com.yeejoin.amos.boot.module.hygf.api.util.FileUtils.toByteArray(dirPath.toString()+"/"+fileName+".bin"),
RSASignUtils .loadPrivateKey(file+"secretKey/pkcs8.pem")));
//String sign = RSASignUtils.sign(firstLink, RSASignUtils.loadPrivateKey(file+"secretKey/pkcs8.pem"));
//生成upload需上传的三个文件
//writeStringToFile(sign,dirPath.toString()+"/"+fileName+".sign");
String checkFile = createCheckFile(fileName,batchNo);
writeStringToFile(checkFile,dirPath.toString()+"/"+fileName+".check");
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(dirPath.toString() + "/" + fileName + ".zip"))) {
addFileToZip(dirPath.toString() + "/" + fileName + ".bin", fileName + ".bin", zos);
addFileToZip(dirPath.toString() + "/" + fileName + ".sign", fileName + ".sign", zos);
addFileToZip(dirPath.toString() + "/" + fileName + ".check", fileName + ".check", zos);
MultipartFile multipartFile = fileToMultipartFile(new File(dirPath.toString() + "/" + fileName + ".zip"));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
if (result != null) {
for (String url : result.getResult().keySet()) {
model.setUploadFile(url);
}
}
} catch (IOException e) {
model.setUploadStatus(UploadStatusEnum.未生成.getName());
e.printStackTrace();
model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS()));
model.setBatchNo(batchNo);
this.saveOrUpdate(model);
} finally {
cleanup(dirPath);
}
model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS()));
model.setBatchNo(batchNo);
model.setUploadFileName(fileName);
model.setProjectNumber(model.getRecordDTOS().get(0).getProjectId());
model.getRecordDTOS().stream().forEach(e->e.setSequenceNbr(null));
if (!Objects.isNull(model.getSequenceNbr())){
icbcWithholdRecordService.saveBatch(model.getRecordDTOS());
}
this.saveOrUpdate(model);
}
/**
* 生成文件
*
*/
public void saveRecord(IcbcWithhold model) {
String batch = generateBatchNumber();
model.getRecordDTOS().forEach(e->{
e.setSequenceNbr(null);
e.setBatchNo(batch);
});
icbcWithholdRecordService.saveBatch(model.getRecordDTOS());
model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS()));
model.setBatchNo(batch);
model.setUploadStatus(UploadStatusEnum.未生成.getName());
this.saveOrUpdate(model);
}
public String createCheckFile(String filePath,String batchNo) throws Exception {
long binSize = getFileSize(batchNo + "/" + filePath + ".bin");
long signSize = getFileSize(batchNo + "/" + filePath + ".sign");
Map<String, Object> build = MapBuilder.<String, Object>create().put("sourceFile", filePath + ".bin")
.put("sourceFileSize", binSize).put("signFile", filePath + ".sign").put("signFileSize", signSize).put("remark", "bin格式文件").build();
Map<String, Object> fileInfo = MapBuilder.<String, Object>create().put("fileInfo", build).build();
return JSON.toJSONString(fileInfo);
}
public static String toEscapedString(Object obj) throws IllegalAccessException {
StringBuilder sb = new StringBuilder();
Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true); // 设置为可访问
Object value = field.get(obj);
if (value == null || (value instanceof String && ((String) value).isEmpty())) {
sb.append((char) 27); // 使用 char(27) 作为分隔符
} else {
sb.append(value).append((char) 27); // 添加字段后跟分隔符
}
}
sb.append('\r');
sb.append('\n'); // 每条记录以回车结束
return sb.toString();
}
public synchronized String generateBatchNumber() {
LocalDate currentDate = LocalDate.now();
// 如果是新的一天,重置序列号
if (!currentDate.equals(lastDate)) {
sequence = 0;
lastDate = currentDate;
}
// 生成8位日期
String datePart = currentDate.format(DATE_FORMATTER);
// 生成5位序列号
String sequencePart = String.format("%05d", sequence++);
// 拼接成完整的批次号
return datePart + partnerIdentification + sequencePart;
}
public static void writeStringToFile(String content, String filename) throws IOException {
createDirectoryIfNotExists(filename);
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "GBK"))) {
writer.write(content);
}
}
/**
* 确保文件所在的目录存在,如果不存在则创建。
*
* @param filename 包含完整路径的文件名
* @throws IOException 如果创建目录失败
*/
public static void createDirectoryIfNotExists(String filename) throws IOException {
File file = new File(filename);
File parentDir = file.getParentFile();
if (parentDir != null && !parentDir.exists()) {
if (!parentDir.mkdirs()) {
throw new IOException("Failed to create directory: " + parentDir.getAbsolutePath());
}
}
}
public static long getFileSize(String filePath) throws Exception {
Path path = Paths.get(filePath);
return Files.size(path);
}
public void downloadAndSaveZipFile(String fileUrl, Path savePath) {
try (InputStream in = new URL(urlPath+"/"+fileUrl).openStream()) {
String fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
// String fileName = savePath.toString();
if (!fileName.toLowerCase().endsWith(".zip")) {
throw new IllegalArgumentException("The provided URL does not point to a ZIP file.");
}
Path zipPath = savePath.resolve(fileName);
FileUtils.copyInputStreamToFile(in, zipPath.toFile());
System.out.println("ZIP file downloaded and saved to: " + zipPath);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
public String downLoadicbcFile(String batchNo,Long sequenceNbr) throws Exception {
IcbcWithhold model = this.getBaseMapper().selectById(sequenceNbr);
if (StringUtils.isNotEmpty(model.getReceiptFile())){
return model.getReceiptFile();
}
String path = new ClassPathResource(file+"secretKey/login-gxjrid_rsa").getPath();
SFTPUtil sftp = new SFTPUtil(sftpIp, sftpPort,
sftpUserName,
path, null);
logger.info(String.valueOf(new StringBuffer().append("服务器地址: ")
.append(sftp.getHostName()).append(" 端口:")
.append(sftp.getPort()).append("用户名:")
.append(sftp.getUserName()).append("密钥文件:")
.append(sftp.getPriKeyFile())));
sftp.priKeyConnect();
Path currentWorkingDir = Paths.get("");
Path dirPath = currentWorkingDir.resolve(batchNo);
if (sftp.isExist(downLoadPath)) {
sftp.downloadAndZipFiles(downLoadPath,batchNo,dirPath.toString()+"/"+batchNo+".zip");
logger.info("文件下载成功");
}
try {
MultipartFile multipartFile = fileToMultipartFile(new File(dirPath.toString() + "/" + batchNo + ".zip"));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
if (result != null) {
for (String url : result.getResult().keySet()) {
model.setReceiptFile(url);
}
this.saveOrUpdate(model);
}
} catch ( Exception e) {
logger.error("平台上传文件失败");
e.printStackTrace();
} finally {
cleanup(dirPath);
}
return model.getReceiptFile();
}
@Scheduled(cron = "${withholdStatusCron}")
public void updateWithholdStatus() throws Exception {
//获取所有已上传但代扣状态为空的数据
LambdaQueryWrapper<IcbcWithhold> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcbcWithhold::getUploadStatus,UploadStatusEnum.已上传.getName());
wrapper.isNull(IcbcWithhold::getWithholdStatus);
List<IcbcWithhold> icbcWithholds = this.getBaseMapper().selectList(wrapper);
String path = new ClassPathResource(file+"secretKey/登录-gxjrid_rsa").getPath();
SFTPUtil sftp = new SFTPUtil(sftpIp, sftpPort,
sftpUserName,
path, null);
logger.info(String.valueOf(new StringBuffer().append("服务器地址: ")
.append(sftp.getHostName()).append(" 端口:")
.append(sftp.getPort()).append("用户名:")
.append(sftp.getUserName()).append("密钥文件:")
.append(sftp.getPriKeyFile())));
sftp.priKeyConnect();
if (sftp.isExist(uploadPath)) {
//修改上传失败的状态
List<Map<String, Object>> allFailureFilesContentAsJson = sftp.getAllFailureFilesContentAsJson(uploadPath);
allFailureFilesContentAsJson.forEach(e->{
icbcWithholds.forEach(i->{
if (e.get("fileName").toString().contains(i.getBatchNo())){
IcbcWithhold icbcWithhold = new IcbcWithhold();
BeanUtil.copyProperties(e,icbcWithhold);
icbcWithhold.setUploadErrorDesc(JSON.toJSONString(e));
icbcWithhold.setUploadStatus(UploadStatusEnum.失败.getName());
this.saveOrUpdate(icbcWithhold);
}
});
});
//修改上传成功的状态
List<String> successFilesContentAsJson = sftp.getAllSuccessFilesContentAsJson(uploadPath);
if (CollectionUtil.isNotEmpty(successFilesContentAsJson)){
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(IcbcWithhold::getBatchNo,successFilesContentAsJson);
updateWrapper.set(IcbcWithhold::getUploadStatus,UploadStatusEnum.成功.getName());
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.代扣处理中.getName());
this.getBaseMapper().update(null,updateWrapper);
}
}
this.upIcbcWithholdRecordWithholdStatus();
if (sftp.isExist(downLoadPath)) {
//获取回盘文件扣款状态
List<ResultLinkField> files = sftp.getAllResultFilesContentAsJson(downLoadPath);
for (ResultLinkField resultLinkField : files) {
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
if (resultLinkField.getStatus().equals("1")) {
updateWrapper.set(IcbcWithhold::getPaymentErrorDesc,resultLinkField.getErrMsg());
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.失败.getName());
}else {
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.成功.getName());
}
updateWrapper.eq(IcbcWithhold::getBatchNo,resultLinkField.getBatchNo());
this.getBaseMapper().update(null,updateWrapper);
}
}
}
/**
*
* @param fileUrl 文件url地址
* @param batchNo 批次号
*/
public void sftpUploadAndUnzip(String fileUrl,String batchNo,String uploader ) {
Path currentWorkingDir = Paths.get("");
Path dirPath = currentWorkingDir.resolve(batchNo);
try {
String path = new ClassPathResource(file+"secretKey/登录-gxjrid_rsa").getPath();
System.out.println("aaaaaaaaaaaaaaaa"+path);
SFTPUtil sftp = new SFTPUtil(sftpIp, sftpPort,
sftpUserName,
path, null);
logger.info(String.valueOf(new StringBuffer().append("服务器地址: ")
.append(sftp.getHostName()).append(" 端口:")
.append(sftp.getPort()).append("用户名:")
.append(sftp.getUserName()).append("密钥文件:")
.append(sftp.getPriKeyFile())));
sftp.priKeyConnect();
// 服务器文件存放路径
downloadAndSaveZipFile(fileUrl,dirPath);
if (sftp.isExist(uploadPath)) {
// sftp.uploadAndUnzip(uploadPath, "testupload.zip", dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1));
sftp.unzipAndUpload(uploadPath, dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1));
logger.info("上传并解压成功");
//修改代扣信息表状态
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcbcWithhold::getBatchNo,batchNo);
updateWrapper.set(IcbcWithhold::getUploadStatus,UploadStatusEnum.已上传.getName());
updateWrapper.set(IcbcWithhold::getUploader,uploader);
updateWrapper.set(IcbcWithhold::getUploadTime,new Date());
this.getBaseMapper().update(null,updateWrapper);
}
} catch (Exception e) {
logger.error("异常信息:" + e.getMessage());
}finally {
cleanup(dirPath);
}
}
public void removeDataById(Long sequenceNbr,String batchNo) {
LambdaUpdateWrapper<IcbcWithhold> icbcWithholdUp = new LambdaUpdateWrapper<>();
icbcWithholdUp.set(BaseEntity::getIsDelete,"1");
icbcWithholdUp.eq(BaseEntity::getSequenceNbr,sequenceNbr);
this.getBaseMapper().update(null ,icbcWithholdUp);
LambdaUpdateWrapper<IcbcWithholdRecord> icbcWithholdRecordUp = new LambdaUpdateWrapper<>();
icbcWithholdRecordUp.set(BaseEntity::getIsDelete,"1");
icbcWithholdRecordUp.eq(IcbcWithholdRecord::getBatchNo,batchNo);
icbcWithholdRecordService.getBaseMapper().update(null ,icbcWithholdRecordUp);
}
public Page<IcbcWithholdDto> queryForIcbcWithholdPage(int current, int size, String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc) {
Page<IcbcWithholdDto> page = new Page<>();
PageHelper.startPage(current,size);
List<IcbcWithholdDto> icbcWithholdDtos = this.getBaseMapper().queryForIcbcWithholdPage(uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc);
PageInfo<IcbcWithholdDto> pageInfo = new PageInfo<>(icbcWithholdDtos);
page.setSize(pageInfo.getSize());
page.setCurrent(pageInfo.getPageNum());
page.setTotal(pageInfo.getTotal());
page.setRecords(icbcWithholdDtos);
return page;
}
public void upIcbcWithholdRecordWithholdStatus() {
LambdaQueryWrapper<IcbcWithhold> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcbcWithhold::getUploadStatus,UploadStatusEnum.成功.getCode());
wrapper.eq(IcbcWithhold::getWithholdStatus,UploadStatusEnum.代扣处理中.getCode());
List<String> batchNos = this.getBaseMapper().selectList(wrapper).stream()
.map(IcbcWithhold::getBatchNo)
.collect(Collectors.toList());;
String APP_ID = "11000000000000028870";
String MY_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDAlcIeANdqipul3/qAIRlknSacHiFCMzLzUJisGcr9ipm3p2rir8WDsac2MxgtUt+f89SGNoWyjv4q0/QAKQQTd5U3KuGAksCJLBGVibuFe7G7YGYVezUksjvocvp8GIinCIkzq67KL2SOpGXAu3s+282rx8AxdTZA/EhXQvbORbWz5+DamyY+wS7Maa8KmIOb6WZPtiXgENZxDHAafrqW8Gt1BnVfJNf5yS5J9Wl+LcR1EPvi5iH8dSIdn1ZMVupoREjV/DvItSogVehsqTRZWuekAo2xH9YEli1UMG/l3deViRn/A4VmPPzdv0xXpn/yO+OTjWez+KmSmJfAZXBvAgMBAAECggEABRYviWFWTz8X+1qeIDI/nHO2KFt3X2tAxkJztd/8h5PYmYw3e4NPATp5Ayp4UgIlW/ExxNW91EiImBL/F939eJIpA8sDJ8U4hqb+U+fOZyksOZnDOIAHmE+I24vl588yFM9Z6F55gGeeDVJ0SZHqIG/nz8i339aLt02yj3N6V1peQugBP6L9arcD+gVu4F70whkqW+lHBK/WzX1OazqEx3Ip175jqzi9/0vO/h/kqnGGXuMi2VeuAPsa+d0a6lf/FScxqCt3t6dCkJ5DPA1MCj81dPi5ZfCM/vE0N8I6LEV+RyC7bb4YVO/PoicFjb2j8vfLvldOUrsvkNH51dZusQKBgQDpMHacOBpIuVzEFfNtS9SgA96cUV6NCSmHoQppJ/p9xKzY4DpcqoOCIBT4WCvVe6PeN5mrjzt8Q5gJWxiq0tVgIF9k8GjLmuiJ2v4Qh8aUmlRwn0T0DYiX/Y7uzX+pRlkpoKrSktlTOT9vmGwZDGDk0h2+H3hZ3YQEucfA6bhHmQKBgQDTbHrbr1WsUR9lrdLaGi/Uphpl3BXLuCnJXav3yIZOktO5V68MfPZXLP7aaNtbK3n0YHD+Uv8wpHBBSWQYjVYlGdvlniA/W1pr73GZJECFfS1BmmFC4GG3E92D5IkmrcPlUuz8XxKrlwHnfW1F0MoDvhp930vS0tS6u+WYTt9dRwKBgCeEQPVkRIACeYf5OFFTQmsDfNv8pgs8fD8xuTPsxHQ/uhLenMVLWBHbIfKb7oG0/CYSQgZitW/vfHpJZ7q7E9HAaqoOW5P1YmbKJ7fhanOQW7LiKqs5B+bJ30j0piendkCpq4kXvaBu2SMuL1NnV5wvRz8K0jhYY6DxYrp8YPAxAoGAZxWTaZ25tgTvvBHeprzx6Ur7wAJpFiU7KpVjjbLV2WW5mbro/LvJGIQ11qQdn/w4wDBtp3MsPblPimWQSnBPOlO7Zd+NdZbDJbFfv/1vACcic8Qj/AmPW0ZyUSaSwKskwqGGLx7j6Yn9QbNkHhBJDz4XiJvhSm/FjS6kKXj7a20CgYEArnEiPmL5g1Ca/qKK9ql8Q6P9gipIfGGpaFu23y0trbcFpVn8Oos/ic0Jgw4Xiz+rqvb6bW2V6lqBJ+9/kdn0i7zlZxKNpYsW2xFgi04OU3d5HkGL16Y1rpqMYYEhjFaOIn7J8P046UYR99yaybgQd18TE6oFrX8OL5uY8M4ge4Y=";
String icbcPulicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB";
String AES_Key = "nuCVNzIxOTHZWv8YjEeYQA==";
DefaultIcbcClient client = new DefaultIcbcClient(APP_ID,
IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY, IcbcConstants.CHARSET_UTF8,
IcbcConstants.FORMAT_JSON,
icbcPulicKey, IcbcConstants.ENCRYPT_TYPE_AES, AES_Key, null, null);
JftApiPayFeewithholdQuerydetailRequestV1 request = new
JftApiPayFeewithholdQuerydetailRequestV1();
String host = "https://gw.open.icbc.com.cn";
request.setServiceUrl(host + "/api/jft/api/pay/feewithhold/querydetail/V1");
JftApiPayFeewithholdQuerydetailRequestV1.JftApiPayFeewithholdQuerydetailRequestV1Biz bizContent = new
JftApiPayFeewithholdQuerydetailRequestV1.JftApiPayFeewithholdQuerydetailRequestV1Biz();
bizContent.setAppId(APP_ID);//平台商户标识
bizContent.setOutVendorId("gxjr");//子商户编号
bizContent.setProjectId("PJ140014023565102203");//缴费项目编号
// bizContent.setBatchNo("20241216JO00400005");//批次号
bizContent.setCorpCis("211590000183323");
// bizContent.setBillNo("1");//序号
bizContent.setTrxDate("2024-12-17");//交易日期
// bizContent.setBusiCode("14948822");
bizContent.setCurPage("1");//查询页码
request.setBizContent(bizContent);
JftApiPayFeewithholdQuerydetailResponseV1 response;
try {
response = client.execute(request, System.currentTimeMillis() + "");
if (response.isSuccess()) {
List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> tradeList = response.getTradeList();
List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> filterList = tradeList.stream().filter(e -> batchNos.contains(e)).collect(Collectors.toList());
filterList.forEach(e->{
LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo());
updateWrapper.eq(IcbcWithholdRecord::getOutUserId,e.getBusiCode());
updateWrapper.set(IcbcWithholdRecord::getWithholdStatus,e.getStatus());
updateWrapper.set(IcbcWithholdRecord::getWithholdTime,e.getTrxTime());
icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper);
});
} else {
System.out.println("ReturnCode:" + response.getReturnCode());
System.out.println("ReturnMsg:" + response.getReturnMsg());
}
} catch (IcbcApiException e) {
e.printStackTrace();
}
}
public void exportData(HttpServletResponse response, IcbcWithhold icbcWithhold ){
List<HygfIcbcRecordExportDTO> dtos = new ArrayList<>();
JSONArray.parseArray(icbcWithhold.getIcbcRecordInfos(),IcbcWithholdRecord.class).forEach(e->{
HygfIcbcRecordExportDTO hygfIcbcRecordExportDTO = new HygfIcbcRecordExportDTO();
BeanUtil.copyProperties(e,hygfIcbcRecordExportDTO);
hygfIcbcRecordExportDTO.setOpenAccountStatus(e.getOpenAccountStatusName());
hygfIcbcRecordExportDTO.setProtocolStatus(e.getProtocolStatusName());
dtos.add(hygfIcbcRecordExportDTO);
});
if (CollectionUtil.isNotEmpty(dtos)){
ExcelUtil.createTemplate(response,icbcWithhold.getBatchNo()+"人员信息",icbcWithhold.getBatchNo()+"人员信息",dtos,HygfIcbcRecordExportDTO.class,null,false);
}
}
}
\ No newline at end of file
PuTTY-User-Key-File-3: ssh-rsa
PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: imported-openssh-key
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQDX1QJtBxXW6LKv5TmzHOdPEonivyVKC8J+
L/Zw6qzQytC3ScxXifOpr0EmiIE0grVGvEwAtfXOwbhz4rEGiYBub/Hxd4FBdU8m
hZHuZhgJfwe7Lhj+UHmRF8Jn/7Eg1749tOTa0fWrdXslvvp5UMoA4b/qdZtCLiMC
8tdV6GvEutdA8j7Ngi9EbmyzOjxov88Awr4JDTe+4zoyt1/cI2wCKgwfjMug9LMl
CDQuSdscetPC4YVNxo/0ul/Oau3OVlRMbqYrpS6syjb8P0yWEMh5ygEIHsuQolzE
KiEnaYRPmu9JSpC3H+3oG4oWWmXBBxpF1Qq0ueAfURWJ2Dram6NV
Private-Lines: 14
AAABAFnllhIVbmpKGAsdfe/1rP6JaTcxiHWT+lmW3p3fkUWSBGcjbOJVSlE19vv2
xWI6wwiIa1usborEs3BJTpS7duwI4oxBy2uZUfNolQToL0DdUToMlEpw+IGPlOC+
ZmeYlNuc2emupBXbZASvzCH1nX3KiaY9gAKLtveGcFyO5zxUFdbH0hoSpQ5/Yu4n
3Yd9a0yh+5lergcMFP6kJn4lIktPpe/hoYbtvJlOlMEmUX7MsSVOJ69MfUkFOMOO
sIg9Cf00BRi/rWPAK/FZw8mURmiiM48ZyU1ZUbDdwIeIXc55oLjUP5+KcetiEK62
ANBPX/yUXyqnAolUGBuKGQxxamEAAACBAP8NbCVECIFol9jed5xPnCWt1jj80HSN
GZNeseVbsYcN/YE3Ni/7q5dz8kllhwk+EEHFiD7zDvdT55xfCrmKq3oubBv2mLlE
WeaOAMt3+Z7mwfIWSnS+WmLZSiVEvKmGPKsp2jWCETf1JV7TNgY4FTuRR3UE//ra
1NlLb8l89gEtAAAAgQDYokj0Ryd6GTSs7oimzOTgI8Rec+Sv2+QBHasBLldZfned
HYR20jSLwyMfCIrTPw7hAuqoWoJcAIFq+xb6NpRLhugGSNkyB7SZwTxTyfT86ACx
0Koa07g3MZVUK5e2dNsqKzCxJvOrMZl7gVn3Ie57SUCZuAif8v28iIN3NBPzyQAA
AIBD1719GnpnLMhpG4nMsrpJceBFVI+R9N1UuxlVcc5N2AWiZb6g9BhIKa3J6MKJ
iPK8k5eb7sa+9f1f5a10CTgQhJaJgL1GI6GWJeJHreUVlLPvzHVFWRmY19d3eR3o
wc3MZn56cWfmF4mVzzryz9Kz15y8KXd3H6RUUDoBiADDXw==
Private-MAC: 2f3108f282f13a275ee6de718d3e2f0ffc84163698acd686b454204e21d4dd13
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