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.

58 lines
2.3 KiB
Java

package com.customization.workflow;
import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.workflow.cmd.forward.SaveFwLimitSetCmd;
import weaver.conn.RecordSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:CL
* @date:2023/2/11 14:00
*/
@CommandDynamicProxy(target = SaveFwLimitSetCmd.class, desc = "指定流转")
public class SaveFwLimitCmd extends AbstractCommandProxy<Map<String, Object>> {
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
SaveFwLimitSetCmd cmd = (SaveFwLimitSetCmd) command;
int uid = cmd.getUser().getUID();
String objtype = (String) cmd.getParams().get("objtype");
// 如果选择平行部门 就对参数进行修改 选择其他则执行之前的逻辑
if ("16".equals(objtype)) {
// 查询平行部门
String sql = "select id,departmentname from hrmdepartment where supdepid=" +
"(select d.supdepid from HrmResource r join hrmdepartment d on r.departmentid=d.id where r.id=?)" +
"and subcompanyid1 = (select subcompanyid1 from HrmResource where id=?) ";
RecordSet recordSet = new RecordSet();
boolean flag = recordSet.executeQuery(sql, uid, uid);
if (flag) {
List<String> idList = new ArrayList<>();
List<String> nameList = new ArrayList<>();
while (recordSet.next()) {
idList.add(recordSet.getString("id"));
nameList.add(recordSet.getString("departmentname"));
}
// 改造参数 放回command
String departmentid = idList.stream().map(String::valueOf).collect(Collectors.joining(","));
String departmentidspan = nameList.stream().map(String::valueOf).collect(Collectors.joining(","));
cmd.getParams().put("departmentid", departmentid);
cmd.getParams().put("departmentidspan", departmentidspan);
}
}
// 执行原有的逻辑
Map<String, Object> result = nextExecute(cmd);
return result;
}
}