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.

179 lines
7.6 KiB
Java

2 years ago
package com.engine.tjbankSocket.impl;
2 years ago
import com.cloudstore.dev.api.bean.MessageBean;
import com.cloudstore.dev.api.bean.MessageType;
import com.cloudstore.dev.api.util.Util_Message;
2 years ago
import com.engine.tjbankSocket.SocketExecute;
import com.engine.util.XMLUtils;
2 years ago
import weaver.conn.RecordSet;
2 years ago
import weaver.file.Prop;
2 years ago
import weaver.general.BaseBean;
2 years ago
import weaver.general.StringUtil;
2 years ago
import weaver.general.Util;
import weaver.soa.workflow.request.RequestService;
2 years ago
2 years ago
import java.io.IOException;
2 years ago
import java.util.*;
2 years ago
2 years ago
/**
* @author 13
*/
2 years ago
public class CWGLSocketExecute extends BaseBean implements SocketExecute {
2 years ago
@Override
public String execute(Map<String, String> param) {
Map<String, String> paramMap = param;
2 years ago
writeLog("paramMap==="+paramMap);
2 years ago
String oaTrvlBnsExpnsAcctNo = Util.null2String(paramMap.get("oaTrvlBnsExpnsAcctNo"));
String apprvrNo = Util.null2String(paramMap.get("apprvrNo"));
String apprvrName = Util.null2String(paramMap.get("apprvrName"));
String flowStatus = Util.null2String(paramMap.get("flowStatus"));
String sgntrOpn = Util.null2String(paramMap.get("sgntrOpn"));
2 years ago
sgntrOpn = apprvrName + "(" + apprvrNo + "):" + sgntrOpn;
2 years ago
Map<String, String> resultMap = null;
1 year ago
String tableName = "";
2 years ago
int userid = 0;
try {
1 year ago
if(oaTrvlBnsExpnsAcctNo.startsWith("BTSQD")){
1 year ago
tableName = "formtable_main_295";
1 year ago
// resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "formtable_main_281");
}else if(oaTrvlBnsExpnsAcctNo.startsWith("FHBTSQD")) {
1 year ago
tableName = "formtable_main_398";
1 year ago
// resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, "");
}else {
throw new Exception("未找到编号 '"+oaTrvlBnsExpnsAcctNo+"' 对应的表单");
};
resultMap = getBeanByOAnum(oaTrvlBnsExpnsAcctNo, tableName);
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", "流程未找到");
}
1 year ago
// if (userid == 0) {
// 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 {
1 year ago
updateStatus(requestid, flowStatus,tableName);
1 year ago
String sqr = getsqrbyBH(oaTrvlBnsExpnsAcctNo, tableName);
2 years ago
if("3".equals(flowStatus)){
sendMsgForSuccess(sqr,oaTrvlBnsExpnsAcctNo,requestid);
}
2 years ago
} 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", "流程提交失败");
}
}
2 years ago
private void sendMsgForSuccess(String userid, String oaTrvlBnsExpnsAcctNo, int requestid) {
2 years ago
MessageType messageType = MessageType.newInstance(1674); // 消息来源(见文档第四点补充 必填)
Set<String> userIdList = new HashSet<>(); // 接收人id 必填
String[] useridArr = userid.split(",");
2 years ago
String proplinkUrl = Prop.getPropValue("subsidy_reminder", "linkUrl");
String proplinkMobileUrl = Prop.getPropValue("subsidy_reminder", "linkMobileUrl");
2 years ago
for (String s : useridArr) {
userIdList.add(s);
}
2 years ago
String title = "您有新的差旅补助到账,请您查收"; // 标题
String context = "差补报销("+oaTrvlBnsExpnsAcctNo+")";
String linkUrl = StringUtil.isEmpty(proplinkUrl) ? "" : proplinkUrl+requestid; // PC端链接
String linkMobileUrl = StringUtil.isEmpty(proplinkMobileUrl) ? "" :proplinkMobileUrl+requestid; // 移动端链接
2 years ago
try {
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
messageBean.setCreater(1);// 创建人id
//message.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理
//messageBean.setTargetId("121|22"); //消息来源code +“|”+业务id需要修改消息为已处理等状态时传入
Util_Message.store(messageBean);
} catch (IOException e) {
e.printStackTrace();
}
}
1 year ago
private void updateStatus(int requestid, String flowStatus ,String tableName) throws Exception {
2 years ago
try {
RecordSet recordSet = new RecordSet();
1 year ago
recordSet.executeUpdate("update "+tableName+" 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 = ?";
1 year ago
writeLog("getBeanByOAnumSql"+sql);
2 years ago
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("编号对应单据不存在");
}
}
2 years ago
/**
*
* @param oaTrvlBnsExpnsAcctNo
* @param tableName
* @return
* @throws Exception
*/
public String getsqrbyBH(String oaTrvlBnsExpnsAcctNo, String tableName) throws Exception {
RecordSet recordSet = new RecordSet();
HashMap<String, String> resultMap = new HashMap<>();
String sql = "select jbrxm from " + tableName + " where djbh = ?";
recordSet.executeQuery(sql, oaTrvlBnsExpnsAcctNo);
if (recordSet.next()) {
return Util.null2String(recordSet.getString("jbrxm"));
} else {
throw new Exception("编号对应单据不存在");
}
}
2 years ago
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
2 years ago
}