更新ppt文件,待阅发送完成后发送成功回执
This commit is contained in:
parent
ac50b06e26
commit
32ccca18a3
@ -16,6 +16,7 @@ import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
@ -27,6 +28,7 @@ import org.quartz.JobExecutionException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -34,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class CopyJob implements IJob {
|
||||
|
||||
private int sendTotal;
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
@ -135,15 +138,15 @@ public class CopyJob implements IJob {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
list.add("10036614");
|
||||
list.add("10056870");
|
||||
// list.add("10036614");
|
||||
// list.add("10056870");
|
||||
|
||||
|
||||
new_uid = new_uid.join(",", list);
|
||||
new_uid = new_uid.join(",", sendList);
|
||||
long startTimes = System.currentTimeMillis();
|
||||
String[] users = new_uid.split(",");
|
||||
System.out.println("new_uid>>>>>>>>>>>>>>"+users.length);
|
||||
int length = 1;
|
||||
int length = 100;
|
||||
int ys = users.length%length;
|
||||
/**
|
||||
* 这个是以300人作为一个发送单位去放到list中并发送待阅数据
|
||||
@ -156,9 +159,9 @@ public class CopyJob implements IJob {
|
||||
|
||||
for (int i=0;i<size;i++){
|
||||
String[] results;
|
||||
results = Arrays.copyOfRange(users, flag, flag+1);
|
||||
results = Arrays.copyOfRange(users, flag, flag+100);
|
||||
lists.add(results);
|
||||
flag = flag+1;
|
||||
flag = flag+100;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +176,9 @@ public class CopyJob implements IJob {
|
||||
|
||||
for (int i=0;i<size;i++){
|
||||
String[] results;
|
||||
results = Arrays.copyOfRange(users, flag, flag+1);
|
||||
results = Arrays.copyOfRange(users, flag, flag+100);
|
||||
lists.add(results);
|
||||
flag = flag+1;
|
||||
flag = flag+100;
|
||||
}
|
||||
String[] redata;
|
||||
redata = Arrays.copyOfRange(users, flag, flag+ys);
|
||||
@ -209,13 +212,14 @@ public class CopyJob implements IJob {
|
||||
|
||||
|
||||
|
||||
public void course(List<String[]> list, long startTime, JSONObject jsonObject, ProcessInstance processInstance,ArrayList<String> sendList){
|
||||
public void course(List<String[]> list, long startTime, JSONObject jsonObject, ProcessInstance processInstance,ArrayList<String> sendList) throws Exception {
|
||||
final boolean[] flag = {false};
|
||||
// 创建线程来实现为每100人为一个的线程跑待阅
|
||||
CountDownLatch countDownLatch = new CountDownLatch(list.size());
|
||||
ExecutorService service = Executors.newFixedThreadPool(5);
|
||||
int m = 0;
|
||||
for (String[] resrt:list
|
||||
) {
|
||||
int finalM = m;
|
||||
service.execute(new Runnable() {
|
||||
@Override
|
||||
|
||||
@ -231,6 +235,7 @@ public class CopyJob implements IJob {
|
||||
}*/
|
||||
try {
|
||||
SendOARead(jsonObject, processInstance, userIds,"批量推送");
|
||||
countDownLatch.countDown();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -240,67 +245,68 @@ public class CopyJob implements IJob {
|
||||
});
|
||||
m++;
|
||||
}
|
||||
countDownLatch.await();
|
||||
if (countDownLatch.getCount()==0){
|
||||
|
||||
try {
|
||||
// 等待所有的任务执行完毕,最多等待1小时
|
||||
if (service.awaitTermination(12, TimeUnit.HOURS)) {
|
||||
List<RowMap> List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '"
|
||||
+ processInstance.getId() + "' AND RESULT = '待处理'");
|
||||
if (List.size() != 0) {
|
||||
System.err.println(processInstance.getTitle() + "批量推送失败后执行二次推送=======>" + List.size());
|
||||
for (RowMap rowMap : List) {
|
||||
try {
|
||||
ArrayList<String> secondUserList = new ArrayList<String>();
|
||||
secondUserList.add(rowMap.getString("NAME"));
|
||||
System.err.println(processInstance.getTitle() + "二次推送账号=======>" + secondUserList);
|
||||
try {
|
||||
// 等待所有的任务执行完毕,最多等待1小时
|
||||
|
||||
BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processInstance.getId()).addQuery("TASKSTATUS=",2).detail();
|
||||
if(executiveTaskBO!=null){
|
||||
List<BO> recordFailLists = new ArrayList<BO>();
|
||||
for(RowMap oneuserId:List){
|
||||
BO bo = new BO();
|
||||
bo.set("TITLE", processInstance.getTitle());
|
||||
bo.set("NAME", oneuserId.getString("NAME"));
|
||||
bo.set("TYPE", "批量推送");
|
||||
bo.set("RESULT", "待处理");
|
||||
bo.set("PROCESSID", processInstance.getId());
|
||||
bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId.getString("NAME")).getDepartmentId());
|
||||
recordFailLists.add(bo);
|
||||
}
|
||||
SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance.getId(), processInstance.getCreateUser());
|
||||
return;
|
||||
List<RowMap> List = DBSql.getMaps("SELECT NAME FROM BO_EU_READ_COUNT WHERE PROCESSID = '"
|
||||
+ processInstance.getId() + "' AND RESULT = '待处理'");
|
||||
if (List.size() != 0) {
|
||||
System.err.println(processInstance.getTitle() + "批量推送失败后执行二次推送=======>" + List.size());
|
||||
for (RowMap rowMap : List) {
|
||||
try {
|
||||
ArrayList<String> secondUserList = new ArrayList<String>();
|
||||
secondUserList.add(rowMap.getString("NAME"));
|
||||
System.err.println(processInstance.getTitle() + "二次推送账号=======>" + secondUserList);
|
||||
|
||||
BO executiveTaskBO=SDK.getBOAPI().query("BO_ACT_EXECUTIVE_TASK").addQuery("TASKID=",processInstance.getId()).addQuery("TASKSTATUS=",2).detail();
|
||||
if(executiveTaskBO!=null){
|
||||
List<BO> recordFailLists = new ArrayList<BO>();
|
||||
for(RowMap oneuserId:List){
|
||||
BO bo = new BO();
|
||||
bo.set("TITLE", processInstance.getTitle());
|
||||
bo.set("NAME", oneuserId.getString("NAME"));
|
||||
bo.set("TYPE", "批量推送");
|
||||
bo.set("RESULT", "待处理");
|
||||
bo.set("PROCESSID", processInstance.getId());
|
||||
bo.set("DEPNAME", SDK.getORGAPI().getUser(oneuserId.getString("NAME")).getDepartmentId());
|
||||
recordFailLists.add(bo);
|
||||
}
|
||||
|
||||
secondSendOARead(jsonObject, processInstance, secondUserList, "单个账号推送");
|
||||
} catch (Exception e) { // TODO: handle exception
|
||||
SDK.getBOAPI().create("BO_EU_READ_COUNT", recordFailLists, processInstance.getId(), processInstance.getCreateUser());
|
||||
return;
|
||||
}
|
||||
|
||||
secondSendOARead(jsonObject, processInstance, secondUserList, "单个账号推送");
|
||||
} catch (Exception e) { // TODO: handle exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long endTimes = System.currentTimeMillis();
|
||||
// 存入日志
|
||||
createReadLog(processInstance, jsonObject, sendList, startTime, endTimes);
|
||||
System.err.println(processInstance.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
|
||||
+ (endTimes - startTime) / 1000 / 60 + "分钟");
|
||||
}
|
||||
|
||||
long endTimes = System.currentTimeMillis();
|
||||
// 存入日志
|
||||
createReadLog(processInstance, jsonObject, sendList, startTime, endTimes);
|
||||
System.err.println(processInstance.getTitle() + "推送OA待阅执行完毕====>" + "用时:"
|
||||
+ (endTimes - startTime) / 1000 / 60 + "分钟");
|
||||
|
||||
|
||||
|
||||
//发送消息通知
|
||||
List<BO> readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",processInstance.getId()).list();
|
||||
if(readCountBO.size()>0){
|
||||
SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+processInstance.getTitle()+"文件有失败记录,请及时处理!!!");
|
||||
}
|
||||
//发送消息通知
|
||||
List<BO> readCountBO=SDK.getBOAPI().query("BO_EU_READ_COUNT").addQuery("PROCESSID=",processInstance.getId()).list();
|
||||
if(readCountBO.size()>0){
|
||||
SDK.getNotificationAPI().sendMessage("admin", "admin", "文件名称:"+processInstance.getTitle()+"文件有失败记录,请及时处理!!!");
|
||||
}
|
||||
|
||||
//更新任务状态
|
||||
int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID ='" + processInstance.getId() + "'");
|
||||
//更新任务状态
|
||||
int r1 = DBSql.update("UPDATE BO_ACT_EXECUTIVE_TASK SET ISTASKEND='2' WHERE TASKID ='" + processInstance.getId() + "'");
|
||||
|
||||
|
||||
} else {
|
||||
System.out.println("超过等待时间,部分任务未执行完毕");
|
||||
} catch (Exception e) {
|
||||
System.out.println("等待中断异常");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("等待中断异常");
|
||||
} else {
|
||||
System.out.println("超过等待时间,部分任务未执行完毕");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -540,16 +541,15 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
||||
* @param jsonObject
|
||||
* @param processExecutionContext
|
||||
*/
|
||||
public void course(List<String[]> list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList<String> sendList){
|
||||
public void course(List<String[]> list,long startTime,JSONObject jsonObject,ProcessExecutionContext processExecutionContext,ArrayList<String> sendList) throws InterruptedException {
|
||||
// 创建线程来实现为每100人为一个的线程跑待阅
|
||||
ProcessInstance instanceById = processExecutionContext.getProcessInstance();
|
||||
final boolean[] flag = {false};
|
||||
CountDownLatch countDownLatch = new CountDownLatch(list.size());
|
||||
ExecutorService service = Executors.newFixedThreadPool(5);
|
||||
int m = 0;
|
||||
for (String[] resrt:list
|
||||
) {
|
||||
int finalM = m;
|
||||
final boolean[] filnaflag = {flag[0]};
|
||||
service.execute(new Runnable() {
|
||||
@Override
|
||||
|
||||
@ -559,9 +559,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
||||
userIds = StringUtils.join(resrt, ",");
|
||||
System.out.println("userIDs>>>>>>>>>>>>>>>"+userIds);
|
||||
try {
|
||||
filnaflag[0] = false;
|
||||
SendOARead(jsonObject, processExecutionContext.getProcessInstance(), userIds,"批量推送");
|
||||
flag[0] = true;
|
||||
countDownLatch.countDown();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -570,8 +569,8 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
||||
});
|
||||
m++;
|
||||
}
|
||||
|
||||
if (service.isTerminated()){
|
||||
countDownLatch.await();
|
||||
if (countDownLatch.getCount()==0){
|
||||
|
||||
try {
|
||||
// 等待所有的任务执行完毕,最多等待1小时
|
||||
@ -633,6 +632,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute
|
||||
} else {
|
||||
System.out.println("超过等待时间,部分任务未执行完毕");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -34,6 +34,9 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
|
||||
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
||||
import org.apache.poi.sl.usermodel.Shape;
|
||||
import org.apache.poi.sl.usermodel.Slide;
|
||||
import org.apache.poi.sl.usermodel.TableCell;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Color;
|
||||
@ -420,7 +423,7 @@ public class UpFileExcelAndPptController {
|
||||
String[] fileNames ={dcContext.getFilePath(),dcContext_old.getFilePath()} ;
|
||||
String mergedFileName = dcContext.getPath()+"dc.pptx";
|
||||
|
||||
if (name.endsWith(".pptx")){
|
||||
if (name.endsWith(".pptx")||name.endsWith(".ppt")){
|
||||
try (FileOutputStream outputStream = new FileOutputStream(mergedFileName)) {
|
||||
XMLSlideShow mergedSlideShow = new XMLSlideShow();
|
||||
|
||||
@ -599,8 +602,6 @@ public class UpFileExcelAndPptController {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -612,6 +613,35 @@ public class UpFileExcelAndPptController {
|
||||
|
||||
|
||||
|
||||
|
||||
private static void copyConditionalFormatting(HSLFSlide sourceSlide, HSLFSlide targetSlide) {
|
||||
List<HSLFShape> shapes = sourceSlide.getShapes();
|
||||
for (HSLFShape shape : shapes) {
|
||||
if (shape instanceof HSLFTextShape) {
|
||||
HSLFTextShape textShape = (HSLFTextShape) shape;
|
||||
HSLFTextShape newShape = targetSlide.createTextBox();
|
||||
newShape.setText(textShape.getText());
|
||||
newShape.setTextPlaceholder(textShape.getTextPlaceholder());
|
||||
} else {
|
||||
targetSlide.addShape(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static HSLFTextShape getMatchingTextShape(HSLFSlide slide, HSLFTextShape sourceShape) {
|
||||
List<HSLFShape> shapes = slide.getShapes();
|
||||
for (HSLFShape shape : shapes) {
|
||||
if (shape instanceof HSLFTextShape) {
|
||||
HSLFTextShape textShape = (HSLFTextShape) shape;
|
||||
if (textShape.getTextParagraphs().size() == sourceShape.getTextParagraphs().size()) {
|
||||
return textShape;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 更新幻灯片ID列表
|
||||
// 更新幻灯片ID列表
|
||||
// 移动幻灯片位置
|
||||
@ -663,6 +693,30 @@ public class UpFileExcelAndPptController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void copyImages(HSLFSlide sourceSlide, HSLFSlide targetSlide) {
|
||||
for (HSLFShape shape : sourceSlide.getShapes()) {
|
||||
if (shape instanceof HSLFPictureShape) {
|
||||
HSLFPictureShape pictureShape = (HSLFPictureShape) shape;
|
||||
HSLFPictureData pictureData = pictureShape.getPictureData();
|
||||
|
||||
try {
|
||||
byte[] pictureBytes = pictureData.getData();
|
||||
String pictureType = pictureData.getContentType();
|
||||
HSLFPictureData pictureIndex = targetSlide.getSlideShow().addPicture(pictureBytes, pictureData.getType());
|
||||
|
||||
HSLFPictureShape newPictureShape = targetSlide.createPicture(pictureIndex);
|
||||
newPictureShape.setAnchor(pictureShape.getAnchor());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*获取修订记录
|
||||
* @param repositoryModel
|
||||
|
||||
Loading…
Reference in New Issue
Block a user