修复部分sonar问题
This commit is contained in:
+27
-13
@@ -369,7 +369,7 @@ public class ReportManageConroller {
|
||||
@ApiOperation(value = "上传图片")
|
||||
@PostMapping("/uploadPicFile")
|
||||
public ResponseMessage<Map<String, Object>> uploadPicFile(MultipartFile file, HttpServletRequest request) throws IOException {
|
||||
|
||||
Random r = new Random();
|
||||
try (InputStream input = file.getInputStream()) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
String path = uploadFile;//此路径映射到localhost
|
||||
@@ -381,13 +381,12 @@ public class ReportManageConroller {
|
||||
Date now = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String date = dateFormat.format(now);
|
||||
Random r = new Random();
|
||||
|
||||
String num = "";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int s = r.nextInt(10);
|
||||
num += String.valueOf(s);
|
||||
}
|
||||
|
||||
//获取上传文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
String contentType = file.getContentType();
|
||||
@@ -500,6 +499,7 @@ public class ReportManageConroller {
|
||||
//如果只下载一个文件,则不压缩
|
||||
if (downLoadFileIds.size() == 1) {
|
||||
String fileId = downLoadFileIds.get(0);
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
FileEntity entity = fileService.getFile(fileId);
|
||||
String fileName = entity.getFileName();
|
||||
@@ -510,7 +510,7 @@ public class ReportManageConroller {
|
||||
//PDF文件需要加水印
|
||||
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
|
||||
String path = uploadFile + entity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
outputStream = new FileOutputStream(path);
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
if ("hwobs".equals(uploadType)) {
|
||||
obsBootUtil.getFileFromOBS(entity.getSavePath(), outputStream);
|
||||
@@ -521,7 +521,7 @@ public class ReportManageConroller {
|
||||
}
|
||||
//给文件添加水印
|
||||
waterMarkUtil.addWatermarkToPdfAndWriteToResponse(new FileInputStream(path), response);
|
||||
outputStream.close();
|
||||
|
||||
} else {
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs 本地:local
|
||||
if ("hwobs".equals(uploadType)){
|
||||
@@ -535,6 +535,10 @@ public class ReportManageConroller {
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.getMessage(),ex);
|
||||
} finally {
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<String> filePaths = new ArrayList<>();
|
||||
@@ -545,14 +549,14 @@ public class ReportManageConroller {
|
||||
response.setHeader("Pragma", "public");
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
FileOutputStream outputStream = null;
|
||||
for (String fileId : downLoadFileIds) {
|
||||
try {
|
||||
FileEntity entity = fileService.getFile(fileId);
|
||||
String fileName = entity.getFileName();
|
||||
|
||||
String path = uploadFile + entity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
outputStream = new FileOutputStream(path);
|
||||
filePaths.add(path);
|
||||
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
@@ -567,9 +571,12 @@ public class ReportManageConroller {
|
||||
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
|
||||
waterMarkUtil.savePdfToFile(new FileInputStream(path), path);
|
||||
}
|
||||
outputStream.close();
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.getMessage(),ex);
|
||||
} finally {
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
//将文件压缩 写入Response
|
||||
@@ -656,6 +663,7 @@ public class ReportManageConroller {
|
||||
//如果只下载一个文件,则不压缩
|
||||
if (downLoadFileIds.size() == 1) {
|
||||
String fileId = downLoadFileIds.get(0);
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
FileEntity entity = fileService.getFile(fileId);
|
||||
String fileName = entity.getFileName();
|
||||
@@ -666,7 +674,7 @@ public class ReportManageConroller {
|
||||
//PDF文件需要加水印
|
||||
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
|
||||
String path = uploadFile + entity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
outputStream = new FileOutputStream(path);
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
if ("hwobs".equals(uploadType)) {
|
||||
obsBootUtil.getFileFromOBS(entity.getSavePath(), outputStream);
|
||||
@@ -677,7 +685,6 @@ public class ReportManageConroller {
|
||||
}
|
||||
//给文件添加水印
|
||||
waterMarkUtil.addWatermarkToPdfAndWriteToResponse(new FileInputStream(path), response);
|
||||
outputStream.close();
|
||||
} else {
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs 本地:local
|
||||
if ("hwobs".equals(uploadType)){
|
||||
@@ -691,6 +698,10 @@ public class ReportManageConroller {
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.getMessage(),ex);
|
||||
} finally {
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<String> filePaths = new ArrayList<>();
|
||||
@@ -701,14 +712,14 @@ public class ReportManageConroller {
|
||||
response.setHeader("Pragma", "public");
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
FileOutputStream outputStream = null;
|
||||
for (String fileId : downLoadFileIds) {
|
||||
try {
|
||||
FileEntity entity = fileService.getFile(fileId);
|
||||
String fileName = entity.getFileName();
|
||||
|
||||
String path = uploadFile + entity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
outputStream = new FileOutputStream(path);
|
||||
filePaths.add(path);
|
||||
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
@@ -723,9 +734,12 @@ public class ReportManageConroller {
|
||||
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
|
||||
waterMarkUtil.savePdfToFile(new FileInputStream(path), path);
|
||||
}
|
||||
outputStream.close();
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.getMessage(),ex);
|
||||
} finally {
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
//将文件压缩 写入Response
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -49,6 +50,12 @@ public class IFileServiceImpl implements IFileService {
|
||||
@Resource
|
||||
private OSSClientUtil ossClientUtil;
|
||||
|
||||
private static Random r;
|
||||
|
||||
static {
|
||||
r = new Random();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文件
|
||||
* @param entity
|
||||
@@ -82,7 +89,7 @@ public class IFileServiceImpl implements IFileService {
|
||||
Date now = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String date = dateFormat.format(now);
|
||||
Random r = new Random();
|
||||
|
||||
String num = "";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int s = r.nextInt(10);
|
||||
@@ -137,7 +144,6 @@ public class IFileServiceImpl implements IFileService {
|
||||
Date now = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String date = dateFormat.format(now);
|
||||
Random r = new Random();
|
||||
String num = "";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int s = r.nextInt(10);
|
||||
|
||||
@@ -950,7 +950,9 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
public String createHtmlString(String fileId) throws Exception {
|
||||
FileEntity fileEntity = fileDao.selectById(fileId);
|
||||
String path = uploadFile + fileEntity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(path);
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
if ("hwobs".equals(uploadType)) {
|
||||
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
|
||||
@@ -959,6 +961,13 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
} else if ("local".equals(uploadType)) {
|
||||
localFileUtil.getFileFromLocal(fileEntity.getSavePath(), outputStream);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
String html = null;
|
||||
|
||||
|
||||
@@ -91,9 +91,13 @@ public class FileContentUtil {
|
||||
default:
|
||||
}
|
||||
} catch (NotOfficeXmlFileException e) {
|
||||
fis.close();
|
||||
log.info("文件内容抽取失败,原因可能是上传的文件为空文件");
|
||||
} finally {
|
||||
if (fis != null){
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
|
||||
return cleanInvalidCharacters(content.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@ public class LocalFileUtil {
|
||||
|
||||
ZipEntry zipEntry = new ZipEntry(sourceFile.getName());
|
||||
zipOutputStream.putNextEntry(zipEntry);
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(sourceFile);
|
||||
FileInputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(sourceFile);
|
||||
|
||||
int len;
|
||||
while ((len = fileInputStream.read(buffer)) > 0) {
|
||||
@@ -49,6 +50,14 @@ public class LocalFileUtil {
|
||||
}
|
||||
|
||||
fileInputStream.close();
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (fileInputStream != null){
|
||||
fileInputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
zipOutputStream.closeEntry();
|
||||
}
|
||||
|
||||
@@ -62,7 +71,10 @@ public class LocalFileUtil {
|
||||
|
||||
public void saveFile(InputStream fileInputStream, String fileName) throws IOException {
|
||||
String path = localFilePath + fileName;
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(path);
|
||||
|
||||
FileOutputStream fileOutputStream= null;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(path);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fileInputStream.read(buffer)) > 0) {
|
||||
@@ -70,6 +82,17 @@ public class LocalFileUtil {
|
||||
}
|
||||
fileInputStream.close();
|
||||
fileOutputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (fileOutputStream != null){
|
||||
fileOutputStream.close();
|
||||
}
|
||||
|
||||
if (fileInputStream != null){
|
||||
fileInputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getFileFromLocal(String savePath, FileOutputStream outputStream) throws IOException {
|
||||
@@ -80,9 +103,10 @@ public class LocalFileUtil {
|
||||
if (!sourceFile.exists()) {
|
||||
throw new IOException("Source file does not exist.");
|
||||
}
|
||||
|
||||
FileInputStream inputStream = null;
|
||||
try {
|
||||
// 创建输入流
|
||||
FileInputStream inputStream = new FileInputStream(sourceFile);
|
||||
inputStream = new FileInputStream(sourceFile);
|
||||
|
||||
// 创建缓冲区
|
||||
byte[] buffer = new byte[1024];
|
||||
@@ -92,11 +116,18 @@ public class LocalFileUtil {
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
// 关闭输入流和输出流
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null){
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void downFile(String savePath, HttpServletResponse response) throws IOException {
|
||||
String filePath = uploadFile + savePath;
|
||||
|
||||
@@ -89,7 +89,9 @@ public class ObsBootUtil {
|
||||
throw new AdcDaBaseException("OBS下载文件失败");
|
||||
}finally {
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
if (objectContent != null) {
|
||||
objectContent.close();
|
||||
}
|
||||
response.getOutputStream().close();
|
||||
}
|
||||
|
||||
@@ -112,9 +114,14 @@ public class ObsBootUtil {
|
||||
throw new AdcDaBaseException("OBS下载文件失败");
|
||||
}finally {
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
if (objectContent != null){
|
||||
objectContent.close();
|
||||
}
|
||||
|
||||
if (outputStream != null){
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -179,10 +179,11 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
return Result.error(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (is != null){
|
||||
is.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,17 +193,18 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
@ApiOperation("下载模板")
|
||||
@GetMapping("/template")
|
||||
public ResponseMessage download(HttpServletResponse response) {
|
||||
|
||||
InputStream fis = null;
|
||||
OutputStream toClient = null;
|
||||
try {
|
||||
InputStream fis = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/用户导入模板.xlsx");
|
||||
fis = Thread.currentThread().getContextClassLoader().getResourceAsStream("template/用户导入模板.xlsx");
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
|
||||
response.reset();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("用户导入模板.xlsx","UTF-8"));
|
||||
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
||||
toClient = new BufferedOutputStream(response.getOutputStream());
|
||||
|
||||
toClient.write(buffer);
|
||||
|
||||
@@ -211,9 +213,23 @@ public class UserEOController extends BaseController<UserEO> {
|
||||
toClient.close();
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (fis != null){
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (toClient != null){
|
||||
try {
|
||||
toClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success();
|
||||
|
||||
|
||||
@@ -61,9 +61,10 @@ public class CompressUtil {
|
||||
}
|
||||
|
||||
} else { // 当前是文件
|
||||
|
||||
FileInputStream inputStream = null;
|
||||
try {
|
||||
// 输入流
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
inputStream = new FileInputStream(file);
|
||||
// 标记要打包的条目
|
||||
out.putNextEntry(new ZipEntry(file.getName()));
|
||||
// 进行写操作
|
||||
@@ -72,9 +73,14 @@ public class CompressUtil {
|
||||
while ((len = inputStream.read(bytes)) > 0) {
|
||||
out.write(bytes, 0, len);
|
||||
}
|
||||
// 关闭输入流
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null){
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.sys.util;
|
||||
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import sun.misc.BASE64Decoder;
|
||||
@@ -41,6 +42,11 @@ public class EncryptUtil {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (encrypt == null){
|
||||
throw new AdcDaBaseException("秘钥生成错误");
|
||||
}
|
||||
|
||||
// 取MD5Hash码,并组合加密数组
|
||||
byte[] md5Hasn = null;
|
||||
try {
|
||||
@@ -48,6 +54,11 @@ public class EncryptUtil {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (md5Hasn == null){
|
||||
throw new AdcDaBaseException("MD5生成错误");
|
||||
}
|
||||
|
||||
// 组合消息体
|
||||
byte[] totalByte = EncryptUtil.addMD5(md5Hasn, encrypt);
|
||||
|
||||
@@ -112,6 +123,10 @@ public class EncryptUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (temp == null){
|
||||
throw new AdcDaBaseException("秘钥生成错误");
|
||||
}
|
||||
|
||||
// 进行解密后的md5Hash校验
|
||||
byte[] md5Hash = null;
|
||||
try {
|
||||
@@ -120,6 +135,10 @@ public class EncryptUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (md5Hash == null){
|
||||
throw new AdcDaBaseException("MD5生成错误");
|
||||
}
|
||||
|
||||
// 进行解密校检
|
||||
for (int i = 0; i < md5Hash.length; i++) {
|
||||
if (md5Hash[i] != temp[i]) {
|
||||
|
||||
+12
-3
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.wkflow.business_activiti.instance.service;
|
||||
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
@@ -57,16 +58,24 @@ public class InstanceService {
|
||||
|
||||
// 得到高亮线
|
||||
List<String> highLightedFlowsList = getHighLightedFlows(processDefinition, historicActivityInstanceList);
|
||||
|
||||
InputStream imageStream = null;
|
||||
try {
|
||||
// 获取流程图图像字符流
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
DefaultProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
|
||||
InputStream imageStream = generator.generateDiagram(bpmnModel, "png", executedActivityIdList,
|
||||
imageStream = generator.generateDiagram(bpmnModel, "png", executedActivityIdList,
|
||||
highLightedFlowsList, "宋体", "宋体", "宋体", null, 1.0);
|
||||
byte[] buffer = new byte[imageStream.available()];
|
||||
imageStream.read(buffer);
|
||||
imageStream.close();
|
||||
return buffer;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new AdcDaBaseException("流程图生成错误,请检查");
|
||||
} finally {
|
||||
if (imageStream != null){
|
||||
imageStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-48
@@ -277,10 +277,6 @@ public class TodoTaskController {
|
||||
|
||||
/**
|
||||
* 转办
|
||||
* @param taskId
|
||||
* @param assignee
|
||||
* @param userId
|
||||
* @param pId
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "新改派任务")
|
||||
@@ -387,7 +383,14 @@ public class TodoTaskController {
|
||||
}
|
||||
iBusProcessNameService.updateById(one);
|
||||
}
|
||||
|
||||
if (task == null){
|
||||
throw new AdcDaBaseException("缺少任务信息,无法完成任务");
|
||||
} else {
|
||||
return WrapMapper.ok(task.getProcessInstanceId());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
throw new AdcDaBaseException("缺少任务id,无法完成任务");
|
||||
}
|
||||
@@ -1077,7 +1080,7 @@ public class TodoTaskController {
|
||||
.processInstanceId(busProcessName.getPrcId())
|
||||
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
|
||||
if (userTask.size() > 0) {
|
||||
if (end.equals("1")) {
|
||||
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
@@ -1085,15 +1088,7 @@ public class TodoTaskController {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
busProcessName.setTaskBackAssignee("");
|
||||
}
|
||||
@@ -1118,6 +1113,7 @@ public class TodoTaskController {
|
||||
Date createTime = null;
|
||||
Date endTime = null;
|
||||
try {
|
||||
SimpleDateFormat SimpleDateFormat_YMD_HMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
createTime = SimpleDateFormat_YMD_HMS.parse(busProcessName.getCreatTime());
|
||||
if(StringUtils.isNotEmpty(busProcessName.getEndTime())){
|
||||
endTime = SimpleDateFormat_YMD_HMS.parse(busProcessName.getEndTime());
|
||||
@@ -1255,23 +1251,11 @@ public class TodoTaskController {
|
||||
.processInstanceId(busProcessName.getPrcId())
|
||||
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
|
||||
if (userTask.size() > 0) {
|
||||
if (end.equals("1")) {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)) {
|
||||
for (UserVO userVO : userVOList) {
|
||||
if (StringUtils.equals(userTask.get(0).getAssignee(), userVO.getUsid())) {
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)) {
|
||||
for (UserVO userVO : userVOList) {
|
||||
if (StringUtils.equals(userTask.get(0).getAssignee(), userVO.getUsid())) {
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
busProcessName.setTaskBackAssignee("");
|
||||
}
|
||||
@@ -1295,6 +1279,7 @@ public class TodoTaskController {
|
||||
Date createTime = null;
|
||||
Date endTime = null;
|
||||
try {
|
||||
SimpleDateFormat SimpleDateFormat_YMD = new SimpleDateFormat("yyyy-MM-dd");
|
||||
createTime = SimpleDateFormat_YMD.parse(busProcessName.getCreatTime());
|
||||
if(StringUtils.isNotEmpty(busProcessName.getEndTime())){
|
||||
endTime = SimpleDateFormat_YMD.parse(busProcessName.getEndTime());
|
||||
@@ -1436,7 +1421,6 @@ public class TodoTaskController {
|
||||
.processInstanceId(busProcessName.getPrcId())
|
||||
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
|
||||
if (userTask.size() > 0) {
|
||||
if (end.equals("1")) {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
@@ -1444,32 +1428,14 @@ public class TodoTaskController {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
busProcessName.setTaskBackAssignee("");
|
||||
}
|
||||
//获取 审批结果
|
||||
// if (StringUtils.isNotEmpty(busProcessName.getPrcId())) {
|
||||
// List<BusProcessApprove> busProcessApproves = iBusProcessApproveService.selectEoByPrcIdAndTask(busProcessName.getPrcId());
|
||||
// if(busProcessApproves.size() != 0){
|
||||
// BusProcessApprove busProcessApprove = busProcessApproves.get(0);
|
||||
// JSONObject dataJson = JSONObject.parseObject(busProcessApprove.getFromValsJson());
|
||||
// if (StringUtils.isNotEmpty(dataJson.getString("flag"))) {
|
||||
// busProcessName.setStatus(dataJson.getString("flag"));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Date createTime = null;
|
||||
Date endTime = null;
|
||||
try {
|
||||
SimpleDateFormat SimpleDateFormat_YMD = new SimpleDateFormat("yyyy-MM-dd");
|
||||
createTime = SimpleDateFormat_YMD.parse(busProcessName.getCreatTime());
|
||||
if(StringUtils.isNotEmpty(busProcessName.getEndTime())){
|
||||
endTime = SimpleDateFormat_YMD.parse(busProcessName.getEndTime());
|
||||
@@ -1530,7 +1496,7 @@ public class TodoTaskController {
|
||||
int fromIndex = 0; // 开始索引
|
||||
int toIndex = 0; // 结束索引
|
||||
|
||||
if (pageNum != pageCount) {
|
||||
if (!pageNum.equals(pageCount)) {
|
||||
fromIndex = (pageNum - 1) * pageSize;
|
||||
toIndex = fromIndex + pageSize;
|
||||
} else {
|
||||
|
||||
@@ -7,11 +7,10 @@ import java.util.Date;
|
||||
|
||||
public class CreatedTools {
|
||||
|
||||
private final static DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
// 返回long型的创建时间
|
||||
public static long getCreated() {
|
||||
Date d = new Date();
|
||||
DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
long l = Long.parseLong(df.format(d));
|
||||
return l;
|
||||
}
|
||||
@@ -19,6 +18,7 @@ public class CreatedTools {
|
||||
public static long getCreated(int add) {
|
||||
long t = System.currentTimeMillis() + add;
|
||||
Timestamp time = new Timestamp(t);
|
||||
DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
long l = Long.parseLong(df.format(time));
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ import java.util.Date;
|
||||
|
||||
public class DateTools {
|
||||
|
||||
public static SimpleDateFormat SimpleDateFormat_YMD = new SimpleDateFormat("yyyy-MM-dd");
|
||||
public static SimpleDateFormat SimpleDateFormat_YMD_HMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// 增加对应天数
|
||||
public static Timestamp addDay(Timestamp end, int day) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
@@ -369,9 +366,14 @@ public class DateTools {
|
||||
public static int getDayOfMonth(String yearMonth) {
|
||||
java.sql.Date date = getYearMonth(yearMonth);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
if (date != null){
|
||||
cal.setTimeInMillis(date.getTime());
|
||||
int dateOfMonth = cal.getActualMaximum(Calendar.DATE);
|
||||
return dateOfMonth;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取每月最大天数
|
||||
@@ -461,24 +463,12 @@ public class DateTools {
|
||||
|
||||
String str = getstrDate1(20181113110947L);
|
||||
System.out.println(str);
|
||||
// System.err.println(getDayOfMonth(2000, 2));
|
||||
// System.err.println(getDayOfMonth("2000-02"));
|
||||
/*
|
||||
* System.err.println(getYearToLong(2016));
|
||||
* System.err.println(getYearToLong(2017));
|
||||
* System.err.println(getYearToLong(2018));
|
||||
*/
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long a = sdf.parse(str).getTime();
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
System.out.println(sdf1.format(new Date(a)));
|
||||
}
|
||||
|
||||
public static long getYearToLong(int year) {
|
||||
java.sql.Date date = strToDate(year + "-01-01");
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
public static long getCreated() {
|
||||
Date d = new Date();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
@@ -78,16 +78,16 @@ public class FileTools {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (null != fin) {
|
||||
if (fin != null) {
|
||||
fin.close();
|
||||
}
|
||||
if (null != fout) {
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
if (null != fcin) {
|
||||
if (fcin != null) {
|
||||
fcin.close();
|
||||
}
|
||||
if (null != fcout) {
|
||||
if (fcout != null) {
|
||||
fcout.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
@@ -100,7 +100,6 @@ public class FileTools {
|
||||
/**
|
||||
* 判断文件夹中所有文件的名字是否含有.bid
|
||||
*
|
||||
* @param file 想要读取的文件对象
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean checkFileName(String filePath, String exclusive_name) {
|
||||
@@ -208,70 +207,4 @@ public class FileTools {
|
||||
return foldResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件写入数据
|
||||
*
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
public static boolean writeFile(String content, String url) {
|
||||
if (StrUtil.isEmpty(url)) {
|
||||
return false;
|
||||
}
|
||||
BufferedWriter writer = null;
|
||||
try {
|
||||
|
||||
File file = new File(url);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream writerStream = new FileOutputStream(file);
|
||||
writer = new BufferedWriter(new OutputStreamWriter(writerStream, "UTF-8"));
|
||||
writer.write(content);
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String readFileToString(String file) {
|
||||
String content = "";
|
||||
// 2、建立数据通道
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
int length = 0;
|
||||
// 循环读取文件内容,输入流中将最多buf.length个字节的数据读入一个buf数组中,返回类型是读取到的字节数。
|
||||
// 当文件读取到结尾时返回 -1,循环结束。
|
||||
while ((length = fis.read(buf)) != -1) {
|
||||
content += new String(buf, 0, length);
|
||||
}
|
||||
// 最后记得,关闭流
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user