Commit b83f3ecb authored by jim's avatar jim

Merge remote-tracking branch 'origin/staging' into staging

parents 0f94c2c9 89b62bef
......@@ -202,14 +202,6 @@ public class AccountController {
return accountService.findOverviewByYearAndMonth(principal.getName(), year, month, zoneId, service);
}
public static void main(String[] args) {
String intStr = "08";
int month = Integer.parseInt(intStr);
System.out.println(month);
}
@RequestMapping(path = "/current/updatetoken", method = RequestMethod.POST)
void updateUserToken(@RequestParam("username") String username, @RequestParam("token") String token) {
accountService.updateUserToken(username, token);
......@@ -352,8 +344,8 @@ public class AccountController {
Pageable pageable = PageRequest.of(page, size);
String[] datas = strDate.split("-");
int year = Integer.valueOf(datas[0]);
int month = Integer.valueOf(datas[1]);
int year = Integer.parseInt(datas[0]);
int month = Integer.parseInt(datas[1]);
int day = 0;
if (datas.length > 2) {
day = Integer.valueOf(datas[2]);
......
......@@ -159,7 +159,6 @@ public class ShopController {
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
}
logger.error(JSONObject.toJSONString(resultDto));
return resultDto;
}
......
......@@ -50,9 +50,6 @@ public class Set3proxyTask {
long validTime = Instant.now().minusSeconds(43200).toEpochMilli();
List<String> tokenUsernames = mongoOAuth2AccessTokenRepository.findByCreatedAtGreaterThan(validTime).stream().map(MongoOAuth2AccessToken::getUsername).collect(Collectors.toList());
if (tokenUsernames.isEmpty()) {
return;
}
List<String> accountParents = accountRepository.findByNameIn(tokenUsernames).stream().map(x -> x.getParent() == null ? x.getName() : x.getParent()).distinct().collect(Collectors.toList());
List<IpResource> ipResources = ipResourceRepository.findByOwnerInAndSpecialLine(accountParents, true);
......@@ -71,7 +68,9 @@ public class Set3proxyTask {
bw.write("monitor /root/3proxy.cfg\n");
// 写入 ipResources 相关信息
bwWriteIpResources(ipResources, bw);
if (ipResources.size() != 0) {
bwWriteIpResources(ipResources, bw);
}
bw.write("\nauth strong\n");
bw.write("\nallow none\nproxy -p20004\nsocks -p20005\n");
......
......@@ -3,12 +3,9 @@ package com.edgec.browserbackend.common.utils;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.util.ArrayList;
......@@ -29,12 +26,12 @@ public class FileUtil {
String line = null;
StringBuffer buf = new StringBuffer();
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(f), charset);
BufferedReader br = new BufferedReader(reader);){
BufferedReader br = new BufferedReader(reader);) {
while ((line = br.readLine()) != null) {
buf.append(line+System.getProperty("line.separator"));
buf.append(line + System.getProperty("line.separator"));
}
} catch (Exception e) {
log.error("[" + f.getName() + "]文件读出失败{}",e);
log.error("[" + f.getName() + "]文件读出失败{}", e);
return null;
}
log.debug("[" + f.getName() + "]文件读出成功");
......@@ -46,14 +43,14 @@ public class FileUtil {
List<String> lineList = new ArrayList<String>();
StringBuffer buf = new StringBuffer();
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(f), charset);
BufferedReader br = new BufferedReader(reader);){
BufferedReader br = new BufferedReader(reader);) {
while ((line = br.readLine()) != null) {
lineList.add(line);
}
br.close();
reader.close();
} catch (Exception e) {
log.error("[" + f.getName() + "]文件读出失败{}",e);
log.error("[" + f.getName() + "]文件读出失败{}", e);
return null;
}
log.debug("[" + f.getName() + "]文件读出成功");
......@@ -61,10 +58,10 @@ public class FileUtil {
}
public static boolean write(String content, File file) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))){
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
bw.write(content);
} catch (Exception e) {
log.error("[" + file.getName() + "]写入失败{}",e);
log.error("[" + file.getName() + "]写入失败{}", e);
return false;
}
log.debug("[" + file.getName() + "]文件写入成功");
......@@ -72,7 +69,7 @@ public class FileUtil {
}
//读取excel
public static List<List<Object>> readExcel(InputStream inputStream){
public static List<List<Object>> readExcel(InputStream inputStream) {
List<List<Object>> list = new ArrayList<>();
Workbook workbook = null;
try {
......@@ -89,7 +86,8 @@ public class FileUtil {
//总列数
int colLength = row.getLastCellNum();
//得到指定的单元格
Cell cell = row.getCell(0);;
Cell cell = row.getCell(0);
;
int size = 1;
boolean first = false;
for (int i = 1; i < rowLength; i++) {
......@@ -99,7 +97,7 @@ public class FileUtil {
for (int j = 0; j < colLength; j++) {
cell = row.getCell(j);
// System.out.println(cell);
if (cell!=null) {
if (cell != null) {
Object cellValue = getCellFormatValue(cell);
if (cellValue.toString().contains("店铺名称")) {
first = true;
......@@ -109,8 +107,7 @@ public class FileUtil {
if (StringUtils.isNotBlank(cellValue.toString())) {
size++;
}
}
else
} else
rowvalue.add("");
}
if (first) {
......@@ -127,37 +124,37 @@ public class FileUtil {
log.error("parse excel file error :", e);
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
}
return list ;
return list;
}
public static Object getCellFormatValue(Cell cell){
public static Object getCellFormatValue(Cell cell) {
Object cellValue = null;
if(cell!=null){
if (cell != null) {
//判断cell类型
switch(cell.getCellType()){
case Cell.CELL_TYPE_NUMERIC:{
cellValue = String.valueOf((int)cell.getNumericCellValue());
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC: {
cellValue = String.valueOf((int) cell.getNumericCellValue());
break;
}
case Cell.CELL_TYPE_FORMULA:{
case Cell.CELL_TYPE_FORMULA: {
//判断cell是否为日期格式
if(DateUtil.isCellDateFormatted(cell)){
if (DateUtil.isCellDateFormatted(cell)) {
//转换为日期格式YYYY-mm-dd
cellValue = cell.getDateCellValue();
}else{
} else {
//数字
cellValue = String.valueOf(cell.getNumericCellValue());
}
break;
}
case Cell.CELL_TYPE_STRING:{
case Cell.CELL_TYPE_STRING: {
cellValue = cell.getRichStringCellValue().getString();
break;
}
default:
cellValue = "";
}
}else{
} else {
cellValue = "";
}
return cellValue;
......@@ -165,25 +162,26 @@ public class FileUtil {
/**
* 方法说明将files打包放到一个zip中。
*
* @return
* @throws IOException
*/
public static File putBatchFilesInZip(List<File> filePaths,File tempFile) throws IOException {
public static File putBatchFilesInZip(List<File> filePaths, File tempFile) throws IOException {
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempFile));
for(File inputFile : filePaths) {
try(FileInputStream fis = new FileInputStream(inputFile);){
for (File inputFile : filePaths) {
try (FileInputStream fis = new FileInputStream(inputFile);) {
//压缩文件中写入名称
ZipEntry entry = new ZipEntry(inputFile.getName());
zos.putNextEntry(entry);
// 向压缩文件中输出数据
int len = 0;
byte[] bt = new byte[5*1024];
byte[] bt = new byte[5 * 1024];
while ((len = fis.read(bt)) != -1) {
//压缩文件中写入真正的文件流
zos.write(bt, 0, len);
}
}catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException();
}
......
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