亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

解析excel數(shù)據(jù)并做檢驗(yàn)及保存到數(shù)據(jù)庫

luffyZh / 1716人閱讀

摘要:此例為初次參與企業(yè)項(xiàng)目做的,代碼粗糙勿見怪從導(dǎo)入核心企業(yè)信息到數(shù)據(jù)庫文件上傳路徑執(zhí)行上傳執(zhí)行讀操作讀出的數(shù)據(jù)導(dǎo)入從第行開始從第列開始第個(gè)數(shù)據(jù)庫寫入操作白名單信息必輸字段核心企業(yè)名稱項(xiàng)目公司名稱為非必輸校驗(yàn)忽略序號(hào)核心企業(yè)名稱項(xiàng)目公司名稱數(shù)據(jù)

此例為初次參與企業(yè)項(xiàng)目做的,代碼粗糙勿見怪:

/**
     * 從EXCEL導(dǎo)入核心企業(yè)信息到數(shù)據(jù)庫
     * @param file
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "importWhitelistExcel")
    public ModelAndView readExcel(
            @RequestParam(value="excel",required=false) MultipartFile file
            ) {
        ModelAndView mv = this.getModelAndView();
        PageData pd = this.getPageData();
        
        Whitelist whiteList = new Whitelist();
        if(!Jurisdiction.buttonJurisdiction(menuUrl, "add")){return null;}
        if (null != file && !file.isEmpty()) {
            String filePath = PathUtil.getClasspath() + Const.FILE_PATH_FILE;                    //文件上傳路徑
            String dateStr = DateUtils.getSdfTimes();
            String fileName = "Whitelist_"+Jurisdiction.getUsername()+"_"+dateStr;            
            fileName =  FileUpload.fileUp(file, filePath, fileName);                              //執(zhí)行上傳
            
            //執(zhí)行讀EXCEL操作,讀出的數(shù)據(jù)導(dǎo)入List 2:從第3行開始;1:從第B列開始;0:第0個(gè)sheet
            String errmsg=null;
            //Matcher matcher = null;
            List readList=new ArrayList();
            List errorList=new ArrayList();
            
            
            try{
                List excelPdList = (List)ObjectExcelRead.readExcel(filePath, fileName, 2, 1, 0, "#.####");
            
                /*數(shù)據(jù)庫寫入操作======================================*/
                /*
                 * 白名單信息必輸字段:
                 * 核心企業(yè)名稱,項(xiàng)目公司名稱
                 * (為非必輸)
                 * 校驗(yàn):
                 */
                
                for(PageData ca:excelPdList){
                    // 忽略序號(hào)
                    PageData readPd = new PageData();
                    PageData tipPd = new PageData();
                    
                    String coreManuName = StringUtils.trimToEmpty(ca.getString("var1")); //核心企業(yè)名稱
                    String companyName = StringUtils.trimToEmpty(ca.getString("var2")); //項(xiàng)目公司名稱
                    String coreManuId = null;
                    //int index = excelPdList.indexOf(ca);
                    
                    // 數(shù)據(jù)校驗(yàn)開始
                    
                    if(StringUtils.isEmpty(coreManuName))
                    {
                        tipPd.put("coreManuName", coreManuName);
                        tipPd.put("companyName", companyName);
                        if(StringUtils.isEmpty(companyName)){
                            
//                            tipPd.put("tip", "核心企業(yè)名稱和項(xiàng)目公司名稱不能為空");
                            
                            continue;
                        }else{
                            tipPd.put("tip", "核心企業(yè)名稱不能為空");
                        }
                        errorList.add(tipPd);
//                        errmsg="核心企業(yè)名稱不能為空";
//                        break;
                    }else if(StringUtils.isEmpty(companyName))
                    {
                        tipPd.put("coreManuName", coreManuName);
                        tipPd.put("companyName", companyName);
                        tipPd.put("tip", "項(xiàng)目公司名稱不能為空");
                        errorList.add(tipPd);
//                        errmsg="核心企業(yè)["+coreManuName+"]項(xiàng)目公司名稱不能為空";
//                        break;
                    }
//                    CoreCompany c = coreCompanyService.findByCompanyName(coreManuName);
//                    System.out.println(coreManuName);
//                    System.out.println(c);
                    if(!StringUtils.isEmpty(coreManuName)){
                        
                        CoreCompany coreManu = coreCompanyService.findByCompanyName(coreManuName);
                        
                        if(coreManu == null) {
                            tipPd.put("coreManuName", coreManuName);
                            tipPd.put("companyName", companyName);
                            tipPd.put("tip", "系統(tǒng)找不到核心企業(yè)名稱,核心企業(yè)名稱錯(cuò)誤");
                            errorList.add(tipPd);
                        }else {
                            coreManuId = coreManu.getId();
                            whiteList = whitelistService.findByWhitelistName(coreManuId, companyName);
                            if(whiteList != null) {//判斷導(dǎo)入表中是否存在相同數(shù)據(jù)
                                tipPd.put("coreManuName", coreManuName);
                                tipPd.put("companyName", companyName);
                                tipPd.put("tip", "此記錄已錄入系統(tǒng)");
                                errorList.add(tipPd);
//                                errmsg = "核心企業(yè)["+coreManuName+"]和項(xiàng)目公司["+companyName+"在系統(tǒng)中已存在,請(qǐng)?jiān)趯?dǎo)入表刪除后重新導(dǎo)入";
//                                break;
                            }
                        }
                        
                    }
                    
                    readPd.put("coreManuId", coreManuId);   //核心企業(yè)編號(hào)
                    readPd.put("companyName", companyName); //項(xiàng)目公司名稱
                    readPd.put("status", "EBST0101");
                    readPd.put("createUser", Jurisdiction.getUsername());
                    readPd.put("createTime", DateUtils.getTime());
                    readPd.put("lasUpdUser", Jurisdiction.getUsername());
                    readPd.put("lasUpdTime", DateUtils.getTime());
                    readPd.put("Id", this.get32UUID()); //ID
                    
                    if(!readList.isEmpty()) {
                        
                        for(PageData read : readList) {
                            
                            if(read.containsValue(companyName) && read.containsValue(coreManuId)){
                                //判斷導(dǎo)入表中是否有相同項(xiàng)目公司
                                tipPd.put("coreManuName", coreManuName);
                                tipPd.put("companyName", companyName);
                                tipPd.put("tip", "此記錄在導(dǎo)入表中重復(fù)");
                                errorList.add(tipPd);
//                                errmsg = "導(dǎo)入表里核心企業(yè)["+coreManuName+"]和項(xiàng)目公司["+companyName+"]在表中重復(fù),請(qǐng)修改后導(dǎo)入";
//                                break;
                            }
                        }
                    }
                    readList.add(readPd);
                }
            }catch(Exception ex){
                logger.error("處理Excel文件出錯(cuò)", ex);
                errmsg="處理Excel文件出錯(cuò),"+ex.getMessage();
            }
            
            
            if(errmsg==null && readList.size()==0){
                errmsg="未檢測到符合條件的數(shù)據(jù)";
            }
            
            if(errmsg!=null || errorList.size()>0){
                if(errmsg==null){
                    errmsg="數(shù)據(jù)導(dǎo)入失敗,請(qǐng)核對(duì)以下數(shù)據(jù)";
                }
                mv.addObject("errmsg", errmsg);
                mv.addObject("tipList", errorList);
                mv.setViewName("business/whitelist/whitelist_upload");
                return mv;
            }
            
