Commit b77a3c79 by shj

数据库备份;数据库查询接口;优化说明文件;

parent d32a44a4
......@@ -161,6 +161,12 @@
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
<version>0.27.0</version>
</dependency>
</dependencies>
......
......@@ -9,7 +9,8 @@
select * from internationalcommunication where id=#{id}
</select>
<insert id="insertInternational">
insert into budgetmanagementsystem.internationalcommunication(name,price) values (#{name},#{price})
insert into budgetmanagementsystem.internationalcommunication(name,price,accommodation,food,traffic)
values (#{name},#{price},#{accommodation},#{food},#{traffic})
</insert>
<update id="updateInternational">
update budgetmanagementsystem.internationalcommunication set name=#{name},price=#{price} where id=#{id}
......
......@@ -482,17 +482,25 @@ public class BudgetHandler {
for (Equipment item : keySet) {
if(item.equals(equipment)){
item.setPrice(equipment.getPrice());
item.setType(equipment.getType());
item.setComment(equipment.getComment());
}
}
//更新value
equipments.put(equipment, nums);
} else if(curd.equals(0))
{
equipments.put(equipment, nums);
else {
equipmentDao.insertEquipment(equipment);
}
else if(curd.equals(3)){
Equipment add = equipmentDao.selectByName(equipment.getName());
equipments.remove(add);
equipments.put(add,nums);
System.out.println("add form database:"+add.getComment());
}else if(curd.equals(4)){
equipmentDao.deleteEquipment(equipment);
System.out.println("delete form database:"+equipment.getName());
}
}
serializeBudget(budget, getFilePath(sessionID));
......@@ -618,8 +626,11 @@ public class BudgetHandler {
{
items.remove(internationalCommunication);
items.put(internationalCommunication, nums);
} else
} else if(curd.equals(0))
{
items.put(internationalCommunication, nums);
internationalCommunicationDao.insertInternational(internationalCommunication);
}
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......@@ -855,6 +866,36 @@ public class BudgetHandler {
}
@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");
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
if (budget == null) {
response.sendError(444, "budget not exists");
return;
}
Map<Others, Integer> items = null;
items = budget.getOthers();
if (curd.equals(0)) {
items.put(others, nums);
} else if (curd.equals(1)) {
items.remove(others);
} else {
items.remove(others);
items.put(others, nums);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
}
/**
* 预算修改的善后工作
*
......
......@@ -35,6 +35,8 @@ public class DatabaseQueryHandler {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("type",item.getType());
obj.put("comment",item.getComment());
obj.put("price",item.getPrice());
obj.put("nums",0);
list.add(obj);
......
......@@ -233,6 +233,8 @@ public class DetailHandler {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("type",item.getType());
obj.put("comment",item.getComment());
obj.put("price",item.getPrice());
obj.put("nums",equipments.get(item));
list.add(obj);
......@@ -543,4 +545,35 @@ public class DetailHandler {
e.printStackTrace();
}
}
@RequestMapping("/Others")
public void showOthers(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("indirect list error");
return;
}
Map<Others, Integer> others = budget.getOthers();
List<JSONObject> list=new LinkedList<>();
for (Others item : others.keySet()) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",others.get(item));
list.add(obj);
}
object.put("data",list);
writer.write(object.toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -22,9 +22,9 @@ public class CheckService implements ICheckService {
if (material == null || material.getName() == null) {
return 201;
}
if (material.computeUnitPrice() >= 10000) {
/*if (material.computeUnitPrice() >= 10000) {
return 202;
}
}*/
return isValid;
}
......
......@@ -44,7 +44,7 @@ public class BudgetExportUtil {
StringBuilder line = new StringBuilder();
line.append("(").append(i).append(")");
line.append(equipment.getType())
line.append(equipment.getName())
.append(num).append("台,每台")
.append(price).append("元,共计")
.append(num * price).append("元");
......@@ -113,6 +113,35 @@ public class BudgetExportUtil {
run.addTab();
run.setText("测试化验加工费:"+detailService.sumTestAndProcess(budget.getTestAndProcesses())+"万元。【具体用途自行填写】");
Map<TestAndProcess, Integer> testAndProcesses = budget.getTestAndProcesses();
i = 0;
for (TestAndProcess item : testAndProcesses.keySet()) {
i++;
int num = testAndProcesses.get(item);
double price = item.getPrice();
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
StringBuilder line = new StringBuilder();
line.append("(").append(i).append(")");
line.append(item.getName())
.append(num).append("次,每次")
.append(price).append("元,共计")
.append(num * price).append("元");
run.setText(line.toString());
line = new StringBuilder();
line.append("用途:【自行填写】,购买")
.append(num).append("服务,")
.append("单价").append(price).append("元,共需").append(num * price).append("元。");
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
run.setText(line.toString());
}
//燃料动力费
paragraph = document.createParagraph();
......
......@@ -2,6 +2,11 @@ import beans.Budget;
import beans.Conference;
import beans.Equipment;
import beans.Item;
import handlers.BudgetHandler;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.xfer.FileSystemFile;
import org.jsoup.select.Evaluator;
import org.junit.Test;
import java.io.*;
......@@ -496,4 +501,29 @@ public class MyTest implements Serializable {
System.out.println(e1.equals(c1));
System.out.println(e1.equals(e2));
}
@Test
public void directoryTest() throws ClassNotFoundException {
System.out.println();
System.getProperty("user.home");
}
@Test
public void SFTPTestUp() throws IOException {
final SSHClient ssh = new SSHClient();
ssh.loadKnownHosts(new File("‪C:\\Users\\Song\\.ssh\\known_hosts"));
ssh.connect("47.92.3.69");
try {
ssh.authPublickey("root");
final String src = "‪F:\\Workspace\\BudgetManagementSystem\\pom.xml";
final SFTPClient sftp = ssh.newSFTPClient();
try {
sftp.put(new FileSystemFile(src), "/tmp");
} finally {
sftp.close();
}
} finally {
ssh.disconnect();
}
}
}
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