Commit b00e96d7 by fudahua

Merge branch 'developer' into 'master'

Developer

See merge request !58
parents 92a6d7bd e6dffe24
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gic</groupId> <groupId>com.gic</groupId>
<artifactId>gic-cloud-data-hook-api</artifactId> <artifactId>gic-cloud-data-hook-api</artifactId>
<version>3.0-SNAPSHOT</version> <version>2.40</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.gic</groupId> <groupId>com.gic</groupId>
<artifactId>gic-cloud-web-service-api</artifactId> <artifactId>gic-cloud-web-service-api</artifactId>
<version>3.0-SNAPSHOT</version> <version>3.80</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<dependency> <dependency>
<groupId>com.gic</groupId> <groupId>com.gic</groupId>
<artifactId>gic-cloud-commons</artifactId> <artifactId>gic-cloud-commons</artifactId>
<version>3.0-SNAPSHOT</version> <version>3.64</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>com.gic</groupId> <groupId>com.gic</groupId>
<artifactId>gic-platform-config</artifactId> <artifactId>gic-platform-config</artifactId>
<version>3.0-SNAPSHOT</version> <version>2.26</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
......
package com.gic.cloud.data.hook.service; package com.gic.cloud.data.hook.service;
import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.dubbo.common.utils.StringUtils;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.cloud.data.hook.api.entity.FlatQueryCondition; import com.gic.cloud.data.hook.api.entity.FlatQueryCondition;
import com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl; import com.gic.cloud.data.hook.service.impl.FreeQueryServiceImpl;
import com.gic.data.shield.SdkEnv; import com.gic.data.shield.SdkEnv;
...@@ -50,6 +52,14 @@ public class DecryptUtils { ...@@ -50,6 +52,14 @@ public class DecryptUtils {
} }
} }
public static String decrypt(String enterpriseId,String encryptString) {
if (DecryptUtils.checkDecrypt(enterpriseId)){
return DecryptUtils.decrypt(encryptString);
}else{
return encryptString;
}
}
public static String dataSecurityProcessUserName(String userName){ public static String dataSecurityProcessUserName(String userName){
if(StringUtils.isBlank(userName)){ if(StringUtils.isBlank(userName)){
return userName; return userName;
...@@ -73,4 +83,23 @@ public class DecryptUtils { ...@@ -73,4 +83,23 @@ public class DecryptUtils {
return false; return false;
} }
/**
* 是否需要解密
* @param enterpriseId
* @return
*/
public static boolean checkDecrypt(String enterpriseId) {
Config appConfig = ConfigService.getAppConfig();
String entIds = appConfig.getProperty("decrypt-enterprise", "1");
if (entIds.equals("-1")) {
return false;
}else if (entIds.equals("1")) {
return true;
}else if (entIds.contains(enterpriseId)) {
return false;
}else{
return true;
}
}
} }
...@@ -169,14 +169,14 @@ public class CsvResultSetHelper implements ResultSetHelper { ...@@ -169,14 +169,14 @@ public class CsvResultSetHelper implements ResultSetHelper {
// 数据处理 // 数据处理
if (doDesensi) { // 如果需要脱敏处理 if (doDesensi) { // 如果需要脱敏处理
if(allFields != null && isName(columnName)){ if(allFields != null && isName(columnName)){
result.add(DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(resultSet.getString(columnName)))); result.add(DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(enterpriseId,resultSet.getString(columnName))));
} else if(allFields == null && FilterFieldUtils.FILETERS_USER_NAME.contains(columnName)) { } else if(allFields == null && FilterFieldUtils.FILETERS_USER_NAME.contains(columnName)) {
result.add(DecryptUtils.dataSecurityProcessUserName(resultSet.getString(i+1))); result.add(DecryptUtils.dataSecurityProcessUserName(resultSet.getString(i+1)));
} else { } else {
result.add("******"); result.add("******");
if(needDecryptByEnt && isPhoneNumber(columnName)){ if(needDecryptByEnt && isPhoneNumber(columnName)){
//导出数据中需要增加加密列,先解密再加密 //导出数据中需要增加加密列,先解密再加密
String value = DecryptUtils.getInstance().decrypt(resultSet.getString(i+1)); String value = DecryptUtils.getInstance().decrypt(enterpriseId,resultSet.getString(i+1));
if(org.apache.commons.lang3.StringUtils.isNotBlank(value)){ if(org.apache.commons.lang3.StringUtils.isNotBlank(value)){
byte[] bytes = rsa.encrypt(StrUtil.bytes(value, CharsetUtil.UTF_8), KeyType.PublicKey); byte[] bytes = rsa.encrypt(StrUtil.bytes(value, CharsetUtil.UTF_8), KeyType.PublicKey);
String encode = Base64.encode(bytes); String encode = Base64.encode(bytes);
...@@ -190,7 +190,7 @@ public class CsvResultSetHelper implements ResultSetHelper { ...@@ -190,7 +190,7 @@ public class CsvResultSetHelper implements ResultSetHelper {
String tmpResult = resultSet.getString(i+1); String tmpResult = resultSet.getString(i+1);
if (tmpResult != null && tmpResult.length() > 0) { if (tmpResult != null && tmpResult.length() > 0) {
//tmpResult = DecryptUtils.getInstance().decrypt(tmpResult); //tmpResult = DecryptUtils.getInstance().decrypt(tmpResult);
tmpResult = DecryptUtils.getInstance().decrypt(tmpResult); tmpResult = DecryptUtils.getInstance().decrypt(enterpriseId,tmpResult);
if(tmpResult.startsWith("0")){ if(tmpResult.startsWith("0")){
tmpResult = tmpResult + "\t"; tmpResult = tmpResult + "\t";
} }
......
...@@ -160,7 +160,7 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService { ...@@ -160,7 +160,7 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
public void run() { public void run() {
Calendar calc = Calendar.getInstance(); Calendar calc = Calendar.getInstance();
//calc.add(Calendar.DATE, -1); //calc.add(Calendar.DATE, -1);
calc.add(Calendar.HOUR, -12); // 从一天改为 12 小时 calc.add(Calendar.HOUR, -48); // 从一天改为 12 小时
Date expireDate = calc.getTime(); Date expireDate = calc.getTime();
List<DownloadTask> expiredTasks = downloadTaskDao.getExpiredDownloadTaskList(expireDate); List<DownloadTask> expiredTasks = downloadTaskDao.getExpiredDownloadTaskList(expireDate);
if (expiredTasks.size() > 0) { if (expiredTasks.size() > 0) {
......
...@@ -241,6 +241,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -241,6 +241,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
log.debug("getFlatQueryResult", "自助指标查询来自 " + enterpriseIds.get(0)); log.debug("getFlatQueryResult", "自助指标查询来自 " + enterpriseIds.get(0));
// 定义返回值 // 定义返回值
FlatQueryResult result = new FlatQueryResult(); FlatQueryResult result = new FlatQueryResult();
String enterpriseId = enterpriseIds.get(0);
// 定义查询语句 // 定义查询语句
String queryFull = this.buildFlatQuerySQL( String queryFull = this.buildFlatQuerySQL(
true, // 查询用途 true, // 查询用途
...@@ -324,11 +325,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -324,11 +325,11 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
if(queryDataType == QueryDataType.FULL){ if(queryDataType == QueryDataType.FULL){
String preResult = rs.getString(fieldColumnIndex); String preResult = rs.getString(fieldColumnIndex);
if(dataPermission == 1 && FilterFieldUtils.FILTERS_PHONE_ONLY.contains(fieldName)){ if(dataPermission == 1 && FilterFieldUtils.FILTERS_PHONE_ONLY.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult); fieldResult = DecryptUtils.decrypt(enterpriseId,preResult);
} else if(dataPermission == 2 && FilterFieldUtils.FILTERS_PHONE_AND_CARD.contains(fieldName)){ } else if(dataPermission == 2 && FilterFieldUtils.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult); fieldResult = DecryptUtils.decrypt(enterpriseId,preResult);
} else if (FilterFieldUtils.FILETERS_USER_NAME.contains(fieldName)){ } else if (FilterFieldUtils.FILETERS_USER_NAME.contains(fieldName)){
fieldResult = DecryptUtils.decrypt(preResult); fieldResult = DecryptUtils.decrypt(enterpriseId,preResult);
} else fieldResult = rs.getObject(fieldColumnIndex); } else fieldResult = rs.getObject(fieldColumnIndex);
} else { } else {
if(dataPermission == 1 && FilterFieldUtils.FILTERS_PHONE_ONLY.contains(fieldName)){ if(dataPermission == 1 && FilterFieldUtils.FILTERS_PHONE_ONLY.contains(fieldName)){
...@@ -336,7 +337,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -336,7 +337,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
} else if(dataPermission == 2 && FilterFieldUtils.FILTERS_PHONE_AND_CARD.contains(fieldName)){ } else if(dataPermission == 2 && FilterFieldUtils.FILTERS_PHONE_AND_CARD.contains(fieldName)){
fieldResult = "******"; fieldResult = "******";
} else if(FilterFieldUtils.FILETERS_USER_NAME.contains(fieldName)){ } else if(FilterFieldUtils.FILETERS_USER_NAME.contains(fieldName)){
fieldResult = DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(rs.getObject(fieldColumnIndex)+"")); fieldResult = DecryptUtils.dataSecurityProcessUserName(DecryptUtils.decrypt(enterpriseId,rs.getObject(fieldColumnIndex)+""));
} else fieldResult = rs.getObject(fieldColumnIndex); } else fieldResult = rs.getObject(fieldColumnIndex);
} }
...@@ -1097,6 +1098,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -1097,6 +1098,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
} else if (applyStatusText.indexOf("\"checkStatus\":1") > 0) { // 如果审核超时 } else if (applyStatusText.indexOf("\"checkStatus\":1") > 0) { // 如果审核超时
task.setApplyStatus(DownloadApplyStatus.TIMEOUT); task.setApplyStatus(DownloadApplyStatus.TIMEOUT);
task.setApplyPermitted(Global.NO); task.setApplyPermitted(Global.NO);
task.setOverTime(new Date());
conditionRemove = true; conditionRemove = true;
} }
if (conditionRemove || conditionUpdate) { if (conditionRemove || conditionUpdate) {
......
...@@ -750,6 +750,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService { ...@@ -750,6 +750,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
conditionUpdate = true; conditionUpdate = true;
} else if (applyStatusText.indexOf("\"checkStatus\":1") > 0) { // 如果审核超时 } else if (applyStatusText.indexOf("\"checkStatus\":1") > 0) { // 如果审核超时
task.setApplyStatus(DownloadApplyStatus.TIMEOUT); task.setApplyStatus(DownloadApplyStatus.TIMEOUT);
task.setOverTime(new Date());
task.setApplyPermitted(Global.NO); task.setApplyPermitted(Global.NO);
conditionRemove = true; conditionRemove = true;
} }
......
...@@ -198,7 +198,8 @@ ...@@ -198,7 +198,8 @@
<update id="updateTaskStatusError"> <update id="updateTaskStatusError">
UPDATE <include refid="updateTable"/> SET UPDATE <include refid="updateTable"/> SET
status = 'error' status = 'error',
over_time=now()
WHERE WHERE
id in id in
<foreach collection="idList" item="item" open="(" close=")" separator=","> <foreach collection="idList" item="item" open="(" close=")" separator=",">
......
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.io.FileOutputStream;
import java.util.Date;
public class ExceTest2 {
public static void main(String[] args) {
int n=25;
int c=100;
Double aDouble = Double.valueOf((double) n / c);
System.out.println(aDouble);
}
}
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.io.FileOutputStream;
import java.util.Date;
public class ExcelTest {
public static void main(String[] args) {
try {
// String originalFilePath = SAVE_FOLDER + "/" + condition.getTaskId() + ".xlsx";
SXSSFWorkbook wb = new SXSSFWorkbook(100); // 内存中保留 100 行
Sheet sheet = wb.createSheet();
CellStyle cellStyle = wb.createCellStyle();
DataFormat format = wb.createDataFormat();
cellStyle.setDataFormat(format.getFormat("yyyy-MM-dd HH:mm:ss"));
// CellStyle cellStyle = wb.createCellStyle();
// DataFormat format = wb.createDataFormat();
// cellStyle.setDataFormat(format.getFormat("yyyy-MM-dd HH:mm:ss"));
int n=0;
do {
Row row = sheet.createRow(n);
{
Cell midCell = row.createCell(0);
midCell.setCellStyle(cellStyle);
midCell.setCellValue(new Date());
}
{
Cell midCell = row.createCell(1);
// midCell.setCellStyle(cellStyle);
midCell.setCellValue(Math.random());
}
}while (n++<10);
FileOutputStream fileOut = new FileOutputStream("d://test.xlsx");
wb.write(fileOut);
//fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式
fileOut.close();
//wb.close();
wb.dispose(); // SXSSFWorkbook 没有 close 方法
}catch (Exception e) {
e.printStackTrace();
}
}
}
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