feat:银行流水关联多个合同,新增预收款开票,所有List校验调整为ColUtil
| | |
| | | package com.by4cloud.platformx.business.dto; |
| | | |
| | | import com.by4cloud.platformx.business.entity.StatementContractDTO; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class BankStatementUpdateDTO { |
| | | |
| | | private Long id; |
| | | |
| | | private Long contractId; |
| | | private List<StatementContractDTO> contractCollectionList; |
| | | |
| | | } |
| | |
| | | * 1 是 0 否 |
| | | */ |
| | | private String invoiceType; |
| | | |
| | | /** |
| | | * 预收发票标识 |
| | | */ |
| | | private String advanceType; |
| | | } |
| | |
| | | |
| | | private String contractCategory; |
| | | |
| | | private String contractId; |
| | | |
| | | } |
| | |
| | | private String payType; |
| | | |
| | | private BigDecimal transationAmount; |
| | | |
| | | private String bankSeqNo; |
| | | |
| | | } |
| | |
| | | |
| | | private String bipCode; |
| | | |
| | | private Integer pageSize; |
| | | |
| | | private Integer pageNum; |
| | | |
| | | } |
| | |
| | | @Schema(description = "合同ID") |
| | | @Column(columnDefinition="bigint comment '合同ID'") |
| | | private Long contractId; |
| | | |
| | | @Schema(description = "合同确认金额") |
| | | @Column(columnDefinition = "decimal(10,2) comment '合同确认金额'") |
| | | private BigDecimal confirmAmount; |
| | | |
| | | @Schema(description = "交易说明") |
| | | @Column(columnDefinition="VARCHAR(255) comment '交易说明'") |
| | | private String remark; |
| | | |
| | | } |
| 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_item",comment = "银行流水合同确认明细")//给表加注释 |
| | | @jakarta.persistence.Table(name = "bank_statement_item")//数据库创建的表明 |
| | | public class BankStatementItem extends BaseModel<BankStatementItem> { |
| | | |
| | | @Schema(description = "银行流水ID") |
| | | @Column(columnDefinition="bigint comment '银行流水ID'") |
| | | private Long statetId; |
| | | |
| | | @Schema(description = "交易流水") |
| | | @Column(columnDefinition="VARCHAR(128) comment '交易流水'") |
| | | private String bankSeqNo; |
| | | |
| | | @Schema(description = "合同ID") |
| | | @Column(columnDefinition="bigint comment '合同ID'") |
| | | private Long contractId; |
| | | |
| | | @Schema(description = "合同确认金额") |
| | | @Column(columnDefinition = "decimal(10,2) comment '合同确认金额'") |
| | | private BigDecimal confirmAmount; |
| | | |
| | | } |
| | |
| | | private String requestParams; |
| | | |
| | | @Schema(description = "回参") |
| | | @Column(columnDefinition="text comment '回参'") |
| | | @Column(columnDefinition="longtext comment '回参'") |
| | | private String responseParams; |
| | | |
| | | @Schema(description = "结果码") |
| | |
| | | @Schema(description = "erp企业编码") |
| | | @Column(columnDefinition = "VARCHAR(64) comment 'erp企业编码'") |
| | | private String erpCompanyCode; |
| | | |
| | | @Schema(description = "客户bip编码") |
| | | @Column(columnDefinition = "VARCHAR(64) comment '客户bip编码'") |
| | | private String bipCode; |
| | | } |
| | |
| | | @Column(columnDefinition="VARCHAR(128) comment '接口名称'") |
| | | private String interfaceName; |
| | | |
| | | @Schema(description = "接口名称") |
| | | @Column(columnDefinition="VARCHAR(128) comment '接口名称'") |
| | | @Schema(description = "请求唯一标识") |
| | | @Column(columnDefinition="VARCHAR(128) comment '请求唯一标识'") |
| | | private String requestId; |
| | | |
| | | @Schema(description = "请求唯一标识") |
| | | @Column(columnDefinition="VARCHAR(64) comment '请求唯一标识'") |
| | | @Schema(description = "入参") |
| | | @Column(columnDefinition="text comment '入参'") |
| | | private String requestParams; |
| | | |
| | | @Schema(description = "回参") |
| | |
| | | |
| | | @Schema(description = "机构税号") |
| | | @Column(columnDefinition="varchar(64) comment '机构税号'") |
| | | private String texNo; |
| | | private String taxNo; |
| | | |
| | | @Schema(description = "销售方名称") |
| | | @Column(columnDefinition="varchar(128) comment '销售方名称'") |
| | |
| | | @Schema(description = "购买方名称") |
| | | @Column(columnDefinition="varchar(128) comment '购买方名称'") |
| | | private String buyerTaxName; |
| | | |
| | | @Schema(description = "购买方税号") |
| | | @Column(columnDefinition="varchar(128) comment '购买方名称'") |
| | | private String buyerTaxNo; |
| | | |
| | | @Schema(description = "发票预览信息") |
| | | @Column(columnDefinition="text comment '发票预览信息'") |
| | |
| | | private String bipPush; |
| | | |
| | | @Schema(description = "bip推送成功后返回数据ID") |
| | | @Column(columnDefinition="bigint comment 'bip推送标识 1/已推送 0/未推送'") |
| | | @Column(columnDefinition="bigint comment 'bip推送成功后返回数据ID'") |
| | | private Long bipId; |
| | | |
| | | @Schema(description = "发票预览bip推送成功后返回的数据结构") |
| | | @Column(columnDefinition="text comment '发票预览信息'") |
| | | @Column(columnDefinition="text comment '发票预览bip推送成功后返回的数据结构'") |
| | | private String bipBody; |
| | | |
| | | @Schema(description = "关联请求ID") |
| | | @Column(columnDefinition = "varchar(64) comment '关联请求ID'") |
| | | private String bwRequestId; |
| | | |
| | | @Schema(description = "预收开票标识") |
| | | @Column(columnDefinition = "char default '0' comment '0/否 1/是'") |
| | | private String advanceFlag; |
| | | } |
| | |
| | | @Column(columnDefinition="decimal(10,2) comment '已开票数量'") |
| | | private BigDecimal invoiceNum; |
| | | |
| | | @Schema(description = "预开票数量") |
| | | @Column(columnDefinition="decimal(10,2) DEFAULT 0.00 comment '预开票数量'") |
| | | private BigDecimal advanceNum; |
| | | |
| | | |
| | | // //以下开票相关 |
| | | // |
| | |
| | | @Column(columnDefinition = "decimal(10,2) comment '总重 /kg'") |
| | | private BigDecimal totalWight; |
| | | |
| | | @Schema(description = "预开票数量") |
| | | @Column(columnDefinition="decimal(10,2) DEFAULT 0.00 comment '预开票数量'") |
| | | private BigDecimal advanceNum; |
| | | |
| | | @Schema(description = "备注") |
| | | @Column(columnDefinition="text comment '备注'") |
| | | private String remarks; |
| | |
| | | @Column(columnDefinition="VARCHAR(128) comment '接口名称'") |
| | | private String erpName; |
| | | |
| | | @Schema(description = "请求唯一标识") |
| | | @Column(columnDefinition="VARCHAR(64) comment '请求唯一标识'") |
| | | @Schema(description = "入参") |
| | | @Column(columnDefinition="text comment '入参'") |
| | | private String requestParams; |
| | | |
| | | @Schema(description = "回参") |
| | |
| | | @Schema(description = "合同ID") |
| | | @Column(columnDefinition="bigint comment '合同ID'") |
| | | private Long contractId; |
| | | |
| | | @Schema(description = "银行流水号") |
| | | @Column(columnDefinition="VARCHAR(255) comment '银行流水号'") |
| | | private String bankSeqNo; |
| | | } |
| New file |
| | |
| | | package com.by4cloud.platformx.business.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class StatementContractDTO { |
| | | |
| | | private Long id; |
| | | |
| | | private BigDecimal toPaidAmount; |
| | | |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.vo; |
| | | |
| | | import com.by4cloud.platformx.business.entity.ContractPaymentSchedule; |
| | | import com.by4cloud.platformx.business.entity.ContractSubjectMatter; |
| | | import com.by4cloud.platformx.business.entity.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.persistence.Column; |
| | |
| | | private List<ContractPaymentSchedule> contractPaymentSchedule; |
| | | |
| | | private List<ContractSubjectMatter> contractSubjectMatter; |
| | | |
| | | private List<ContractOutBound> contractOutBound; |
| | | |
| | | private List<PaymentSlip> paymentSlip; |
| | | |
| | | private List<ContractInvoice> contractInvoice; |
| | | } |
| | |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "标的物行号") |
| | | private String lineNo; |
| | | |
| | | @Schema(description = "标的物名称") |
| | | private String subjectMatterName; |
| | | |
| | |
| | | @Schema(description = "出库数量") |
| | | private BigDecimal outBoundNum; |
| | | |
| | | @Schema(description = "出库日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date outBoundTime; |
| | | |
| | | @Schema(description = "开票数量") |
| | | private BigDecimal invoiceNum; |
| | | |
| | | @Schema(description = "拟开票数量") |
| | | private BigDecimal toInvoiceNum; |
| | | |
| | | @Schema(description = "预开票数量") |
| | | private BigDecimal advanceNum; |
| | | |
| | | @Schema(description = "单价") |
| | | private BigDecimal unitPrice; |
| | | |
| | | @Schema(description = "开票状态(0-未开票 1-开票中 2-已开票)") |
| | | private String invoiceStatus; |
| | | |
| | | } |
| | |
| | | |
| | | @Schema(description = "合同分类") |
| | | private Integer invoiceNum; |
| | | |
| | | @Schema(description = "预收款") |
| | | private BigDecimal advanceAmount; |
| | | } |
| | |
| | | |
| | | private String custName; |
| | | |
| | | private String custCode; |
| | | |
| | | private String legalPerson; |
| | | |
| | | private String registrationAddress; |
| | |
| | | @Schema(description = "合同类型") |
| | | private String contractCategory; |
| | | |
| | | @Schema(description = "预开发票") |
| | | private String advanceInvoice; |
| | | |
| | | @Schema(description = "甲方名称") |
| | | private String partyA; |
| | | |
| | |
| | | LambdaQueryWrapper<BusinessCustomer> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.like(StrUtil.isNotEmpty(businessCustomer.getCompanyName()),BusinessCustomer::getCompanyName,businessCustomer.getCompanyName()); |
| | | List<BusinessCustomer> businessCustomerList = businessCustomerService.listByScope(wrapper); |
| | | if (ArrayUtil.isNotEmpty(businessCustomerList.toArray())){ |
| | | if (CollUtil.isNotEmpty(businessCustomerList)){ |
| | | List<BusinessCustomerSelectVo> voList = BeanUtil.copyToList(businessCustomerList, BusinessCustomerSelectVo.class); |
| | | if (voList.size()>1000){ |
| | | return R.ok(voList.subList(0,1000)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取合同预开票信息 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getContractAdvance/{contractId}" ) |
| | | public R getContractAdvance(@PathVariable("contractId")Long contractId) { |
| | | return contractInvoiceService.getContractAdvance(contractId); |
| | | } |
| | | |
| | | /** |
| | | * 获取合同房租 水电 费用信息 |
| | | * @return |
| | | */ |
| | |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_product_add')" ) |
| | | public R save(@RequestBody Product product) { |
| | | if (ArrayUtil.isNotEmpty(productService.listByScope(Wrappers.lambdaQuery(product).eq(Product::getErpCode,product.getErpCode())).toArray())){ |
| | | if (CollUtil.isNotEmpty(productService.listByScope(Wrappers.lambdaQuery(product).eq(Product::getErpCode,product.getErpCode())))){ |
| | | return R.failed("产品Erp编码已存在"); |
| | | } |
| | | return R.ok(productService.save(product)); |
| New file |
| | |
| | | package com.by4cloud.platformx.business.mapper; |
| | | |
| | | import com.by4cloud.platformx.business.entity.BankStatementItem; |
| | | import com.by4cloud.platformx.common.data.datascope.PlatformxBaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface BankStatementItemMapper extends PlatformxBaseMapper<BankStatementItem> { |
| | | |
| | | |
| | | } |
| | |
| | | @DS("druid_bip_view") |
| | | public interface BipViewMapper { |
| | | |
| | | @Select("select certificate_id, cust_name,legal_person,registration_address from mdm_send.mdm_cust_base_info_tra_send WHERE is_deleted = '0' and cust_name = #{companyName}") |
| | | @Select("select certificate_id, cust_name,legal_person,registration_address,cust_code from mdm_send.mdm_cust_base_info_tra_send WHERE is_deleted = '0' and cust_name = #{companyName}") |
| | | CustInfoVo selectBaseInfoByCustName(String companyName); |
| | | |
| | | @Select("SELECT mcbats.bank_account,mcbats.bank_name FROM mdm_send.mdm_cust_bank_account_tra_send AS mcbats WHERE is_deleted = '0' and holder_name = #{companyName}") |
| | |
| | | public interface ContractInvoiceService { |
| | | R getContractOutBound(Long contractId); |
| | | |
| | | R getContractAdvance(Long contractId); |
| | | |
| | | R genInvoiceInfo(GenInvoiceInfoDTO genInvoiceInfoDTO); |
| | | |
| | | R toInvoice(GenInvoiceInfoDTO genInvoiceInfoDTO); |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.admin.api.entity.SysDept; |
| | | import com.by4cloud.platformx.admin.api.feign.RemoteDeptService; |
| | | 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.entity.*; |
| | | import com.by4cloud.platformx.business.mapper.BankStatementItemMapper; |
| | | 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 com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | 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; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 银行流水 |
| | | * |
| | |
| | | private final ContractMapper contractMapper; |
| | | private final BusinessCustomerMapper businessCustomerMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final RemoteDeptService remoteDeptService; |
| | | private final BankStatementItemMapper bankStatementItemMapper; |
| | | |
| | | @Value("${bip.url}") |
| | | private String url; |
| | | |
| | | @Value("${BWInvoice.flag}") |
| | | private Boolean bwFlag; |
| | | |
| | | @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("合同查询失败"); |
| | | if (CollUtil.isEmpty(updateDTO.getContractCollectionList())){ |
| | | 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; |
| | | BigDecimal toPaidTotal = updateDTO.getContractCollectionList().stream() .map(StatementContractDTO::getToPaidAmount) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (toPaidTotal.compareTo(statement.getTranAmount().subtract(statement.getConfirmAmount()))>0){ |
| | | return R.failed("确认收款总额不能超过交易流水金额"); |
| | | } |
| | | statement.setContractId(updateDTO.getContractId()); |
| | | statement.setConfirmAmount(statement.getConfirmAmount().add(toPaidTotal)); |
| | | baseMapper.updateById(statement); |
| | | |
| | | updateDTO.getContractCollectionList().stream().forEach(statementContractDTO -> { |
| | | BankStatementItem item = new BankStatementItem(); |
| | | item.setStatetId(statement.getId()); |
| | | item.setBankSeqNo(statement.getBankSeqNo()); |
| | | item.setConfirmAmount(statementContractDTO.getToPaidAmount()); |
| | | item.setContractId(statementContractDTO.getId()); |
| | | bankStatementItemMapper.insert(item); |
| | | |
| | | Contract contract = contractMapper.selectById(statementContractDTO.getId()); |
| | | PaymentConfirmAddDTO addDTO = new PaymentConfirmAddDTO(); |
| | | addDTO.setBusGuestId(statement.getBusGuestId()+""); |
| | | addDTO.setConfirmTime(statement.getTranDate()); |
| | | addDTO.setContractNo(contract.getContractNo()); |
| | | addDTO.setInOrOut("1"); |
| | | addDTO.setTransationAmount(statementContractDTO.getToPaidAmount()); |
| | | addDTO.setBankSeqNo(statement.getBankSeqNo()); |
| | | paymentConfirmService.add(addDTO); |
| | | }); |
| | | |
| | | |
| | | |
| | | //bip推送 |
| | | pushSaveCollection(statement); |
| | | if (bwFlag) { |
| | | pushSaveCollection(statement, updateDTO.getContractCollectionList()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private void pushSaveCollection(BankStatement statement) { |
| | | private void pushSaveCollection(BankStatement statement, List<StatementContractDTO> contractDTOList) { |
| | | String accessToken = ""; |
| | | if (redisTemplate.hasKey("BIP_TOKEN")) { |
| | | accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN"); |
| | | } else { |
| | | paymentConfirmService.getAccessToken(accessToken); |
| | | accessToken = paymentConfirmService.getAccessToken(accessToken); |
| | | } |
| | | if (StrUtil.isEmpty(accessToken)) { |
| | | log.error("bip accessToken 获取异常"); |
| | | return; |
| | | } |
| | | String finalAccessToken = accessToken; |
| | | JSONObject params = genRequestParam(statement); |
| | | |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(statement.getBusGuestId()); |
| | | if (ObjUtil.isNull(customer)||StrUtil.isEmpty(customer.getBipCode())){ |
| | | log.error("查询客户信息异常"); |
| | | return; |
| | | } |
| | | R<SysDept> r = remoteDeptService.getById(SecurityUtils.getUser().getCompId()); |
| | | if (!r.isOk()){ |
| | | log.error("查询单位信息异常"); |
| | | return; |
| | | } |
| | | SysDept dept = r.getData(); |
| | | JSONObject params = genRequestParam(statement,dept,customer,contractDTOList); |
| | | |
| | | log.info("收款单集成 Request:{}", params.toJSONString()); |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/receivable/save?access_token=" + finalAccessToken, params.toJSONString()); |
| | |
| | | |
| | | } |
| | | |
| | | private JSONObject genRequestParam(BankStatement statement) { |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(statement.getBusGuestId()); |
| | | Contract contract = contractMapper.selectById(statement.getContractId()); |
| | | JSONObject req = new JSONObject(); |
| | | |
| | | private JSONObject genRequestParam(BankStatement statement,SysDept dept,BusinessCustomer customer,List<StatementContractDTO> contractDTOList) { |
| | | JSONObject jsonObject = 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("billDate",DateUtil.format(statement.getTranDate(), DatePattern.NORM_DATETIME_FORMAT)); |
| | | data.put("exchangeRate","1");//汇率 |
| | | data.put("exchangeRateDate",DateUtil.now());//汇率时间 |
| | | 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("customerCode",customer.getBipCode());//客户编码 |
| | | data.put("financeOrgCode",dept.getBipCode());//开票组织编码 |
| | | data.put("orgCode",dept.getBipCode());//业务组织编码 |
| | | data.put("bustypeCode","");//交易类型编码 暂估默认ZGYSFP,销售默认MJHYXGLXT |
| | | data.put("oriCurrencyCode","CNY");//币种 |
| | | data.put("_status","Insert"); |
| | | data.put("oriTaxIncludedAmount",statement.getTranAmount()); |
| | | |
| | | req.put("data",data); |
| | | return req; |
| | | |
| | | JSONArray bodyItem = new JSONArray(); |
| | | for (StatementContractDTO statementContractDTO:contractDTOList) { |
| | | Contract contract = contractMapper.selectById(statementContractDTO.getId()); |
| | | JSONObject item = new JSONObject(); |
| | | item.put("oriTaxIncludedAmount", statementContractDTO.getToPaidAmount()); |
| | | item.put("contractNo", contract.getContractNo()); |
| | | item.put("quickTypeCode", "1"); |
| | | item.put("_status", "Insert"); |
| | | bodyItem.add(item); |
| | | } |
| | | data.put("bodyItem",bodyItem); |
| | | jsonObject.put("data",data); |
| | | return jsonObject; |
| | | } |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | .or().isNull(BusinessCustomer::getLegalPerson) |
| | | .or().isNull(BusinessCustomer::getBankName) |
| | | .or().isNull(BusinessCustomer::getBankAccount) |
| | | .or().isNull(BusinessCustomer::getRegisterName)) |
| | | .or().isNull(BusinessCustomer::getRegisterName) |
| | | .or().isNull(BusinessCustomer::getBipCode)) |
| | | ); |
| | | if (ArrayUtil.isNotEmpty(bcList.toArray())){ |
| | | if (CollUtil.isNotEmpty(bcList)){ |
| | | for (BusinessCustomer bc:bcList |
| | | ) { |
| | | log.info("开始同步{}信息",bc.getCompanyName()); |
| | | CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(bc.getCompanyName()); |
| | | if (ObjUtil.isNull(custInfo)){ |
| | | continue; |
| | | } |
| | | if (ObjUtil.isNotNull(custInfo)){ |
| | | bc.setCreditCode(custInfo.getCertificateId()); |
| | | bc.setRegisterName(custInfo.getCustName()); |
| | | bc.setLegalPerson(custInfo.getLegalPerson()); |
| | | bc.setAddress(custInfo.getRegistrationAddress()); |
| | | bc.setBipCode(custInfo.getCustCode()); |
| | | baseMapper.updateById(bc); |
| | | log.info("{}同步名称、法人、地址、信用码信息成功",bc.getCompanyName()); |
| | | log.info("{}同步名称、法人、地址、信用码、bipcode信息成功",bc.getCompanyName()); |
| | | } |
| | | List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(bc.getCompanyName()); |
| | | if (ArrayUtil.isNotEmpty(bankVoList.toArray())){ |
| | | if (CollUtil.isEmpty(bankVoList)){ |
| | | continue; |
| | | } |
| | | if (CollUtil.isNotEmpty(bankVoList)){ |
| | | if (StrUtil.isEmpty(bc.getBankAccount())){ |
| | | bc.setBankAccount(bankVoList.get(0).getBankAccount()); |
| | | baseMapper.updateById(bc); |
| | | log.info("{}同步银行卡号信息成功",bc.getCompanyName()); |
| | | } |
| | | List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName()); |
| | | if (ArrayUtil.isNotEmpty(bankNameVoList.toArray())){ |
| | | if (CollUtil.isNotEmpty(bankNameVoList)){ |
| | | bc.setBankName(bankNameVoList.get(0).getBankNameName()); |
| | | baseMapper.updateById(bc); |
| | | log.info("{}同步银行名称信息成功",bc.getCompanyName()); |
| | |
| | | log.info("{}主数据查询名称、法人、地址、信用码信息成功",companyName); |
| | | } |
| | | List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(bc.getCompanyName()); |
| | | if (ArrayUtil.isNotEmpty(bankVoList.toArray())){ |
| | | if (CollUtil.isNotEmpty(bankVoList)){ |
| | | if (StrUtil.isEmpty(bc.getBankAccount())){ |
| | | bc.setBankAccount(bankVoList.get(0).getBankAccount()); |
| | | log.info("{}主数据查询银行卡号信息成功",companyName); |
| | | } |
| | | List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName()); |
| | | if (ArrayUtil.isNotEmpty(bankNameVoList.toArray())){ |
| | | if (CollUtil.isNotEmpty(bankNameVoList)){ |
| | | bc.setBankName(bankNameVoList.get(0).getBankNameName()); |
| | | log.info("{}主数据查询银行名称信息成功",companyName); |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DatePattern; |
| | | 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.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.by4cloud.platformx.business.vo.*; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.data.datascope.DataScope; |
| | | import com.by4cloud.platformx.common.data.mybatis.BaseModel; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.by4cloud.platformx.flow.task.dto.ProcessInstanceParamDto; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springdoc.core.annotations.ParameterObject; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | |
| | | public class ContractInvoiceServiceImpl extends ServiceImpl<ContractInvoiceMapper, ContractInvoice> implements ContractInvoiceService { |
| | | |
| | | private final ContractMapper contractMapper; |
| | | private final ContractSubjectMatterMapper contractSubjectMatterMapper; |
| | | private final BusinessCustomerMapper businessCustomerMapper; |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | private final PaymentConfirmMapper paymentConfirmMapper; |
| | |
| | | private final RemoteDeptService remoteDeptService; |
| | | private final RemoteFlowProcessService remoteFlowProcessService; |
| | | private final PaymentConfirmService paymentConfirmService; |
| | | private final RedisTemplate redisTemplate; |
| | | private final StringRedisTemplate redisTemplate; |
| | | |
| | | |
| | | @Value("${BWInvoice.url}") |
| | |
| | | .selectAll(ContractOutBound.class) |
| | | .eq(ContractOutBound::getContractId, contractId); |
| | | List<ContractInvoiceOutBoundVo> invoiceOutBoundVoList = contractOutBoundMapper.selectJoinList(ContractInvoiceOutBoundVo.class, wrapper); |
| | | if (ArrayUtil.isNotEmpty(invoiceOutBoundVoList.toArray())) { |
| | | if (CollUtil.isNotEmpty(invoiceOutBoundVoList)) { |
| | | invoiceOutBoundVoList.stream().forEach(contractInvoiceOutBoundVo -> { |
| | | |
| | | contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(contractInvoiceOutBoundVo.getInvoiceNum())); |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,contractId) |
| | | .eq(ContractSubjectMatter::getMaterialCode,contractInvoiceOutBoundVo.getSubjectMatterCode()) |
| | | .eq(StrUtil.isNotBlank(contractInvoiceOutBoundVo.getLineNo()),ContractSubjectMatter::getLineNo,contractInvoiceOutBoundVo.getLineNo()) |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNotNull(subjectMatter)&&subjectMatter.getAdvanceNum().compareTo(new BigDecimal("0"))>0){ |
| | | contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(subjectMatter.getAdvanceNum())); |
| | | } |
| | | contractInvoiceOutBoundVo.setToInvoiceNum(contractInvoiceOutBoundVo.getInvoiceNum()); |
| | | }); |
| | | } |
| | | return R.ok(invoiceOutBoundVoList); |
| | | } |
| | | |
| | | @Override |
| | | public R getContractAdvance(Long contractId) { |
| | | MPJLambdaWrapper<ContractSubjectMatter> wrapper = new MPJLambdaWrapper<ContractSubjectMatter>() |
| | | .selectAll(ContractSubjectMatter.class) |
| | | .selectAs(ContractSubjectMatter::getMaterialCode, "subjectMatterCode") |
| | | .selectAs(ContractSubjectMatter::getMaterialName, "subjectMatterName") |
| | | .selectAs(ContractSubjectMatter::getQuantity, "outBoundNum") |
| | | .eq(ContractSubjectMatter::getContractId, contractId); |
| | | List<ContractInvoiceOutBoundVo> invoiceOutBoundVoList = contractSubjectMatterMapper.selectJoinList(ContractInvoiceOutBoundVo.class, wrapper); |
| | | if (ArrayUtil.isNotEmpty(invoiceOutBoundVoList)) { |
| | | invoiceOutBoundVoList.stream().forEach(contractInvoiceOutBoundVo -> { |
| | | contractInvoiceOutBoundVo.setInvoiceNum(contractInvoiceOutBoundVo.getOutBoundNum().subtract(contractInvoiceOutBoundVo.getAdvanceNum())); |
| | | contractInvoiceOutBoundVo.setToInvoiceNum(contractInvoiceOutBoundVo.getInvoiceNum()); |
| | | }); |
| | | } |
| | |
| | | return R.failed("请选择开票出库单后再操作"); |
| | | } |
| | | Long contractId = null; |
| | | if (!StrUtil.equals(genInvoiceInfoDTO.getContractCategory(),"water_house")) { |
| | | if (StrUtil.isNotBlank(genInvoiceInfoDTO.getContractId())) { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getStageName, "合同签订").eq(ContractPaymentSchedule::getContractId,genInvoiceInfoDTO.getContractId()) |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNull(schedule)) { |
| | | return R.failed("合同预收款阶段异常,请联系技术人员"); |
| | | } |
| | | Contract contract = contractMapper.selectById(genInvoiceInfoDTO.getContractId()); |
| | | if (ObjUtil.isNull(contract)) { |
| | | return R.failed("合同信息异常,请联系技术人员"); |
| | | } |
| | | R<SysDept> r = remoteDeptService.getById(contract.getPartyBId()); |
| | | if (!r.isOk()) { |
| | | return R.failed("获取开票单位异常"); |
| | | } |
| | | SysDept b = r.getData(); |
| | | BigDecimal advanceAmount = new BigDecimal("0"); |
| | | for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : genInvoiceInfoDTO.getOutBoundInvoiceList()) { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(subjectMatter)) { |
| | | advanceAmount = advanceAmount.add(contractOutBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice())); |
| | | } |
| | | } |
| | | log.info("advanceAmount:{}",advanceAmount); |
| | | log.info("schedule.getPlannedAmount:{}",schedule.getPlannedAmount()); |
| | | if (advanceAmount.compareTo(schedule.getPlannedAmount()) > 0) { |
| | | return R.failed("开票金额超出合同签订阶段应收金额:" + schedule.getPlannedAmount() + ",请调整开票数量"); |
| | | } |
| | | GenInvoiceInfoVo vo = genAdvanceInvoiceInfoVo(genInvoiceInfoDTO, contract, b); |
| | | |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | if (!StrUtil.equals(genInvoiceInfoDTO.getContractCategory(), "water_house")) { |
| | | ContractOutBound outBound = contractOutBoundMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId()); |
| | | contractId = outBound.getContractId(); |
| | | }else { |
| | | } else { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId()); |
| | | contractId = schedule.getContractId(); |
| | | } |
| | |
| | | List<ContractOutBoundMergeVo> mergeOutBounds = new ArrayList<>(); |
| | | // List<ContractOutBound> outBounds = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery() |
| | | // .in(ContractOutBound::getId, genInvoiceInfoDTO.getOutBoundInvoiceList().stream().map(item->item.getContractOutBoundId()).collect(Collectors.toList()))); |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")){ |
| | | if (ArrayUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList().toArray())) { |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | if (CollUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) { |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | |
| | | if (!ArrayUtil.contains(erpCode.toArray(), contractOutBound.getSubjectMatterCode())) { |
| | | if (!CollUtil.contains(erpCode, contractOutBound.getSubjectMatterCode())) { |
| | | erpCode.add(contractOutBound.getSubjectMatterCode()); |
| | | ContractOutBoundMergeVo mergeVo = new ContractOutBoundMergeVo(); |
| | | mergeVo.setMaterialCode(contractOutBound.getSubjectMatterCode()); |
| | |
| | | List<ContractOutBoundMergeVo> filteredList = mergeOutBounds.stream() |
| | | .filter(item -> contractOutBound.getSubjectMatterCode().equals(item.getMaterialCode())) // 防止空指针,建议常量在前 |
| | | .collect(Collectors.toList()); |
| | | if (ArrayUtil.isNotEmpty(filteredList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(filteredList)) { |
| | | filteredList.get(0).setQuantity(filteredList.get(0).getQuantity().add(contractOutBound.getOutBoundNum())); |
| | | } |
| | | } |
| | | }); |
| | | if (ArrayUtil.isNotEmpty(mergeOutBounds.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(mergeOutBounds)) { |
| | | invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class); |
| | | invoiceItemVoList.stream().forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | |
| | | vo.setPriceWords(Convert.digitToChinese(vo.getTotalPrice())); |
| | | } |
| | | } |
| | | }else { |
| | | if (ArrayUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList().toArray())) { |
| | | } else { |
| | | if (ArrayUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) { |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | |
| | | if (!ArrayUtil.contains(erpCode.toArray(), schedule.getSubjectMatterCode())) { |
| | | if (!CollUtil.contains(erpCode, schedule.getSubjectMatterCode())) { |
| | | erpCode.add(schedule.getSubjectMatterCode()); |
| | | ContractOutBoundMergeVo mergeVo = new ContractOutBoundMergeVo(); |
| | | mergeVo.setMaterialCode(schedule.getSubjectMatterCode()); |
| | |
| | | mergeVo.setUnitPrice(subjectMatter.getUnitPrice()); |
| | | } |
| | | mergeOutBounds.add(mergeVo); |
| | | }else { |
| | | List<ContractOutBoundMergeVo> filterMergeVo = mergeOutBounds.stream().filter(item->item.getMaterialCode() |
| | | } else { |
| | | List<ContractOutBoundMergeVo> filterMergeVo = mergeOutBounds.stream().filter(item -> item.getMaterialCode() |
| | | .equals(schedule.getSubjectMatterCode())).collect(Collectors.toList()); |
| | | if (ArrayUtil.isNotEmpty(filterMergeVo.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(filterMergeVo)) { |
| | | filterMergeVo.get(0).setPriceAndTax(schedule.getPlannedAmount().add(filterMergeVo.get(0).getPriceAndTax())); |
| | | } |
| | | } |
| | | }); |
| | | if (ArrayUtil.isNotEmpty(mergeOutBounds.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(mergeOutBounds)) { |
| | | invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class); |
| | | invoiceItemVoList.stream().forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | |
| | | return vo; |
| | | } |
| | | |
| | | private GenInvoiceInfoVo genAdvanceInvoiceInfoVo(GenInvoiceInfoDTO genInvoiceInfoDTO, Contract contract, SysDept b) { |
| | | GenInvoiceInfoVo vo = new GenInvoiceInfoVo(); |
| | | BusinessCustomer a = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | vo.setAdvanceInvoice("111"); |
| | | vo.setPartyA(a.getCompanyName()); |
| | | vo.setPartyAOrgCode(a.getCreditCode()); |
| | | vo.setPartyAOpenBank(a.getBankName()); |
| | | vo.setPartyABankAccount(a.getBankAccount()); |
| | | vo.setPartyB(b.getOrgName()); |
| | | vo.setPartyBOrgCode(b.getOrgCode()); |
| | | vo.setPartyBOpenBank(b.getOrgBank()); |
| | | vo.setPartyBBankAccount(b.getOrgBankAccount()); |
| | | List<InvoiceItemVo> invoiceItemVoList = new ArrayList<>(); |
| | | List<String> erpCode = new ArrayList<>(); |
| | | List<ContractOutBoundMergeVo> mergeOutBounds = new ArrayList<>(); |
| | | |
| | | if (CollUtil.isNotEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) { |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(subjectMatter)) { |
| | | if (!CollUtil.contains(erpCode, subjectMatter.getMaterialCode())) { |
| | | erpCode.add(subjectMatter.getMaterialCode()); |
| | | ContractOutBoundMergeVo mergeVo = new ContractOutBoundMergeVo(); |
| | | mergeVo.setMaterialCode(subjectMatter.getMaterialCode()); |
| | | mergeVo.setMaterialInternalName(subjectMatter.getMaterialName()); |
| | | mergeVo.setQuantity(contractOutBoundInvoiceVo.getInvoiceNum()); |
| | | Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode()) |
| | | .eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(product)) { |
| | | mergeVo.setTaxClass(product.getTaxClass()); |
| | | mergeVo.setSpecification(product.getProductType()); |
| | | mergeVo.setTaxRate(new BigDecimal(product.getTaxRate())); |
| | | mergeVo.setTaxCode(product.getTaxCode()); |
| | | Product productClass = productMapper.selectById(product.getParentId()); |
| | | if (ObjUtil.isNotNull(product)) { |
| | | if (StrUtil.equals(product.getErpCode(), "water_bill")) { |
| | | mergeVo.setItemName("*" + product.getTaxClass() + "*水费"); |
| | | } else if (StrUtil.equals(product.getErpCode(), "electricity_bill")) { |
| | | mergeVo.setItemName("*" + product.getTaxClass() + "*电费"); |
| | | } else if (StrUtil.equals(product.getErpCode(), "house_rental")) { |
| | | mergeVo.setItemName("*" + product.getTaxClass() + "*房屋租赁"); |
| | | } else { |
| | | mergeVo.setItemName("*" + product.getTaxClass() + "*" + productClass.getProductName()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | mergeVo.setUnitPrice(subjectMatter.getUnitPrice()); |
| | | mergeVo.setUnit(subjectMatter.getUnit()); |
| | | mergeOutBounds.add(mergeVo); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | if (ArrayUtil.isNotEmpty(mergeOutBounds)) { |
| | | invoiceItemVoList = BeanUtil.copyToList(mergeOutBounds, InvoiceItemVo.class); |
| | | invoiceItemVoList.stream().forEach(invoiceItemVo -> { |
| | | // for (InvoiceItemVo invoiceItemVo:invoiceItemVoList) { |
| | | BigDecimal itemPrice = invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity()); |
| | | BigDecimal itemPriceTax = itemPrice.divide(new BigDecimal("100").add(invoiceItemVo.getTaxRate()), 2, RoundingMode.HALF_UP).multiply(invoiceItemVo.getTaxRate()); |
| | | invoiceItemVo.setPriceTax(itemPriceTax); |
| | | invoiceItemVo.setPriceNoTax(itemPrice.subtract(itemPriceTax)); |
| | | }); |
| | | vo.setTotalPrice(invoiceItemVoList.stream().map(item -> item.getPriceTax().add(item.getPriceNoTax())).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | vo.setInvoiceItemList(invoiceItemVoList); |
| | | vo.setPriceWords(Convert.digitToChinese(vo.getTotalPrice())); |
| | | } |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | public R toInvoice(GenInvoiceInfoDTO genInvoiceInfoDTO) { |
| | | if (ArrayUtil.isEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList().toArray())) { |
| | | if (ArrayUtil.isEmpty(genInvoiceInfoDTO.getOutBoundInvoiceList())) { |
| | | return R.failed("请选择开票出库单后再操作"); |
| | | } |
| | | Long contractId = null; |
| | | if (!StrUtil.equals(genInvoiceInfoDTO.getContractCategory(),"water_house")) { |
| | | if (StrUtil.isNotBlank(genInvoiceInfoDTO.getContractId())) { |
| | | |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getStageName, "合同签订").eq(ContractPaymentSchedule::getContractId,genInvoiceInfoDTO.getContractId()) |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNull(schedule)) { |
| | | return R.failed("合同预收款阶段异常,请联系技术人员"); |
| | | } |
| | | Contract contract = contractMapper.selectById(genInvoiceInfoDTO.getContractId()); |
| | | if (ObjUtil.isNull(contract)) { |
| | | return R.failed("合同信息异常,请联系技术人员"); |
| | | } |
| | | ContractInvoice lastInvoice = baseMapper.selectOne(Wrappers.<ContractInvoice>lambdaQuery().eq(ContractInvoice::getContractId,contract.getId()) |
| | | .orderByDesc(ContractInvoice::getCreateTime).last("limit 1")); |
| | | if (ObjUtil.isNotNull(lastInvoice)&&StrUtil.equals(lastInvoice.getApprovalStatus(),"0")){ |
| | | return R.failed("请等待最近的发票审核完成后再进行预收开票"); |
| | | } |
| | | R<SysDept> r = remoteDeptService.getById(contract.getPartyBId()); |
| | | if (!r.isOk()) { |
| | | return R.failed("获取开票单位异常"); |
| | | } |
| | | SysDept b = r.getData(); |
| | | BigDecimal advanceAmount = new BigDecimal("0"); |
| | | for (ContractOutBoundInvoiceVo contractOutBoundInvoiceVo : genInvoiceInfoDTO.getOutBoundInvoiceList()) { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(subjectMatter)) { |
| | | advanceAmount = advanceAmount.add(contractOutBoundInvoiceVo.getInvoiceNum().multiply(subjectMatter.getUnitPrice())); |
| | | } |
| | | } |
| | | |
| | | if (advanceAmount.compareTo(schedule.getPlannedAmount()) > 0) { |
| | | return R.failed("开票金额超出合同签订阶段应收金额:" + schedule.getPlannedAmount() + ",请调整开票数量"); |
| | | } |
| | | GenInvoiceInfoVo vo = genAdvanceInvoiceInfoVo(genInvoiceInfoDTO, contract, b); |
| | | //发票保存 |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, genInvoiceInfoDTO.getOutBoundInvoiceList(), DateUtil.current() + "","1"); |
| | | //启动流程 |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | | dto.setParamMap(map); |
| | | dto.setFlowName(FlowNameEnum.销售挂账审批.name()); |
| | | R r1 = remoteFlowProcessService.startProcessInstance(dto); |
| | | if (r1.getCode() == 1) { |
| | | return R.failed("流程启动失败"); |
| | | } |
| | | //更新合同出库单状态 |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | subjectMatter.setAdvanceNum(subjectMatter.getAdvanceNum().add(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractSubjectMatterMapper.updateById(subjectMatter); |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | if (!StrUtil.equals(genInvoiceInfoDTO.getContractCategory(), "water_house")) { |
| | | ContractOutBound outBound = contractOutBoundMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId()); |
| | | contractId = outBound.getContractId(); |
| | | }else { |
| | | } else { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(genInvoiceInfoDTO.getOutBoundInvoiceList().get(0).getContractOutBoundId()); |
| | | contractId = schedule.getContractId(); |
| | | } |
| | |
| | | SysDept b = r.getData(); |
| | | GenInvoiceInfoVo vo = genInvoiceInfoVo(genInvoiceInfoDTO, contract, b); |
| | | //发票保存 |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, genInvoiceInfoDTO.getOutBoundInvoiceList(), DateUtil.current() + ""); |
| | | ContractInvoice invoice = saveContractInvoice(vo, contract, genInvoiceInfoDTO.getOutBoundInvoiceList(), DateUtil.current() + "","0"); |
| | | //启动流程 |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | | if (StrUtil.equals(genInvoiceInfoDTO.getContractCategory(),"water_house")) { |
| | | map.put("contractCategory","water_house"); |
| | | if (StrUtil.equals(genInvoiceInfoDTO.getContractCategory(), "water_house")) { |
| | | map.put("contractCategory", "water_house"); |
| | | } |
| | | dto.setParamMap(map); |
| | | dto.setFlowName(FlowNameEnum.销售挂账审批.name()); |
| | |
| | | if (r1.getCode() == 1) { |
| | | return R.failed("流程启动失败"); |
| | | } |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | //更新合同出库单状态 |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | contractOutBound.setInvoiceStatus("1"); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | } |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | }); |
| | | }else { |
| | | } else { |
| | | //更新合同房租 水电 费开票状态 |
| | | genInvoiceInfoDTO.getOutBoundInvoiceList().stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | schedule.setInvoiceFlag("1"); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | }); |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | schedule.setInvoiceFlag("1"); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | //销方 |
| | | jsonObject.put("taxNo", vo.getPartyBOrgCode());//税号 |
| | | jsonObject.put("isSplit", false);//超过发票单张限额是否需要拆分开具,默认不拆分(拆分只支持发票类型代码为 专票 004 普票 007 电子票 026的 |
| | | jsonObject.put("taxUserName", "");//登录名为税局页面登 录名 |
| | | jsonObject.put("formatGenerate", false);//是否需要生成版式返回版式链接(true / false) |
| | | jsonObject.put("formatPushType", false);//版式生成是否推送(true / false) |
| | | //data |
| | |
| | | invoiceDetail.put("goodsUnit", invoiceItemVo.getUnit()); |
| | | invoiceDetail.put("goodsQuantity", invoiceItemVo.getQuantity()); |
| | | invoiceDetail.put("goodsPrice", invoiceItemVo.getUnitPrice()); |
| | | if (!StrUtil.equals(vo.getContractCategory(),"water_house")) { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity())); |
| | | }else { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceAndTax()); |
| | | if (!StrUtil.equals(vo.getContractCategory(), "water_house")) { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax()); |
| | | } else { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax()); |
| | | } |
| | | invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax()); |
| | | |
| | |
| | | //购方 |
| | | data.put("buyerTaxNo", vo.getPartyAOrgCode()); |
| | | data.put("buyerName", vo.getPartyA()); |
| | | data.put("invoiceTotalPrice", vo.getTotalPrice().subtract(vo.getInvoiceItemList().stream().map(item -> item.getPriceTax()).reduce(BigDecimal.ZERO, BigDecimal::add))); |
| | | data.put("invoiceTotalTax", vo.getInvoiceItemList().stream().map(item -> item.getPriceTax()).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | data.put("drawer", SecurityUtils.getUser().getPhone());// TODO 税务总局系统登陆人手机号 |
| | | data.put("invoiceTotalPriceTax", vo.getTotalPrice()); |
| | | data.put("buyerBankName", vo.getPartyAOpenBank()); |
| | | data.put("buyerBankNumber", vo.getPartyABankAccount()); |
| | |
| | | return jsonObject; |
| | | } |
| | | |
| | | private ContractInvoice saveContractInvoice(GenInvoiceInfoVo genInvoiceInfoVo, Contract contract, List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList, String serialNo) { |
| | | private ContractInvoice saveContractInvoice(GenInvoiceInfoVo genInvoiceInfoVo, Contract contract, |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList, String serialNo,String advanceFlag) { |
| | | ContractInvoice invoice = new ContractInvoice(); |
| | | invoice.setContractId(contract.getId()); |
| | | invoice.setInvoiceCategory("1"); |
| | | invoice.setRedReversal("0"); |
| | | invoice.setSerialNo(serialNo); |
| | | invoice.setTexNo(genInvoiceInfoVo.getPartyBOrgCode()); |
| | | invoice.setTaxNo(genInvoiceInfoVo.getPartyBOrgCode()); |
| | | invoice.setSellerTaxName(genInvoiceInfoVo.getPartyB()); |
| | | invoice.setBuyerTaxName(genInvoiceInfoVo.getPartyA()); |
| | | invoice.setBuyerTaxNo(genInvoiceInfoVo.getPartyAOrgCode()); |
| | | invoice.setInvoiceTotalTax(genInvoiceInfoVo.getInvoiceItemList().stream().map(item -> item.getPriceTax()).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | invoice.setInvoiceTotalPrice(genInvoiceInfoVo.getTotalPrice().subtract(invoice.getInvoiceTotalTax())); |
| | | invoice.setInvoiceTotalPriceTax(genInvoiceInfoVo.getTotalPrice()); |
| | |
| | | invoice.setInvoiceStatus("1"); |
| | | invoice.setApprovalStatus("0"); |
| | | invoice.setOutBoundId(outBoundInvoiceVoList.stream() |
| | | .map(item-> String.valueOf(item.getContractOutBoundId())) // 或者 .map(Object::toString) |
| | | .map(item -> String.valueOf(item.getContractOutBoundId())) // 或者 .map(Object::toString) |
| | | .collect(Collectors.joining(","))); |
| | | invoice.setInvoicePreviewParam(JSONObject.toJSONString(outBoundInvoiceVoList)); |
| | | invoice.setAdvanceFlag(advanceFlag); |
| | | baseMapper.insert(invoice); |
| | | return invoice; |
| | | } |
| | |
| | | Contract contract = contractMapper.selectById(blueInvoice.getContractId()); |
| | | ContractInvoice invoice = new ContractInvoice(); |
| | | invoice.setContractId(blueInvoice.getContractId()); |
| | | invoice.setTexNo(blueInvoice.getTexNo()); |
| | | invoice.setTaxNo(blueInvoice.getTaxNo()); |
| | | invoice.setSellerTaxName(blueInvoice.getSellerTaxName()); |
| | | invoice.setBuyerTaxName(blueInvoice.getBuyerTaxName()); |
| | | invoice.setBuyerTaxNo(blueInvoice.getBuyerTaxNo()); |
| | | invoice.setInvoiceTotalTax(blueInvoice.getInvoiceTotalTax()); |
| | | invoice.setInvoiceTotalPrice(blueInvoice.getInvoiceTotalPrice()); |
| | | invoice.setInvoiceTotalPriceTax(blueInvoice.getInvoiceTotalPriceTax()); |
| | |
| | | invoice.setBlueInvoiceId(invoiceId); |
| | | invoice.setApprovalStatus("0"); |
| | | invoice.setInvoicePreviewParam(blueInvoice.getInvoicePreviewParam()); |
| | | invoice.setAdvanceFlag(blueInvoice.getAdvanceFlag()); |
| | | baseMapper.insert(invoice); |
| | | //启动流程 |
| | | ProcessInstanceParamDto dto = new ProcessInstanceParamDto(); |
| | | Map<String, Object> map = BeanUtil.beanToMap(invoice); |
| | | dto.setParamMap(map); |
| | | if (StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | map.put("contractCategory","water_house"); |
| | | if (StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | map.put("contractCategory", "water_house"); |
| | | } |
| | | dto.setParamMap(map); |
| | | dto.setFlowName(FlowNameEnum.销售挂账审批.name()); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private JSONObject genRedInvoice(Contract contract,ContractInvoice blueInvoice, String redConfirmSerialNo) { |
| | | private JSONObject genRedInvoice(Contract contract, ContractInvoice blueInvoice, String redConfirmSerialNo) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("taxNo", blueInvoice.getTexNo()); |
| | | jsonObject.put("taxNo", blueInvoice.getTaxNo()); |
| | | jsonObject.put("redConfirmSerialNo", redConfirmSerialNo); |
| | | jsonObject.put("entryIdentity", "01"); |
| | | jsonObject.put("sellerTaxNo", blueInvoice.getTexNo()); |
| | | jsonObject.put("sellerTaxNo", blueInvoice.getTaxNo()); |
| | | jsonObject.put("sellerTaxName", blueInvoice.getSellerTaxName()); |
| | | jsonObject.put("buyerTaxName", blueInvoice.getBuyerTaxName()); |
| | | jsonObject.put("originalInvoiceNo", blueInvoice.getInvoiceNo()); |
| | | jsonObject.put("originInvoiceIsPaper", "N"); |
| | | jsonObject.put("buyerTaxNo", blueInvoice.getBuyerTaxNo()); |
| | | jsonObject.put("originInvoiceDate", blueInvoice.getInvoiceTime()); |
| | | jsonObject.put("originInvoiceTotalPrice", blueInvoice.getInvoiceTotalPrice()); |
| | | jsonObject.put("originInvoiceTotalTax", blueInvoice.getInvoiceTotalPrice()); |
| | | jsonObject.put("originInvoiceTotalTax", blueInvoice.getInvoiceTotalTax()); |
| | | jsonObject.put("invoiceTotalPrice", blueInvoice.getInvoiceTotalPrice().multiply(new BigDecimal("-1"))); |
| | | jsonObject.put("invoiceTotalTax", blueInvoice.getInvoiceTotalTax().multiply(new BigDecimal("-1"))); |
| | | jsonObject.put("originInvoiceIsPaper", "N"); |
| | | jsonObject.put("originInvoiceType", "01"); |
| | | jsonObject.put("invoiceTotalPrice", blueInvoice.getInvoiceTotalPrice()); |
| | | jsonObject.put("invoiceTotalTax", blueInvoice.getInvoiceTotalPrice()); |
| | | jsonObject.put("redInvoiceLabel", "2"); |
| | | jsonObject.put("redInvoiceLabel", "01"); |
| | | jsonObject.put("invoiceSource", "2"); |
| | | jsonObject.put("originalInvoiceNo", blueInvoice.getInvoiceNo()); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(blueInvoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | JSONArray invoiceDetailsList = new JSONArray(); |
| | | Integer lineNo = 1; |
| | | for (InvoiceItemVo invoiceItemVo : vo.getInvoiceItemList()) { |
| | | JSONObject invoiceDetail = new JSONObject(); |
| | | invoiceDetail.put("originalInvoiceDetailNo", lineNo); |
| | | invoiceDetail.put("projectName", invoiceItemVo.getItemName()); |
| | | invoiceDetail.put("goodsLineNo", lineNo); |
| | | invoiceDetail.put("goodsCode", invoiceItemVo.getTaxCode()); |
| | | invoiceDetail.put("goodsTaxRate", invoiceItemVo.getTaxRate().divide(new BigDecimal("100"))); |
| | | invoiceDetail.put("goodsUnit", invoiceItemVo.getUnit()); |
| | | invoiceDetail.put("goodsQuantity", invoiceItemVo.getQuantity()); |
| | | invoiceDetail.put("goodsPrice", invoiceItemVo.getUnitPrice()); |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getUnitPrice().multiply(invoiceItemVo.getQuantity())); |
| | | }else { |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceAndTax()); |
| | | } |
| | | invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax()); |
| | | |
| | | invoiceDetail.put("goodsTotalPrice", invoiceItemVo.getPriceNoTax().multiply(new BigDecimal("-1"))); |
| | | invoiceDetail.put("goodsTotalTax", invoiceItemVo.getPriceTax().multiply(new BigDecimal("-1"))); |
| | | invoiceDetailsList.add(invoiceDetail); |
| | | lineNo++; |
| | | } |
| | |
| | | if (bwFlag) { |
| | | List<ContractInvoice> contractInvoices = baseMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery() |
| | | .eq(ContractInvoice::getInvoiceCategory, "1").eq(ContractInvoice::getInvoiceStatus, "1")); |
| | | if (ArrayUtil.isNotEmpty(contractInvoices.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(contractInvoices)) { |
| | | contractInvoices.stream().forEach(contractInvoice -> { |
| | | JSONObject request = new JSONObject(); |
| | | request.put("tax_no", contractInvoice.getTexNo()); |
| | | request.put("taxNo", contractInvoice.getTaxNo()); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("serial_no", contractInvoice.getSerialNo()); |
| | | data.put("return_type", "1"); |
| | | data.put("taxNo", contractInvoice.getSerialNo()); |
| | | data.put("returnType", "3"); |
| | | data.put("invoiceIssueMode", "1"); |
| | | String requestId = IdUtil.fastUUID(); |
| | | |
| | | log.info("serial_no:{},发票查询入参:{},", contractInvoice.getSerialNo(), request.toJSONString()); |
| | | String result = HttpUtil.post("method=baiwang.output.format.query&version=1.0&request_id=" + requestId, request.toJSONString()); |
| | | log.info("serial_no:{},发票查询回参:{},", contractInvoice.getSerialNo(), result); |
| | |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | | if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) && resultObj.getBoolean("success")) { |
| | | JSONObject model = resultObj.getJSONObject("model"); |
| | | contractInvoice.setInvoicePath(model.getString("query_data")); |
| | | contractInvoice.setInvoicePath(model.getString("queryData")); |
| | | contractInvoice.setInvoiceStatus("2"); |
| | | baseMapper.updateById(contractInvoice); |
| | | } |
| | |
| | | if (redisTemplate.hasKey("BIP_TOKEN")) { |
| | | accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN"); |
| | | } else { |
| | | paymentConfirmService.getAccessToken(accessToken); |
| | | accessToken = paymentConfirmService.getAccessToken(accessToken); |
| | | } |
| | | if (StrUtil.isEmpty(accessToken)) { |
| | | log.error("bip accessToken 获取异常"); |
| | | return; |
| | | } |
| | | Contract contract = contractMapper.selectById(contractInvoice.getContractId()); |
| | | if (ObjUtil.isNull(contract)) { |
| | | log.error("查询合同信息异常"); |
| | | return; |
| | | } |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | if (ObjUtil.isNull(customer) || StrUtil.isEmpty(customer.getBipCode())) { |
| | | log.error("查询合同信息异常"); |
| | | return; |
| | | } |
| | | R<SysDept> r = remoteDeptService.getById(contract.getPartyBId()); |
| | | if (!r.isOk()) { |
| | | log.error("查询单位信息异常"); |
| | | return; |
| | | } |
| | | SysDept dept = r.getData(); |
| | | //蓝票 |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(),"1")) { |
| | | JSONObject params = genBlueReceiveParams(contractInvoice); |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(), "1")) { |
| | | JSONObject params = genBlueReceiveParams(contractInvoice, contract, customer, dept); |
| | | String finalAccessToken = accessToken; |
| | | |
| | | log.info("XSJZ_YS_DJ_INSERT Request:", params.toJSONString()); |
| | | log.info("XSJZ_YS_DJ_INSERT Request:{}", params.toJSONString()); |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/receivable/save?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("XSJZ_YS_DJ_INSERT Response:{}", result); |
| | | //保存请求记录 |
| | |
| | | } |
| | | } |
| | | //红票 |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(),"2")) { |
| | | if (StrUtil.equals(contractInvoice.getInvoiceCategory(), "2")) { |
| | | JSONObject params = genRedReceiveParams(contractInvoice); |
| | | String finalAccessToken = accessToken; |
| | | |
| | |
| | | } |
| | | |
| | | private JSONObject genRedReceiveParams(ContractInvoice contractInvoice) { |
| | | ContractInvoice blue = contractInvoice.selectById(contractInvoice.getBlueInvoiceId()); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id",contractInvoice.getBipId()); |
| | | jsonObject.put("data",data); |
| | | return jsonObject; |
| | | data.put("id", blue.getBipId()); |
| | | jsonObject.put("data", data); |
| | | return jsonObject; |
| | | } |
| | | |
| | | private JSONObject genBlueReceiveParams(ContractInvoice contractInvoice) { |
| | | private JSONObject genBlueReceiveParams(ContractInvoice contractInvoice, Contract contract, BusinessCustomer customer, SysDept dept) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | JSONObject data = new JSONObject(); |
| | | if (contractInvoice.getInvoiceCategory().equals("1")){ |
| | | data.put("direction","1"); |
| | | }else { |
| | | data.put("direction","-1"); |
| | | if (contractInvoice.getInvoiceCategory().equals("1")) { |
| | | data.put("direction", "1"); |
| | | } else { |
| | | data.put("direction", "-1"); |
| | | } |
| | | data.put("billDate",DateUtil.format(contractInvoice.getInvoiceTime(),DatePattern.NORM_DATETIME_FORMAT)); |
| | | data.put("objectType","1"); |
| | | data.put("exchangeRate","1"); |
| | | data.put("exchangeRateDate",DateUtil.now()); |
| | | data.put("_status","Insert"); |
| | | data.put("billDate", DateUtil.format(contractInvoice.getInvoiceTime(), DatePattern.NORM_DATETIME_FORMAT)); |
| | | data.put("exchangeRate", "1");//汇率 |
| | | data.put("exchangeRateDate", DateUtil.now());//汇率时间 |
| | | data.put("objectType", "1"); |
| | | data.put("customerCode", customer.getBipCode());//客户编码 |
| | | data.put("financeOrgCode", dept.getBipCode());//开票组织编码 |
| | | data.put("orgCode", dept.getBipCode());//业务组织编码 |
| | | data.put("bustypeCode", "");//交易类型编码 暂估默认ZGYSFP,销售默认MJHYXGLXT |
| | | data.put("contractNo", contract.getContractNo()); |
| | | data.put("oriCurrencyCode", "CNY");//币种 |
| | | 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("invoiceNo", contractInvoice.getInvoiceNo()); |
| | | 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"); |
| | | item.put("oriTaxIncludedAmount", invoiceItemVo.getPriceAndTax()); |
| | | item.put("_status", "Insert"); |
| | | |
| | | bodyItem.add(item); |
| | | } |
| | | data.put("bodyItem",bodyItem); |
| | | jsonObject.put("data",data); |
| | | return jsonObject; |
| | | data.put("bodyItem", bodyItem); |
| | | jsonObject.put("data", data); |
| | | return jsonObject; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (bwFlag) { |
| | | List<ContractInvoice> contractInvoices = baseMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery() |
| | | .eq(ContractInvoice::getInvoiceCategory, "2").eq(ContractInvoice::getInvoiceStatus, "3")); |
| | | if (ArrayUtil.isNotEmpty(contractInvoices.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(contractInvoices)) { |
| | | contractInvoices.stream().forEach(contractInvoice -> { |
| | | JSONObject request = new JSONObject(); |
| | | request.put("taxNo", contractInvoice.getTexNo()); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("redConfirmSerialNo", contractInvoice.getSerialNo()); |
| | | data.put("buySelSelector", "1"); |
| | | request.put("taxNo", contractInvoice.getTaxNo()); |
| | | request.put("redConfirmSerialNo", contractInvoice.getSerialNo()); |
| | | request.put("buySelSelector", "0"); |
| | | request.put("invoiceStartDate", DateUtil.formatDate(DateUtil.beginOfYear(new Date()))); |
| | | request.put("invoiceEndDate", DateUtil.formatDate(DateUtil.endOfYear(new Date()))); |
| | | String requestId = IdUtil.fastUUID(); |
| | | log.info("serial_no:{},红字确认单查询入参:{},", contractInvoice.getSerialNo(), request.toJSONString()); |
| | | String result = HttpUtil.post("method=baiwang.output.redinvoice.formlist&&version=1.0&request_id=" + requestId, request.toJSONString()); |
| | | log.info("serial_no:{},红字确认单查询回参:{},", contractInvoice.getSerialNo(), result); |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | | saveBwRequestRecord("baiwang.output.redinvoice.formlist", requestId, request.toJSONString(), result); |
| | | if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) && resultObj.getBoolean("success")) { |
| | | JSONArray models = JSONArray.parseArray(resultObj.getString("model")); |
| | | if (ArrayUtil.isNotEmpty(models.toArray())) { |
| | | contractInvoice.setInvoiceStatus("2"); |
| | | if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) && |
| | | !resultObj.getBoolean("success")) { |
| | | log.error("红字确认单失败!!!"); |
| | | return; |
| | | } |
| | | JSONArray models = resultObj.getJSONArray("model"); |
| | | if (ArrayUtil.isNotEmpty(models)) { |
| | | JSONObject model = (JSONObject) models.get(0); |
| | | |
| | | if (StrUtil.isEmpty(model.getString("confirmBillingMark")) || StrUtil.equals(model.getString("confirmBillingMark"), "N")) { |
| | | //红冲失败 |
| | | contractInvoice.setRedReversal("2"); |
| | | } else if (StrUtil.equals(model.getString("confirmBillingMark"), "Y")) { |
| | | //确认即开 |
| | | contractInvoice.setInvoiceNo(model.getString("redInvoiceNo")); |
| | | contractInvoice.setRedReversal("1"); |
| | | baseMapper.updateById(contractInvoice); |
| | | //推送BIP |
| | | pushBipInvoice(contractInvoice); |
| | | } |
| | |
| | | Contract contract = contractMapper.selectById(invoice.getContractId()); |
| | | GenInvoiceInfoVo vo = BeanUtil.copyProperties(JSONObject.parseObject(invoice.getInvoicePreview()), GenInvoiceInfoVo.class); |
| | | vo.setContractCategory(contract.getContractCategory()); |
| | | invoice.setApprovalStatus("1"); |
| | | baseMapper.updateById(invoice); |
| | | //蓝票 |
| | | if (invoice.getInvoiceCategory().equals("1")) { |
| | | // TODO 开蓝票接口 |
| | | JSONObject request = genBlueInvoice(vo, invoice.getSerialNo()); |
| | | if (bwFlag) { |
| | | String requestId = IdUtil.fastUUID(); |
| | | invoice.setBwRequestId(requestId); |
| | | log.info("蓝票请求接口入参", request.toJSONString()); |
| | | String result = HttpUtil.post(bwUrl + "method=baiwang.output.invoice.issue&version=1.0&requestId=" + requestId, request.toJSONString()); |
| | | log.info("蓝票请求接口回参", result); |
| | |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | | if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) && |
| | | !resultObj.getBoolean("success")) { |
| | | log.error("开票失败!!!"); |
| | | return; |
| | | } |
| | | JSONArray models = JSONArray.parseArray(resultObj.getString("success")); |
| | | if (ArrayUtil.isNotEmpty(models.toArray())) { |
| | | JSONObject modelJson = resultObj.getJSONObject("model"); |
| | | JSONArray models = modelJson.getJSONArray("success"); |
| | | if (ArrayUtil.isNotEmpty(models)) { |
| | | JSONObject model = (JSONObject) models.get(0); |
| | | Date invoiceDate = DateUtil.parse(model.getString("invoiceDate"), DatePattern.PURE_DATETIME_PATTERN); |
| | | invoice.setInvoiceTime(invoiceDate); |
| | | invoice.setInvoiceNo(model.getString("invoiceNo")); |
| | | } |
| | | } |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | if (StrUtil.isNotBlank(vo.getAdvanceInvoice())){ |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | contractMapper.updateById(contract); |
| | | return; |
| | | } |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | //合同状态 |
| | | if (StrUtil.equals(contract.getBillingStatus(), "2")) { |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | |
| | | contract.setBillingStatus("1"); |
| | | } |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) > 0) { |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | } |
| | | }else { |
| | | } else { |
| | | //判断 循环是否完成 |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery().eq(ContractExecDate::getContractId,contract.getId()) |
| | | .eq(ContractExecDate::getGenFlag,"0")); |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery().eq(ContractExecDate::getContractId, contract.getId()) |
| | | .eq(ContractExecDate::getGenFlag, "0")); |
| | | List<MeterReadRecord> recordList = meterReadRecordMapper.selectList(Wrappers.<MeterReadRecord>lambdaQuery() |
| | | .eq(MeterReadRecord::getContractId,contract.getId()) |
| | | .eq(MeterReadRecord::getContractId, contract.getId()) |
| | | .isNull(MeterReadRecord::getMeterReadNum)); |
| | | if (ArrayUtil.isEmpty(execDateList.toArray())&&ArrayUtil.isEmpty(recordList.toArray())) { |
| | | if (ArrayUtil.isEmpty(execDateList) && ArrayUtil.isEmpty(recordList)) { |
| | | //判断是否有可开票记录 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId,contract.getId()).eq(ContractPaymentSchedule::getInvoiceFlag,"0")); |
| | | if (ArrayUtil.isEmpty(scheduleList.toArray())){ |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).eq(ContractPaymentSchedule::getInvoiceFlag, "0")); |
| | | if (ArrayUtil.isEmpty(scheduleList)) { |
| | | contract.setBillingStatus("3"); |
| | | }else { |
| | | } else { |
| | | contract.setBillingStatus("2"); |
| | | } |
| | | |
| | | }else { |
| | | } else { |
| | | //判断是否有可开票记录 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId,contract.getId())); |
| | | if (ArrayUtil.isEmpty(scheduleList.toArray())){ |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | if (ArrayUtil.isEmpty(scheduleList)) { |
| | | contract.setBillingStatus("1"); |
| | | }else { |
| | | } else { |
| | | contract.setBillingStatus("2"); |
| | | } |
| | | } |
| | | contract.setBillingAmout(vo.getTotalPrice().add(contract.getBillingAmout())); |
| | | //防止重复审开票审核通过后 开票金额超出合同金额 |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount())>0){ |
| | | if (contract.getBillingAmout().compareTo(contract.getAmount()) > 0) { |
| | | contract.setBillingAmout(contract.getAmount()); |
| | | } |
| | | contractMapper.updateById(contract); |
| | |
| | | if (invoice.getInvoiceCategory().equals("2")) { |
| | | // TODO 开红票接口 |
| | | ContractInvoice blueInvoice = baseMapper.selectById(invoice.getBlueInvoiceId()); |
| | | JSONObject request = genRedInvoice(contract,blueInvoice, invoice.getSerialNo()); |
| | | JSONObject request = genRedInvoice(contract, blueInvoice, invoice.getSerialNo()); |
| | | String requestId = IdUtil.fastUUID(); |
| | | invoice.setBwRequestId(requestId); |
| | | if (bwFlag) { |
| | | log.info("红字确认单请求接口入参", request.toJSONString()); |
| | | log.info("红字确认单请求接口入参:{}", request.toJSONString()); |
| | | String result = HttpUtil.post(bwUrl + "method=baiwang.output.redinvoice.add&version=1.0&requestId=" + requestId, request.toJSONString()); |
| | | log.info("红字确认单请求接口回参", result); |
| | | log.info("红字确认单请求接口回参:{}", result); |
| | | saveBwRequestRecord("baiwang.output.redinvoice.add", requestId, request.toJSONString(), result); |
| | | JSONObject resultObj = JSONObject.parseObject(result); |
| | | if (resultObj.containsKey("requestId") && StrUtil.equals(resultObj.getString("requestId"), requestId) && |
| | | !resultObj.getBoolean("success")) { |
| | | JSONArray models = JSONArray.parseArray(resultObj.getString("success")); |
| | | if (ArrayUtil.isNotEmpty(models.toArray())) { |
| | | JSONObject model = (JSONObject) models.get(0); |
| | | log.error("红字确认单失败!!!"); |
| | | return; |
| | | } |
| | | JSONArray models = resultObj.getJSONArray("model"); |
| | | if (ArrayUtil.isNotEmpty(models)) { |
| | | JSONObject model = (JSONObject) models.get(0); |
| | | |
| | | if (StrUtil.isEmpty(model.getString("confirmBillingMark"))||StrUtil.equals(model.getString("confirmBillingMark"),"N")) { |
| | | //等待确认 |
| | | invoice.setRedReversal("3"); |
| | | }else if (StrUtil.equals(model.getString("confirmBillingMark"),"Y")) { |
| | | //确认即开 |
| | | invoice.setInvoiceNo(model.getString("redInvoiceNo")); |
| | | invoice.setRedReversal("1"); |
| | | //推送BIP |
| | | pushBipInvoice(invoice); |
| | | } |
| | | if (StrUtil.isEmpty(model.getString("confirmBillingMark")) || StrUtil.equals(model.getString("confirmBillingMark"), "N")) { |
| | | //等待确认 |
| | | invoice.setRedReversal("3"); |
| | | } else if (StrUtil.equals(model.getString("confirmBillingMark"), "Y")) { |
| | | //确认即开 |
| | | invoice.setInvoiceNo(model.getString("redInvoiceNo")); |
| | | invoice.setRedReversal("1"); |
| | | //推送BIP |
| | | pushBipInvoice(invoice); |
| | | } |
| | | } |
| | | } |
| | | contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax())); |
| | | //防止重复审开票审核通过后 开票金额为负 |
| | | if (contract.getBillingAmout().compareTo(new BigDecimal("0"))<0){ |
| | | if (contract.getBillingAmout().compareTo(new BigDecimal("0")) < 0) { |
| | | contract.setBillingAmout(new BigDecimal("0")); |
| | | } |
| | | contractMapper.updateById(contract); |
| | | blueInvoice.setRedReversal("1"); |
| | | baseMapper.updateById(blueInvoice); |
| | | if (StrUtil.isNotBlank(vo.getAdvanceInvoice())){ |
| | | //还原预开数量 |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class); |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (ObjUtil.isNotNull(subjectMatter)){ |
| | | subjectMatter.setAdvanceNum(subjectMatter.getAdvanceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | if (subjectMatter.getAdvanceNum().compareTo(new BigDecimal("0"))<=0){ |
| | | subjectMatter.setAdvanceNum(new BigDecimal("0")); |
| | | } |
| | | contractSubjectMatterMapper.updateById(subjectMatter); |
| | | } |
| | | }); |
| | | } |
| | | return; |
| | | } |
| | | //更新合同开票状态 前提出库完成 |
| | | contract.setBillingStatus("2"); |
| | | contractMapper.updateById(contract); |
| | | blueInvoice.setRedReversal("1"); |
| | | baseMapper.updateById(blueInvoice); |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | //更新合同出库单状态 |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class); |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |
| | | } else { |
| | | //更新合同房租 水电 费开票状态 |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(blueInvoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class); |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | schedule.setInvoiceFlag("0"); |
| | |
| | | } |
| | | } |
| | | } |
| | | invoice.setApprovalStatus("1"); |
| | | baseMapper.updateById(invoice); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | Contract contract = contractMapper.selectById(invoice.getContractId()); |
| | | //蓝票 |
| | | if (invoice.getInvoiceCategory().equals("1")) { |
| | | if (!StrUtil.equals(contract.getContractCategory(),"water_house")) { |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | //更新合同出库单状态 |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(invoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class); |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum()))<=0) { |
| | | if (contractOutBoundInvoiceVo.getInvoiceNum().compareTo(contractOutBound.getOutBoundNum().subtract(contractOutBound.getInvoiceNum())) <= 0) { |
| | | contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum())); |
| | | contractOutBoundMapper.updateById(contractOutBound); |
| | | } |
| | | }); |
| | | } |
| | | }else { |
| | | } else { |
| | | //更新合同房租 水电 费开票状态 |
| | | List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(invoice.getInvoicePreviewParam()), ContractOutBoundInvoiceVo.class); |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList)) { |
| | | outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> { |
| | | ContractPaymentSchedule schedule = contractPaymentScheduleMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId()); |
| | | schedule.setInvoiceFlag("0"); |
| | |
| | | |
| | | @Override |
| | | public Page pageInvoice(Page page, ContractInvoiceQueryDTO queryDTO) { |
| | | return baseMapper.pageInvoice(page,queryDTO, DataScope.of("comp_id")); |
| | | return baseMapper.pageInvoice(page, queryDTO, DataScope.of("comp_id")); |
| | | } |
| | | |
| | | @Override |
| | | public Page pageScope(Page page, ContractQueryDTO queryDTO) { |
| | | return baseMapper.pageScope(page,queryDTO, DataScope.of("comp_id")); |
| | | return baseMapper.pageScope(page, queryDTO, DataScope.of("comp_id")); |
| | | } |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.by4cloud.platformx.business.mapper.*; |
| | | import com.by4cloud.platformx.business.service.ContractPaymentScheduleProcessService; |
| | | import com.by4cloud.platformx.business.vo.ContractPaymentScheduleVo; |
| | | import com.by4cloud.platformx.business.vo.ScheduleProcessVo; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | |
| | | if (ObjUtil.isNull(schedule)) { |
| | | return R.failed("履约阶段与合同不一致,请联系技术人员"); |
| | | } |
| | | if (schedule.getStageName().equals("货到签收") && ArrayUtil.isEmpty(addDTO.getContractOutBoundIds().toArray())) { |
| | | if (schedule.getStageName().equals("货到签收") && CollUtil.isEmpty(addDTO.getContractOutBoundIds())) { |
| | | return R.failed("请选择到货的出库信息"); |
| | | } |
| | | //合同 |
| | | Contract contract = contractMapper.selectById(schedule.getContractId()); |
| | | List<ContractSubjectMatter> subjectMatterList = subjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId, contract.getId())); |
| | | if (ArrayUtil.isEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isEmpty(subjectMatterList)) { |
| | | return R.failed("该合同标的物异常,请联系技术人员"); |
| | | } |
| | | // if (!subjectMatterList.stream().allMatch(item -> item.getDeliveryStatus() == 2)) { |
| | |
| | | List<ContractOutBound> contractOutBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery().eq(ContractOutBound::getContractId, contract.getId()) |
| | | .isNotNull(ContractOutBound::getArrivalTime)); |
| | | if (schedule.getStageName().equals("货到签收")) { |
| | | if (ArrayUtil.isNotEmpty(contractOutBoundList.toArray()) |
| | | && ArrayUtil.isNotEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isNotEmpty(contractOutBoundList) |
| | | && CollUtil.isNotEmpty(subjectMatterList)) { |
| | | Map<String, BigDecimal> sumMap = contractOutBoundList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | ContractOutBound::getSubjectMatterCode, |
| | |
| | | //客户付款完成合同 |
| | | List<Contract> customerCompleteContractList = contractMapper.selectList(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, contract.getPartyAId()) |
| | | .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).apply(" amount = paid_amount")); |
| | | if (ArrayUtil.isNotEmpty(customerCompleteContractList)){ |
| | | if (CollUtil.isNotEmpty(customerCompleteContractList)){ |
| | | List<BigDecimal> outAmountList = new ArrayList<>(); |
| | | for (Contract completeContract:customerCompleteContractList |
| | | ) { |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())){ |
| | | if (CollUtil.isNotEmpty(outAmountList)){ |
| | | BigDecimal currentSum = new BigDecimal("0"); |
| | | for (BigDecimal currentAmount:outAmountList |
| | | ) { |
| | |
| | | List<ContractPaymentSchedule> afterSchedule = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder())); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()) |
| | | .gt(ContractPaymentSchedule::getPaymentRatio,"0")); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | // if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * @author cd |
| | | * @description |
| | |
| | | private final PaymentSlipMapper paymentSlipMapper; |
| | | private final ContractInvoiceMapper contractInvoiceMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | |
| | | @Value("${erp.ymj}") |
| | | private String ymjErp; |
| | |
| | | } |
| | | } |
| | | |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){ |
| | | if (CollUtil.isEmpty(addDTO.getContractSubjectMatter())){ |
| | | return R.failed("标的物不能为空"); |
| | | } |
| | | |
| | |
| | | } |
| | | baseMapper.insert(contract); |
| | | |
| | | if (ArrayUtil.isNotEmpty(addDTO.getContractSubjectMatter())) { |
| | | if (CollUtil.isNotEmpty(addDTO.getContractSubjectMatter())) { |
| | | addDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> { |
| | | ContractSubjectMatter subjectMatter = BeanUtil.copyProperties(contractSubjectMatterAddDTO, ContractSubjectMatter.class); |
| | | subjectMatter.setContractId(contract.getId()); |
| | |
| | | |
| | | } |
| | | |
| | | if (ArrayUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) { |
| | | AtomicInteger index = new AtomicInteger(1); |
| | | addDTO.getContractPaymentSchedule().stream().forEach(contractPaymentScheduleAddDTO -> { |
| | | int currentIndex = index.getAndIncrement(); |
| | |
| | | } |
| | | baseMapper.updateById(contract); |
| | | |
| | | if (ArrayUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) { |
| | | if (CollUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) { |
| | | contractSubjectMatterMapper.delete(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId, contract.getId())); |
| | | |
| | | updateDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> { |
| | |
| | | }); |
| | | } |
| | | |
| | | if (ArrayUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | contractPaymentScheduleMapper.delete(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | |
| | | AtomicInteger index = new AtomicInteger(1); |
| | |
| | | if (ObjUtil.isNotNull(a)){ |
| | | detailVo.setPartyAOrgCode(a.getCreditCode()); |
| | | } |
| | | List<ContractOutBound> outBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery() |
| | | .eq(ContractOutBound::getContractId,id).orderByAsc(ContractOutBound::getOutBoundTime)); |
| | | if (CollUtil.isNotEmpty(outBoundList)){ |
| | | detailVo.setContractOutBound(outBoundList); |
| | | } |
| | | List<ContractInvoice> invoiceList = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery() |
| | | .eq(ContractInvoice::getContractId,id).orderByAsc(ContractInvoice::getCreateTime)); |
| | | if (CollUtil.isNotEmpty(invoiceList)){ |
| | | detailVo.setContractInvoice(invoiceList); |
| | | } |
| | | List<PaymentSlip> slipList = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery() |
| | | .eq(PaymentSlip::getContractId,id).orderByAsc(PaymentSlip::getPaymentTime)); |
| | | if (CollUtil.isNotEmpty(slipList)){ |
| | | detailVo.setPaymentSlip(slipList); |
| | | } |
| | | return detailVo; |
| | | } |
| | | |
| | |
| | | List<ContractSubjectMatter> subjectMatterList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | | .eq(ContractSubjectMatter::getContractId,id)); |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isNotEmpty(subjectMatterList)) { |
| | | for (ContractSubjectMatter contractSubjectMatter: subjectMatterList) { |
| | | if (StrUtil.equals(contract.getExecFrequency(), "1")) { |
| | | Long weeksTrue = DateUtil.betweenWeek(DateUtil.beginOfWeek(contract.getEffectiveDate()), |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, fitstSchedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, fitstSchedule.getStageOrder()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //第一阶段生效时间 |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | |
| | | baseMapper.updateById(contract); |
| | | } |
| | | //只有当前合同签字阶段 |
| | | // if(ArrayUtil.isEmpty(afterSchedule.toArray())){ |
| | | // if(ArrayUtil.isEmpty(afterSchedule)){ |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | // } |
| | |
| | | request.put("moneySum",contract.getAmount()); |
| | | request.put("signManner","面签"); |
| | | request.put("salesman",""); |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList)){ |
| | | JSONArray subjectMatter = new JSONArray(); |
| | | subjectMatterList.stream().forEach(contractSubjectMatter -> { |
| | | JSONObject subjectMatterItem = new JSONObject(); |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outAmountList)) { |
| | | BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //新增当前合同 资金转入 |
| | | PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount", |
| | |
| | | .lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today()) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, "2") |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(scheduleList)) { |
| | | scheduleList.stream().forEach(contractPaymentSchedule -> { |
| | | Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId()); |
| | | if (ObjUtil.isNotNull(contract)) { |
| | |
| | | public R genCycleReceiced() { |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | .le(ContractExecDate::getExecDate, DateUtil.today()).eq(ContractExecDate::getGenFlag,"0")); |
| | | if (ArrayUtil.isNotEmpty(execDateList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(execDateList)) { |
| | | execDateList.stream().forEach(contractExecDate -> { |
| | | Contract contract = baseMapper.selectById(contractExecDate.getContractId()); |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | |
| | | |
| | | @Override |
| | | public R addContractSgb(ContractAddDTO addDTO) { |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){ |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter())){ |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule().toArray())){ |
| | | if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule())){ |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(addDTO.getContractPaymentSchedule())){ |
| | |
| | | |
| | | @Override |
| | | public R updateContractSgb(ContractUpdateDTO updateDTO) { |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter().toArray())){ |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter())){ |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule().toArray())){ |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule())){ |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(updateDTO.getContractPaymentSchedule())){ |
| | |
| | | @Override |
| | | public Page fourAssociation(Page page,ContractQueryDTO queryDTO) { |
| | | Page<FourAssociationPageVo> page1 = baseMapper.fourAssociation(page,queryDTO,DataScope.of("comp_id")); |
| | | if (ArrayUtil.isNotEmpty(page1.getRecords().toArray())){ |
| | | if (ArrayUtil.isNotEmpty(page1.getRecords())){ |
| | | page1.getRecords().stream().forEach(fourAssociationPageVo -> { |
| | | List<PaymentSlip> slips = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getContractId,fourAssociationPageVo.getId()) |
| | | .orderByAsc(PaymentSlip::getPaymentTime)); |
| | | if (ArrayUtil.isNotEmpty(slips.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(slips)){ |
| | | fourAssociationPageVo.setSlipVoList(BeanUtil.copyToList(slips,ContractSlipVo.class)); |
| | | } |
| | | List<ContractInvoice> invoices = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery().eq(ContractInvoice::getContractId,fourAssociationPageVo.getId()) |
| | | .orderByAsc(ContractInvoice::getInvoiceTime)); |
| | | if (ArrayUtil.isNotEmpty(invoices.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(invoices)){ |
| | | fourAssociationPageVo.setInvoiceVoList(BeanUtil.copyToList(invoices, ContractInvoiceVo.class)); |
| | | } |
| | | if (fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getPaidAmount())==0&& |
| | | fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0){ |
| | | fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0&& |
| | | ArrayUtil.isNotEmpty(slips)&&ArrayUtil.isNotEmpty(invoices) |
| | | ){ |
| | | fourAssociationPageVo.setAssociation("已完成"); |
| | | } |
| | | }); |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * 水电抄表 |
| | | * |
| | |
| | | List<MeterReadRecord> recordList = baseMapper.selectList(Wrappers.<MeterReadRecord>lambdaQuery() |
| | | .eq(MeterReadRecord::getContractId,contract.getId()) |
| | | .isNull(MeterReadRecord::getMeterReadNum)); |
| | | if (ArrayUtil.isEmpty(execDateList.toArray())&&ArrayUtil.isEmpty(recordList.toArray())){ |
| | | if (ArrayUtil.isEmpty(execDateList)&&ArrayUtil.isEmpty(recordList)){ |
| | | List<PaymentConfirm> confirmList = paymentConfirmMapper.selectList(Wrappers.<PaymentConfirm>lambdaQuery() |
| | | .eq(PaymentConfirm::getContractId, contract.getId()) |
| | | .and(wrapper -> wrapper |
| | |
| | | .or() |
| | | .eq(PaymentConfirm::getBusinessType, "不征税自来水应收") |
| | | )); |
| | | if (ArrayUtil.isNotEmpty(confirmList.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(confirmList)){ |
| | | BigDecimal total = confirmList.stream().map(PaymentConfirm::getTransationAmount).filter(amount -> amount != null).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | contract.setAmount(total); |
| | | contractMapper.updateById(contract); |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * EPR出库记录 |
| | |
| | | |
| | | @Override |
| | | public R add(OutBoundAddDTO addDTO) { |
| | | if (ArrayUtil.isEmpty(addDTO.getSubjectMatterList().toArray())) { |
| | | if (CollUtil.isEmpty(addDTO.getSubjectMatterList())) { |
| | | return R.failed("出库标的物不能为空"); |
| | | } |
| | | MPJLambdaWrapper<ContractSubjectMatter> wrapper = new MPJLambdaWrapper<ContractSubjectMatter>() |
| | |
| | | ) |
| | | .orderByAsc(ContractSubjectMatter::getCreateTime); |
| | | List<ContractSubjectMatter> subjectMatterList = contractSubjectMatterMapper.selectList(wrapper); |
| | | if (ArrayUtil.isEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isEmpty(subjectMatterList)) { |
| | | return R.failed("没有查询到相关合同订单"); |
| | | } |
| | | List<String> erpCodeList = subjectMatterList.stream().map(ContractSubjectMatter::getMaterialCode).collect(Collectors.toList()); |
| | |
| | | }); |
| | | |
| | | //出库应收款明细 |
| | | if (ArrayUtil.isNotEmpty(currentOutMap.keySet())) { |
| | | if (CollUtil.isNotEmpty(currentOutMap.keySet())) { |
| | | for (Long contractId : currentOutMap.keySet()) { |
| | | //当前出库合同出库标的物 |
| | | List<ContractSubjectMatter> contractSubjectMatterList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | |
| | | //客户付款完成合同 |
| | | List<Contract> customerCompleteContractList = contractMapper.selectList(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, contract.getPartyAId()) |
| | | .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).apply(" amount = paid_amount")); |
| | | if (ArrayUtil.isNotEmpty(customerCompleteContractList)) { |
| | | if (CollUtil.isNotEmpty(customerCompleteContractList)) { |
| | | List<BigDecimal> outAmountList = new ArrayList<>(); |
| | | for (Contract completeContract : customerCompleteContractList |
| | | ) { |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())) { |
| | | if (CollUtil.isNotEmpty(outAmountList)) { |
| | | BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //新增当前合同 资金转入 |
| | | PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount", |
| | |
| | | //查询是否有后续阶段 |
| | | // List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId) |
| | | // .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder())); |
| | | // if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | // if (.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // } |
| | | scheduleMapper.updateById(schedule); |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // scheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | |
| | | |
| | | @Override |
| | | public R addContractOut(OutBoundAddDTO addDTO) { |
| | | if (ArrayUtil.isEmpty(addDTO.getSubjectMatterList().toArray())) { |
| | | if (CollUtil.isEmpty(addDTO.getSubjectMatterList())) { |
| | | return R.failed("出库标的物不能为空"); |
| | | } |
| | | // 1. 确定查询用的合同编号字段值 |
| | |
| | | if (ObjUtil.isNull(contract)) { |
| | | return R.failed("合同信息查询失败"); |
| | | } |
| | | if (addDTO.getSubjectMatterList().stream().allMatch(item->item.getOutBoundNum().compareTo(new BigDecimal("0"))==0)){ |
| | | return R.failed("出库数量不能都为为0"); |
| | | } |
| | | addDTO.setSubjectMatterList(addDTO.getSubjectMatterList().stream().filter(item->item.getOutBoundNum().compareTo(new BigDecimal("0"))>0).collect(Collectors.toList())); |
| | | //出库数量校验 |
| | | for (OutSubjectMatterAddDTO outSubjectMatterAddDTO: addDTO.getSubjectMatterList()) { |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNull(subjectMatter)){ |
| | | continue; |
| | | } |
| | | if (outSubjectMatterAddDTO.getOutBoundNum().compareTo(new BigDecimal("0"))==0){ |
| | | return R.failed(outSubjectMatterAddDTO.getSubjectMatterCode()+"出库数量不能为0"); |
| | | } |
| | | if (subjectMatter.getDeliveryStatus()==0){ |
| | | if (outSubjectMatterAddDTO.getOutBoundNum().compareTo(subjectMatter.getQuantity())>0){ |
| | |
| | | //客户付款完成合同 |
| | | List<Contract> customerCompleteContractList = contractMapper.selectList(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, contract.getPartyAId()) |
| | | .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).apply(" amount = paid_amount")); |
| | | if (ArrayUtil.isNotEmpty(customerCompleteContractList)) { |
| | | if (CollUtil.isNotEmpty(customerCompleteContractList)) { |
| | | List<BigDecimal> outAmountList = new ArrayList<>(); |
| | | for (Contract completeContract : customerCompleteContractList |
| | | ) { |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())) { |
| | | if (CollUtil.isNotEmpty(outAmountList)) { |
| | | BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //新增当前合同 资金转入 |
| | | PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount", |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray())&&contract.getOutBoundAmout().compareTo(contract.getAmount())==0) { |
| | | if (CollUtil.isNotEmpty(afterSchedule)&&contract.getOutBoundAmout().compareTo(contract.getAmount())==0) { |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | scheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | |
| | | @Override |
| | | public R delOutBound(String batchNumber) { |
| | | List<OutBound> outBoundList = baseMapper.selectList(Wrappers.<OutBound>lambdaQuery().eq(OutBound::getBatchNumber,batchNumber)); |
| | | if (ArrayUtil.isEmpty(outBoundList)){ |
| | | if (CollUtil.isEmpty(outBoundList)){ |
| | | return R.failed("出库信息异常,请联系营销系统管理人员"); |
| | | } |
| | | List<ContractOutBound> contractOutBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery() |
| | | .in(ContractOutBound::getOutBoundId,outBoundList.stream().map(OutBound::getId).collect(Collectors.toList()))); |
| | | if (ArrayUtil.isEmpty(contractOutBoundList)){ |
| | | if (CollUtil.isEmpty(contractOutBoundList)){ |
| | | return R.failed("出库信息异常,请联系营销系统管理人员"); |
| | | } |
| | | boolean allZero = true; |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.IntStream; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * 收款确认 |
| | |
| | | private final MeterReadRecordMapper meterReadRecordMapper; |
| | | private final BankStatementMapper bankStatementMapper; |
| | | private final RemoteDeptService remoteDeptService; |
| | | private final RedisTemplate redisTemplate; |
| | | private final StringRedisTemplate redisTemplate; |
| | | |
| | | @Value("${bip.url}") |
| | | private String url; |
| | |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | | slip.setPayType(addDTO.getPayType()); |
| | | slip.setContractId(contract.getId()); |
| | | paymentSlipMapper.insert(slip); |
| | | |
| | | BigDecimal newtotal = addDTO.getTransationAmount().add(lastTotal); |
| | |
| | | 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())) { |
| | | if (CollUtil.isNotEmpty(scheduleList)) { |
| | | BigDecimal remain = addDTO.getTransationAmount(); |
| | | for (ContractPaymentSchedule schedule : scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | |
| | | List<MeterReadRecord> recordList = meterReadRecordMapper.selectList(Wrappers.<MeterReadRecord>lambdaQuery() |
| | | .eq(MeterReadRecord::getContractId,contract.getId()) |
| | | .isNull(MeterReadRecord::getMeterReadNum)); |
| | | if (ArrayUtil.isEmpty(execDateList.toArray())&&ArrayUtil.isEmpty(recordList.toArray())){ |
| | | if (CollUtil.isEmpty(execDateList)&&CollUtil.isEmpty(recordList)){ |
| | | //更新合同已付款 |
| | | BigDecimal paid = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(contract.getPaidAmount())) { |
| | |
| | | // List<Contract> customerContractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, addDTO.getBusGuestId()) |
| | | // .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).orderByAsc(Contract::getCreateTime) |
| | | // .apply(" ((contract_category != 'water_house' and amount != paid_amount) or contract_category = 'water_house')")); |
| | | // if (ArrayUtil.isEmpty(customerContractList.toArray())) { |
| | | // if (ArrayUtil.isEmpty(customerContractList)) { |
| | | // return R.failed("为查询到未付款合同"); |
| | | // } |
| | | // BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | |
| | | // .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | // .ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | // .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | // if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | // if (ArrayUtil.isNotEmpty(scheduleList)) { |
| | | // BigDecimal remain = transtionAmount; |
| | | // for (ContractPaymentSchedule schedule : scheduleList) { |
| | | // BigDecimal lastRemain = remain; |
| | |
| | | // 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())) { |
| | | // if (ArrayUtil.isNotEmpty(payComScheduleList)) { |
| | | // BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() : |
| | | // item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // contract.setPaidAmount(payTotal); |
| | |
| | | // 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.toArray())) { |
| | | // 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))) { |
| | | // if (ArrayUtil.isNotEmpty(contractPaymentScheduleList) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | // contractService.updateById(contract); |
| | | // } |
| | |
| | | |
| | | //客户预付有剩余 且 有预付款的合同 |
| | | // if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | // if (ArrayUtil.isNotEmpty(payNoCompleteContractList.toArray())){ |
| | | // if (ArrayUtil.isNotEmpty(payNoCompleteContractList)){ |
| | | // //余额 放到付款未完成合同 预收 |
| | | // Contract lastContract = payNoCompleteContractList.get(0); |
| | | // //保存明细 |
| | | // saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate); |
| | | // } |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){ |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList)&&ArrayUtil.isNotEmpty(advanceContractList)){ |
| | | // //客户预付有剩余 没有预付款的合同 |
| | | // Contract lastContract = advanceContractList.get(0); |
| | | // //保存明细 |
| | | // saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate); |
| | | // } |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isEmpty(advanceContractList.toArray()) |
| | | // &&ArrayUtil.isNotEmpty(payCompleteContractList.toArray())) { |
| | | // if (ArrayUtil.isEmpty(payNoCompleteContractList)&&ArrayUtil.isEmpty(advanceContractList) |
| | | // &&ArrayUtil.isNotEmpty(payCompleteContractList)) { |
| | | // //客户预付有剩余 没有预付款的合同 |
| | | // Contract lastContract = payCompleteContractList.get(payCompleteContractList.size() - 1); |
| | | // //保存明细 |
| | |
| | | if (redisTemplate.hasKey("BIP_TOKEN")) { |
| | | accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN"); |
| | | } else { |
| | | getAccessToken(accessToken); |
| | | accessToken = getAccessToken(accessToken); |
| | | } |
| | | if (StrUtil.isEmpty(accessToken)) { |
| | | return R.failed("获取token失败"); |
| | |
| | | for (String bipCode : bipCodeArr) { |
| | | //入参 |
| | | JSONObject params = new JSONObject(); |
| | | if (ObjUtil.isNotEmpty(dto.getPageSize())){ |
| | | params.put("pageSize",dto.getPageSize()); |
| | | }else { |
| | | params.put("pageSize",999); |
| | | } |
| | | if (ObjUtil.isNotEmpty(dto.getPageNum())){ |
| | | params.put("pageNum",dto.getPageNum()); |
| | | }else { |
| | | params.put("pageNum",1); |
| | | } |
| | | if (StrUtil.isNotBlank(dto.getStartDate())){ |
| | | params.put("begindate",dto.getStartDate()); |
| | | }else { |
| | |
| | | return; |
| | | } |
| | | SysDept dept = r.getData(); |
| | | JSONObject dataJson = JSONObject.parseObject(resultJson.getString("data")); |
| | | JSONObject dataJson = resultJson.getJSONObject("data"); |
| | | if (ObjUtil.isNull(dataJson)) { |
| | | log.error("返回结果中data解析失败"); |
| | | return; |
| | | } |
| | | JSONArray recordList = JSONArray.parseArray(resultJson.getString("recordList")); |
| | | if (ArrayUtil.isEmpty(recordList.toArray())) { |
| | | JSONArray recordList = dataJson.getJSONArray("recordList"); |
| | | if (CollUtil.isEmpty(recordList)) { |
| | | log.error("返回结果中recordList为空"); |
| | | return; |
| | | } |
| | |
| | | |
| | | private void savePaymentConfirm(JSONObject record, SysDept dept) { |
| | | |
| | | if (record.containsKey("to_acct_name")){ |
| | | log.error("付款单id:{},付款公司为空", record.getString("id")); |
| | | return; |
| | | } |
| | | |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .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("tran_amt"))) { |
| | | log.error("付款单id:{},交易金额异常", record.getString("id")); |
| | | return; |
| | | } |
| | | //保存付款单 |
| | | Boolean codeFlag = saveBankStatement(customer, record); |
| | | //保存付款单 |
| | | Boolean codeFlag = saveBankStatement(customer, record,dept); |
| | | if (codeFlag) { |
| | | log.error("付款单id:{},付款单已存在"); |
| | | return; |
| | |
| | | |
| | | } |
| | | |
| | | private Boolean saveBankStatement(BusinessCustomer customer, JSONObject record) { |
| | | private Boolean saveBankStatement(BusinessCustomer customer, JSONObject record,SysDept dept) { |
| | | BankStatement bankStatement = new BankStatement(); |
| | | bankStatement.setBankSeqNo(record.getString("bank_seq_no")); |
| | | bankStatement.setReceiveBankAcc(record.getString("bank_seq_no")); |
| | |
| | | bankStatement.setTranAmount(record.getBigDecimal("tran_amt")); |
| | | bankStatement.setDataId(record.getLong("id")); |
| | | bankStatement.setDataJson(record.toJSONString()); |
| | | bankStatement.setBusGuestId(customer.getId()); |
| | | if (ObjUtil.isNotNull(customer)) { |
| | | 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()); |
| | | bankStatement.setRemark(record.getString("remark")); |
| | | bankStatement.setCompId(dept.getDeptId()); |
| | | bankStatementMapper.insert(bankStatement); |
| | | return true; |
| | | } |
| | |
| | | @Override |
| | | public R queryAging() { |
| | | List<AgingCompanyVo> companys = contractPaymentScheduleMapper.selectAgingCompany(null, DataScope.of("comp_id")); |
| | | if (ArrayUtil.isEmpty(companys.toArray())) { |
| | | if (CollUtil.isEmpty(companys)) { |
| | | return R.failed("暂无账龄"); |
| | | } |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | |
| | | queryDTO.setCompanyId(company.getCompanyId()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())) { |
| | | if (CollUtil.isEmpty(companyAgingVo)) { |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天", new BigDecimal("0"), null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | } else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "0-30天")) { |
| | | if (!CollUtil.contains(overdueRanges, "0-30天")) { |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "31-60天")) { |
| | | if (!CollUtil.contains(overdueRanges, "31-60天")) { |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "61-90天")) { |
| | | if (!CollUtil.contains(overdueRanges, "61-90天")) { |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "91-180天")) { |
| | | if (!CollUtil.contains(overdueRanges, "91-180天")) { |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "181-365天")) { |
| | | if (!CollUtil.contains(overdueRanges, "181-365天")) { |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "1年以上")) { |
| | | if (!CollUtil.contains(overdueRanges, "1年以上")) { |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.by4cloud.platformx.business.service.ContractService; |
| | | import com.by4cloud.platformx.business.service.PaymentOffsetService; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * 抵抹账 |
| | |
| | | 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())){ |
| | | if (CollUtil.isNotEmpty(scheduleList)){ |
| | | BigDecimal remain = paymentOffset.getOffsetAmount(); |
| | | for (ContractPaymentSchedule schedule:scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | |
| | | } |
| | | contractService.updateById(contract); |
| | | // 查询所有付款阶段是否都付款完成 |
| | | // if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | // if (.isNotEmpty(scheduleList)){ |
| | | // if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){ |
| | | // contract.setContractStatus(3); |
| | | // contractService.updateById(contract); |
| | |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.core.lang.tree.TreeNode; |
| | | import cn.hutool.core.lang.tree.TreeUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.admin.api.entity.SysDept; |
| | | import com.by4cloud.platformx.business.dto.ProductAddDTO; |
| | | import com.by4cloud.platformx.business.dto.ProductQueryDTO; |
| | | import com.by4cloud.platformx.business.entity.Product; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.BindingResult; |
| | | |
| | | |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.IntStream; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * 产品信息 |
| | |
| | | |
| | | @Override |
| | | public R saveErpProduct(List<ProductAddDTO> addDTOS) { |
| | | if (ArrayUtil.isNotEmpty(addDTOS.toArray())){ |
| | | if (CollUtil.isNotEmpty(addDTOS)){ |
| | | for (ProductAddDTO addDTO:addDTOS |
| | | ) { |
| | | List<Product> classPro = baseMapper.selectListByScope(Wrappers.<Product>lambdaQuery() |
| | | .eq(StrUtil.isNotEmpty(addDTO.getErpTypeCode()),Product::getErpCode,addDTO.getErpTypeCode()) |
| | | .eq(StrUtil.isNotEmpty(addDTO.getErpTypeName()),Product::getProductName,addDTO.getErpTypeName()) |
| | | , DataScope.of("comp_id")); |
| | | if (ArrayUtil.isEmpty(classPro.toArray())){ |
| | | if (CollUtil.isEmpty(classPro)){ |
| | | Product product = new Product(); |
| | | product.setProductName(addDTO.getErpTypeName()); |
| | | product.setProductType(addDTO.getSpecification()); |
| | |
| | | @Override |
| | | public R importProduct(List<ProductExcelVO> excelVOList, BindingResult bindingResult) { |
| | | List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget(); |
| | | if (ArrayUtil.isNotEmpty(excelVOList.toArray())) { |
| | | if (CollUtil.isNotEmpty(excelVOList)) { |
| | | List<List<ProductExcelVO>> groups = splitList(excelVOList, 5000); |
| | | groups.stream().forEach(group->{ |
| | | for (ProductExcelVO addDTO:group |
| | |
| | | errorMsg.add("产品分类信息没有"); |
| | | } |
| | | List<Product> one = this.listByScope(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, addDTO.getErpCode())); |
| | | if (ArrayUtil.isNotEmpty(one.toArray())){ |
| | | if (CollUtil.isNotEmpty(one)){ |
| | | errorMsg.add("产品erp编码已存在"); |
| | | } |
| | | if (CollUtil.isEmpty(errorMsg)){ |
| | |
| | | .eq(StrUtil.isNotEmpty(addDTO.getErpTypeCode()),Product::getErpCode,addDTO.getErpTypeCode()) |
| | | .eq(StrUtil.isNotEmpty(addDTO.getErpTypeName()),Product::getProductName,addDTO.getErpTypeName()) |
| | | , DataScope.of("comp_id")); |
| | | if (ArrayUtil.isEmpty(classPro.toArray())){ |
| | | if (CollUtil.isEmpty(classPro)){ |
| | | Product product = new Product(); |
| | | product.setProductName(addDTO.getErpTypeName()); |
| | | product.setProductType(addDTO.getSpecification()); |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | compIds.add(Long.valueOf(ymj)); |
| | | compIds.add(Long.valueOf(jxc)); |
| | | List<ContractIncomeAnalysisVo> contractIncomeAnalysisVoList = contractMapper.contractIncomeAnalysis(commonDTO,compIds); |
| | | if (ArrayUtil.isNotEmpty(contractIncomeAnalysisVoList.toArray())){ |
| | | if (CollUtil.isNotEmpty(contractIncomeAnalysisVoList)){ |
| | | contractIncomeAnalysisVoList.stream().forEach(contractIncomeAnalysisVo -> { |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),sgb)){ |
| | | contractIncomeAnalysisVo.setCompName("石工泵"); |
| | |
| | | public R contractAmountAnalysisByArea(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("company_area"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("地区字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R contractAmountAnalysisByIndustry(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("industry_sector"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("行业字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R contractAmountAnalysisByMarket(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("market_type"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("市场类型字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R contractAmountAnalysisBySpcBus(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("supply_attribute"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("供应属性字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R contractAmountAnalysisByExportBus(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("export_attr"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("区域字段获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R contractAmountAnalysisBySaleModel(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("sales_model"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("销售模式字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | public R agingAnalysisByArea(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("company_area"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("地区字典分类获取异常"); |
| | | } |
| | | // List<AgingCompanyVo> companys = contractPaymentScheduleMapper.selectAgingCompany(DataScope.of("comp_id")); |
| | | // if (ArrayUtil.isEmpty(companys.toArray())){ |
| | | // if (CollUtil.isEmpty(companys)){ |
| | | // return R.failed("暂无账龄"); |
| | | // } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | | AgingQueryDTO queryDTO = new AgingQueryDTO(); |
| | | if (ArrayUtil.contains(compIds.toArray(),SecurityUtils.getUser().getCompId())){ |
| | | if (CollUtil.contains(compIds,SecurityUtils.getUser().getCompId())){ |
| | | queryDTO.setCompanyId(SecurityUtils.getUser().getCompId()); |
| | | } |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | |
| | | queryDTO.setAreaId(item.getItemValue()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | public R agingAnalysisByIndustry(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("industry_sector"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("行业字典分类获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | |
| | | |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | | AgingQueryDTO queryDTO = new AgingQueryDTO(); |
| | | if (ArrayUtil.contains(compIds.toArray(),SecurityUtils.getUser().getCompId())){ |
| | | if (CollUtil.contains(compIds,SecurityUtils.getUser().getCompId())){ |
| | | queryDTO.setCompanyId(SecurityUtils.getUser().getCompId()); |
| | | } |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | |
| | | queryDTO.setIndustryId(item.getItemValue()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | queryDTO.setCompanyId(dept.getDeptId()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotalShip(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | queryDTO.setCompanyId(dept.getDeptId()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotalInvoice(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | public R agingAnalysisByMarket(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("market_type"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | if (CollUtil.isEmpty(items)){ |
| | | return R.failed("市场类型字典分类获取异常"); |
| | | } |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | |
| | | queryDTO.setClassId(item.getItemValue()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | |
| | | queryDTO.setCompanyId(dept.getDeptId()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotalScale(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (CollUtil.isEmpty(companyAgingVo)){ |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | if (!CollUtil.contains(overdueRanges,"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo(1L,"0-30天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | if (!CollUtil.contains(overdueRanges,"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo(2L,"31-60天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | if (!CollUtil.contains(overdueRanges,"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo(3L,"61-90天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | if (!CollUtil.contains(overdueRanges,"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo(4L,"91-180天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | if (!CollUtil.contains(overdueRanges,"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo(5L,"181-365天",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | if (!CollUtil.contains(overdueRanges,"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo(6L,"1年以上",new BigDecimal("0"),null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| 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.BankStatementItemMapper"> |
| | | |
| | | <resultMap id="bankStatementItemMap" type="com.by4cloud.platformx.business.entity.BankStatementItem"> |
| | | <id property="id" column="id"/> |
| | | <result property="compId" column="comp_id"/> |
| | | <result property="bankSeqNo" column="bank_seq_no"/> |
| | | <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> |
| | |
| | | |
| | | <mapper namespace="com.by4cloud.platformx.business.mapper.ContractInvoiceMapper"> |
| | | |
| | | <resultMap id="ContractInvoiceMap" type="com.by4cloud.platformx.business.entity.ContractInvoice"> |
| | | <id property="id" column="id"/> |
| | | <result property="compId" column="comp_id"/> |
| | | <result property="contractId" column="contract_id"/> |
| | | <result property="invoicePrice" column="invoice_total_price_tax"/> |
| | | <result property="invoiceTime" column="invoice_time"/> |
| | | <result property="invoicePath" column="invoice_path"/> |
| | | <result property="invoiceCategory" column="invoice_category"/> |
| | | <result property="redReversal" column="red_reversal"/> |
| | | <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> |
| | | <select id="homeZbjt" resultType="com.by4cloud.platformx.business.vo.HomeZbjtVo"> |
| | | SELECT |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) sgbbr, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) sgbby, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) sgbbn, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) smjbr, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) smjby, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) smjbn, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) jxcbr, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) jxcby, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) jxcbn, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) tfbr, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) tfby, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) tfbn, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) ymjbr, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) ymjby, |
| | | ( |
| | | SELECT |
| | | sum(ci.invoice_total_price_tax) |
| | | FROM |
| | | contract_invoice ci |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) ymjbn |
| | | <resultMap id="ContractInvoiceMap" type="com.by4cloud.platformx.business.entity.ContractInvoice"> |
| | | <id property="id" column="id"/> |
| | | <result property="compId" column="comp_id"/> |
| | | <result property="contractId" column="contract_id"/> |
| | | <result property="invoicePrice" column="invoice_total_price_tax"/> |
| | | <result property="invoiceTime" column="invoice_time"/> |
| | | <result property="invoicePath" column="invoice_path"/> |
| | | <result property="invoiceCategory" column="invoice_category"/> |
| | | <result property="redReversal" column="red_reversal"/> |
| | | <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> |
| | | <select id="homeZbjt" resultType="com.by4cloud.platformx.business.vo.HomeZbjtVo"> |
| | | SELECT ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) sgbbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) sgbby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556196124250113 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) sgbbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) smjbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) smjby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056555602756063234 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) smjbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) jxcbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) jxcby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556317461270529 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) jxcbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) tfbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) tfby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556421857497090 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) tfbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) ymjbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) ymjby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci |
| | | WHERE ci.del_flag = '0' |
| | | AND comp_id = 2056556535640576002 |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) ymjbn |
| | | </select> |
| | | <select id="homeZgs" resultType="com.by4cloud.platformx.business.vo.HomeZgsVo"> |
| | | SELECT |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) hbbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) hbby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) hbbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '6' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) xbbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '6' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) xbby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) xbbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) dbbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) dbby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) dbbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) hdbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) hdby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) hdbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) znbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) znby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) znbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) xnbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) xnby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) xnbn, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.export_service_attr = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) hwbr, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.export_service_attr = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) hwby, |
| | | ( |
| | | SELECT |
| | | sum( ci.invoice_total_price_tax ) |
| | | FROM |
| | | contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE |
| | | ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND ci.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) hwbn |
| | | <select id="homeZgs" resultType="com.by4cloud.platformx.business.vo.HomeZgsVo"> |
| | | SELECT ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) hbbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) hbby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) hbbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '6' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) xbbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '6' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) xbby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) xbbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) dbbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) dbby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '1' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) dbbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) hdbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) hdby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '3' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) hdbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) znbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) znby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '4' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) znbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) xnbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) xnby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '5' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) xnbn, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.export_service_attr = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= CURDATE() |
| | | AND ci.invoice_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY )) hwbr, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.export_service_attr = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01')) hwby, |
| | | ( |
| | | SELECT sum(ci.invoice_total_price_tax) |
| | | FROM contract_invoice ci, |
| | | contract c, |
| | | business_customer bc |
| | | WHERE ci.del_flag = '0' |
| | | AND bc.del_flag = '0' |
| | | AND c.del_flag = '0' |
| | | AND ci.contract_id = c.id |
| | | AND bc.id = c.party_a_id |
| | | AND bc.area_id = '2' |
| | | AND ci.comp_id = #{compId} |
| | | AND ci.invoice_time >= DATE_FORMAT(CURDATE(), '%Y-01-01') |
| | | AND ci.invoice_time < DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01')) hwbn |
| | | </select> |
| | | <select id="pageInvoice" resultType="com.by4cloud.platformx.business.vo.HomeInvoiceVo"> |
| | | <select id="pageInvoice" resultType="com.by4cloud.platformx.business.vo.HomeInvoiceVo"> |
| | | SELECT |
| | | t.id, |
| | | t.contract_id, |
| | |
| | | WHERE |
| | | t.del_flag = '0' |
| | | <if test="queryDTO.queryCompId !=null and queryDTO.queryCompId !=''"> |
| | | AND t.comp_id = #{queryDTO.queryCompId} |
| | | AND t.comp_id = #{queryDTO.queryCompId} |
| | | </if> |
| | | <if test="queryDTO.invoiceCategory !=null and queryDTO.invoiceCategory !=''"> |
| | | AND t.invoice_category = #{queryDTO.invoiceCategory} |
| | | AND t.invoice_category = #{queryDTO.invoiceCategory} |
| | | </if> |
| | | <if test="queryDTO.contractNo !=null and queryDTO.contractNo !=''"> |
| | | AND t1.contract_no LIKE CONCAT('%', #{queryDTO.contractNo}, '%') |
| | |
| | | AND t2.company_name LIKE CONCAT('%', #{queryDTO.partyA}, '%') |
| | | </if> |
| | | <if test="queryDTO.queryArea !=null and queryDTO.queryArea !=''"> |
| | | AND t2.class_id = #{queryDTO.queryArea} |
| | | AND t2.class_id = #{queryDTO.queryArea} |
| | | </if> |
| | | <if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''"> |
| | | AND t2.export_service_attr = #{queryDTO.queryServiceAttr} |
| | | AND t2.export_service_attr = #{queryDTO.queryServiceAttr} |
| | | </if> |
| | | <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='1'.toString()"> |
| | | AND t.invoice_time >= CURDATE() |
| | | AND t.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY ) |
| | | AND t.invoice_time >= CURDATE() |
| | | AND t.invoice_time < DATE_ADD( CURDATE(), INTERVAL 1 DAY ) |
| | | </if> |
| | | <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='2'.toString()"> |
| | | AND t.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND t.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' ) |
| | | AND t.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND t.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' ) |
| | | </if> |
| | | <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='3'.toString()"> |
| | | AND t.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND t.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' ) |
| | | AND t.invoice_time >= DATE_FORMAT( CURDATE(), '%Y-01-01' ) |
| | | AND t.invoice_time < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' ) |
| | | </if> |
| | | <if test="queryDTO.startTime !=null and queryDTO.endTime !=null"> |
| | | AND t.invoice_time >= #{queryDTO.startTime} |
| | | AND t.invoice_time <= #{queryDTO.endTime} |
| | | AND t.invoice_time >= #{queryDTO.startTime} |
| | | AND t.invoice_time <= #{queryDTO.endTime} |
| | | </if> |
| | | ORDER BY |
| | | t.create_time DESC |
| | | </select> |
| | | <select id="pageScope" resultType="com.by4cloud.platformx.business.vo.ContractInvoicePageVo"> |
| | | <select id="pageScope" resultType="com.by4cloud.platformx.business.vo.ContractInvoicePageVo"> |
| | | SELECT |
| | | id, |
| | | contract_no, |
| | | contract_name, |
| | | party_a_id, |
| | | party_a, |
| | | party_b_id, |
| | | party_b, |
| | | amount, |
| | | currency, |
| | | contract_type, |
| | | supply_attribute, |
| | | contract_status, |
| | | contract_attribute, |
| | | sign_date, |
| | | sign_place, |
| | | effective_date, |
| | | delivery_cycle, |
| | | expiration_date, |
| | | attachment_url, |
| | | remark, |
| | | parent_id, |
| | | approve_time, |
| | | arrival_schedule_id, |
| | | accept_schedule_id, |
| | | warranty_schedule_id, |
| | | erp_push_flag, |
| | | billing_status, |
| | | billing_amout, |
| | | next_schedule_name, |
| | | template_id, |
| | | sales_model, |
| | | paid_amount, |
| | | contract_category, |
| | | exec_frequency, |
| | | exec_times, |
| | | exec_day, |
| | | environment, |
| | | standard, |
| | | use_month, |
| | | after_ship_month, |
| | | ship_method, |
| | | ship_address, |
| | | packaging, |
| | | repair_period, |
| | | repair_breach_amount, |
| | | goods_short, |
| | | goods_short_breach_amount, |
| | | overdue_breach_amount, |
| | | terminate_contract, |
| | | court, |
| | | contract_attchment, |
| | | city, |
| | | region, |
| | | invoice_notice, |
| | | contract_tax, |
| | | economic_matters, |
| | | erp_contract_no, |
| | | data_id, |
| | | industry_code, |
| | | area_code, |
| | | create_by, |
| | | update_by, |
| | | create_time, |
| | | update_time, |
| | | del_flag, |
| | | comp_id, |
| | | (select count(1) from contract_invoice ci where ci.del_flag = '0' and ci.contract_id = c.id) invoiceNum |
| | | id, |
| | | contract_no, |
| | | contract_name, |
| | | party_a_id, |
| | | party_a, |
| | | party_b_id, |
| | | party_b, |
| | | amount, |
| | | currency, |
| | | contract_type, |
| | | supply_attribute, |
| | | contract_status, |
| | | contract_attribute, |
| | | sign_date, |
| | | sign_place, |
| | | effective_date, |
| | | delivery_cycle, |
| | | expiration_date, |
| | | attachment_url, |
| | | remark, |
| | | parent_id, |
| | | approve_time, |
| | | arrival_schedule_id, |
| | | accept_schedule_id, |
| | | warranty_schedule_id, |
| | | erp_push_flag, |
| | | billing_status, |
| | | billing_amout, |
| | | next_schedule_name, |
| | | template_id, |
| | | sales_model, |
| | | paid_amount, |
| | | contract_category, |
| | | exec_frequency, |
| | | exec_times, |
| | | exec_day, |
| | | environment, |
| | | standard, |
| | | use_month, |
| | | after_ship_month, |
| | | ship_method, |
| | | ship_address, |
| | | packaging, |
| | | repair_period, |
| | | repair_breach_amount, |
| | | goods_short, |
| | | goods_short_breach_amount, |
| | | overdue_breach_amount, |
| | | terminate_contract, |
| | | court, |
| | | contract_attchment, |
| | | city, |
| | | region, |
| | | invoice_notice, |
| | | contract_tax, |
| | | economic_matters, |
| | | erp_contract_no, |
| | | data_id, |
| | | industry_code, |
| | | area_code, |
| | | create_by, |
| | | update_by, |
| | | create_time, |
| | | update_time, |
| | | del_flag, |
| | | comp_id, |
| | | (select count(1) from contract_invoice ci where ci.del_flag = '0' and ci.contract_id = c.id) invoiceNum, |
| | | (select planned_amount from contract_payment_schedule cps where cps.del_flag='0' and cps.stage_name='合同签订' and cps.contract_id = c.id) advanceAmount |
| | | FROM |
| | | contract c |
| | | contract c |
| | | WHERE |
| | | del_flag = '0' |
| | | del_flag = '0' |
| | | <if test="queryDTO.contractNo !=null and queryDTO.contractNo !=''"> |
| | | AND contract_no LIKE CONCAT('%', #{queryDTO.contractNo}, '%') |
| | | </if> |
| | |
| | | <if test="queryDTO.billingStatus !=null and queryDTO.billingStatus !=''"> |
| | | AND billing_status = #{queryDTO.billingStatus} |
| | | </if> |
| | | <if test="queryDTO.advanceType !=null and queryDTO.advanceType !=''"> |
| | | AND exists (select * from contract_payment_schedule cps where cps.del_flag='0' and |
| | | cps.stage_name='合同签订' and cps.payment_ratio > 0 and cps.contract_id = c.id) |
| | | AND not exists (select * from contract_out_bound cps where cps.del_flag='0' and |
| | | cps.contract_id = c.id) |
| | | </if> |
| | | ORDER BY |
| | | create_time ASC |
| | | create_time ASC |
| | | </select> |
| | | </mapper> |
| | |
| | | WHERE |
| | | del_flag = '0' |
| | | <if test="queryDTO.productName !=null and queryDTO.productName !=''"> |
| | | and t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%') |
| | | and ( t.product_name LIKE CONCAT('%', #{queryDTO.productName}, '%') or |
| | | t.erp_code LIKE CONCAT('%', #{queryDTO.productName}, '%')) |
| | | </if> |
| | | <if test="queryDTO.parentId !=null "> |
| | | and t.parent_id = #{queryDTO.parentId} |