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