Commit c929ff56 by shj

Vue真的超好用der

parent 96cd9b7c
...@@ -234,9 +234,9 @@ public class BudgetHandler { ...@@ -234,9 +234,9 @@ public class BudgetHandler {
@Autowired @Autowired
private ICheckService checkService; private ICheckService checkService;
@RequestMapping("/Modify/Equip") @RequestMapping("/Modify/Equipment")
public void modifyEquip(Integer mode, Equipment equipment, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) { public void modifyEquip(Integer mode, Equipment equipment, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) {
System.out.println("/Modify/Equip"); System.out.println("/Modify/Equipment");
if (nums < 0) return; if (nums < 0) return;
String sessionID = getSessionID(request.getCookies()); String sessionID = getSessionID(request.getCookies());
...@@ -252,56 +252,10 @@ public class BudgetHandler { ...@@ -252,56 +252,10 @@ public class BudgetHandler {
{ {
equipments.remove(equipment); equipments.remove(equipment);
equipments.put(equipment, nums); equipments.put(equipment, nums);
/*for (Equipment item : equipments.keySet()) {
if(item.equals(equipment))
{
item.setPrice(equipment.getPrice());
equipments.put(item,nums);
break;
}
}*/
} else } else
equipments.put(equipment, nums); equipments.put(equipment, nums);
serializeBudget(budget, getFilePath(sessionID)); serializeBudget(budget, getFilePath(sessionID));
/*if (mode.equals(0))//修改预算
{
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
assert budget != null;
Map<Equipment, Integer> items = budget.getEquipments();
Equipment mod=equipmentDao.selectById(id);
if(mod!=null)
items.put(mod,nums);
try {
double sum=0.0;
for (Equipment equipment : items.keySet()) {
sum+=(equipment.getPrice()*items.get(equipment));
}
response.getWriter().print(sum);
} catch (IOException e) {
e.printStackTrace();
}
serializeBudget(budget, getFilePath(sessionID));
} else//修改规则
{
Equipment equipment = new Equipment();
equipment.setId(id);
equipment.setName(name);
equipment.setPrice(price);
if (curd.equals(0))//增
{
equipmentDao.insertEquipment(equipment);
} else if (curd.equals(1))//删
{
equipmentDao.deleteEquipment(equipment);
} else//改
{
equipmentDao.updateEquipment(equipment);
}
}*/
} }
...@@ -455,23 +409,6 @@ public class BudgetHandler { ...@@ -455,23 +409,6 @@ public class BudgetHandler {
items.put(property,nums); items.put(property,nums);
} }
serializeBudget(budget, getFilePath(sessionID)); serializeBudget(budget, getFilePath(sessionID));
/*} *//*else//修改规则
{
Property item = new Property();
item.setId(id);
item.setName(name);
item.setPrice(price);
if (curd.equals(0))//增
{
propertyDao.insertProperty(item);
} else if (curd.equals(1))//删
{
propertyDao.deleteProperty(item);
} else//改
{
propertyDao.updateProperty(item);
}
}*/
} }
...@@ -682,22 +619,7 @@ public class BudgetHandler { ...@@ -682,22 +619,7 @@ public class BudgetHandler {
items.remove(travel); items.remove(travel);
items.put(travel, pair); items.put(travel, pair);
} }
serializeBudget(budget, getFilePath(sessionID)); serializeBudget(budget, getFilePath(sessionID));
/*else//修改规则
{
if (curd.equals(0))//增
{
travelDao.insertTravel(travel);
} else if (curd.equals(1))//删
{
travelDao.deleteTravel(travel);
} else//改
{
travelDao.updateTravel(travel);
}
}*/
} }
......
...@@ -83,6 +83,15 @@ public class DetailHandler { ...@@ -83,6 +83,15 @@ public class DetailHandler {
object.put("travel",sub); object.put("travel",sub);
req_sofar+=req;sum_sofar+=sum; req_sofar+=req;sum_sofar+=sum;
sub=new JSONObject();
req=budget.getRequirement().getLabour();
sum=detailService.sumLabour(budget.getLabour());
sub.put("req",req);
sub.put("sum",sum);
sub.put("diff",req-sum);
object.put("labour",sub);
req_sofar+=req;sum_sofar+=sum;
object.put("req",req_sofar); object.put("req",req_sofar);
object.put("sum",sum_sofar); object.put("sum",sum_sofar);
object.put("diff",req_sofar-sum_sofar); object.put("diff",req_sofar-sum_sofar);
...@@ -113,7 +122,7 @@ public class DetailHandler { ...@@ -113,7 +122,7 @@ public class DetailHandler {
obj.put("nums",equipments.get(item)); obj.put("nums",equipments.get(item));
list.add(obj); list.add(obj);
} }
object.put("equipments",list); object.put("data",list);
writer.write(JSON.toJSONString(object)); writer.write(JSON.toJSONString(object));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -144,7 +153,7 @@ public class DetailHandler { ...@@ -144,7 +153,7 @@ public class DetailHandler {
obj.put("days",travels.get(item).getDays()); obj.put("days",travels.get(item).getDays());
list.add(obj); list.add(obj);
} }
object.put("travels",list); object.put("data",list);
writer.write(JSON.toJSONString(object)); writer.write(JSON.toJSONString(object));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
package service; package service;
import beans.Equipment; import beans.Equipment;
import beans.Labour;
import beans.Pair; import beans.Pair;
import beans.Travel; import beans.Travel;
...@@ -11,4 +12,6 @@ public interface IDetailService { ...@@ -11,4 +12,6 @@ public interface IDetailService {
double sumEquipment(Map<Equipment, Integer> equipments); double sumEquipment(Map<Equipment, Integer> equipments);
double sumTravel(Map<Travel, Pair> travels); double sumTravel(Map<Travel, Pair> travels);
double sumLabour(Map<Labour, Integer> labour);
} }
package service.impl; package service.impl;
import beans.Equipment; import beans.Equipment;
import beans.Labour;
import beans.Pair; import beans.Pair;
import beans.Travel; import beans.Travel;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -27,4 +28,13 @@ public class DetailService implements IDetailService { ...@@ -27,4 +28,13 @@ public class DetailService implements IDetailService {
} }
return sum; return sum;
} }
@Override
public double sumLabour(Map<Labour, Integer> labours) {
double sum=0.0;
for (Labour labour : labours.keySet()) {
sum+=(labour.getPrice()*labours.get(labour));
}
return sum;
}
} }
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