這篇文章將為大家詳細(xì)講解有關(guān)大數(shù)據(jù)中如何實(shí)現(xiàn)導(dǎo)入,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
為新源等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及新源網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、新源網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
@PostConstruct public void init(){ format = new SimpleDateFormat(CollectChargeEnum.DATEFORMAT.getName()); headers = new String[]{"停車場名稱", "車牌號", "支付方式", "賬號類型", "交易號", "支付金額", "支付時間", "平帳狀態(tài)"}; exportFields = new String[]{"stoppingPlaceName", "vehicleNo", "payTypeName", "chargeType", "transactionNo", "payCharge", "payTime", "flatAccountStatusName"}; setMethodName = new String[]{"setStoppingPlaceId", "setVehicleNo", "setPayType", "setChargeType", "setTransactionNo", "setPayCharge", "setPayTime", "setFlatAccountStatus"}; intFileIndex = Arrays.asList(new Integer[]{2,7}); } @Override public boolean importExcel(MultipartFile importFile) throws BizException{ List<FlatAccoutEntity> listFlatAccountInfo = new ArrayList<FlatAccoutEntity>(100); // 解析Excel importFile文件, 0 sheet頁 List<Map<String,String>> readExcel = ExcelUtil.readExcel(importFile, 0); // 獲取當(dāng)期時間 // 獲取用戶信息 net.sf.json.JSONObject userInfo = CurrentUserInfoUtil.getCurrentUserInfo(redisTemplate); // 獲取用戶名 String userName = userInfo.get("userName").toString(); // 獲取小區(qū)id String stoppingPlaceId = currloginInfoService.getCurrLoginStoppingPlaceId(); // 獲取停車場name StoppingPlaceInfomationEntity stoppingPlaceInfomation = stoppingPlaceInfomationService.getById(stoppingPlaceId); String stoppingPlaceName = StringUtils.EMPTY; if(stoppingPlaceInfomation!=null) { stoppingPlaceName = stoppingPlaceInfomation.getStoppingPlaceName(); } // 循環(huán)獲取數(shù)據(jù) for (Map<String, String> map : readExcel) { FlatAccoutEntity accoutEntity = new FlatAccoutEntity(); // 判斷是否是該停車場 if(StringUtils.isNotEmpty(map.get("停車場名稱")) && stoppingPlaceName.equals(map.get("停車場名稱"))) { }else { throw new BizException("10003","該數(shù)據(jù)不是當(dāng)前停車場"); } // 設(shè)置停車場 accoutEntity.setStoppingPlaceId(stoppingPlaceId); // excel中第1列是停車場名稱,不需要取 for(int i=1;i<headers.length;i++) { String valueStr = map.get(headers[i]); // 判斷該字段是否為數(shù)字 if(intFileIndex.contains(i)){ int valueInt = -1; // 將valueStr轉(zhuǎn)換為int // 若是支付方式 if(i==2){ valueInt = EnumUtils.getPayTypeValue(valueStr); } // 若是平帳狀態(tài) if(i==7){ valueInt = EnumUtils.getFlatStatusValue(valueStr); } // 調(diào)用該字段的set方法 MethodUtils.callSetMethod(accoutEntity,setMethodName[i], Integer.class,valueInt); }else if(i==6){ // 轉(zhuǎn)換為日期格式 try { final Date valueDate = format.parse(valueStr); MethodUtils.callSetMethod(accoutEntity,setMethodName[i],Date.class,valueDate); } catch (ParseException e) { log.error(e); continue; } }else { // 其余都是str類型 不需要轉(zhuǎn)換類型 MethodUtils.callSetMethod(accoutEntity,setMethodName[i],String.class,valueStr); } } listFlatAccountInfo.add(accoutEntity); } // 保存數(shù)據(jù)至數(shù)據(jù)庫 boolean saveResult = this.saveBatch(listFlatAccountInfo); return saveResult; }
關(guān)于“大數(shù)據(jù)中如何實(shí)現(xiàn)導(dǎo)入”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
分享標(biāo)題:大數(shù)據(jù)中如何實(shí)現(xiàn)導(dǎo)入
當(dāng)前網(wǎng)址:http://chinadenli.net/article46/ppsceg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、營銷型網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、響應(yīng)式網(wǎng)站、App設(shè)計(jì)、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)