Browse Source

题目管理完善

master
yanyan 3 years ago
parent
commit
d853ccdd9b
  1. 3
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml
  2. 220
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/add.html
  3. 16
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bind.html
  4. 264
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/detail.html
  5. 191
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/edit.html
  6. 30
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/scene/manage.html
  7. 1
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneManageController.java
  8. 64
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java
  9. 20
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneQuestionService.java
  10. 51
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneQuestionServiceImpl.java
  11. 2
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml

3
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml

@ -10,7 +10,8 @@ ruoyi:
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
# profile: E:/ruoyi/uploadPath
profile: /Users/kylin_stone/Workspaces/uploads
# profile: /Users/kylin_stone/Workspaces/uploads
profile: /Users/yan/upload
# 获取ip地址开关
addressEnabled: true

220
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/add.html

@ -1,51 +1,195 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="zdxtInclude :: header('新增场景题目')" />
<th:block th:include="zdxtInclude :: header('新增场景题目')"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-add">
<input name="parentId" type="text" hidden>
<div class="form-group">
<label class="col-sm-3 control-label">题目名称:</label>
<div class="col-sm-8">
<input name="name" class="form-control" type="text">
</div>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" enctype="multipart/form-data" id="form-question-add" type="text/template">
<input name="parentId" type="text" hidden>
<div class="form-group" id="textTitle" hidden>
<label class="col-sm-3 control-label">题目:</label>
<div class="col-sm-8">
<input name="name" class="form-control" type="text">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status" class="form-control">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
<div class="form-group" id="fileTitle" hidden>
<label class="col-sm-3 control-label">题目:</label>
<div id="fileIn" class="col-sm-8">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div class="form-group" shiro:hasPermission="system:user:isAllow">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status" class="form-control">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
var prefix = ctx + "project/question"
$("#form-question-add").validate({
focusCleanup: true
});
</div>
<div class="form-group" shiro:hasPermission="system:user:isAllow">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}"
th:checked="${role.flag}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript" th:inline="javascript">
var type = [[${type}]];
var parentId = [[${parentId}]];
var prefix = ctx + "project/question"
function submitHandler() {
if ($.validate.form()) {
var parentId = [[${parentId}]];
$("[name='parentId']").val(parentId);
$.operate.save(prefix + "/add", $('#form-question-add').serialize());
$("#form-question-add").validate({
focusCleanup: true
});
$(function() {
// 渲染文件要素信息
renderVersionAtt();
})
if (type === 0) {
$("#textTitle").show();
} else {
$("#fileTitle").show();
}
function submitHandler() {
if ($.validate.form()) {
$('#fileInput').fileinput('upload');
// var parentId = [[${parentId}]];
// $("[name='parentId']").val(parentId);
// $.operate.save(prefix + "/add", $('#form-question-add').serialize());
}
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
$("#fileInput").fileinput('clear')
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/add", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
</script>
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-question-add").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i=0; i<arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
var parentId = [[${parentId}]];
data.parentId = parentId;
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
// actionDelete: ''//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
};
/** 文件上传回调 */
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
}
</script>
</body>
</html>

16
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bind.html

@ -17,8 +17,8 @@
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
@ -31,8 +31,8 @@
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
@ -45,8 +45,8 @@
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
@ -59,8 +59,8 @@
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select th:each="li:${list}" class="form-control">
<option th:value="${li.id}" th:text="${li.name}"></option>
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>

264
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/detail.html

@ -1,52 +1,240 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="zdxtInclude :: header('场景题目详情')" />
<th:block th:include="zdxtInclude :: header('场景题目详情')"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
<style>
.file-caption-main {
display: none;
}
</style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-detail" th:object="${sceneQuestion}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">题目名称:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text" readonly>
</div>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-detail" th:object="${sceneQuestion}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group" id="textTitle" hidden>
<label class="col-sm-3 control-label">题目:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text" readonly>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status" class="form-control" th:field="*{status}" readonly>
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
<div class="form-group" id="fileTitle" hidden>
<label class="col-sm-3 control-label">题目:</label>
<div id="fileIn" class="col-sm-8" readonly>
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建人:</label>
<div class="col-sm-8">
<input name="creator" th:field="*{creator}" class="form-control" type="text" readonly>
<div id="fileOut" class="col-sm-8" style="display: none" readonly>
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建时间:</label>
<div class="col-sm-8">
<input name="createTime" th:field="*{createTime}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<select name="status" class="form-control" th:field="*{status}" readonly>
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${sceneQuestion.roleId.contains(role.roleId.toString())}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建人:</label>
<div class="col-sm-8">
<input name="creator" th:field="*{creator}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">创建时间:</label>
<div class="col-sm-8">
<input name="createTime" th:field="*{createTime}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="roleId" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}"
th:checked="${sceneQuestion.roleId.contains(role.roleId.toString())}"
th:disabled="${role.status == '1'}">
</label>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "project/question";
var sceneObj = [[${sceneQuestion}]];
if (sceneObj.name == null || sceneObj.name === "") {
$("#fileTitle").show();
} else {
$("#textTitle").show();
}
$(function () {
// 渲染文件要素信息
renderVersionAtt();
})
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = $("[name='id']").val();
$.getJSON(prefix + "/queryFiles/" + key, function (result) {
if (result.data != null) {
$("#fileIn").hide();
$("#fileOut").show();
// 重置文件预览框
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>");
queryFiles(key);
isFlieIn = false;
} else {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
isFlieIn = true;
$("#fileInput").fileinput('clear')
}
});
}
/** 预览附件 */
function queryFiles(key) {
$.ajax({
type: "POST",
url: prefix + "/queryFilesPost",
data: {"key": key},
dataType: 'json',
success: function (result) {
if (result.success == true) {
initFile("fileOutput", prefix + "/edit", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = {fileList: null, previewRespDTOS: null}
initFile("fileInput", prefix + "/edit", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-question-edit").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i = 0; i < arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
actionDelete: '',//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
// 同步上传成功回调
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
};
</script>
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
// $.modal.closeLoading();
// $.modal.msgReload(result.message, modal_status.SUCCESS);
}
</script>
</body>
</html>

191
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/edit.html

@ -2,17 +2,31 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('修改场景题目')" />
<th:block th:include="zdxtInclude :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-edit" th:object="${sceneQuestion}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<div class="form-group" id="textTitle" hidden>
<label class="col-sm-3 control-label">题目名称:</label>
<div class="col-sm-8">
<input name="name" th:field="*{name}" class="form-control" type="text">
</div>
</div>
<div class="form-group" id="fileTitle" hidden>
<label class="col-sm-3 control-label">题目:</label>
<div id="fileIn" class="col-sm-8">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div id="fileOut" class="col-sm-8" style="display: none">
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
@ -33,16 +47,187 @@
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript" th:inline="javascript">
var type = [[${type}]];
var prefix = ctx + "project/question";
$("#form-question-edit").validate({
focusCleanup: true
});
$(function() {
// 渲染文件要素信息
renderVersionAtt();
})
if (type === 0) {
$("#textTitle").show();
} else if (type === 1) {
$("#fileWarn").html("提示:请导入图片格式文件!");
$("#fileTitle").show();
} else if (type === 2) {
$("#fileWarn").html("提示:请导入视频格式文件!");
$("#fileTitle").show();
}
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-question-edit').serialize());
$('#fileInput').fileinput('upload');
// $.operate.save(prefix + "/edit", $('#form-question-edit').serialize());
}
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = $("[name='id']").val();
$.getJSON(prefix + "/queryFiles/" + key, function (result) {
if (result.data != null) {
$("#fileIn").hide();
$("#fileOut").show();
// 重置文件预览框
$("#fileOut").html("<div class=\"file-loading\"><input id=\"fileOutput\" name=\"file\" type=\"file\" multiple></div>");
queryFiles(key);
isFlieIn = false;
} else {
$("#fileIn").show();
$("#fileOut").hide();
uploadFiles();
isFlieIn = true;
$("#fileInput").fileinput('clear')
}
});
}
/** 预览附件 */
function queryFiles(key) {
$.ajax({
type: "POST",
url: prefix + "/queryFilesPost",
data: {"key": key},
dataType: 'json',
success: function (result) {
if (result.success == true) {
initFile("fileOutput", prefix + "/edit", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/edit", filePreview);
}
/** 初始化文件 */
function initFile(elementId, url, filePreview) {
var preview = filePreview.previewRespDTOS;
if (preview != null) {
for (var i = 0; i < preview.length; i++) {
// 图片删除的地址
preview[i].url = prefix + "/removeFile"
}
}
$("#" + elementId).fileinput({
'theme': 'explorer',
initialPreviewAsData: true,
dropZoneEnabled: true,
dropZoneTitle: "上传图片或视频",
uploadUrl: url,
uploadAsync: false,//异步上传
enctype: 'multipart/form-data',
showClose: false,
showPreview: true,
showUpload: false,
uploadExtraData: function () {
var formData = $("#form-question-edit").serialize();
formData = decodeURIComponent(formData, true);
var arr = formData.split("&");
var data = {};
for (var i=0; i<arr.length; i++) {
var item = arr[i].split('=');
var value = item[1].replace("+", " ");
data[item[0]] = value;
}
return data;
},
// showBrowse: false,
previewFileIcon: '<i class="fas fa-file"></i>',
preferIconicPreview: true,
previewFileIconSettings: { // configure your icon file extensions
'doc': '<i class="fa fa-file-word-o text-primary"></i>',
'xls': '<i class="fa fa-file-excel-o text-success"></i>',
'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
'txt': '<i class="fa fa-file-text-o text-info"></i>',
'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
'htm': '<i class="fa fa-file-code-o text-info"></i>',
'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
'mp3': '<i class="fa fa-file-audio-o text-warning"></i>'
},
previewFileExtSettings: {
'doc': function (ext) {
return ext.match(/(doc|docx)$/i);
},
'xls': function (ext) {
return ext.match(/(xls|xlsx)$/i);
},
'ppt': function (ext) {
return ext.match(/(ppt|pptx)$/i);
},
'zip': function (ext) {
return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
},
'htm': function (ext) {
return ext.match(/(htm|html)$/i);
},
'mov': function (ext) {
return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
},
'mp3': function (ext) {
return ext.match(/(mp3|wav)$/i);
},
'txt': function (ext) {
return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
}
},
layoutTemplates: {
// actionDelete: ''//去掉删除按钮
actionUpload: '' // 去掉上传按钮
},
initialPreview: filePreview.fileList == null ? [] : filePreview.fileList,
initialPreviewConfig: preview == null ? [] : preview
});
// 同步上传成功回调
$("#fileInput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
// 同步上传成功回调
$("#fileOutput").on("filebatchuploadsuccess", function (event, data, previewId, index) {
fileUploadCallBack(data.response);
})
};
function fileUploadCallBack(result) {
var parent = window.parent;
if (result.success) {
parent.$.modal.msgSuccess(result.message);
} else {
$.modal.alertError(result.message);
}
$.modal.close();
parent.$.table.refresh();
// $.modal.closeLoading();
// $.modal.msgReload(result.message, modal_status.SUCCESS);
}
</script>
</body>

30
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/scene/manage.html

@ -152,19 +152,19 @@
$.table.init(options);
});
function exportWord() {
table.set();
var row = $("#" + table.options.id).bootstrapTable('getSelections')[0];
if ($.common.isEmpty(row)) {
$.modal.alertWarning("请选择您要导出的记录");
return;
}
if (row.length > 0) {
$.modal.alertWarning("只能选择一条记录");
return;
}
window.location.href = prefix + "/export/" + row.guid;
}
// function exportWord() {
// table.set();
// var row = $("#" + table.options.id).bootstrapTable('getSelections')[0];
// if ($.common.isEmpty(row)) {
// $.modal.alertWarning("请选择您要导出的记录");
// return;
// }
// if (row.length > 0) {
// $.modal.alertWarning("只能选择一条记录");
// return;
// }
// window.location.href = prefix + "/export/" + row.guid;
// }
function detailFull(id) {
table.set();
@ -190,9 +190,7 @@
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
<input type="checkbox" id="updateSupport" name="updateSupport"
title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
&nbsp; <a href="/scene/manage/importTemplate"><i class="fa fa-file-excel-o"></i> 下载模板</a>
<a href="/scene/manage/importTemplate"><i class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
<font color="red" class="pull-left mt10">
提示:仅允许导入“xls”或“xlsx”格式文件!

1
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneManageController.java

@ -131,6 +131,7 @@ public class SceneManageController extends BaseController {
* 删除
*/
@PostMapping("/importData")
@ResponseBody
@ApiOperation("导入记录")
public ZDResponse importRecord(@RequestPart("file") MultipartFile multipartFile) {
return sceneManageService.importData(multipartFile);

64
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java

@ -4,7 +4,9 @@ import com.zdxt.auth.feign.RoleApi;
import com.zdxt.common.ZDResponse;
import com.zdxt.common.controller.BaseController;
import com.zdxt.common.util.TableDataInfo;
import com.zdxt.knowledge.domain.SceneManage;
import com.zdxt.knowledge.domain.SceneQuestion;
import com.zdxt.knowledge.mapper.SceneManageMapper;
import com.zdxt.knowledge.service.ISceneQuestionService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -12,8 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -32,6 +35,9 @@ public class SceneQuestionController extends BaseController {
@Autowired
private ISceneQuestionService sceneQuestionService;
@Autowired
private SceneManageMapper sceneManageMapper;
@Autowired
private RoleApi roleApi;
@ -94,7 +100,9 @@ public class SceneQuestionController extends BaseController {
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
SceneManage sceneManage = sceneManageMapper.selectSceneManageById(parentId);
mmap.put("parentId", parentId);
mmap.put("type", sceneManage.getType());
mmap.put("roles", roleApi.getRolesAll());
return prefix + "/add";
}
@ -105,8 +113,8 @@ public class SceneQuestionController extends BaseController {
@RequiresPermissions("project:question:add")
@PostMapping("/add")
@ResponseBody
public ZDResponse addSave(SceneQuestion sceneQuestion) {
return sceneQuestionService.insertSceneQuestion(sceneQuestion) > 0
public ZDResponse addSave(@RequestParam("file") MultipartFile[] files, SceneQuestion sceneQuestion) {
return sceneQuestionService.insertSceneQuestion(files, sceneQuestion) > 0
? ZDResponse.success() : ZDResponse.error("新增失败");
}
@ -116,8 +124,10 @@ public class SceneQuestionController extends BaseController {
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(id);
SceneManage sceneManage = sceneManageMapper.selectSceneManageById(sceneQuestion.getParentId());
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("roles", roleApi.getRolesAll());
mmap.put("type", sceneManage.getType());
return prefix + "/edit";
}
@ -127,8 +137,8 @@ public class SceneQuestionController extends BaseController {
@RequiresPermissions("project:question:edit")
@PostMapping("/edit")
@ResponseBody
public ZDResponse editSave(SceneQuestion sceneQuestion) {
return sceneQuestionService.updateSceneQuestion(sceneQuestion) > 0
public ZDResponse editSave(@RequestParam("file") MultipartFile[] files, SceneQuestion sceneQuestion) {
return sceneQuestionService.updateSceneQuestion(files, sceneQuestion) > 0
? ZDResponse.success() : ZDResponse.error("修改失败");
}
@ -143,6 +153,50 @@ public class SceneQuestionController extends BaseController {
? ZDResponse.success() : ZDResponse.error("删除失败");
}
/**
* 查询附件信息
*
* @param key
* @return
*/
@GetMapping("/queryFiles/{key}")
@ResponseBody
public ZDResponse queryFiles(@PathVariable String key) {
HashMap<String, Object> map = new HashMap<>();
map.put("filePreview", sceneQuestionService.queryFiles(key));
return ZDResponse.success("获取成功", map);
}
/**
* 查询附件信息
*
* @param key
* @return
*/
@PostMapping("/queryFilesPost")
@ResponseBody
public ZDResponse queryFilesPost(String key) {
HashMap<String, Object> map = new HashMap<>();
map.put("filePreview", sceneQuestionService.queryFiles(key));
return ZDResponse.success("获取成功", map);
}
/**
* 删除案例要素附件
*
* @param key
* @return
*/
@PostMapping("/removeFile")
@ResponseBody
public ZDResponse removeFile(String key) {
if (sceneQuestionService.removeFile(key) > 0) {
return ZDResponse.success("操作成功");
} else {
return ZDResponse.error("操作失败");
}
}
/**
* 绑定场景题目
*/

20
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneQuestionService.java

@ -1,6 +1,8 @@
package com.zdxt.knowledge.service;
import com.zdxt.common.zdxtFile.AttFileRespDTO;
import com.zdxt.knowledge.domain.SceneQuestion;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -34,7 +36,7 @@ public interface ISceneQuestionService
* @param sceneQuestion 场景题目
* @return 结果
*/
public int insertSceneQuestion(SceneQuestion sceneQuestion);
public int insertSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion);
/**
* 修改场景题目
@ -42,7 +44,7 @@ public interface ISceneQuestionService
* @param sceneQuestion 场景题目
* @return 结果
*/
public int updateSceneQuestion(SceneQuestion sceneQuestion);
public int updateSceneQuestion(MultipartFile[] files,SceneQuestion sceneQuestion);
/**
* 批量删除场景题目
@ -67,4 +69,18 @@ public interface ISceneQuestionService
* @return 结果
*/
public int bindAnswer(SceneQuestion sceneQuestion);
/**
* 查询附件
* @param key
* @return
*/
AttFileRespDTO queryFiles(String key);
/**
* 删除案例要素图片
* @param key 图片id
* @return
*/
public int removeFile(String key);
}

51
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneQuestionServiceImpl.java

@ -1,18 +1,28 @@
package com.zdxt.knowledge.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.zdxt.auth.dto.RoleBean;
import com.zdxt.auth.dto.UserBean;
import com.zdxt.auth.dto.ZdxtFileBean;
import com.zdxt.auth.feign.FileUploadApi;
import com.zdxt.auth.feign.RoleApi;
import com.zdxt.auth.feign.UserApi;
import com.zdxt.auth.feign.ZdxtFileCommonApi;
import com.zdxt.common.util.Convert;
import com.zdxt.common.util.DateUtils;
import com.zdxt.common.zdxtFile.AttFileRespDTO;
import com.zdxt.common.zdxtFile.FilePreviewUtilBean;
import com.zdxt.common.zdxtFile.ZdxtFileCommon;
import com.zdxt.knowledge.domain.SceneQuestion;
import com.zdxt.knowledge.mapper.SceneQuestionMapper;
import com.zdxt.knowledge.service.ISceneQuestionService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -28,12 +38,14 @@ import java.util.stream.Collectors;
public class SceneQuestionServiceImpl implements ISceneQuestionService {
@Autowired
private SceneQuestionMapper sceneQuestionMapper;
@Autowired
private UserApi userApi;
@Autowired
private RoleApi roleApi;
@Autowired
private FileUploadApi fileUploadApi;
@Autowired
private ZdxtFileCommonApi zdxtFileCommonApi;
/**
* 查询场景题目
@ -82,13 +94,20 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
* @return 结果
*/
@Override
public int insertSceneQuestion(SceneQuestion sceneQuestion) {
public int insertSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion) {
UserBean userBean = userApi.getCurrentUser();
if (Objects.nonNull(userBean)) {
sceneQuestion.setCreator(userBean.getUserName());
sceneQuestion.setCreateTime(DateUtils.getNowDate());
}
return sceneQuestionMapper.insertSceneQuestion(sceneQuestion);
int result = sceneQuestionMapper.insertSceneQuestion(sceneQuestion);
// 上传文件,并在附件表中添加记录
if (result > 0 && ObjectUtil.isNotEmpty(files)) {
for (MultipartFile file : files) {
zdxtFileCommonApi.insertZdxtFile(file, sceneQuestion.getId() + "", fileUploadApi.upload(file));
}
}
return result;
}
/**
@ -98,7 +117,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
* @return 结果
*/
@Override
public int updateSceneQuestion(SceneQuestion sceneQuestion) {
public int updateSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion) {
sceneQuestion.setUpdateTime(DateUtils.getNowDate());
return sceneQuestionMapper.updateSceneQuestion(sceneQuestion);
}
@ -125,6 +144,28 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
return sceneQuestionMapper.deleteSceneQuestionById(id);
}
@Override
public AttFileRespDTO queryFiles(String key) {
ZdxtFileBean zdxtFileBeanCondition = new ZdxtFileBean();
zdxtFileBeanCondition.setBusinessId(key);
List<ZdxtFileBean> fileBeanList = zdxtFileCommonApi.selectZdxtFileList(zdxtFileBeanCondition);
ArrayList<ZdxtFileCommon> fileList = new ArrayList<>();
for (ZdxtFileBean fileBean : fileBeanList) {
ZdxtFileCommon zdxtFileCommon = new ZdxtFileCommon();
BeanUtil.copyProperties(fileBean, zdxtFileCommon);
fileList.add(zdxtFileCommon);
}
FilePreviewUtilBean filePreviewUtilBean = new FilePreviewUtilBean();
return filePreviewUtilBean.attachementToAttFileRespDTO(fileList);
}
@Override
public int removeFile(String key) {
return zdxtFileCommonApi.deleteZdxtFileById(key);
}
/**
* 绑定场景题目信息
*

2
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneQuestionMapper.xml

@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<insert id="insertSceneQuestion" parameterType="SceneQuestion">
<insert id="insertSceneQuestion" parameterType="SceneQuestion" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into scene_question
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null ">id,</if>

Loading…
Cancel
Save