Commit a9b58bd0 authored by liuna's avatar liuna

2017年12月24日 --智能分析平台

--解决数据质量规则遗留问题
parent 8b5b5a46
......@@ -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,6 +115,7 @@ 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("查询","质量规则","由筛选项得到质量规则");
......@@ -125,8 +126,11 @@ public class QualityRuleResultController {
List<Long> dataSourceList=changeStrToList(dataSourceS);
List<Long> chnnalList=changeStrToList(chnnalS);
List<Long> bussinesList=changeStrToList(bussinesS);
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;
......
......@@ -110,7 +110,6 @@
}else{
var list = a.split("=")[1];
list=list.substring(0,list.length-1);
console.log(list);
$.dialog({
content:"已经存在"+list+"的数据质量规则!"
})
......
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