Commit 7e61c3f0 by 陶光胜

取数平台调整

parent 31f0a0cd
......@@ -67,4 +67,6 @@ public interface IDownloadTaskService {
List<DownloadRecord> listUnDownloadTask(String source);
DownloadProcessDTO getDownloadProcess();
void checkTaskStatus(String param);
}
package com.gic.cloud.data.hook.service;
import com.alibaba.dubbo.common.utils.StringUtils;
import com.gic.data.shield.SdkEnv;
import com.gic.data.shield.decrypt.DataDecryptionClient;
import com.gic.data.shield.exception.DecryptException;
......@@ -40,5 +41,20 @@ public class DecryptUtils {
}
}
public static String dataSecurityProcessUserName(String userName){
if(StringUtils.isBlank(userName)){
return userName;
}
int length = userName.length();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(userName.charAt(0));
if(length > 1){
for(int k=0; k<length-1 ;k++){
stringBuffer.append("*");
}
}
return stringBuffer.toString();
}
}
......@@ -30,4 +30,6 @@ public interface DownloadRecordDao {
@Param("fuzzyRange") String fuzzyRange, @Param("fuzzy") String fuzzy);
List<DownloadRecord> listUnDownloadTask(@Param("source") String source);
List<DownloadRecord> listExpireTask();
}
......@@ -64,4 +64,6 @@ public interface DownloadTaskDao {
DownloadProcessDTO getDownloadProcess();
int updateTaskStatusError(@Param("idList") List<String> idList);
}
package com.gic.cloud.data.hook.service.entity;
import com.gic.cloud.data.hook.service.DecryptUtils;
import com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl;
import com.opencsv.ResultSetHelper;
import java.io.IOException;
......@@ -68,26 +69,24 @@ public class CsvResultSetHelper implements ResultSetHelper {
boolean doDecrypt = false; // 是否进行解密
if (this.filterMode.equals(CsvDataFilterMode.DESENSI)) { // 如果需要脱敏
if (this.filters != null && this.filters.size() > 0) {
for (String filter : this.filters) {
if (columnName.contains(filter)) {
doDesensi = true;
break;
} // IF OVER
} // FOR OVER
if(filters.contains(columnName)){
doDesensi = true;
}
} // IF OVER
} else if (this.filterMode.equals(CsvDataFilterMode.DECRYPT)) { // 如果需要解密
if (this.filters != null && this.filters.size() > 0) {
for (String filter : this.filters) {
if (columnName.equals(filter)) {
doDecrypt = true;
break;
} // IF OVER
} // FOR OVER
if(filters.contains(columnName) || FreeQueryServiceImpl.FILETERS_USER_NAME.contains(columnName)){
doDecrypt = true;
}
} // IF OVER
}
// 数据处理
if (doDesensi) { // 如果需要脱敏处理
result[i] = "******";
if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(columnName)){
result[i] = DecryptUtils.dataSecurityProcessUserName(resultSet.getString(columnName));
} else {
result[i] = "******";
}
} else if (doDecrypt) { // 如果需要解密处理
//System.out.println("CSV 解密字段名 " + columnName);
String tmpResult = resultSet.getString(columnName);
......
......@@ -15,6 +15,7 @@ import com.gic.cloud.data.hook.service.dao.RiskModeRecordDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.opencsv.CSVWriter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.ibatis.annotations.Param;
......@@ -260,5 +261,19 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
return downloadProcess;
}
@Override
public void checkTaskStatus(String param) {
List<DownloadRecord> downloadRecordList = this.downloadRecordDao.listExpireTask();
List<String> idList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(downloadRecordList)){
for(DownloadRecord downloadRecord : downloadRecordList){
idList.add(downloadRecord.getId());
}
}
if(CollectionUtils.isNotEmpty(idList)){
//设置超时任务的状态为error
}
}
}
......@@ -271,22 +271,26 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
} else fieldResult = "";
} else fieldResult = "******";
} else fieldResult = rs.getObject(fieldColumnIndex);**/
if (FreeQueryServiceImpl.FILTERS_PHONE_ONLY.contains(fieldName) || FreeQueryServiceImpl.FILTERS_PHONE_AND_CARD.contains(fieldName)) {
if(queryDataType == QueryDataType.FULL){
String preResult = rs.getString(fieldColumnIndex);
if(dataPermission == 1 && FreeQueryServiceImpl.FILTERS_PHONE_ONLY.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult);
}else if(dataPermission == 2 && FreeQueryServiceImpl.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult);
}else fieldResult = rs.getObject(fieldColumnIndex);
} else {
if(dataPermission == 1 && FreeQueryServiceImpl.FILTERS_PHONE_ONLY.contains(fieldName)){
fieldResult = "******";
}else if(dataPermission == 2 && FreeQueryServiceImpl.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = "******";
} else fieldResult = rs.getObject(fieldColumnIndex);
}
} else fieldResult = rs.getObject(fieldColumnIndex);
if(queryDataType == QueryDataType.FULL){
String preResult = rs.getString(fieldColumnIndex);
if(dataPermission == 1 && FreeQueryServiceImpl.FILTERS_PHONE_ONLY.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult);
} else if(dataPermission == 2 && FreeQueryServiceImpl.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult);
} else if (FreeQueryServiceImpl.FILETERS_USER_NAME.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult);
} else fieldResult = rs.getObject(fieldColumnIndex);
} else {
if(dataPermission == 1 && FreeQueryServiceImpl.FILTERS_PHONE_ONLY.contains(fieldName)){
fieldResult = "******";
} else if(dataPermission == 2 && FreeQueryServiceImpl.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = "******";
} else if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(fieldName)){
fieldResult = DecryptUtils.dataSecurityProcessUserName(rs.getObject(fieldColumnIndex)+"");
} else fieldResult = rs.getObject(fieldColumnIndex);
}
} // SWITCH OVER
result.add(fieldName, fieldResult);
// } // IF ELSE OVER
......@@ -605,11 +609,15 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
//row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1);
List<String> cFilters = condition.getDecryptFilters();
if (task.getQueryDataType() == QueryDataType.FULL && cFilters.contains(cName)) {
if (task.getQueryDataType() == QueryDataType.FULL && (cFilters.contains(cName) || FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName))) {
String tmpResult = rs.getString(j + 1);
if (StringUtils.isNotBlank(tmpResult)) tmpResult = DecryptUtils.getInstance().decrypt(tmpResult);
row.createCell(j).setCellValue(tmpResult);
} else {
if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName)){
String name = DecryptUtils.getInstance().decrypt(rs.getString(j + 1));
DecryptUtils.dataSecurityProcessUserName(name);
}
int cType = rs.getMetaData().getColumnType(j + 1);
switch (cType) {
case Types.TIMESTAMP:
......
......@@ -56,6 +56,8 @@ 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","friend_card_num","from_card_num", "friend_phone_num","from_phone_num");
public static final List<String> FILETERS_USER_NAME = Arrays.asList("member_name","children_name","mbr_name");
@Autowired
IDownloadTaskService downloadTaskService;
......@@ -230,7 +232,11 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
String fieldName = metaData.getColumnLabel(i + 1);
Object filedValue;
if (queryDataType == QueryDataType.SAFE && FreeQueryServiceImpl.isFilterFields(desensiType, fieldName)) {
filedValue = "******";
if(FILETERS_USER_NAME.contains(fieldName)){
filedValue = DecryptUtils.dataSecurityProcessUserName(rs.getString(fieldName));
} else {
filedValue = "******";
}
} else {
switch (metaData.getColumnType(i + 1)) {
case Types.TIMESTAMP:
......@@ -434,8 +440,12 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
//row.createCell(j).setCellValue(c);
String cName = rs.getMetaData().getColumnName(j+1);
if (task.getQueryDataType() == QueryDataType.SAFE
&& FreeQueryServiceImpl.isFilterFields(condition.getDesensiType(), cName)) {
row.createCell(j).setCellValue("******");
&& (FreeQueryServiceImpl.isFilterFields(condition.getDesensiType(), cName) || FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName))) {
if(FreeQueryServiceImpl.FILETERS_USER_NAME.contains(cName)){
row.createCell(j).setCellValue(DecryptUtils.dataSecurityProcessUserName(rs.getString(cName)));
} else {
row.createCell(j).setCellValue("******");
}
} else {
int cType = rs.getMetaData().getColumnType(j + 1);
switch (cType) {
......
......@@ -117,4 +117,23 @@
and start_time &lt;= CONCAT(DATE_FORMAT(NOW(),'%Y-%m-%d'),' 23:59:59') order by start_time
</select>
<select id="listExpireTask" 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,
apply_status
FROM
dh_download_task
WHERE (status = 'building' or status = 'waiting')
and start_time &lt;= DATE_ADD(start_time,INTERVAL -24 HOUR) order by start_time
</select>
</mapper>
\ No newline at end of file
......@@ -192,4 +192,15 @@
(status = 'building' or status = 'waiting') and start_time &gt;= CONCAT(DATE_FORMAT(NOW(),'%Y-%m-%d'),' 00:00:00')
and start_time &lt;= CONCAT(DATE_FORMAT(NOW(),'%Y-%m-%d'),' 23:59:59')
</select>
<update id="updateTaskStatusError">
UPDATE <include refid="updateTable"/> SET
status = 'error'
WHERE
id in
<foreach collection="idList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper>
\ 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