Commit 2a6ae852 authored by 李秀明's avatar 李秀明

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

parents 180f1f8f 76956efb
......@@ -46,7 +46,9 @@ public class ExcelUtil {
Class<?> model, DataSources dataDictionaryMapper, boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
OutputStream outputStream = null;
try {
outputStream = getOutputStream(fileName, response, ExcelTypeEnum.XLSX);
//下拉列表集合
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
if (flag) {
......@@ -59,16 +61,25 @@ public class ExcelUtil {
resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint, dataDictionaryMapper);
}
}
EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX), model)
if (null != outputStream) {
EasyExcel.write(outputStream, model)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
.registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy)
.doWrite(data);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......@@ -88,7 +99,9 @@ public class ExcelUtil {
boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
OutputStream outputStream = null;
try {
outputStream = getOutputStream(fileName, response, ExcelTypeEnum.XLSX);
// 组装表头
List<List<String>> dutyCarTitleList = new ArrayList<>();
Field[] declaredFields = model.getDeclaredFields();
......@@ -127,16 +140,25 @@ public class ExcelUtil {
}
// String s = new String(fileName.getBytes(), "UTF-8");
// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(s, "UTF-8"));
ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcel.write(getOutputStream(fileName, response,
ExcelTypeEnum.XLSX)).head(dutyCarTitleList).excelType(ExcelTypeEnum.XLSX)
if (null != outputStream) {
ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcel.write(outputStream)
.head(dutyCarTitleList).excelType(ExcelTypeEnum.XLSX)
.sheet(sheetName).registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(data);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......
......@@ -6,6 +6,7 @@ import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.enums.WorkFlowEnum;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -29,9 +30,8 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
result += SecureRandomUtil.getIntSecureRandom(10);
}
return newDate + result;
}
......
......@@ -109,6 +109,7 @@ public class DynamicEnumUtil {
AccessibleObject.setAccessible(new Field[]{valuesField}, true);
try {
if (null != valuesField) {
// 2. 将他拷贝到数组
T[] previousValues = (T[]) valuesField.get(enumType);
List<T> values = new ArrayList<T>(Arrays.asList(previousValues));
......@@ -125,6 +126,9 @@ public class DynamicEnumUtil {
// 6. 清楚枚举的缓存
cleanEnumCache(enumType);
return newValue;
} else {
return null;
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
......
......@@ -58,10 +58,9 @@ public class QRCodeUtil {
try {
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(5, 8) + String.valueOf(IdWorker.getFlowIdWorkerInstance().nextId()).substring(0, 10) + randomNumForQrCode;
} catch (Exception e) {
Random random = new Random(System.currentTimeMillis());
String tmp = "";
for (int i = 0; i < 13; i++) {
tmp += random.nextInt(10);
tmp += SecureRandomUtil.getIntSecureRandom(10);
}
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(2, 8) + tmp.substring(0, 10) + randomNumForQrCode;
} finally {
......@@ -78,7 +77,7 @@ public class QRCodeUtil {
*/
public static String temporaryQrCode() {
long qrCode = -1 * System.currentTimeMillis();
qrCode += (long) (random.nextDouble() * 10000000);
qrCode += (long) (SecureRandomUtil.getIntSecureRandomByDouble() * 10000000);
return String.valueOf(qrCode);
}
......
package com.yeejoin.amos.boot.biz.common.utils;
import java.security.SecureRandom;
import java.util.Random;
public class SecureRandomUtil {
public static int getIntSecureRandom(Integer bound) {
SecureRandom secureRandom = new SecureRandom();
return secureRandom.nextInt(bound);
}
public static Double getIntSecureRandomByDouble() {
SecureRandom secureRandom = new SecureRandom();
return secureRandom.nextDouble();
}
public static int getIntSecureRandom(Integer bound, SecureRandom secureRandom) {
return secureRandom.nextInt(bound);
}
public static void main(String[] args) {
SecureRandom secureRandom = new SecureRandom();
System.out.println((secureRandom.nextDouble() * 9 + 1) * 100000 + "-----");
Random random = new Random();
System.out.println((Math.random() * 9 + 1) * 100000);
System.out.println((int) (secureRandom.nextDouble() * 900 + 100));
}
}
......@@ -322,7 +322,10 @@ public class TreeParser {
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,
String.valueOf(nodeTypeMethod == null ? "0" : nodeTypeMethod.invoke(entity)));
"0");
if (null != nodeTypeMethod && null != nodeTypeMethod.invoke(entity)) {
menu.setNodeType(String.valueOf(nodeTypeMethod.invoke(entity)));
}
resultList.add(menu);
}
}
......@@ -385,7 +388,10 @@ public class TreeParser {
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,
String.valueOf(nodeTypeMethod == null ? "0" : nodeTypeMethod.invoke(entity)));
"0");
if (null != nodeTypeMethod && null != nodeTypeMethod.invoke(entity)) {
menu.setNodeType(String.valueOf(nodeTypeMethod.invoke(entity)));
}
childList.add(menu);
}
} else {
......@@ -396,7 +402,10 @@ public class TreeParser {
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)),
String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,
String.valueOf(nodeTypeMethod == null ? "0" : nodeTypeMethod.invoke(entity)));
"0");
if (null != nodeTypeMethod && null != nodeTypeMethod.invoke(entity)) {
menu.setNodeType(String.valueOf(nodeTypeMethod.invoke(entity)));
}
childList.add(menu);
}
}
......@@ -420,11 +429,9 @@ public class TreeParser {
public static String genTreeCode() {
int length = CODE_LENGTH;
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(62);
sb.append(str.charAt(number));
sb.append(str.charAt(SecureRandomUtil.getIntSecureRandom(62)));
}
return sb.toString();
}
......
......@@ -82,6 +82,7 @@ public class WordConverterUtils {
* @param fileService 图片上传接口
*/
private static void docToHtml( String imagePathStr,String readUrl,String srcFile, File targetFile, FileService fileService,String product,String appKey,String token ) {
InputStream in = null;
try {
File imagePath = new File(imagePathStr);
if (!imagePath.exists()) {
......@@ -91,8 +92,8 @@ public class WordConverterUtils {
//链接url
URLConnection uc = url.openConnection();
//获取输入流
InputStream in = uc.getInputStream();
in = uc.getInputStream();
if (null != in) {
HWPFDocument wordDocument = new HWPFDocument(in);
org.w3c.dom.Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
......@@ -103,9 +104,9 @@ public class WordConverterUtils {
FileOutputStream out = new FileOutputStream(imagePathStr + name);
out.write(content);
String urlString= fileService.uploadFile(fileToMultipartFile(new File(imagePathStr + name)), product, appKey, token );
String urlString = fileService.uploadFile(fileToMultipartFile(new File(imagePathStr + name)), product, appKey, token);
//上传平台
return readUrl+urlString;
return readUrl + urlString;
} catch (Exception e) {
e.printStackTrace();
return "";
......@@ -121,8 +122,17 @@ public class WordConverterUtils {
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != in) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......
......@@ -544,9 +544,8 @@ public class oConvertUtils {
public static String randomGen(int place) {
String base = "qwertyuioplkjhgfdsazxcvbnmQAZWSXEDCRFVTGBYHNUJMIKLOP0123456789";
StringBuffer sb = new StringBuffer();
Random rd = new Random();
for(int i=0;i<place;i++) {
sb.append(base.charAt(rd.nextInt(base.length())));
sb.append(base.charAt(SecureRandomUtil.getIntSecureRandom(62)));
}
return sb.toString();
}
......@@ -657,12 +656,23 @@ public class oConvertUtils {
*/
public static String readStatic(String url) {
String json = "";
InputStream stream = null;
try {
//换个写法,解决springboot读取jar包中文件的问题
InputStream stream = oConvertUtils.class.getClassLoader().getResourceAsStream(url.replace("classpath:", ""));
json = IOUtils.toString(stream,"UTF-8");
stream = oConvertUtils.class.getClassLoader().getResourceAsStream(url.replace("classpath:", ""));
if (null != stream) {
json = IOUtils.toString(stream, "UTF-8");
}
} catch (IOException e) {
log.error(e.getMessage(),e);
} finally {
if (null != stream) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return json;
}
......
......@@ -401,37 +401,37 @@ public class HttpContentTypeUtil {
return sendHttpGet(httpGet);
}
/**
* 发送 delete请求带请求头
*/
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
StringBuffer content = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
printWriter.write(paramsJson);
printWriter.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
content.append(line);
}
br.close();
connection.disconnect();
} catch (Exception e) {
}
return content.toString();
}
// /**
// * 发送 delete请求带请求头
// */
// public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
// StringBuffer content = new StringBuffer();
// try {
// URL url = new URL(httpUrl);
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// connection.setRequestMethod("DELETE");
// connection.setDoInput(true);
// connection.setDoOutput(true);
// connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
// for (Map.Entry<String, String> entry : headerMap.entrySet()) {
// connection.setRequestProperty(entry.getKey(), entry.getValue());
// }
// PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
// printWriter.write(paramsJson);
// printWriter.flush();
//
// BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// String line;
// while ((line = br.readLine()) != null) {
// content.append(line);
// }
// br.close();
// connection.disconnect();
// } catch (Exception e) {
//
// }
// return content.toString();
// }
/**
* 发送 post请求
......
......@@ -52,7 +52,9 @@ public class ExcelUtil {
List<? extends Object> data, Class<?> model, DataSources dataDictionaryMapper, boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
OutputStream outputStream = null;
try {
outputStream = getOutputStream(fileName, response, ExcelTypeEnum.XLSX);
// 下拉列表集合
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
if (flag) {
......@@ -65,15 +67,25 @@ public class ExcelUtil {
resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint, dataDictionaryMapper);
}
}
EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX), model)
if (null != outputStream) {
EasyExcel.write(outputStream, model)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
.registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest("系统错误!");
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......@@ -92,7 +104,9 @@ public class ExcelUtil {
DataSources dataDictionaryMapper, boolean flag, String typeFlag,boolean isTemplete) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
OutputStream outputStream = null;
try {
outputStream = getOutputStream(fileName, response, ExcelTypeEnum.XLSX);
// 组装表头
List<List<String>> dutyCarTitleList = new ArrayList<>();
Field[] declaredFields = model.getDeclaredFields();
......@@ -129,24 +143,24 @@ public class ExcelUtil {
}
}
}
ExcelWriterSheetBuilder excelWriterSheetBuilder =EasyExcel
.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX))
if (null != outputStream) {
ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcel
.write(outputStream)
.head(dutyCarTitleList)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName);
if ("WXXFZB".equals(typeFlag) && isTemplete) {
List<Map<Integer, String[]>> fireStationExplicitListConstraintMap = new ArrayList<Map<Integer, String[]>>();
List<List<Object>> resultList =new ArrayList<List<Object>>();
List<List<Object>> resultList = new ArrayList<List<Object>>();
data.stream().forEach(i -> {
Map<Integer, String[]> map = new HashMap<>();
List<Object> detail = (List<Object>) i;
// 微型消防站中的对应单位微型消防站下拉列表数据的集合
List<String> fireStationDetailList = (List<String>) detail.get(detail.size()-1);
List<String> fireStationDetailList = (List<String>) detail.get(detail.size() - 1);
String[] strings = new String[fireStationDetailList.size()];
map.put(4, fireStationDetailList.toArray(strings));
map.putAll(explicitListConstraintMap);
fireStationExplicitListConstraintMap.add(map);
detail.remove(detail.size()-1);
detail.remove(detail.size() - 1);
resultList.add(detail);
});
excelWriterSheetBuilder.registerWriteHandler(
......@@ -154,21 +168,20 @@ public class ExcelUtil {
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(resultList);
}
else if("JJZB".equals(typeFlag) && isTemplete){
} else if ("JJZB".equals(typeFlag) && isTemplete) {
List<Map<Integer, String[]>> fireStationExplicitListConstraintMap = new ArrayList<Map<Integer, String[]>>();
List<List<Object>> resultList =new ArrayList<List<Object>>();
List<List<Object>> resultList = new ArrayList<List<Object>>();
data.stream().forEach(i -> {
Map<Integer, String[]> map = new HashMap<>();
List<Object> detail = (List<Object>) i;
// 微型消防站中的对应单位微型消防站下拉列表数据的集合
List<String> fireStationDetailList = (List<String>) detail.get(detail.size()-1);
List<String> fireStationDetailList = (List<String>) detail.get(detail.size() - 1);
String[] strings = new String[fireStationDetailList.size()];
List<String> postTypeNameDetailList = (List<String>) detail.get(detail.size()-2);
List<String> postTypeNameDetailList = (List<String>) detail.get(detail.size() - 2);
String[] postTypeNamestrings = new String[postTypeNameDetailList.size()];
List<String> userNameDetailList = (List<String>) detail.get(detail.size()-3);
List<String> userNameDetailList = (List<String>) detail.get(detail.size() - 3);
String[] userNamestrings = new String[userNameDetailList.size()];
List<String> companyNameList = (List<String>) detail.get(detail.size()-4);
List<String> companyNameList = (List<String>) detail.get(detail.size() - 4);
String[] companyNameLists = new String[companyNameList.size()];
map.put(4, fireStationDetailList.toArray(strings));
map.put(3, postTypeNameDetailList.toArray(postTypeNamestrings));
......@@ -176,10 +189,10 @@ public class ExcelUtil {
map.put(1, companyNameList.toArray(companyNameLists));
map.putAll(explicitListConstraintMap);
fireStationExplicitListConstraintMap.add(map);
detail.remove(detail.size()-1);
detail.remove(detail.size()-1);
detail.remove(detail.size()-1);
detail.remove(detail.size()-1);
detail.remove(detail.size() - 1);
detail.remove(detail.size() - 1);
detail.remove(detail.size() - 1);
detail.remove(detail.size() - 1);
resultList.add(detail);
});
excelWriterSheetBuilder
......@@ -188,7 +201,7 @@ public class ExcelUtil {
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(resultList);
}else {
} else {
excelWriterSheetBuilder = excelWriterSheetBuilder
.registerWriteHandler(
new TemplateCellWriteHandlerDate(explicitListConstraintMap))
......@@ -196,10 +209,19 @@ public class ExcelUtil {
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(data);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......@@ -391,6 +413,7 @@ public class ExcelUtil {
List<? extends Object> data, List<List<String>> heads, List<String> headstr, String fileType) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
OutputStream outputStream = null;
try {
// 下拉列表集合
List<List<Object>> listData = Lists.newArrayList();
......@@ -413,16 +436,26 @@ public class ExcelUtil {
} else if("1040".equals(fileType)) {
typeEnum = ExcelTypeEnum.XLSX;
}
EasyExcel.write(getOutputStream(fileName, response, typeEnum))
outputStream = getOutputStream(fileName, response, typeEnum);
if (null != outputStream) {
EasyExcel.write(outputStream)
.excelType(typeEnum).sheet(sheetName)
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy)
.head(heads).doWrite(listData);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......
package com.yeejoin.amos.boot.module.common.api.excel;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationHelper;
......@@ -72,8 +74,7 @@ public class TemplateDynamicCellWriteHandlerDate implements SheetWriteHandler{
if (v.length > LIMIT_NUMBER) {
//定义sheet的名称
//1.创建一个隐藏的sheet 名称为 hidden + k+随机数防止数据过多造成的名字重复
Random random = new Random();
String sheetName = "hidden" +startIndex + k+random.nextInt(1000);
String sheetName = "hidden" +startIndex + k+ SecureRandomUtil.getIntSecureRandom(1000);
Workbook workbook = writeWorkbookHolder.getWorkbook();
Sheet hiddenSheet = workbook.createSheet(sheetName);
for (int i = 0, length = v.length; i < length; i++) {
......
......@@ -7,6 +7,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import org.apache.commons.lang3.StringUtils;
import javax.imageio.ImageIO;
......@@ -14,6 +15,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
......@@ -70,10 +72,10 @@ public class QRCodeUtil {
try {
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(5, 8) + String.valueOf(IdWorker.getFlowIdWorkerInstance().nextId()).substring(0, 10) + randomNumForQrCode;
} catch (Exception e) {
Random random = new Random(System.currentTimeMillis());
SecureRandom random = new SecureRandom();
String tmp = "";
for (int i = 0; i < 13; i++) {
tmp += random.nextInt(10);
tmp += SecureRandomUtil.getIntSecureRandom(10, random);
}
res = simpleDateFormat.format(new Date(System.currentTimeMillis())).substring(2, 8) + tmp.substring(0, 10) + randomNumForQrCode;
} finally {
......@@ -90,7 +92,7 @@ public class QRCodeUtil {
*/
public static String temporaryQrCode() {
long qrCode = -1 * System.currentTimeMillis();
qrCode += (long) (random.nextDouble() * 10000000);
qrCode += (long) (SecureRandomUtil.getIntSecureRandomByDouble() * 10000000);
return String.valueOf(qrCode);
}
......
package com.yeejoin.equipmanage.common.utils;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
......@@ -12,9 +15,9 @@ public class RandomUtil {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
SecureRandom random = new SecureRandom();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
result += SecureRandomUtil.getIntSecureRandom(10, random);
}
return newDate + result;
}
......
package com.yeejoin.equipmanage.common.utils;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
......@@ -17,9 +20,9 @@ public class RandomUtils {
SimpleDateFormat sdf = new SimpleDateFormat("ddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
SecureRandom random = new SecureRandom();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
result += SecureRandomUtil.getIntSecureRandom(10, random);
}
return Long.valueOf(newDate + result);
}
......
......@@ -197,9 +197,11 @@ public class WordTemplateUtils {
e1.printStackTrace();
}
try {
if (null != in) {
data = new byte[in.available()];
in.read(data);
in.close();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
......
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dto.CurrentStatusDto;
import com.yeejoin.amos.boot.module.common.api.dto.FailureDetailsDto;
......@@ -550,9 +551,8 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
result += SecureRandomUtil.getIntSecureRandom(10);
}
return newDate + result;
}
......
......@@ -3090,7 +3090,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
String code = key.substring(0, key.indexOf("Code"));
o = map.get(code);
}
if (!ObjectUtils.isEmpty(o)) {
if (null != o && !ObjectUtils.isEmpty(o)) {
dynamicFormInstanceDto.setFieldValue(value.toString());
dynamicFormInstanceDto.setFieldValueLabel(o.toString());
} else {
......
......@@ -282,7 +282,7 @@ public class ConfigureController extends AbstractBaseController {
unit = fireFightingSystemMapper.getWaterlevelUnit(s, "FHS_WirelessliquidDetector_WaterLevel");
}
}
if (!ObjectUtils.isEmpty(unit) && "CM".equals(unit.get("unit")) || "cm".equals(unit.get("unit")) || "厘米".equals(unit.get("unit"))){
if (!ObjectUtils.isEmpty(unit) && ("CM".equals(unit.get("unit")) || "cm".equals(unit.get("unit")) || "厘米".equals(unit.get("unit")))){
BigDecimal divide = new BigDecimal(100);
if (!ObjectUtils.isEmpty(record.get("nowLevel")) && !"--".equals(record.get("nowLevel"))){
BigDecimal nowLevel = new BigDecimal(String.valueOf(record.get("nowLevel")));
......
......@@ -211,8 +211,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime = weekStart.getTime();
long endTime = weekEnd.getTime();
long startTime = null != weekStart ? weekStart.getTime() : 0;
long endTime = null != weekEnd ? weekEnd.getTime() : 0;
HashMap<String, Object> mapData = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -221,7 +221,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (!ObjectUtils.isEmpty(mapData)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData.get("faultNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("faultNum")));
......@@ -259,8 +259,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime1 = weekStart1.getTime();
long endTime1 = weekEnd1.getTime();
long startTime1 = null != weekStart1 ? weekStart1.getTime() : 0;
long endTime1 = null != weekEnd1 ? weekEnd1.getTime() : 0;
HashMap<String, Object> mapData1 = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -269,7 +269,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (!ObjectUtils.isEmpty(mapData1)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData1.get("faultNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("faultNum")));
......@@ -358,8 +358,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime = weekStart.getTime();
long endTime = weekEnd.getTime();
long startTime = null != weekStart ? weekStart.getTime() : 0;
long endTime = null != weekEnd ? weekEnd.getTime() : 0;
HashMap<String, Object> mapData = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -368,7 +368,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (!ObjectUtils.isEmpty(mapData)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData.get("controlCabinetAlarmNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("controlCabinetAlarmNum")));
......@@ -407,8 +407,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime1 = weekStart1.getTime();
long endTime1 = weekEnd1.getTime();
long startTime1 = null != weekStart1 ? weekStart1.getTime() : 0;
long endTime1 = null != weekEnd1 ? weekEnd1.getTime() : 0;
HashMap<String, Object> mapData1 = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -417,7 +417,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (!ObjectUtils.isEmpty(mapData1)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData1.get("controlCabinetAlarmNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("controlCabinetAlarmNum")));
......@@ -479,8 +479,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime = weekStart.getTime();
long endTime = weekEnd.getTime();
long startTime = null != weekStart ? weekStart.getTime() : 0;
long endTime = null != weekEnd ? weekEnd.getTime() : 0;
HashMap<String, Object> mapData = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -489,7 +489,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime && check.getTime() <= endTime) {
if (!ObjectUtils.isEmpty(mapData)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData.get("powerLossNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("powerLossNum")));
......@@ -534,8 +534,8 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
long startTime1 = weekStart1.getTime();
long endTime1 = weekEnd1.getTime();
long startTime1 = null != weekStart1 ? weekStart1.getTime() : 0;
long endTime1 = null != weekEnd1 ? weekEnd1.getTime() : 0;
HashMap<String, Object> mapData1 = new HashMap<>();
for (Map<String, Object> map : maps) {
Date check = null;
......@@ -544,7 +544,7 @@ public class EmergencyController extends AbstractBaseController {
} catch (ParseException e) {
e.printStackTrace();
}
if (!ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (null != check && !ObjectUtils.isEmpty(check) && check.getTime() >= startTime1 && check.getTime() <= endTime1) {
if (!ObjectUtils.isEmpty(mapData1)) {
BigDecimal old = new BigDecimal(String.valueOf(mapData1.get("powerLossNum")));
BigDecimal add = new BigDecimal(String.valueOf(map.get("powerLossNum")));
......
......@@ -182,7 +182,7 @@ public class EquipmentIndexController {
for (CarProperty x : list) {
x.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId());
x.setEquipmentIndexName(equipmentIndex.getPerfQuotaName());
if (bool.get()) {
if (bool.get() && null != signalClassify) {
x.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor());
x.setIsAlarm(signalClassify.getIsAlarm());
x.setEmergencyLevel(signalClassify.getEmergencyLevel());
......@@ -200,7 +200,7 @@ public class EquipmentIndexController {
y.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId());
y.setEquipmentIndexName(equipmentIndex.getPerfQuotaName());
y.setValueEnum(equipmentIndex.getValueEnum());
if (bool.get() && !ObjectUtils.isEmpty(signalClassify)) {
if (bool.get() && null != signalClassify && !ObjectUtils.isEmpty(signalClassify)) {
y.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor());
y.setIsAlarm(signalClassify.getIsAlarm());
y.setEmergencyLevel(signalClassify.getEmergencyLevel());
......
......@@ -1068,7 +1068,7 @@ public class TopographyController extends AbstractBaseController {
}
j++;
}
if (!CollectionUtils.isEmpty(list)) {
if (!CollectionUtils.isEmpty(list) && null != iotIndexRes) {
iotIndexRes.setIotData(list);
}
if (!ObjectUtils.isEmpty(iotIndexRes)) {
......
package com.yeejoin.equipmanage.operation;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import com.yeejoin.equipmanage.common.vo.AreaResquest;
import com.yeejoin.equipmanage.context.SpringContextHolder;
import com.yeejoin.equipmanage.remote.RiskModelFeign;
......@@ -7,6 +8,7 @@ import com.yeejoin.equipmanage.remote.RiskSource;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.security.SecureRandom;
import java.util.Random;
@Getter
......@@ -32,9 +34,9 @@ public enum AreaSynRiskOperator {
public RiskSource getRiskSource(AreaResquest areaResquest){
RiskSource riskSource = new RiskSource();
StringBuilder code = new StringBuilder();
Random random = new Random();
SecureRandom random = new SecureRandom();
for (int i = 0; i < 24; i++) {
code.append(random.nextInt(10));
code.append(SecureRandomUtil.getIntSecureRandom(10, random));
}
riskSource.setCode(code.toString());
riskSource.setId(Long.parseLong(String.valueOf(areaResquest.getId())));
......
......@@ -133,7 +133,7 @@ public class EquipmentIndexImpl extends ServiceImpl<EquipmentIndexMapper, Equipm
carProperty.setEquipmentIndexId(equipmentIndex.getId());
carProperty.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId());
carProperty.setEquipmentIndexName(equipmentIndex.getPerfQuotaName());
if (bool.get()) {
if (bool.get() && null != signalClassify) {
carProperty.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor());
carProperty.setIsAlarm(signalClassify.getIsAlarm());
carProperty.setEmergencyLevel(signalClassify.getEmergencyLevel());
......@@ -160,7 +160,7 @@ public class EquipmentIndexImpl extends ServiceImpl<EquipmentIndexMapper, Equipm
equipmentSpecificIndex.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId());
equipmentSpecificIndex.setEquipmentIndexName(equipmentIndex.getPerfQuotaName());
equipmentSpecificIndex.setEquipmentSpecificName(y.getName());
if (bool.get()) {
if (bool.get() && null != signalClassify) {
equipmentSpecificIndex.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor());
equipmentSpecificIndex.setIsAlarm(signalClassify.getIsAlarm());
equipmentSpecificIndex.setEmergencyLevel(signalClassify.getEmergencyLevel());
......
......@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.equipmanage.common.entity.DynamicFormGroup;
import com.yeejoin.equipmanage.common.entity.EquipmentManageEntity;
......@@ -137,7 +138,7 @@ public class EquipmentManageServiceImpl extends ServiceImpl<EquipmentManageMappe
@Override
public String checkCode(String param) {
int num = (int) (Math.random() * 900 + 100);
int num = (int) (SecureRandomUtil.getIntSecureRandomByDouble() * 900 + 100);
;
String val = param;
val += String.valueOf(num);
......
......@@ -788,19 +788,20 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
int allNum = 0;
// 启动次数
int startNum = 0;
ResponseModel all = iotFeign.selectListNew(vo.getIotCode().substring(0,8),null, startTime, endTime,null, pressurePumpStart);
if (null != vo) {
ResponseModel all = iotFeign.selectListNew(vo.getIotCode().substring(0, 8), null, startTime, endTime, null, pressurePumpStart);
if (200 == all.getStatus() && !ObjectUtils.isEmpty(all.getResult())) {
String json1 = JSON.toJSONString(all.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
allNum = listObject1.size();
}
ResponseModel start = iotFeign.selectListNew(vo.getIotCode().substring(0,8),null, startTime, endTime,"true", pressurePumpStart);
ResponseModel start = iotFeign.selectListNew(vo.getIotCode().substring(0, 8), null, startTime, endTime, "true", pressurePumpStart);
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
startNum = listObject1.size();
}
}
Map<String, Object> retMap = new HashMap<>();
......
......@@ -590,7 +590,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
p.setDataConfig(map);
if (StringUtils.isEmpty(id)) {
// 建筑
if (equipSpecificIds.contains(valueOf(equipSpecificId))) {
if (null != equipSpecificIds && equipSpecificIds.contains(valueOf(equipSpecificId))) {
p.setBinding(true);
} else {
p.setBinding(false);
......@@ -671,7 +671,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
p.setDataConfig(map);
if (StringUtils.isEmpty(id)) {
// 建筑
if (equipSpecificIds.contains(valueOf(equipSpecificId))) {
if (null != equipSpecificIds && equipSpecificIds.contains(valueOf(equipSpecificId))) {
p.setBinding(true);
} else {
p.setBinding(false);
......
......@@ -577,9 +577,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
jsonObjectData.put("astId", equipmentSpeIndex.getSpecificCode());
jsonObjectData.put("equipType", equipmentSpeIndex.getEquipmentCode());
jsonObjectData.put("name", equipmentSpeIndex.getEquipmentSpecificName() + "-" + equipmentSpeIndex.getEquipmentSpecificIndexName());
if (value.equals("true")) {
if (null != value && value.equals("true")) {
jsonObjectData.put("value", "1");
} else if (value.equals("false")) {
} else if (null != value && value.equals("false")) {
jsonObjectData.put("value", "0");
} else {
jsonObjectData.put("value", value);
......
......@@ -331,7 +331,7 @@ public class WarehouseStructureServiceImpl extends ServiceImpl<WarehouseStructur
if(ws.getParentId() == null) {
ws.setCellCode(ws.getCode());
}else {
ws.setCellCode(parent.getCellCode() + code);
ws.setCellCode(null != parent ? parent.getCellCode() : "" + code);
}
save(ws);
} else {
......
......@@ -586,7 +586,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
for (Map<String, Object> orgUser : orgUsers) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
if(!alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
if (null != alertSubmittedNew) {
alertSubmittedObject.setAlertSubmittedId(alertSubmittedNew.getSequenceNbr());
}
} else {
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
}
......@@ -632,7 +634,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
// 调用短信发送接口
Map<String,String> besidesMap = new HashMap<>();
besidesMap.put(alterId,String.valueOf(alertCalled.getSequenceNbr()));
if (null != alertCalled) {
besidesMap.put(alterId, String.valueOf(alertCalled.getSequenceNbr()));
}
if(alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
......@@ -660,9 +664,10 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
if (null != alertCalledId) {
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
}
}
/**
* 短信报送
......@@ -1031,7 +1036,6 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
if (!ValidationUtil.isEmpty(report)) {
String os = System.getProperty("os.name");
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("templates/check-report-template.docx");
String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
String filePath = "";
......@@ -1052,6 +1056,20 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
Configure.ConfigureBuilder configureBuilder = Configure.newBuilder();
configureBuilder.setElMode(ELMode.SPEL_MODE).bind("alertCalledPowerInfoDtoList", calledPowerInfoTablePolicy)
.bind("alertCallCommandDtoList", alertCallCommandTablePolicy).build();
InputStream resourceAsStream = null;
try {
resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("templates/check-report-template.docx");
} catch (Exception e) {
} finally {
if (null != resourceAsStream) {
try {
resourceAsStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
XWPFTemplate template = XWPFTemplate.compile(resourceAsStream, configureBuilder.build()).render(report);
File file = new File(fileName);
......
......@@ -102,15 +102,16 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
model.setFileType("坐席呼出");
}
Map<String, String> downloadFile = null;
if(downloadFile.isEmpty()) {
this.updateById(l);
return;
}
for(Map.Entry<String,String> file : downloadFile.entrySet()) {
model.setFilePath(file.getKey());
}
// 注掉无用代码
// Map<String, String> downloadFile = null;
//
// if(downloadFile.isEmpty()) {
// this.updateById(l);
// return;
// }
// for(Map.Entry<String,String> file : downloadFile.entrySet()) {
// model.setFilePath(file.getKey());
// }
});
}
......
......@@ -350,13 +350,13 @@ public class CheckServiceImpl implements ICheckService {
score += checkInput.getScore();
checkItemList.add(checkInput);
EquipmentInputItemRo equipmentInputItemRo = new EquipmentInputItemRo();
if(!StringUtils.isBlank(pointClassify.getName())){
if(null != pointClassify && !StringUtils.isBlank(pointClassify.getName())){
equipmentInputItemRo.setEquipmentName(pointClassify.getName());
}
equipmentInputItemRo.setCheckResult(item.getInputValue());
equipmentInputItemRo.setRuleType(RuleTypeEnum.CHECKRESULT.getCode());
equipmentInputItemRo.setCheckContent(inputItem.getItemNo());
if(!StringUtils.isBlank(pointClassify.getEquipmentId())){
if(null != pointClassify && !StringUtils.isBlank(pointClassify.getEquipmentId())){
equipmentInputItemRoList.add(equipmentInputItemRo);
}
}
......@@ -432,7 +432,7 @@ public class CheckServiceImpl implements ICheckService {
if(imgList.size()>0){
checkService.saveCheckImg(imgList);
}
if (check.getPlanTaskId() > 0) {
if (check.getPlanTaskId() > 0 && null != detail) {
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), requestParam.getPointId(), requestParam.getPlanTaskId(), user.getUserId());
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
......@@ -686,7 +686,7 @@ public class CheckServiceImpl implements ICheckService {
if (imgList.size() > 0) {
checkService.saveCheckImg(imgList);
}
if (check.getPlanTaskId() > 0) {
if (check.getPlanTaskId() > 0 && null != detail) {
planTaskDetailMapper.finishTaskDetail(Long.parseLong(detail.get("planTaskDetailId").toString()), requestParam.getPointId(), requestParam.getPlanTaskId(), requestParam.getUserId());
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
......
......@@ -728,7 +728,7 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
}
// 延期治理选择的延期日期不能早于整改日期校验
if (executeTypeEnum.equals(LatentDangerExcuteTypeEnum.隐患延期治理)) {
if (latentDangerBo.getReformLimitDate().compareTo(DateUtil.longStr2Date(latentDangerExcuteParam.getDelayLimitDate())) >= 0) {
if (null != latentDangerBo && latentDangerBo.getReformLimitDate().compareTo(DateUtil.longStr2Date(latentDangerExcuteParam.getDelayLimitDate())) >= 0) {
executeSubmitDto.setIsOk(false);
executeSubmitDto.setMsg("延期日期不能早于整改期限");
return executeSubmitDto;
......
......@@ -1413,6 +1413,7 @@ public class PointServiceImpl implements IPointService {
for (Map<String, String> statusEnum : statusEnums) {
String code = statusEnum.get("value");
boolean isCreate = true;
if (null != content) {
for (HashMap<String, Object> c : content) {
if (code.equals(c.get("status"))) {
isCreate = false;
......@@ -1420,6 +1421,7 @@ public class PointServiceImpl implements IPointService {
break;
}
}
}
if (isCreate) {
HashMap<String, Object> temp = new HashMap<>();
temp.put("name", statusEnum.get("name"));
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*;
......@@ -537,6 +538,6 @@ public class SynDataServiceImpl implements ISynDataService {
}
private String buildRandomNum(String originalId) {
return "SPC_" + (int) ((Math.random() * 9 + 1) * 100000) + "_" + originalId;
return "SPC_" + (int) ((SecureRandomUtil.getIntSecureRandomByDouble() * 9 + 1) * 100000) + "_" + originalId;
}
}
package com.yeejoin.amos.patrol.business.util;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import org.apache.commons.lang.StringUtils;
import java.security.SecureRandom;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
......@@ -1092,8 +1094,10 @@ public class DateUtil {
{
;
}
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
return day;
if (null != date && null != mydate) {
return (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
return 0;
}
/**
......@@ -1136,13 +1140,13 @@ public class DateUtil {
*/
private static String getRandom(int i)
{
Random jjj = new Random();
SecureRandom jjj = new SecureRandom();
// int suiJiShu = jjj.nextInt(9);
if (i == 0) return "";
String jj = "";
for (int k = 0; k < i; k++)
{
jj = jj + jjj.nextInt(9);
jj = jj + SecureRandomUtil.getIntSecureRandom(9, jjj);
}
return jj;
}
......
......@@ -92,36 +92,48 @@ public class DesUtil {
int[] tempBt;
int x, y, z;
tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt;
int x, y;
tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x = 0;
tempBt = bt;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
encByte = tempBt;
}
}
......@@ -139,36 +151,48 @@ public class DesUtil {
int[] tempBt;
int x, y, z;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt;
int x, y;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
encByte = tempBt;
}
}
......@@ -183,36 +207,48 @@ public class DesUtil {
int[] tempBt;
int x, y, z;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
if (null != thirdKeyBt) {
for (z = 0; z < thirdLength; z++) {
tempBt = enc(tempBt, (int[]) thirdKeyBt.get(z));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt;
int x, y;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = 0; y < secondLength; y++) {
tempBt = enc(tempBt, (int[]) secondKeyBt.get(y));
}
}
encByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x;
tempBt = tempByte;
if (null != firstKeyBt) {
for (x = 0; x < firstLength; x++) {
tempBt = enc(tempBt, (int[]) firstKeyBt.get(x));
}
}
encByte = tempBt;
}
}
......@@ -262,36 +298,48 @@ public class DesUtil {
int[] tempBt;
int x, y, z;
tempBt = intByte;
if (null != thirdKeyBt) {
for (x = thirdLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) thirdKeyBt.get(x));
}
}
if (null != secondKeyBt) {
for (y = secondLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(y));
}
}
if (null != firstKeyBt) {
for (z = firstLength - 1; z >= 0; z--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(z));
}
}
decByte = tempBt;
} else {
if (firstKey != null && firstKey != "" && secondKey != null && secondKey != "") {
int[] tempBt;
int x, y, z;
tempBt = intByte;
if (null != secondKeyBt) {
for (x = secondLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) secondKeyBt.get(x));
}
}
if (null != firstKeyBt) {
for (y = firstLength - 1; y >= 0; y--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(y));
}
}
decByte = tempBt;
} else {
if (firstKey != null && firstKey != "") {
int[] tempBt;
int x, y, z;
tempBt = intByte;
if (null != firstKeyBt) {
for (x = firstLength - 1; x >= 0; x--) {
tempBt = dec(tempBt, (int[]) firstKeyBt.get(x));
}
}
decByte = tempBt;
}
}
......
......@@ -298,17 +298,19 @@ public static List<HashMap<String, Date>> genExeDate(Plan plan, CalDateVo vo,Str
init = init + exeInt;
calDate = DateUtil.getIntervalDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_WEEK.equals(planType)){//周计划
for(String str :strArr){
if (null != strArr) {
for (String str : strArr) {
HashMap<String, Date> tempMap = new HashMap<String, Date>();
int inter = Integer.parseInt(str);
calDate = DateUtil.getIntervalDate(weekDate,inter);
if(calDate.getTime() >= exeDate.getTime() && (calDate.getTime()>=exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())){
calDate = DateUtil.getIntervalDate(weekDate, inter);
if (calDate.getTime() >= exeDate.getTime() && (calDate.getTime() >= exeBeginDate.getTime() && calDate.getTime() <= exeEndDate.getTime())) {
tempMap.put("begin_date", calDate);
tempMap.put("end_date", calDate);
tempMap.put("next_gen_date", calDate);
dateList.add(tempMap);
}
}
}
init = init + exeInt;
weekDate = DateUtil.getIntervalWeekDate(exeDate,init);
}else if(XJConstant.PLAN_TYPE_MONTH.equals(planType)){//月计划
......
......@@ -5,6 +5,7 @@ import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
......@@ -49,7 +50,7 @@ public class QRCodeUtil {
*/
public static String temporaryQrCode() {
long qrCode = -1 * System.currentTimeMillis();
qrCode += (long)(random.nextDouble() * 10000000);
qrCode += (long)(SecureRandomUtil.getIntSecureRandomByDouble() * 10000000);
return String.valueOf(qrCode);
}
......
package com.yeejoin.amos.patrol.business.util;
import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
......@@ -10,9 +13,9 @@ public class RandomUtil {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
SecureRandom random = new SecureRandom();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
result += SecureRandomUtil.getIntSecureRandom(10, random);
}
return newDate + result;
}
......
......@@ -222,9 +222,11 @@ public class WordTemplateUtils {
e1.printStackTrace();
}
try {
if (null != in) {
data = new byte[in.available()];
in.read(data);
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -382,8 +382,10 @@ public class DateUtil {
} catch (Exception e) {
e.printStackTrace();
}
Time date = new Time(d.getTime());
return date;
if (null != d) {
return new Time(d.getTime());
}
return null;
}
/**
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.jpush.common.entity;
import org.apache.commons.lang.StringUtils;
import java.security.SecureRandom;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
......@@ -1070,8 +1071,10 @@ public class DateUtil {
{
;
}
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
return day;
if (null != date && null != mydate) {
return (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
return 0;
}
/**
......@@ -1114,7 +1117,7 @@ public class DateUtil {
*/
private static String getRandom(int i)
{
Random jjj = new Random();
SecureRandom jjj = new SecureRandom();
// int suiJiShu = jjj.nextInt(9);
if (i == 0) return "";
String jj = "";
......
......@@ -383,8 +383,10 @@ public class DateUtil {
} catch (Exception e) {
e.printStackTrace();
}
Time date = new Time(d.getTime());
return date;
if (null != d) {
return new Time(d.getTime());
}
return null;
}
/**
......
......@@ -1070,8 +1070,10 @@ public class DateUtil {
{
;
}
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
return day;
if (null != date && null != mydate) {
return (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
return 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