項目中使用的功能點

一、將產(chǎn)品提供的基礎敏感詞excel導入到數(shù)據(jù)庫,關鍵代碼及實現(xiàn)如下

創(chuàng)新互聯(lián)公司公司2013年成立,先為銀州等服務建站,銀州等地企業(yè),進行企業(yè)商務咨詢服務。為銀州企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務解決您的所有建站問題。

1.添加依賴

<dependency>

? ? ? ? ? ? <groupId>net.sourceforge.jexcelapi</groupId>

? ? ? ? ? ? <artifactId>jxl</artifactId>

? ? ? ? ? ? <version>2.6.10</version>

? ? ? ? </dependency>

2.代碼實現(xiàn)如下

try {

? ? ? ? ? ? File file = new File("/Users/suyanzhu/Downloads/word.xls");

? ? ? ? ? ? boolean exists = file.exists();

? ? ? ? ? ? Workbook workbook = Workbook.getWorkbook(file);

? ? ? ? ? ? Sheet sheet = workbook.getSheet(0);

? ? ? ? ? ? for (int i = 1;i < sheet.getRows();i++){

? ? ? ? ? ? ? ? Cell cell1 = sheet.getCell(0, i);

? ? ? ? ? ? ? ? Cell cell2 = sheet.getCell(1, i);

? ? ? ? ? ? ? ? Long typeId = 1L;

? ? ? ? ? ? ? ? if (cell1.getContents().equals("敏感詞類型1")){

? ? ? ? ? ? ? ? ? ? typeId = 1L;

? ? ? ? ? ? ? ? }else if (cell1.getContents().equals("敏感詞類型2")){

? ? ? ? ? ? ? ? ? ? typeId = 2L;

? ? ? ? ? ? ? ? }else if (cell1.getContents().equals("敏感詞類型3")){

? ? ? ? ? ? ? ? ? ? typeId = 3L;

? ? ? ? ? ? ? ? }else if (cell1.getContents().equals("敏感詞類型4")){

? ? ? ? ? ? ? ? ? ? typeId = 4L;

? ? ? ? ? ? ? ? }else if (cell1.getContents().equals("敏感詞類型5")){

? ? ? ? ? ? ? ? ? ? typeId = 5L;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? SensitiveWordParamDTO build = SensitiveWordParamDTO

? ? ? ? ? ? ? ? ? ? ? ? .builder().addUserId(1L)

? ? ? ? ? ? ? ? ? ? ? ? .expressionState(2)

? ? ? ? ? ? ? ? ? ? ? ? .name(cell2.getContents())

? ? ? ? ? ? ? ? ? ? ? ? .replaceWord("*")

? ? ? ? ? ? ? ? ? ? ? ? .typeId(typeId)

? ? ? ? ? ? ? ? ? ? ? ? .build();

? ? ? ? ? ? ? ? try {

? ? ? ? ? ? ? ? ? ? sensitiveWordProvider.save(build);

? ? ? ? ? ? ? ? } catch (SsHoursException e) {

? ? ? ? ? ? ? ? ? ? e.printStackTrace();

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? ? ? workbook.close();

? ? ? ? } catch (IOException e) {

? ? ? ? ? ? e.printStackTrace();

? ? ? ? } catch (BiffException e) {

? ? ? ? ? ? e.printStackTrace();

? ? ? ? }

二、一對多數(shù)據(jù)顯示在一行sql

SELECT

rrc.id,

cc.nickname,

cc.mobile,

rrc.update_time,

rrc.update_user_id,

? apa.optionIds

FROM

表1?rrc

LEFT JOIN (

SELECT

GROUP_CONCAT(

rrco.option_id

) optionIds,

risk_customer_id

FROM

表2?rrco

GROUP BY

rrco.risk_customer_id

) apa ON apa.risk_customer_id = rrc.id

LEFT JOIN?表3 cc ON cc.id = rrc.customer_id

LEFT JOIN?表2 rrco ON rrc.id = rrco.risk_customer_id

WHERE

rrco.option_id = 3

GROUP BY

rrc.id

三、給定數(shù)字生成1到指定數(shù)字的數(shù)字列表

//?開始值

int start = 1;

//?結(jié)束值

int end = 100;

// 生成1,2,3,4,5...100

List<Integer> list = Stream.iterate(start, item -> item+1).limit(end).collect(Collectors.toList());


網(wǎng)頁標題:項目中使用的功能點
URL標題:http://bm7419.com/article18/goejdp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、App設計、建站公司、品牌網(wǎng)站建設、服務器托管、自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設