test successgit add .!
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
WebRoot/WEB-INF/classes/com/jinshan/model/Report$3.class
Normal file
BIN
WebRoot/WEB-INF/classes/com/jinshan/model/Report$3.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,17 +1,20 @@
|
|||||||
<div>
|
<div>
|
||||||
<center>
|
<center>
|
||||||
<form action="/report/update" method="post"
|
<form action="/report/update" method="post"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data" target="rfFrame">
|
||||||
<input type="hidden" name="report_id" value="{{report_id}}" >
|
<input type="hidden" name="report_id" value="{{report_id}}">
|
||||||
<lable for="creator">创建者:</lable>
|
<lable for="creator">创建者:</lable>
|
||||||
<input id="creator" type="text" value="{{report.report_creator}}" name="report_creator"><br>
|
<input id="creator" type="text" value="{{report.report_creator}}"
|
||||||
<br>
|
name="report_creator" placeholder="创建者"><br> <br>
|
||||||
<lable>创建/修改时间:{{report.report_create_time}}</lable>
|
<lable for="time">创建时间:</lable>
|
||||||
<br> <br>
|
<input id="time" type="text" value="{{report.report_create_time}}"
|
||||||
|
name="report_time" placeholder="创建时间" readonly> <a
|
||||||
|
href="#/reports/" ng-click="remove()">删除</a><br> <br>
|
||||||
<table width="80%" border="1">
|
<table width="80%" border="1">
|
||||||
<caption>
|
<caption>
|
||||||
<input id="name" type="text" value="{{report.report_name}}"
|
<input id="name" type="text" value="{{report.report_name}}"
|
||||||
style="width: 30%; text-align: center" name="report_name">
|
style="width: 30%; text-align: center" name="report_name"
|
||||||
|
placeholder="请填写安全检查信息表名">
|
||||||
</caption>
|
</caption>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
@@ -53,6 +56,9 @@
|
|||||||
<input type="submit"></input>
|
<input type="submit"></input>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<iframe hidden id="rfFrame" name="rfFrame" src="about:blank"$amp;>amp;$lt;</iframe>
|
||||||
|
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
<div>
|
<div>
|
||||||
<br>
|
<br>
|
||||||
<h4>
|
<h4>
|
||||||
安全检查信息列表
|
安全检查信息列表 <a
|
||||||
|
href="#/reports/add">添加</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<div ng-repeat="report in reportList">
|
<div ng-repeat="report in reportList">
|
||||||
<a href="#/reports/{{report.report_id}}"><ui>{{report.report_name}}</ui></a>
|
<ui>
|
||||||
|
<a href="#/reports/{{report.report_id}}">{{report.report_name}}</a>
|
||||||
|
</ui>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -9,23 +9,30 @@ appControllers.controller('ReportListController', [ '$scope', '$http',
|
|||||||
});
|
});
|
||||||
} ]);
|
} ]);
|
||||||
|
|
||||||
appControllers.controller('ReportDetailController', [
|
appControllers.controller('ReportDetailController', [ '$scope', '$routeParams',
|
||||||
'$scope',
|
'$http', function($scope, $routeParams, $http) {
|
||||||
'$routeParams',
|
|
||||||
'$http',
|
|
||||||
function($scope, $routeParams, $http) {
|
|
||||||
$scope.report_id = $routeParams.report_id;
|
$scope.report_id = $routeParams.report_id;
|
||||||
|
|
||||||
$http.get("/report/query?report_id=" + $scope.report_id).success(
|
var url = "";
|
||||||
function(response) {
|
|
||||||
|
|
||||||
$scope.report = response;
|
if ($scope.report_id == "add") {
|
||||||
$scope.contents = response.contents;
|
url = "/report/add";
|
||||||
|
|
||||||
});
|
} else {
|
||||||
|
url += "/report/query?report_id=" + $scope.report_id;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.submit = function() {
|
$http.get(url).success(function(response) {
|
||||||
|
|
||||||
};
|
$scope.report = response;
|
||||||
|
$scope.contents = response.contents;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.remove = function(report_id) {
|
||||||
|
if (confirm("确定删除?")) {
|
||||||
|
$http.get("/report/delete?report_id=" + $scope.report_id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} ]);
|
} ]);
|
||||||
BIN
WebRoot/upload/20151209/psb - 副本.jpg
Normal file
BIN
WebRoot/upload/20151209/psb - 副本.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
WebRoot/upload/20151209/psb - 副本1.jpg
Normal file
BIN
WebRoot/upload/20151209/psb - 副本1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
WebRoot/upload/20151209/psb - 副本2.jpg
Normal file
BIN
WebRoot/upload/20151209/psb - 副本2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
WebRoot/upload/20151209/psb - 副本3.jpg
Normal file
BIN
WebRoot/upload/20151209/psb - 副本3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
@@ -89,7 +89,7 @@ CREATE TABLE `check_record` (
|
|||||||
`record_id` int(11) NOT NULL AUTO_INCREMENT,
|
`record_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`report_id` int(11) NOT NULL,
|
`report_id` int(11) NOT NULL,
|
||||||
`check_item_id` int(11) NOT NULL,
|
`check_item_id` int(11) NOT NULL,
|
||||||
`passed` varchar(1) NOT NULL,
|
`passed` varchar(1) DEFAULT '0',
|
||||||
`pic_url` varchar(200) DEFAULT '""',
|
`pic_url` varchar(200) DEFAULT '""',
|
||||||
`note` varchar(200) DEFAULT '""',
|
`note` varchar(200) DEFAULT '""',
|
||||||
PRIMARY KEY (`record_id`),
|
PRIMARY KEY (`record_id`),
|
||||||
@@ -147,9 +147,4 @@ CREATE TABLE `report` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of report
|
-- Records of report
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `report` VALUES ('1', 'AH-H001-01 2015年3月11日18点测试表', '黄金定', '2015-11-14 11:46:10');
|
INSERT INTO `report` VALUES ('1', 'AH-H001-01 2015年3月11日18点测试表', '杜佳', '2015-12-10 11:46:10');
|
||||||
INSERT INTO `report` VALUES ('2', 'AH-H001-02 2015年3月12日18点测试表', '杜佳佳', '2015-11-14 11:46:10');
|
|
||||||
INSERT INTO `report` VALUES ('3', 'AH-H001-03 2015年3月12日18点测试表', '杜佳佳', '2015-11-14 11:46:10');
|
|
||||||
INSERT INTO `report` VALUES ('4', 'AH-H001-04 2015年3月12日18点测试表', '杜佳佳', '2015-11-14 11:46:10');
|
|
||||||
INSERT INTO `report` VALUES ('5', 'AH-H001-05 2015年3月12日18点测试表', '杜佳佳', '2015-11-14 11:46:10');
|
|
||||||
INSERT INTO `report` VALUES ('6', 'AH-H001-06 2015年3月12日18点测试表', '杜佳佳', '2015-11-14 11:46:10');
|
|
||||||
|
|||||||
2009
jinshan.log
2009
jinshan.log
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,8 @@ public class IndexController extends Controller {
|
|||||||
|
|
||||||
public void index() {
|
public void index() {
|
||||||
|
|
||||||
setAttr("status", "SUCCESS");
|
// setAttr("status", "SUCCESS");
|
||||||
renderJson();
|
// renderJson();
|
||||||
|
redirect("/index.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.jinshan.controller;
|
package com.jinshan.controller;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -32,6 +35,15 @@ public class ReportController extends Controller {
|
|||||||
renderJson();
|
renderJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add() {
|
||||||
|
setAttr("report_name", "");
|
||||||
|
setAttr("report_creator", "");
|
||||||
|
setAttr("report_create_time", "");
|
||||||
|
setAttr("contents", Report.dao.query());
|
||||||
|
|
||||||
|
renderJson();
|
||||||
|
}
|
||||||
|
|
||||||
public void query() {
|
public void query() {
|
||||||
Integer report_id = getParaToInt("report_id");
|
Integer report_id = getParaToInt("report_id");
|
||||||
|
|
||||||
@@ -49,82 +61,32 @@ public class ReportController extends Controller {
|
|||||||
renderJson();
|
renderJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
public void updateByJsonStr() {
|
||||||
public void update() {
|
String type = getPara("type");
|
||||||
// String type = getPara("type");
|
if (type.equals("add")) {
|
||||||
// if (type.equals("add")) {
|
if (addByJsonStr()) {
|
||||||
// if (add()) {
|
setAttr("result", "add success");
|
||||||
// setAttr("result", "add success");
|
} else {
|
||||||
// } else {
|
setAttr("result", "add failed");
|
||||||
// setAttr("result", "add failed");
|
}
|
||||||
// }
|
} else if (type.equals("delete")) {
|
||||||
// } else if (type.equals("delete")) {
|
if (delete1()) {
|
||||||
// if (delete()) {
|
setAttr("result", "delete success");
|
||||||
// setAttr("result", "delete success");
|
} else {
|
||||||
// } else {
|
setAttr("result", "delete failed");
|
||||||
// setAttr("result", "delete failed");
|
}
|
||||||
// }
|
} else if (type.equals("edit")) {
|
||||||
// } else if (type.equals("edit")) {
|
if (editByJsonStr()) {
|
||||||
// if (edit()) {
|
setAttr("result", "edit success");
|
||||||
// setAttr("result", "edit success");
|
} else {
|
||||||
// } else {
|
setAttr("result", "edit failed");
|
||||||
// setAttr("result", "edit failed");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
List<UploadFile> list_uf = getFiles("upload");
|
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("report_id", getPara("report_id"));
|
|
||||||
map.put("report_name", getPara("report_name"));
|
|
||||||
map.put("report_creator", getPara("report_creator"));
|
|
||||||
|
|
||||||
ArrayList<Object> items = new ArrayList<>();
|
|
||||||
|
|
||||||
List<CheckContent> list_content = CheckContent.dao
|
|
||||||
.find("select * from check_content");
|
|
||||||
for (int i = 0; i < list_content.size(); i++) {
|
|
||||||
List<CheckItem> list_item = CheckItem.dao.find(
|
|
||||||
"select * from check_item where check_content_id = ?",
|
|
||||||
list_content.get(i).get("check_content_id"));
|
|
||||||
for (int j = 0; j < list_item.size(); j++) {
|
|
||||||
String pic_url = "";
|
|
||||||
String passed = "0";
|
|
||||||
String note = "";
|
|
||||||
|
|
||||||
if (getPara("pic_url_" + String.valueOf((i + 1)) + "_"
|
|
||||||
+ String.valueOf((i + 1))) != null) {
|
|
||||||
pic_url = getPara("pic_url_" + String.valueOf((i + 1))
|
|
||||||
+ "_" + String.valueOf((j + 1)));
|
|
||||||
}
|
|
||||||
if (getPara("passed_" + String.valueOf((i + 1)) + "_"
|
|
||||||
+ String.valueOf((j + 1))) != null) {
|
|
||||||
passed = "1";
|
|
||||||
}
|
|
||||||
if (getPara("note_" + String.valueOf((i + 1)) + "_"
|
|
||||||
+ String.valueOf((i + 1))) != null) {
|
|
||||||
note = getPara("note_" + String.valueOf((i + 1)) + "_"
|
|
||||||
+ String.valueOf((j + 1)));
|
|
||||||
}
|
|
||||||
Map<String, Object> map1 = new HashMap<>();
|
|
||||||
map1.put("pic_url", pic_url);
|
|
||||||
map1.put("passed", passed);
|
|
||||||
map1.put("note", note);
|
|
||||||
|
|
||||||
|
|
||||||
@!!!!!!!!!!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map<String, String[]> map = getParaMap();
|
|
||||||
|
|
||||||
renderJson();
|
renderJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean add() {
|
private boolean addByJsonStr() {
|
||||||
String jsonStr = null;
|
String jsonStr = null;
|
||||||
try {
|
try {
|
||||||
jsonStr = getBody(getRequest());
|
jsonStr = getBody(getRequest());
|
||||||
@@ -139,35 +101,118 @@ public class ReportController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean delete() {
|
public boolean delete1() {
|
||||||
Integer report_id = getParaToInt("report_id");
|
Integer report_id = getParaToInt("report_id");
|
||||||
if (Report.dao.deleteById(report_id)) {
|
if (Report.dao.deleteById(report_id)) {
|
||||||
|
setAttr("result", "delete success");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
setAttr("result", "delete failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
Integer report_id = getParaToInt("report_id");
|
||||||
|
if (Report.dao.deleteById(report_id)) {
|
||||||
|
setAttr("result", "delete success");
|
||||||
|
} else {
|
||||||
|
setAttr("result", "delete failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean editByJsonStr() {
|
||||||
|
String jsonStr = null;
|
||||||
|
try {
|
||||||
|
jsonStr = getBody(getRequest());
|
||||||
|
} catch (ServletException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = new JSONObject(jsonStr);
|
||||||
|
if (Report.dao.updateByJSONObject(jsonObject)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean edit() {
|
public void update() {
|
||||||
// String jsonStr = null;
|
String saveDirectory = "upload" + File.separator
|
||||||
// try {
|
+ new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||||
// jsonStr = getBody(getRequest());
|
List<UploadFile> list_uf = getFiles(saveDirectory);
|
||||||
// } catch (ServletException | IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// JSONObject jsonObject = new JSONObject(jsonStr);
|
|
||||||
// if (Report.dao.updateByJSONObject(jsonObject)) {
|
|
||||||
// return true;
|
|
||||||
// } else {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getFiles("/upload");
|
Map<String, Object> map = new HashMap<>();
|
||||||
// if () {
|
map.put("report_id", getPara("report_id"));
|
||||||
// return true;
|
map.put("report_name", getPara("report_name"));
|
||||||
// } else {
|
map.put("report_creator", getPara("report_creator"));
|
||||||
return true;
|
map.put("list_uf", list_uf);
|
||||||
// }
|
|
||||||
|
ArrayList<Object> items = new ArrayList<>();
|
||||||
|
|
||||||
|
List<CheckContent> list_content = CheckContent.dao
|
||||||
|
.find("select * from check_content");
|
||||||
|
for (int i = 0; i < list_content.size(); i++) {
|
||||||
|
List<CheckItem> list_item = CheckItem.dao.find(
|
||||||
|
"select * from check_item where check_content_id = ?",
|
||||||
|
list_content.get(i).get("check_content_id"));
|
||||||
|
for (int j = 0; j < list_item.size(); j++) {
|
||||||
|
String passed = "0";
|
||||||
|
String note = "";
|
||||||
|
|
||||||
|
int check_content_id = i + 1;
|
||||||
|
int table_sequence = j + 1;
|
||||||
|
if (getPara("passed_" + String.valueOf((check_content_id))
|
||||||
|
+ "_" + String.valueOf((table_sequence))) != null) {
|
||||||
|
passed = "1";
|
||||||
|
}
|
||||||
|
if (getPara("note_" + String.valueOf((check_content_id)) + "_"
|
||||||
|
+ String.valueOf((table_sequence))) != null) {
|
||||||
|
note = getPara("note_" + String.valueOf((check_content_id))
|
||||||
|
+ "_" + String.valueOf((table_sequence)));
|
||||||
|
}
|
||||||
|
CheckItem checkItem = CheckItem.dao
|
||||||
|
.findFirst(
|
||||||
|
"select * from check_item where check_content_id = ? and table_sequence = ?",
|
||||||
|
check_content_id, table_sequence);
|
||||||
|
int check_item_id = checkItem.getInt("check_item_id");
|
||||||
|
|
||||||
|
Map<String, Object> map1 = new HashMap<>();
|
||||||
|
map1.put("passed", passed);
|
||||||
|
map1.put("note", note);
|
||||||
|
map1.put("check_item_id", check_item_id);
|
||||||
|
|
||||||
|
items.add(map1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("items", items);
|
||||||
|
|
||||||
|
if (map.get("report_id") != null) {
|
||||||
|
if (editByMap(map)) {
|
||||||
|
setAttr("result", "edit success");
|
||||||
|
} else {
|
||||||
|
setAttr("result", "edit failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (addByMap(map)) {
|
||||||
|
setAttr("result", "edit success");
|
||||||
|
} else {
|
||||||
|
setAttr("result", "edit failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean editByMap(Map<String, Object> map) {
|
||||||
|
|
||||||
|
return Report.dao.update(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean addByMap(Map<String, Object> map) {
|
||||||
|
|
||||||
|
return Report.dao.update(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBody(HttpServletRequest request) throws ServletException,
|
private String getBody(HttpServletRequest request) throws ServletException,
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.jinshan.model;
|
package com.jinshan.model;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -14,11 +17,14 @@ import org.json.JSONObject;
|
|||||||
import com.jfinal.plugin.activerecord.Db;
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
import com.jfinal.plugin.activerecord.IAtom;
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
import com.jfinal.plugin.activerecord.Model;
|
import com.jfinal.plugin.activerecord.Model;
|
||||||
|
import com.jfinal.upload.UploadFile;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Report extends Model<Report> {
|
public class Report extends Model<Report> {
|
||||||
public static Report dao = new Report();
|
public static Report dao = new Report();
|
||||||
|
|
||||||
|
public int tmp_report_id;
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public List<Object> query(int report_id) {
|
public List<Object> query(int report_id) {
|
||||||
ArrayList<Object> list = new ArrayList<>();
|
ArrayList<Object> list = new ArrayList<>();
|
||||||
@@ -99,6 +105,47 @@ public class Report extends Model<Report> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Object> query() {
|
||||||
|
ArrayList<Object> list = new ArrayList<>();
|
||||||
|
List<CheckContent> list_contents = CheckContent.dao
|
||||||
|
.find("select * from check_content");
|
||||||
|
int len_contents = list_contents.size();
|
||||||
|
for (int i = 0; i < len_contents; i++) {
|
||||||
|
CheckContent checkContent = list_contents.get(i);
|
||||||
|
int check_content_id = checkContent.getInt("check_content_id");
|
||||||
|
String check_content = checkContent.getStr("check_content");
|
||||||
|
|
||||||
|
ArrayList<Object> items = new ArrayList<>();
|
||||||
|
List<CheckItem> list_items = CheckItem.dao.find(
|
||||||
|
"select * from check_item where check_content_id = ?",
|
||||||
|
check_content_id);
|
||||||
|
int len_items = list_items.size();
|
||||||
|
for (int j = 0; j < len_items; j++) {
|
||||||
|
CheckItem checkItem = list_items.get(j);
|
||||||
|
String check_item = checkItem.getStr("check_item");
|
||||||
|
int table_sequence = checkItem.getLong("table_sequence")
|
||||||
|
.intValue();
|
||||||
|
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("item", check_content_id + "." + table_sequence
|
||||||
|
+ check_item);
|
||||||
|
item.put("passed", "0");
|
||||||
|
item.put("note", "");
|
||||||
|
item.put("pic_url", "");
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("No", check_content_id);
|
||||||
|
map.put("content", check_content);
|
||||||
|
map.put("items", items);
|
||||||
|
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean updateByJSONObject(JSONObject jsonObject) {
|
public boolean updateByJSONObject(JSONObject jsonObject) {
|
||||||
|
|
||||||
if (jsonObject.has("report_id")) {
|
if (jsonObject.has("report_id")) {
|
||||||
@@ -209,6 +256,131 @@ public class Report extends Model<Report> {
|
|||||||
});
|
});
|
||||||
return succeed;
|
return succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean update(Map<String, Object> map) {
|
||||||
|
if (map.get("report_id") != null) {
|
||||||
|
return edit(map);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private boolean edit(Map<String, Object> map) {
|
||||||
|
|
||||||
|
final String report_id = (String) map.get("report_id");
|
||||||
|
|
||||||
|
final String report_name = (String) map.get("report_name");
|
||||||
|
final String report_creator = (String) map.get("report_creator");
|
||||||
|
|
||||||
|
final List<UploadFile> list_uf = (List<UploadFile>) map.get("list_uf");
|
||||||
|
|
||||||
|
final ArrayList<Object> items = (ArrayList<Object>) map.get("items");
|
||||||
|
|
||||||
|
if (report_id.equals("add")) {
|
||||||
|
String report_create_time = new SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||||
|
|
||||||
|
if (report_name.equals("") || report_creator.equals("")) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (new Report().set("report_name", report_name)
|
||||||
|
.set("report_creator", report_creator)
|
||||||
|
.set("report_create_time", report_create_time).save()) {
|
||||||
|
Report report_add = dao
|
||||||
|
.findFirst(
|
||||||
|
"select * from report where report_name = ? and report_creator = ?",
|
||||||
|
report_name, report_creator);
|
||||||
|
int report_id_add = report_add.getInt("report_id");
|
||||||
|
|
||||||
|
List<CheckItem> list_checkItems = CheckItem.dao
|
||||||
|
.find("select * from check_item");
|
||||||
|
for (int i = 0; i < list_checkItems.size(); i++) {
|
||||||
|
CheckItem checkItem = list_checkItems.get(i);
|
||||||
|
|
||||||
|
int check_item_id = checkItem.getInt("check_item_id");
|
||||||
|
|
||||||
|
if (!new CheckRecord().set("report_id", report_id_add)
|
||||||
|
.set("check_item_id", check_item_id).save()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmp_report_id = report_id_add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean succeed = Db.tx(new IAtom() {
|
||||||
|
public boolean run() throws SQLException {
|
||||||
|
int _report_id;
|
||||||
|
if (report_id.equals("add")) {
|
||||||
|
_report_id = tmp_report_id;
|
||||||
|
} else {
|
||||||
|
_report_id = Integer.parseInt(report_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean editCheckReports = true;
|
||||||
|
editCheckReports = dao.findById(_report_id)
|
||||||
|
.set("report_name", report_name)
|
||||||
|
.set("report_creator", report_creator).update();
|
||||||
|
|
||||||
|
boolean editCheckRecords = true;
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
Map<String, Object> map1 = (Map<String, Object>) items
|
||||||
|
.get(i);
|
||||||
|
int check_item_id = (int) map1.get("check_item_id");
|
||||||
|
|
||||||
|
CheckRecord checkRecord = CheckRecord.dao
|
||||||
|
.findFirst(
|
||||||
|
"select * from check_record where report_id = ? and check_item_id = ?",
|
||||||
|
_report_id, check_item_id);
|
||||||
|
editCheckRecords = checkRecord.setAttrs(map1).update();
|
||||||
|
if (!editCheckRecords) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean editCheckRecordsPic_url = true;
|
||||||
|
for (int i = 0; i < list_uf.size(); i++) {
|
||||||
|
UploadFile uf = list_uf.get(i);
|
||||||
|
|
||||||
|
String pic_url_name = uf.getParameterName();
|
||||||
|
String[] para = pic_url_name.split("_");
|
||||||
|
|
||||||
|
int check_content_id = Integer.parseInt(para[2]);
|
||||||
|
int table_sequence = Integer.parseInt(para[3]);
|
||||||
|
|
||||||
|
String saveDirectory = "/upload"
|
||||||
|
+ File.separator
|
||||||
|
+ new SimpleDateFormat("yyyyMMdd")
|
||||||
|
.format(new Date());
|
||||||
|
String pic_url = saveDirectory + File.separator
|
||||||
|
+ uf.getFileName();
|
||||||
|
|
||||||
|
CheckItem checkItem = CheckItem.dao
|
||||||
|
.findFirst(
|
||||||
|
"select * from check_item where check_content_id = ? and table_sequence = ?",
|
||||||
|
check_content_id, table_sequence);
|
||||||
|
int check_item_id = checkItem.getInt("check_item_id");
|
||||||
|
|
||||||
|
CheckRecord checkRecord = CheckRecord.dao
|
||||||
|
.findFirst(
|
||||||
|
"select * from check_record where report_id = ? and check_item_id = ?",
|
||||||
|
report_id, check_item_id);
|
||||||
|
editCheckRecordsPic_url = checkRecord.set("pic_url",
|
||||||
|
pic_url).update();
|
||||||
|
if (!editCheckRecordsPic_url) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return editCheckRecords && editCheckReports
|
||||||
|
&& editCheckRecordsPic_url;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return succeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@@ -250,12 +422,12 @@ class SortItemsByNo implements Comparator {
|
|||||||
if (char1 <= 57 && char1 >= 48) {
|
if (char1 <= 57 && char1 >= 48) {
|
||||||
no1 = Integer.valueOf(s1.substring(2, 4));
|
no1 = Integer.valueOf(s1.substring(2, 4));
|
||||||
} else {
|
} else {
|
||||||
no1 = Integer.valueOf(s1.substring(2,3));
|
no1 = Integer.valueOf(s1.substring(2, 3));
|
||||||
}
|
}
|
||||||
if (char2 <= 57 && char2 >= 48) {
|
if (char2 <= 57 && char2 >= 48) {
|
||||||
no2 = Integer.valueOf(s2.substring(2, 4));
|
no2 = Integer.valueOf(s2.substring(2, 4));
|
||||||
} else {
|
} else {
|
||||||
no2 = Integer.valueOf(s2.substring(2,3));
|
no2 = Integer.valueOf(s2.substring(2, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no1 > no2)
|
if (no1 > no2)
|
||||||
|
|||||||
Reference in New Issue
Block a user