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.

89 lines
3.5 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.engine.attendance.workflow.action;
import com.engine.common.util.DbTools;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.*;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: sy
* @Description: 撤销请假
* @Date: 2024/3/15
**/
@Slf4j
public class RevokeLeaveAction implements Action {
@Override
public String execute(RequestInfo requestInfo) {
log.info("RevokeLeaveAction,do action on request:" + requestInfo.getRequestid());
String requestid = requestInfo.getRequestid();
try {
// Property[] property = requestInfo.getMainTableInfo().getProperty();
// User user = requestInfo.getRequestManager().getUser();
// for (Property pro : property) {
// String name = Util.null2String(pro.getName());
// if(name.equals("cxsm")){
//
// }
// }
DetailTable[] detailTable = requestInfo.getDetailTableInfo().getDetailTable();
List<Map<String, String>> updateList = new ArrayList<>();
if (detailTable.length > 0) {
for (DetailTable dt : detailTable) {
//明细表
Row[] s = dt.getRow();
for (Row r : s) {
//行
Cell[] h = r.getCell();
for (Cell c : h) {
//列
Map<String, String> itemMap = new HashMap<>();
String name = Util.null2String(c.getName());
if ("cxsm".equals(name)) {
itemMap.put("cxsm", Util.null2String(c.getValue()));
} else if ("cxlyid".equals(name)) {
itemMap.put("cxlyid", Util.null2String(c.getValue()));
updateList.add(itemMap);
}
}
}
}
}
if (updateList.size() > 0) {
updateList.forEach(f -> {
if (StringUtils.isNotBlank(f.get("cxlyid"))) {
String sql = "update uf_jcl_kq_ccjl_dt1" +" set "+"cxly=0,cxcc=1,cxsm=?,cxid=? where id = ?";
log.info("RevokeLeaveAction sql : [{}]",sql);
DbTools.update(sql, Util.null2String(f.get("cxsm")), requestid, f.get("cxlyid"));
log.info("RevokeLeaveAction cxsm : {}, requestid : {}, cxlyid : {}",Util.null2String(f.get("cxsm")), requestid, f.get("cxlyid"));
}
});
}
} catch (Exception e) {
log.info("流程数据报错:RevokeLeaveAction:");
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
log.info(errorsWriter.toString());
requestInfo.getRequestManager().setMessageid("11111" + requestInfo.getRequestid() + "22222");
requestInfo.getRequestManager().setMessagecontent("【撤销请假更改请假撤销状态action】报错请联系管理员");
return Action.FAILURE_AND_CONTINUE;
}
return SUCCESS;
}
}