feat:银行流水绑定合同问题 出库单据查看 历史当前逾期新增删除去掉 完成开票隐藏开票按钮 出库业务单据文件类型
| New file |
| | |
| | | package com.by4cloud.platformx.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class BankStatementUpdateDTO { |
| | | |
| | | private Long id; |
| | | |
| | | private Long contractId; |
| | | |
| | | } |
| | |
| | | @Schema(description = "合同附件URL") |
| | | private String attachmentUrl; |
| | | |
| | | @Schema(description = "合同附件名称") |
| | | private String attachmentName; |
| | | |
| | | @Schema(description = "备注") |
| | | private String remark; |
| | | |
| New file |
| | |
| | | package com.by4cloud.platformx.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SyncPaymentRecepitDTO { |
| | | |
| | | private String startDate; |
| | | |
| | | private String endDate; |
| | | |
| | | private String bipCode; |
| | | |
| | | } |
| New file |
| | |
| | | package com.by4cloud.platformx.business.entity; |
| | | |
| | | import com.by4cloud.platformx.common.data.mybatis.BaseModel; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.persistence.Column; |
| | | import jakarta.persistence.Entity; |
| | | import lombok.Data; |
| | | import org.hibernate.annotations.Table; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 2026年8月7日 16:04:22 |
| | | * syt |
| | | */ |
| | | @Data |
| | | @Entity//加了才能自动生成表 |
| | | @Table(appliesTo="bank_statement",comment = "银行流水")//给表加注释 |
| | | @jakarta.persistence.Table(name = "bank_statement")//数据库创建的表明 |
| | | public class BankStatement extends BaseModel<BankStatement> { |
| | | |
| | | @Schema(description = "交易流水") |
| | | @Column(columnDefinition="VARCHAR(128) comment '交易流水'") |
| | | private String bankSeqNo; |
| | | |
| | | @Schema(description = "收款银行账户id") |
| | | @Column(columnDefinition="VARCHAR(128) comment '收款银行账户id'") |
| | | private String receiveBankAcc; |
| | | |
| | | @Schema(description = "收款银行账户账号") |
| | | @Column(columnDefinition="VARCHAR(128) comment '收款银行账户账号'") |
| | | private String receiveBankAccAcc; |
| | | |
| | | @Schema(description = "收款银行账户户名") |
| | | @Column(columnDefinition="VARCHAR(128) comment '收款银行账户户名'") |
| | | private String receiveBankAccName; |
| | | |
| | | @Schema(description = "付款银行账户") |
| | | @Column(columnDefinition="VARCHAR(128) comment '付款银行账户'") |
| | | private String payBankNo; |
| | | |
| | | @Schema(description = "付款银行账户户名") |
| | | @Column(columnDefinition="VARCHAR(128) comment '付款银行账户户名'") |
| | | private String payBankAccName; |
| | | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Schema(description = "交易时间") |
| | | @Column(columnDefinition = "datetime comment '交易时间'") |
| | | private Date tranDate; |
| | | |
| | | @Schema(description = "交易金额") |
| | | @Column(columnDefinition = "decimal(10,2) comment '交易金额'") |
| | | private BigDecimal tranAmount; |
| | | |
| | | @Schema(description = "数据ID") |
| | | @Column(columnDefinition="bigint comment '数据ID'") |
| | | private Long dataId; |
| | | |
| | | @Schema(description = "数据") |
| | | @Column(columnDefinition="text comment '数据'") |
| | | private String dataJson; |
| | | |
| | | @Schema(description = "客户ID") |
| | | @Column(columnDefinition="bigint comment '客户ID'") |
| | | private Long busGuestId; |
| | | |
| | | @Schema(description = "合同ID") |
| | | @Column(columnDefinition="bigint comment '合同ID'") |
| | | private Long contractId; |
| | | } |
| | |
| | | @Column(columnDefinition = "decimal(10,2) comment '出库金额'") |
| | | private BigDecimal outBoundAmout; |
| | | |
| | | @Schema(description = "合同中心推送标识") |
| | | @Column(columnDefinition = "char DEFAULT '0' comment '合同中心推送标识 0 未推 1 已推'") |
| | | private String centerPushFlag; |
| | | |
| | | } |
| | |
| | | @Data |
| | | public class AgingVo { |
| | | |
| | | private Long sort; |
| | | |
| | | private String overdueRange; |
| | | |
| | | private BigDecimal totalAmount; |
| | | |
| | | private BigDecimal totalPercent; |
| | | |
| | | public AgingVo(String overdueRange,BigDecimal totalAmount, BigDecimal totalPercent) { |
| | | public AgingVo(Long sort,String overdueRange,BigDecimal totalAmount, BigDecimal totalPercent) { |
| | | this.sort = sort; |
| | | this.overdueRange = overdueRange; |
| | | this.totalAmount = totalAmount; |
| | | this.totalPercent = totalPercent; |
| | | } |
| | | |
| | | public AgingVo(String overdueRange, BigDecimal totalAmount) { |
| | | public AgingVo(Long sort,String overdueRange, BigDecimal totalAmount) { |
| | | this.sort = sort; |
| | | this.overdueRange = overdueRange; |
| | | this.totalAmount = totalAmount; |
| | | } |
| | |
| | | @Schema(description = "合同附件URL") |
| | | private String attachmentUrl; |
| | | |
| | | @Schema(description = "合同附件名称") |
| | | private String attachmentName; |
| | | |
| | | @Schema(description = "备注") |
| | | private String remark; |
| | | |
| | |
| | | @Schema(description = "客商ID") |
| | | private Long busGuestId; |
| | | |
| | | @Schema(description = "合同编号") |
| | | private String contractNo; |
| | | |
| | | @Schema(description = "合同名称") |
| | | private String contractName; |
| | | |
| New file |
| | |
| | | package com.by4cloud.platformx.business.controller; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.business.dto.BankStatementUpdateDTO; |
| | | import com.by4cloud.platformx.business.entity.BankStatement; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.business.service.BankStatementService; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | | import org.springdoc.core.annotations.ParameterObject; |
| | | import org.springframework.http.HttpHeaders; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 银行流水 |
| | | * |
| | | * @author syt |
| | | * @date 2026-08-07 16:10:36 |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/bankStatement" ) |
| | | @Tag(description = "bankStatement" , name = "银行流水管理" ) |
| | | @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) |
| | | public class BankStatementController { |
| | | |
| | | private final BankStatementService bankStatementService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param page 分页对象 |
| | | * @param bankStatement 银行流水 |
| | | * @return |
| | | */ |
| | | @Operation(summary = "分页查询" , description = "分页查询" ) |
| | | @GetMapping("/page" ) |
| | | @PreAuthorize("@pms.hasPermission('business_bankStatement_view')" ) |
| | | public R getBankStatementPage(@ParameterObject Page page, @ParameterObject BankStatement bankStatement) { |
| | | LambdaQueryWrapper<BankStatement> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.like(StrUtil.isNotBlank(bankStatement.getPayBankAccName()),BankStatement::getPayBankAccName,bankStatement.getPayBankAccName()); |
| | | wrapper.like(StrUtil.isNotBlank(bankStatement.getReceiveBankAccName()),BankStatement::getReceiveBankAccName,bankStatement.getReceiveBankAccName()); |
| | | wrapper.orderByDesc(BankStatement::getCreateTime); |
| | | return R.ok(bankStatementService.pageByScope(page, wrapper)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id查询银行流水 |
| | | * @param id id |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "通过id查询" , description = "通过id查询" ) |
| | | @GetMapping("/{id}" ) |
| | | @PreAuthorize("@pms.hasPermission('business_bankStatement_view')" ) |
| | | public R getById(@PathVariable("id" ) Long id) { |
| | | return R.ok(bankStatementService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 新增银行流水 |
| | | * @param bankStatement 银行流水 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "新增银行流水" , description = "新增银行流水" ) |
| | | @SysLog("新增银行流水" ) |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_bankStatement_add')" ) |
| | | public R save(@RequestBody BankStatement bankStatement) { |
| | | return R.ok(bankStatementService.save(bankStatement)); |
| | | } |
| | | |
| | | /** |
| | | * 修改银行流水 |
| | | * @param updateDTO 银行流水 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "修改银行流水" , description = "修改银行流水" ) |
| | | @SysLog("修改银行流水" ) |
| | | @PostMapping("/edit") |
| | | public R updateById(@RequestBody BankStatementUpdateDTO updateDTO) { |
| | | return bankStatementService.edit(updateDTO); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除银行流水 |
| | | * @param ids id列表 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "通过id删除银行流水" , description = "通过id删除银行流水" ) |
| | | @SysLog("通过id删除银行流水" ) |
| | | @DeleteMapping |
| | | @PreAuthorize("@pms.hasPermission('business_bankStatement_del')" ) |
| | | public R removeById(@RequestBody Long[] ids) { |
| | | return R.ok(bankStatementService.removeBatchByIds(CollUtil.toList(ids))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出excel 表格 |
| | | * @param bankStatement 查询条件 |
| | | * @param ids 导出指定ID |
| | | * @return excel 文件流 |
| | | */ |
| | | @ResponseExcel |
| | | @GetMapping("/export") |
| | | @PreAuthorize("@pms.hasPermission('business_bankStatement_export')" ) |
| | | public List<BankStatement> export(BankStatement bankStatement,Long[] ids) { |
| | | return bankStatementService.list(Wrappers.lambdaQuery(bankStatement).in(ArrayUtil.isNotEmpty(ids), BankStatement::getId, ids)); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.business.dto.PaymentConfirmQueryDTO; |
| | | import com.by4cloud.platformx.business.dto.PaymentSlipQueryDTO; |
| | | import com.by4cloud.platformx.business.dto.SyncPaymentRecepitDTO; |
| | | import com.by4cloud.platformx.business.entity.PaymentConfirm; |
| | | import com.by4cloud.platformx.business.entity.PaymentSlip; |
| | | import com.by4cloud.platformx.business.service.PaymentConfirmService; |
| | | import com.by4cloud.platformx.business.service.PaymentSlipService; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.annotation.Inner; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/paymentSlip" ) |
| | | @RequestMapping("/paymentSlip" ) |
| | | @Tag(description = "paymentSlip" , name = "收款单" ) |
| | | @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) |
| | | public class PaymentSlipController { |
| | |
| | | /** |
| | | * 定时查询收款单 |
| | | */ |
| | | @Inner(value = false) |
| | | @GetMapping("syncPaymentRecepit") |
| | | public R syncPaymentRecepit(){ |
| | | return paymentConfirmService.syncPaymentRecepit(); |
| | | public R syncPaymentRecepit(SyncPaymentRecepitDTO dto){ |
| | | return paymentConfirmService.syncPaymentRecepit(dto); |
| | | } |
| | | |
| | | /** |
| | | * 定时查询收款单 |
| | | */ |
| | | @Inner(value = false) |
| | | @GetMapping("syncPaymentRecepitHandle") |
| | | public R syncPaymentRecepitHandle(@ParameterObject SyncPaymentRecepitDTO dto){ |
| | | return paymentConfirmService.syncPaymentRecepit(dto); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.by4cloud.platformx.business.mapper; |
| | | |
| | | import com.by4cloud.platformx.common.data.datascope.PlatformxBaseMapper; |
| | | import com.by4cloud.platformx.business.entity.BankStatement; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface BankStatementMapper extends PlatformxBaseMapper<BankStatement> { |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.by4cloud.platformx.business.service; |
| | | |
| | | import com.by4cloud.platformx.business.dto.BankStatementUpdateDTO; |
| | | import com.by4cloud.platformx.business.entity.BankStatement; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.data.mybatis.IIService; |
| | | |
| | | public interface BankStatementService extends IIService<BankStatement> { |
| | | |
| | | R edit(BankStatementUpdateDTO updateDTO); |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.by4cloud.platformx.business.dto.PaymentConfirmAddDTO; |
| | | import com.by4cloud.platformx.business.dto.SyncPaymentRecepitDTO; |
| | | import com.by4cloud.platformx.business.entity.PaymentConfirm; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.data.mybatis.IIService; |
| | |
| | | |
| | | R add(PaymentConfirmAddDTO addDTO); |
| | | |
| | | R syncPaymentRecepit(); |
| | | R syncPaymentRecepit(SyncPaymentRecepitDTO dto); |
| | | |
| | | String getAccessToken(String accessToken); |
| | | |
| New file |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.business.dto.BankStatementUpdateDTO; |
| | | import com.by4cloud.platformx.business.dto.PaymentConfirmAddDTO; |
| | | import com.by4cloud.platformx.business.entity.BankStatement; |
| | | import com.by4cloud.platformx.business.entity.BusinessCustomer; |
| | | import com.by4cloud.platformx.business.entity.Contract; |
| | | import com.by4cloud.platformx.business.mapper.BankStatementMapper; |
| | | import com.by4cloud.platformx.business.mapper.BusinessCustomerMapper; |
| | | import com.by4cloud.platformx.business.mapper.ContractMapper; |
| | | import com.by4cloud.platformx.business.service.BankStatementService; |
| | | import com.by4cloud.platformx.business.service.PaymentConfirmService; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | /** |
| | | * 银行流水 |
| | | * |
| | | * @author syt |
| | | * @date 2026-08-07 16:10:36 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class BankStatementServiceImpl extends ServiceImpl<BankStatementMapper, BankStatement> implements BankStatementService { |
| | | |
| | | private final PaymentConfirmService paymentConfirmService; |
| | | private final ContractMapper contractMapper; |
| | | private final BusinessCustomerMapper businessCustomerMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | |
| | | @Value("${bip.url}") |
| | | private String url; |
| | | |
| | | @Override |
| | | public R edit(BankStatementUpdateDTO updateDTO) { |
| | | BankStatement statement = baseMapper.selectById(updateDTO.getId()); |
| | | Contract contract = contractMapper.selectById(updateDTO.getContractId()); |
| | | if (ObjUtil.isNull(contract)){ |
| | | return R.failed("合同查询失败"); |
| | | } |
| | | PaymentConfirmAddDTO addDTO = new PaymentConfirmAddDTO(); |
| | | addDTO.setBusGuestId(statement.getBusGuestId()+""); |
| | | addDTO.setConfirmTime(statement.getTranDate()); |
| | | addDTO.setContractNo(contract.getContractNo()); |
| | | addDTO.setInOrOut("1"); |
| | | addDTO.setTransationAmount(statement.getTranAmount()); |
| | | R r = paymentConfirmService.add(addDTO); |
| | | if (!r.isOk()){ |
| | | return r; |
| | | } |
| | | statement.setContractId(updateDTO.getContractId()); |
| | | baseMapper.updateById(statement); |
| | | |
| | | //bip推送 |
| | | pushSaveCollection(statement); |
| | | return R.ok(); |
| | | } |
| | | |
| | | private void pushSaveCollection(BankStatement statement) { |
| | | String accessToken = ""; |
| | | if (redisTemplate.hasKey("BIP_TOKEN")) { |
| | | accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN"); |
| | | } else { |
| | | paymentConfirmService.getAccessToken(accessToken); |
| | | } |
| | | if (StrUtil.isEmpty(accessToken)) { |
| | | log.error("bip accessToken 获取异常"); |
| | | return; |
| | | } |
| | | String finalAccessToken = accessToken; |
| | | JSONObject params = genRequestParam(statement); |
| | | |
| | | log.info("收款单集成 Request:{}", params.toJSONString()); |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/receivable/save?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("收款单集成 Response:{}", result); |
| | | |
| | | } |
| | | |
| | | private JSONObject genRequestParam(BankStatement statement) { |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(statement.getBusGuestId()); |
| | | Contract contract = contractMapper.selectById(statement.getContractId()); |
| | | JSONObject req = new JSONObject(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | |
| | | JSONObject freeCh = new JSONObject(); |
| | | freeCh.put("YSYF57","MJHYXGLXT"); |
| | | |
| | | data.put("freeChId",freeCh); |
| | | data.put("extVouchCode",statement.getBankSeqNo()); |
| | | data.put("billDate",statement.getTranDate()); |
| | | data.put("objectType","1"); |
| | | data.put("customerCode",customer.getCreditCode()); |
| | | data.put("exchangeRate",1); |
| | | data.put("exchangeRateDate", DateUtil.now()); |
| | | data.put("contractNo",contract.getContractNo()); |
| | | |
| | | JSONArray bodyItems = new JSONArray(); |
| | | |
| | | JSONObject bodyItem = new JSONObject(); |
| | | bodyItem.put("srcBillType","38"); |
| | | bodyItem.put("srcBillNo",statement.getBankSeqNo()); |
| | | |
| | | JSONObject freeChItem = new JSONObject(); |
| | | freeChItem.put("YSZJX01A","业务资金预算项目"); |
| | | freeChItem.put("YSZJX05",""); |
| | | freeChItem.put("YSZJX11","2146820445301112836"); |
| | | freeChItem.put("zzbkfl",""); |
| | | bodyItem.put("freeChId",freeChItem); |
| | | |
| | | bodyItems.add(bodyItem); |
| | | data.put("bodyItem",bodyItems); |
| | | |
| | | data.put("_status","Insert"); |
| | | data.put("oriTaxIncludedAmount",statement.getTranAmount()); |
| | | |
| | | req.put("data",data); |
| | | return req; |
| | | |
| | | } |
| | | } |
| | |
| | | private GenInvoiceInfoVo genInvoiceInfoVo(GenInvoiceInfoDTO genInvoiceInfoDTO, Contract contract, SysDept b) { |
| | | GenInvoiceInfoVo vo = new GenInvoiceInfoVo(); |
| | | BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | vo.setPartyA(a.getRegisterName()); |
| | | vo.setPartyA(a.getCompanyName()); |
| | | vo.setPartyAOrgCode(a.getCreditCode()); |
| | | vo.setPartyAOpenBank(a.getBankName()); |
| | | vo.setPartyABankAccount(a.getBankAccount()); |
| | |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | //更新合同出库单状态 |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound bound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | bound.setInvoiceStatus("1"); |
| | | bound.setInvoiceNum(bound.getInvoiceNum().add(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(bound); |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | contractOutBound.setInvoiceStatus("1"); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | } |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | }); |
| | | }else { |
| | | //更新合同房租 水电 费开票状态 |
| | |
| | | data.put("billDate",DateUtil.format(contractInvoice.getInvoiceTime(),DatePattern.NORM_DATETIME_FORMAT)); |
| | | data.put("objectType","1"); |
| | | data.put("exchangeRate","1"); |
| | | data.put("exchangeRate",DateUtil.now()); |
| | | data.put("exchangeRateDate",DateUtil.now()); |
| | | data.put("_status","Insert"); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(contractInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | JSONArray bodyItem = new JSONArray(); |
| | | for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) { |
| | | JSONObject item = new JSONObject(); |
| | | |
| | | JSONObject freeCh = new JSONObject(); |
| | | freeCh.put("JT32",""); |
| | | item.put("freeChId",freeCh); |
| | | |
| | | item.put("invoiceNo",contractInvoice.getInvoiceNo()); |
| | | item.put("materialCode",invoiceItemVo.getErpCode()); |
| | | item.put("taxRate", invoiceItemVo.getTaxRate()); |
| | | item.put("oriTaxAmount", invoiceItemVo.getPriceTax()); |
| | | item.put("oriTaxExcludedAmount", invoiceItemVo.getPriceNoTax()); |
| | | item.put("oriTaxIncludedAmount", invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity())); |
| | | item.put("_status","Insert"); |
| | | |
| | |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | //合同状态 |
| | | if (StrUtil.equals(contract.getBillingStatus(), "2")) { |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) == 0) { |
| | | contract.setBillingStatus("3"); |
| | | } |
| | | } else { |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | contractMapper.updateById(contract); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | contractMapper.updateById(contract); |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) < 0) { |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } |
| | | }else { |
| | | //判断 循环是否完成 |
| | |
| | | contract.setBillingStatus("2"); |
| | | } |
| | | } |
| | | if (ObjUtil.isNull(contract.getBillingAmout())) { |
| | | contract.setBillingAmout(vo.getTotalPrice()); |
| | | } else { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } |
| | |
| | | } |
| | | } |
| | | contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax())); |
| | | //防止重复审开票审核通过后 开票金额为负 |
| | | if (contract.getBillingAmout().compareTo(new BigDecimal("0"))<0){ |
| | | contract.setBillingAmout(new BigDecimal("0")); |
| | | } |
| | | //更新合同开票状态 前提出库完成 |
| | | contract.setBillingStatus("2"); |
| | | contractMapper.updateById(contract); |
| | |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |
| | |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |
| | |
| | | import com.by4cloud.platformx.business.mapper.*; |
| | | import com.by4cloud.platformx.business.service.ContractService; |
| | | import com.by4cloud.platformx.business.utils.ItemGeneratorUtil; |
| | | import com.by4cloud.platformx.business.utils.NetworkFileToBase64; |
| | | import com.by4cloud.platformx.business.vo.ContractDetailVo; |
| | | import com.by4cloud.platformx.business.vo.ContractInvoiceVo; |
| | | import com.by4cloud.platformx.business.vo.ContractSlipVo; |
| | |
| | | if (StrUtil.isEmpty(updateDTO.getPartyA())){ |
| | | BusinessCustomer bc = businessCustomerMapper.selectById(updateDTO.getPartyAId()); |
| | | if (ObjUtil.isNotNull(bc)){ |
| | | updateDTO.setPartyA(bc.getRegisterName()); |
| | | updateDTO.setPartyA(bc.getCompanyName()); |
| | | } |
| | | if (StrUtil.isEmpty(bc.getErpCompanyCode())||StrUtil.isEmpty(bc.getRegisterName())|| |
| | | StrUtil.isEmpty(bc.getBankName())||StrUtil.isEmpty(bc.getBankAccount())){ |
| | |
| | | //合同中心推送 |
| | | new Thread(()->{ |
| | | try { |
| | | JSONObject request = new JSONObject(); |
| | | request.put("fd_docNumber",contract.getContractNo()); |
| | | request.put("fd_singer",contract.getNickName()); |
| | | request.put("fd_signTime",DateUtil.formatDate(contract.getSignDate())); |
| | | request.put("fd_linkPerson",""); |
| | | request.put("fd_linkPhone",""); |
| | | request.put("fd_address",contract.getSignPlace()); |
| | | request.put("fd_receivedTime",DateUtil.format(contract.getCreateTime(),DatePattern.NORM_DATETIME_PATTERN)); |
| | | request.put("fd_receivedNum",1); |
| | | request.put("fd_effedate",DateUtil.formatDate(contract.getEffectiveDate())); |
| | | request.put("fd_enddate",DateUtil.formatDate(contract.getExpirationDate())); |
| | | request.put("fd_reviewerNo",contract.getNickName()); |
| | | request.put("fd_docStatus","20"); |
| | | request.put("fd_templateId",""); |
| | | request.put("fd_attName",contract.getAttachmentName()); |
| | | request.put("fd_attcontent",contract.getAttachmentName()); |
| | | log.info("合同中心同步合同接口入参:{}",request.toJSONString()); |
| | | String resp = HttpUtil.post("https://oatest.res.jzeg.cn/ekp/api/km-agreement/kmAgreementWebService/addContractReview",request.toJSONString()); |
| | | log.info("合同中心同步合同接口回参:{}",resp); |
| | | JSONObject requestApply = new JSONObject(); |
| | | requestApply.put("fd_selectionmethod","公开招标"); |
| | | requestApply.put("fd_isrelated","是"); |
| | | requestApply.put("fd_bizId",contract.getId()); |
| | | requestApply.put("fd_remark",contract.getRemark()); |
| | | requestApply.put("fd_MainContent",""); |
| | | requestApply.put("fd_settlementType","00"); |
| | | requestApply.put("fd_applyType","外销"); |
| | | requestApply.put("fd_contractsubject ",subjectMatterList.stream().map(item->item.getMaterialName()).collect(Collectors.joining(","))); |
| | | requestApply.put("fd_docNumber",contract.getContractNo()); |
| | | requestApply.put("fd_templateId","19e39bb6c1edadbdb162c434274a8a18"); |
| | | requestApply.put("fd_name",contract.getContractName()); |
| | | requestApply.put("fd_signDate",DateUtil.formatDate(contract.getSignDate())); |
| | | requestApply.put("fd_endDate",DateUtil.formatDate(contract.getExpirationDate())); |
| | | requestApply.put("fd_contractCreater",contract.getNickName()); |
| | | requestApply.put("fd_currency","人民币"); |
| | | requestApply.put("fd_ContractAmount",contract.getAmount()); |
| | | requestApply.put("fd_finAmount",contract.getAmount().divide(new BigDecimal("113"),2,RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("87"))); |
| | | requestApply.put("fd_docStatus","20"); |
| | | requestApply.put("fd_taxRates",13); |
| | | requestApply.put("fd_customerName",contract.getPartyA()); |
| | | requestApply.put("fd_systemSource","非煤销售系统"); |
| | | requestApply.put("fd_type","00"); |
| | | log.info("合同中心合同起草接口入参:{}",requestApply.toJSONString()); |
| | | String respApply = HttpUtil.post("https://oatest.res.jzeg.cn/ekp/api/km-agreement/kmAgreementWebService/addSupplyContractApply",requestApply.toJSONString()); |
| | | log.info("合同中心合同起草接口回参:{}",respApply); |
| | | JSONObject applyResp = JSONObject.parseObject(respApply); |
| | | if (applyResp.getString("code").equals("00")) { |
| | | JSONObject request = new JSONObject(); |
| | | request.put("fd_docNumber", contract.getContractNo()); |
| | | request.put("fd_singer", contract.getNickName()); |
| | | request.put("fd_signTime", DateUtil.formatDate(contract.getSignDate())); |
| | | request.put("fd_linkPerson", ""); |
| | | request.put("fd_linkPhone", ""); |
| | | request.put("fd_address", contract.getSignPlace()); |
| | | request.put("fd_receivedTime", DateUtil.format(contract.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN)); |
| | | request.put("fd_receivedNum", 1); |
| | | request.put("fd_effedate", DateUtil.formatDate(contract.getSignDate())); |
| | | request.put("fd_enddate", DateUtil.formatDate(contract.getExpirationDate())); |
| | | request.put("fd_reviewerNo", contract.getNickName()); |
| | | request.put("fd_docStatus", "20"); |
| | | request.put("fd_templateId", "19e39bb6c1edadbdb162c434274a8a18"); |
| | | request.put("fd_attName", contract.getAttachmentName()); |
| | | request.put("fd_attcontent", NetworkFileToBase64.convertNetworkFileToBase64("https://zbjt.res.jzeg.cn/api" + contract.getAttachmentUrl())); |
| | | log.info("合同中心同步合同接口入参:{}", request.toJSONString()); |
| | | String resp = HttpUtil.post("https://oatest.res.jzeg.cn/ekp/api/km-agreement/kmAgreementWebService/addContractReview", request.toJSONString()); |
| | | log.info("合同中心同步合同接口回参:{}", resp); |
| | | JSONObject respJson = JSONObject.parseObject(resp); |
| | | if (respJson.getString("code").equals("00")) { |
| | | contract.setCenterPushFlag("1"); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | public R copyNewContract(Long id) { |
| | | Contract oldContract = baseMapper.selectById(id); |
| | | Contract newContract = BeanUtil.copyProperties(oldContract, Contract.class, "id", "createTime"); |
| | | newContract.setOutBoundAmout(new BigDecimal("0")); |
| | | newContract.setPaidAmount(new BigDecimal("0")); |
| | | newContract.setBillingStatus("1"); |
| | | newContract.setErpPushFlag("0"); |
| | |
| | | return R.failed("erp客户编码不存在"); |
| | | } |
| | | contract.setPartyAId(bc.getId()); |
| | | contract.setPartyA(bc.getCompanyName()); |
| | | if (ObjUtil.isNotNull(addDTO.getDeliveryCycle())){ |
| | | contract.setExpirationDate(DateUtil.offsetDay(addDTO.getSignDate(),addDTO.getDeliveryCycle())); |
| | | } |
| | |
| | | List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()) |
| | | .gt(ContractPaymentSchedule::getPaymentRatio, 0) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray())&&contract.getOutBoundAmout().compareTo(contract.getAmount())==0) { |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | |
| | | import com.by4cloud.platformx.admin.api.feign.RemoteDeptService; |
| | | import com.by4cloud.platformx.business.dto.AgingQueryDTO; |
| | | import com.by4cloud.platformx.business.dto.PaymentConfirmAddDTO; |
| | | import com.by4cloud.platformx.business.dto.SyncPaymentRecepitDTO; |
| | | import com.by4cloud.platformx.business.entity.*; |
| | | import com.by4cloud.platformx.business.mapper.*; |
| | | import com.by4cloud.platformx.business.service.BusinessCustomerService; |
| | |
| | | private final BipRequestRecordMapper bipRequestRecordMapper; |
| | | private final ContractExecDateMapper contractExecDateMapper; |
| | | private final MeterReadRecordMapper meterReadRecordMapper; |
| | | private final BankStatementMapper bankStatementMapper; |
| | | private final RemoteDeptService remoteDeptService; |
| | | private final RedisTemplate redisTemplate; |
| | | |
| | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (newtotal.compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setTransationAmount(addDTO.getTransationAmount()); |
| | |
| | | entity.setContractNo(addDTO.getContractNo()); |
| | | |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusinessType("退款"); |
| | | entity.setTransationAmount(addDTO.getTransationAmount()); |
| | | BigDecimal newtotal = addDTO.getTransationAmount().multiply(new BigDecimal("-1")).add(lastConfirm.getTotalAmount()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R syncPaymentRecepit() { |
| | | public R syncPaymentRecepit(SyncPaymentRecepitDTO dto) { |
| | | String accessToken = ""; |
| | | if (redisTemplate.hasKey("BIP_TOKEN")) { |
| | | accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN"); |
| | |
| | | if (StrUtil.isEmpty(accessToken)) { |
| | | return R.failed("获取token失败"); |
| | | } |
| | | String[] bipCodeArr = codes.split(","); |
| | | String[] bipCodeArr = StrUtil.isNotBlank(dto.getBipCode())?dto.getBipCode().split(","):codes.split(","); |
| | | for (String bipCode : bipCodeArr) { |
| | | //入参 |
| | | JSONObject params = genParams(bipCode); |
| | | JSONObject params = new JSONObject(); |
| | | if (StrUtil.isNotBlank(dto.getStartDate())){ |
| | | params.put("begindate",dto.getStartDate()); |
| | | }else { |
| | | params.put("begindate", DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1))); |
| | | } |
| | | if (StrUtil.isNotBlank(dto.getStartDate())){ |
| | | params.put("enddate", dto.getEndDate()); |
| | | }else { |
| | | params.put("enddate", DateUtil.today()); |
| | | } |
| | | //单据状态已审批 |
| | | params.put("accentity_code", bipCode); |
| | | String finalAccessToken = accessToken; |
| | | new Thread(() -> { |
| | | try { |
| | |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | log.info("SK_CX Request:", params.toJSONString()); |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/collection/list?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("SK_CX Response:{}", result); |
| | | log.info("银行流水查询 Request:{}", params.toJSONString()); |
| | | String result = HttpUtil.post(url + "/iuap-api-auth/yonbip/ctm/cmp/bankReconciliationQuery?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("银行流水查询 Response:{}", result); |
| | | //保存请求记录 |
| | | saveBipRequestRecord(params, "<XSJZ_SK_CX_001>-收款单查询接口", result); |
| | | saveBipRequestRecord(params, "银行流水查询接口", result); |
| | | JSONObject resultJson = JSONObject.parseObject(result); |
| | | if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) { |
| | | handleAndSave(bipCode, resultJson); |
| | |
| | | }).start(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private JSONObject genParams(String bipCode) { |
| | | JSONObject params = new JSONObject(); |
| | | params.put("pageIndex", 1); |
| | | params.put("pageSize", 999); |
| | | params.put("open_billDate_begin", DateUtil.offsetDay(new Date(), -1) + " 00:00:00"); |
| | | params.put("open_billDate_begin", DateUtil.today() + " 00:00:00"); |
| | | //单据状态已审批 |
| | | params.put("verifyState", new String[]{"2"}); |
| | | //往来对象客户 |
| | | params.put("objectType", new String[]{"1"}); |
| | | //单位 |
| | | JSONObject simpleMap = new JSONObject(); |
| | | simpleMap.put("financeOrg.code", bipCode); |
| | | params.put("simple", simpleMap); |
| | | return params; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | String getTokenResult = HttpUtil.get(url + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken?appKey=" + appKey + "×tamp=" + timestamp |
| | | + "&signature=" + signature); |
| | | log.info("Get access_token Response:", getTokenResult); |
| | | log.info("Get access_token Response:{}", getTokenResult); |
| | | JSONObject tokenJson = JSONObject.parseObject(getTokenResult); |
| | | if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("200")) { |
| | | if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("00000")) { |
| | | log.error("Get access_token ERROR"); |
| | | return ""; |
| | | } |
| | |
| | | return ""; |
| | | } |
| | | accessToken = JSONObject.parseObject(tokenJson.getString("data")).getString("access_token"); |
| | | log.info("access_token value:", accessToken); |
| | | redisTemplate.opsForValue().set("BIP_TOKEN", accessToken, tokenJson.getIntValue("expire") - 10, TimeUnit.SECONDS); |
| | | log.info("access_token value:{}", accessToken); |
| | | redisTemplate.opsForValue().set("BIP_TOKEN", accessToken, JSONObject.parseObject(tokenJson.getString("data")).getIntValue("expire") - 10, TimeUnit.SECONDS); |
| | | return accessToken; |
| | | } |
| | | |
| | |
| | | log.error("返回结果中recordList为空"); |
| | | return; |
| | | } |
| | | log.info("==================开始处理收款单信息==================="); |
| | | log.info("==================开始处理银行流水信息==================="); |
| | | recordList.stream().forEach(record -> { |
| | | |
| | | savePaymentConfirm((JSONObject) record, dept); |
| | | }); |
| | | log.info("==================结束处理收款单信息==================="); |
| | | log.info("==================结束处理银行流水信息==================="); |
| | | } |
| | | |
| | | private void savePaymentConfirm(JSONObject record, SysDept dept) { |
| | | |
| | | List<Contract> contractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyA, record.getString("bodyItemCustomerName")) |
| | | .eq(Contract::getPartyBId, dept.getDeptId()).orderByAsc(Contract::getCreateTime)); |
| | | if (ArrayUtil.isEmpty(contractList.toArray())) { |
| | | log.error("付款单id:{},甲方:{},乙方:{},无相关合同", record.getString("id"), record.getString("bodyItemCustomerName"), dept.getName()); |
| | | if (record.containsKey("to_acct_name")){ |
| | | log.error("付款单id:{},付款公司为空", record.getString("id")); |
| | | return; |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(record.getString("bodyItemCustomerName")), BusinessCustomer::getRegisterName, record.getString("bodyItemCustomerName")) |
| | | .eq(BusinessCustomer::getCompanyName, record.getString("to_acct_name")) |
| | | .eq(BusinessCustomer::getCompId,dept.getDeptId()) |
| | | ); |
| | | if (ObjUtil.isNull(customer)) { |
| | | log.error("付款单id:{},客商查询失败,请检查客商", record.getString("id")); |
| | | return; |
| | | } |
| | | if (ObjUtil.isNull(record.getBigDecimal("bodyItemOriTaxExcludedAmount"))) { |
| | | log.error("付款单id:{},付款单无税金额,异常", record.getString("id")); |
| | | if (ObjUtil.isNull(record.getBigDecimal("tran_amt"))) { |
| | | log.error("付款单id:{},交易金额异常", record.getString("id")); |
| | | return; |
| | | } |
| | | //保存付款单 |
| | | Boolean codeFlag = savePaymentSlip(customer, record, dept); |
| | | Boolean codeFlag = saveBankStatement(customer, record); |
| | | if (codeFlag) { |
| | | log.error("付款单id:{},付款单已存在"); |
| | | return; |
| | | } |
| | | BigDecimal transtionAmount = record.getBigDecimal("bodyItemOriTaxExcludedAmount"); |
| | | //剩余付款 |
| | | BigDecimal transtionRemainAmount = transtionAmount; |
| | | //收到付款的合同 |
| | | List<Contract> payContractList = new ArrayList<>(); |
| | | //付款完成的合同 |
| | | List<Contract> payCompleteContractList = new ArrayList<>(); |
| | | //付款未完成的合同 |
| | | List<Contract> payNoCompleteContractList = new ArrayList<>(); |
| | | //有预付款的合同 |
| | | List<Contract> advanceContractList = new ArrayList<>(); |
| | | //付款时间 |
| | | Date payDate = DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT); |
| | | Iterator<Contract> iterator = contractList.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Contract contract = iterator.next(); |
| | | PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId()) |
| | | .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1")); |
| | | BigDecimal lastTotal = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | lastTotal = lastConfirm.getTotalAmount(); |
| | | } |
| | | |
| | | //合同最近明细总额为0 或 > 0 情况下 |
| | | if (lastTotal.compareTo(new BigDecimal("0")) >= 0) { |
| | | log.info("当前合同号:{},明细总额无应收款", contract.getContractNo()); |
| | | advanceContractList.add(contract); |
| | | continue; |
| | | } |
| | | |
| | | transtionRemainAmount = transtionRemainAmount.add(lastTotal); |
| | | PaymentConfirm entity = new PaymentConfirm(); |
| | | entity.setContractId(contract.getId()); |
| | | entity.setContractName(contract.getContractName()); |
| | | entity.setContractNo(contract.getContractNo()); |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | entity.setScheduleId(lastConfirm.getScheduleId()); |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | entity.setIsBip(1); |
| | | entity.setPaymentCode(record.getString("code")); |
| | | entity.setPayType(record.get("bodyItemSettleModeName") != null ? record.getString("bodyItemSettleModeName").contains("承兑汇票") ? 1 : 0 : null); |
| | | entity.setBipId(record.getString("id")); |
| | | if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setConfirmTime(payDate); |
| | | // 判断是否是最后一个 |
| | | if (!iterator.hasNext()) { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setAdvanceAmount(transtionRemainAmount); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | } else { |
| | | entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(new BigDecimal("0")); |
| | | } |
| | | baseMapper.insert(entity); |
| | | } else if (transtionRemainAmount.compareTo(new BigDecimal("0")) == 0) { |
| | | entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(new BigDecimal("0")); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | break; |
| | | } else { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setTotalAmount(transtionAmount); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | payContractList.stream().forEach(contract -> { |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = transtionAmount; |
| | | for (ContractPaymentSchedule schedule : scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | | remain = remain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() : |
| | | schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | if (remain.compareTo(new BigDecimal("0")) >= 0) { |
| | | schedule.setActualAmount(schedule.getPlannedAmount()); |
| | | schedule.setPaymentDate(payDate); |
| | | schedule.setPaymentStatus(2); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setPaymentTime(payDate); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //删除当前逾期 |
| | | currentOverdueMapper.deleteById(currentOverdue); |
| | | } |
| | | } else { |
| | | schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) : |
| | | schedule.getActualAmount().add(lastRemain)); |
| | | schedule.setPaymentDate(payDate); |
| | | schedule.setPaymentStatus(1); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setReceivableAmount(lastRemain); |
| | | historyOverdue.setPaymentTime(payDate); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //查询历史已付逾期金额 |
| | | List<HistoryOverdue> historyOverdueList = historyOverdueMapper.selectList(Wrappers.<HistoryOverdue>lambdaQuery().eq(HistoryOverdue::getScheduleId, currentOverdue.getScheduleId())); |
| | | BigDecimal hisTotal = historyOverdueList.stream().map(item -> item.getReceivableAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //更新当前逾期 |
| | | currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(hisTotal)); |
| | | currentOverdueMapper.updateById(currentOverdue); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | ); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())) { |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() : |
| | | item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | contract.setPaidAmount(payTotal); |
| | | // if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | // } |
| | | // contractService.updateById(contract); |
| | | // if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | // payCompleteContractList.add(contract); |
| | | // } |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | // contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | payCompleteContractList.add(contract); |
| | | } |
| | | //付款 且 付款未全付 |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) > 0) { |
| | | payNoCompleteContractList.add(contract); |
| | | } |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | .eq(ContractExecDate::getContractId, contract.getId()).eq(ContractExecDate::getGenFlag, "0")); |
| | | if (ArrayUtil.isEmpty(execDateList)) { |
| | | List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray()) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | contract.setContractStatus(3); |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | | } else { |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | //客户预付有剩余 且 有预付款的合同 |
| | | // if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | // if (ArrayUtil.isNotEmpty(payNoCompleteContractList.toArray())){ |
| | | // //余额 放到付款未完成合同 预收 |
| | | // Contract lastContract = payNoCompleteContractList.get(payNoCompleteContractList.size() - 1); |
| | | // //保存明细 |
| | | // saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate); |
| | | // } |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){ |
| | | // //客户预付有剩余 没有预付款的合同 |
| | | // Contract lastContract = payNoCompleteContractList.get(payNoCompleteContractList.size() - 1); |
| | | // //保存明细 |
| | | // saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate); |
| | | // } |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isEmpty(advanceContractList.toArray()) |
| | | // &&ArrayUtil.isNotEmpty(payCompleteContractList.toArray())) { |
| | | // //客户预付有剩余 没有预付款的合同 |
| | | // Contract lastContract = payCompleteContractList.get(payCompleteContractList.size() - 1); |
| | | // //保存明细 |
| | | // saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate); |
| | | // |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record, SysDept dept) { |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayee(dept.getName()); |
| | | slip.setPayeeCompId(dept.getDeptId()); |
| | | slip.setPaymentTime(ObjUtil.isNotNull(record.get("billDate")) ? |
| | | DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT) : new Date()); |
| | | slip.setPaymentAmount(ObjUtil.isNotNull(record.get("bodyItemOriTaxExcludedAmount")) ? record.getBigDecimal("bodyItemOriTaxExcludedAmount") : new BigDecimal("0")); |
| | | slip.setPayType(ObjUtil.isNotNull(record.get("bodyItemSettleModeName")) ? record.getString("bodyItemSettleModeName") : ""); |
| | | if (ObjUtil.isNotNull(record.get("code"))) { |
| | | slip.setPaymentNumber(record.getString("code")); |
| | | PaymentSlip paymentSlip = paymentSlipMapper.selectOne(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getPaymentNumber, slip.getPaymentNumber())); |
| | | if (ObjUtil.isNull(paymentSlip)) { |
| | | paymentSlipMapper.insert(slip); |
| | | return false; |
| | | } |
| | | private Boolean saveBankStatement(BusinessCustomer customer, JSONObject record) { |
| | | BankStatement bankStatement = new BankStatement(); |
| | | bankStatement.setBankSeqNo(record.getString("bank_seq_no")); |
| | | bankStatement.setReceiveBankAcc(record.getString("bank_seq_no")); |
| | | bankStatement.setReceiveBankAccAcc(record.getString("bankaccount_account")); |
| | | bankStatement.setReceiveBankAccName(record.getString("bankaccount_acctName")); |
| | | bankStatement.setPayBankNo(record.getString("to_acct_no")); |
| | | bankStatement.setPayBankAccName(record.getString("to_acct_name")); |
| | | bankStatement.setTranDate(DateUtil.parseDateTime(record.getString("tran_date"))); |
| | | bankStatement.setTranAmount(record.getBigDecimal("tran_amt")); |
| | | bankStatement.setDataId(record.getLong("id")); |
| | | bankStatement.setDataJson(record.toJSONString()); |
| | | bankStatement.setBusGuestId(customer.getId()); |
| | | BankStatement statement = bankStatementMapper.selectOne(Wrappers.<BankStatement>lambdaQuery().eq(BankStatement::getDataId,record.getLong("id"))); |
| | | if (ObjUtil.isNotNull(statement)){ |
| | | return false; |
| | | } |
| | | statement.setCompId(customer.getCompId()); |
| | | bankStatementMapper.insert(bankStatement); |
| | | return true; |
| | | } |
| | | |
| | | public void saveNewPaymentConfirm(BusinessCustomer customer, JSONObject record, Contract contract, BigDecimal transtionRemainAmount |
| | | , Date payDate) { |
| | | PaymentConfirm entity = new PaymentConfirm(); |
| | | entity.setContractId(contract.getId()); |
| | | entity.setContractName(contract.getContractName()); |
| | | entity.setContractNo(contract.getContractNo()); |
| | | PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId()) |
| | | .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1")); |
| | | BigDecimal lastTotal = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | lastTotal = lastConfirm.getTotalAmount(); |
| | | } |
| | | |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | entity.setScheduleId(lastConfirm.getScheduleId()); |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (ObjUtil.isNotNull(record)) { |
| | | entity.setIsBip(1); |
| | | entity.setPaymentCode(record.getString("code")); |
| | | entity.setPayType(record.get("bodyItemSettleModeName") != null ? record.getString("bodyItemSettleModeName").contains("承兑汇票") ? 1 : 0 : null); |
| | | entity.setBipId(record.getString("id")); |
| | | } |
| | | entity.setConfirmTime(payDate); |
| | | entity.setTransationAmount(transtionRemainAmount); |
| | | entity.setTotalAmount(transtionRemainAmount.add(lastTotal)); |
| | | if (entity.getTotalAmount().compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setAdvanceAmount(entity.getTotalAmount()); |
| | | } else if (entity.getTotalAmount().compareTo(new BigDecimal("0")) < 0) { |
| | | entity.setReceivableAmount(entity.getTotalAmount().multiply(new BigDecimal("-1"))); |
| | | } |
| | | baseMapper.insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public R queryAllBusinessType() { |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())) { |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天", new BigDecimal("0"), null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天", new BigDecimal("0"), null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天", new BigDecimal("0"), null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天", new BigDecimal("0"), null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | } else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "0-30天")) { |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "31-60天")) { |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "61-90天")) { |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "91-180天")) { |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "181-365天")) { |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "1年以上")) { |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | |
| | | |
| | | private final ContractService contractService; |
| | | private final PaymentConfirmMapper paymentConfirmMapper; |
| | | private final BusinessCustomerMapper businessCustomerMapper; |
| | | private final ContractPaymentScheduleMapper contractPaymentScheduleMapper; |
| | | private final CurrentOverdueMapper currentOverdueMapper; |
| | | private final HistoryOverdueMapper historyOverdueMapper; |
| | |
| | | @Override |
| | | public R add(PaymentOffset paymentOffset) { |
| | | baseMapper.insert(paymentOffset); |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(paymentOffset.getBusGuestId()); |
| | | |
| | | Contract contract = contractService.getById(paymentOffset.getContractId()); |
| | | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(paymentOffset.getBusGuestId()); |
| | | slip.setBusGuestName(paymentOffset.getBusGuestName()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setPayeeCompId(contract.getPartyBId()); |
| | | slip.setPayee(contract.getPartyB()); |
| | | slip.setPaymentTime(paymentOffset.getOffsetTime()); |
| | |
| | | entity.setContractName(contract.getContractName()); |
| | | entity.setContractNo(contract.getContractNo()); |
| | | entity.setBusGuestId(paymentOffset.getBusGuestId()); |
| | | entity.setBusGuestName(paymentOffset.getBusGuestName()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusinessType("抵抹账"); |
| | | entity.setConfirmTime(paymentOffset.getOffsetTime()); |
| | | entity.setTransationAmount(paymentOffset.getOffsetAmount()); |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.IntStream; |
| | |
| | | // if (ArrayUtil.isEmpty(companys.toArray())){ |
| | | // return R.failed("暂无账龄"); |
| | | // } |
| | | List<Long> compIds = new ArrayList<>(); |
| | | compIds.add(Long.valueOf(sgb)); |
| | | compIds.add(Long.valueOf(smj)); |
| | | compIds.add(Long.valueOf(tfgs)); |
| | | compIds.add(Long.valueOf(ymj)); |
| | | compIds.add(Long.valueOf(jxc)); |
| | | |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | | AgingQueryDTO queryDTO = new AgingQueryDTO(); |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(null); |
| | | if (ArrayUtil.contains(compIds.toArray(),SecurityUtils.getUser().getCompId())){ |
| | | queryDTO.setCompanyId(SecurityUtils.getUser().getCompId()); |
| | | } |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | items.stream().forEach(item->{ |
| | | AgingAnalysisVo agingAnalysisVo = new AgingAnalysisVo(); |
| | | agingAnalysisVo.setCompanyName(item.getLabel()); |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| | |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | return R.failed("行业字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | | compIds.add(Long.valueOf(sgb)); |
| | | compIds.add(Long.valueOf(smj)); |
| | | compIds.add(Long.valueOf(tfgs)); |
| | | compIds.add(Long.valueOf(ymj)); |
| | | compIds.add(Long.valueOf(jxc)); |
| | | |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | | AgingQueryDTO queryDTO = new AgingQueryDTO(); |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(null); |
| | | if (ArrayUtil.contains(compIds.toArray(),SecurityUtils.getUser().getCompId())){ |
| | | queryDTO.setCompanyId(SecurityUtils.getUser().getCompId()); |
| | | } |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | items.stream().forEach(item->{ |
| | | AgingAnalysisVo agingAnalysisVo = new AgingAnalysisVo(); |
| | | agingAnalysisVo.setCompanyName(item.getLabel()); |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private List<AgingVo> completeData(List<AgingVo> companyAgingVo) { |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())) { |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | | companyAgingVo.add(agingVo4); |
| | | companyAgingVo.add(agingVo5); |
| | | companyAgingVo.add(agingVo6); |
| | | } else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "0-30天")) { |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "31-60天")) { |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "61-90天")) { |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "91-180天")) { |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "181-365天")) { |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "1年以上")) { |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | return companyAgingVo; |
| | | } |
| | | |
| | | @Override |
| | | public R agingAnalysisByMarket(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("market_type"); |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| | |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | | companyAgingVo.sort(Comparator.comparing(AgingVo::getSort)); |
| | | agingAnalysisVo.setAmount(companyAgingVo.stream().map(AgingVo::getTotalAmount).collect(Collectors.toList())); |
| | | List<AgingVo> finalCompanyAgingVo = companyAgingVo; |
| | | agingAnalysisVo.setPercent(IntStream.range(0, agingVoList.size()) |
| New file |
| | |
| | | package com.by4cloud.platformx.business.utils; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.Base64; |
| | | |
| | | public class NetworkFileToBase64 { |
| | | |
| | | /** |
| | | * 将网络地址的文件转换为 Base64 字符串 |
| | | * |
| | | * @param fileUrl 网络文件的 URL 地址 |
| | | * @return Base64 编码字符串,失败返回 null |
| | | */ |
| | | public static String convertNetworkFileToBase64(String fileUrl) { |
| | | InputStream inputStream = null; |
| | | ByteArrayOutputStream outputStream = null; |
| | | |
| | | try { |
| | | // 1. 创建 URL 对象 |
| | | URL url = new URL(fileUrl); |
| | | |
| | | // 2. 打开连接 |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | | |
| | | // 3. 设置请求属性和超时时间(防止长时间挂起) |
| | | conn.setRequestMethod("GET"); |
| | | conn.setConnectTimeout(5000); // 连接超时 5秒 |
| | | conn.setReadTimeout(10000); // 读取超时 10秒 |
| | | |
| | | // 4. 获取输入流 |
| | | int responseCode = conn.getResponseCode(); |
| | | if (responseCode != HttpURLConnection.HTTP_OK) { |
| | | System.err.println("HTTP 错误代码: " + responseCode); |
| | | return null; |
| | | } |
| | | |
| | | inputStream = conn.getInputStream(); |
| | | outputStream = new ByteArrayOutputStream(); |
| | | |
| | | // 5. 读取数据到内存 |
| | | byte[] buffer = new byte[1024]; |
| | | int len; |
| | | while ((len = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, len); |
| | | } |
| | | |
| | | // 6. 获取字节数组并编码 |
| | | byte[] fileBytes = outputStream.toByteArray(); |
| | | return Base64.getEncoder().encodeToString(fileBytes); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } finally { |
| | | // 7. 关闭资源 |
| | | try { |
| | | if (inputStream != null) inputStream.close(); |
| | | if (outputStream != null) outputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.Base64; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | |
| | | String base64String = Base64.getEncoder().encodeToString(signData); |
| | | return URLEncoder.encode(base64String, "UTF-8"); |
| | | } |
| | | |
| | | public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { |
| | | long timestamp = System.currentTimeMillis(); |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", "95578dbdeabc41049b75e8af3dd66d19"); |
| | | paramMap.put("timestamp", timestamp); |
| | | System.out.println(timestamp); |
| | | System.out.println(sign(paramMap,"f3a098d7848f87042b39d2cc1645b6c0ffa065cd")); |
| | | } |
| | | } |
| New file |
| | |
| | | <?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.by4cloud.platformx.business.mapper.BankStatementMapper"> |
| | | |
| | | <resultMap id="bankStatementMap" type="com.by4cloud.platformx.business.entity.BankStatement"> |
| | | <id property="id" column="id"/> |
| | | <result property="compId" column="comp_id"/> |
| | | <result property="bankSeqNo" column="bank_seq_no"/> |
| | | <result property="dataId" column="data_id"/> |
| | | <result property="dataJson" column="data_json"/> |
| | | <result property="payBankAccName" column="pay_bank_acc_name"/> |
| | | <result property="payBankNo" column="pay_bank_no"/> |
| | | <result property="receiveBankAcc" column="receive_bank_acc"/> |
| | | <result property="receiveBankAccAcc" column="receive_bank_acc_acc"/> |
| | | <result property="receiveBankAccName" column="receive_bank_acc_name"/> |
| | | <result property="tranAmount" column="tran_amount"/> |
| | | <result property="tranDate" column="tran_date"/> |
| | | <result property="createBy" column="create_by"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="delFlag" column="del_flag"/> |
| | | </resultMap> |
| | | </mapper> |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.area_id = b.area_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.area_id = b.area_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.area_id = b.area_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.area_id = b.area_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.area_id = b.area_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.area_id IS NOT NULL |
| | | c.del_flag='0' |
| | | AND b.area_id IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.area_id |
| | |
| | | where |
| | | c1.del_flag = '0' |
| | | and c1.industry_code = c.industry_code |
| | | AND YEAR( sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | where |
| | | c1.del_flag = '0' |
| | | and c1.industry_code = c.industry_code |
| | | AND YEAR( sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | where |
| | | c1.del_flag = '0' |
| | | and c1.industry_code = c.industry_code |
| | | AND YEAR( sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | where |
| | | c1.del_flag = '0' |
| | | and c1.industry_code = c.industry_code |
| | | AND YEAR( sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | where |
| | | c1.del_flag = '0' |
| | | and c1.industry_code = c.industry_code |
| | | AND YEAR( sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | FROM |
| | | contract c |
| | | where |
| | | c.industry_code is not null |
| | | c.del_flag='0' |
| | | AND c.industry_code is not null |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | c.industry_code |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.class_id = b.class_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.class_id = b.class_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.class_id = b.class_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.class_id = b.class_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.class_id = b.class_id |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.class_id IS NOT NULL |
| | | c.del_flag='0' |
| | | AND b.class_id IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.class_id |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.export_service_attr = b.export_service_attr |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.export_service_attr = b.export_service_attr |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.export_service_attr = b.export_service_attr |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.export_service_attr = b.export_service_attr |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.export_service_attr = b.export_service_attr |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.export_service_attr IS NOT NULL |
| | | c.del_flag='0' |
| | | AND b.export_service_attr IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.export_service_attr |
| | |
| | | WHERE |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | WHERE |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | WHERE |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | WHERE |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | WHERE |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | DATE_FORMAT(sign_date, '%Y-%m') AS stat_month, |
| | | SUM(amount) AS total_amount |
| | | FROM contract |
| | | WHERE YEAR(sign_date) = #{queryDTO.year} |
| | | WHERE |
| | | del_flag='0' |
| | | AND YEAR(sign_date) = #{queryDTO.year} |
| | | AND party_b_id = #{compId} |
| | | GROUP BY DATE_FORMAT(sign_date, '%Y-%m') |
| | | ) curr ON m.stat_month = curr.stat_month |
| | |
| | | MONTH(sign_date) AS month_num, |
| | | SUM(amount) AS total_amount |
| | | FROM contract |
| | | WHERE YEAR(sign_date) = YEAR(CURDATE()) |
| | | WHERE del_flag='0' |
| | | AND YEAR(sign_date) = YEAR(CURDATE()) |
| | | AND party_b_id = #{compId} |
| | | GROUP BY DATE_FORMAT(sign_date, '%Y-%m'), MONTH(sign_date) |
| | | ) prev ON m.month_num = prev.month_num + 1 |
| | |
| | | MONTH(sign_date) AS month_num, |
| | | SUM(amount) AS total_amount |
| | | FROM contract |
| | | WHERE YEAR(sign_date) = YEAR(CURDATE()) - 1 |
| | | WHERE del_flag='0' |
| | | AND YEAR(sign_date) = YEAR(CURDATE()) - 1 |
| | | AND party_b_id = #{compId} |
| | | GROUP BY MONTH(sign_date) |
| | | ) last_year ON m.month_num = last_year.month_num |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | AND YEAR( c.sign_date ) = #{queryDTO.year} |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.sales_model IS NOT NULL |
| | | c.del_flag='0' |
| | | AND b.sales_model IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.sales_model |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hbbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) xbbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) xbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) dbbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) dbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hdbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hdbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) znbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) znbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) xnbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) xnbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.export_service_attr = '2' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hwbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hwbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * cob.out_bound_num ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.export_service_attr = '2' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.export_service_attr = '2' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hbbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND cob.subject_matter_code = csm.material_code |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) xbbr, |
| | | ( |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) xbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | | FROM |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '6' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) dbbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) dbbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '1' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hdbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hdbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '3' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) znbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) znbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '4' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) xnbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) xnbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.area_id = '5' |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.export_service_attr = '2' |
| | | AND cob.comp_id = #{compId} |
| | | <!-- AND cob.out_bound_time >= CURDATE() --> |
| | | AND cob.out_bound_time < DATE_ADD( CURDATE(), INTERVAL -6 DAY )) hwbr, |
| | | AND cob.out_bound_time >= CURDATE() |
| | | AND cob.out_bound_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) hwbr, |
| | | ( |
| | | SELECT |
| | | sum( csm.unit_price * ( cob.out_bound_num - cob.invoice_num ) ) |
| | |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND cob.contract_id = csm.contract_id |
| | | AND cob.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND cob.subject_matter_code = csm.material_code |
| | | AND bc.export_service_attr = '2' |
| | |
| | | </select> |
| | | <select id="selectAgingTotal" resultType="com.by4cloud.platformx.business.vo.AgingVo"> |
| | | SELECT |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | COALESCE(SUM( |
| | | COALESCE ( |
| | | sum( |
| | | CASE |
| | | |
| | | WHEN cps.payment_status = '0' THEN |
| | | cps.planned_amount |
| | | WHEN cps.payment_status = '1' THEN |
| | | cps.planned_amount - cps.actual_amount ELSE 0 |
| | | END |
| | | ), 0) AS total_amount |
| | | ), |
| | | 0 |
| | | ) AS total_amount |
| | | FROM |
| | | ( |
| | | SELECT '0-30天' AS overdue_range, 0 AS min_days, 30 AS max_days UNION ALL |
| | | SELECT '31-60天', 31, 60 UNION ALL |
| | | SELECT '61-90天', 61, 90 UNION ALL |
| | | SELECT '91-180天', 91, 180 UNION ALL |
| | | SELECT '181-365天', 181, 365 UNION ALL |
| | | SELECT '1年以上', 366, 999999 |
| | | ) AS ranges |
| | | LEFT JOIN |
| | | contract_payment_schedule cps ON |
| | | cps.del_flag = '0' |
| | | AND cps.payment_status NOT IN ('2', '3') |
| | | AND cps.effective_end_date < current_date |
| | | AND DATEDIFF(current_date, cps.effective_end_date) BETWEEN ranges.min_days AND ranges.max_days |
| | | LEFT JOIN |
| | | contract c ON cps.contract_id = c.id |
| | | LEFT JOIN |
| | | business_customer bc ON c.party_a_id = bc.id |
| | | where |
| | | c.del_flag = '0' |
| | | SELECT |
| | | 1 sort, |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | 2 sort, |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | 3 sort, |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | 4 sort, |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | 5 sort, |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | 6 sort, |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | | ) ranges |
| | | LEFT JOIN contract_payment_schedule cps ON cps.del_flag = '0' |
| | | AND cps.payment_status NOT IN ( '2', '3' ) |
| | | AND cps.effective_end_date < CURRENT_DATE |
| | | AND DATEDIFF( CURRENT_DATE, cps.effective_end_date ) BETWEEN ranges.min_days |
| | | AND ranges.max_days |
| | | LEFT JOIN contract c ON cps.contract_id = c.id |
| | | LEFT JOIN business_customer bc ON c.party_a_id = bc.id |
| | | WHERE |
| | | c.del_flag = '0' |
| | | <if test="queryDTO.companyId !=null"> |
| | | and c.party_a_id = #{queryDTO.companyId} |
| | | and c.comp_id = #{queryDTO.companyId} |
| | | </if> |
| | | <if test="queryDTO.areaId !=null"> |
| | | and bc.area_id = #{queryDTO.areaId} |
| | |
| | | and bc.class_id = #{queryDTO.classId} |
| | | </if> |
| | | GROUP BY |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | ranges.min_days |
| | | ORDER BY |
| | | ranges.min_days; |
| | | ranges.min_days |
| | | </select> |
| | | <select id="selectAgingCompanyShip" resultType="com.by4cloud.platformx.business.vo.AgingCompanyVo"> |
| | | SELECT |
| | |
| | | </select> |
| | | <select id="selectAgingTotalShip" resultType="com.by4cloud.platformx.business.vo.AgingVo"> |
| | | SELECT |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | COALESCE ( |
| | | sum(amount-paid_amount), |
| | |
| | | ) AS total_amount |
| | | FROM |
| | | ( |
| | | SELECT |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | | ) ranges |
| | | SELECT |
| | | 1 sort, |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | 2 sort, |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | 3 sort, |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | 4 sort, |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | 5 sort, |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | 6 sort, |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | | ) ranges |
| | | LEFT JOIN contract c ON c.del_flag = '0' |
| | | AND DATEDIFF( |
| | | CURRENT_DATE, |
| | |
| | | </if> |
| | | AND EXISTS ( SELECT 1 FROM contract_out_bound cob WHERE cob.del_flag = '0' AND cob.contract_id = c.id ) |
| | | GROUP BY |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | ranges.min_days |
| | | ORDER BY |
| | |
| | | </select> |
| | | <select id="selectAgingTotalInvoice" resultType="com.by4cloud.platformx.business.vo.AgingVo"> |
| | | SELECT |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | COALESCE ( |
| | | sum(amount-paid_amount), |
| | |
| | | ) AS total_amount |
| | | FROM |
| | | ( |
| | | SELECT |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | | ) ranges |
| | | SELECT |
| | | 1 sort, |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | 2 sort, |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | 3 sort, |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | 4 sort, |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | 5 sort, |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | 6 sort, |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | | ) ranges |
| | | LEFT JOIN contract c ON c.del_flag = '0' |
| | | AND DATEDIFF( |
| | | CURRENT_DATE, |
| | |
| | | </if> |
| | | AND EXISTS ( SELECT 1 FROM contract_invoice ci WHERE ci.del_flag = '0' AND ci.contract_id = c.id) |
| | | GROUP BY |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | ranges.min_days |
| | | ORDER BY |
| | |
| | | </select> |
| | | <select id="selectAgingTotalScale" resultType="com.by4cloud.platformx.business.vo.AgingVo"> |
| | | SELECT |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | COALESCE ( |
| | | SUM( |
| | |
| | | FROM |
| | | ( |
| | | SELECT |
| | | 1 sort, |
| | | '0-30天' AS overdue_range, |
| | | 0 AS min_days, |
| | | 30 AS max_days UNION ALL |
| | | SELECT |
| | | 2 sort, |
| | | '31-60天', |
| | | 31, |
| | | 60 UNION ALL |
| | | SELECT |
| | | 3 sort, |
| | | '61-90天', |
| | | 61, |
| | | 90 UNION ALL |
| | | SELECT |
| | | 4 sort, |
| | | '91-180天', |
| | | 91, |
| | | 180 UNION ALL |
| | | SELECT |
| | | 5 sort, |
| | | '181-365天', |
| | | 181, |
| | | 365 UNION ALL |
| | | SELECT |
| | | 6 sort, |
| | | '1年以上', |
| | | 366, |
| | | 999999 |
| | |
| | | and c.party_b_id = #{queryDTO.companyId} |
| | | </if> |
| | | GROUP BY |
| | | ranges.sort, |
| | | ranges.overdue_range, |
| | | ranges.min_days |
| | | ORDER BY |
| | |
| | | t.id, |
| | | t.bus_guest_name, |
| | | t.bus_guest_id, |
| | | t1.contract_no, |
| | | t.contract_name, |
| | | t.contract_id, |
| | | t.material_name, |
| | |
| | | <if test="queryDTO.parentId !=null "> |
| | | and t.parent_id = #{queryDTO.parentId} |
| | | </if> |
| | | <if test="queryDTO.contractCategory !=null and queryDTO.contractCategory !='' and queryDTO.contractCategory=='water_house'"> |
| | | and t.erp_code in |
| | | <foreach collection="erpCodes" item="erp" open="(" separator="," close=")"> |
| | | #{erp} |
| | | </foreach> |
| | | </if> |
| | | <choose> |
| | | <when test="queryDTO.contractCategory !=null and queryDTO.contractCategory !='' and queryDTO.contractCategory=='water_house'"> |
| | | and t.erp_code in |
| | | <foreach collection="erpCodes" item="erp" open="(" separator="," close=")"> |
| | | #{erp} |
| | | </foreach> |
| | | </when> |
| | | <otherwise> |
| | | and t.erp_code not in |
| | | <foreach collection="erpCodes" item="erp" open="(" separator="," close=")"> |
| | | #{erp} |
| | | </foreach> |
| | | </otherwise> |
| | | </choose> |
| | | |
| | | </select> |
| | | </mapper> |