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
cd8efb02
Commit
cd8efb02
authored
Apr 24, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
咨询费的输入、生成、展示和修改完成;下一步:国际交流合作费的生成、展示和修改
parent
4cdc16f1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
210 additions
and
79 deletions
+210
-79
BudgetHandler.java
src/main/java/handlers/BudgetHandler.java
+20
-36
DetailHandler.java
src/main/java/handlers/DetailHandler.java
+36
-0
IDetailService.java
src/main/java/service/IDetailService.java
+2
-0
BudgetService.java
src/main/java/service/impl/BudgetService.java
+31
-7
DetailService.java
src/main/java/service/impl/DetailService.java
+9
-0
budgetDetail.jsp
src/main/webapp/budgetDetail.jsp
+85
-26
index.jsp
src/main/webapp/index.jsp
+9
-10
test.jsp
src/main/webapp/test.jsp
+18
-0
No files found.
src/main/java/handlers/BudgetHandler.java
View file @
cd8efb02
...
...
@@ -86,8 +86,9 @@ public class BudgetHandler {
}
else
if
(
item
.
contains
(
"labour"
))
{
budget
.
setLabour
(
budgetService
.
doLabour
(
number
));
budget
.
getRequirement
().
setLabour
(
number
);
}
else
if
(
item
.
contains
(
"consul
a
tation"
))
{
}
else
if
(
item
.
contains
(
"consultation"
))
{
budget
.
setConsultations
(
budgetService
.
doConsultation
(
number
));
budget
.
getRequirement
().
setConsultation
(
number
);
}
else
if
(
item
.
contains
(
"others"
))
{
budget
.
setOthers
(
budgetService
.
doOthers
(
number
));
budget
.
getRequirement
().
setOthers
(
number
);
...
...
@@ -455,7 +456,6 @@ public class BudgetHandler {
private
IConferenceDao
conferenceDao
;
/**
*
* @param mode
* @param conference
* @param nums
...
...
@@ -467,7 +467,7 @@ public class BudgetHandler {
public
void
modifyConference
(
Integer
mode
,
Conference
conference
,
Integer
nums
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
System
.
out
.
println
(
"/Modify/Conference"
);
if
(
nums
<
0
)
return
;
if
(
nums
<
0
)
return
;
String
sessionID
=
getSessionID
(
request
.
getCookies
());
Budget
budget
=
retrieveBudget
(
sessionID
);
...
...
@@ -503,44 +503,28 @@ public class BudgetHandler {
* @param response
*/
@RequestMapping
(
"/Modify/Consultation"
)
public
void
modifyConsultation
(
Integer
mode
,
Integer
id
,
String
name
,
Double
price
,
Integer
nums
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
modifyConsultation
(
Integer
mode
,
Consultation
consultation
,
Integer
nums
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
System
.
out
.
println
(
"/Modify/Consultation"
);
if
(
mode
.
equals
(
0
))
//修改预算
{
//咨询费的预算不需要单独更改
/*if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
if
(
nums
<
0
)
return
;
String
sessionID
=
getSessionID
(
request
.
getCookies
());
Budget
budget
=
retrieveBudget
(
sessionID
);
assert budget != null;
assert
budget
!=
null
;
Map<Consultation, Integer> items = null;
items = budget.getConsultations();
for (Consultation item : items.keySet()) {
if (item.getId().equals(id)) {
items.put(item, nums);
break;
}
}
serializeBudget(budget, getFilePath(sessionID));*/
}
else
//修改规则
{
Consultation
item
=
new
Consultation
();
item
.
setId
(
id
);
item
.
setName
(
name
);
item
.
setPrice
(
price
);
if
(
curd
.
equals
(
0
))
//增
{
consultationDao
.
insertConsultation
(
item
);
}
else
if
(
curd
.
equals
(
1
))
//删
{
consultationDao
.
deleteConsultation
(
item
);
}
else
//改
{
consultationDao
.
updateConsultation
(
item
);
}
Map
<
Consultation
,
Integer
>
items
=
null
;
items
=
budget
.
getConsultations
();
if
(
curd
.
equals
(
0
))
{
items
.
put
(
consultation
,
nums
);
}
else
if
(
curd
.
equals
(
1
))
{
items
.
remove
(
consultation
);
}
else
{
items
.
remove
(
consultation
);
items
.
put
(
consultation
,
nums
);
}
afterUpdate
(
budget
);
serializeBudget
(
budget
,
getFilePath
(
sessionID
));
}
...
...
src/main/java/handlers/DetailHandler.java
View file @
cd8efb02
...
...
@@ -116,6 +116,16 @@ public class DetailHandler {
object
.
put
(
"labour"
,
sub
);
req_sofar
+=
req
;
sum_sofar
+=
sum
;
//咨询费
sub
=
new
JSONObject
();
req
=
budget
.
getRequirement
().
getConsultation
();
sum
=
detailService
.
sumConsultation
(
budget
.
getConsultations
());
sub
.
put
(
"req"
,
req
);
sub
.
put
(
"sum"
,
sum
);
sub
.
put
(
"diff"
,
req
-
sum
);
object
.
put
(
"consultation"
,
sub
);
req_sofar
+=
req
;
sum_sofar
+=
sum
;
object
.
put
(
"req"
,
req_sofar
);
object
.
put
(
"sum"
,
sum_sofar
);
object
.
put
(
"diff"
,
req_sofar
-
sum_sofar
);
...
...
@@ -296,4 +306,30 @@ public class DetailHandler {
e
.
printStackTrace
();
}
}
@RequestMapping
(
"/Consultation"
)
public
void
consultationDetail
(
HttpServletRequest
request
,
HttpServletResponse
response
){
try
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/html;charset=utf-8"
);
PrintWriter
writer
=
response
.
getWriter
();
JSONObject
object
=
new
JSONObject
();
String
sessionID
=
BudgetHandler
.
getSessionID
(
request
.
getCookies
());
Budget
budget
=
BudgetHandler
.
retrieveBudget
(
sessionID
);
Map
<
Consultation
,
Integer
>
consultationIntegerMap
=
budget
.
getConsultations
();
List
<
JSONObject
>
list
=
new
LinkedList
<>();
for
(
Consultation
item
:
consultationIntegerMap
.
keySet
())
{
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"id"
,
item
.
getId
());
obj
.
put
(
"name"
,
item
.
getName
());
obj
.
put
(
"price"
,
item
.
getPrice
());
obj
.
put
(
"nums"
,
consultationIntegerMap
.
get
(
item
));
list
.
add
(
obj
);
}
object
.
put
(
"data"
,
list
);
writer
.
write
(
JSON
.
toJSONString
(
object
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/service/IDetailService.java
View file @
cd8efb02
...
...
@@ -15,4 +15,6 @@ public interface IDetailService {
double
sumProperty
(
Map
<
Property
,
Integer
>
properties
);
double
sumConference
(
Map
<
Conference
,
Integer
>
conferences
);
double
sumConsultation
(
Map
<
Consultation
,
Integer
>
consultations
);
}
src/main/java/service/impl/BudgetService.java
View file @
cd8efb02
...
...
@@ -242,8 +242,8 @@ public class BudgetService implements IBudgetService {
}
while
(
sum
<
number
)
{
for
(
Conference
conference
:
map
.
keySet
())
{
int
i
=
map
.
get
(
conference
);
map
.
put
(
conference
,++
i
);
int
i
=
map
.
get
(
conference
);
map
.
put
(
conference
,
++
i
);
sum
+=
conference
.
computeUnitPrice
();
if
(
sum
>=
number
)
return
map
;
}
...
...
@@ -284,15 +284,15 @@ public class BudgetService implements IBudgetService {
@Override
public
Map
<
Labour
,
Integer
>
doLabour
(
Double
number
)
{
List
<
Labour
>
list
=
labourDao
.
selectAll
();
Map
<
Labour
,
Integer
>
result
=
new
HashMap
<>();
Map
<
Labour
,
Integer
>
result
=
new
HashMap
<>();
try
{
Labour
labour
=
list
.
get
(
0
);
labour
.
setPeople
(
1
);
labour
.
setMonths
(
1
);
while
(
labour
.
computeUnitPrice
()<
number
)
{
labour
.
setMonths
(
labour
.
getMonths
()
+
1
);
while
(
labour
.
computeUnitPrice
()
<
number
)
{
labour
.
setMonths
(
labour
.
getMonths
()
+
1
);
}
result
.
put
(
labour
,
1
);
result
.
put
(
labour
,
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -308,7 +308,31 @@ public class BudgetService implements IBudgetService {
@Override
public
Map
<
Consultation
,
Integer
>
doConsultation
(
Double
number
)
{
List
<
Consultation
>
consultations
=
consultationDao
.
selectAll
();
return
generateMap
((
List
)
consultations
,
number
);
Map
<
Consultation
,
Integer
>
result
=
new
HashMap
<>();
if
(
consultations
==
null
||
consultations
.
size
()==
0
)
return
result
;
try
{
Consultation
consultation
=
null
;
//取一个价格非0的元素,避免死循环
for
(
Consultation
item
:
consultations
)
{
if
(
item
.
getPrice
()
>
0
)
{
consultation
=
item
;
break
;
}
}
if
(
consultation
==
null
)
return
result
;
result
.
put
(
consultation
,
0
);
double
sum
=
0.0
;
while
(
sum
<
number
){
int
i
=
result
.
get
(
consultation
);
result
.
put
(
consultation
,++
i
);
sum
+=
consultation
.
getPrice
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
/**
...
...
src/main/java/service/impl/DetailService.java
View file @
cd8efb02
...
...
@@ -52,4 +52,13 @@ public class DetailService implements IDetailService {
}
return
sum
;
}
@Override
public
double
sumConsultation
(
Map
<
Consultation
,
Integer
>
consultations
)
{
double
sum
=
0.0
;
for
(
Consultation
item
:
consultations
.
keySet
())
{
sum
+=(
item
.
computeUnitPrice
()*
consultations
.
get
(
item
));
}
return
sum
;
}
}
src/main/webapp/budgetDetail.jsp
View file @
cd8efb02
...
...
@@ -84,7 +84,7 @@
<li><a
href=
"#international"
data-toggle=
"tab"
>
国际交流合作费
</a></li>
<li><a
href=
"#property"
data-toggle=
"tab"
onclick=
"propertyVue.showlist()"
>
出版/文献/信息传播/知识产权事务费
</a></li>
<li><a
href=
"#labour"
data-toggle=
"tab"
onclick=
"labourVue.showlist()"
>
劳务费
</a></li>
<li><a
href=
"#consultation"
data-toggle=
"tab"
>
咨询费
</a></li>
<li><a
href=
"#consultation"
data-toggle=
"tab"
onclick=
"consultationVue.showlist()"
>
咨询费
</a></li>
<li><a
href=
"#others"
data-toggle=
"tab"
>
其他费用
</a></li>
<li><a
href=
"#indirect"
data-toggle=
"tab"
onclick=
"indirectVue.showlist()"
>
间接费用
</a></li>
...
...
@@ -217,13 +217,13 @@
<tbody
id=
"travel-table"
>
<tr
v-for=
"item in items"
v-bind:title=
"item.name"
>
<td><input
type=
"text"
readonly
v-model=
"item.name"
></td>
<td><input
type=
"number"
v-model=
"item.price"
></td>
<td><input
type=
"number"
v-model=
"item.food"
></td>
<td><input
type=
"number"
v-model=
"item.traffic"
></td>
<td><input
type=
"number"
v-model=
"item.accommodation"
></td>
<td><input
type=
"number"
v-model=
"item.people"
></td>
<td><input
type=
"number"
v-model=
"item.days"
></td>
<td><input
type=
"text"
readonly
v-model=
"item.name"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.price"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.food"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.traffic"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.accommodation"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.people"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.days"
class=
"form-control"
></td>
<td>
<button
class=
"btn btn-success"
@
click=
"update(item)"
>
确认
</button>
<button
class=
"btn btn-danger"
@
click=
"del(item)"
>
删除
</button>
...
...
@@ -231,13 +231,13 @@
</tr>
<tr
class=
"success"
>
<td><input
type=
"text"
v-model=
"sample.name"
></td>
<td><input
type=
"number"
v-model=
"sample.price"
></td>
<td><input
type=
"number"
v-model=
"sample.food"
></td>
<td><input
type=
"number"
v-model=
"sample.traffic"
></td>
<td><input
type=
"number"
v-model=
"sample.accommodation"
></td>
<td><input
type=
"number"
v-model=
"sample.people"
></td>
<td><input
type=
"number"
v-model=
"sample.days"
></td>
<td><input
type=
"text"
v-model=
"sample.name"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.price"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.food"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.traffic"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.accommodation"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.people"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"sample.days"
class=
"form-control"
></td>
<td>
<button
class=
"btn btn-success"
@
click=
"add(sample)"
>
添加
</button>
</td>
...
...
@@ -264,7 +264,7 @@
<tbody>
<tr
v-for=
"item in items"
v-bind:title=
"item.name"
>
<td><input
type=
"text"
readonly
v-model=
"item.name"
></td>
<td><input
type=
"text"
readonly
v-model=
"item.name"
class=
"form-control"
></td>
<
%
--
<
td
>
<select
class=
"form-control"
v-model=
"item.expertType"
>
<option
disabled
value=
""
>
请选择其中一项
</option>
...
...
@@ -274,10 +274,10 @@
</select>
</td>
<td><input
type=
"number"
v-model=
"item.experts"
></td>
--%>
<td><input
type=
"number"
v-model=
"item.price"
></td>
<td><input
type=
"number"
v-model=
"item.people"
></td>
<td><input
type=
"number"
v-model=
"item.days"
></td>
<td><input
type=
"number"
v-model=
"item.nums"
></td>
<td><input
type=
"number"
v-model=
"item.price"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.people"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.days"
class=
"form-control"
></td>
<td><input
type=
"number"
v-model=
"item.nums"
class=
"form-control"
></td>
<td>
<button
class=
"btn btn-success"
@
click=
"update(item)"
>
确认
</button>
<button
class=
"btn btn-danger"
@
click=
"del(item)"
>
删除
</button>
...
...
@@ -373,18 +373,31 @@
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
编号
</th>
<th
hidden
>
编号
</th>
<th>
人员类型
</th>
<th>
费用标准
</th>
<th>
人数
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<tr
v-for=
"item in items"
v-bind:title=
"item.name"
>
<td><input
type=
"text"
readonly
v-model=
"item.name"
class=
"form-control"
></td>
<
%
--
<
td
><input
type=
"number"
v-model=
"item.price"
></td>
--%>
<td>
<select
class=
"form-control"
v-model=
"item.price"
>
<option
v-for=
"n in 2800"
v-if=
"n%100==0"
>
{{n}}
</option>
</select>
</td>
<td><input
type=
"number"
v-model=
"item.nums"
class=
"form-control"
></td>
<td>
<button
class=
"btn btn-success"
@
click=
"update(item)"
>
确认
</button>
<button
class=
"btn btn-danger"
@
click=
"del(item)"
>
删除
</button>
</td>
</tr>
</tbody>
</table>
<p
class=
"help-block"
>
此项由会议费决定,不可单独更改
</p>
</div>
<div
class=
"tab-pane fade"
id=
"others"
>
...
...
@@ -611,7 +624,7 @@
el
:
"#conference"
,
data
:
{
items
:
[],
sample
:
{
name
:
"sample"
,
expertType
:
"专家"
,
experts
:
0
,
price
:
0
,
people
:
0
,
days
:
0
,
nums
:
0
}
sample
:
{
name
:
"sample"
,
expertType
:
"专家"
,
experts
:
0
,
price
:
0
,
people
:
0
,
days
:
0
,
nums
:
0
}
},
methods
:
{
update
:
function
(
item
)
{
...
...
@@ -638,8 +651,8 @@
this
.
$http
.
post
(
"${pageContext.request.contextPath}/Budget/Modify/Conference"
,
{
name
:
item
.
name
,
expertType
:
item
.
expertType
,
experts
:
item
.
experts
,
expertType
:
item
.
expertType
,
experts
:
item
.
experts
,
price
:
item
.
price
,
people
:
item
.
people
,
days
:
item
.
days
,
...
...
@@ -705,6 +718,52 @@
});
var
consultationVue
=
new
Vue
({
el
:
"#consultation"
,
data
:
{
items
:
[],
sample
:
{
name
:
"sample"
,
price
:
0
,
nums
:
0
}
},
methods
:
{
update
:
function
(
item
)
{
this
.
doUpdate
(
item
,
2
);
},
del
:
function
(
item
)
{
this
.
doUpdate
(
item
,
1
);
},
add
:
function
(
item
)
{
this
.
doUpdate
(
item
,
0
);
},
showlist
:
function
()
{
this
.
$http
.
get
(
"${pageContext.request.contextPath}/Budget/Detail/Consultation"
).
then
(
function
(
data
)
{
this
.
items
=
data
.
body
.
data
;
console
.
log
(
"showlist"
);
updateBudgetPage
(
"consultation"
)
},
function
(
error
)
{
console
.
log
(
error
)
}
)
},
doUpdate
:
function
(
item
,
curd
)
{
this
.
$http
.
post
(
"${pageContext.request.contextPath}/Budget/Modify/Consultation"
,
{
name
:
item
.
name
,
price
:
item
.
price
,
nums
:
item
.
nums
,
curd
:
curd
},
{
emulateJSON
:
true
}
).
then
(
function
(
value
)
{
this
.
showlist
();
});
}
},
created
:
function
()
{
}
});
/**
* 更新差值
* @param type 当前预算种类
...
...
src/main/webapp/index.jsp
View file @
cd8efb02
...
...
@@ -63,6 +63,7 @@
international =
6,
property =
8,
labour =
66,
consultation =
2,
others =
0;
%
>
...
...
@@ -136,7 +137,6 @@
</label>
<div
class=
"col-sm-4"
id=
"tip"
>
<input
name=
"conference-number"
class=
"form-control"
type=
"number"
value=
<%=conference%
>
>
(系统计算相应的咨询费)
</div>
</div>
...
...
@@ -168,15 +168,14 @@
<input
name=
"labour-number"
class=
"form-control"
type=
"number"
value=
"<%=labour%>"
></div>
</div>
<
%
--
<
div
class=
"checkbox"
>
<span
class=
"add-on"
>
<label
class=
"checkbox"
>
咨询费
<input
name=
"items"
type=
"checkbox"
value=
"consultation"
>
</label>
</span>
<input
name=
"consultation-number"
class=
"form-control"
type=
"number"
value=
"0"
>
</div>
--%>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-4"
>
<input
name=
"items"
type=
"checkbox"
value=
"consultation"
checked
>
咨询费
</label>
<div
class=
"col-sm-4"
>
<input
name=
"consultation-number"
class=
"form-control"
type=
"number"
value=
"<%=consultation%>"
></div>
</div>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-4"
>
...
...
src/main/webapp/test.jsp
View file @
cd8efb02
...
...
@@ -32,6 +32,9 @@
}
</style>
<script
src=
"https://cdn.staticfile.org/angular.js/1.6.3/angular.min.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/vue/dist/vue.js"
></script>
<script
src=
"https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"
></script>
</head>
<body>
...
...
@@ -87,6 +90,13 @@ ${pageContext.request.contextPath}<br>
</table>
</div>
<div
id=
"VueTest"
>
<select
v-model=
"num"
>
<option
v-for=
"n in 2800"
v-if=
"n%100==0"
>
{{n}}
</option>
</select>
<p>
{{num}}
</p>
</div>
<script
type=
"text/javascript"
>
angular
.
module
(
'myApp'
,
[]).
controller
(
'ctrl'
,
function
(
$scope
,
$http
)
{
...
...
@@ -122,6 +132,14 @@ ${pageContext.request.contextPath}<br>
document
.
getElementById
(
"xxx"
).
style
.
color
=
colors
[
i
%
colors
.
length
];
i
++
;
}
var
vueTest
=
new
Vue
({
el
:
"#VueTest"
,
data
:{
list
:[
1
,
2
,
3
,
4
,
5
],
num
:
500
}
});
</script>
</body>
</html>
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