//            if(errmsg!=null){
//                mv.addObject("errmsg", errmsg);
//                mv.setViewName("business/whitelist/whitelist_upload");
//                return mv;
//            }
            //批量保存到數(shù)據(jù)庫
            try {
                whitelistService.saveAll(readList);
            } catch (Exception e) {
//                e.printStackTrace();
                logger.error(e.toString());
                errmsg = "系統(tǒng)異常,保存數(shù)據(jù)失敗";
                mv.addObject("errmsg", errmsg);
                mv.setViewName("business/whitelist/whitelist_upload");
                return mv;
            }
            
        }
            
        mv.addObject("msg","success");
        mv.setViewName("save_result");
        return mv;
        
        
    }
    

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/66719.html

相關(guān)文章

  • 數(shù)據(jù)游戲」:使用 LSTM 模型預(yù)測三天后單股收盤價(jià)

    摘要:本次比賽將使用模型來預(yù)測招商銀行三天后的收盤價(jià),也就是利用月日前的數(shù)據(jù),來預(yù)測月日的收盤價(jià)。按照個(gè)交易日的模式,將數(shù)據(jù)變成一個(gè),,的張量表。在實(shí)際使用時(shí)進(jìn)行模型載入,分別查看預(yù)測結(jié)果。 作者:瘋貓子,「數(shù)據(jù)游戲」優(yōu)勝隊(duì)伍成員 摘要 LSTM模型是RNN的一種,其特點(diǎn)是在單一循環(huán)神經(jīng)網(wǎng)絡(luò)的基礎(chǔ)上,構(gòu)建出了長短記憶門,也就是可以長時(shí)間發(fā)現(xiàn)和記憶長依賴關(guān)系。本次比賽將使用LSTM模型來預(yù)測招...

    dreamans 評(píng)論0 收藏0
  • 數(shù)據(jù)游戲」:使用 LSTM 模型預(yù)測三天后單股收盤價(jià)

    摘要:本次比賽將使用模型來預(yù)測招商銀行三天后的收盤價(jià),也就是利用月日前的數(shù)據(jù),來預(yù)測月日的收盤價(jià)。按照個(gè)交易日的模式,將數(shù)據(jù)變成一個(gè),,的張量表。在實(shí)際使用時(shí)進(jìn)行模型載入,分別查看預(yù)測結(jié)果。 作者:瘋貓子,「數(shù)據(jù)游戲」優(yōu)勝隊(duì)伍成員 摘要 LSTM模型是RNN的一種,其特點(diǎn)是在單一循環(huán)神經(jīng)網(wǎng)絡(luò)的基礎(chǔ)上,構(gòu)建出了長短記憶門,也就是可以長時(shí)間發(fā)現(xiàn)和記憶長依賴關(guān)系。本次比賽將使用LSTM模型來預(yù)測招...

    JeOam 評(píng)論0 收藏0
  • XCel 項(xiàng)目總結(jié) - Electron 與 Vue 的性能優(yōu)化

    摘要:而這里的單元格信息是唯一的,所以直接通過為一個(gè)空對(duì)象賦值即可。和相關(guān)的知識(shí)和技巧高亮的列單元格采用展示。在中,被選中的單元格會(huì)高亮相應(yīng)的行和列,以提醒用戶。 showImg(https://segmentfault.com/img/bVGkdk?w=900&h=500); XCEL 是一個(gè) Excel 數(shù)據(jù)清洗工具,其通過可視化的方式讓用戶輕松地對(duì) Excel 數(shù)據(jù)進(jìn)行篩選。 XCEL...

    XUI 評(píng)論0 收藏0
  • 第一篇(從django后臺(tái)解析excel數(shù)據(jù)批量導(dǎo)入數(shù)據(jù)庫)

    摘要:總結(jié)整個(gè)過程的難點(diǎn)在于獲取文件對(duì)象,從數(shù)據(jù)中取值然后在按取出,這樣我們就可以從后臺(tái)上傳文件,然后進(jìn)行批量導(dǎo)入數(shù)據(jù)庫,其他數(shù)據(jù)格式只需要改和中的數(shù)據(jù)字段就可以 第一篇(從django后臺(tái)解析excel數(shù)據(jù)批量導(dǎo)入數(shù)據(jù)庫) 文章會(huì)在github中持續(xù)更新 作者: knthony github 聯(lián)系我 1.django 如何從后臺(tái)上傳excel中批量解析數(shù)據(jù) 要從django后臺(tái)導(dǎo)入...

    2i18ns 評(píng)論0 收藏0
  • 第7期 Datawhale 組隊(duì)學(xué)習(xí)計(jì)劃

    馬上就要開始啦這次共組織15個(gè)組隊(duì)學(xué)習(xí) 涵蓋了AI領(lǐng)域從理論知識(shí)到動(dòng)手實(shí)踐的內(nèi)容 按照下面給出的最完備學(xué)習(xí)路線分類 難度系數(shù)分為低、中、高三檔 可以按照需要參加 - 學(xué)習(xí)路線 - showImg(https://segmentfault.com/img/remote/1460000019082128); showImg(https://segmentfault.com/img/remote/...

    dinfer 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<