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;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章