修复部分sonar问题
This commit is contained in:
+19
-10
@@ -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);
|
||||
|
||||
// 获取流程图图像字符流
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
DefaultProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
|
||||
InputStream imageStream = generator.generateDiagram(bpmnModel, "png", executedActivityIdList,
|
||||
highLightedFlowsList, "宋体", "宋体", "宋体", null, 1.0);
|
||||
byte[] buffer = new byte[imageStream.available()];
|
||||
imageStream.read(buffer);
|
||||
imageStream.close();
|
||||
return buffer;
|
||||
InputStream imageStream = null;
|
||||
try {
|
||||
// 获取流程图图像字符流
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
DefaultProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
|
||||
imageStream = generator.generateDiagram(bpmnModel, "png", executedActivityIdList,
|
||||
highLightedFlowsList, "宋体", "宋体", "宋体", null, 1.0);
|
||||
byte[] buffer = new byte[imageStream.available()];
|
||||
imageStream.read(buffer);
|
||||
return buffer;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new AdcDaBaseException("流程图生成错误,请检查");
|
||||
} finally {
|
||||
if (imageStream != null){
|
||||
imageStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-60
@@ -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);
|
||||
}
|
||||
return WrapMapper.ok(task.getProcessInstanceId());
|
||||
|
||||
if (task == null){
|
||||
throw new AdcDaBaseException("缺少任务信息,无法完成任务");
|
||||
} else {
|
||||
return WrapMapper.ok(task.getProcessInstanceId());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
throw new AdcDaBaseException("缺少任务id,无法完成任务");
|
||||
}
|
||||
@@ -1077,23 +1080,15 @@ 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())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
|
||||
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() + ")");
|
||||
}
|
||||
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,40 +1421,21 @@ 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())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(CollectionUtils.isNotEmpty(userVOList)){
|
||||
for (UserVO userVO : userVOList) {
|
||||
if(StringUtils.equals(userVO.getUsid(),userTask.get(0).getAssignee())){
|
||||
busProcessName.setTaskBackAssignee(userVO.getUsname() + "(" + userVO.getAccount() + ")");
|
||||
}
|
||||
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 {
|
||||
|
||||
@@ -6,12 +6,11 @@ import java.text.SimpleDateFormat;
|
||||
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();
|
||||
cal.setTimeInMillis(date.getTime());
|
||||
int dateOfMonth = cal.getActualMaximum(Calendar.DATE);
|
||||
return dateOfMonth;
|
||||
|
||||
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) {
|
||||
@@ -99,8 +99,7 @@ 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