Commit 5661f8ab by shj

设备费详细描述,设备费map的key更新,不再删除原有,而是直接定位key并更新价格,预算说明同步

parent a3de9b40
......@@ -3,13 +3,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="dao.IEquipmentDao">
<insert id="insertEquipment" useGeneratedKeys="true" keyProperty="id">
insert into equipment(name,price) values(#{name},#{price})
insert into equipment(name,price,comment,type) values(#{name},#{price},#{comment},#{type})
</insert>
<select id="selectByName" resultType="beans.Equipment">
select * from equipment where name=#{name}
</select>
<update id="updateEquipment">
update equipment set price=#{price},name=#{name} where id=#{id}
update equipment set price=#{price},name=#{name},comment=#{comment},type=#{type} where id=#{id}
</update>
<select id="selectAll" resultType="beans.Equipment">
select * from equipment
......
......@@ -475,12 +475,25 @@ public class BudgetHandler {
response.setStatus(444);
return;
}
if (curd.equals(2))//
if (curd.equals(2))//改
{
equipments.remove(equipment);
Set<Equipment> keySet = equipments.keySet();
//更新key
for (Equipment item : keySet) {
if(item.equals(equipment)){
item.setPrice(equipment.getPrice());
}
}
//更新value
equipments.put(equipment, nums);
} else
} else if(curd.equals(0))
equipments.put(equipment, nums);
else {
Equipment add = equipmentDao.selectByName(equipment.getName());
equipments.remove(add);
equipments.put(add,nums);
System.out.println("add form database:"+add.getComment());
}
}
serializeBudget(budget, getFilePath(sessionID));
......
......@@ -53,6 +53,9 @@ public class CrawlerService implements ICrawlerService {
.getElementsByClass("rank__name").first()
.getElementsByTag("a").first()
.text().trim();
String params = rankItem.getElementsByClass("rank-list__cell cell-3").first()
.getElementsByClass("_j_pro_info_count").first()
.getElementsByTag("a").get(1).attributes().get("href").trim();
String priceStr = rankItem.getElementsByClass("rank-list__cell cell-4").first()
.getElementsByClass("rank__price").first()
.text().trim();
......@@ -64,11 +67,16 @@ public class CrawlerService implements ICrawlerService {
priceStr = priceStr.substring(1);
price = Double.valueOf(priceStr);
}
Equipment equipment=new Equipment();
equipment.setName(name);
equipment.setPrice(price);
equipments.add(equipment);
index++;
String comment = getDescription(params);
if (price < 100000.0) {
Equipment equipment = new Equipment();
equipment.setName(name);
equipment.setPrice(price);
equipment.setComment(comment);
equipment.setType("工作站");
equipments.add(equipment);
index++;
}
//爬取前十
if (index > 10)
break;
......@@ -90,4 +98,17 @@ public class CrawlerService implements ICrawlerService {
System.out.println("爬取");
}
private String getDescription(String params) {
String url = "http:" + params;
StringBuilder builder = new StringBuilder();
try {
Document document = Jsoup.connect(url).get();
Element paramsList = document.getElementsByClass("detailed-parameters").first();
builder.append(paramsList.text().trim());
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
}
......@@ -51,7 +51,7 @@ public class BudgetExportUtil {
run.setText(line.toString());
line = new StringBuilder();
line.append("用途,")
line.append("【用途说明,例如“针对测试过程中产生的图形数据的存储和分析需要”】,")
.append(num).append("台,主要配置如下:").append(equipment.getComment())
.append("。工作站单价约").append(price).append("元,共需").append(num * price).append("元。");
paragraph = document.createParagraph();
......@@ -136,7 +136,7 @@ public class BudgetExportUtil {
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
run.setText("为顺利完成本课题实施方案中的工作内容,课题拟对上海、南宁、桂林、北海等地相关单位进行调研和技术交流。具体考察调研单位包括:上海市交通委员会、广西省交通运输厅、桂林运营公司、钦州运营公司等。");
run.setText("为顺利完成本课题实施方案中的工作内容,课题拟对【出差地点】等地相关单位进行调研和技术交流。具体考察调研单位包括:【上海市交通委员会、广西省交通运输厅、桂林运营公司、钦州运营公司等】。");
paragraph = document.createParagraph();
run = paragraph.createRun();
......@@ -213,6 +213,14 @@ public class BudgetExportUtil {
run.addTab();
run.setText(line.toString());
}
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
run.setText("【会议任务举例】 牵头单位将组织和协调各课题组召开项目启动会,共同商讨各课题的具体目标、流程、关键节点及研究路线," +
"牵头单位每年组织和协调各课题组召开一次项目及课题中期检查会,检查各课题进度,讨论遇到的问题,内部研讨,寻找解决问题的方法," +
"为了做好项目的结题验收工作,牵头单位将组织各课题承担单位自查自纠,总结课题财务执行情况和撰写课题自评价报告,邀请专家进行项目预验收," +
"项目牵头单位将根据项目进度要求,按时完成项目结题验收工作,并组织召开项目结题验收;" +
"在课题实施期间,要与相关领域其他学者进行研讨,预计受邀参加国内学术会议;");
//国际交流合作费
......
......@@ -147,7 +147,7 @@
</td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(database[selectedIndex])">添加</button>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加</button>
</td>
</tr>
</tbody>
......@@ -610,6 +610,9 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Equipment").then(
function (data) {
......
......@@ -200,7 +200,7 @@
<!-- Button -->
<div title="所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可">
<button class="btn btn-default btn-lg center-block" type="submit">生成预算</button>
<button class="btn btn-default btn-lg center-block" type="submit">保存修改</button>
<p class="help-block" style="color:red">所有复选框必须勾选,如果不需要某类费用,后面的数字填0即可</p>
</div>
</form>
......
......@@ -58,6 +58,7 @@
<div>
<h1>你好!<label id="username" style="color:green;"></label></h1>
<a href="Crawler/Workstation">爬取工作站数据</a><br>
<button class="btn btn-danger" onclick="logout()">退出登录</button>
</div>
......
import beans.Equipment;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.junit.Test;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class CrawlerTest {
@Test
public void test01() {
String url = "http://top.zol.com.cn/compositor/51/workstation.html";
List<Equipment> equipments = new LinkedList<>();
try {
Document document = Jsoup.connect(url).get();
Elements rankList = document.getElementsByClass("rank-list").first().getElementsByClass("rank-list__item");
int index = 0;
for (Element rankItem : rankList) {
if (rankItem.className().equals("rank-list__item clearfix")) {
String name = rankItem.getElementsByClass("rank-list__cell cell-3").first()
.getElementsByClass("rank__name").first()
.getElementsByTag("a").first()
.text().trim();
String params = rankItem.getElementsByClass("rank-list__cell cell-3").first()
.getElementsByClass("_j_pro_info_count").first()
.getElementsByTag("a").get(1).attributes().get("href").trim();
System.out.println("params url: " + params);
String priceStr = rankItem.getElementsByClass("rank-list__cell cell-4").first()
.getElementsByClass("rank__price").first()
.text().trim();
String comment = getDescription(params);
System.out.println("description: " + comment);
double price = 0;
if (priceStr.endsWith("万")) {
priceStr = priceStr.substring(1, priceStr.length() - 1);
price = Double.valueOf(priceStr) * 10000.00;
} else {
priceStr = priceStr.substring(1);
price = Double.valueOf(priceStr);
}
Equipment equipment = new Equipment();
equipment.setName(name);
equipment.setPrice(price);
equipments.add(equipment);
index++;
//爬取前十
if (index > 10)
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("爬取");
}
private String getDescription(String params) {
String url = "http:" + params;
StringBuilder builder = new StringBuilder();
try {
Document document = Jsoup.connect(url).get();
Element paramsList = document.getElementsByClass("detailed-parameters").first();
builder.append(paramsList.text().trim());
/*builder.append("CPU型号:").append(paramsList.getElementById("newPmVal_2").text());
builder.append(",CPU数量:").append(paramsList.getElementById("newPmVal_5").text());
builder.append(",CPU核心:").append(paramsList.getElementById("newPmVal_10").text());
builder.append(";内存大小:").append(paramsList.getElementById("newPmVal_15").text());
builder.append(";显卡类型:").append(paramsList.getElementById("newPmVal_23").text());
builder.append(",显存容量:").append(paramsList.getElementById("newPmVal_24").text());
builder.append(";硬盘容量:").append(paramsList.getElementById("newPmVal_20").text());
builder.append(";硬盘描述:").append(paramsList.getElementById("newPmVal_21").text());*/
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
}
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