1.Import Excel

这个是用Java的内置类实现的导入excel:

public ResponseData pup2PubTransfer(@RequestParam MultipartFile file, HttpServletResponse response) throws Exception {
        ImportParams params = new ImportParams();
        params.setTitleRows(0);
        params.setSheetNum(2);
        params.setNeedVerfiy(true);
        ExcelImportResult<OmsPubBankFlowExcelEntity> result = ExcelImportUtil.importExcelMore(file.getInputStream(),
                OmsPubBankFlowExcelEntity.class, params);
        //List<OmsPubBankFlowExcelEntity> list= ExcelImportUtil.importExcel(file.getInputStream(), OmsPubBankFlowExcelEntity.class,params);
        //校验 客户名称,金额,交易时间不能为空,如果有一条不满足则返回,没有则存储
        if (result.getFailList().size() > 0) {
            OutputStream fos = response.getOutputStream();
            result.getWorkbook().write(fos);
            fos.close();
        } else { ...

导入并校验:

   @ApiOperation("公对公转账银行流水记录导入")
    @RequestMapping(value = "/", method = RequestMethod.POST)
    public ResponseData pup2PubTransfer(@RequestParam MultipartFile file, HttpServletResponse response) throws Exception {
        ImportParams params = new ImportParams();
        params.setTitleRows(0);
        params.setSheetNum(2);
        params.setNeedVerfiy(true);
        ExcelImportResult<OmsPubBankFlowExcelEntity> result = ExcelImportUtil.importExcelMore(file.getInputStream(),
                OmsPubBankFlowExcelEntity.class, params);
        //List<OmsPubBankFlowExcelEntity> list= ExcelImportUtil.importExcel(file.getInputStream(), OmsPubBankFlowExcelEntity.class,params);
        //校验 客户名称,金额,交易时间不能为空,如果有一条不满足则返回,没有则存储
        if (result.getFailList().size() > 0) {
            OutputStream fos = response.getOutputStream();
            result.getWorkbook().write(fos);
            fos.close();
        } else {
            List<OmsPubBankFlowExcelEntity> omsPubBankFlowExcelEntitys = result.getList();
            //先做单,对公
            List<OmsOrder> pubOmsOrders = omsOrderService.queryVerifyOrder(BizConstants.CWDZ_DG_XZD.getCode());
            //后做单,已预收,预收款做单
            List<OmsOrder> advanceOmsOrders=omsOrderService.queryVerifyOrder(BizConstants.CWDZ_DG_YSK_YZD.getCode());
            pubOmsOrders.addAll(advanceOmsOrders);
            List handOrder=new ArrayList();
            List exceptionOrder=new ArrayList();
            Iterator<OmsPubBankFlowExcelEntity> iterator = omsPubBankFlowExcelEntitys.iterator();
            while (iterator.hasNext()){
                OmsPubBankFlowExcelEntity entity=iterator.next();
                for(OmsOrder omsOrder:pubOmsOrders){
                    String amount=entity.getAmount();
                    BigDecimal bankAmount=new BigDecimal(amount);
                    BigDecimal orderAmount=omsOrder.getTotalAmount();
                    String orderTime = DateUtil.format(omsOrder.getCreateTime(), "yyyy-MM");
                    String bankTime=DateUtil.format(entity.getTransferTime(), "yyyy-MM");
                    if(entity.getAccName().equals(omsOrder.getKhmc())
                            && (orderAmount.compareTo(bankAmount)==0) && orderTime.equals(bankTime)){
                        omsOrder.setPayStatus(BizConstants.ZFZT_YZF.getCode());
                        if(!handOrder.contains(omsOrder)){
                            handOrder.add(omsOrder);

                        }else{
                            omsOrder.setPayStatus(BizConstants.ZFZT_WZF.getCode());
                            exceptionOrder.add(omsOrder);
                        }
                        iterator.remove();
                    }
                }
            }

        }
        return null;
    }

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值