Commit 56ecbbe6 by shj

劳务费增删改,专职人员五险一金计算

parent b45184a0
...@@ -4,8 +4,19 @@ package beans; ...@@ -4,8 +4,19 @@ package beans;
* 会议费 * 会议费
*/ */
public class Conference extends Item { public class Conference extends Item {
@Deprecated
private int experts; private int experts;
private int people; private int people;
private int days;
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public int getPeople() { public int getPeople() {
return people; return people;
...@@ -25,7 +36,7 @@ public class Conference extends Item { ...@@ -25,7 +36,7 @@ public class Conference extends Item {
@Override @Override
public double computeUnitPrice() { public double computeUnitPrice() {
return getPrice()*getPeople(); return getPrice()*getPeople()*getDays();
} }
@Override @Override
...@@ -33,9 +44,12 @@ public class Conference extends Item { ...@@ -33,9 +44,12 @@ public class Conference extends Item {
return "Conference{" + return "Conference{" +
"experts=" + experts + "experts=" + experts +
", people=" + people + ", people=" + people +
", days=" + days +
"} " + super.toString(); "} " + super.toString();
} }
public double cost(Pair pair,Consultation consultation)
@Deprecated
public double cost(Pair pair, Consultation consultation)
{ {
if(pair==null || pair.getDays()<=0 || pair.getPeople()<=0 || (consultation==null&&getExperts()!=0)) if(pair==null || pair.getDays()<=0 || pair.getPeople()<=0 || (consultation==null&&getExperts()!=0))
return 0.0; return 0.0;
......
package beans; package beans;
import util.SalaryCalculator;
/** /**
* 劳务费 * 劳务费
*/ */
public class Labour extends Item{ public class Labour extends Item{
private int priority; private int priority;
private int people;
private int months;
public int getPeople() {
return people;
}
public void setPeople(int people) {
this.people = people;
}
public int getMonths() {
return months;
}
public void setMonths(int months) {
this.months = months;
}
@Override @Override
public String toString() { public String toString() {
return "Labour{" + return "Labour{" +
"priority=" + priority + "priority=" + priority +
", people=" + people +
", months=" + months +
"} " + super.toString(); "} " + super.toString();
} }
...@@ -20,4 +42,15 @@ public class Labour extends Item{ ...@@ -20,4 +42,15 @@ public class Labour extends Item{
public void setPriority(int priority) { public void setPriority(int priority) {
this.priority = priority; this.priority = priority;
} }
@Override
public double computeUnitPrice() {
double base=0;
if(getName().equals("专职")){
base = SalaryCalculator.getOrgCost(getPrice());
}
else
base=getPrice();
return base*getPeople()*getMonths();
}
} }
...@@ -376,8 +376,8 @@ public class BudgetHandler { ...@@ -376,8 +376,8 @@ public class BudgetHandler {
@Autowired @Autowired
private IPropertyDao propertyDao; private IPropertyDao propertyDao;
/** /**
*
* @param mode * @param mode
* @param property * @param property
* @param nums * @param nums
...@@ -391,25 +391,25 @@ public class BudgetHandler { ...@@ -391,25 +391,25 @@ public class BudgetHandler {
/*if (mode.equals(0))//修改预算 /*if (mode.equals(0))//修改预算
{*/ {*/
if (nums < 0) return; if (nums < 0) return;
String sessionID = getSessionID(request.getCookies()); String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID); Budget budget = retrieveBudget(sessionID);
assert budget != null; assert budget != null;
Map<Property, Integer> items = null; Map<Property, Integer> items = null;
items = budget.getProperties(); items = budget.getProperties();
if(!checkService.checkProperty(property)) return; if (!checkService.checkProperty(property)) return;
if(curd.equals(0)){ if (curd.equals(0)) {
items.put(property,nums); items.put(property, nums);
}else if(curd.equals(1)){ } else if (curd.equals(1)) {
items.remove(property); items.remove(property);
}else{ } else {
items.remove(property); items.remove(property);
items.put(property,nums); items.put(property, nums);
} }
afterUpdate(budget); afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID)); serializeBudget(budget, getFilePath(sessionID));
} }
...@@ -418,51 +418,35 @@ public class BudgetHandler { ...@@ -418,51 +418,35 @@ public class BudgetHandler {
/** /**
* 修改预算中的劳务费、规则中的劳务费 * 修改预算中的劳务费、规则中的劳务费
*
* @param mode * @param mode
* @param id * @param labour
* @param name
* @param price
* @param nums * @param nums
* @param curd * @param curd
* @param request * @param request
* @param response * @param response
*/ */
@RequestMapping("/Modify/Labour") @RequestMapping("/Modify/Labour")
public void modifyLabour(Integer mode, Integer id, String name, Double price, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) { public void modifyLabour(Integer mode, Labour labour, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) {
System.out.println("/Modify/Labour"); System.out.println("/Modify/Labour");
if (mode.equals(0))//修改预算 if (nums < 0) return;
{ String sessionID = getSessionID(request.getCookies());
if (nums < 0) return; Budget budget = retrieveBudget(sessionID);
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
assert budget != null; assert budget != null;
Map<Labour, Integer> items = null; Map<Labour, Integer> items = null;
items = budget.getLabour(); items = budget.getLabour();
Labour mod = labourDao.selectById(id); if (curd.equals(0)) {
if (mod != null) items.put(labour, nums);
items.put(mod, nums); } else if (curd.equals(1)) {
serializeBudget(budget, getFilePath(sessionID)); items.remove(labour);
} else//修改规则 } else {
{ items.remove(labour);
Labour item = new Labour(); items.put(labour, nums);
item.setId(id);
item.setName(name);
item.setPrice(price);
if (curd.equals(0))//增
{
labourDao.insertLabour(item);
} else if (curd.equals(1))//删
{
labourDao.deleteLabour(item);
} else//改
{
labourDao.updateLabour(item);
}
} }
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
} }
...@@ -627,9 +611,10 @@ public class BudgetHandler { ...@@ -627,9 +611,10 @@ public class BudgetHandler {
/** /**
* 预算修改的善后工作 * 预算修改的善后工作
*
* @param budget * @param budget
*/ */
private void afterUpdate(Budget budget){ private void afterUpdate(Budget budget) {
budget.setIndirects(budget.computeIndirect()); budget.setIndirects(budget.computeIndirect());
} }
...@@ -830,7 +815,7 @@ public class BudgetHandler { ...@@ -830,7 +815,7 @@ public class BudgetHandler {
} }
writer.newLine(); writer.newLine();
writer.write("劳务费,费用名称,费用标准,数量,小计"); writer.write("劳务费,费用名称,费用标准,数量,小计(五险一金)");
writer.newLine(); writer.newLine();
items = (Map) budget.getLabour(); items = (Map) budget.getLabour();
for (Item item : items.keySet()) { for (Item item : items.keySet()) {
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import service.IDetailService; import service.IDetailService;
import util.SalaryCalculator;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -105,6 +106,16 @@ public class DetailHandler { ...@@ -105,6 +106,16 @@ public class DetailHandler {
object.put("property",sub); object.put("property",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);
...@@ -255,4 +266,33 @@ public class DetailHandler { ...@@ -255,4 +266,33 @@ public class DetailHandler {
e.printStackTrace(); e.printStackTrace();
} }
} }
@RequestMapping("/Labour")
public void labourDetail(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<Labour, Integer> labourIntegerMap = budget.getLabour();
List<JSONObject> list=new LinkedList<>();
for (Labour item : labourIntegerMap.keySet()) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("tax", item.computeUnitPrice()/(item.getMonths()*item.getPeople()));
obj.put("people",item.getPeople());
obj.put("months",item.getMonths());
obj.put("nums",labourIntegerMap.get(item));
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
} }
...@@ -119,28 +119,27 @@ public class BudgetService implements IBudgetService { ...@@ -119,28 +119,27 @@ public class BudgetService implements IBudgetService {
*/ */
@Override @Override
public Map<Equipment, Integer> doEquipment(Double number) { public Map<Equipment, Integer> doEquipment(Double number) {
Map<Equipment,Integer> map=new HashMap<>(); Map<Equipment, Integer> map = new HashMap<>();
List<Equipment> equipments = equipmentDao.selectAll(); List<Equipment> equipments = equipmentDao.selectAll();
if(equipments!=null && equipments.size()>0) { if (equipments != null && equipments.size() > 0) {
Collections.sort(equipments,new Comparator<Equipment>() { Collections.sort(equipments, new Comparator<Equipment>() {
@Override @Override
public int compare(Equipment o1, Equipment o2) { public int compare(Equipment o1, Equipment o2) {
double diff=o1.getPrice()-o2.getPrice(); double diff = o1.getPrice() - o2.getPrice();
return (int)diff; return (int) diff;
} }
}); });
for (Equipment equipment : equipments) { for (Equipment equipment : equipments) {
map.put(equipment,0); map.put(equipment, 0);
} }
Equipment equipment = equipments.get(0); Equipment equipment = equipments.get(0);
double sum=0.0; double sum = 0.0;
int i=0; int i = 0;
while(sum<number) while (sum < number) {
{ sum += equipment.getPrice();
sum+=equipment.getPrice();
i++; i++;
} }
map.put(equipment,i); map.put(equipment, i);
} }
return map; return map;
} }
...@@ -189,31 +188,28 @@ public class BudgetService implements IBudgetService { ...@@ -189,31 +188,28 @@ public class BudgetService implements IBudgetService {
*/ */
@Override @Override
public Map<Travel, Pair> doTravel(Double number) { public Map<Travel, Pair> doTravel(Double number) {
Map<Travel,Pair> result=new HashMap<>(); Map<Travel, Pair> result = new HashMap<>();
List<Travel> travels = travelDao.selectAll(); List<Travel> travels = travelDao.selectAll();
if(travels!=null && travels.size()!=0) if (travels != null && travels.size() != 0) {
{ double sofar = 0.0;
double sofar=0.0;
for (Travel travel : travels) { for (Travel travel : travels) {
if(sofar<number) if (sofar < number) {
{ Pair pair = new Pair(1, 1);
Pair pair=new Pair(1,1); result.put(travel, pair);
result.put(travel,pair); sofar += travel.cost(pair);
sofar+=travel.cost(pair);
} }
} }
while (sofar<number) while (sofar < number) {
{
for (Travel travel : result.keySet()) { for (Travel travel : result.keySet()) {
Pair pair=result.get(travel); Pair pair = result.get(travel);
double oldCost=travel.cost(pair); double oldCost = travel.cost(pair);
pair.setDays(pair.getDays()+1); pair.setDays(pair.getDays() + 1);
double newCost=travel.cost(pair); double newCost = travel.cost(pair);
sofar+=(newCost-oldCost); sofar += (newCost - oldCost);
System.out.println("oldCost:"+oldCost); System.out.println("oldCost:" + oldCost);
System.out.println("newCost:"+newCost); System.out.println("newCost:" + newCost);
System.out.println("sofar:"+sofar); System.out.println("sofar:" + sofar);
if(sofar>=number) { if (sofar >= number) {
System.out.println(result); System.out.println(result);
return result; return result;
} }
...@@ -224,6 +220,7 @@ public class BudgetService implements IBudgetService { ...@@ -224,6 +220,7 @@ public class BudgetService implements IBudgetService {
} }
/////////////////////////////////////////////////////////待解决 /////////////////////////////////////////////////////////待解决
/** /**
* 合成会议费 * 合成会议费
* *
...@@ -232,35 +229,32 @@ public class BudgetService implements IBudgetService { ...@@ -232,35 +229,32 @@ public class BudgetService implements IBudgetService {
*/ */
@Override @Override
public Map<Conference, Pair> doConference(Double number) { public Map<Conference, Pair> doConference(Double number) {
Map<Conference,Pair> map=new HashMap<>(); Map<Conference, Pair> map = new HashMap<>();
List<Conference> conferences = conferenceDao.selectAll(); List<Conference> conferences = conferenceDao.selectAll();
List<Consultation> consultations = consultationDao.selectAll(); List<Consultation> consultations = consultationDao.selectAll();
Consultation consultation=null; Consultation consultation = null;
if(consultations!=null && consultations.size()>0) if (consultations != null && consultations.size() > 0) {
{
for (Consultation item : consultations) { for (Consultation item : consultations) {
consultation=item; consultation = item;
break; break;
} }
} }
double sum=0.0; double sum = 0.0;
for (Conference conference : conferences) { for (Conference conference : conferences) {
if(sum<number) if (sum < number) {
{
Pair value = new Pair(1, 1); Pair value = new Pair(1, 1);
map.put(conference,value); map.put(conference, value);
sum+=conference.cost(value,consultation); sum += conference.cost(value, consultation);
} }
} }
while (sum<number) while (sum < number) {
{
for (Conference conference : map.keySet()) { for (Conference conference : map.keySet()) {
Pair pair = map.get(conference); Pair pair = map.get(conference);
double oldCost=conference.cost(pair,consultation); double oldCost = conference.cost(pair, consultation);
pair.setPeople(pair.getPeople()+1); pair.setPeople(pair.getPeople() + 1);
double newCost=conference.cost(pair,consultation); double newCost = conference.cost(pair, consultation);
sum+=(newCost-oldCost); sum += (newCost - oldCost);
if(sum>=number) return map; if (sum >= number) return map;
} }
} }
return map; return map;
...@@ -298,8 +292,20 @@ public class BudgetService implements IBudgetService { ...@@ -298,8 +292,20 @@ public class BudgetService implements IBudgetService {
*/ */
@Override @Override
public Map<Labour, Integer> doLabour(Double number) { public Map<Labour, Integer> doLabour(Double number) {
List<Labour> labour = labourDao.selectAll(); List<Labour> list = labourDao.selectAll();
return generateMap((List) labour, number); 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);
}
result.put(labour,1);
} catch (Exception e) {
e.printStackTrace();
}
return result;
} }
/** /**
...@@ -342,11 +348,10 @@ public class BudgetService implements IBudgetService { ...@@ -342,11 +348,10 @@ public class BudgetService implements IBudgetService {
@Override @Override
public Map<Consultation, Integer> doConsultation(int n) { public Map<Consultation, Integer> doConsultation(int n) {
List<Consultation> consultations = consultationDao.selectAll(); List<Consultation> consultations = consultationDao.selectAll();
Map<Consultation,Integer> map=new HashMap<>(); Map<Consultation, Integer> map = new HashMap<>();
if(consultations!=null && consultations.size()>0) if (consultations != null && consultations.size() > 0) {
{
Consultation consultation = consultations.get(0); Consultation consultation = consultations.get(0);
map.put(consultation,n); map.put(consultation, n);
} }
return map; return map;
} }
......
...@@ -30,7 +30,7 @@ public class DetailService implements IDetailService { ...@@ -30,7 +30,7 @@ public class DetailService implements IDetailService {
public double sumLabour(Map<Labour, Integer> labours) { public double sumLabour(Map<Labour, Integer> labours) {
double sum=0.0; double sum=0.0;
for (Labour labour : labours.keySet()) { for (Labour labour : labours.keySet()) {
sum+=(labour.getPrice()*labours.get(labour)); sum+=(labour.computeUnitPrice()*labours.get(labour));
} }
return sum; return sum;
} }
......
package util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
/**
* 五险一金计算器(简易版)
* 没有考虑社保汇缴基数和公积金汇缴基数的变动,两者均采用税前工资
*/
public class SalaryCalculator {
private static double yanglao=0.19;
private static double yiliao=0.10;
private static double shiye=0.008;
private static double gongjijin=0.12;
private static double gongshang=0.004;
private static double shengyu=0.008;
/**
* 根据税前工资,计算用人成本
* @param preTaxSalary
* @return
*/
public static double getOrgCost(double preTaxSalary){
return preTaxSalary+getWuxianyijin(preTaxSalary);
}
/**
* 根据税前工资,计算企业应缴纳的五险一金
* @param preTaxSalary
* @return
*/
public static double getWuxianyijin(double preTaxSalary){
double shebaoBase=getShebaoBase(preTaxSalary);
double gongjijinBase=getGongjijinBase(preTaxSalary);
return shebaoBase*getShebaoPercentage()+gongjijinBase*getGongjijinPercentage();
}
private static double getGongjijinPercentage() {
return gongjijin;
}
private static double getShebaoPercentage() {
return yanglao+yiliao+shiye+gongshang+shengyu;
}
private static double getGongjijinBase(double preTaxSalary) {
return (preTaxSalary>25401)?25401:((preTaxSalary<2273)?2273:preTaxSalary);
}
private static double getShebaoBase(double preTaxSalary) {
return (preTaxSalary>25401)?25401:((preTaxSalary<5080)?5080:preTaxSalary);
}
private static double getAllPercentage() {
return yanglao+yiliao+shiye+gongjijin+gongshang+shengyu;
}
public static double getYanglao() {
return yanglao;
}
public static void setYanglao(double yanglao) {
SalaryCalculator.yanglao = yanglao;
}
public static double getYiliao() {
return yiliao;
}
public static void setYiliao(double yiliao) {
SalaryCalculator.yiliao = yiliao;
}
public static double getShiye() {
return shiye;
}
public static void setShiye(double shiye) {
SalaryCalculator.shiye = shiye;
}
public static double getGongjijin() {
return gongjijin;
}
public static void setGongjijin(double gongjijin) {
SalaryCalculator.gongjijin = gongjijin;
}
public static double getGongshang() {
return gongshang;
}
public static void setGongshang(double gongshang) {
SalaryCalculator.gongshang = gongshang;
}
public static double getShengyu() {
return shengyu;
}
public static void setShengyu(double shengyu) {
SalaryCalculator.shengyu = shengyu;
}
}
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<li><a href="#conference" data-toggle="tab" onclick="conferenceVue.showlist()">会议费(包含咨询费)</a></li> <li><a href="#conference" data-toggle="tab" onclick="conferenceVue.showlist()">会议费(包含咨询费)</a></li>
<li><a href="#international" data-toggle="tab">国际交流合作费</a></li> <li><a href="#international" data-toggle="tab">国际交流合作费</a></li>
<li><a href="#property" data-toggle="tab" onclick="propertyVue.showlist()">出版/文献/信息传播/知识产权事务费</a></li> <li><a href="#property" data-toggle="tab" onclick="propertyVue.showlist()">出版/文献/信息传播/知识产权事务费</a></li>
<li><a href="#labour" data-toggle="tab">劳务费</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">咨询费</a></li>
<li><a href="#others" data-toggle="tab">其他费用</a></li> <li><a href="#others" data-toggle="tab">其他费用</a></li>
<li><a href="#indirect" data-toggle="tab" onclick="indirectVue.showlist()">间接费用</a></li> <li><a href="#indirect" data-toggle="tab" onclick="indirectVue.showlist()">间接费用</a></li>
...@@ -252,10 +252,11 @@ ...@@ -252,10 +252,11 @@
<tr> <tr>
<th hidden>编号</th> <th hidden>编号</th>
<th>名称</th> <th>名称</th>
<th>专家类型</th> <th hidden>专家类型</th>
<th>需要专家人数</th> <th hidden>需要专家人数</th>
<th>单价</th> <th>单价</th>
<th>参会人数</th> <th>参会人数</th>
<th>天数</th>
<th>会议次数</th> <th>会议次数</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
...@@ -264,7 +265,7 @@ ...@@ -264,7 +265,7 @@
<tbody> <tbody>
<tr v-for="item in items" v-bind:title="item.name"> <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"></td>
<td> <%--<td>
<select class="form-control" v-model="item.expertType"> <select class="form-control" v-model="item.expertType">
<option disabled value="">请选择其中一项</option> <option disabled value="">请选择其中一项</option>
<option>专家</option> <option>专家</option>
...@@ -272,10 +273,11 @@ ...@@ -272,10 +273,11 @@
<option>C</option> <option>C</option>
</select> </select>
</td> </td>
<td><input type="number" v-model="item.experts"></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.price"></td>
<td><input type="number" v-model="item.people"></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.days"></td>
<td><input type="number" v-model="item.nums"></td>
<td> <td>
<button class="btn btn-success" @click="update(item)">确认</button> <button class="btn btn-success" @click="update(item)">确认</button>
<button class="btn btn-danger" @click="del(item)">删除</button> <button class="btn btn-danger" @click="del(item)">删除</button>
...@@ -343,15 +345,25 @@ ...@@ -343,15 +345,25 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>编号</th> <th hidden>编号</th>
<th>名称</th> <th>类型</th>
<th>单价</th> <th>劳务费(每人每月)</th>
<th>数量</th> <th></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <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="number" v-model="item.price">五险一金:{{item.tax}}</td>
<td><input type="number" v-model="item.people"></td>
<td><input type="number" v-model="item.months"></td>
<td>
<button class="btn btn-success" @click="update(item)">确认</button>
<button class="btn btn-danger" @click="del(item)">删除</button>
</td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -644,6 +656,53 @@ ...@@ -644,6 +656,53 @@
}); });
var labourVue = new Vue({
el: "#labour",
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/Labour").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("labour")
}, function (error) {
console.log(error)
}
)
},
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Labour",
{
name: item.name,
price: item.price,
people: item.people,
months: item.months,
nums: item.nums,
curd: curd
},
{emulateJSON: true}
).then(function (value) {
this.showlist();
});
}
},
created: function () {
}
});
/** /**
* 更新差值 * 更新差值
......
import org.junit.Test;
import util.SalaryCalculator;
import java.util.ArrayList;
public class GongjijinTest {
@Test
public void gongjijinTest(){
ArrayList<Double> list=new ArrayList<Double>();
for(int i=1;i<10;i++)
list.add((double)(i*1000));
for (Double salary : list) {
System.out.println(SalaryCalculator.getOrgCost(salary));
}
System.out.println(SalaryCalculator.getOrgCost(100000));
}
}
...@@ -4,6 +4,14 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.junit.Test; import org.junit.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -25,4 +33,36 @@ public class JsonTest { ...@@ -25,4 +33,36 @@ public class JsonTest {
} }
System.out.println(JSON.toJSONString(map.entrySet())); System.out.println(JSON.toJSONString(map.entrySet()));
} }
@Test
public void urlTest(){
URLConnection urlConnection=null;
BufferedReader bufferedReader=null;
try {
URL url=new URL("http://salarycalculator.sinaapp.com/calculate?city=beijing&origin_salary=8000&base_3j=8000&base_gjj=8000&is_gjj=true&is_exgjj=false&factor_exgjj=0.08");
urlConnection = url.openConnection();
urlConnection.connect();
bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), StandardCharsets.UTF_8));
StringBuilder builder=new StringBuilder();
String line=null;
while((line=bufferedReader.readLine())!=null)
{
builder.append(line);
}
System.out.println(builder.toString());
JSONObject object = JSON.parseObject(builder.toString());
System.out.println(object.getDouble("org_allpay"));
} catch (IOException e) {
e.printStackTrace();
}finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
} }
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