Commit b2d453f8 by shj

数据库备份;数据库查询接口

parent b77a3c79
CREATE TABLE budgetmanagementsystem.budgets
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
userid int(11) DEFAULT '0' COMMENT '用户id',
filename varchar(50) COMMENT '预算文件名称'
);
CREATE TABLE budgetmanagementsystem.conference
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '名称(会议内容)',
price double COMMENT '会议标准费用',
comment text,
experts int(11) COMMENT '需要专家人数',
people int(11) DEFAULT '0' COMMENT '参会人数',
days int(11) DEFAULT '0'
);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (1, '项目启动会', 700, null, 3, 0, 0);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (2, '中期', 700, null, 3, 0, 0);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (3, '预验收', 700, null, 3, 0, 0);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (4, '验收', 700, null, 2, 0, 0);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (5, '学术会议', 5000, null, 0, 0, 0);
INSERT INTO budgetmanagementsystem.conference (id, name, price, comment, experts, people, days) VALUES (9, '技术交流会', 700, null, 0, 0, 0);
CREATE TABLE budgetmanagementsystem.consultation
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '专家信息(职称等)',
price double COMMENT '咨询费',
comment text
);
INSERT INTO budgetmanagementsystem.consultation (id, name, price, comment) VALUES (1, '其他专家', 1000, null);
INSERT INTO budgetmanagementsystem.consultation (id, name, price, comment) VALUES (6, '中级专家', 1500, null);
INSERT INTO budgetmanagementsystem.consultation (id, name, price, comment) VALUES (7, '高级专家', 2400, null);
CREATE TABLE budgetmanagementsystem.equipment
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '型号规格',
price double,
type varchar(50) COMMENT '子类别',
img varchar(100) COMMENT '图片url',
comment text COMMENT '备注'
);
INSERT INTO budgetmanagementsystem.equipment (id, name, price, type, img, comment) VALUES (104, '存储服务器', 98000, '存储服务器', '', 'Intel Xeon E5-2600 v4处理器,2颗,48核,96线程;128G内存;80T硬盘');
INSERT INTO budgetmanagementsystem.equipment (id, name, price, type, img, comment) VALUES (105, '计算服务器', 30000, '计算服务器', null, 'Intel Xeon Skylake-W-2133处理器;32F内存;256GNVMe固态,2T硬盘');
INSERT INTO budgetmanagementsystem.equipment (id, name, price, type, img, comment) VALUES (106, '深度学习工作站', 20000, '深度学习工作站', null, '英特尔(Intel)2.5G十四核Xeon处理器,64G ddr4 2133内存,英伟达(Nvidia)Quadro 16G显卡,Radeon Pro Vega 64 图形处理器,2T 机械硬盘');
INSERT INTO budgetmanagementsystem.equipment (id, name, price, type, img, comment) VALUES (107, '移动工作站', 20000, '移动工作站', null, '第九代 Intel Core i5 处理器,16GB 2666MHz DDR4 内存,2TB 固态硬盘,Radeon Pro 580X 图形处理器 (配备 8GB GDDR5 显存)');
CREATE TABLE budgetmanagementsystem.internationalcommunication
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100),
price double,
comment text,
accommodation double,
food double,
traffic double COMMENT '市内交通(公杂费)'
);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (1, '澳大利亚', 24000, null, 1100, 380, 310);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (2, '北卡莱罗纳', 21000, null, null, null, null);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (4, '东京', 0, null, 1200, 630, 310);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (5, '莫斯科', 0, null, 2000, 310, 280);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (6, '法国巴黎', 0, null, 1200, 460, 300);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (7, '美国华盛顿', 0, null, 1400, 380, 310);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (8, '美国纽约', 0, null, 1700, 380, 310);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (10, '东京', 0, null, 1200, 630, 310);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (11, '法国巴黎', 0, null, 1200, 460, 300);
INSERT INTO budgetmanagementsystem.internationalcommunication (id, name, price, comment, accommodation, food, traffic) VALUES (18, 'sample', 0, null, 0, 0, 0);
CREATE TABLE budgetmanagementsystem.labour
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '名目(本硕博专)',
price double COMMENT '单价(人月)',
priority int(11) COMMENT '优先级',
comment text
);
INSERT INTO budgetmanagementsystem.labour (id, name, price, priority, comment) VALUES (1, '博士生', 2200, 2, null);
INSERT INTO budgetmanagementsystem.labour (id, name, price, priority, comment) VALUES (2, '硕士生', 1760, 3, null);
INSERT INTO budgetmanagementsystem.labour (id, name, price, priority, comment) VALUES (3, '专职', 8000, 1, null);
CREATE TABLE budgetmanagementsystem.material
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '名称/规格',
price double COMMENT '单价',
type varchar(50) COMMENT '类型',
img varchar(100) COMMENT '图片链接',
comment text COMMENT '备注'
);
INSERT INTO budgetmanagementsystem.material (id, name, price, type, img, comment) VALUES (1, '硬盘', 2000, null, null, null);
INSERT INTO budgetmanagementsystem.material (id, name, price, type, img, comment) VALUES (2, '加密移动硬盘', 3000, null, null, null);
INSERT INTO budgetmanagementsystem.material (id, name, price, type, img, comment) VALUES (16, '服务器内存', 4000, null, null, null);
CREATE TABLE budgetmanagementsystem.others
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100),
price double,
comment text
);
INSERT INTO budgetmanagementsystem.others (id, name, price, comment) VALUES (1, '审计费', 20000, null);
CREATE TABLE budgetmanagementsystem.power
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100),
price double,
comment text
);
CREATE TABLE budgetmanagementsystem.property
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '名称名目',
price double,
comment text
);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (1, '著作权', 2000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (2, '知识产权', 5000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (3, '广西省电子地图数据', 10000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (4, '广西省货车 UGC 数据', 10000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (5, '广西省物流 UGC 数据', 10000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (6, '论文发表费', 4000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (7, '广西省交通流量视频数据', 10000, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (11, 'sample', 0, null);
INSERT INTO budgetmanagementsystem.property (id, name, price, comment) VALUES (12, 'sample', 0, null);
CREATE TABLE budgetmanagementsystem.ruleEquipment
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
min_val int(11) DEFAULT '0',
max_val int(11) DEFAULT '100000'
);
CREATE TABLE budgetmanagementsystem.testandprocess
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(100) COMMENT '名称、内容',
price double COMMENT '单价',
comment text COMMENT '备注'
);
INSERT INTO budgetmanagementsystem.testandprocess (id, name, price, comment) VALUES (1, '测试化验加工费', 150000, null);
INSERT INTO budgetmanagementsystem.testandprocess (id, name, price, comment) VALUES (2, '数据清洗服务', 50000, null);
INSERT INTO budgetmanagementsystem.testandprocess (id, name, price, comment) VALUES (3, '云服务器租用', 100000, null);
CREATE TABLE budgetmanagementsystem.travel
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(50) COMMENT '目的地',
price double COMMENT '往返价格',
food double COMMENT '伙食标准',
traffic double COMMENT '交通标准',
accommodation double COMMENT '住宿标准',
comment text COMMENT '备注'
);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (1, '上海', 2000, 100, 80, 500, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (2, '南宁', 2000, 100, 80, 350, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (3, '桂林', 2000, 100, 80, 350, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (4, '北海', 2000, 100, 80, 350, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (7, '天津', 2000, 100, 80, 380, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (8, '深圳', 2000, 100, 80, 450, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (9, '重庆', 2000, 100, 80, 370, null);
INSERT INTO budgetmanagementsystem.travel (id, name, price, food, traffic, accommodation, comment) VALUES (10, '西安', 2000, 100, 80, 350, null);
CREATE TABLE budgetmanagementsystem.user
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
name varchar(50) DEFAULT 'username' COMMENT '用户名',
password varchar(20) DEFAULT 'password' COMMENT '密码'
);
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (1, '1', '1');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (2, '2', '2');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (3, '222', '222');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (4, '333', '333');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (5, 'zhangsan', 'zhangsan');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (6, '444', '444');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (7, 'xxx', 'xxx');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (9, '44444', '44444');
INSERT INTO budgetmanagementsystem.user (id, name, password) VALUES (10, 'aaa', 'aaa');
CREATE TABLE budgetmanagementsystem.user_budget
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
userid int(11) NOT NULL,
budgetid mediumtext NOT NULL,
budgetname varchar(100)
);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (13, 1, '1557585969465', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (15, 4, '1557653424704', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (16, 4, '1557658609291', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (23, 5, '1557681943936', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (24, 5, '1557681978320', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (26, 3, '1557682461267', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (27, 3, '1557682473376', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (29, 9, '1557717529246', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (46, 10, '1557738195161', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (47, 10, '1557743667619', null);
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (120, 7, '1558802034440', 'new');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (122, 1, '1558966651041', 'HP Z8 G4(Z3Z16AV-SC001)');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (123, 7, '1558969830804', '预算');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (126, 7, '1558979419134', 'HP Z8 G4(Z3Z16AV-SC001)');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (127, 7, '1559005935872', '基于群体智能的城市交通数据开放共享技术研发');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (128, 1, '1559127952477', 'new');
INSERT INTO budgetmanagementsystem.user_budget (id, userid, budgetid, budgetname) VALUES (131, 6, '1559132140099', '预算');
CREATE TABLE budgetmanagementsystem.workstation
(
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
spec varchar(100) COMMENT '型号规格',
price double COMMENT '单价(万)',
img varchar(100) COMMENT '图片url'
);
CREATE UNIQUE INDEX workstation_spec_uindex ON budgetmanagementsystem.workstation (spec);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (35, '戴尔Precision T5820(Xeon W-2123/64GB/512GB+4TB/P2000)', 23700, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (36, 'UltraLAB P490(14664-MAX)', 60000, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (37, 'HP Z4 G4(1JP11AV-SC001)', 17000, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (38, 'Wiseteam CP265 C33128-SAEK12', 149900, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (39, '凌炫Pt8040(E221T-ECEP6)', 499900, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (40, '联想ThinkStation P520c(Xeon W-2123/16GB/256GB+1TB/P2000)', 14400, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (41, '戴尔Precision T7920塔式系列(P7920T-S4110NLCN01)', 24300, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (42, 'UltraLAB Alpha720(425256-SB28TD)', 275000, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (43, 'UltraLAB H490(14664-M5TCX)', 47000, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (44, 'UltraLAB EX620(23496-M528TC)', 140000, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (45, '戴尔Precision 7530系列(Promo-M7530I78750-Online1)', 18600, null);
INSERT INTO budgetmanagementsystem.workstation (id, spec, price, img) VALUES (46, '戴尔Precision 5530系列(Promo-M5530I58300-Online1)', 9999, null);
\ No newline at end of file
......@@ -9,7 +9,7 @@
select * from conference where id=#{id}
</select>
<insert id="insertConference">
insert into budgetmanagementsystem.conference(name, price, experts,people) values (#{name},#{price},#{experts},#{people})
insert into budgetmanagementsystem.conference(name, price, experts,people,days) values (#{name},#{price},#{experts},#{people},#{days})
</insert>
<update id="updateConference">
update budgetmanagementsystem.conference set name=#{name},price=#{price},experts=#{experts},people=#{people} where id=#{id};
......
......@@ -6,4 +6,8 @@ import java.util.List;
public interface IOthersDao {
List<Others> selectAll();
void insertOthers(Others others);
void deleteOthers(Others others);
}
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="dao.IOthersDao">
<select id="selectAll" resultType="beans.Others">
select * from others
</select>
<select id="selectById" resultType="beans.Others">
select * from others where id=#{id}
</select>
<insert id="insertOthers" useGeneratedKeys="true" keyProperty="id">
insert into others(name,price) values (#{name},#{price})
</insert>
<update id="updateProperty">
update budgetmanagementsystem.others set name=#{name},price=#{price} where id=#{id}
</update>
<delete id="deleteOthers">
delete from others where id=#{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<select id="selectById" resultType="beans.Property">
select * from property where id=#{id}
</select>
<insert id="insertProperty">
<insert id="insertProperty" useGeneratedKeys="true" keyProperty="id">
insert into budgetmanagementsystem.property(name,price) values (#{name},#{price})
</insert>
<update id="updateProperty">
......
......@@ -6,4 +6,8 @@ import java.util.List;
public interface ITestAndProcessDao {
List<TestAndProcess> selectAll();
void insertTestAndProcess(TestAndProcess testAndProcess);
void deleteTestAndProcess(TestAndProcess testAndProcess);
}
......@@ -5,4 +5,10 @@
<select id="selectAll" resultType="beans.TestAndProcess">
select * from testandprocess
</select>
<insert id="insertTestAndProcess" useGeneratedKeys="true" keyProperty="id">
insert into testandprocess(name,price) values(#{name},#{price})
</insert>
<delete id="deleteTestAndProcess">
delete from testandprocess where id=#{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -551,14 +551,25 @@ public class BudgetHandler {
{
items.remove(material);
items.put(material, nums);
} else
} else if(curd.equals(0))
{
items.put(material, nums);
materialDao.insertMaterial(material);
}else if(curd.equals(3))
{
items.put(material, nums);
}else if(curd.equals(4))
{
materialDao.deleteMaterial(material);
}
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
}
@Autowired
private ITestAndProcessDao testAndProcessDao;
@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");
......@@ -581,8 +592,14 @@ public class BudgetHandler {
{
items.remove(testAndProcess);
items.put(testAndProcess, nums);
} else
} else if(curd.equals(3))
items.put(testAndProcess, nums);
else if(curd.equals(0)){
items.put(testAndProcess,nums);
testAndProcessDao.insertTestAndProcess(testAndProcess);
}else if(curd.equals(4)){
testAndProcessDao.deleteTestAndProcess(testAndProcess);
}
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......@@ -630,6 +647,12 @@ public class BudgetHandler {
{
items.put(internationalCommunication, nums);
internationalCommunicationDao.insertInternational(internationalCommunication);
}else if(curd.equals(3))
{
items.put(internationalCommunication, nums);
}else if(curd.equals(4))
{
internationalCommunicationDao.deleteInternational(internationalCommunication);
}
}
afterUpdate(budget);
......@@ -668,11 +691,16 @@ public class BudgetHandler {
if (!checkService.checkProperty(property)) return;
if (curd.equals(0)) {
items.put(property, nums);
propertyDao.insertProperty(property);
} else if (curd.equals(1)) {
items.remove(property);
} else {
} else if(curd.equals(2)){
items.remove(property);
items.put(property, nums);
}else if(curd.equals(3)){
items.put(property,nums);
}else if(curd.equals(4)){
propertyDao.deleteProperty(property);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......@@ -747,11 +775,16 @@ public class BudgetHandler {
Map<Conference, Integer> items = budget.getConferences();
if (curd.equals(0)) {
items.put(conference, nums);
conferenceDao.insertConference(conference);
} else if (curd.equals(1)) {
items.remove(conference);
} else {
} else if(curd.equals(2)){
items.remove(conference);
items.put(conference, nums);
}else if(curd.equals(3)){
items.put(conference,nums);
}else if(curd.equals(4)){
conferenceDao.deleteConference(conference);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......@@ -867,6 +900,8 @@ public class BudgetHandler {
@Autowired
private IOthersDao othersDao;
@RequestMapping("/Modify/Others")
public void modifyOthers(Integer mode, Others others, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("/Modify/Others");
......@@ -884,11 +919,16 @@ public class BudgetHandler {
items = budget.getOthers();
if (curd.equals(0)) {
items.put(others, nums);
othersDao.insertOthers(others);
} else if (curd.equals(1)) {
items.remove(others);
} else {
} else if(curd.equals(2)){
items.remove(others);
items.put(others, nums);
}else if(curd.equals(3)){
items.put(others, nums);
}else if(curd.equals(4)){
othersDao.deleteOthers(others);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......
......@@ -48,6 +48,60 @@ public class DatabaseQueryHandler {
}
}
@Autowired
private IMaterialDao materialDao;
@RequestMapping("/Material")
public void queryMaterial(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<Material> materials = materialDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Material item : materials) {
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 ITestAndProcessDao testAndProcessDao;
@RequestMapping("/TestAndProcess")
public void queryTestAndProcess(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<TestAndProcess> testAndProcesses = testAndProcessDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (TestAndProcess item : testAndProcesses) {
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 ILabourDao labourDao;
@RequestMapping("/Labour")
......@@ -136,6 +190,61 @@ public class DatabaseQueryHandler {
}
@Autowired
private IConferenceDao conferenceDao;
@RequestMapping("/Conference")
public void queryConference(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<Conference> conferences = conferenceDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Conference item : conferences) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("people",item.getPeople());
obj.put("days",item.getDays());
obj.put("nums",0);
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@Autowired
private IPropertyDao propertyDao;
@RequestMapping("/Property")
public void queryProperty(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<Property> properties = propertyDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Property item : properties) {
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 IInternationalCommunicationDao internationalCommunicationDao;
......@@ -167,4 +276,30 @@ public class DatabaseQueryHandler {
e.printStackTrace();
}
}
@Autowired
private IOthersDao othersDao;
@RequestMapping("/Others")
public void queryOthers(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<Others> others = othersDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Others item : others) {
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();
}
}
}
......@@ -150,7 +150,16 @@ public class BudgetService implements IBudgetService {
@Override
public Map<Material, Integer> doMaterial(Double number) {
List<Material> materials = materialDao.selectAll();
return generateMap((List) materials, number);
Map<Material,Integer> result=new HashMap<>();
if(materials!=null && materials.size()>0){
Material material = materials.get(0);
int i=0;
while (i*material.getPrice()<number){
i++;
}
result.put(material,i);
}
return result;
}
/**
......@@ -163,6 +172,7 @@ public class BudgetService implements IBudgetService {
public Map<TestAndProcess, Integer> doTestAndProcess(Double number) {
Map<TestAndProcess,Integer> result=new HashMap<>();
TestAndProcess testAndProcess = new TestAndProcess();
testAndProcess.setId(0);
testAndProcess.setPrice(number);
testAndProcess.setName("测试化验加工费");
result.put(testAndProcess,1);
......@@ -179,6 +189,7 @@ public class BudgetService implements IBudgetService {
public Map<Power, Integer> doPower(Double number) {
Map<Power,Integer> result=new HashMap<>();
Power power = new Power();
power.setId(1);
power.setPrice(number);
power.setName("燃料动力费");
result.put(power,1);
......@@ -196,31 +207,16 @@ public class BudgetService implements IBudgetService {
Map<Travel, Integer> result = new HashMap<>();
List<Travel> travels = travelDao.selectAll();
if (travels != null && travels.size() != 0) {
double sofar = 0.0;
for (Travel travel : travels) {
travel.setPeople(1);
travel.setDays(1);
if (sofar < number) {
result.put(travel, 1);
sofar += travel.computeUnitPrice();
}
}
while (sofar < number) {
for (Travel travel : result.keySet()) {
int days = travel.getDays();
double oldCost = travel.computeUnitPrice();
travel.setDays(days+1);
double newCost = travel.computeUnitPrice();
sofar += (newCost - oldCost);
//System.out.println("oldCost:" + oldCost);
//System.out.println("newCost:" + newCost);
//System.out.println("sofar:" + sofar);
if (sofar >= number) {
//System.out.println(result);
return result;
}
}
Travel travel = travels.get(0);
int i=1;
travel.setDays(1);
travel.setPeople(1);
while(travel.computeUnitPrice()<number){
i++;
travel.setPeople(i);
}
result.put(travel,1);
}
return result;
}
......@@ -237,22 +233,15 @@ public class BudgetService implements IBudgetService {
public Map<Conference, Integer> doConference(Double number) {
Map<Conference, Integer> map = new HashMap<>();
List<Conference> conferences = conferenceDao.selectAll();
double sum = 0.0;
for (Conference conference : conferences) {
if (sum < number) {
conference.setPeople(1);
conference.setDays(1);
map.put(conference, 1);
sum += conference.computeUnitPrice();
}
}
while (sum < number) {
for (Conference conference : map.keySet()) {
int i = map.get(conference);
map.put(conference, ++i);
sum += conference.computeUnitPrice();
if (sum >= number) return map;
if(conferences!=null && conferences.size()>0){
Conference conference = conferences.get(0);
conference.setDays(1);
conference.setPeople(1);
int i=1;
while(conference.computeUnitPrice()<number){
conference.setPeople(++i);
}
map.put(conference,1);
}
return map;
}
......@@ -287,7 +276,16 @@ public class BudgetService implements IBudgetService {
@Override
public Map<Property, Integer> doProperty(Double number) {
List<Property> properties = propertyDao.selectAll();
return generateMap((List) properties, number);
Map<Property,Integer> result=new HashMap<>();
if(properties!=null && properties.size()>0){
Property property = properties.get(0);
int i=0;
while(i*property.getPrice()<number){
i++;
}
result.put(property,i);
}
return result;
}
/**
......@@ -395,6 +393,7 @@ public class BudgetService implements IBudgetService {
public Map<Others, Integer> doOthers(Double number) {
Map<Others, Integer> others = new HashMap<>();
Others item = new Others();
item.setId(0);
item.setName("其他费用");
item.setPrice(number);
others.put(item, 1);
......
......@@ -304,6 +304,25 @@
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
</table>
......@@ -337,6 +356,25 @@
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
</table>
......@@ -477,6 +515,29 @@
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].people" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].days" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
</table>
......@@ -553,7 +614,8 @@
<td><input type="number" v-model="database[selectedIndex].people" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].days" 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>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除</button>
</td>
</tr>
</tbody>
......@@ -583,6 +645,7 @@
<button class="btn btn-danger" @click="del(item)">删除</button>
</td>
</tr>
<tr class="success">
<td><input type="text" v-model="sample.name" class="form-control"></td>
<td><input type="number" v-model="sample.price" class="form-control"></td>
......@@ -591,6 +654,27 @@
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
</table>
......@@ -722,7 +806,6 @@
<td><input type="number" v-model="sample.nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(sample)">添加到本费用</button>
<button class="btn btn-success" @click="addToDatabase(sample)">添加到数据库</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
......@@ -740,6 +823,8 @@
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
......@@ -781,6 +866,14 @@
<script>
/*
curd额取值:0,1,2,3,4
0:自定义增加费用条目到费用列表和数据库,
1:删除已存在的费用条目,
2:修改费用列表中的条目
3:从数据库中添加到费用列表,
4:从数据库中删除条目
*/
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
......@@ -814,7 +907,7 @@
data: {
sample: {id:0,name: "sample", price: 0, nums: 0, type: "", comment: ""},
items: [],
database: [{name: "sample", price: 0, nums: 0, type: "", comment: ""}],
database: [{id:0,name: "sample", price: 0, nums: 0, type: "", comment: ""}],
selectedIndex: 0
},
methods: {
......@@ -892,7 +985,9 @@
el: "#material",
data: {
items: [],
sample: {name: "sample", price: 0, nums: 0}
sample: {id:0,name: "sample", price: 0, nums: 0},
database: [{id:0,name: "sample", price: 0, nums: 0}],
selectedIndex: 0
},
methods: {
update: function (item) {
......@@ -904,12 +999,37 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Material").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("material")
updateBudgetPage("material");
this.showDatabase();
}, function (error) {
console.log(error)
}
)
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Material").then(
function (data) {
var tmp = data.body.data;
for (var i = 0; i < tmp.length; i++) {
if (inItems(tmp[i], this.items)) {
console.log("inItems:true, " + tmp[i].name);
tmp.splice(i, 1);
i--;
}
}
this.database = tmp;
console.log("show database");
}, function (error) {
console.log(error)
}
......@@ -918,6 +1038,7 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Material",
{
id:item.id,
name: item.name,
price: item.price,
nums: item.nums,
......@@ -938,7 +1059,9 @@
el: "#test",
data: {
items: [],
sample: {name: "sample", price: 0, nums: 0}
sample: {id:0,name: "sample", price: 0, nums: 0},
database: [{id:0,name: "sample", price: 0, nums: 0}],
selectedIndex: 0
},
methods: {
update: function (item) {
......@@ -950,12 +1073,37 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/TestAndProcess").then(
function (data) {
var tmp = data.body.data;
for (var i = 0; i < tmp.length; i++) {
if (inItems(tmp[i], this.items)) {
console.log("inItems:true, " + tmp[i].name);
tmp.splice(i, 1);
i--;
}
}
this.database = tmp;
console.log("show database");
}, function (error) {
console.log(error)
}
)
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/TestAndProcess").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("testAndProcess")
updateBudgetPage("testAndProcess");
this.showDatabase();
}, function (error) {
console.log(error)
}
......@@ -964,6 +1112,7 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/TestAndProcess",
{
id:item.id,
name: item.name,
price: item.price,
nums: item.nums,
......@@ -984,8 +1133,8 @@
el: "#international",
data: {
items: [],
sample: {name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0},
database: [{name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0}],
sample: {id:0,name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0},
database: [{id:0,name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0}],
selectedIndex: 0
},
methods: {
......@@ -998,6 +1147,12 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/International").then(
function (data) {
......@@ -1031,6 +1186,7 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/International",
{
id:item.id,
name: item.name,
price: item.price,
food: item.food,
......@@ -1073,7 +1229,9 @@
el: "#property",
data: {
items: [],
sample: {name: "sample", price: 0, nums: 0}
sample: {id:0,name: "sample", price: 0, nums: 0},
database: [{id:0,name: "sample", price: 0, nums: 0}],
selectedIndex: 0
},
methods: {
update: function (item) {
......@@ -1085,12 +1243,37 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Property").then(
function (data) {
var tmp = data.body.data;
for (var i = 0; i < tmp.length; i++) {
if (inItems(tmp[i], this.items)) {
console.log("inItems:true, " + tmp[i].name);
tmp.splice(i, 1);
i--;
}
}
this.database = tmp;
console.log("show database");
}, function (error) {
console.log(error)
}
)
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Property").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("property");
this.showDatabase();
}, function (error) {
console.log(error)
}
......@@ -1099,6 +1282,7 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Property",
{
id:item.id,
name: item.name,
price: item.price,
nums: item.nums,
......@@ -1233,7 +1417,9 @@
el: "#conference",
data: {
items: [],
sample: {name: "sample", expertType: "专家", experts: 0, price: 0, people: 0, days: 0, nums: 0}
sample: {id:0,name: "sample", expertType: "专家", experts: 0, price: 0, people: 0, days: 0, nums: 0},
database: [{id:0,name: "sample", expertType: "专家", experts: 0, price: 0, people: 0, days: 0, nums: 0}],
selectedIndex: 0
},
methods: {
update: function (item) {
......@@ -1245,12 +1431,37 @@
add: function (item) {
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Conference").then(
function (data) {
var tmp = data.body.data;
for (var i = 0; i < tmp.length; i++) {
if (inItems(tmp[i], this.items)) {
console.log("inItems:true, " + tmp[i].name);
tmp.splice(i, 1);
i--;
}
}
this.database = tmp;
console.log("show database");
}, function (error) {
console.log(error)
}
)
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Conference").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("conference")
updateBudgetPage("conference");
this.showDatabase();
}, function (error) {
console.log(error)
}
......@@ -1259,9 +1470,8 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Conference",
{
id:item.id,
name: item.name,
expertType: item.expertType,
experts: item.experts,
price: item.price,
people: item.people,
days: item.days,
......@@ -1436,17 +1646,8 @@
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Others").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("others");
this.showDatabase();
}, function (error) {
console.log(error)
}
);
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Others").then(
......@@ -1466,9 +1667,22 @@
}
)
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Others").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("others");
this.showDatabase();
}, function (error) {
console.log(error)
}
);
},
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Others",
{
id:item.id,
name: item.name,
price: item.price,
nums: item.nums,
......
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