Browse Source

场景演练角色题目绑定

master
yanyan 3 years ago
parent
commit
6b5d0e050a
  1. 2
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/static/ajax/libs/hui/css/H-ui.css
  2. 4
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/static/drawflow/docs/beautiful.css
  3. 315
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/addNew.html
  4. 125
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bind.html
  5. 143
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bindNew.html
  6. 596
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/index.html
  7. 16
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/view.html
  8. 46
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/add.html
  9. 41
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/edit.html
  10. 136
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/view.html
  11. 11
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/scene/manage.html
  12. 89
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneQuestionController.java
  13. 116
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneRoleController.java
  14. 147
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneRole.java
  15. 53
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/SceneRoleMapper.java
  16. 25
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneQuestionService.java
  17. 54
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneRoleService.java
  18. 56
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneQuestionServiceImpl.java
  19. 97
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneRoleServiceImpl.java
  20. 97
      lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneRoleMapper.xml

2
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/static/ajax/libs/hui/css/H-ui.css

@ -1552,7 +1552,7 @@ input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit
.w-300{width:300px}
.w-200{width:200px}
@media (max-width: 1000px) {
.Hui-wraper,.wp,{ width:auto!important;padding:0 15px!important}
.Hui-wraper,.wp{ width:auto!important;padding:0 15px!important}
}
@media print{
.Hui-wraper{width:auto}

4
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/static/drawflow/docs/beautiful.css

@ -15,7 +15,7 @@ html, body {
}
header {
height: 66px;
height: 30px;
border-bottom: 1px solid var(--border-color);
padding-left: 20px;
}
@ -52,7 +52,7 @@ header a {
.col {
overflow: auto;
width: 300px;
width: 200px;
height: 100%;
border-right: 1px solid var(--border-color);
}

315
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/addNew.html

@ -0,0 +1,315 @@
<!DOCTYPE html>
<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" enctype="multipart/form-data" id="form-question-add" type="text/template" th:object="${sceneQuestion}">
<div class="form-group">
<label class="col-sm-3 control-label">题目:</label>
<div class="col-sm-8">
<div id="fileIn">
<div class="file-loading">
<input id="fileInput" name="file" type="file" multiple>
</div>
</div>
<div id="fileOut" style="display: none">
<div class="file-loading">
<input id="fileOutput" name="file" type="file" multiple>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">答案:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="answer" id="answer" placeholder="多选以逗号分隔" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">选项:</label>
<div class="col-sm-8">
<table id="tab11" style="display: none">
<tbody>
<tr>
<td height="30" align="center"><input type="text" name="NO" size="2" value="1" style="text-align: center;" disabled /></td>
<td width="30" align="center"><input type="text" name="identify" value="A" style="width: 30px; text-align: center;"/></td>
<td align="center"><input type="text" name="qContent" style="width: 100%;" /></td>
<td><input type="button" id="Button1" onClick="deltr(this)" value="删行"></td>
</tr>
</tbody>
</table>
<input type="button" id="btn_addtr" value="增行">
<table id="dynamicTable" width="500" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td height="30" align="center" bgcolor="#CCCCCC">ID</td>
<td width="30" align="center" bgcolor="#CCCCCC">标识</td>
<td align="center" bgcolor="#CCCCCC">内容</td>
<td width="30" align="center" bgcolor="#CCCCCC">操作</td>
<td></td>
</tr>
</thead>
<tbody id="answerTrFlag">
<tr>
<td height="30" align="center"><input type="text" name="NO" size="2" value="1" style="text-align: center;" disabled /></td>
<td width="30" align="center"><input type="text" name="identify" value="A" style="width: 30px; text-align: center;"/></td>
<td align="center"><input type="text" name="qContent" style="width: 100%;" /></td>
<td><input type="button" id="Button2" onClick="deltr(this)" value="删行"></td>
</tr>
</tbody>
</table>
</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 prefix = ctx + "project/question"
$("#form-question-add").validate({
focusCleanup: true
});
// 当前文件框id,是不是fileInput
var isFlieIn = true;
$(function() {
// 渲染要素信息
renderVersionAtt();
})
function submitHandler() {
if (isFlieIn) {
$('#fileInput').fileinput('upload');
} else {
$('#fileOutput').fileinput('upload');
}
}
/** 附件相关 */
/** 渲染附件信息 */
function renderVersionAtt() {
var key = [[${guid}]];
$.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 + "/addSaveNew", result.data.filePreview);
}
},
error: function (error) {
$.modal.alertWarning("附件预览失败!");
}
});
}
/** 上传附件 */
function uploadFiles() {
var filePreview = { fileList: null, previewRespDTOS: null }
initFile("fileInput", prefix + "/addSaveNew", 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-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 optionList = new Array();
var j = 0;
$('input[name="identify"]').each(function () {
if (j !== 0) {
let option = {}
option.identify = $(this).val();
option.content = $(this).parent().next().children().val();
optionList.push(option);
}
j++;
});
data.option = JSON.stringify(optionList);
data.parentId = [[${parentId}]];
data.guid = [[${guid}]];
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);
}
/** 动态表格 */
$(function () {
var sceneQuestion = [[${sceneQuestion}]]
if(sceneQuestion!=null){
var answers = JSON.parse(sceneQuestion.option);
var html = "";
for (var i=0; i<answers.length; i++) {
var answer = answers[i];
html += '<tr>';
html += '<td height="30" align="center"><input type="text" name="NO" size="2" value="'+(i+1)+'" style="text-align: center;" disabled/></td>';
html += '<td width="30" align="center"><input type="text" name="identify" value="'+answer.identify+'" style="width: 30px; text-align: center;"/></td>';
html += '<td align="center"><input type="text" name="qContent" value="'+answer.content+'" style="width: 100%;"/></td>';
html += '</tr>';
}
$("input[name='answer']").val(sceneQuestion.answer);
$("#answerTrFlag").html(html);
}
var show_count = 8; //要显示的条数
var count = 1; //递增的开始值,这里是你的ID
$("#btn_addtr").click(function () {
var length = $("#dynamicTable tbody tr").length;
//alert(length);
if (length < show_count) //点击时候,如果当前的数字小于递增结束的条件
{
$("#tab11 tbody tr").clone().appendTo("#dynamicTable tbody"); //在表格后面添加一行
changeIndex();//更新行号
}
});
});
function changeIndex() {
var c = ['0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
var i = 1;
$("#dynamicTable tbody tr").each(function () { //循环tab tbody下的tr
// console.log(i)
$(this).find("input[name='NO']").val(i);//更新行号
$(this).find("input[name='identify']").val(c[i]);//更新标号
i++;
});
}
function deltr(opp) {
var length = $("#dynamicTable tbody tr").length;
//alert(length);
if (length <= 1) {
alert("至少保留一行");
} else {
$(opp).parent().parent().remove();//移除当前行
changeIndex();
}
}
</script>
</body>
</html>

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

@ -1,125 +0,0 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="zdxtInclude :: header('场景题目绑定')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-question-bind" th:object="${sceneQuestion}">
<h2 th:text="*{name}" style="margin-bottom: 30px;"></h2>
<input name="guid" th:field="*{guid}" type="hidden">
<div class="form-group">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="A...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="B...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="C...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<input name="answer" class="form-control" type="text" placeholder="D...">
</div>
<div class="col-sm-2" style="width: 12%">
<input type="checkbox" name="check" onclick="inputCheck(this)">
<span>正确</span>
</div>
<div class="col-sm-4" style="display: none">
<select class="form-control">
<option th:each="li : ${list}" th:text="${li.id}" th:value="${li.id}"></option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "project/question"
$("#form-question-add").validate({
focusCleanup: true
});
function inputCheck(obj) {
if ($(obj).prop('checked')) {
// 还原之前样式
$("[name='check']").prop('checked', false);
// $("[name='select']").val("");
$(".col-sm-4").hide();
//选中当前样式
$(obj).prop('checked', true)
$(obj).parent().next().show();
} else {
$(obj).parent().next().hide();
}
}
function submitHandler() {
if ($.validate.form()) {
var reqData = {};
var nextQuestionId;
var reqList = new Array();
var checkFlag = false;
var elements = document.getElementsByName("answer");
for (let i = 0; i < document.getElementsByName("answer").length; i++) {
if (elements[i].value === "") {
$.modal.alertWarning("请将选项填写完整");
return;
}
var req = {};
req.answer = elements[i].value;
req.check = elements[i].parentElement.nextElementSibling.firstElementChild.checked;
checkFlag = checkFlag === true ? true : req.check;
reqList.push(req);
debugger
if (req.check) {
let divData = elements[i].parentElement.nextElementSibling.nextElementSibling;
nextQuestionId = $(divData).find("select").val();
}
}
if (!checkFlag) {
$.modal.alertWarning("请勾选一个正确选项");
return;
}
reqData.id = $("[name = 'id']").val();
reqData.nextQuestionId = nextQuestionId;
reqData.answer = JSON.stringify(reqList);
$.operate.save(prefix + "/bindAnswer", reqData);
}
}
</script>
</body>
</html>

143
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/bindNew.html

@ -1,143 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Tree Diagram with Tooltips</title>
<style>
.card {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
width: 120px;
height: 50px;
cursor: pointer;
}
.card text {
font-size: 14px;
font-family: sans-serif;
}
.tooltip {
position: absolute;
text-align: center;
padding: 10px;
font-size: 14px;
font-family: sans-serif;
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 5px;
pointer-events: none;
visibility: hidden;
}
.link {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}
</style>
</head>
<body>
<div id="tree"></div>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script>
// 树形结构数据
// var treeData = {
// "name": "Root",
// "children": [
// {
// "name": "Node 1",
// "children": [
// {"name": "Leaf 1"},
// ]
// },
// {
// "name": "Node 2",
// "children": [
// {"name": "Leaf 1"}
// ]
// }
// ]
// };
var treeData = {
"name": "Root",
"children": [
{
"name": "Node 1",
"children": [
{"name": "Leaf 1"},
]
}
]
};
// 定义画布大小和边距
var margin = {top: 20, right: 120, bottom: 20, left: 120},
width = 600 - margin.right - margin.left,
height = 300 - margin.top - margin.bottom;
// 定义树形布局
var treemap = d3.tree()
.size([height, width]);
// 为数据设置层级关系
var root = d3.hierarchy(treeData);
// 计算节点位置
treemap(root);
// 创建SVG画布
var svg = d3.select("#tree")
.append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// 添加节点组
var node = svg.selectAll(".node")
.data(root.descendants())
.enter()
.append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
.on("mouseover", function(d) {
tooltip.style("visibility", "visible");
tooltip.text(d.data.name);
})
.on("mousemove", function(d) {
tooltip.style("top", (d3.event.pageY-10)+"px").style("left",(d3.event.pageX+10)+"px");
})
.on("mouseout", function(d) {
tooltip.style("visibility", "hidden");
});
// 添加节点卡片
node.append("rect")
.attr("class", "card");
// 添加节点标签
node.append("text")
.attr("dy", 20)
.attr("dx", 6)
.text(function(d) { return d.data.name; });
// 添加连线
var link = svg.selectAll(".link")
.data(root.links())
.enter()
.append("path")
.attr("class", "link")
.attr("d", d3.linkHorizontal()
.x(function(d) { return d.y; })
.y(function(d) { return d.x; }));
// 添加提示框
var tooltip = d3.select("body")
.append("div")
.attr("class", "tooltip");
</script>
</body>
</html>

596
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/question/index.html

@ -1,239 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Drawflow</title>
<th:block th:include="zdxtInclude :: header('场景题目绑定')"/>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Drawflow</title>
</head>
<body>
<script src="/drawflow/dist/drawflow.min.js"></script>
<script src="/drawflow/lib/all.min.js" integrity="sha256-KzZiKy0DWYsnwMF+X1DvQngQ2/FxF7MF3Ff72XcpuPs=" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="/drawflow/src/drawflow.css" />
<link rel="stylesheet" type="text/css" href="/drawflow/docs/beautiful.css" />
<link rel="stylesheet" href="/drawflow/lib/all.min.css" integrity="sha256-h20CPZ0QyXlBuAw7A+KluUYx/3pK+c7lYEpqLTlxjYQ=" crossorigin="anonymous" />
<link href="/drawflow/lib/css2.css" rel="stylesheet">
<script src="/drawflow/lib/sweetalert2@9.js"></script>
<header>
<script src="/drawflow/dist/drawflow.min.js"></script>
<script src="/drawflow/lib/all.min.js" integrity="sha256-KzZiKy0DWYsnwMF+X1DvQngQ2/FxF7MF3Ff72XcpuPs="
crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="/drawflow/src/drawflow.css"/>
<link rel="stylesheet" type="text/css" href="/drawflow/docs/beautiful.css"/>
<link rel="stylesheet" href="/drawflow/lib/all.min.css" integrity="sha256-h20CPZ0QyXlBuAw7A+KluUYx/3pK+c7lYEpqLTlxjYQ="
crossorigin="anonymous"/>
<link href="/drawflow/lib/css2.css" rel="stylesheet">
<script src="/drawflow/lib/sweetalert2@9.js"></script>
<header>
<h3>题目绑定</h3>
</header>
<div class="wrapper">
<div class="col">
<div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="facebook">
<i class="fab fa-facebook"></i><span> 文本</span>
</div>
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="slack">-->
<!-- <i class="fab fa-slack"></i><span> Slack recive message</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="github">-->
<!-- <i class="fab fa-github"></i><span> Github Star</span>-->
<!-- </div>-->
<div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="telegram">
<i class="fab fa-telegram"></i><span> 下一题</span>
</div>
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="aws">-->
<!-- <i class="fab fa-aws"></i><span> AWS</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="log">-->
<!-- <i class="fas fa-file-signature"></i><span> File Log</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="google">-->
<!-- <i class="fab fa-google-drive"></i><span> Google Drive save</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="email">-->
<!-- <i class="fas fa-at"></i><span> Email send</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="template">-->
<!-- <i class="fas fa-code"></i><span> Template</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="multiple">-->
<!-- <i class="fas fa-code-branch"></i><span> Multiple inputs/outputs</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="personalized">-->
<!-- <i class="fas fa-fill"></i><span> Personalized</span>-->
<!-- </div>-->
<!-- <div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="dbclick">-->
<!-- <i class="fas fa-mouse"></i><span> DBClick!</span>-->
<!-- </div>-->
</header>
<div class="wrapper">
<div class="col">
<div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="aws">
<i class="fab fa-aws"></i><span> 题目</span>
</div>
<div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="template">
<i class="fas fa-code"></i><span> 答案</span>
</div>
<div class="drag-drawflow" draggable="true" ondragstart="drag(event)" data-node="google">
<i class="fab fa-google-drive"></i><span> 结束</span>
</div>
</div>
<div class="col-right">
<div class="menu">
<ul>
<li onclick="editor.changeModule('Home'); changeModule(event);" class="selected">主界面</li>
<!--<li onclick="editor.changeModule('Other'); changeModule(event);">Other Module</li> -->
</ul>
</div>
<div id="drawflow" ondrop="drop(event)" ondragover="allowDrop(event)">
<div class="btn-export" onclick="Swal.fire({ title: 'Export',
<div class="menu">
<ul>
<li onclick="editor.changeModule('Home'); changeModule(event);" class="selected">主界面</li>
<!--<li onclick="editor.changeModule('Other'); changeModule(event);">Other Module</li> -->
</ul>
</div>
<div id="drawflow" ondrop="drop(event)" ondragover="allowDrop(event)">
<div class="btn-export" onclick="Swal.fire({ title: 'Export',
html: '<pre><code>'+JSON.stringify(editor.export(), null,4)+'</code></pre>'
})" hidden>Export</div>
<!--<div class="btn-clear" onclick="editor.clearModuleSelected()">Clear</div>
<div class="btn-lock">
<i id="lock" class="fas fa-lock" onclick="editor.editor_mode='fixed'; changeMode('lock');"></i>
<i id="unlock" class="fas fa-lock-open" onclick="editor.editor_mode='edit'; changeMode('unlock');" style="display:none;"></i>
})" hidden>Export
</div>
</div>
<div class="bar-zoom">
<i class="fas fa-search-minus" onclick="editor.zoom_out()"></i>
<i class="fas fa-search" onclick="editor.zoom_reset()"></i>
<i class="fas fa-search-plus" onclick="editor.zoom_in()"></i>
</div> -->
</div>
</div>
</div>
<script>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<th:block th:include="zdxtInclude :: bootstrap-fileinput-js"/>
<script type="text/javascript" th:inline="javascript">
var sceneRole = [[${sceneRole}]]
var id = document.getElementById("drawflow");
const editor = new Drawflow(id);
editor.reroute = true;
editor.reroute_fix_curvature = true;
editor.force_first_input = false;
/*
editor.createCurvature = function(start_pos_x, start_pos_y, end_pos_x, end_pos_y, curvature_value, type) {
var center_x = ((end_pos_x - start_pos_x)/2)+start_pos_x;
return ' M ' + start_pos_x + ' ' + start_pos_y + ' L '+ center_x +' ' + start_pos_y + ' L ' + center_x + ' ' + end_pos_y + ' L ' + end_pos_x + ' ' + end_pos_y;
}*/
const dataToImport = {
"drawflow": {
"Home": {
"data": {
"1": {
"id": 1,
"name": "开始",
"data": {},
"class": "facebook",
"html": "\n <div>\n <div class=\"title-box\"><i class=\"fab fa-facebook\"></i> 开始</div>\n </div>\n ",
"typenode": false,
"inputs": {},
"outputs": {
"output_1": {
"connections": [{
"node": "2",
"output": "input_1"
}, {
"node": "3",
"output": "input_1"
}, {
"node": "11",
"output": "input_1"
}]
const initData = {
"drawflow": {
"Home": {
"data": {
"1": {
"id": 1,
"name": "开始",
"data": {},
"class": "facebook",
"html": "\n <div>\n <div style='background-color: red' class=\"title-box\"><i class=\"fab fa-facebook\"></i> 开始</div>\n </div>\n ",
"typenode": false,
"inputs": {},
"outputs": {
"output_1": {
"connections": [{
"node": "2",
"output": "input_1"
}]
}
},
"pos_x": 25,
"pos_y": 100
}
}
}
},
"pos_x": 25,
"pos_y": 100
}
}
}
}
}
const dataToImport = (sceneRole.content == null || sceneRole.content === "") ? initData : JSON.parse(sceneRole.content);
editor.start();
editor.import(dataToImport);
/*
var welcome = `
<div>
<div class="title-box">👏 Welcome!!</div>
<div class="box">
<p>Simple flow library <b>demo</b>
<a href="https://github.com/jerosoler/Drawflow" target="_blank">Drawflow</a> by <b>Jero Soler</b></p><br>
<p>Multiple input / outputs<br>
Data sync nodes<br>
Import / export<br>
Modules support<br>
Simple use<br>
Type: Fixed or Edit<br>
Events: view console<br>
Pure Javascript<br>
</p>
<br>
<p><b><u>Shortkeys:</u></b></p>
<p>🎹 <b>Delete</b> for remove selected<br>
💠 Mouse Left Click == Move<br>
❌ Mouse Right == Delete Option<br>
🔍 Ctrl + Wheel == Zoom<br>
📱 Mobile support<br>
...</p>
</div>
</div>
`;
*/
//editor.addNode(name, "typenode": false, inputs, outputs, posx, posy, class, data, html);
/*editor.addNode('welcome', 0, 0, 50, 50, 'welcome', {}, welcome );
editor.addModule('Other');
*/
function submitHandler() {
var data = {};
data.guid = sceneRole.guid;
data.content = JSON.stringify(editor.export(), null, 4);
$.post(ctx + "small/project/role/edit", data, function (req, status) {
if (req.success) {
$.modal.alertSuccess("保存成功");
}
})
}
// Events!
editor.on('nodeCreated', function(id) {
console.log("Node created " + id);
editor.on('nodeSelected', function (id) {
// if (editor.getNodeFromId(id).name === "aws") {
// $.modal.open("新增题目", "/project/question/add/" + sceneRole.guid, 600, 450);
// }
console.log("Node selected " + id);
})
editor.on('nodeRemoved', function(id) {
console.log("Node removed " + id);
editor.on('nodeCreated', function (id) {
let uuid = getUuid();
editor.getNodeFromId(id).uuid = uuid;
})
editor.on('nodeSelected', function(id) {
console.log("Node selected " + id);
editor.on('nodeRemoved', function (id) {
console.log("Node removed " + id);
})
editor.on('moduleCreated', function(name) {
console.log("Module Created " + name);
editor.on('moduleCreated', function (name) {
console.log("Module Created " + name);
})
editor.on('moduleChanged', function(name) {
console.log("Module Changed " + name);
editor.on('moduleChanged', function (name) {
console.log("Module Changed " + name);
})
editor.on('connectionCreated', function(connection) {
console.log('Connection created');
console.log(connection);
editor.on('connectionCreated', function (connection) {
console.log('Connection created');
console.log(connection);
})
editor.on('connectionRemoved', function(connection) {
console.log('Connection removed');
console.log(connection);
})
/*
editor.on('mouseMove', function(position) {
console.log('Position mouse x:' + position.x + ' y:'+ position.y);
editor.on('connectionRemoved', function (connection) {
console.log('Connection removed');
console.log(connection);
})
*/
editor.on('nodeMoved', function(id) {
console.log("Node moved " + id);
editor.on('nodeMoved', function (id) {
console.log("Node moved " + id);
})
editor.on('zoom', function(zoom) {
console.log('Zoom level ' + zoom);
editor.on('zoom', function (zoom) {
console.log('Zoom level ' + zoom);
})
editor.on('translate', function(position) {
console.log('Translate x:' + position.x + ' y:'+ position.y);
editor.on('translate', function (position) {
console.log('Translate x:' + position.x + ' y:' + position.y);
})
editor.on('addReroute', function(id) {
console.log("Reroute added " + id);
editor.on('addReroute', function (id) {
console.log("Reroute added " + id);
})
editor.on('removeReroute', function(id) {
console.log("Reroute removed " + id);
editor.on('removeReroute', function (id) {
console.log("Reroute removed " + id);
})
/* DRAG EVENT */
@ -241,87 +163,89 @@
var elements = document.getElementsByClassName('drag-drawflow');
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener('touchend', drop, false);
elements[i].addEventListener('touchmove', positionMobile, false);
elements[i].addEventListener('touchstart', drag, false );
elements[i].addEventListener('touchend', drop, false);
elements[i].addEventListener('touchmove', positionMobile, false);
elements[i].addEventListener('touchstart', drag, false);
}
var mobile_item_selec = '';
var mobile_last_move = null;
function positionMobile(ev) {
mobile_last_move = ev;
}
function allowDrop(ev) {
ev.preventDefault();
function positionMobile(ev) {
mobile_last_move = ev;
}
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
if (ev.type === "touchstart") {
mobile_item_selec = ev.target.closest(".drag-drawflow").getAttribute('data-node');
} else {
ev.dataTransfer.setData("node", ev.target.getAttribute('data-node'));
}
if (ev.type === "touchstart") {
mobile_item_selec = ev.target.closest(".drag-drawflow").getAttribute('data-node');
} else {
ev.dataTransfer.setData("node", ev.target.getAttribute('data-node'));
}
}
function drop(ev) {
if (ev.type === "touchend") {
var parentdrawflow = document.elementFromPoint( mobile_last_move.touches[0].clientX, mobile_last_move.touches[0].clientY).closest("#drawflow");
if(parentdrawflow != null) {
addNodeToDrawFlow(mobile_item_selec, mobile_last_move.touches[0].clientX, mobile_last_move.touches[0].clientY);
if (ev.type === "touchend") {
var parentdrawflow = document.elementFromPoint(mobile_last_move.touches[0].clientX, mobile_last_move.touches[0].clientY).closest("#drawflow");
if (parentdrawflow != null) {
addNodeToDrawFlow(mobile_item_selec, mobile_last_move.touches[0].clientX, mobile_last_move.touches[0].clientY);
}
mobile_item_selec = '';
} else {
ev.preventDefault();
var data = ev.dataTransfer.getData("node");
addNodeToDrawFlow(data, ev.clientX, ev.clientY);
}
mobile_item_selec = '';
} else {
ev.preventDefault();
var data = ev.dataTransfer.getData("node");
addNodeToDrawFlow(data, ev.clientX, ev.clientY);
}
}
function addNodeToDrawFlow(name, pos_x, pos_y) {
if(editor.editor_mode === 'fixed') {
return false;
}
pos_x = pos_x * ( editor.precanvas.clientWidth / (editor.precanvas.clientWidth * editor.zoom)) - (editor.precanvas.getBoundingClientRect().x * ( editor.precanvas.clientWidth / (editor.precanvas.clientWidth * editor.zoom)));
pos_y = pos_y * ( editor.precanvas.clientHeight / (editor.precanvas.clientHeight * editor.zoom)) - (editor.precanvas.getBoundingClientRect().y * ( editor.precanvas.clientHeight / (editor.precanvas.clientHeight * editor.zoom)));
if (editor.editor_mode === 'fixed') {
return false;
}
pos_x = pos_x * (editor.precanvas.clientWidth / (editor.precanvas.clientWidth * editor.zoom)) - (editor.precanvas.getBoundingClientRect().x * (editor.precanvas.clientWidth / (editor.precanvas.clientWidth * editor.zoom)));
pos_y = pos_y * (editor.precanvas.clientHeight / (editor.precanvas.clientHeight * editor.zoom)) - (editor.precanvas.getBoundingClientRect().y * (editor.precanvas.clientHeight / (editor.precanvas.clientHeight * editor.zoom)));
switch (name) {
case 'facebook':
var facebook = `
switch (name) {
case 'facebook':
var facebook = `
<div>
<div class="title-box"><i class="fab fa-facebook"></i> 文本</div>
</div>
`;
editor.addNode('facebook', 0, 1, pos_x, pos_y, 'facebook', {}, facebook );
break;
case 'slack':
var slackchat = `
editor.addNode('facebook', 0, 1, pos_x, pos_y, 'facebook', {}, facebook);
break;
case 'slack':
var slackchat = `
<div>
<div class="title-box"><i class="fab fa-slack"></i> Slack chat message</div>
</div>
`
editor.addNode('slack', 1, 0, pos_x, pos_y, 'slack', {}, slackchat );
break;
case 'github':
var githubtemplate = `
editor.addNode('slack', 1, 0, pos_x, pos_y, 'slack', {}, slackchat);
break;
case 'github':
var githubtemplate = `
<div>
<div class="title-box"><i class="fab fa-github "></i> Github Stars</div>
<div class="box">
<p>Enter repository url</p>
<input type="text" df-name>
</div>
</div>
`;
editor.addNode('github', 0, 1, pos_x, pos_y, 'github', { "name": ''}, githubtemplate );
break;
case 'telegram':
var telegrambot = `
editor.addNode('github', 0, 1, pos_x, pos_y, 'github', {"name": ''}, githubtemplate);
break;
case 'telegram':
var telegrambot = `
<div>
<div class="title-box"><i class="fab fa-telegram-plane"></i> 下一题</div>
<div class="title-box"><i class="fab fa-telegram-plane"></i> Telegram</div>
<div class="box">
<p>请选择你要绑定的下一个问题</p>
<select df-channel>
<option value="channel_1">Channel 1</option>
<option value="channel_2">Channel 2</option>
@ -331,80 +255,86 @@
</div>
</div>
`;
editor.addNode('telegram', 1, 0, pos_x, pos_y, 'telegram', { "channel": 'channel_3'}, telegrambot );
break;
case 'aws':
var aws = `
<div>
<div class="title-box"><i class="fab fa-aws"></i> Aws Save </div>
<div class="box">
<p>Save in aws</p>
<input type="text" df-db-dbname placeholder="DB name"><br><br>
<input type="text" df-db-key placeholder="DB key">
<p>Output Log</p>
</div>
</div>
`;
editor.addNode('aws', 1, 1, pos_x, pos_y, 'aws', { "db": { "dbname": '', "key": '' }}, aws );
break;
case 'log':
var log = `
editor.addNode('telegram', 1, 0, pos_x, pos_y, 'telegram', {"channel": 'channel_3'}, telegrambot);
break;
case 'aws':
var guid = getUuid();
var aws = "<div>\n " +
"<div class=\"title-box\"><i class=\"fas fa-file-signature\"" +
"onclick=\"editQuestion(\'" + guid + "\')\" ></i>题目</div>\n " +
" <div class=\"box\">\n </div>\n " +
" </div>";
// var aws = `
// <div>
// <div class="title-box"><i class="fas fa-file-signature" onclick="editQuestion(\'' + guid + '\')"></i>题目</div>
// <div class="box">
// <input type="text" df-db-key placeholder="DB key">
// </div>
// </div>
// `;
editor.addNode(guid, 1, 1, pos_x, pos_y, 'aws', {"db": {"dbname": '', "key": ''}}, aws);
break;
case 'log':
var log = `
<div>
<div class="title-box"><i class="fas fa-file-signature"></i> Save log file </div>
</div>
`;
editor.addNode('log', 1, 0, pos_x, pos_y, 'log', {}, log );
break;
case 'google':
var google = `
editor.addNode('log', 1, 0, pos_x, pos_y, 'log', {}, log);
break;
case 'google':
var google = `
<div>
<div class="title-box"><i class="fab fa-google-drive"></i> Google Drive save </div>
<div class="title-box" style="background-color: red"><i class="fab fa-google-drive"></i> 结束 </div>
</div>
`;
editor.addNode('google', 1, 0, pos_x, pos_y, 'google', {}, google );
break;
case 'email':
var email = `
editor.addNode('google', 1, 0, pos_x, pos_y, 'google', {}, google);
break;
case 'email':
var email = `
<div>
<div class="title-box"><i class="fas fa-at"></i> Send Email </div>
</div>
`;
editor.addNode('email', 1, 0, pos_x, pos_y, 'email', {}, email );
break;
editor.addNode('email', 1, 0, pos_x, pos_y, 'email', {}, email);
break;
case 'template':
var template = `
case 'template':
var template = `
<div>
<div class="title-box"><i class="fas fa-code"></i> Template</div>
<div class="title-box">答案</div>
<div class="box">
Ger Vars
<textarea df-template></textarea>
Output template with vars
<select df-channel>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>
</div>
</div>
`;
editor.addNode('template', 1, 1, pos_x, pos_y, 'template', { "template": 'Write your template'}, template );
break;
case 'multiple':
var multiple = `
editor.addNode('template', 1, 1, pos_x, pos_y, 'template', {"template": 'Write your template'}, template);
break;
case 'multiple':
var multiple = `
<div>
<div class="box">
Multiple!
</div>
</div>
`;
editor.addNode('multiple', 3, 4, pos_x, pos_y, 'multiple', {}, multiple );
break;
case 'personalized':
var personalized = `
editor.addNode('multiple', 3, 4, pos_x, pos_y, 'multiple', {}, multiple);
break;
case 'personalized':
var personalized = `
<div>
Personalized
</div>
`;
editor.addNode('personalized', 1, 1, pos_x, pos_y, 'personalized', {}, personalized );
break;
case 'dbclick':
var dbclick = `
editor.addNode('personalized', 1, 1, pos_x, pos_y, 'personalized', {}, personalized);
break;
case 'dbclick':
var dbclick = `
<div>
<div class="title-box"><i class="fas fa-mouse"></i> Db Click</div>
<div class="box dbclickbox" ondblclick="showpopup(event)">
@ -420,63 +350,79 @@
</div>
</div>
`;
editor.addNode('dbclick', 1, 1, pos_x, pos_y, 'dbclick', { name: ''}, dbclick );
break;
editor.addNode('dbclick', 1, 1, pos_x, pos_y, 'dbclick', {name: ''}, dbclick);
break;
default:
}
default:
}
}
var transform = '';
function showpopup(e) {
e.target.closest(".drawflow-node").style.zIndex = "9999";
e.target.children[0].style.display = "block";
//document.getElementById("modalfix").style.display = "block";
//e.target.children[0].style.transform = 'translate('+translate.x+'px, '+translate.y+'px)';
transform = editor.precanvas.style.transform;
editor.precanvas.style.transform = '';
editor.precanvas.style.left = editor.canvas_x +'px';
editor.precanvas.style.top = editor.canvas_y +'px';
console.log(transform);
//e.target.children[0].style.top = -editor.canvas_y - editor.container.offsetTop +'px';
//e.target.children[0].style.left = -editor.canvas_x - editor.container.offsetLeft +'px';
editor.editor_mode = "fixed";
}
function closemodal(e) {
e.target.closest(".drawflow-node").style.zIndex = "2";
e.target.parentElement.parentElement.style.display ="none";
//document.getElementById("modalfix").style.display = "none";
editor.precanvas.style.transform = transform;
editor.precanvas.style.left = '0px';
editor.precanvas.style.top = '0px';
editor.editor_mode = "edit";
}
var transform = '';
function showpopup(e) {
e.target.closest(".drawflow-node").style.zIndex = "9999";
e.target.children[0].style.display = "block";
//document.getElementById("modalfix").style.display = "block";
//e.target.children[0].style.transform = 'translate('+translate.x+'px, '+translate.y+'px)';
transform = editor.precanvas.style.transform;
editor.precanvas.style.transform = '';
editor.precanvas.style.left = editor.canvas_x + 'px';
editor.precanvas.style.top = editor.canvas_y + 'px';
console.log(transform);
//e.target.children[0].style.top = -editor.canvas_y - editor.container.offsetTop +'px';
//e.target.children[0].style.left = -editor.canvas_x - editor.container.offsetLeft +'px';
editor.editor_mode = "fixed";
}
function closemodal(e) {
e.target.closest(".drawflow-node").style.zIndex = "2";
e.target.parentElement.parentElement.style.display = "none";
//document.getElementById("modalfix").style.display = "none";
editor.precanvas.style.transform = transform;
editor.precanvas.style.left = '0px';
editor.precanvas.style.top = '0px';
editor.editor_mode = "edit";
}
function changeModule(event) {
var all = document.querySelectorAll(".menu ul li");
var all = document.querySelectorAll(".menu ul li");
for (var i = 0; i < all.length; i++) {
all[i].classList.remove('selected');
all[i].classList.remove('selected');
}
event.target.classList.add('selected');
event.target.classList.add('selected');
}
function changeMode(option) {
//console.log(lock.id);
if(option == 'lock') {
lock.style.display = 'none';
unlock.style.display = 'block';
} else {
lock.style.display = 'block';
unlock.style.display = 'none';
}
//console.log(lock.id);
if (option == 'lock') {
lock.style.display = 'none';
unlock.style.display = 'block';
} else {
lock.style.display = 'block';
unlock.style.display = 'none';
}
}
function editQuestion(guid){
$.modal.open("新增题目", "/project/question/addNew?guid="+guid+"&parentId=" + sceneRole.guid, 600, 450);
}
</script>
function getUuid() {
var s = [];
var hexDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (var i = 0; i < 32; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
}
s[14] = "4"
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
let uuid = s.join("")
return uuid
}
</script>
</body>
</html>

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

@ -102,8 +102,7 @@
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.guid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.guid + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.guid + '\',800,450)"><i class="fa fa-eye"></i>查看</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bind(\'' + row.guid + '\',800,450)"><i class="fa fa-eject"></i>绑定</a>');
actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bindNew(\'' + row.guid + '\',900,500)"><i class="fa fa-eject"></i>绑定</a>');
//actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bindNew(\'' + row.guid + '\',900,500)"><i class="fa fa-eject"></i>绑定</a>');
return actions.join('');
}
}]
@ -119,16 +118,9 @@
$.modal.open("新增场景题目", ctx + "project/question/add/" + parentId, 800, 450);
}
function bind(id, width, height) {
$.modal.open("", ctx + "project/question/bind/" + id, width, height);
}
function bindNew(id, width, height) {
$.modal.open("", ctx + "project/question/bindNew/" + id, width, height);
// $.get(ctx + "project/question/bindNew/" + id,
// function(){}
// );
}
// function bindNew(id, width, height) {
// $.modal.open("", ctx + "project/question/bindNew/" + id, width, height);
// }
function reset() {
$("[name='name']").val("");

46
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/add.html

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="zdxtInclude :: header('新增场景角色')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-add" type="text/template">
<input name="sceneId" type="text" hidden>
<div class="form-group" id="fileTitle">
<label class="col-sm-3 control-label is-required">角色名称:</label>
<div class="col-sm-6">
<div class="file-loading">
<input name="name" type="text" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">状态:</label>
<div class="col-sm-6">
<select name="status" class="form-control">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</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 sceneId = [[${sceneId}]];
$('input[name="sceneId"]').val(sceneId);
var prefix = ctx + "small/project/role"
$("#form-manage-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-role-add').serialize());
}
}
</script>
</body>
</html>

41
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/edit.html

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="zdxtInclude :: header('编辑场景角色')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-edit" th:object="${sceneRole}">
<input name="guid" th:field="*{guid}" 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">
</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}">
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="zdxtInclude :: footer" />
<script type="text/javascript">
var prefix = ctx + "small/project/role"
$("#form-manage-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-role-edit').serialize());
}
}
</script>
</body>
</html>

136
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/role/view.html

@ -0,0 +1,136 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="zdxtInclude :: header('场景角色列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<input type="text" name="sceneId" hidden/>
<ul>
<li>
<p>名称:</p>
<input type="text" name="name"/>
</li>
<li>
<p>状态:</p>
<select name="status">
<option value="">请选择</option>
<option value="0">有效</option>
<option value="1">无效</option>
</select>
</li>
<li>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-reset btn-rounded btn-sm" onclick="reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="add()" shiro:hasPermission="system:role:add">
<i class="fa fa-plus"></i> 新增角色
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="zdxtInclude :: footer"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('project:role:edit')}]];
var removeFlag = [[${@permission.hasPermi('project:role:remove')}]];
var detailFlag = [[${@permission.hasPermi('project:role:detail')}]];
var prefix = ctx + "small/project/role";
var sceneId = [[${sceneId}]];
$(function () {
var sceneId = [[${sceneId}]];
$("[name='sceneId']").val(sceneId);
var options = {
url: prefix + "/list",
createUrl: prefix + "/add/{}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
detailUrl: prefix + "/detail/{guid}",
modalName: "场景角色",
columns: [{
checkbox: true
},
{
title: '序号',
align: 'center',
formatter: function (value, row, index) {
return $.table.serialNumber(index);
}
},
{
field: 'name',
title: '角色名称'
},
{
field: 'status',
title: '状态',
formatter: function (value, index) {
return value === 0 ? "有效" : "无效";
}
},
{
field: 'creator',
title: '创建人'
},
{
field: 'createTime',
title: '创建时间'
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.guid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.guid + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="question(\'' + row.guid + '\')"><i class="fa fa-eye"></i>绑定</a> ');
//actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.guid + '\',800,450)"><i class="fa fa-eye"></i>查看</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bind(\'' + row.guid + '\',800,450)"><i class="fa fa-eject"></i>绑定</a>');
//actions.push('<a class="btn btn-danger btn-xs ' + bindFlag + '" href="javascript:void(0)" onclick="bindNew(\'' + row.guid + '\',900,500)"><i class="fa fa-eject"></i>绑定</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
function detail(id, width, height) {
$.modal.open("查看场景角色", ctx + "small/project/role/detail/" + id, width, height);
}
function add() {
$.modal.open("新增场景角色", ctx + "small/project/role/add/" + sceneId, 600, 350);
}
function edit(id) {
$.modal.open("编辑场景角色", ctx + "small/project/role/edit/" + id, 600, 350);
}
function question(id) {
table.set();
$.modal.openFull("", ctx + "small/project/role/bindNew/" + id);
}
function reset() {
$("[name='name']").val("");
$("[name='status']").val("");
$.table.search()
}
</script>
</body>
</html>

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

@ -152,7 +152,7 @@
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.guid + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.guid + '\')"><i class="fa fa-remove"></i> 删除</a>');
actions.push('<a class="btn btn-primary btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detailFull(\'' + row.guid + '\')"><i class="fa fa-eye"></i>查看</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="question(\'' + row.guid + '\',\'' + row.name + '\')"><i class="fa fa-eject"></i>题目</a>');
actions.push('<a class="btn btn-danger btn-xs" href="/small/project/role/view/'+row.guid+'"><i class="fa fa-eject"></i>角色</a>');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sort(\'' + row.guid + '\')"><i class="fa fa-eject"></i>上移</a>');
return actions.join('');
}
@ -187,10 +187,11 @@
$.modal.openFull("场景详情", url);
}
function question(id, name) {
table.set();
$.modal.openFull("场景名称 >>" + name, ctx + "project/question/view/" + id);
}
// function question(id, name) {
// table.set();
// //$.modal.openFull("场景名称 >>" + name, ctx + "project/question/view/" + id);
// $.modal.openFull("", ctx + "project/question/bindNew/" + id);
// }
function sort(id) {
$.get(ctx + "scene/manage/sort/" + id, null, function (res) {

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

@ -7,8 +7,8 @@ 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.mapper.SceneRoleMapper;
import com.zdxt.knowledge.service.ISceneQuestionService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -18,8 +18,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 场景题目Controller
@ -38,6 +36,8 @@ public class SceneQuestionController extends BaseController {
@Autowired
private SceneManageMapper sceneManageMapper;
@Autowired
private SceneRoleMapper sceneRoleMapper;
@Autowired
private RoleApi roleApi;
@ -69,54 +69,12 @@ public class SceneQuestionController extends BaseController {
return prefix + "/detail";
}
@RequiresPermissions("project:question:bind")
@GetMapping("/bind/{guid}")
public String bind(@PathVariable("guid") String guid, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(guid);
List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(new SceneQuestion());
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().filter(item -> !Objects.equals(item.getGuid(), guid)).collect(Collectors.toList());
}
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("list", list);
return prefix + "/bind";
}
@RequiresPermissions("project:question:bind")
@GetMapping("/bindNew/{guid}")
public String bindNew(@PathVariable("guid") String guid, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(guid);
List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(new SceneQuestion());
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().filter(item -> !Objects.equals(item.getGuid(), guid)).collect(Collectors.toList());
}
mmap.put("sceneQuestion", sceneQuestion);
mmap.put("list", list);
return prefix + "/index";
}
// /**
// * 导出场景题目列表
// */
// @RequiresPermissions("project:question:export")
// @PostMapping("/export")
// @ResponseBody
// public AjaxResult export(SceneQuestion sceneQuestion)
// {
// List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(sceneQuestion);
// ExcelUtil<SceneQuestion> util = new ExcelUtil<SceneQuestion>(SceneQuestion.class);
// return util.exportExcel(list, "question");
// }
/**
* 新增场景题目
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") String parentId, ModelMap mmap) {
SceneManage sceneManage = sceneManageMapper.selectSceneManageById(parentId);
@GetMapping("/add")
public String add(@RequestParam("parentId") String parentId, ModelMap mmap) {
mmap.put("parentId", parentId);
mmap.put("type", sceneManage.getType());
mmap.put("roles", roleApi.getRolesAll());
return prefix + "/add";
}
@ -211,13 +169,38 @@ public class SceneQuestionController extends BaseController {
}
/**
* 绑定场景题目
* 新增场景题目
*/
@RequiresPermissions("project:question:bind")
@PostMapping("/bindAnswer")
@GetMapping("/addNew")
public String addNew(@RequestParam("guid") String guid, @RequestParam("parentId") String parentId, ModelMap mmap) {
SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(guid);
mmap.put("parentId", parentId);
mmap.put("guid", guid);
mmap.put("sceneQuestion", sceneQuestion);
return prefix + "/addNew";
}
/**
* 流程图-新增/修改场景题目节点
*/
@RequiresPermissions("project:question:add")
@PostMapping("/addSaveNew")
@ResponseBody
public ZDResponse bindAnswer(SceneQuestion sceneQuestion) {
return sceneQuestionService.bindAnswer(sceneQuestion) > 0
? ZDResponse.success() : ZDResponse.error("绑定失败");
public ZDResponse addSaveNew(@RequestParam("file") MultipartFile[] files, SceneQuestion sceneQuestion) {
return sceneQuestionService.editSceneQuestion(files, sceneQuestion) > 0
? ZDResponse.success() : ZDResponse.error("新增失败");
}
// @RequiresPermissions("project:question:bind")
// @GetMapping("/bindNew/{guid}")
// public String bindNew(@PathVariable("guid") String guid, ModelMap mmap) {
// SceneQuestion sceneQuestion = sceneQuestionService.selectSceneQuestionById(guid);
// List<SceneQuestion> list = sceneQuestionService.selectSceneQuestionList(new SceneQuestion());
// if (CollectionUtils.isNotEmpty(list)) {
// list = list.stream().filter(item -> !Objects.equals(item.getGuid(), guid)).collect(Collectors.toList());
// }
// mmap.put("sceneQuestion", sceneQuestion);
// mmap.put("list", list);
// return prefix + "/index";
// }
}

116
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/controller/SceneRoleController.java

@ -0,0 +1,116 @@
package com.zdxt.knowledge.controller;
import com.zdxt.common.ZDResponse;
import com.zdxt.common.controller.BaseController;
import com.zdxt.common.util.TableDataInfo;
import com.zdxt.knowledge.domain.SceneRole;
import com.zdxt.knowledge.service.ISceneRoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 场景角色Controller
*
* @author ruoyi
* @date 2023-12-26
*/
@Controller
@RequestMapping("/small/project/role")
public class SceneRoleController extends BaseController {
private String prefix = "project/role";
@Autowired
private ISceneRoleService sceneRoleService;
@RequiresPermissions("project:role:view")
@GetMapping("/view/{sceneId}")
public String view(@PathVariable("sceneId") String sceneId, ModelMap mmap) {
mmap.put("sceneId", sceneId);
return prefix + "/view";
}
/**
* 查询场景角色列表
*/
@RequiresPermissions("project:role:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SceneRole sceneRole) {
startPage();
List<SceneRole> list = sceneRoleService.selectSceneRoleList(sceneRole);
return getDataTable(list);
}
@RequiresPermissions("project:role:detail")
@GetMapping("/detail/{guid}")
public String detail(@PathVariable("guid") String guid, ModelMap mmap) {
SceneRole SceneRole = sceneRoleService.selectSceneRoleById(guid);
mmap.put("sceneRole", SceneRole);
return prefix + "/detail";
}
/**
* 新增场景角色
*/
@GetMapping("/add/{sceneId}")
public String add(@PathVariable("sceneId") String sceneId, ModelMap mmap) {
mmap.put("sceneId", sceneId);
return prefix + "/add";
}
/**
* 新增保存场景角色
*/
@RequiresPermissions("project:role:add")
@PostMapping("/add")
@ResponseBody
public ZDResponse addSave(SceneRole sceneRole) {
return sceneRoleService.insertSceneRole(sceneRole) > 0
? ZDResponse.success() : ZDResponse.error("新增失败");
}
/**
* 修改场景角色
*/
@GetMapping("/edit/{guid}")
public String edit(@PathVariable("guid") String guid, ModelMap mmap) {
SceneRole sceneRole = sceneRoleService.selectSceneRoleById(guid);
mmap.put("sceneRole", sceneRole);
return prefix + "/edit";
}
/**
* 修改保存场景角色
*/
@RequiresPermissions("project:role:edit")
@PostMapping("/edit")
@ResponseBody
public ZDResponse editSave(SceneRole sceneRole) {
return sceneRoleService.updateSceneRole(sceneRole) > 0
? ZDResponse.success() : ZDResponse.error("修改失败");
}
/**
* 删除场景角色
*/
@RequiresPermissions("project:role:remove")
@PostMapping("/remove")
@ResponseBody
public ZDResponse remove(String ids) {
return sceneRoleService.deleteSceneRoleByIds(ids) > 0
? ZDResponse.success() : ZDResponse.error("删除失败");
}
@RequiresPermissions("project:role:bind")
@GetMapping("/bindNew/{guid}")
public String bindNew(@PathVariable("guid") String guid, ModelMap mmap) {
SceneRole sceneRole = sceneRoleService.selectSceneRoleById(guid);
mmap.put("sceneRole", sceneRole);
return "project/question/index";
}
}

147
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/domain/SceneRole.java

@ -0,0 +1,147 @@
package com.zdxt.knowledge.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* 场景角色 scene_role
*
* @author ruoyi
* @date 2023-12-26
*/
public class SceneRole implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String guid;
/**
* 题目名称
*/
private String name;
/**
* 场景id
*/
private String sceneId;
/**
* 状态0有效1无效
*/
private Integer status;
/**
* 绑定的题目流程图内容
*/
private String content;
/**
* 创建人
*/
private String creator;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 请求参数
*/
private Map<String, Object> params;
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSceneId() {
return sceneId;
}
public void setSceneId(String sceneId) {
this.sceneId = sceneId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

53
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/mapper/SceneRoleMapper.java

@ -0,0 +1,53 @@
package com.zdxt.knowledge.mapper;
import com.zdxt.knowledge.domain.SceneRole;
import java.util.List;
/**
* 场景角色Mapper接口
*
* @author ruoyi
* @date 2023-12-26
*/
public interface SceneRoleMapper {
/**
* 查询场景角色
*
* @param guid 场景角色ID
* @return 场景角色
*/
public SceneRole selectSceneRoleById(String guid);
/**
* 查询场景角色列表
*
* @param sceneRole 场景角色
* @return 场景角色集合
*/
public List<SceneRole> selectSceneRoleList(SceneRole sceneRole);
/**
* 新增场景角色
*
* @param sceneRole 场景角色
* @return 结果
*/
public int insertSceneRole(SceneRole sceneRole);
/**
* 修改场景角色
*
* @param sceneRole 场景角色
* @return 结果
*/
public int updateSceneRole(SceneRole sceneRole);
/**
* 批量删除场景角色
*
* @param guids 需要删除的数据ID
* @return 结果
*/
public int deleteSceneRoleByIds(String[] guids);
}

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

@ -38,6 +38,15 @@ public interface ISceneQuestionService
*/
public int insertSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion);
/**
* 流程图-新增/修改场景题目节点
*
* @param sceneQuestion 场景题目
* @return 结果
*/
public int editSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion);
/**
* 修改场景题目
*
@ -54,22 +63,6 @@ public interface ISceneQuestionService
*/
public int deleteSceneQuestionByIds(String guids);
/**
* 删除场景题目信息
*
* @param guid 场景题目ID
* @return 结果
*/
public int deleteSceneQuestionById(String guid);
/**
* 绑定场景题目信息
*
* @param sceneQuestion
* @return 结果
*/
public int bindAnswer(SceneQuestion sceneQuestion);
/**
* 查询附件
* @param key

54
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/ISceneRoleService.java

@ -0,0 +1,54 @@
package com.zdxt.knowledge.service;
import com.zdxt.knowledge.domain.SceneRole;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 场景角色Service接口
*
* @author ruoyi
* @date 2023-12-26
*/
public interface ISceneRoleService {
/**
* 查询场景角色
*
* @param guid 场景角色ID
* @return 场景角色
*/
public SceneRole selectSceneRoleById(String guid);
/**
* 查询场景角色列表
*
* @param sceneRole 场景角色
* @return 场景角色集合
*/
public List<SceneRole> selectSceneRoleList(SceneRole sceneRole);
/**
* 新增场景角色
*
* @param sceneRole 场景角色
* @return 结果
*/
public int insertSceneRole(SceneRole sceneRole);
/**
* 修改场景角色
*
* @param sceneRole 场景角色
* @return 结果
*/
public int updateSceneRole(SceneRole sceneRole);
/**
* 批量删除场景角色
*
* @param guids 需要删除的数据ID
* @return 结果
*/
public int deleteSceneRoleByIds(String guids);
}

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

@ -88,6 +88,39 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
return questionList;
}
/**
* 新增场景题目
*
* @param sceneQuestion 场景题目
* @return 结果
*/
@Override
public int editSceneQuestion(MultipartFile[] files, SceneQuestion sceneQuestion) {
int result;
UserBean userBean = userApi.getCurrentUser();
SceneQuestion questionEntity = sceneQuestionMapper.selectSceneQuestionById(sceneQuestion.getGuid());
if (Objects.isNull(questionEntity)) {
if (Objects.nonNull(userBean)) {
sceneQuestion.setCreator(userBean.getUserName());
sceneQuestion.setCreateTime(DateUtils.getNowDate());
}
result = sceneQuestionMapper.insertSceneQuestion(sceneQuestion);
} else {
if (Objects.nonNull(userBean)) {
sceneQuestion.setUpdateTime(DateUtils.getNowDate());
}
result = sceneQuestionMapper.updateSceneQuestion(sceneQuestion);
zdxtFileCommonApi.deleteZdxtFileByIds(sceneQuestion.getGuid());
}
// 上传文件,并在附件表中添加记录
if (result > 0 && ObjectUtil.isNotEmpty(files)) {
for (MultipartFile file : files) {
zdxtFileCommonApi.insertZdxtFile(file, sceneQuestion.getGuid() + "", fileUploadApi.upload(file));
}
}
return result;
}
/**
* 新增场景题目
*
@ -101,7 +134,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
sceneQuestion.setCreator(userBean.getUserName());
sceneQuestion.setCreateTime(DateUtils.getNowDate());
}
sceneQuestion.setGuid(StringUtils.getUUID());
sceneQuestion.setGuid(StringUtils.isEmpty(sceneQuestion.getGuid()) ? StringUtils.getUUID() : sceneQuestion.getGuid());
int result = sceneQuestionMapper.insertSceneQuestion(sceneQuestion);
// 上传文件,并在附件表中添加记录
if (result > 0 && ObjectUtil.isNotEmpty(files)) {
@ -135,17 +168,6 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
return sceneQuestionMapper.deleteSceneQuestionByIds(Convert.toStrArray(guids));
}
/**
* 删除场景题目信息
*
* @param guid 场景题目ID
* @return 结果
*/
@Override
public int deleteSceneQuestionById(String guid) {
return sceneQuestionMapper.deleteSceneQuestionById(guid);
}
@Override
public AttFileRespDTO queryFiles(String key) {
ZdxtFileBean zdxtFileBeanCondition = new ZdxtFileBean();
@ -168,14 +190,4 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService {
return zdxtFileCommonApi.deleteZdxtFileById(key);
}
/**
* 绑定场景题目信息
*
* @param sceneQuestion
* @return 结果
*/
@Override
public int bindAnswer(SceneQuestion sceneQuestion) {
return sceneQuestionMapper.bindAnswer(sceneQuestion);
}
}

97
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/java/com/zdxt/knowledge/service/impl/SceneRoleServiceImpl.java

@ -0,0 +1,97 @@
package com.zdxt.knowledge.service.impl;
import com.zdxt.auth.dto.UserBean;
import com.zdxt.auth.feign.UserApi;
import com.zdxt.common.util.Convert;
import com.zdxt.common.util.DateUtils;
import com.zdxt.common.util.StringUtils;
import com.zdxt.knowledge.domain.SceneRole;
import com.zdxt.knowledge.mapper.SceneRoleMapper;
import com.zdxt.knowledge.service.ISceneRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Objects;
/**
* 场景题目Service业务层处理
*
* @author ruoyi
* @date 2023-12-26
*/
@Service
public class SceneRoleServiceImpl implements ISceneRoleService {
@Autowired
private SceneRoleMapper sceneRoleMapper;
@Autowired
private UserApi userApi;
/**
* 查询场景题目
*
* @param guid 场景题目ID
* @return 场景题目
*/
@Override
public SceneRole selectSceneRoleById(String guid) {
return sceneRoleMapper.selectSceneRoleById(guid);
}
/**
* 查询场景题目列表
*
* @param sceneRole 场景题目
* @return 场景题目
*/
@Override
public List<SceneRole> selectSceneRoleList(SceneRole sceneRole) {
return sceneRoleMapper.selectSceneRoleList(sceneRole);
}
/**
* 新增场景题目
*
* @param sceneRole 场景题目
* @return 结果
*/
@Override
public int insertSceneRole(SceneRole sceneRole) {
UserBean userBean = userApi.getCurrentUser();
if (Objects.nonNull(userBean)) {
sceneRole.setCreator(userBean.getUserName());
sceneRole.setCreateTime(DateUtils.getNowDate());
}
sceneRole.setGuid(StringUtils.getUUID());
return sceneRoleMapper.insertSceneRole(sceneRole);
}
/**
* 修改场景题目
*
* @param sceneRole 场景题目
* @return 结果
*/
@Override
public int updateSceneRole( SceneRole sceneRole) {
UserBean userBean = userApi.getCurrentUser();
if (Objects.nonNull(userBean)) {
sceneRole.setUpdateBy(userBean.getUserName());
}
sceneRole.setUpdateTime(DateUtils.getNowDate());
return sceneRoleMapper.updateSceneRole(sceneRole);
}
/**
* 删除场景题目对象
*
* @param guids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteSceneRoleByIds(String guids) {
return sceneRoleMapper.deleteSceneRoleByIds(Convert.toStrArray(guids));
}
}

97
lib/EmergencyService/zdxtEmergencyKnowledgeService/src/main/resources/mapper/SceneRoleMapper.xml

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zdxt.knowledge.mapper.SceneRoleMapper">
<resultMap type="com.zdxt.knowledge.domain.SceneRole" id="SceneRoleResult">
<result property="guid" column="guid"/>
<result property="name" column="name"/>
<result property="sceneId" column="scene_id"/>
<result property="status" column="status"/>
<result property="content" column="content"/>
<result property="creator" column="creator"/>
<result property="updateBy" column="update_by"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectSceneRoleVo">
select guid,
name,
scene_id,
status,
content,
creator,
create_time,
update_by,
update_time
from scene_role
</sql>
<select id="selectSceneRoleList" parameterType="SceneRole" resultMap="SceneRoleResult">
<include refid="selectSceneRoleVo"/>
<where>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="sceneId != null and sceneId != ''">and scene_id = #{sceneId}</if>
<if test="status != null ">and status = #{status}</if>
<if test="creator != null and creator != ''">and creator = #{creator}</if>
</where>
order by create_time desc
</select>
<select id="selectSceneRoleById" parameterType="String" resultMap="SceneRoleResult">
<include refid="selectSceneRoleVo"/>
where guid = #{guid}
</select>
<insert id="insertSceneRole" parameterType="SceneRole">
insert into scene_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="guid != null ">guid,</if>
<if test="name != null and name != ''">`name`,</if>
<if test="sceneId != null and sceneId != ''">scene_id,</if>
<if test="status != null ">status,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="createTime != null ">create_time,</if>
<if test="updateTime != null ">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="guid != null ">#{guid},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="sceneId != null and sceneId != ''">#{sceneId},</if>
<if test="status != null ">#{status},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="updateTime != null ">#{updateTime},</if>
</trim>
</insert>
<update id="updateSceneRole" parameterType="SceneRole">
update scene_role
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="status != null ">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
</trim>
where guid = #{guid}
</update>
<delete id="deleteSceneRoleById" parameterType="String">
delete
from scene_role
where guid = #{guid}
</delete>
<delete id="deleteSceneRoleByIds" parameterType="String">
delete from scene_role where guid in
<foreach item="guid" collection="array" open="(" separator="," close=")">
#{guid}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save