Commit 72abfa59 by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !8
parents fd10b012 32db0ee9
package com.gic.cloud.data.hook.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* dh_search_log
*/
public class DhSearchLogDTO implements Serializable {
/**
*
*/
private Integer logId;
/**
*
*/
private String enterpriseId;
/**
*
*/
private String enterpriseName;
/**
*
*/
private String userId;
/**
*
*/
private String userName;
/**
* 1自助指标 2自定义指标 3开发自定义查询
*/
private Integer model;
/**
*
*/
private Integer count;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private Date createTime;
public Integer getLogId() {
return logId;
}
public void setLogId(Integer logId) {
this.logId = logId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getModel() {
return model;
}
public void setModel(Integer model) {
this.model = model;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
package com.gic.cloud.data.hook.api.dto;
import java.io.Serializable;
public class DownloadProcessDTO implements Serializable {
private Integer taskAmount;
private Integer dataAmount;
public Integer getTaskAmount() {
return taskAmount;
}
public void setTaskAmount(Integer taskAmount) {
this.taskAmount = taskAmount;
}
public Integer getDataAmount() {
return dataAmount;
}
public void setDataAmount(Integer dataAmount) {
this.dataAmount = dataAmount;
}
}
......@@ -216,4 +216,34 @@ public class DownloadRecord implements Serializable {
public void setReportId(String reportId) {
this.reportId = reportId;
}
protected Integer desensiType;
public Integer getDesensiType() {
return desensiType;
}
public void setDesensiType(Integer desensiType) {
this.desensiType = desensiType;
}
private String downloadCondition;
public String getDownloadCondition() {
return downloadCondition;
}
public void setDownloadCondition(String downloadCondition) {
this.downloadCondition = downloadCondition;
}
private String applyPermitted;
public String getApplyPermitted() {
return applyPermitted;
}
public void setApplyPermitted(String applyPermitted) {
this.applyPermitted = applyPermitted;
}
}
......@@ -347,8 +347,23 @@ public class DownloadTask implements Serializable {
this.applyPermitted = applyPermitted;
}
protected Integer desensiType;
public Integer getDesensiType() {
return desensiType;
}
public void setDesensiType(Integer desensiType) {
this.desensiType = desensiType;
}
private String downloadCondition;
public String getDownloadCondition() {
return downloadCondition;
}
public void setDownloadCondition(String downloadCondition) {
this.downloadCondition = downloadCondition;
}
}
......@@ -3,6 +3,7 @@ package com.gic.cloud.data.hook.api.dto;
import com.gic.cloud.data.hook.api.entity.Global;
import java.io.Serializable;
import java.util.Date;
/** 自助查询表定义 DTO
* @author Sam.Z
......@@ -148,4 +149,14 @@ public class FlatQueryTable implements Serializable {
public void setAuthDesc(String authDesc) {
this.authDesc = authDesc;
}
private Date lastUpdateTime;
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
}
......@@ -282,6 +282,23 @@ public class FlatQueryExecuteRequest implements Serializable {
this.realSql = realSql;
}
private Integer model = 1;
public Integer getModel() {
return model;
}
public void setModel(Integer model) {
this.model = model;
}
private Integer count = 0;
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}
package com.gic.cloud.data.hook.api.service;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.hook.api.dto.DownloadProcessDTO;
import com.gic.cloud.data.hook.api.dto.DownloadRecord;
import com.gic.cloud.data.hook.api.dto.DownloadTask;
import com.gic.cloud.data.hook.api.dto.RiskModeRecord;
......@@ -62,4 +63,8 @@ public interface IDownloadTaskService {
*/
public Page<RiskModeRecord> getRiskModeRecordPage(String enterpriseId, Date startTime, Date endTime, Integer riskDuration, String fuzzyRange, String fuzzy, Integer pageNum, Integer pageSize);
List<DownloadRecord> listUnDownloadTask(String source);
DownloadProcessDTO getDownloadProcess();
}
......@@ -63,4 +63,6 @@ public interface IFlatQueryResultService {
public List<Object> getFlatQueryFilterData(String tableId, List<String>enterpriseIds, String fieldName);
public void initTask();
}
......@@ -77,4 +77,6 @@ public interface IFreeQueryService {
FreeQuerySource getFreeQuerySource(String enterpriseId);
void initTask();
}
package com.gic.cloud.data.hook.api.service;
import com.gic.cloud.data.hook.api.dto.DhSearchLogDTO;
public interface SearchLogService {
void saveLog(DhSearchLogDTO dhSearchLogDTO);
}
#Dubbo Registry Cache
#Tue Sep 15 11:35:18 CST 2020
com.gic.cloud.data.hook.api.service.SearchLogService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.SearchLogService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.SearchLogService&methods\=saveLog&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140918276
com.gic.cloud.data.hook.api.service.IDownloadTaskService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.IDownloadTaskService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.IDownloadTaskService&methods\=createRiskModeRecord,listUnDownloadTask,createDownloadRecord,getRiskModeRecordPage,getDownloadRecordPage,deleteDownloadTask,getDownloadProcess,getDownloadTaskPage&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140918147
com.gic.cloud.data.hook.api.service.IFlatQueryTableService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.IFlatQueryTableService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.IFlatQueryTableService&methods\=queryFlatQueryFavo,queryFlatQueryTableById,queryFlatQueryTablePage,createFlatQueryFavo,removeFlatQueryFavo,queryFlatQueryTableDetailByTableId&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140918020
com.gic.cloud.data.hook.api.service.IFlatQueryResultService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.IFlatQueryResultService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.IFlatQueryResultService&methods\=getFlatQueryFilterData,initTask,estimateFlatQueryDownloadTask,buildFlatQueryDownloadTask,getFlatQueryResult&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140918093
com.gic.cloud.data.hook.api.service.IMyFlatQueryService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.IMyFlatQueryService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.IMyFlatQueryService&methods\=createMyFlatQuery,queryMyFlatQueryPage,deleteMyFlatQuery,updateMyFlatQuery,queryMyFlatQueryById&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140918216
com.gic.cloud.data.hook.api.service.IFreeQueryService=empty\://192.168.1.217\:20338/com.gic.cloud.data.hook.api.service.IFreeQueryService?anyhost\=true&application\=gic-cloud-data-hook&category\=configurators&check\=false&default.dispatcher\=maintenance&default.queues\=10000&default.retries\=0&default.threads\=30&default.timeout\=10000&dubbo\=2.8.5&generic\=false&interface\=com.gic.cloud.data.hook.api.service.IFreeQueryService&methods\=getFreeQueryRecordByUserIdAndRecordId,createFreeQueryRecord,deleteFreeQueryRecord,getColumnsByTable,buildFreeQueryDownloadTask,updateFreeQueryRecord,getFreeQueryResult,initTask,getFreeQuerySource,getFreeQueryCount,getFreeQueryRecordListByUserId,getFreeQueryTableList&payload\=41557050&pid\=16652&side\=provider&timeout\=120000&timestamp\=1600140917339
package com.gic.cloud.data.hook.service.dao;
import com.gic.cloud.data.hook.service.entity.DhSearchLog;
public interface DhSearchLogMapper {
/**
* 根据主键删除
*
* @param logId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer logId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(DhSearchLog record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(DhSearchLog record);
/**
* 根据主键查询
*
* @param logId 主键
* @return 实体对象
*/
DhSearchLog selectByPrimaryKey(Integer logId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(DhSearchLog record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(DhSearchLog record);
}
\ No newline at end of file
......@@ -29,4 +29,5 @@ public interface DownloadRecordDao {
@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("queryDataType") Integer queryDataType,
@Param("fuzzyRange") String fuzzyRange, @Param("fuzzy") String fuzzy);
List<DownloadRecord> listUnDownloadTask(@Param("source") String source);
}
package com.gic.cloud.data.hook.service.dao;
import com.gic.cloud.data.hook.api.dto.DownloadProcessDTO;
import com.gic.cloud.data.hook.api.dto.DownloadTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -61,4 +62,6 @@ public interface DownloadTaskDao {
*/
public List<DownloadTask> getDownloadTaskOfWaiting(@Param("queryDataSource") String queryDataSource);
DownloadProcessDTO getDownloadProcess();
}
package com.gic.cloud.data.hook.service.entity;
import java.util.Date;
/**
* dh_search_log
*/
public class DhSearchLog {
/**
*
*/
private Integer logId;
/**
*
*/
private String enterpriseId;
/**
*
*/
private String enterpriseName;
/**
*
*/
private String userId;
/**
*
*/
private String userName;
/**
* 1自助指标 2自定义指标 3开发自定义查询
*/
private Integer model;
/**
*
*/
private Integer count;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private Date createTime;
public Integer getLogId() {
return logId;
}
public void setLogId(Integer logId) {
this.logId = logId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getModel() {
return model;
}
public void setModel(Integer model) {
this.model = model;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
......@@ -3,10 +3,7 @@ package com.gic.cloud.data.hook.service.impl;
import cn.medubi.client.utils.LogPak;
import com.alibaba.fastjson.JSON;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.hook.api.dto.DownloadRecord;
import com.gic.cloud.data.hook.api.dto.DownloadTask;
import com.gic.cloud.data.hook.api.dto.FlatQueryTable;
import com.gic.cloud.data.hook.api.dto.RiskModeRecord;
import com.gic.cloud.data.hook.api.dto.*;
import com.gic.cloud.data.hook.api.entity.DownloadTaskStatus;
import com.gic.cloud.data.hook.api.entity.FreeQueryTaskCondition;
import com.gic.cloud.data.hook.api.entity.Global;
......@@ -246,6 +243,16 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
return result;
}
@Override
public List<DownloadRecord> listUnDownloadTask(String source) {
return this.downloadRecordDao.listUnDownloadTask(source);
}
@Override
public DownloadProcessDTO getDownloadProcess() {
DownloadProcessDTO downloadProcess = this.downloadTaskDao.getDownloadProcess();
return downloadProcess;
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.hook.api.dto.*;
import com.gic.cloud.data.hook.api.entity.*;
import com.gic.cloud.data.hook.api.service.IDownloadTaskService;
import com.gic.cloud.data.hook.api.service.IFlatQueryResultService;
import com.gic.cloud.data.hook.service.DecryptUtils;
import com.gic.cloud.data.hook.service.HiveHelper;
......@@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.io.*;
import java.math.BigDecimal;
......@@ -56,6 +58,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
@Autowired
FlatQueryTableDao flatQueryTableDao;
@Autowired
IDownloadTaskService downloadTaskService;
/** 自助指标查询关联的下载条件列表 */
protected List<FlatQueryTaskCondition> taskConditions = Lists.newArrayList();
......@@ -320,7 +324,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
log.debug("自助指标字段过滤请求:", sql);
ResultSet rs = stat.executeQuery(sql);
while (rs.next()) {
if(rs.getObject(fieldName) != null){
result.add(rs.getObject(fieldName));
}
} // WHILE OVER
} catch (Exception ex) {
ex.printStackTrace();
......@@ -436,9 +442,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
Integer preReportCount = DownloadTaskServiceImpl.getInstance().getDownloadTaskCountByEnterpriseId(curTask.getEnterpriseId());
curTask.setReportId(ServiceUtils.buildReportId(curTask.getQueryDataType(), preReportCount));
// 保存下载任务
DownloadTaskServiceImpl.getInstance().createDownloadTask(curTask);
// 生成条件
FlatQueryTaskCondition condition = new FlatQueryTaskCondition();
condition.setTaskId(curTask.getId());
......@@ -457,9 +460,29 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
condition.setAuthStoreIdList(authStoreIdList);
// 保存至列表
this.taskConditions.add(condition);
// 保存下载任务
curTask.setDownloadCondition(JSON.toJSONString(condition));
DownloadTaskServiceImpl.getInstance().createDownloadTask(curTask);
return curTask;
}
@Override
@PostConstruct
public void initTask(){
try {
List<DownloadRecord> list = this.downloadTaskService.listUnDownloadTask(QueryDataSource.FLAT_QUERY);
if(CollectionUtils.isNotEmpty(list)){
for(DownloadRecord record : list){
if(StringUtils.isNotBlank(record.getDownloadCondition())){
FlatQueryTaskCondition condition = JSON.parseObject(record.getDownloadCondition(), FlatQueryTaskCondition.class);
this.taskConditions.add(condition);
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private static SimpleDateFormat datetimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.gic.cloud.data.hook.api.dto.*;
import com.gic.cloud.data.hook.api.dto.DataDesensiType;
import com.gic.cloud.data.hook.api.entity.*;
import com.gic.cloud.data.hook.api.service.IDownloadTaskService;
import com.gic.cloud.data.hook.api.service.IFreeQueryService;
import com.gic.cloud.data.hook.service.HiveHelper;
import com.gic.cloud.data.hook.service.HttpUtils;
......@@ -17,6 +18,7 @@ import com.gic.cloud.data.hook.service.entity.CsvResultSetHelper;
import com.google.common.collect.Lists;
import com.opencsv.CSVWriter;
import com.opencsv.ResultSetHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
......@@ -25,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.*;
import java.nio.charset.Charset;
import java.sql.*;
......@@ -51,6 +54,9 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
/** 脱敏字段 */
public static final List<String> FILTERS_PHONE_AND_CARD = Arrays.asList("card_num", "mobile", "phone", "enterprise_name", "phone_number", "receive_phone_number","receive_card_num","use_phone_number", "use_card_num");
@Autowired
IDownloadTaskService downloadTaskService;
/** 获取指定脱敏类型的过滤字段集合
* @param desensiType
* @return
......@@ -278,6 +284,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
curTask.setUseCompress(useCompress ? Global.YES : Global.NO);
// 新增下载任务属性
curTask.setQueryDataType(queryDataType);
curTask.setDesensiType(desensiType);
curTask.setApplyId(applyId); // 设置申请编号
if (queryDataType == QueryDataType.SAFE) { // 如果是安全模式
curTask.setApplyPermitted(Global.YES); // 安全模式直接允许下载
......@@ -310,6 +317,33 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
@Override
@PostConstruct
public void initTask() {
try{
List<DownloadRecord> list = this.downloadTaskService.listUnDownloadTask(QueryDataSource.FREE_QUERY);
if(CollectionUtils.isNotEmpty(list)) {
for (DownloadRecord record : list) {
if(record.getDesensiType() != null){
FreeQueryTaskCondition condition = new FreeQueryTaskCondition();
condition.setTaskId(record.getId());
condition.setSql(record.getRealSql());
condition.setEnterpriseId(record.getEnterpriseId());
condition.setDesensiType(record.getDesensiType());
// 设置条件可否执行
if (record.getApplyPermitted().equals(Global.YES)) {
condition.setBuildPermitted(Global.YES);
} else condition.setBuildPermitted(Global.NO);
// 保存至列表
this.taskConditions.add(condition);
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private static SimpleDateFormat datetimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
......
package com.gic.cloud.data.hook.service.impl;
import com.gic.cloud.data.hook.api.dto.DhSearchLogDTO;
import com.gic.cloud.data.hook.api.service.SearchLogService;
import com.gic.cloud.data.hook.service.dao.DhSearchLogMapper;
import com.gic.cloud.data.hook.service.entity.DhSearchLog;
import com.gic.commons.util.EntityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("searchLogService")
public class SearchLogServiceImpl implements SearchLogService {
@Autowired
private DhSearchLogMapper dhSearchLogMapper;
@Override
public void saveLog(DhSearchLogDTO dhSearchLogDTO) {
dhSearchLogDTO.setCreateTime(new Date());
this.dhSearchLogMapper.insert(EntityUtil.changeEntityByJSON(DhSearchLog.class, dhSearchLogDTO));
}
}
package com.gic.cloud.data.hook.service.init;
import com.gic.cloud.data.hook.api.service.IFlatQueryResultService;
import com.gic.cloud.data.hook.api.service.IFreeQueryService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class MyApplicationContextAware implements ApplicationContextAware {
private Logger log = LogManager.getLogger(MyApplicationContextAware.class);
@Autowired
private IFreeQueryService freeQueryService;
@Autowired
private IFlatQueryResultService flatQueryResultService;
@Override
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
//this.freeQueryService.initTask();
//this.flatQueryResultService.initTask();
log.info("任务初始化");
}
}
......@@ -31,6 +31,8 @@
<bean class="com.gic.cloud.data.hook.service.impl.MyFlatQueryServiceImpl" id="myFlatQueryService" />
<dubbo:service interface="com.gic.cloud.data.hook.api.service.IMyFlatQueryService" ref="myFlatQueryService" timeout="120000" />
<dubbo:service interface="com.gic.cloud.data.hook.api.service.SearchLogService" ref="searchLogService" timeout="120000" />
<!-- 引用的 Dubbo 服务 -->
<!--<dubbo:reference interface="com.gic.dict.api.service.ManagerDictService" id="managerDictService" timeout="10000" />
<dubbo:reference interface="com.gic.cloud.communicate.api.service.member.MemberTagFieldService" id="memberTagFieldService" timeout="10000" />
......
<?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.gic.cloud.data.hook.service.dao.DhSearchLogMapper">
<resultMap id="BaseResultMap" type="com.gic.cloud.data.hook.service.entity.DhSearchLog">
<id column="log_id" jdbcType="INTEGER" property="logId" />
<result column="enterprise_id" jdbcType="VARCHAR" property="enterpriseId" />
<result column="enterprise_name" jdbcType="VARCHAR" property="enterpriseName" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="model" jdbcType="INTEGER" property="model" />
<result column="count" jdbcType="INTEGER" property="count" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
log_id, enterprise_id, enterprise_name, user_id, user_name, model, count, start_time,
end_time, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dh_search_log
where log_id = #{logId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from dh_search_log
where log_id = #{logId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.cloud.data.hook.service.entity.DhSearchLog">
insert into dh_search_log (log_id, enterprise_id, enterprise_name,
user_id, user_name, model,
count, start_time, end_time,
create_time)
values (#{logId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=VARCHAR}, #{enterpriseName,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{model,jdbcType=INTEGER},
#{count,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.cloud.data.hook.service.entity.DhSearchLog">
insert into dh_search_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="logId != null">
log_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="enterpriseName != null">
enterprise_name,
</if>
<if test="userId != null">
user_id,
</if>
<if test="userName != null">
user_name,
</if>
<if test="model != null">
model,
</if>
<if test="count != null">
count,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="createTime != null">
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logId != null">
#{logId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseName != null">
#{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="model != null">
#{model,jdbcType=INTEGER},
</if>
<if test="count != null">
#{count,jdbcType=INTEGER},
</if>
<if test="startTime != null">
#{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.cloud.data.hook.service.entity.DhSearchLog">
update dh_search_log
<set>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseName != null">
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="model != null">
model = #{model,jdbcType=INTEGER},
</if>
<if test="count != null">
count = #{count,jdbcType=INTEGER},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where log_id = #{logId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.cloud.data.hook.service.entity.DhSearchLog">
update dh_search_log
set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
user_name = #{userName,jdbcType=VARCHAR},
model = #{model,jdbcType=INTEGER},
count = #{count,jdbcType=INTEGER},
start_time = #{startTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP}
where log_id = #{logId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -24,7 +24,10 @@
t.amount,
t.query_data_type,
t.real_sql,
t.report_id
t.report_id,
t.desensi_type,
t.download_condition,
t.apply_permitted
</sql>
......@@ -94,6 +97,22 @@
#{userName}
)
</insert>
<select id="listUnDownloadTask" resultType="DownloadRecord">
SELECT
id,
enterprise_id,
name AS "task_name",
module_name,
amount,
query_data_type,
real_sql,
report_id,
desensi_type,
download_condition,
apply_permitted
FROM
dh_download_task
WHERE query_data_source = #{source} and (status = 'waiting' or status = 'building')
</select>
</mapper>
\ No newline at end of file
......@@ -104,7 +104,9 @@
real_sql,
enterprise_id,
report_id,
del_flag
del_flag,
desensi_type,
download_condition
) VALUES (
#{id},
#{userId},
......@@ -125,7 +127,9 @@
#{realSql},
#{enterpriseId},
#{reportId},
'0'
'0',
#{desensiType},
#{downloadCondition }
)
</insert>
......@@ -180,4 +184,11 @@
AND q.del_flag = '0'
</select>
<select id="getDownloadProcess" resultType="DownloadProcessDTO">
SELECT sum(amount) dataAmount,count(1) taskAmount
FROM
dh_download_task
WHERE
status = 'building' or status = 'waiting'
</select>
</mapper>
\ No newline at end of file
......@@ -20,7 +20,8 @@
q.download_count,
f.is_favo,
q.auth_store_id,
q.auth_desc
q.auth_desc,
q.last_update_time
</sql>
<sql id="queryJoins">
......
package com.gic.cloud.data.hook.vo;
import java.io.Serializable;
public class DownloadProcessVO implements Serializable {
private Integer taskAmount;
private Integer milliSecond;
public Integer getTaskAmount() {
return taskAmount;
}
public void setTaskAmount(Integer taskAmount) {
this.taskAmount = taskAmount;
}
public Integer getMilliSecond() {
return milliSecond;
}
public void setMilliSecond(Integer milliSecond) {
this.milliSecond = milliSecond;
}
}
package com.gic.cloud.data.hook.web;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.hook.api.dto.DownloadProcessDTO;
import com.gic.cloud.data.hook.api.dto.DownloadRecord;
import com.gic.cloud.data.hook.api.dto.DownloadTask;
import com.gic.cloud.data.hook.api.dto.RiskModeRecord;
import com.gic.cloud.data.hook.api.entity.GeneralResult;
import com.gic.cloud.data.hook.api.service.IDownloadTaskService;
import com.gic.cloud.data.hook.vo.DownloadProcessVO;
import com.gic.web.common.utils.SessionContextUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -117,6 +119,15 @@ public class DownloadTaskController {
return this.downloadTaskService.getRiskModeRecordPage(enterpriseId, startTime, endTime, riskDuration, fuzzyRange, fuzzy, pageNum, pageSize);
}
@RequestMapping("/get-task-process")
public DownloadProcessVO getDownloadProcess(){
DownloadProcessDTO downloadProcess = this.downloadTaskService.getDownloadProcess();
Integer unit = 60*2*1000;
DownloadProcessVO vo = new DownloadProcessVO();
vo.setMilliSecond(downloadProcess.getTaskAmount()*unit);
vo.setTaskAmount(downloadProcess.getTaskAmount());
return vo;
}
}
......@@ -15,6 +15,7 @@ import com.gic.cloud.data.hook.api.entity.Global;
import com.gic.cloud.data.hook.api.service.IFlatQueryResultService;
import com.gic.cloud.data.hook.api.service.IFlatQueryTableService;
import com.gic.cloud.data.hook.api.service.IMyFlatQueryService;
import com.gic.cloud.data.hook.api.service.SearchLogService;
import com.gic.enterprise.api.constant.StoreWidget;
import com.gic.enterprise.api.dto.EnterpriseSettingDTO;
import com.gic.enterprise.api.dto.StoreWidgetDTO;
......@@ -62,6 +63,8 @@ public class FlatQueryController {
private PowerService powerService;
@Autowired
private RightService rightService;
@Autowired
private SearchLogService searchLogService;
/** 查询表定义及下载量等信息
......@@ -145,7 +148,16 @@ public class FlatQueryController {
for (FlatQueryCondition condition : executeRequest.getQueryConditions()) {
System.out.println(condition.getFieldName() + " " + condition.getFieldType());
}
return this.flatQueryResultService.getFlatQueryResult(
AuthorizedUser loginUser = SessionContextUtils.getLoginUser();
DhSearchLogDTO dto = new DhSearchLogDTO();
dto.setEnterpriseId(loginUser.getEnterpriseId());
dto.setEnterpriseName(loginUser.getEnterpriseDTO().getEnterpriseName());
dto.setUserId(loginUser.getUserId());
dto.setUserName(loginUser.getLoginName());
dto.setModel(executeRequest.getModel());
dto.setCount(executeRequest.getCount());
dto.setStartTime(new Date());
FlatQueryResult flatQueryResult = this.flatQueryResultService.getFlatQueryResult(
executeRequest.getTableId(),
executeRequest.getEnterpriseIds(),
executeRequest.getQueryConditions(),
......@@ -155,7 +167,10 @@ public class FlatQueryController {
executeRequest.getQueryDataType(),
1000,
dataPermission,
this.getAuthStoreId()); // 强制 1000 限制
this.getAuthStoreId());// 强制 1000 限制
dto.setEndTime(new Date());
this.searchLogService.saveLog(dto);
return flatQueryResult;
}
/** 获取自助查询下载量评估
......
package com.gic.cloud.data.hook.web;
import com.alibaba.fastjson.JSON;
import com.gic.clerk.api.dto.AuthorizedUser;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.hook.api.dto.*;
import com.gic.cloud.data.hook.api.entity.FlatQueryExecuteRequest;
import com.gic.cloud.data.hook.api.entity.GeneralResult;
import com.gic.cloud.data.hook.api.service.IFlatQueryResultService;
import com.gic.cloud.data.hook.api.service.IFreeQueryService;
import com.gic.cloud.data.hook.api.service.SearchLogService;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.web.common.utils.SessionContextUtils;
......@@ -32,6 +34,8 @@ public class FreeQueryController {
private IFreeQueryService freeQueryService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private SearchLogService searchLogService;
/** 获取所有的自定义查询表信息
* @param request
......@@ -143,10 +147,23 @@ public class FreeQueryController {
* @return
*/
@RequestMapping("/get-free-query-result")
public FreeQueryResult getFreeQueryResult(String sql, String enterpriseId, Integer queryDataType, Integer desensiType, HttpServletRequest request, HttpServletResponse response) {
public FreeQueryResult getFreeQueryResult(String sql, String enterpriseId, Integer queryDataType, Integer desensiType,
Integer model, Integer count, HttpServletRequest request, HttpServletResponse response) {
AuthorizedUser loginUser = SessionContextUtils.getLoginUser();
DhSearchLogDTO dto = new DhSearchLogDTO();
dto.setEnterpriseId(loginUser.getEnterpriseId());
dto.setEnterpriseName(loginUser.getEnterpriseDTO().getEnterpriseName());
dto.setUserId(loginUser.getUserId());
dto.setUserName(loginUser.getLoginName());
dto.setModel(model);
dto.setCount(count);
dto.setStartTime(new Date());
Integer dataPermission = this.enterpriseService.getEnterpriseSettingByEnterpriseId(SessionContextUtils.getLoginUserEnterpriseId()).getDataPermission();
System.out.println("!!!!!!!!:"+dataPermission);
return this.freeQueryService.getFreeQueryResult( "SELECT tmpTable.* FROM (" + sql + ") AS tmpTable LIMIT 1000", enterpriseId, queryDataType, dataPermission);
FreeQueryResult freeQueryResult = this.freeQueryService.getFreeQueryResult("SELECT tmpTable.* FROM (" + sql + ") AS tmpTable LIMIT 1000", enterpriseId, queryDataType, dataPermission);
dto.setEndTime(new Date());
this.searchLogService.saveLog(dto);
return freeQueryResult;
}
......
package com.gic.cloud.data.hook.web;
import com.alibaba.fastjson.JSON;
import com.gic.cloud.data.hook.api.dto.FlatQueryResult;
import com.gic.cloud.data.hook.api.dto.FlatQueryTable;
import com.gic.cloud.data.hook.api.entity.FlatQueryCondition;
import com.gic.cloud.data.hook.api.entity.FlatQueryFieldType;
import com.gic.cloud.data.hook.api.service.IFlatQueryResultService;
import com.gic.cloud.data.hook.api.service.IFlatQueryTableService;
import com.google.common.collect.Lists;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller
public class TestController {
private org.slf4j.Logger logger= LoggerFactory.getLogger(TestController.class);
@Autowired
private IFlatQueryTableService flatQueryTableService;
@Autowired
private IFlatQueryResultService flatQueryResultService;
// @ResponseBody
// @RequestMapping("/test2")
// public String test2(HttpServletRequest request, HttpServletResponse response) {
// return "hello world";
// }
// @ResponseBody
// @RequestMapping("/test")
// public FlatQueryTable test(HttpServletRequest request, HttpServletResponse response) {
// FlatQueryTable table = this.flatQueryTableService.queryFlatQueryTableById("test_table");
// logger.debug("json 格式为 " + JSON.toJSONString(table));
// return table;
// }
// @ResponseBody
// @RequestMapping("/test2")
// public FlatQueryResult test2(HttpServletRequest request, HttpServletResponse response) {
// // 准备查询条件
// List<FlatQueryCondition> conditions = Lists.newArrayList();
// FlatQueryCondition testCondition = new FlatQueryCondition();
// testCondition.setFieldName("order_id");
// testCondition.setFieldType(FlatQueryFieldType.TEXT);
// conditions.add(testCondition);
// // 进行查询
// FlatQueryResult result = this.flatQueryResultService.getFlatQueryResult("extract_order_information", conditions, "", "", false, 500000);
//
// return result;
// }
}
......@@ -27,6 +27,7 @@
<dubbo:reference interface="com.gic.clerk.api.service.PowerService" id="powerService" timeout="6000" retries="0" />
<dubbo:reference interface="com.gic.enterprise.api.service.StoreWidgetService" id="storeWidgetService" timeout="6000" retries="0" />
<dubbo:reference interface="com.gic.clerk.api.service.RightService" id="rightService" timeout="6000" retries="0" />
<dubbo:reference interface="com.gic.cloud.data.hook.api.service.SearchLogService" id="searchLogService" timeout="6000" retries="0" />
<!--<dubbo:reference interface="com.gic.enterprise.api.service.EnterPerformanceService" id="enterPerformanceService" timeout="10000" retries="0" />
<dubbo:reference interface="com.gic.cloud.communicate.api.service.performance.CloudPerformanceService" id="cloudPerformanceService" timeout="10000" retries="0" />
<dubbo:reference interface="com.gic.cloud.communicate.api.service.store.AreaService" id="areaService" timeout="10000" retries="0" />-->
......
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