Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BudgetManagementSystem
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王利雷
BudgetManagementSystem
Commits
5661f8ab
Commit
5661f8ab
authored
May 24, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备费详细描述,设备费map的key更新,不再删除原有,而是直接定位key并更新价格,预算说明同步
parent
a3de9b40
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
141 additions
and
14 deletions
+141
-14
IEquipmentDao.xml
src/main/java/dao/IEquipmentDao.xml
+2
-2
BudgetHandler.java
src/main/java/handlers/BudgetHandler.java
+16
-3
CrawlerService.java
src/main/java/service/impl/CrawlerService.java
+26
-5
BudgetExportUtil.java
src/main/java/util/BudgetExportUtil.java
+10
-2
budgetDetail.jsp
src/main/webapp/budgetDetail.jsp
+4
-1
budgetSetting.jsp
src/main/webapp/budgetSetting.jsp
+1
-1
usercenter.jsp
src/main/webapp/usercenter.jsp
+1
-0
CrawlerTest.java
src/test/java/CrawlerTest.java
+81
-0
No files found.
src/main/java/dao/IEquipmentDao.xml
View file @
5661f8ab
...
...
@@ -3,13 +3,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"dao.IEquipmentDao"
>
<insert
id=
"insertEquipment"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into equipment(name,price
) values(#{name},#{pric
e})
insert into equipment(name,price
,comment,type) values(#{name},#{price},#{comment},#{typ
e})
</insert>
<select
id=
"selectByName"
resultType=
"beans.Equipment"
>
select * from equipment where name=#{name}
</select>
<update
id=
"updateEquipment"
>
update equipment set price=#{price},name=#{name} where id=#{id}
update equipment set price=#{price},name=#{name}
,comment=#{comment},type=#{type}
where id=#{id}
</update>
<select
id=
"selectAll"
resultType=
"beans.Equipment"
>
select * from equipment
...
...
src/main/java/handlers/BudgetHandler.java
View file @
5661f8ab
...
...
@@ -475,12 +475,25 @@ public class BudgetHandler {
response
.
setStatus
(
444
);
return
;
}
if
(
curd
.
equals
(
2
))
//
增
改
if
(
curd
.
equals
(
2
))
//改
{
equipments
.
remove
(
equipment
);
Set
<
Equipment
>
keySet
=
equipments
.
keySet
();
//更新key
for
(
Equipment
item
:
keySet
)
{
if
(
item
.
equals
(
equipment
)){
item
.
setPrice
(
equipment
.
getPrice
());
}
}
//更新value
equipments
.
put
(
equipment
,
nums
);
}
else
}
else
if
(
curd
.
equals
(
0
))
equipments
.
put
(
equipment
,
nums
);
else
{
Equipment
add
=
equipmentDao
.
selectByName
(
equipment
.
getName
());
equipments
.
remove
(
add
);
equipments
.
put
(
add
,
nums
);
System
.
out
.
println
(
"add form database:"
+
add
.
getComment
());
}
}
serializeBudget
(
budget
,
getFilePath
(
sessionID
));
...
...
src/main/java/service/impl/CrawlerService.java
View file @
5661f8ab
...
...
@@ -53,6 +53,9 @@ public class CrawlerService implements ICrawlerService {
.
getElementsByClass
(
"rank__name"
).
first
()
.
getElementsByTag
(
"a"
).
first
()
.
text
().
trim
();
String
params
=
rankItem
.
getElementsByClass
(
"rank-list__cell cell-3"
).
first
()
.
getElementsByClass
(
"_j_pro_info_count"
).
first
()
.
getElementsByTag
(
"a"
).
get
(
1
).
attributes
().
get
(
"href"
).
trim
();
String
priceStr
=
rankItem
.
getElementsByClass
(
"rank-list__cell cell-4"
).
first
()
.
getElementsByClass
(
"rank__price"
).
first
()
.
text
().
trim
();
...
...
@@ -64,11 +67,16 @@ public class CrawlerService implements ICrawlerService {
priceStr
=
priceStr
.
substring
(
1
);
price
=
Double
.
valueOf
(
priceStr
);
}
Equipment
equipment
=
new
Equipment
();
equipment
.
setName
(
name
);
equipment
.
setPrice
(
price
);
equipments
.
add
(
equipment
);
index
++;
String
comment
=
getDescription
(
params
);
if
(
price
<
100000.0
)
{
Equipment
equipment
=
new
Equipment
();
equipment
.
setName
(
name
);
equipment
.
setPrice
(
price
);
equipment
.
setComment
(
comment
);
equipment
.
setType
(
"工作站"
);
equipments
.
add
(
equipment
);
index
++;
}
//爬取前十
if
(
index
>
10
)
break
;
...
...
@@ -90,4 +98,17 @@ public class CrawlerService implements ICrawlerService {
System
.
out
.
println
(
"爬取"
);
}
private
String
getDescription
(
String
params
)
{
String
url
=
"http:"
+
params
;
StringBuilder
builder
=
new
StringBuilder
();
try
{
Document
document
=
Jsoup
.
connect
(
url
).
get
();
Element
paramsList
=
document
.
getElementsByClass
(
"detailed-parameters"
).
first
();
builder
.
append
(
paramsList
.
text
().
trim
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
builder
.
toString
();
}
}
src/main/java/util/BudgetExportUtil.java
View file @
5661f8ab
...
...
@@ -51,7 +51,7 @@ public class BudgetExportUtil {
run
.
setText
(
line
.
toString
());
line
=
new
StringBuilder
();
line
.
append
(
"
用途
,"
)
line
.
append
(
"
【用途说明,例如“针对测试过程中产生的图形数据的存储和分析需要”】
,"
)
.
append
(
num
).
append
(
"台,主要配置如下:"
).
append
(
equipment
.
getComment
())
.
append
(
"。工作站单价约"
).
append
(
price
).
append
(
"元,共需"
).
append
(
num
*
price
).
append
(
"元。"
);
paragraph
=
document
.
createParagraph
();
...
...
@@ -136,7 +136,7 @@ public class BudgetExportUtil {
paragraph
=
document
.
createParagraph
();
run
=
paragraph
.
createRun
();
run
.
addTab
();
run
.
setText
(
"为顺利完成本课题实施方案中的工作内容,课题拟对
上海、南宁、桂林、北海等地相关单位进行调研和技术交流。具体考察调研单位包括:上海市交通委员会、广西省交通运输厅、桂林运营公司、钦州运营公司等
。"
);
run
.
setText
(
"为顺利完成本课题实施方案中的工作内容,课题拟对
【出差地点】等地相关单位进行调研和技术交流。具体考察调研单位包括:【上海市交通委员会、广西省交通运输厅、桂林运营公司、钦州运营公司等】
。"
);
paragraph
=
document
.
createParagraph
();
run
=
paragraph
.
createRun
();
...
...
@@ -213,6 +213,14 @@ public class BudgetExportUtil {
run
.
addTab
();
run
.
setText
(
line
.
toString
());
}
paragraph
=
document
.
createParagraph
();
run
=
paragraph
.
createRun
();
run
.
addTab
();
run
.
setText
(
"【会议任务举例】 牵头单位将组织和协调各课题组召开项目启动会,共同商讨各课题的具体目标、流程、关键节点及研究路线,"
+
"牵头单位每年组织和协调各课题组召开一次项目及课题中期检查会,检查各课题进度,讨论遇到的问题,内部研讨,寻找解决问题的方法,"
+
"为了做好项目的结题验收工作,牵头单位将组织各课题承担单位自查自纠,总结课题财务执行情况和撰写课题自评价报告,邀请专家进行项目预验收,"
+
"项目牵头单位将根据项目进度要求,按时完成项目结题验收工作,并组织召开项目结题验收;"
+
"在课题实施期间,要与相关领域其他学者进行研讨,预计受邀参加国内学术会议;"
);
//国际交流合作费
...
...
src/main/webapp/budgetDetail.jsp
View file @
5661f8ab
...
...
@@ -147,7 +147,7 @@
</td>
<td><input
type=
"number"
v-model=
"database[selectedIndex].nums"
class=
"form-control"
></td>
<td>
<button
class=
"btn btn-success"
@
click=
"add(database[selectedIndex])"
>
添加
</button>
<button
class=
"btn btn-success"
@
click=
"add
FromDatabase
(database[selectedIndex])"
>
添加
</button>
</td>
</tr>
</tbody>
...
...
@@ -610,6 +610,9 @@
add
:
function
(
item
)
{
this
.
doUpdate
(
item
,
0
);
},
addFromDatabase
:
function
(
item
)
{
this
.
doUpdate
(
item
,
3
);
},
showlist
:
function
()
{
this
.
$http
.
get
(
"${pageContext.request.contextPath}/Budget/Detail/Equipment"
).
then
(
function
(
data
)
{
...
...
src/main/webapp/budgetSetting.jsp
View file @
5661f8ab
...
...
@@ -200,7 +200,7 @@
<!-- Button -->
<div
title=
"所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可"
>
<button
class=
"btn btn-default btn-lg center-block"
type=
"submit"
>
生成预算
</button>
<button
class=
"btn btn-default btn-lg center-block"
type=
"submit"
>
保存修改
</button>
<p
class=
"help-block"
style=
"color:red"
>
所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可
</p>
</div>
</form>
...
...
src/main/webapp/usercenter.jsp
View file @
5661f8ab
...
...
@@ -58,6 +58,7 @@
<div>
<h1>
你好!
<label
id=
"username"
style=
"color:green;"
></label></h1>
<a
href=
"Crawler/Workstation"
>
爬取工作站数据
</a><br>
<button
class=
"btn btn-danger"
onclick=
"logout()"
>
退出登录
</button>
</div>
...
...
src/test/java/CrawlerTest.java
0 → 100644
View file @
5661f8ab
import
beans.Equipment
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
CrawlerTest
{
@Test
public
void
test01
()
{
String
url
=
"http://top.zol.com.cn/compositor/51/workstation.html"
;
List
<
Equipment
>
equipments
=
new
LinkedList
<>();
try
{
Document
document
=
Jsoup
.
connect
(
url
).
get
();
Elements
rankList
=
document
.
getElementsByClass
(
"rank-list"
).
first
().
getElementsByClass
(
"rank-list__item"
);
int
index
=
0
;
for
(
Element
rankItem
:
rankList
)
{
if
(
rankItem
.
className
().
equals
(
"rank-list__item clearfix"
))
{
String
name
=
rankItem
.
getElementsByClass
(
"rank-list__cell cell-3"
).
first
()
.
getElementsByClass
(
"rank__name"
).
first
()
.
getElementsByTag
(
"a"
).
first
()
.
text
().
trim
();
String
params
=
rankItem
.
getElementsByClass
(
"rank-list__cell cell-3"
).
first
()
.
getElementsByClass
(
"_j_pro_info_count"
).
first
()
.
getElementsByTag
(
"a"
).
get
(
1
).
attributes
().
get
(
"href"
).
trim
();
System
.
out
.
println
(
"params url: "
+
params
);
String
priceStr
=
rankItem
.
getElementsByClass
(
"rank-list__cell cell-4"
).
first
()
.
getElementsByClass
(
"rank__price"
).
first
()
.
text
().
trim
();
String
comment
=
getDescription
(
params
);
System
.
out
.
println
(
"description: "
+
comment
);
double
price
=
0
;
if
(
priceStr
.
endsWith
(
"万"
))
{
priceStr
=
priceStr
.
substring
(
1
,
priceStr
.
length
()
-
1
);
price
=
Double
.
valueOf
(
priceStr
)
*
10000.00
;
}
else
{
priceStr
=
priceStr
.
substring
(
1
);
price
=
Double
.
valueOf
(
priceStr
);
}
Equipment
equipment
=
new
Equipment
();
equipment
.
setName
(
name
);
equipment
.
setPrice
(
price
);
equipments
.
add
(
equipment
);
index
++;
//爬取前十
if
(
index
>
10
)
break
;
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"爬取"
);
}
private
String
getDescription
(
String
params
)
{
String
url
=
"http:"
+
params
;
StringBuilder
builder
=
new
StringBuilder
();
try
{
Document
document
=
Jsoup
.
connect
(
url
).
get
();
Element
paramsList
=
document
.
getElementsByClass
(
"detailed-parameters"
).
first
();
builder
.
append
(
paramsList
.
text
().
trim
());
/*builder.append("CPU型号:").append(paramsList.getElementById("newPmVal_2").text());
builder.append(",CPU数量:").append(paramsList.getElementById("newPmVal_5").text());
builder.append(",CPU核心:").append(paramsList.getElementById("newPmVal_10").text());
builder.append(";内存大小:").append(paramsList.getElementById("newPmVal_15").text());
builder.append(";显卡类型:").append(paramsList.getElementById("newPmVal_23").text());
builder.append(",显存容量:").append(paramsList.getElementById("newPmVal_24").text());
builder.append(";硬盘容量:").append(paramsList.getElementById("newPmVal_20").text());
builder.append(";硬盘描述:").append(paramsList.getElementById("newPmVal_21").text());*/
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
builder
.
toString
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment