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.

121 lines
4.7 KiB
Java

2 years ago
package com.engine.tjbankSocket.impl;
import com.engine.tjbankSocket.SocketExecute;
import com.engine.util.XMLUtils;
2 years ago
import com.icbc.api.internal.apache.http.impl.cookie.S;
import weaver.conn.RecordSet;
2 years ago
import weaver.conn.RecordSetTrans;
import weaver.general.BaseBean;
import weaver.general.GCONST;
2 years ago
import weaver.general.StringUtil;
2 years ago
import weaver.general.Util;
2 years ago
import weaver.interfaces.workflow.action.Action;
2 years ago
import weaver.soa.workflow.request.RequestService;
2 years ago
2 years ago
import java.util.HashMap;
2 years ago
import java.util.Map;
2 years ago
public class CWGLSocketExecute extends BaseBean implements SocketExecute {
2 years ago
@Override
public String execute(String param) {
Map<String, String> paramMap = XMLUtils.parseXMLToMap(param);
2 years ago
writeLog("paramMap==="+paramMap);
2 years ago
String oaTrvlBnsExpnsAcctNo = paramMap.get("oaTrvlBnsExpnsAcctNo");
String apprvrNo = paramMap.get("apprvrNo");
2 years ago
String apprvrName = paramMap.get("apprvrName");
2 years ago
String flowStatus = paramMap.get("flowStatus");
String sgntrOpn = paramMap.get("sgntrOpn");
2 years ago
sgntrOpn = apprvrName + "(" + apprvrNo + "):" + sgntrOpn;
2 years ago
Map<String, String> resultMap = null;
int userid = 0;
try {
2 years ago
resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "formtable_main_295");
2 years ago
} catch (Exception e) {
e.printStackTrace();
2 years ago
return XMLUtils.CW2XML(paramMap, "1", e.getMessage());
2 years ago
}
try {
2 years ago
userid = getHrmidByWorkCode(apprvrNo);
2 years ago
} catch (Exception e) {
e.printStackTrace();
}
String id = resultMap.get("id");
int requestid = Util.getIntValue(resultMap.get("requestid"));
2 years ago
writeLog("requestid==="+requestid);
if (requestid == 0) {
2 years ago
return XMLUtils.CW2XML(paramMap, "1", "流程未找到");
}
2 years ago
if (userid == 0) {
2 years ago
return XMLUtils.CW2XML(paramMap, "1", "人员未找到");
}
2 years ago
RequestService requestService = new RequestService();
2 years ago
boolean istrue = false;
2 years ago
if ("0".equals(flowStatus)) {
sgntrOpn = sgntrOpn + "(驳回)";
istrue = requestService.nextNodeByReject(requestid, 1, sgntrOpn);
} else if ("1".equals(flowStatus)) {
sgntrOpn = sgntrOpn + "(记账前退单)";
istrue = requestService.nextNodeByReject(requestid, 1, sgntrOpn);
} else if ("2".equals(flowStatus)) {
sgntrOpn = sgntrOpn + "(记账后退单)";
istrue = requestService.nextNodeByReject(requestid, 1, sgntrOpn);
} else {
istrue = requestService.nextNodeBySubmit(null, requestid, 1, sgntrOpn);
2 years ago
}
2 years ago
writeLog("istrue==="+istrue);
if (istrue) {
try {
updateStatus(requestid, flowStatus);
} catch (Exception e) {
e.printStackTrace();
return XMLUtils.CW2XML(paramMap, "1", e.getMessage());
}
2 years ago
return XMLUtils.CW2XML(paramMap, "0", "");
2 years ago
} else {
return XMLUtils.CW2XML(paramMap, "1", "流程提交失败");
}
}
private void updateStatus(int requestid, String flowStatus) throws Exception {
try {
RecordSet recordSet = new RecordSet();
2 years ago
recordSet.executeUpdate("update formtable_main_295 set cwxtzt = ? where requestId = ?", flowStatus, requestid);
2 years ago
} catch (Exception e) {
throw new Exception("更新状态失败");
2 years ago
}
2 years ago
}
2 years ago
2 years ago
public Map<String, String> getBeanByOAnum(String oaTrvlBnsExpnsAcctNo, String tableName) throws Exception {
2 years ago
RecordSet recordSet = new RecordSet();
HashMap<String, String> resultMap = new HashMap<>();
2 years ago
String sql = "select * from " + tableName + " where djbh = ?";
recordSet.executeQuery(sql, oaTrvlBnsExpnsAcctNo);
if (recordSet.next()) {
2 years ago
resultMap.put("id", Util.null2String(recordSet.getString("id")));
resultMap.put("requestid", Util.null2String(recordSet.getString("requestid")));
return resultMap;
2 years ago
} else {
2 years ago
throw new Exception("编号对应单据不存在");
}
}
public int getHrmidByWorkCode(String workcode) throws Exception {
RecordSet recordSet = new RecordSet();
2 years ago
String sql = "select id from HRMRESOURCE where workcode = ?";
2 years ago
recordSet.executeQuery(sql, workcode);
if (recordSet.next()) {
2 years ago
return Util.getIntValue(recordSet.getString("id"));
2 years ago
} else {
2 years ago
throw new Exception("审批人不存在");
}
}
2 years ago
public static void main(String[] args) {
2 years ago
HashMap<String, String> paramMap = new HashMap<>();
String sgntrOpn = paramMap.get("sgntrOpn");
sgntrOpn = "(" + 1111 + "):" + sgntrOpn;
System.out.println(sgntrOpn);
2 years ago
}
2 years ago
}