@@ -0,0 +1,106 @@ | |||
package com.qtzl.alterSales.dao.entity.second; | |||
import com.txffp.api.core.dao.entity.AbstractUpdateTimeEntity; | |||
import javax.persistence.Column; | |||
import javax.persistence.Entity; | |||
import javax.persistence.Table; | |||
/** | |||
* 路网日终应收账单; | |||
* @author : zhangxin | |||
* @date : 2024-7-25 | |||
*/ | |||
@Entity | |||
@Table(name="AFL_PACCOUNT_RECEIVABLEBILL") | |||
public class AflPaccountReceivableBill extends AbstractUpdateTimeEntity { | |||
/** 发行方编号 */ | |||
private String issuerId ; | |||
/** 记账日 */ | |||
private Integer accountDate ; | |||
/** 客车渠道编号 */ | |||
private String channelId ; | |||
/** 扣款笔数 */ | |||
private Integer payCount ; | |||
/** 扣款金额 */ | |||
private Integer payAmount ; | |||
/** 退款笔数 */ | |||
private Integer refundCount ; | |||
/** 退款金额 */ | |||
private Integer refundAmount ; | |||
/** 解析文件名称 */ | |||
private String fileName ; | |||
/** 发行方编号 */ | |||
@Column(name ="ISSUER_ID") | |||
public String getIssuerId(){ | |||
return this.issuerId; | |||
} | |||
/** 发行方编号 */ | |||
public void setIssuerId(String issuerId){ | |||
this.issuerId=issuerId; | |||
} | |||
/** 记账日 */ | |||
@Column(name ="ACCOUNT_DATE") | |||
public Integer getAccountDate(){ | |||
return this.accountDate; | |||
} | |||
/** 记账日 */ | |||
public void setAccountDate(Integer accountDate){ | |||
this.accountDate=accountDate; | |||
} | |||
/** 客车渠道编号 */ | |||
@Column(name ="CHANNEL_ID") | |||
public String getChannelId(){ | |||
return this.channelId; | |||
} | |||
/** 客车渠道编号 */ | |||
public void setChannelId(String channelId){ | |||
this.channelId=channelId; | |||
} | |||
/** 扣款笔数 */ | |||
@Column(name ="PAY_COUNT") | |||
public Integer getPayCount(){ | |||
return this.payCount; | |||
} | |||
/** 扣款笔数 */ | |||
public void setPayCount(Integer payCount){ | |||
this.payCount=payCount; | |||
} | |||
/** 扣款金额 */ | |||
@Column(name ="PAY_AMOUNT") | |||
public Integer getPayAmount(){ | |||
return this.payAmount; | |||
} | |||
/** 扣款金额 */ | |||
public void setPayAmount(Integer payAmount){ | |||
this.payAmount=payAmount; | |||
} | |||
/** 退款笔数 */ | |||
@Column(name ="REFUND_COUNT") | |||
public Integer getRefundCount(){ | |||
return this.refundCount; | |||
} | |||
/** 退款笔数 */ | |||
public void setRefundCount(Integer refundCount){ | |||
this.refundCount=refundCount; | |||
} | |||
/** 退款金额 */ | |||
@Column(name ="REFUND_AMOUNT") | |||
public Integer getRefundAmount(){ | |||
return this.refundAmount; | |||
} | |||
/** 退款金额 */ | |||
public void setRefundAmount(Integer refundAmount){ | |||
this.refundAmount=refundAmount; | |||
} | |||
/** 解析文件名称 */ | |||
@Column(name ="FILE_NAME") | |||
public String getFileName(){ | |||
return this.fileName; | |||
} | |||
/** 解析文件名称 */ | |||
public void setFileName(String fileName){ | |||
this.fileName=fileName; | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.qtzl.alterSales.dao.repo.jpa.second; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import com.qtzl.alterSales.dao.entity.second.AflPaccountReceivableBill; | |||
import org.springframework.data.jpa.repository.JpaRepository; | |||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | |||
/*** | |||
* <p> | |||
* 客车渠道最终扣款账单(新) | |||
* </p> | |||
* | |||
* @author zhangxin | |||
*/ | |||
public interface AflPaccountReceivableBillRepo extends JpaRepository<AflPaccountReceivableBill, String> | |||
, JpaSpecificationExecutor<AflPaccountReceivableBill> | |||
, AbstractJpaRepo<AflPaccountReceivableBill, String>{ | |||
} |
@@ -2,49 +2,46 @@ package com.qtzl.alterSales.manager.model.protocol.sales; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaPageableDataRequest; | |||
import com.qtzl.alterSales.manager.vo.FssPaccountFinalbillVo; | |||
import org.apache.commons.lang3.StringUtils; | |||
import com.qtzl.alterSales.manager.vo.AflPaccountReceivableBillVo; | |||
/** | |||
* 客车渠道最终扣款账单统计,按照自然日分组统计 | |||
*/ | |||
public class FssPaccountFinalbillFindPageRequest extends JpaPageableDataRequest<FssPaccountFinalbillVo> { | |||
public class FssPaccountFinalbillFindPageRequest extends JpaPageableDataRequest<AflPaccountReceivableBillVo> { | |||
/** 自然日 */ | |||
private String naturalDate ; | |||
private Integer accountDate ; | |||
@Override | |||
public HqlBuilder toSelectHql() { | |||
// HqlBuilder builder = new HqlBuilder(" SELECT new com.qtzl.alterSales.manager.vo.FssPaccountFinalbillVo(naturalDate, SUM(payCount), SUM(payAmount) , SUM(refundCount), SUM(refundAmount) ) from FssPaccountFinalbill GROUP BY naturalDate "); | |||
HqlBuilder builder = new HqlBuilder(" SELECT new com.qtzl.alterSales.manager.vo.FssPaccountFinalbillVo(naturalDate, SUM(payCount), SUM(payAmount) , SUM(refundCount), SUM(refundAmount) ) from FssPaccountFinalbill GROUP BY naturalDate "); | |||
HqlBuilder builder = new HqlBuilder(" SELECT new com.qtzl.alterSales.manager.vo.AflPaccountReceivableBillVo(accountDate, SUM(payCount), SUM(payAmount) , SUM(refundCount), SUM(refundAmount) ) from AflPaccountReceivableBill GROUP BY accountDate "); | |||
appendParam(builder); | |||
builder.append( " ORDER BY naturalDate DESC "); | |||
builder.append( " ORDER BY accountDate DESC "); | |||
return builder; | |||
} | |||
@Override | |||
public String toCountHql() { | |||
HqlBuilder builder = new HqlBuilder("SELECT COUNT(1) FROM FssPaccountFinalbill GROUP BY naturalDate"); | |||
HqlBuilder builder = new HqlBuilder("SELECT COUNT(COUNT(1)) FROM AflPaccountReceivableBill GROUP BY accountDate"); | |||
appendParam(builder); | |||
builder.append( " ORDER BY naturalDate DESC "); | |||
System.out.println(builder.toString()); | |||
return builder.toString(); | |||
} | |||
private void appendParam(HqlBuilder builder) { | |||
if (!StringUtils.isEmpty(naturalDate)){ | |||
builder.append(" having naturalDate = :naturalDate", naturalDate); | |||
if (accountDate!=null){ | |||
builder.append(" having accountDate = :accountDate", accountDate); | |||
} | |||
} | |||
public String getNaturalDate() { | |||
return naturalDate; | |||
public Integer getAccountDate() { | |||
return accountDate; | |||
} | |||
public void setNaturalDate(String naturalDate) { | |||
this.naturalDate = naturalDate; | |||
public void setAccountDate(Integer accountDate) { | |||
this.accountDate = accountDate; | |||
} | |||
} |
@@ -6,24 +6,39 @@ import cn.com.taiji.common.pub.BeanTools; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import com.google.common.collect.Lists; | |||
import com.qtzl.alterSales.dao.repo.jpa.primary.FssPaccountFinalbillRepo; | |||
import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountReceivableBillRepo; | |||
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; | |||
import com.qtzl.alterSales.manager.model.protocol.sales.FssPaccountFinalbillFindCountRequest; | |||
import com.qtzl.alterSales.manager.model.protocol.sales.FssPaccountFinalbillFindCountResponse; | |||
import com.qtzl.alterSales.manager.model.protocol.sales.FssPaccountFinalbillFindPageRequest; | |||
import com.qtzl.alterSales.manager.vo.AflPaccountReceivableBillVo; | |||
import com.qtzl.alterSales.manager.vo.FssPaccountFinalbillVo; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.stereotype.Service; | |||
import javax.annotation.Resource; | |||
import javax.persistence.criteria.Predicate; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author zhangxin | |||
*/ | |||
@Service | |||
public class FssPaccountFinalbillServiceImpl implements FssPaccountFinalbillService{ | |||
private static final Logger log = LoggerFactory.getLogger(FssPaccountFinalbillServiceImpl.class); | |||
@Resource | |||
FssPaccountFinalbillRepo fssPaccountFinalbillRepo; | |||
@Resource | |||
AflPaccountReceivableBillRepo aflPaccountReceivableBillRepo; | |||
@Override | |||
public FssPaccountFinalbillFindCountResponse findByNaturalDateCount(FssPaccountFinalbillFindCountRequest request) throws ServiceHandleException { | |||
@@ -37,7 +52,8 @@ public class FssPaccountFinalbillServiceImpl implements FssPaccountFinalbillServ | |||
if (pagination.getResult()==null||pagination.getResult().size()<1) { | |||
return response; | |||
} | |||
response.setData(pagination.getResult(FssPaccountFinalbillVo.class)); | |||
List<FssPaccountFinalbillVo> collect = pagination.getResult(AflPaccountReceivableBillVo.class).stream().map(this::toVo).collect(Collectors.toList()); | |||
response.setData(collect); | |||
return response; | |||
} | |||
@@ -56,16 +72,56 @@ public class FssPaccountFinalbillServiceImpl implements FssPaccountFinalbillServ | |||
} | |||
FssPaccountFinalbillFindPageRequest queryRequest = new FssPaccountFinalbillFindPageRequest(); | |||
BeanUtil.copyProperties(request, queryRequest); | |||
return fssPaccountFinalbillRepo.page(queryRequest); | |||
if (!StringUtils.isEmpty(request.getNaturalDate())){ | |||
Integer accountDate = getAccountDate(request.getNaturalDate()); | |||
queryRequest.setAccountDate(accountDate); | |||
} | |||
return aflPaccountReceivableBillRepo.page(queryRequest); | |||
} | |||
private long count(FssPaccountFinalbillFindCountRequest request) throws ServiceHandleException { | |||
return fssPaccountFinalbillRepo.count(((root, query, cb) -> { | |||
Integer accountDate = getAccountDate(request.getNaturalDate()); | |||
return aflPaccountReceivableBillRepo.count(((root, query, cb) -> { | |||
List<Predicate> list = Lists.newArrayList(); | |||
if (!StringUtils.isEmpty(request.getNaturalDate())) { | |||
list.add(cb.equal(root.<String>get("naturalDate"), request.getNaturalDate())); | |||
if (accountDate!=null) { | |||
list.add(cb.equal(root.<Integer>get("accountDate"), accountDate)); | |||
} | |||
Predicate[] p = new Predicate[list.size()]; | |||
return cb.and(list.toArray(p)); | |||
})); | |||
} | |||
private FssPaccountFinalbillVo toVo(AflPaccountReceivableBillVo aflPaccountReceivableBillVo) { | |||
FssPaccountFinalbillVo fssPaccountFinalbillVo = new FssPaccountFinalbillVo(); | |||
BeanUtil.copyProperties(aflPaccountReceivableBillVo,fssPaccountFinalbillVo); | |||
String payDate = getPayDate(aflPaccountReceivableBillVo.getAccountDate().toString()); | |||
log.info("时间类型转换中:"+payDate); | |||
fssPaccountFinalbillVo.setNaturalDate(payDate); | |||
return fssPaccountFinalbillVo; | |||
} | |||
private String getPayDate(String payDate){ | |||
log.info("时间类型转换中:"+payDate); | |||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); | |||
formatter.setLenient(false); | |||
Date newDate=null; | |||
try { | |||
newDate= formatter.parse(payDate); | |||
} catch (ParseException e) { | |||
log.error("时间类型转换失败:"+payDate); | |||
return payDate; | |||
} | |||
formatter = new SimpleDateFormat("yyyy-MM-dd"); | |||
String format = formatter.format(newDate); | |||
log.info("时间类型转换成功:"+format); | |||
return format; | |||
} | |||
private Integer getAccountDate(String accountDate){ | |||
Integer newAccountDate = null; | |||
try { | |||
String accountDateInt = accountDate.replaceAll("-", ""); | |||
newAccountDate = Integer.parseInt(accountDateInt); | |||
} catch (Exception e) { | |||
log.error("数据类型转换失败"); | |||
} | |||
return newAccountDate; | |||
} | |||
} |
@@ -0,0 +1,77 @@ | |||
package com.qtzl.alterSales.manager.vo; | |||
import cn.com.taiji.common.entity.BaseEntity; | |||
/*** | |||
* <p> | |||
* 客车渠道最终扣款账单统计 新 | |||
* </p> | |||
* | |||
* @author zhangxin | |||
*/ | |||
public class AflPaccountReceivableBillVo extends BaseEntity { | |||
/** 自然日 */ | |||
private Integer accountDate ; | |||
/** 扣款笔数 */ | |||
private Long payCountSum ; | |||
/** 扣款金额 */ | |||
private Long payAmountSum ; | |||
/** 退款笔数 */ | |||
private Long refundCountSum ; | |||
/** 退款金额 */ | |||
private Long refundAmountSum ; | |||
public AflPaccountReceivableBillVo() { | |||
} | |||
public AflPaccountReceivableBillVo(Integer accountDate, Long payCountSum, Long payAmountSum, Long refundCountSum, Long refundAmountSum) { | |||
this.accountDate = accountDate; | |||
this.payCountSum = payCountSum; | |||
this.payAmountSum = payAmountSum; | |||
this.refundCountSum = refundCountSum; | |||
this.refundAmountSum = refundAmountSum; | |||
} | |||
public Integer getAccountDate() { | |||
return accountDate; | |||
} | |||
public void setAccountDate(Integer accountDate) { | |||
this.accountDate = accountDate; | |||
} | |||
public Long getPayCountSum() { | |||
return payCountSum; | |||
} | |||
public void setPayCountSum(Long payCountSum) { | |||
this.payCountSum = payCountSum; | |||
} | |||
public Long getPayAmountSum() { | |||
return payAmountSum; | |||
} | |||
public void setPayAmountSum(Long payAmountSum) { | |||
this.payAmountSum = payAmountSum; | |||
} | |||
public Long getRefundCountSum() { | |||
return refundCountSum; | |||
} | |||
public void setRefundCountSum(Long refundCountSum) { | |||
this.refundCountSum = refundCountSum; | |||
} | |||
public Long getRefundAmountSum() { | |||
return refundAmountSum; | |||
} | |||
public void setRefundAmountSum(Long refundAmountSum) { | |||
this.refundAmountSum = refundAmountSum; | |||
} | |||
} |