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
7c4b42bb
Commit
7c4b42bb
authored
May 15, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
差旅费结构、显示、增删改优化
parent
43b56536
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
74 additions
and
71 deletions
+74
-71
Budget.java
src/main/java/beans/Budget.java
+5
-4
Travel.java
src/main/java/beans/Travel.java
+16
-21
BudgetHandler.java
src/main/java/handlers/BudgetHandler.java
+28
-25
DetailHandler.java
src/main/java/handlers/DetailHandler.java
+4
-3
IBudgetService.java
src/main/java/service/IBudgetService.java
+1
-1
IDetailService.java
src/main/java/service/IDetailService.java
+1
-1
BudgetService.java
src/main/java/service/impl/BudgetService.java
+10
-9
DetailService.java
src/main/java/service/impl/DetailService.java
+2
-2
budgetDetail.jsp
src/main/webapp/budgetDetail.jsp
+5
-2
index.jsp
src/main/webapp/index.jsp
+2
-1
JsonTest.java
src/test/java/JsonTest.java
+0
-2
No files found.
src/main/java/beans/Budget.java
View file @
7c4b42bb
...
...
@@ -14,7 +14,8 @@ public class Budget implements Serializable {
private
Map
<
Material
,
Integer
>
materials
;
private
Map
<
TestAndProcess
,
Integer
>
testAndProcesses
;
private
Map
<
Power
,
Integer
>
powers
;
private
Map
<
Travel
,
Pair
>
travels
;
//private Map<Travel, Pair> travels;
private
Map
<
Travel
,
Integer
>
travels
;
//private Map<Conference, Pair> conferences;
private
Map
<
Conference
,
Integer
>
conferences
;
private
Map
<
InternationalCommunication
,
Integer
>
internationalCommunications
;
...
...
@@ -81,11 +82,11 @@ public class Budget implements Serializable {
this
.
powers
=
powers
;
}
public
Map
<
Travel
,
Pai
r
>
getTravels
()
{
public
Map
<
Travel
,
Intege
r
>
getTravels
()
{
return
travels
;
}
public
void
setTravels
(
Map
<
Travel
,
Pai
r
>
travels
)
{
public
void
setTravels
(
Map
<
Travel
,
Intege
r
>
travels
)
{
this
.
travels
=
travels
;
}
...
...
@@ -171,7 +172,7 @@ public class Budget implements Serializable {
}
if
(
travels
!=
null
)
for
(
Travel
travel
:
travels
.
keySet
())
{
direct
+=
travel
.
co
st
(
travels
.
get
(
travel
)
);
direct
+=
travel
.
co
mputeUnitPrice
()*
travels
.
get
(
travel
);
}
if
(
conferences
!=
null
)
for
(
Conference
conference
:
conferences
.
keySet
())
{
...
...
src/main/java/beans/Travel.java
View file @
7c4b42bb
...
...
@@ -7,37 +7,26 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
public
class
Travel
extends
Item
{
@JSONField
(
name
=
"dest"
)
private
String
dest
;
@JSONField
(
name
=
"food"
)
private
double
food
;
@JSONField
(
name
=
"traffic"
)
private
double
traffic
;
@JSONField
(
name
=
"accommodation"
)
private
double
accommodation
;
private
int
people
;
private
int
days
;
@Override
public
double
computeUnitPrice
()
{
return
getPrice
()
+
getFood
()
+
getAccommodation
()
+
getTraffic
();
public
int
getPeople
()
{
return
people
;
}
@Override
public
String
toString
()
{
return
"Travel{"
+
"dest='"
+
dest
+
'\''
+
", food="
+
food
+
", traffic="
+
traffic
+
", accommodation="
+
accommodation
+
"} "
+
super
.
toString
();
public
void
setPeople
(
int
people
)
{
this
.
people
=
people
;
}
public
String
getDest
()
{
return
getName
()
;
public
int
getDays
()
{
return
days
;
}
public
void
setD
est
(
String
dest
)
{
setName
(
dest
)
;
public
void
setD
ays
(
int
days
)
{
this
.
days
=
days
;
}
public
double
getFood
()
{
...
...
@@ -70,6 +59,7 @@ public class Travel extends Item {
* @param pair
* @return
*/
@Deprecated
public
double
cost
(
Pair
pair
)
{
if
(
pair
==
null
||
pair
.
getPeople
()<=
0
||
pair
.
getDays
()<=
0
)
return
0.0
;
return
pair
.
getPeople
()
*
...
...
@@ -77,4 +67,9 @@ public class Travel extends Item {
+
(
getTraffic
()
+
getFood
())
*
pair
.
getDays
()
+
getAccommodation
()
*
(
pair
.
getDays
()
-
1
));
}
@Override
public
double
computeUnitPrice
()
{
return
getPeople
()*(
getPrice
()
+
(
getTraffic
()+
getFood
())*
getDays
()
+
getAccommodation
()*(
getDays
()-
1
));
}
}
src/main/java/handlers/BudgetHandler.java
View file @
7c4b42bb
...
...
@@ -413,16 +413,15 @@ public class BudgetHandler {
private
IInternationalCommunicationDao
internationalCommunicationDao
;
/**
* 修改预算中的国际交流合作费
、规则中的国际交流合作费
* 修改预算中的国际交流合作费
*
* @param mode
* @param id
* @param name
* @param price
* @param internationalCommunication
* @param nums
* @param curd
* @param request
* @param response
* @throws IOException
*/
@RequestMapping
(
"/Modify/International"
)
public
void
modifyInternational
(
Integer
mode
,
InternationalCommunication
internationalCommunication
,
Integer
nums
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
...
...
@@ -629,10 +628,10 @@ public class BudgetHandler {
* @param response
*/
@RequestMapping
(
"/Modify/Travel"
)
public
void
modifyTravel
(
Integer
mode
,
Travel
travel
,
Pair
pair
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
void
modifyTravel
(
Integer
mode
,
Travel
travel
,
Integer
nums
,
Integer
curd
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
System
.
out
.
println
(
"/Modify/Travel"
);
if
(
pair
==
null
||
pair
.
getDays
()
<
0
||
pair
.
getPeople
()
<
0
)
return
;
if
(
nums
<
0
)
return
;
String
sessionID
=
getSessionID
(
request
.
getCookies
());
Budget
budget
=
retrieveBudget
(
sessionID
);
...
...
@@ -641,15 +640,15 @@ public class BudgetHandler {
return
;
}
Map
<
Travel
,
Pai
r
>
items
=
budget
.
getTravels
();
Map
<
Travel
,
Intege
r
>
items
=
budget
.
getTravels
();
checkService
.
checkTravel
(
travel
);
if
(
curd
.
equals
(
0
))
{
items
.
put
(
travel
,
pair
);
items
.
put
(
travel
,
nums
);
}
else
if
(
curd
.
equals
(
1
))
{
items
.
remove
(
travel
);
}
else
{
items
.
remove
(
travel
);
items
.
put
(
travel
,
pair
);
items
.
put
(
travel
,
nums
);
}
afterUpdate
(
budget
);
serializeBudget
(
budget
,
getFilePath
(
sessionID
));
...
...
@@ -801,19 +800,20 @@ public class BudgetHandler {
}
writer
.
newLine
();
writer
.
write
(
"差旅费,目的地,往返价格,伙食费,交通费,住宿费,人数,天数,小计"
);
writer
.
write
(
"差旅费,目的地,往返价格,伙食费,交通费,住宿费,人数,天数,
次数,
小计"
);
writer
.
newLine
();
Map
<
Travel
,
Pai
r
>
travels
=
budget
.
getTravels
();
Map
<
Travel
,
Intege
r
>
travels
=
budget
.
getTravels
();
for
(
Item
item
:
travels
.
keySet
())
{
if
(
item
instanceof
Travel
)
{
writer
.
write
(
comma
+
((
Travel
)
item
).
get
Dest
()
writer
.
write
(
comma
+
((
Travel
)
item
).
get
Name
()
+
comma
+
item
.
getPrice
()
+
comma
+
((
Travel
)
item
).
getFood
()
+
comma
+
((
Travel
)
item
).
getTraffic
()
+
comma
+
((
Travel
)
item
).
getAccommodation
()
+
comma
+
travels
.
get
(
item
).
getPeople
()
+
comma
+
travels
.
get
(
item
).
getDays
()
+
comma
+
((
Travel
)
item
).
cost
(
travels
.
get
(
item
)));
+
comma
+
((
Travel
)
item
).
getPeople
()
+
comma
+
((
Travel
)
item
).
getDays
()
+
comma
+
travels
.
get
(
item
)
+
comma
+
item
.
computeUnitPrice
()
*
travels
.
get
(
item
));
writer
.
newLine
();
}
}
...
...
@@ -835,17 +835,20 @@ public class BudgetHandler {
}
writer
.
newLine
();
writer
.
write
(
"国际合作交流费,会议内容,
费用标准,会议
次数,小计"
);
writer
.
write
(
"国际合作交流费,会议内容,
市际交通(往返交通),住宿补贴,伙食补贴,公杂费,人数,天数,
次数,小计"
);
writer
.
newLine
();
items
=
(
Map
)
budget
.
getInternationalCommunications
();
for
(
Item
item
:
items
.
keySet
())
{
if
(
item
instanceof
InternationalCommunication
)
{
writer
.
write
(
comma
+
item
.
getName
()
+
comma
+
item
.
getPrice
()
+
comma
+
items
.
get
(
item
)
+
comma
+
item
.
computeUnitPrice
()
*
items
.
get
(
item
));
writer
.
newLine
();
}
Map
<
InternationalCommunication
,
Integer
>
internationalCommunications
=
budget
.
getInternationalCommunications
();
for
(
InternationalCommunication
item
:
internationalCommunications
.
keySet
())
{
writer
.
write
(
comma
+
item
.
getName
()
+
comma
+
item
.
getPrice
()
+
comma
+
item
.
getAccommodation
()
+
comma
+
item
.
getFood
()
+
comma
+
item
.
getTraffic
()
+
comma
+
item
.
getPeople
()
+
comma
+
item
.
getDays
()
+
comma
+
items
.
get
(
item
)
+
comma
+
item
.
computeUnitPrice
()
*
internationalCommunications
.
get
(
item
));
writer
.
newLine
();
}
writer
.
newLine
();
...
...
src/main/java/handlers/DetailHandler.java
View file @
7c4b42bb
...
...
@@ -281,7 +281,7 @@ public class DetailHandler {
response
.
sendError
(
444
,
"budget not exists"
);
return
;
}
Map
<
Travel
,
Pai
r
>
travels
=
budget
.
getTravels
();
Map
<
Travel
,
Intege
r
>
travels
=
budget
.
getTravels
();
List
<
JSONObject
>
list
=
new
LinkedList
<>();
for
(
Travel
item
:
travels
.
keySet
())
{
JSONObject
obj
=
new
JSONObject
();
...
...
@@ -291,8 +291,9 @@ public class DetailHandler {
obj
.
put
(
"food"
,
item
.
getFood
());
obj
.
put
(
"traffic"
,
item
.
getTraffic
());
obj
.
put
(
"accommodation"
,
item
.
getAccommodation
());
obj
.
put
(
"people"
,
travels
.
get
(
item
).
getPeople
());
obj
.
put
(
"days"
,
travels
.
get
(
item
).
getDays
());
obj
.
put
(
"people"
,
item
.
getPeople
());
obj
.
put
(
"days"
,
item
.
getDays
());
obj
.
put
(
"nums"
,
travels
.
get
(
item
));
list
.
add
(
obj
);
}
object
.
put
(
"data"
,
list
);
...
...
src/main/java/service/IBudgetService.java
View file @
7c4b42bb
...
...
@@ -15,7 +15,7 @@ public interface IBudgetService {
Map
<
Power
,
Integer
>
doPower
(
Double
number
);
Map
<
Travel
,
Pai
r
>
doTravel
(
Double
number
);
Map
<
Travel
,
Intege
r
>
doTravel
(
Double
number
);
//Map<Conference, Pair> doConference(Double number);
Map
<
Conference
,
Integer
>
doConference
(
Double
number
);
...
...
src/main/java/service/IDetailService.java
View file @
7c4b42bb
...
...
@@ -8,7 +8,7 @@ public interface IDetailService {
double
sumEquipment
(
Map
<
Equipment
,
Integer
>
equipments
);
double
sumTravel
(
Map
<
Travel
,
Pai
r
>
travels
);
double
sumTravel
(
Map
<
Travel
,
Intege
r
>
travels
);
double
sumLabour
(
Map
<
Labour
,
Integer
>
labour
);
...
...
src/main/java/service/impl/BudgetService.java
View file @
7c4b42bb
...
...
@@ -187,24 +187,25 @@ public class BudgetService implements IBudgetService {
* @return
*/
@Override
public
Map
<
Travel
,
Pai
r
>
doTravel
(
Double
number
)
{
Map
<
Travel
,
Pai
r
>
result
=
new
HashMap
<>();
public
Map
<
Travel
,
Intege
r
>
doTravel
(
Double
number
)
{
Map
<
Travel
,
Intege
r
>
result
=
new
HashMap
<>();
List
<
Travel
>
travels
=
travelDao
.
selectAll
();
if
(
travels
!=
null
&&
travels
.
size
()
!=
0
)
{
double
sofar
=
0.0
;
for
(
Travel
travel
:
travels
)
{
travel
.
setPeople
(
1
);
travel
.
setDays
(
1
);
if
(
sofar
<
number
)
{
Pair
pair
=
new
Pair
(
1
,
1
);
result
.
put
(
travel
,
pair
);
sofar
+=
travel
.
cost
(
pair
);
result
.
put
(
travel
,
1
);
sofar
+=
travel
.
computeUnitPrice
();
}
}
while
(
sofar
<
number
)
{
for
(
Travel
travel
:
result
.
keySet
())
{
Pair
pair
=
result
.
get
(
travel
);
double
oldCost
=
travel
.
co
st
(
pair
);
pair
.
setDays
(
pair
.
getDays
()
+
1
);
double
newCost
=
travel
.
co
st
(
pair
);
int
days
=
travel
.
getDays
(
);
double
oldCost
=
travel
.
co
mputeUnitPrice
(
);
travel
.
setDays
(
days
+
1
);
double
newCost
=
travel
.
co
mputeUnitPrice
(
);
sofar
+=
(
newCost
-
oldCost
);
//System.out.println("oldCost:" + oldCost);
//System.out.println("newCost:" + newCost);
...
...
src/main/java/service/impl/DetailService.java
View file @
7c4b42bb
...
...
@@ -18,10 +18,10 @@ public class DetailService implements IDetailService {
}
@Override
public
double
sumTravel
(
Map
<
Travel
,
Pai
r
>
travels
)
{
public
double
sumTravel
(
Map
<
Travel
,
Intege
r
>
travels
)
{
double
sum
=
0.0
;
for
(
Travel
travel
:
travels
.
keySet
())
{
sum
+=
travel
.
co
st
(
travels
.
get
(
travel
)
);
sum
+=
travel
.
co
mputeUnitPrice
()*
travels
.
get
(
travel
);
}
return
sum
;
}
...
...
src/main/webapp/budgetDetail.jsp
View file @
7c4b42bb
...
...
@@ -223,6 +223,7 @@
<th>
住宿补助
</th>
<th>
人数
</th>
<th>
天数
</th>
<th>
次数
</th>
<th>
操作
</th>
</tr>
</thead>
...
...
@@ -236,6 +237,7 @@
<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><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>
...
...
@@ -305,7 +307,7 @@
<p
class=
"help-block"
><b>
市际
</b>
交通:指代往返价格、会议注册费等一次性费用
</p>
<p
class=
"help-block"
><b>
市内
</b>
交通:指代一切公杂费
</p>
</div>
<table
class=
"table table-hover"
>
<table
class=
"table table-hover
text-nowrap
"
>
<thead>
<tr>
<th>
名称
</th>
...
...
@@ -380,7 +382,7 @@
</td>
</tr>
<tr
class=
"success"
>
<td><input
type=
"text"
readonly
v-model=
"sample.name"
class=
"form-control"
></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.nums"
class=
"form-control"
></td>
<td>
...
...
@@ -736,6 +738,7 @@
traffic
:
item
.
traffic
,
days
:
item
.
days
,
people
:
item
.
people
,
nums
:
item
.
nums
,
curd
:
curd
},
{
emulateJSON
:
true
}
...
...
src/main/webapp/index.jsp
View file @
7c4b42bb
...
...
@@ -183,8 +183,9 @@
</div>
<!-- Button -->
<div>
<div
title=
"所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可"
>
<button
class=
"btn btn-default btn-lg center-block"
type=
"submit"
>
生成预算
</button>
<p
class=
"help-block"
style=
"color:red"
>
所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可
</p>
</div>
</form>
...
...
src/test/java/JsonTest.java
View file @
7c4b42bb
...
...
@@ -21,11 +21,9 @@ public class JsonTest {
{
Map
<
Travel
,
Pair
>
map
=
new
HashMap
<>();
map
.
put
(
new
Travel
(){{
setDest
(
"xxx"
);
setPrice
(
100
);
setFood
(
10
);
setTraffic
(
50
);
setAccommodation
(
80
);
}},
new
Pair
(
1
,
1
));
map
.
put
(
new
Travel
(){{
setDest
(
"yyy"
);
setPrice
(
200
);
setFood
(
20
);
setTraffic
(
90
);
setAccommodation
(
99
);
}},
new
Pair
(
1
,
2
));
for
(
Map
.
Entry
<
Travel
,
Pair
>
travelPairEntry
:
map
.
entrySet
())
{
...
...
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