Commit dc3075b8 authored by 胡斌's avatar 胡斌

Merge remote-tracking branch 'origin/liuna'

parents dc21cad1 a9b58bd0
......@@ -41,6 +41,9 @@ public interface KpiDao extends JpaSpecificationExecutor<Kpi>,PagingAndSortingRe
@Query("select businessId from Kpi kpi where kpiId=:kpiId")
Long findBusinessIdByKpiId(@Param("kpiId") Long kpiId);
//由指标得到指标名
@Query("select kpiCode from Kpi kpi where kpi.kpiId in :kpiIdList")
List<String> findKpiCodeByBusinessIds(@Param("kpiIdList") List<Long> kpiIdList);
//由指标名得到指标周期类型
@Query("select kpiCycleType.isHourKpi from Kpi kpi,KpiCycleType kpiCycleType where kpi.kpiCycleTypeId=kpiCycleType.kpiCycleTypeId and kpi.kpiName IN (:kpiName) and kpi.kpiId >=0")
......
......@@ -15,4 +15,7 @@ public interface QualityRuleViewDao extends JpaSpecificationExecutor<QualityRule
//根据筛选项得到质量规则
List<QualityRuleView> findByDataSourceIdInAndChannelIdInAndBusinessIdInOrderByQualityRuleIdAscBusinessTimeDesc(List<Long> dataSource,List<Long> chnnal,List<Long> busines);
//筛选项加指标编码
List<QualityRuleView> findByDataSourceIdInAndChannelIdInAndBusinessIdInAndKpiCodeOrderByQualityRuleIdAscBusinessTimeDesc(List<Long> dataSource,List<Long> chnnal,List<Long> busines,String kpiCode);
}
......@@ -20,4 +20,9 @@ public class QualityRuleViewService {
return qualityRuleViewDao.findByDataSourceIdInAndChannelIdInAndBusinessIdInOrderByQualityRuleIdAscBusinessTimeDesc(dataSource,chnnal,busines);
}
//筛选项加指标编码查询
public List<QualityRuleView> getBy(List<Long> dataSource, List<Long> chnnal, List<Long> busines, String kpiCode){
return qualityRuleViewDao.findByDataSourceIdInAndChannelIdInAndBusinessIdInAndKpiCodeOrderByQualityRuleIdAscBusinessTimeDesc(dataSource,chnnal,busines,kpiCode);
}
}
......@@ -2,6 +2,8 @@ package com.hp.cmsz.web.analysissupport;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -261,7 +263,7 @@ public class QualityRuleMaintainController {
List<Long> kList = qualityRuleDao.findByKpiIds(kpiIdList);
System.out.println(kList);
String sr = null;
String sr = "";
if (kList==null || kList.size()==0) {
for (int j = 0; j < provinceIdList.size(); j++) {
for (int l = 0; l < kpiIdList.size(); l++) {
......@@ -319,7 +321,66 @@ public class QualityRuleMaintainController {
sr="1";
} else {
sr= "2";
kpiIdList.removeAll(kList);
System.out.println(kpiIdList);
for (int j = 0; j < provinceIdList.size(); j++) {
for (int l = 0; l < kpiIdList.size(); l++) {
QualityRule qualityRule = new QualityRule();
qualityRule.setProvinceId(provinceIdList.get(j));
qualityRule.setKpiId(kpiIdList.get(l));
Long businessId = kpiDao.findBusinessIdByKpiId(kpiIdList.get(l));
qualityRule.setBusinessId(businessId);
if (!channel.trim().equals("")) {
qualityRule.setChannelId(Long.parseLong(channel));
}
if (!dataSourceId.trim().equals("")) {
qualityRule.setDataSourceId(Long.parseLong(dataSourceId));
}
if (!frequencyValue.trim().equals("")) {
qualityRule.setFrequencyValue(Long.parseLong(frequencyValue));
qualityRule.setFrequencyType(Long.parseLong(frequencyType));
if (frequencyType.equals("0")) {
qualityRule.setKpiMonitorTime(frequencyValue + "/1440");
} else if (frequencyType.equals("1")) {
qualityRule.setKpiMonitorTime(frequencyValue + "/24");
} else if (frequencyType.equals("2")) {
qualityRule.setKpiMonitorTime(frequencyValue);
} else if (frequencyType.equals("3")) {
qualityRule.setKpiMonitorTime("ADD_MONTH(" + frequencyValue + ")");
}
}
if (!businessTime.trim().equals("")) {
qualityRule.setBusinessTime(Timestamp.valueOf(businessTime));
}
if (!frequencyValue.trim().equals("")) {
if (frequencyType.equals("0")) {
qualityRule.setKpiMonitorRunTime(Timestamp.valueOf(sd.format(sd.parse(businessTime).getTime() + Integer.parseInt(frequencyValue) * 60 * 1000)));
} else if (frequencyType.equals("1")) {
qualityRule.setKpiMonitorRunTime(Timestamp.valueOf(sd.format(sd.parse(businessTime).getTime() + Integer.parseInt(frequencyValue) * 60 * 60 * 1000)));
} else if (frequencyType.equals("2")) {
qualityRule.setKpiMonitorRunTime(Timestamp.valueOf(sd.format(sd.parse(businessTime).getTime() + Integer.parseInt(frequencyValue) * 24 * 60 * 60 * 1000)));
} else if (frequencyType.equals("3")) {
qualityRule.setKpiMonitorRunTime(Timestamp.valueOf(sd.format(sd.parse(businessTime).getMonth() + Integer.parseInt(frequencyValue))));
}
}
qualityRule.setRuleCrtTime(Timestamp.valueOf(sd.format(new Date())));
qualityRule.setRuleUpdateTime(Timestamp.valueOf(sd.format(new Date())));
qualityRule.setRuleValidFlag("1");
qualityRule.setIfSystemValue("1");
qualityRuleDao.save(qualityRule);
cmszOperationLogService.createLog("增加", "新建质量模型", "");
Long qualityRuleId = qualityRule.getQualityRuleId();
if (!qualityRuleIdList.isEmpty()) {
accuracyRuleService.updateAccuracyRuleByAccuracyRuleIds(qualityRuleId, qualityRuleIdList);
qualityRuleIdList.clear();
}
}
}
List<String> kpiNameList = kpiDao.findKpiCodeByBusinessIds(kList);
for (int i = 0; i < kpiNameList.size(); i++) {
sr += kpiNameList.get(i)+",";
}
System.out.println("sr="+sr);
}
return "redirect:/AnalysisSupport/QualityRuleResult?sr="+sr;
}
......
......@@ -115,8 +115,9 @@ public class QualityRuleResultController {
@RequestParam(value = "dataSource") String dataSource,// 数据来源
@RequestParam(value = "chnnal") String chnnal,//渠道
@RequestParam(value = "bussines") String bussines,//业务
@RequestParam(value = "code") String code,
HttpServletResponse response) throws UnsupportedEncodingException{
cmszOperationLogService.createLog("查询","质量规则","由筛选项得到质量规则");
List<QualityRuleView> qualityRuleViewList;
String[] dataSourceS=dataSource.split(",");
......@@ -125,8 +126,11 @@ public class QualityRuleResultController {
List<Long> dataSourceList=changeStrToList(dataSourceS);
List<Long> chnnalList=changeStrToList(chnnalS);
List<Long> bussinesList=changeStrToList(bussinesS);
qualityRuleViewList = qualityRuleViewService.getQualityRuleViewBy(dataSourceList,chnnalList,bussinesList);
if(code.equals("")){
qualityRuleViewList = qualityRuleViewService.getQualityRuleViewBy(dataSourceList,chnnalList,bussinesList);
}else{
qualityRuleViewList = qualityRuleViewService.getBy(dataSourceList,chnnalList,bussinesList,code);
}
Gson gson = new Gson();
response.setContentType("text/Xml;charset=gbk");
PrintWriter out = null;
......
......@@ -8,7 +8,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hp.cmsz.entity.Kpi;
import com.hp.cmsz.repository.KpiDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......
......@@ -43,7 +43,11 @@
<div class="form">
<tags:Quality_dataSource_channel_business/>
<div id="kpiCodeDiv" class="slide-menu-option">
<label >指标编码</label>&nbsp;&nbsp;
<input id="kpiCodeID" class="form-control" type="text" style="width:250px;" onFocus="">
</div>
<button id="submit" class="btn btn-primary" onclick="ruleResultSubmit()">提交</button>
<button id="disable" class="btn btn-warning" onclick="ruleResultReset()">重置</button>
</div>
......@@ -62,6 +66,7 @@
<span id="ProvinceTag" class="label label-info" data-placement="bottom" ></span>
<span id="DataSourceTag" class="label label-info" data-placement="bottom" ></span>
<span id="BusinessTag" class="label label-info" data-placement="bottom" ></span>
<span id="KpiCodeTag" class="label label-info" data-placement="bottom" ></span>
</div>
</div>
......@@ -95,21 +100,21 @@
</div>
<script type="text/javascript" src="${ctx}/static/js/ruleResultDetailTable.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var url = decodeURI(window.location.search);
var a = url.split("?")[1];
$(document).ready(function(){
var url = decodeURI(window.location.search);
var a = url.split("?")[1];
if (a =="sr=1"){
$.dialog({
content:"成功生成数据质量规则!"
})
}else if (a =="sr=2"){
}else{
var list = a.split("=")[1];
list=list.substring(0,list.length-1);
$.dialog({
content:"已经存在此kpiId的数据质量规则!"
content:"已经存在"+list+"的数据质量规则!"
})
}
console.log(url.split("?")[1]);
});
}
});
var receiveRulePageNum = "${rulePageNum}";
ruleResultDetailTable();
......@@ -128,47 +133,90 @@ $("#createRule").click(function(){
var dataSource=getStatsDataSourceCheckedValuesString();
var chnnal=getStatsChannelCheckedValuesString();
var bussines=getStatsBusinessCheckedValuesString();
var code=$.trim(document.getElementById("kpiCodeID").value);
if(code ===""){
if(dataSource==""){
$.alert("数据来源的选择不能为空");
}else if(chnnal===""){
$.alert("渠道的选择不能为空");
}else if(bussines===""){
$.alert("业务的选择不能为空");
}else{
toggleMenu('slidePushMenus');//隐藏筛选项
//数据来源标签
$('#DataSourceTag').text("数据来源").append($("<span class='badge'></span>").text(getStatsDataSourceCheckedValues().length)).attr('data-original-title',getStatsDataSourceCheckedTitles()).tooltip();
if(dataSource==""){
$.alert("数据来源的选择不能为空");
}else if(chnnal===""){
$.alert("渠道的选择不能为空");
}else if(bussines===""){
$.alert("业务的选择不能为空");
}else{
toggleMenu('slidePushMenus');//隐藏筛选项
//数据来源标签
$('#DataSourceTag').text("数据来源").append($("<span class='badge'></span>").text(getStatsDataSourceCheckedValues().length)).attr('data-original-title',getStatsDataSourceCheckedTitles()).tooltip();
//渠道标签
$('#ChannelTag').text("渠道").append($("<span class='badge'></span>").text(getStatsChannelCheckedValues().length)).attr('data-original-title',getStatsChannelCheckedTitles()).tooltip();
//业务标签
$('#BusinessTag').text("业务").append($("<span class='badge'></span>").text(getStatsBusinessCheckedValues().length)).attr('data-original-title',getStatsBusinessCheckedTitlesString()).tooltip();
$.ajax({
type : 'GET',
contentType : 'application/json',
url: "${ctx}/AnalysisSupport/QualityRuleResult/ruleTableChange?dataSource="+dataSource+"&chnnal="+chnnal+"&bussines="+bussines,
dataType : 'text',
async: false,
beforeSend: function(data) {
},
success: function(data) {
$("#qualityRuleView").val(data);
ruleResultDetailTable();
qualityRuleId="";
$("#updateRule").attr("disabled", true);
toggleMenu('slidePushMenus2');//隐藏筛选项
}
});
}
//渠道标签
$('#ChannelTag').text("渠道").append($("<span class='badge'></span>").text(getStatsChannelCheckedValues().length)).attr('data-original-title',getStatsChannelCheckedTitles()).tooltip();
}
//业务标签
$('#BusinessTag').text("业务").append($("<span class='badge'></span>").text(getStatsBusinessCheckedValues().length)).attr('data-original-title',getStatsBusinessCheckedTitlesString()).tooltip();
function ruleResultReset(){
//指标编码
$("#KpiCodeTag").text("指标编码").attr('data-original-title',code).tooltip();
$.ajax({
type : 'GET',
contentType : 'application/json',
url: "${ctx}/AnalysisSupport/QualityRuleResult/ruleTableChange?dataSource="+dataSource+"&chnnal="+chnnal+"&bussines="+bussines+"&code"+code,
dataType : 'text',
async: false,
beforeSend: function(data) {
},
success: function(data) {
$("#qualityRuleView").val(data);
ruleResultDetailTable();
qualityRuleId="";
$("#updateRule").attr("disabled", true);
toggleMenu('slidePushMenus2');//隐藏筛选项
}
});
}
}else if(code!==""){
if(dataSource==""){
$.alert("数据来源的选择不能为空");
}else if(chnnal===""){
$.alert("渠道的选择不能为空");
}else if(bussines===""){
$.alert("业务的选择不能为空");
}else{
toggleMenu('slidePushMenus');//隐藏筛选项
//数据来源标签
$('#DataSourceTag').text("数据来源").append($("<span class='badge'></span>").text(getStatsDataSourceCheckedValues().length)).attr('data-original-title',getStatsDataSourceCheckedTitles()).tooltip();
//渠道标签
$('#ChannelTag').text("渠道").append($("<span class='badge'></span>").text(getStatsChannelCheckedValues().length)).attr('data-original-title',getStatsChannelCheckedTitles()).tooltip();
//业务标签
$('#BusinessTag').text("业务").append($("<span class='badge'></span>").text(getStatsBusinessCheckedValues().length)).attr('data-original-title',getStatsBusinessCheckedTitlesString()).tooltip();
//指标编码
$("#KpiCodeTag").text("指标编码").attr('data-original-title',code).tooltip();
$.ajax({
type : 'GET',
contentType : 'application/json',
url: "${ctx}/AnalysisSupport/QualityRuleResult/ruleTableChange?dataSource="+dataSource+"&chnnal="+chnnal+"&bussines="+bussines+"&code="+code,
dataType : 'text',
async: false,
beforeSend: function(data) {
},
success: function(data) {
$("#qualityRuleView").val(data);
ruleResultDetailTable();
qualityRuleId="";
$("#updateRule").attr("disabled", true);
toggleMenu('slidePushMenus2');//隐藏筛选项
}
});
}
}
}
function ruleResultReset(){
$("#kpiCodeID").attr("value",'');
statsDataSourceReset();//三级联动重置
}
$("#updateRule").click(function(){
......@@ -203,6 +251,9 @@ $("#deleteRule").click(function(){
});
});
</script>
</body>
</html>
\ No newline at end of file
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