Commit bc1b51e5 authored by 胡斌's avatar 胡斌

智能分析平台备份提交

parent 42306cb2
package com.hp.cmsz.entity;
import javax.persistence.*;
@Entity
@Table(name = "FXJM_MODEL_PREVIEW_INFO_T")
public class PreviewParameter {
private Long previewId;
private String parameterName;
private String parameterValue;
private String parameterCode;
private String parameterSourceId;
@Id
@GeneratedValue(strategy= GenerationType.SEQUENCE, generator="PreviewParameterSequence")
@SequenceGenerator(name = "PreviewParameterSequence", sequenceName = "PARAMETER_SOURCE_SEQ", allocationSize=1)
public Long getPreviewId() {
return previewId;
}
public void setPreviewId(Long previewId) {
this.previewId = previewId;
}
public String getParameterName() {
return parameterName;
}
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
public String getParameterValue() {
return parameterValue;
}
public void setParameterValue(String parameterValue) {
this.parameterValue = parameterValue;
}
public String getParameterCode() {
return parameterCode;
}
public void setParameterCode(String parameterCode) {
this.parameterCode = parameterCode;
}
public String getParameterSourceId() {
return parameterSourceId;
}
public void setParameterSourceId(String parameterSourceId) {
this.parameterSourceId = parameterSourceId;
}
}
...@@ -17,7 +17,11 @@ import com.hp.cmsz.entity.ModelParameter; ...@@ -17,7 +17,11 @@ import com.hp.cmsz.entity.ModelParameter;
*/ */
public interface ModelParameterDao extends JpaSpecificationExecutor<ModelParameter>, public interface ModelParameterDao extends JpaSpecificationExecutor<ModelParameter>,
PagingAndSortingRepository<ModelParameter, Long> { PagingAndSortingRepository<ModelParameter, Long> {
List<ModelParameter> findAllByParameterIdIn(List<Long> id);
//根据参数ID更新数据模型ID //根据参数ID更新数据模型ID
@Modifying @Modifying
@Query("update ModelParameter mp set mp.dataModelId=:dataModelId where mp.parameterId in (:parameterIds)") @Query("update ModelParameter mp set mp.dataModelId=:dataModelId where mp.parameterId in (:parameterIds)")
...@@ -39,6 +43,7 @@ public interface ModelParameterDao extends JpaSpecificationExecutor<ModelParamet ...@@ -39,6 +43,7 @@ public interface ModelParameterDao extends JpaSpecificationExecutor<ModelParamet
//根据数据模型ID查找系统默认的参数d //根据数据模型ID查找系统默认的参数d
List<ModelParameter> findByDataModelIdAndIfSystemDefault(Long dataModelId, Long ifSystemDefault); List<ModelParameter> findByDataModelIdAndIfSystemDefault(Long dataModelId, Long ifSystemDefault);
//根据任务ID查找系统默认的参数d //根据任务ID查找系统默认的参数d
List<ModelParameter> findByTaskIdAndIfSystemDefault(Long taskId, Long ifSystemDefault); List<ModelParameter> findByTaskIdAndIfSystemDefault(Long taskId, Long ifSystemDefault);
......
package com.hp.cmsz.repository;
import com.hp.cmsz.entity.PreviewParameter;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface PreviewParameterDao extends JpaSpecificationExecutor<PreviewParameter>,
PagingAndSortingRepository<PreviewParameter, Long> {
}
...@@ -21,9 +21,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -21,9 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.text.ParseException; import java.text.ParseException;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Map;
import com.hp.cmsz.entity.commonmanage.RunTaskDetail; import com.hp.cmsz.entity.commonmanage.RunTaskDetail;
import com.hp.cmsz.entity.*; import com.hp.cmsz.entity.*;
...@@ -79,6 +77,9 @@ public class TaskManageController { ...@@ -79,6 +77,9 @@ public class TaskManageController {
@Autowired @Autowired
private SystemParameterDao systemParameterDao; private SystemParameterDao systemParameterDao;
@Autowired
private PreviewParameterDao previewParameterDao;
@RequestMapping(value = "/taskHome") @RequestMapping(value = "/taskHome")
public ModelAndView taskHome(String selectTab) { public ModelAndView taskHome(String selectTab) {
...@@ -335,48 +336,55 @@ public class TaskManageController { ...@@ -335,48 +336,55 @@ public class TaskManageController {
@RequestMapping(value = "/modelPreview") @RequestMapping(value = "/modelPreview")
@ResponseBody @ResponseBody
public APPEWarningDetail ModelPreview(String id){ public APPEWarningDetail ModelPreview(String id,String previewId){
// APPEWarningDetail app = null; // APPEWarningDetail app = null;
APPEWarningDetail app = new APPEWarningDetail(); APPEWarningDetail app = new APPEWarningDetail();
String modelSavePath = systemParameterDao.findByParameterName("MODEL_SCRIPT_FILE_DIR").get(0).getParameterValue(); String modelSavePath = systemParameterDao.findByParameterName("MODEL_SCRIPT_FILE_DIR").get(0).getParameterValue();
RunTask rt = runTaskService.getRunTask(Long.parseLong(id)); RunTask rt = runTaskService.getRunTask(Long.parseLong(id));
String path =modelSavePath+"/"+rt.getDataModelView().getModelScriptName()+" "+id+" 1"; String path =modelSavePath+"/"+rt.getDataModelView().getModelScriptName()+" "+id+" 1 "+previewId;
// String path ="d:\\rscript\\a.r"; // String path ="d:\\rscript\\a.r";
try { // try {
Runtime run = Runtime.getRuntime();// 返回与当前 Java 应用程序相关的运行时对象 // Runtime run = Runtime.getRuntime();// 返回与当前 Java 应用程序相关的运行时对象
try { // try {
String cmds = "Rscript "+path; // 注意:对字符串中路径\进行转义 // String cmds = "Rscript "+path; // 注意:对字符串中路径\进行转义
Process p = run.exec(cmds);// 启动另一个进程来执行命令 // Process p = run.exec(cmds);// 启动另一个进程来执行命令
InputStream is = p.getInputStream(); // InputStream is = p.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); // BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null; // String line = null;
//[1] "13500001" // //[1] "13500001"
StringBuffer context = new StringBuffer(); // StringBuffer context = new StringBuffer();
while ((line = reader.readLine()) != null){ // while ((line = reader.readLine()) != null){
System.out.println(line); // System.out.println(line);
context.append(line); // context.append(line);
} // }
//
System.out.println("context:"+context); // System.out.println("context:"+context);
int i = context.indexOf("EWARNING_DETAIL_ID:"); // int i = context.indexOf("EWARNING_DETAIL_ID:");
String k = context.substring(i+19,context.length()-1); // String k = context.substring(i+19,context.length()-1);
//
p.waitFor(); // p.waitFor();
is.close(); // is.close();
reader.close(); // reader.close();
p.destroy(); // p.destroy();
app = aPPEWarningDetailDao.findByEwarningDetailId(Long.parseLong(k)); // app = aPPEWarningDetailDao.findByEwarningDetailId(Long.parseLong(k));
//
app.seteWarningCalcResult(eWarningCalcResultDao.findByEwarningDetailId(app.getEwarningDetailId())); // app.seteWarningCalcResult(eWarningCalcResultDao.findByEwarningDetailId(app.getEwarningDetailId()));
//
//
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
}catch (Exception e){ // }catch (Exception e){
System.out.println("错误:"+e.toString()); // System.out.println("错误:"+e.toString());
} // }
System.out.println(path);
app = aPPEWarningDetailDao.findByEwarningDetailId(Long.parseLong("13500001"));
app.seteWarningCalcResult(eWarningCalcResultDao.findByEwarningDetailId(app.getEwarningDetailId()));
return app; return app;
}; };
...@@ -431,8 +439,30 @@ public class TaskManageController { ...@@ -431,8 +439,30 @@ public class TaskManageController {
paramValArr = new String[]{parameterVal}; paramValArr = new String[]{parameterVal};
} }
} }
List<Long> paramIdList = new ArrayList<Long>();
for (String aParamIdArr : paramIdArr) {
paramIdList.add(Long.parseLong(aParamIdArr));
}
return "success"; List<ModelParameter> mpL = modelParameterDao.findAllByParameterIdIn(paramIdList);
String t = new Date().getTime()+"";
for (int i=0;i<mpL.size();i++) {
for (Long aLong : paramIdList) {
if(aLong.equals(mpL.get(i).getParameterId())){
PreviewParameter pp = new PreviewParameter();
pp.setParameterName(mpL.get(i).getParameterName());
assert paramValArr != null;
pp.setParameterValue(paramValArr[i]);
pp.setParameterCode(mpL.get(i).getParameterCode());
pp.setParameterSourceId(t);
// assert paramValArr != null;
// mpL.get(i).setParameterValue();
previewParameterDao.save(pp);
}
}
}
// modelParameterDao.save(mpL);
return "success?"+t;
} }
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
var content ="<div class='dialog-p' style='max-height: 560px; overflow-y: scroll; overflow-x: auto;'>" + var content ="<div class='dialog-p' style='max-height: 560px; overflow-y: scroll; overflow-x: auto;'>" +
" <div class='col-xs-12'>" + " <div class='col-xs-12'>" +
" <div class='panel panel-default'>" + " <div class='panel panel-default'>" +
" <div class='panel-heading'>模型预览<input onclick='editTask(this)' id='"+taskType+"_"+id+"' style='float:right' type='button' class='btn btn-primary' value='参数修改'></div>" + " <div class='panel-heading'>模型预览</div>" +
" <div class='panel-body'>"+ " <div class='panel-body'>"+
" <table class='table table-vertical'>"+ " <table class='table table-vertical'>"+
" <tr><td>"+ " <tr><td>"+
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<script src="${ctx}/static/js/slideCommon.js"></script> <script src="${ctx}/static/js/slideCommon.js"></script>
<%-- <script src="${ctx}/static/js/mlpushmenu.js"></script> --%> <%-- <script src="${ctx}/static/js/mlpushmenu.js"></script> --%>
<script language="javascript"> <script language="javascript">
var paraDialog = null;
var taskName = ""; var taskName = "";
<c:if test="${queryCondition.defaultTaskType == 1}"> <c:if test="${queryCondition.defaultTaskType == 1}">
...@@ -112,25 +113,14 @@ taskName = "自定义任务"; ...@@ -112,25 +113,14 @@ taskName = "自定义任务";
}); });
} }
function preview(){ function preview(){
var id = $('input[name="taskId"]:checked').val();
var taskType = '${queryCondition.defaultTaskType}';
<%--${ctx}/static/images/loading.gif--%> <%--${ctx}/static/images/loading.gif--%>
$("#loading").show();
$.ajax({ parameterChange()
type : 'GET',
'url' : '${ctx}/BaseManage/TaskManage/modelPreview?id='+id,
data : "",
success : function(data) {
$("#loading").hide();
parent.OpenDialog(data,id,taskType);
}
});
} }
function parameterChange() { function parameterChange() {
var id = $('input[name="taskId"]:checked').val(); var id = $('input[name="taskId"]:checked').val();
$.ajax({ $.ajax({
...@@ -151,10 +141,11 @@ taskName = "自定义任务"; ...@@ -151,10 +141,11 @@ taskName = "自定义任务";
"</tbody>" + "</tbody>" +
"</table>" + "</table>" +
"<div><button class='btn-sm btn btn-success btn-sm btn-group btn-group-cog' onclick='changeParameter();'>确认</button></div>"+ "<div><button class='btn-sm btn btn-success btn-sm btn-group btn-group-cog' onclick='changeParameter();'>确认</button></div>"+
"<div><button class='btn-sm btn btn-warning btn-sm btn-group btn-group-cog' onclick='cancel();'>取消预览</button></div>"+
"</div>"; "</div>";
$.dialog({ paraDialog = $.dialog({
title:'参数修改', title:'预览参数修改',
content:context, content:context,
lock: true lock: true
}); });
...@@ -166,22 +157,44 @@ taskName = "自定义任务"; ...@@ -166,22 +157,44 @@ taskName = "自定义任务";
function changeParameter() { function changeParameter() {
var paramId = ""; var paramId = "";
var paramVal = ""; var paramVal = "";
var trL = $('tr[class="parameterTr"]').each(function(){ var id = $('input[name="taskId"]:checked').val();
var taskType = '${queryCondition.defaultTaskType}';
$('tr[class="parameterTr"]').each(function(){
paramId+= $(this).context.id+","; paramId+= $(this).context.id+",";
paramVal+= $(this).find("input").val()+","; paramVal+= $(this).find("input").val()+",";
}); });
paramId = paramId.substring(0,paramId.length-1) paramId = paramId.substring(0,paramId.length-1);
paramVal = paramVal.substring(0,paramVal.length-1) paramVal = paramVal.substring(0,paramVal.length-1);
$.ajax({ $.ajax({
url:'${ctx}/BaseManage/TaskManage/updateParameter?parameterId='+paramId+"&parameterVal="+paramVal, url:'${ctx}/BaseManage/TaskManage/updateParameter?parameterId='+paramId+"&parameterVal="+paramVal,
type:'get', type:'get',
success:function (data) { success:function (data) {
var state = data.split("?")[0];
var t = data.split("?")[1];
if(state ==="success"){
paraDialog.close();
$("#loading").show();
$.ajax({
type : 'GET',
'url' : '${ctx}/BaseManage/TaskManage/modelPreview?id='+id+"&previewId="+t,
data : "",
success : function(data) {
$("#loading").hide();
parent.OpenDialog(data,id,taskType);
}
});
}
}
}
}) })
}
function cancel() {
paraDialog.close()
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<%--create by afe 2017-10-26--%> <%--create by afe 2017-10-26--%>
<c:if test="${runTask.defaultTaskType == '1' || runTask.defaultTaskType == '5' }"> <c:if test="${runTask.defaultTaskType == '1' || runTask.defaultTaskType == '5' }">
<button class="btn-sm btn btn-primary btn-sm btn-group btn-group-cog" id="ModelPreview" onclick="preview()" disabled>模型预览</button> <button class="btn-sm btn btn-primary btn-sm btn-group btn-group-cog" id="ModelPreview" onclick="preview()" disabled>模型预览</button>
<button class="btn-sm btn btn-primary btn-sm btn-group btn-group-cog" id="parameterChange" onclick="parameterChange()" disabled>参数修改</button>
</c:if> </c:if>
</div> </div>
</div> </div>
......
...@@ -555,7 +555,7 @@ function selectRule(qualityRuleId){ ...@@ -555,7 +555,7 @@ function selectRule(qualityRuleId){
$.ajax({ $.ajax({
type : 'GET', type : 'GET',
contentType : 'application/json', contentType : 'application/json',
url: "${ctx}/AnalysisSupport/QualityRuleResult/findAccuracy?qualityRuleId="+qualityRuleId, url: "/AnalysisSupport/QualityRuleResult/findAccuracy?qualityRuleId="+qualityRuleId,
dataType : 'text', dataType : 'text',
beforeSend: function(data) { beforeSend: function(data) {
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment