Commit 65a1aeaf by shj

导航栏修改,测试化验加工费展示与修改,添加数据库查询接口,前端展示数据库列表(具体某项费用的),保证展示的数据库列表中已经删除了存在与该项预算费用的条目,因此不会出现条目冲突

parent 7c4b42bb
......@@ -409,6 +409,36 @@ public class BudgetHandler {
}
@RequestMapping("/Modify/TestAndProcess")
public void modifyTestAndProcess(Integer mode, TestAndProcess testAndProcess, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("/Modify/TestAndProcess");
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
if (budget == null) {
response.sendError(444, "budget not exists");
return;
}
Map<TestAndProcess, Integer> items = null;
items = budget.getTestAndProcesses();
//删除
if (curd.equals(1)) {
items.remove(testAndProcess);
} else {
if (curd.equals(2))//增改
{
items.remove(testAndProcess);
items.put(testAndProcess, nums);
} else
items.put(testAndProcess, nums);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
}
@Autowired
private IInternationalCommunicationDao internationalCommunicationDao;
......
package handlers;
import beans.Budget;
import beans.Consultation;
import beans.Equipment;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import dao.IConsultationDao;
import dao.IEquipmentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/Database/Query")
public class DatabaseQueryHandler {
@Autowired
private IEquipmentDao equipmentDao;
@RequestMapping("/Equipment")
public void queryEquipment(HttpServletRequest request, HttpServletResponse response){
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
JSONObject object=new JSONObject();
List<Equipment> equipments = equipmentDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Equipment item : equipments) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",0);
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@Autowired
private IConsultationDao consultationDao;
@RequestMapping("/Consultation")
public void queryConsultation(HttpServletRequest request, HttpServletResponse response){
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
JSONObject object=new JSONObject();
List<Consultation> consultations = consultationDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Consultation item : consultations) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",0);
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -95,6 +95,16 @@ public class DetailHandler {
object.put("material",sub);
req_sofar+=req;sum_sofar+=sum;
//测试化验加工费
sub=new JSONObject();
req=budget.getRequirement().getTest();
sum=detailService.sumTestAndProcess(budget.getTestAndProcesses());
sub.put("req",req);
sub.put("sum",sum);
sub.put("diff",req-sum);
object.put("testAndProcess",sub);
req_sofar+=req;sum_sofar+=sum;
//差旅费
sub=new JSONObject();
req=budget.getRequirement().getTravel();
......@@ -229,6 +239,38 @@ public class DetailHandler {
}
}
@RequestMapping("/TestAndProcess")
public void detailTest(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);
if(budget==null) {
response.getWriter().write("equipment list error");
response.sendError(444,"budget not exists");
return;
}
Map<TestAndProcess, Integer> testAndProcesses = budget.getTestAndProcesses();
List<JSONObject> list=new LinkedList<>();
for (TestAndProcess item : testAndProcesses.keySet()) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",testAndProcesses.get(item));
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/International")
public void detailInternational(HttpServletRequest request, HttpServletResponse response)
{
......
......@@ -21,4 +21,6 @@ public interface IDetailService {
double sumMaterial(Map<Material, Integer> materials);
double sumInternational(Map<InternationalCommunication, Integer> internationalCommunications);
double sumTestAndProcess(Map<TestAndProcess, Integer> testAndProcesses);
}
......@@ -79,4 +79,13 @@ public class DetailService implements IDetailService {
}
return sum;
}
@Override
public double sumTestAndProcess(Map<TestAndProcess, Integer> testAndProcesses) {
double sum=0.0;
for (TestAndProcess item : testAndProcesses.keySet()) {
sum+=(item.computeUnitPrice()*testAndProcesses.get(item));
}
return sum;
}
}
......@@ -45,7 +45,7 @@
<ul class="nav navbar-nav">
<li><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li class="active"><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
......
......@@ -36,7 +36,7 @@
<ul class="nav navbar-nav">
<li class="active"><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
......
......@@ -46,7 +46,7 @@
<ul class="nav navbar-nav">
<li><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%>
<li class="active"><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
......
......@@ -47,7 +47,7 @@
<ul class="nav navbar-nav">
<li><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>
<li class="active"><a href="${pageContext.request.contextPath}/Test">测试</a></li>
......@@ -101,6 +101,26 @@ ${pageContext.request.contextPath}<br>
<button class="btn btn-danger" onclick="logout()">退出登录</button>
<div id="forTest">
<select v-model="selectedIndex">
<option v-for="(item,index) in items" :value="index">{{item.name}}</option>
</select>
<td><input type="text" v-model="items[selectedIndex].name"></td>
<td><input type="text" v-model="items[selectedIndex].age"></td>
</div>
<script type="text/javascript">
var vueTest=new Vue({
el:"#forTest",
data:{
items:[{ name : 'zhangsan', age : 24, tel : 110 },
{ name : 'lisi', age : 20, tel: 120 },
{ name : 'wangwu', age : 21, tel : 119 }],
text:"111",
selectedIndex:0
}
});
</script>
<script type="text/javascript">
function logout() {
if(confirm("确认退出登录?")){
......
......@@ -45,7 +45,7 @@
<ul class="nav navbar-nav">
<li><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
......
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