You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.2 KiB
Java

2 years ago
package weaver.interfaces.workflow.action.javacode;
import com.api.formmode.page.util.Util;
import com.icbc.api.internal.apache.http.E;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.general.BaseBean;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
/**
* Online custom action interface
*
*/
public class Action20231013103613 extends BaseBean implements Action {
/**
* After selecting aciton after the process path node, this method will be executed after the node is submitted.
*/
@Override
public String execute(RequestInfo request) {
String requestId = request.getRequestid();
String tablename = request.getRequestManager().getBillTableName();
RecordSet rs = new RecordSet();
try {
rs.executeQuery("select MAINREQUESTID from workflow_requestbase where requestid = ?" , requestId);
//查询主流程
String mainrequestid = "";
if(rs.next()){
mainrequestid = Util.null2String(rs.getString("MAINREQUESTID"));
}
//查询平行流程request
ArrayList<String> siblingRequestIds = new ArrayList<>();
rs.executeQuery("select requestid from workflow_requestbase where MAINREQUESTID = ?" , mainrequestid);
while(rs.next()){
String siblingRequestId = Util.null2String(rs.getString("requestid"));
siblingRequestIds.add(siblingRequestId);
}
writeLog("平行流程"+siblingRequestIds);
//当前流程的协办部门
rs.execute("select * from " + tablename + " where requestid = " + requestId);
rs.next();
String xbbm = rs.getString("xbbm");
//
HashMap<String, String> xbbmMap = new HashMap<>();
rs.execute("select * from " + tablename + " where requestid in (" + String.join(",",siblingRequestIds)+" )");
while ( rs.next()){
String mainid = rs.getString("id");
String ycfxbbm = rs.getString("ycfxbbm");
String newycfxbbm = mergeWithoutDuplicates(xbbm, ycfxbbm);
xbbmMap.put(mainid,newycfxbbm);
}
writeLog("修改平行流程"+xbbmMap);
xbbmMap.forEach((key,value) ->{
rs.executeUpdate("update "+ tablename +" set ycfxbbm = ? where id = ?",value,key);
});
}catch (Exception e){
boolean error = true;
if (error) {
request.getRequestManager().setMessageid("90001");
request.getRequestManager().setMessagecontent("System Abnormal Termination Process Submission");
}
}
return Action.SUCCESS;
}
// public static String mergeWithoutDuplicates(String a, String b) {
// if (b == null || b.isEmpty()) {
// return a;
// }
//
// String[] idsA = a.split(",");
// String[] idsB = b.split(",");
//
// for (String idA : idsA) {
// boolean exists = false;
// for (String idB : idsB) {
// if (idA.equals(idB)) {
// exists = true;
// break;
// }
// }
// if (!exists) {
// b += "," + idA;
// }
// }
// return b;
// }
public static void main(String[] args) {
String a = "1,2,3,4,5";
String b = "3,4,5,6,7";
b = mergeWithoutDuplicates(a, b);
System.out.println(b); // 输出: 3,4,5,6,7,1,2
}
public static String mergeWithoutDuplicates(String a, String b) {
Set<String> setB = new HashSet<>();
StringBuilder result = new StringBuilder(b);
if (b != null && !b.isEmpty()) {
for (String id : b.split(",")) {
setB.add(id.trim());
}
}
for (String idA : a.split(",")) {
idA = idA.trim();
if (!setB.contains(idA)) {
if (result.length() > 0) {
result.append(",");
}
result.append(idA);
}
}
return result.toString();
}
}