Commit 793255b1 authored by liuna's avatar liuna

2017年12月15日 智能分析平台提交内容

--数据质量规则批量插入优化和投诉文本明细数据筛选项更新条件字段
parent 3708ac12
This diff is collapsed.
......@@ -185,4 +185,28 @@ public class QualityRuleOperationDetail {
public void setWarningNum(Long warningNum) {
this.warningNum = warningNum;
}
@Override
public String toString() {
return "QualityRuleOperationDetail{" +
"qualityRuleId=" + qualityRuleId +
", kpiId=" + kpiId +
", businessId=" + businessId +
", channelId=" + channelId +
", dataSourceId=" + dataSourceId +
", provinceId=" + provinceId +
", kpiMonitorRunTime=" + kpiMonitorRunTime +
", businessTime=" + businessTime +
", kpiName='" + kpiName + '\'' +
", kpiCode='" + kpiCode + '\'' +
", businessName='" + businessName + '\'' +
", channelName='" + channelName + '\'' +
", dataSourceName='" + dataSourceName + '\'' +
", provinceName='" + provinceName + '\'' +
", warningType='" + warningType + '\'' +
", ifFilter=" + ifFilter +
", warningReason='" + warningReason + '\'' +
", warningNum=" + warningNum +
'}';
}
}
......@@ -2,6 +2,8 @@ package com.hp.cmsz.repository;
import com.hp.cmsz.entity.QualityRuleOperationDetail;
import com.hp.cmsz.entity.QualityRuleReport;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
......@@ -10,5 +12,6 @@ import java.util.List;
public interface QualityRuleReportInfoDao extends JpaSpecificationExecutor<QualityRuleOperationDetail>,
PagingAndSortingRepository<QualityRuleOperationDetail, Long> {
List<QualityRuleOperationDetail> findByProvinceIdAndKpiIdAndBusinessTimeBetweenOrderByBusinessTimeDescProvinceIdDescWarningNumAsc(Long provinceId, Long kpiId, Timestamp startTime, Timestamp endTime);
Page<QualityRuleOperationDetail> findByProvinceIdAndKpiIdAndBusinessTimeBetweenOrderByBusinessTimeDescProvinceIdDescWarningNumAsc(Long provinceId, Long kpiId, Timestamp startTime, Timestamp endTime,Pageable pageable);
}
......@@ -12,7 +12,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface TSWB_YZDetailDataDao extends JpaSpecificationExecutor<TSWB_YZDetailData>,
PagingAndSortingRepository<TSWB_YZDetailData, Long> {
Page<TSWB_YZDetailData> findByProcessingTime(String month, Pageable pageable);
Page<TSWB_YZDetailData> findByFilingTime(String month, Pageable pageable);
}
......@@ -52,6 +52,7 @@ public class QualityRuleInfoService {
public List<QualityRuleReport> findBy(Long provinceId, Long kpiId, Timestamp startTime, Timestamp endTime){
return qualityRuleInfoDao.findByProvinceIdAndKpiIdAndBusinessTimeBetweenOrderByBusinessTimeDescProvinceIdDescWarningNumAsc(provinceId,kpiId,startTime,endTime);
}
/**
* 创建分页请求.
*/
......
package com.hp.cmsz.service.analysissupport;
import com.hp.cmsz.entity.QualityRuleInfo;
import com.hp.cmsz.entity.QualityRuleOperationDetail;
import com.hp.cmsz.entity.QualityRuleReport;
import com.hp.cmsz.repository.QualityRuleReportInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.sql.Timestamp;
import java.util.List;
@Service
@Transactional
public class QualityRuleReportInfoService {
@Autowired
private QualityRuleReportInfoDao qualityRuleReportInfoDao;
public List<QualityRuleOperationDetail> findBy(Long provinceId, Long kpiId, Timestamp startTime, Timestamp endTime){
return qualityRuleReportInfoDao.findByProvinceIdAndKpiIdAndBusinessTimeBetweenOrderByBusinessTimeDescProvinceIdDescWarningNumAsc(provinceId,kpiId,startTime,endTime);
@PersistenceContext
EntityManager em;
public Page<QualityRuleOperationDetail> findBy(QualityRuleOperationDetail qualityRuleOperationDetail, int pageNumber, int pageSize, String sortType, Long provinceId, Long kpiId, Timestamp startTime, Timestamp endTime){
PageRequest pageRequest = buildPageRequest(pageNumber, pageSize, sortType, "qualityRuleId");
return qualityRuleReportInfoDao.findByProvinceIdAndKpiIdAndBusinessTimeBetweenOrderByBusinessTimeDescProvinceIdDescWarningNumAsc(provinceId,kpiId,startTime,endTime,pageRequest);
}
/**
* 创建分页请求.
*/
private PageRequest buildPageRequest(int pageNumber, int pagzSize, String sortType, String sortFiled) {
Sort sort = new Sort(Sort.Direction.DESC, sortFiled);
return new PageRequest(pageNumber - 1, pagzSize, sort);
}
public List getData(String jhql) {
List dataList = em.createNativeQuery(jhql).getResultList();
em.close();
return dataList;
}
}
package com.hp.cmsz.service.analysissupport;
import com.hp.cmsz.entity.QualityRule;
import com.hp.cmsz.repository.QualityRuleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.sql.Timestamp;
import java.util.List;
......@@ -17,9 +20,24 @@ import java.util.List;
@Transactional
public class QualityRuleService {
@PersistenceContext
protected EntityManager em;
@Autowired
private QualityRuleDao qualityRuleDao;
//批量插入
@Transactional
public void insertIntoRule(List<QualityRule> qualityRules){
for (int i = 0; i < qualityRules.size(); i++) {
em.persist(qualityRules.get(i));
if (i % 100 == 0) {
em.flush();
em.clear();
}
}
}
//根据质量规则ID删除质量规则
@Transactional(readOnly=false)
public void deleteByQualityRuleId(List<Long> qualityRuleId){
......
......@@ -98,11 +98,11 @@ public class TSWBAnalysisService {
Date endTime) {
List<SearchFilter> filterList = new ArrayList<SearchFilter>();
if (startTime != null ) {
filterList.add(new SearchFilter("processingTime", SearchFilter.Operator.GTE, startTime));
filterList.add(new SearchFilter("filingTime", SearchFilter.Operator.GTE, startTime));
}
if (endTime != null ) {
filterList.add(new SearchFilter("processingTime", SearchFilter.Operator.LTE, endTime));
filterList.add(new SearchFilter("filingTime", SearchFilter.Operator.LTE, endTime));
}
Specification<TSWB_YZDetailData> spec = DynamicSpecifications.bySearchFilter(filterList, TSWB_YZDetailData.class);
return spec;
......
......@@ -260,22 +260,18 @@ public class QualityRuleMaintainController {
@RequestParam(value="frequencyValue") String frequencyValue,
@RequestParam(value="businessTime") String businessTime,
HttpServletResponse response, HttpServletRequest request) throws ParseException {
System.out.println("frequencyType:"+frequencyType+"kpiMonitorTimeValue:"+frequencyValue);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<Long> provinceIdList = new ArrayList<Long>();
for(int i=0;i<province.split(",").length;i++){
provinceIdList.add(Long.parseLong(province.split(",")[i]));
}
List<Long> businessIdList = new ArrayList<Long>();
for(int i=0;i<business.split(",").length;i++){
businessIdList.add(Long.parseLong(business.split(",")[i]));
}
List<Long> kpiIdList = new ArrayList<Long>();
for(int i=0;i<kpi.split(",").length;i++){
kpiIdList.add(Long.parseLong(kpi.split(",")[i]));
}
List<QualityRule> qualityRuleList = new ArrayList<QualityRule>();
for(int j=0; j<provinceIdList.size(); j++) {
for(int l=0; l<kpiIdList.size(); l++){
QualityRule qualityRule = new QualityRule();
......@@ -312,17 +308,18 @@ public class QualityRuleMaintainController {
qualityRule.setRuleUpdateTime(Timestamp.valueOf(sd.format(new Date())));
qualityRule.setRuleValidFlag("1");
qualityRule.setIfSystemValue("1");
qualityRuleDao.save(qualityRule);
cmszOperationLogService.createLog("增加", "新建质量模型", "quality_rule_warehouse_info_t. QUALITY_RULE_ID=" + qualityRule.getQualityRuleId().toString());
cmszOperationLogService.createLog("增加", "新建质量模型","");
Long qualityRuleId = qualityRule.getQualityRuleId();
if(!qualityRuleIdList.isEmpty()){
accuracyRuleService.updateAccuracyRuleByAccuracyRuleIds(qualityRuleId, qualityRuleIdList);
qualityRuleIdList.clear();
}
qualityRuleList.add(qualityRule);
}
}
qualityRuleService.insertIntoRule(qualityRuleList);
return "redirect:/AnalysisSupport/QualityRuleResult";
}
}
......@@ -14,11 +14,14 @@ import com.hp.cmsz.service.analysissupport.QualityRuleReportInfoService;
import com.hp.cmsz.service.analysissupport.QualityRuleReportService;
import com.hp.cmsz.web.PageURLController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.HtmlUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
......@@ -162,31 +165,30 @@ public class QualityRuleReportController {
}
//查看数据质量运营内容
@RequestMapping(value = "/findOperation*",method = RequestMethod.GET)
@ResponseBody
public void findQuality(
@RequestMapping(value = "/findOperationFrame")
public ModelAndView findQuality(
@RequestParam(value = "provinceId") String provinceId,
@RequestParam(value = "kpiId") String kpiId,
@RequestParam(value = "reportSumStartTime") String reportSumStartTime,
@RequestParam(value = "reportSumEndTime") String reportSumEndTime,
@RequestParam(value = "sortType", defaultValue = "parameterId") String sortType,
@RequestParam(value = "page", defaultValue = "1") int pageNumber,
@RequestParam(value = "pageSize", defaultValue = "30") int pageSize,
HttpServletResponse response) throws ParseException{
ModelAndView modelAndView = new ModelAndView("AnalysisSupport/ReportOperationTable");
QualityRuleOperationDetail qualityRuleOperationDetail = new QualityRuleOperationDetail();
Long province = Long.parseLong(provinceId);
Long kpi = Long.parseLong(kpiId);
Timestamp startTime = Timestamp.valueOf(reportSumStartTime);
Timestamp endTime =Timestamp.valueOf(reportSumEndTime);
List<QualityRuleOperationDetail> qualityRuleReportList = qualityRuleReportInfoService.findBy(province,kpi,startTime,endTime);
sortType = HtmlUtils.htmlEscape(sortType);
Page<QualityRuleOperationDetail> qualityRuleOperationDetailPage = qualityRuleReportInfoService.findBy(qualityRuleOperationDetail, pageNumber, pageSize, sortType,province,kpi,startTime,endTime);
modelAndView.addObject("qualityRuleOperationDetailPage", qualityRuleOperationDetailPage);
modelAndView.addObject("pageSize", pageSize);
modelAndView.addObject("sortType", sortType);
cmszOperationLogService.createLog("查询","数据质量规则运营","查询数据质量运营明细");
Gson gson = new Gson();
response.setContentType("text/Xml;charset=gbk");
PrintWriter out = null;
try {
out = response.getWriter();
out.println(gson.toJson(qualityRuleReportList));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return modelAndView;
}
}
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<table class="table table-hover table-striped">
<thead>
<tr>
<th width="6.4%">省份</th>
<th width="6.4%">数据来源</th>
<th width="6.4%">渠道</th>
<th width="6.4%">业务</th>
<th width="6.4%">指标名称</th>
<th width="6.4%">指标编码</th>
<th width="6.4%">告警类型</th>
<th width="6.4%">告警原因</th>
<th width="6.4%">指标监控范围</th>
<th width="6.4%">指标采集时间</th>
</tr>
</thead>
<tbody>
<c:forEach items="${qualityRuleOperationDetailPage.content}" var="qualityRuleOperationDetail">
<tr>
<td>${qualityRuleOperationDetail.provinceName} </td>
<td>${qualityRuleOperationDetail.dataSourceName}</td>
<td>${qualityRuleOperationDetail.channelName}</td>
<td>${qualityRuleOperationDetail.businessName}</td>
<td>${qualityRuleOperationDetail.kpiName}</td>
<td>${qualityRuleOperationDetail.kpiCode}</td>
<td>${qualityRuleOperationDetail.warningType}</td>
<td>${qualityRuleOperationDetail.warningReason}</td>
<td><fmt:formatDate value="${qualityRuleOperationDetail.kpiMonitorRunTime}" pattern="yyyy-MM-dd hh:mm:ss" /> </td>
<td><fmt:formatDate value="${qualityRuleOperationDetail.businessTime}" pattern="yyyy-MM-dd hh:mm:ss" /></td>
</tr>
</c:forEach>
</tbody>
</table>
<tags:paging page="${qualityRuleOperationDetailPage}" paginationSize="${pageSize}" />
......@@ -38,8 +38,8 @@
<td>${qualityRuleInfo.kpiCode}</td>
<td>${qualityRuleInfo.warningType}</td>
<td>${qualityRuleInfo.warningReason}</td>
<td>${qualityRuleInfo.kpiMonitorRunTime}</td>
<td>${qualityRuleInfo.businessTime}</td>
<td><fmt:formatDate value="${qualityRuleInfo.kpiMonitorRunTime}" pattern="yyyy-MM-dd hh:mm:ss" /></td>
<td><fmt:formatDate value="${qualityRuleInfo.businessTime}" pattern="yyyy-MM-dd hh:mm:ss" /></td>
<%--<td>--%>
<%--<c:if test="${qualityRuleInfo.ifFilter == '0'}">未过滤</c:if>--%>
<%--<c:if test="${qualityRuleInfo.ifFilter == '1'}">已过滤</c:if>--%>
......
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