Commit ba1544cc by shj

国际交流合作费的结构、生成、展示与修改,页面展示的优化

parent a7dc6914
......@@ -4,6 +4,61 @@ package beans;
* 国际交流合作费
*/
public class InternationalCommunication extends Item {
private double food;
private double accommodation;
private double traffic;
private int people;
private int days;
public double getFood() {
return food;
}
public void setFood(double food) {
this.food = food;
}
public double getAccommodation() {
return accommodation;
}
public void setAccommodation(double accommodation) {
this.accommodation = accommodation;
}
public double getTraffic() {
return traffic;
}
public void setTraffic(double traffic) {
this.traffic = traffic;
}
public int getPeople() {
return people;
}
public void setPeople(int people) {
this.people = people;
}
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
/**
* 人数*机票+人数*天数*(各种补贴)
* @return
*/
@Override
public double computeUnitPrice() {
return getPeople()*getPrice()+getPeople()*getDays()*(getFood()+getAccommodation()+getTraffic());
}
@Override
public String toString() {
return "InternationalCommunication{} " + super.toString();
......
package exception;
/**
* 预算数据不存在の错误
*/
public class BudgetNotExist extends Exception {
public BudgetNotExist() {
super();
}
public BudgetNotExist(String message) {
super(message);
}
}
......@@ -3,10 +3,14 @@ package service;
import beans.*;
public interface ICheckService {
boolean checkEquipment(Equipment equipment);
boolean checkMaterial(Material material);
final int isValid=0;
int checkEquipment(Equipment equipment);
int checkMaterial(Material material);
boolean checkTravel(Travel travel);
boolean checkIndirect(Indirect indirect);
boolean checkProperty(Property property);
String getMessage(int status);
}
......@@ -17,4 +17,8 @@ public interface IDetailService {
double sumConference(Map<Conference, Integer> conferences);
double sumConsultation(Map<Consultation, Integer> consultations);
double sumMaterial(Map<Material, Integer> materials);
double sumInternational(Map<InternationalCommunication, Integer> internationalCommunications);
}
......@@ -260,7 +260,16 @@ public class BudgetService implements IBudgetService {
@Override
public Map<InternationalCommunication, Integer> doInternationalCommunication(Double number) {
List<InternationalCommunication> internationalCommunications = internationalCommunicationDao.selectAll();
return generateMap((List) internationalCommunications, number);
Map<InternationalCommunication,Integer> result=new HashMap<>();
if(internationalCommunications==null || internationalCommunications.size()==0) return result;
InternationalCommunication internationalCommunication = internationalCommunications.get(0);
internationalCommunication.setDays(1);
internationalCommunication.setPeople(1);
while(internationalCommunication.computeUnitPrice()<number){
internationalCommunication.setDays(internationalCommunication.getDays()+1);
}
result.put(internationalCommunication,1);
return result;
}
/**
......
......@@ -3,18 +3,29 @@ package service.impl;
import beans.*;
import org.springframework.stereotype.Service;
import service.ICheckService;
@Service
public class CheckService implements ICheckService {
@Override
public boolean checkEquipment(Equipment equipment) {
if(equipment==null
|| equipment.getName()==null) return false;
return true;
public int checkEquipment(Equipment equipment) {
if (equipment == null || equipment.getName() == null) {
return 101;
}
if(equipment.computeUnitPrice()>=100000){
return 102;
}
return isValid;
}
@Override
public boolean checkMaterial(Material material) {
return true;
public int checkMaterial(Material material) {
if (material == null || material.getName() == null) {
return 201;
}
if (material.computeUnitPrice() >= 10000) {
return 202;
}
return isValid;
}
@Override
......@@ -31,4 +42,19 @@ public class CheckService implements ICheckService {
public boolean checkProperty(Property property) {
return true;
}
@Override
public String getMessage(int status) {
switch (status){
case 101:
return "不能为空";
case 102:
return "设备费需要小于100000";
case 201:
return "不能为空";
case 202:
return "材料费需要小于1000";
}
return "";
}
}
......@@ -61,4 +61,22 @@ public class DetailService implements IDetailService {
}
return sum;
}
@Override
public double sumMaterial(Map<Material, Integer> materials) {
double sum=0.0;
for (Material item : materials.keySet()) {
sum+=(item.computeUnitPrice()*materials.get(item));
}
return sum;
}
@Override
public double sumInternational(Map<InternationalCommunication, Integer> internationalCommunications) {
double sum=0.0;
for (InternationalCommunication item : internationalCommunications.keySet()) {
sum+=(item.computeUnitPrice()*internationalCommunications.get(item));
}
return sum;
}
}
<%--
Created by IntelliJ IDEA.
User: Song
Date: 2019/5/15
Time: 12:18
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>预算不存在</title>
</head>
<body>
<div>
<h1 class="center-block">预算文件不存在,3秒钟后跳转到首页</h1>
</div>
<script language=javascript>
setTimeout('window.location="${pageContext.request.contextPath}/"',3000)
</script>
</body>
</html>
......@@ -63,7 +63,7 @@
others = 0; %>
<iframe hidden id="hidden_frame" name="hidden_frame"></iframe>
<form class="form-horizontal" method="post" action="${pageContext.request.contextPath}/Budget/Generate" target="_blank">
<form class="form-horizontal" method="post" action="${pageContext.request.contextPath}/Budget/Generate">
<div class="form-group">
<label class="control-label col-sm-4">总预算(万元)</label>
......@@ -78,7 +78,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="equipment" checked>
<input name="items" type="checkbox" value="equipment" checked required>
设备费
</label>
<div class="col-sm-4">
......@@ -88,7 +88,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="material" checked>
<input name="items" type="checkbox" value="material" checked required>
材料费
</label>
<div class="col-sm-4">
......@@ -98,7 +98,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="test-and-process" checked>
<input name="items" type="checkbox" value="test-and-process" checked required>
测试化验加工费
</label>
<div class="col-sm-4">
......@@ -108,7 +108,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="power" checked>
<input name="items" type="checkbox" value="power" checked required>
燃料动力费
</label>
<div class="col-sm-4">
......@@ -118,7 +118,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="travel" checked>
<input name="items" type="checkbox" value="travel" checked required>
差旅费
</label>
<div class="col-sm-4">
......@@ -128,7 +128,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="conference" checked>
<input name="items" type="checkbox" value="conference" checked required>
会议费
</label>
<div class="col-sm-4" id="tip">
......@@ -138,7 +138,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="international-communication" checked>
<input name="items" type="checkbox" value="international-communication" checked required>
国际合作交流费
</label>
<div class="col-sm-4">
......@@ -148,7 +148,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="property" checked>
<input name="items" type="checkbox" value="property" checked required>
产权费
</label>
<div class="col-sm-4">
......@@ -157,7 +157,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="labour" checked>
<input name="items" type="checkbox" value="labour" checked required>
劳务费
</label>
<div class="col-sm-4">
......@@ -166,7 +166,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="consultation" checked>
<input name="items" type="checkbox" value="consultation" checked required>
咨询费
</label>
<div class="col-sm-4">
......@@ -175,7 +175,7 @@
<div class="form-group">
<label class="control-label col-sm-4">
<input name="items" type="checkbox" value="others" checked>
<input name="items" type="checkbox" value="others" checked required>
其他费用
</label>
<div class="col-sm-4">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment