/*
 *
 * Copyright (c) 2001-2016 泛微软件.
 * 泛微协同商务系统,版权所有.
 *
 */
package weaver.ofs.manager;


import com.alibaba.fastjson.JSONObject;
import com.cloudstore.dev.api.bean.MessageBean;
import com.cloudstore.dev.api.bean.MessageType;
import com.cloudstore.dev.api.util.Util_Message;
import com.engine.msgcenter.biz.ConfigManager;
import com.engine.msgcenter.biz.WeaMessageTypeConfig;
import com.google.common.collect.Sets;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.integration.cache.OfsSettingCache;
import weaver.integration.logging.Logger;
import weaver.integration.logging.LoggerFactory;
import weaver.ofs.bean.*;
import weaver.ofs.dao.OfsTableName;
import weaver.ofs.manager.remind.*;
import weaver.ofs.service.*;
import weaver.ofs.util.OfsUtils;
import weaver.rtx.RTXConfig;
import weaver.security.util.SecurityMethodUtil;
import weaver.systeminfo.SystemEnv;

import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
/**
 *
 * 统一待办数据处理类
 * @version 1.0
 */
public class OfsTodoDataManager {
	/**
	 * 日志打印对象
	 */
	private static Logger log = LoggerFactory.getLogger(OfsTodoDataManager.class);
	/**
	 * 系统管理员ID
	 */
	private static final String SYSADMIN_ID = "1";
	/**
	 * 待办信息处理返回xml结果根元素
	 */
	private static final String RESULT_XML_ROOT = "ResultInfo";
	/**
	 * 缺省数据id
	 */
	private static final int DEFAULT_DATA_ID = 0;//缺省数据id
	/**
	 * 下划线分隔符
	 */
	private static final String LINK_CHAR = "_";
	/**
	 * 统一待办设置业务对象
	 */
	private OfsSettingService ofsSettingService = new OfsSettingService();
	/**
	 * 统一待办数据处理对象
	 */
	private OfsTodoDataService ofsTodoDataService = new OfsTodoDataService();
	/**
	 * 统一待办系统信息对象
	 */
	private OfsSysInfoService ofsSysInfoService = new OfsSysInfoService();
	/**
	 * 统一待办流程对象
	 */
	private OfsWorkflowService ofsWorkflowService = new OfsWorkflowService();
	/**
	 * 统一待办处理日志记录对象
	 */
	private OfsLogService ofsLogService = new OfsLogService();
	/**
	 * 访问Ip
	 */
	private String clientIp;//访问Ip
	/**
	 * 获取访问Ip
	 * @return
	 */
	public String getClientIp() {
		return clientIp;
	}
	/**
	 * 设置访问Ip
	 * @param clientIp
	 */
	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}

	/**
	 * 接收待办流程
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> receiveTodoRequestByMap(Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String createdatetime = OfsUtils.getStringValueByMapKey(dataMap,"createdatetime");
		String creator = OfsUtils.getStringValueByMapKey(dataMap,"creator");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String receivedatetime = OfsUtils.getStringValueByMapKey(dataMap,"receivedatetime");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}

		return receiveTodoRequest(
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				pcurl,
				appurl,
				creator,
				createdatetime,
				receiver,
				receivedatetime,
				receivets);
	}
	/**
	 * 接收待办流程(json格式)
	 * @param json
	 * @return
	 */
	public String receiveTodoRequestByJson(String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = receiveTodoRequestByMap(dataMap);
		String resultJson = OfsUtils.mapToJson(resultMap);

		return resultJson;
	}
	/**
	 * 接收待办流程(xml格式)
	 * @param xml
	 * @return
	 */
	public String receiveTodoRequestByXml(String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = receiveTodoRequestByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}
	/**
	 * 接收待办信息
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param pcurl
	 * @param appurl
	 * @param creator
	 * @param createdatetime
	 * @param receiver
	 * @param receivedatetime
	 * @param receivets
	 * @return
	 */
	public Map<String,String> receiveTodoRequest(
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String pcurl,
			String appurl,
			String creator,
			String createdatetime,
			String receiver,
			String receivedatetime,
			String receivets
	){
		Map<String, String> resultMap = new HashMap<String, String>();

		String isremark = OfsLog.IsRemark_Todo;

		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//校验创建日期时间
		resultMap = validateCreateDateTime(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		//校验flowid不能为空
		resultMap = validateFlowid(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		createdate = createdatetime.substring(0,10);
		createtime = createdatetime.length()>11 ? createdatetime.substring(11):createtime;

		//校验接收日期时间
		resultMap = validateReceiveDateTime(receivedatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		receivedate = receivedatetime.substring(0,10);
		receivetime = receivedatetime.length()>11 ? receivedatetime.substring(11):receivetime;

		Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;
		int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);
		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键

		String returnMessage = "";
		if(OfsTodoData_id == OfsTodoData.Default_TodoDataId){//流程数据不存在
			//新增流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveTodoRequest(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets
			);

			if(!OfsTodoData_insert_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003832,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003833,weaver.general.ThreadVarLanguage.getLang())+"";
			//获取主键
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);

		}else{//流程数据存在
			//更新 流程数据
			boolean OfsTodoData_update_flag = ofsTodoDataService.updateTodoRequest(
					OfsTodoData_id+"",
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets
			);

			if(!OfsTodoData_update_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003834,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoEdit,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003835,weaver.general.ThreadVarLanguage.getLang())+"";
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}

		Map<String, String> msgUrlMap = updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);

		String OfsSysInfo_sysname = buildSysName(OfsSettingMap,OfsSysInfoMap);//系统显示名称

		sendMessage(
				OfsSettingMap,
				OfsSysInfoMap,
				OfsSysInfo_sysname,
				workflowname,
				requestname,
				msgUrlMap.get("pcurl"),
                msgUrlMap.get("appurl"),
				creatorid,
				createdate,
				createtime,
				receiverid,
				receivedate,
				receivetime,
				OfsTodoData_id,
				requestid
		);

		return buildReceiveTodoRequest(
				syscode,
				OfsLog.DataType_WfData,
				OfsLog.OperType_AutoNew,
				OfsLog.OperResult_Success,
				returnMessage
		);
	}

	/**
	 * 保存日志
	 * @param sysid
	 * @param datatype
	 * @param opertype
	 * @param operresult
	 * @param failremark
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param isremark
	 * @param pcurl
	 * @param appurl
	 * @param creator
	 * @param Creatorid
	 * @param createdate
	 * @param createtime
	 * @param receiver
	 * @param userid
	 * @param receivedate
	 * @param receivetime
	 * @return
	 */
	private Map<String, String> saveLog(
			String sysid,
			String datatype,
			String opertype,
			String operresult,
			String failremark,
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String isremark,
			String pcurl,
			String appurl,
			String creator,
			String Creatorid,
			String createdate,
			String createtime,
			String receiver,
			String userid,
			String receivedate,
			String receivetime
	) {
		String data[] = datatype.split("_");
		datatype = data[0];
		String dataid = data[1];

		ofsLogService.insert(
				sysid,
				datatype,
				dataid,
				opertype,
				operresult,
				failremark,
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				isremark,
				pcurl,
				appurl,
				creator,
				Creatorid,
				createdate,
				createtime,
				receiver,
				userid,
				receivedate,
				receivetime
		);
		return buildReceiveTodoRequest(
				syscode,
				datatype,
				opertype,
				operresult,
				failremark
		);
	}
	/**
	 * 构造处理接收待办信息的结果到map中
	 * @param syscode
	 * @param dataType
	 * @param operType
	 * @param operResult
	 * @param message
	 * @return
	 */
	private Map<String, String> buildReceiveTodoRequest(
			String syscode,
			String dataType,
			String operType,
			String operResult,
			String message
	) {
		Map<String, String> map = new HashMap<String,String>();
		map.put("syscode", syscode);
		map.put("dataType", dataType);
		map.put("operType", operType);
		map.put("operResult", operResult);
		map.put("message", message);

		return map;
	}

	/**
	 * 接收异构系统流程(map格式)
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> receiveRequestInfoByMap (Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String isremark = OfsUtils.getStringValueByMapKey(dataMap,"isremark");
		String viewtype = OfsUtils.getStringValueByMapKey(dataMap,"viewtype");
		String createdatetime = OfsUtils.getStringValueByMapKey(dataMap,"createdatetime");
		String creator = OfsUtils.getStringValueByMapKey(dataMap,"creator");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String receivedatetime = OfsUtils.getStringValueByMapKey(dataMap,"receivedatetime");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}
		return receiveRequestInfo(
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				pcurl,
				appurl,
				isremark,
				viewtype,
				creator,
				createdatetime,
				receiver,
				receivedatetime,
				receivets);
	}
	/**
	 * 删除异构系统流程(map格式)
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> deleteRequestInfoByMap (Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");

		return deleteRequestInfo(
				syscode,
				flowid
		);
	}
	/**
	 * 删除异构系统流程(json格式)
	 * @param json
	 * @return
	 */
	public String deleteRequestInfoByJson (String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = deleteRequestInfoByMap(dataMap);
		String resultJson = OfsUtils.mapToJson(resultMap);

		return resultJson;
	}
	/**
	 * 删除异构系统流程(xml格式)
	 * @return
	 */
	public String deleteRequestInfoByXML (String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = deleteRequestInfoByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}
	/**
	 * 删除用户异构系统流程(map格式)
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> deleteUserRequestInfoByMap (Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String userid=OfsUtils.getStringValueByMapKey(dataMap,"userid");

		return deleteUserRequestInfo(
				syscode,
				flowid,
				userid
		);
	}
	/**
	 * 根据用户id删除异构系统流程(json格式)
	 * @param json
	 * @return
	 */
	public String deleteUserRequestInfoByJson (String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = deleteUserRequestInfoByMap(dataMap);
		String resultJson = OfsUtils.mapToJson(resultMap);

		return resultJson;
	}

	/**
	 * 根据用户id删除异构系统流程(xml格式)
	 * @param xml
	 * @return
	 */
	public String deleteUserRequestInfoByXML (String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = deleteUserRequestInfoByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}


	/**
	 * 接收异构系统流程(json格式)
	 * @param json
	 * @return
	 */
	public String receiveRequestInfoByJson (String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = receiveRequestInfoByMap(dataMap);
		return OfsUtils.mapToJson(resultMap);
	}

	/**
	 * 接收异构系统流程(xml格式)
	 * @param xml
	 * @return
	 */
	public String receiveRequestInfoByXml (String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = receiveRequestInfoByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}

	/**
	 * 接收异构系统流程
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param pcurl
	 * @param appurl
	 * @param isremark
	 * @param viewtype
	 * @param creator
	 * @param createdatetime
	 * @param receiver
	 * @param receivedatetime
	 * @param receivets
	 * @return
	 */
	public Map<String, String> receiveRequestInfo(
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String pcurl,
			String appurl,
			String isremark,
			String viewtype,
			String creator,
			String createdatetime,
			String receiver,
			String receivedatetime,
			String receivets
	) {
		Map<String, String> resultMap = new HashMap<String, String>();

		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//校验创建日期时间
		resultMap = validateCreateDateTime(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		//校验flowid不能为空
		resultMap = validateFlowid(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		createdate = createdatetime.substring(0,10);
		createtime = createdatetime.length()>11 ? createdatetime.substring(11):createtime;

		//校验接收日期时间
		resultMap = validateReceiveDateTime(receivedatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		receivedate = receivedatetime.substring(0,10);
		receivetime = receivedatetime.length()>11 ? receivedatetime.substring(11):receivetime;

		Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

		//检测isremark不合法
		resultMap = validateIsRemark(
				syscode, OfsSysInfo_sysid,flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//检查viewtype值是否合法
		resultMap = validateViewType(viewtype,
				syscode, OfsSysInfo_sysid,flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_sysname = buildSysName(OfsSettingMap,OfsSysInfoMap);//系统显示名称
		String isremarkName = buildIsRemarkName(isremark);
		String OfsLog_OperType = "";

		int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);

		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键

		String returnMessage = "";

		if(OfsTodoData_id == 0){//流程数据不存在
			String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;
			//保存流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveRequestInfoInsert(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					isremark,
					viewtype,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets
			);


			if(!(OfsTodoData_insert_flag)){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003836,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(498,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003836,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(25008,weaver.general.ThreadVarLanguage.getLang())+"";
			//获取主键
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);

			OfsLog_OperType = OfsLog.OperType_AutoNew;
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData+ LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}else{
			//数据存在，做更新操作
			String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;

			boolean isNeedUpdate = ofsTodoDataService.isNeedUpdate(OfsTodoData_id,receivets);
			boolean OfsTodoData_update_flag = false;
			if(isNeedUpdate){
				//保存流程数据；
				OfsTodoData_update_flag = ofsTodoDataService.receiveRequestInfoUpdate(
						OfsTodoData_id+"",
						syscode,
						OfsSysInfo_sysid+"",
						requestid+"",
						flowid,
						flowguid,
						requestname,
						workflowname,
						OfsWorkflow_workflowid+"",
						nodename,
						isremark,
						viewtype,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime,
						receivets
				);
			}else{
				//数据库里的时间戳新，无需更新
				OfsTodoData_update_flag = true;
			}

			if(!(OfsTodoData_update_flag)){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(82604,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(498,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(82604,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(25008,weaver.general.ThreadVarLanguage.getLang())+"";
			OfsLog_OperType = OfsLog.OperType_AutoEdit;
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets
			);
		}

		if((isremark.equals(OfsTodoData.IsRemark_Todo) || isremark.equals("8") || isremark.equals("9")) && viewtype.equals(OfsTodoData.ViewType_None)){//待办才发送消息提醒
			Map<String, String> msgUrlMap = updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);
			sendMessage(
					OfsSettingMap,
					OfsSysInfoMap,
					OfsSysInfo_sysname,
					workflowname,
					requestname,
					msgUrlMap.get("pcurl"),
					msgUrlMap.get("appurl"),
					creatorid,
					createdate,
					createtime,
					receiverid,
					receivedate,
					receivetime,
					OfsTodoData_id,
					requestid
			);
		}

		////将所有已办且iscomplete=0变更为iscomplete=1；不处理待办情况
		if(isremark.equals(OfsTodoData.IsRemark_Done)){//已办的处理
			ofsTodoDataService.processOverRequestComplete(syscode,flowid);
		}else if(isremark.equals(OfsTodoData.IsRemark_Over)){//办结的处理
			ofsTodoDataService.processOverRequestComplete(syscode,flowid);
		}

		updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);
		//TODO 设置消息已处理
		if(isremark.equals("2") || isremark.equals("4")){
			Set<String> userids = new HashSet<String>();
			userids.add(receiverid);
			try {
				Util_Message.updateBizState(userids,syscode+"_"+flowid,"1");
			} catch (Exception e) {
				log.error("消息已处理异常——userids："+userids+"，syscode+_+flowid："+syscode+"_"+flowid+", state:1",e);
			}
		}
		return buildReceiveTodoRequest(
				syscode,
				OfsLog.DataType_WfData,
				OfsLog_OperType,
				OfsLog.OperResult_Success,
				returnMessage
		);
	}

	/**
	 * 删除异构系统流程
	 * @param syscode
	 * @param flowid
	 * @return
	 */
	public Map<String, String> deleteRequestInfo(
			String syscode,
			String flowid
	) {
		if(syscode==null||"".equals(syscode)){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,syscode为空"
			);
		}
		if(flowid==null||"".equals(flowid)){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,flowid为空"
			);
		}

		int tododataCnt = ofsTodoDataService.getTodoDataCnt(syscode,flowid);
		if(tododataCnt==0){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,流程数据不存在"
			);
		}else{
			
			//TODO 删除消息
			RecordSet rs1 = new RecordSet();
			rs1.executeQuery("select * from ofs_todo_data where syscode = ? and flowid = ?",syscode,flowid);
			Set<String> userids = new HashSet<String>();
			while(rs1.next()){
				userids.add(rs1.getString("userid"));
			}
			log.error("userids:"+userids);
			try {
				MessageBean messageBean = Util_Message.createMessage();
				messageBean.setUserList(userids);//接收人id
				messageBean.setTargetId(syscode+"_"+flowid);
				Util_Message.delMessageTargetid(messageBean);
			} catch (Exception e) {
				e.printStackTrace();
				log.error("删除消息异常",e);
			}
			
			ofsTodoDataService.receiveRequestInfoDelete(syscode,flowid);

	

			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Success,
					"流程数据删除成功"
			);
		}
	}
	/**
	 * 删除某个用户异构系统流程
	 * @param syscode
	 * @param flowid
	 * @param userid
	 * @return
	 */
	public Map<String, String> deleteUserRequestInfo(
			String syscode,
			String flowid,
			String userid
	) {
		if(syscode==null||"".equals(syscode)){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,syscode为空"
			);
		}
		if(flowid==null||"".equals(flowid)){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,flowid为空"
			);
		}
		if(userid==null||"".equals(userid)){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,userid为空"
			);
		}

		int tododataCnt = ofsTodoDataService.getTodoDataCnt(syscode,flowid,userid);
		if(tododataCnt==0){
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog.OperType_Del,
					OfsLog.OperResult_Failure,
					"流程数据删除失败,流程数据不存在"
			);
		}else{
			
			//TODO 删除消息
			RecordSet rs1 = new RecordSet();
			rs1.executeQuery("select * from ofs_todo_data where syscode = ? and flowid = ? and receiver = ?",syscode,flowid,userid);
			Set<String> userids = new HashSet<String>();
			rs1.next();
			userids.add(rs1.getString("userid"));

			log.error("userids:"+userids);

			try {
				MessageBean messageBean = Util_Message.createMessage();
				messageBean.setUserList(userids);//接收人id
				messageBean.setTargetId(syscode+"_"+flowid);
				Util_Message.delMessageTargetid(messageBean);
			} catch (Exception e) {
				e.printStackTrace();
				log.error("删除消息异常",e);
			}
			
			ofsTodoDataService.receiveRequestInfoUserDelete(syscode, flowid, userid);

			String OfsLog_OperType = OfsLog.OperType_Del;
		
			return buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Success,
					"流程数据删除成功"
			);
		}
	}

	/**
	 * 处理待办流程(变为已办map格式)
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> processDoneRequestByMap(Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}

		return processDoneRequest(
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				receiver,
				pcurl,
				appurl,
				receivets
		);
	}

	/**
	 * 处理待办流程（变为已办json格式）
	 * @param json
	 * @return
	 */
	public String processDoneRequestByJson (String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = processDoneRequestByMap(dataMap);
		return OfsUtils.mapToJson(resultMap);
	}

	/**
	 * 处理待办流程（变为已办xml格式）
	 * @param xml
	 * @return
	 */
	public String processDoneRequestByXml (String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = processDoneRequestByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}
	/**
	 * 处理待办流程（变为已办）
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param receiver
	 * @param pcurl
	 * @param appurl
	 * @param receivets
	 * @return
	 */
	public Map<String,String> processDoneRequest(
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String receiver,
			String pcurl,
			String appurl,
			String receivets
	){
		Map<String,String> resultMap = new HashMap<String, String>();

		String isremark = OfsLog.IsRemark_Done;

		String creator = "";
		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//校验flowid不能为空
		resultMap = validateFlowid("",
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据系统标识获取异构系统信息
		Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;

		int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);

		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键

		String returnMessage = "";

		if(OfsTodoData_id == 0){//异构系统流程数据不存在
			String currentDateString = TimeUtil.getCurrentTimeString();
			String dateStr = currentDateString.substring(0,10);
			String timeStr = currentDateString.substring(11);
			//新增流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveDoneRequest(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					dateStr,
					timeStr,
					receivets
			);

			if(!OfsTodoData_insert_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003837,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						dateStr,
						timeStr
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003838,weaver.general.ThreadVarLanguage.getLang())+"";
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					dateStr,
					timeStr,receivets
			);
		}else{//异构系统流程数据存在
			boolean isNeedUpdate = ofsTodoDataService.isNeedUpdate(OfsTodoData_id,receivets);
			boolean OfsTodoData_update_flag = false;
			//更新待办变为已办
			if(isNeedUpdate){
				OfsTodoData_update_flag = ofsTodoDataService.processDoneRequest(
						syscode,
						flowid,
						receiver,
						workflowname,
						requestname,
						nodename,
						pcurl,
						appurl,
						receivets
				);
			}else{
				OfsTodoData_update_flag = true;
			}

			if(!OfsTodoData_update_flag){//保存失败，记录系统日志：流程数据-自动更新-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003839,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoEdit,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003840,weaver.general.ThreadVarLanguage.getLang())+"";
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}

		//将所有已办且iscomplete=0变更为iscomplete=1；不处理待办情况
		ofsTodoDataService.processOverRequestComplete(syscode,flowid);

		updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);

		//TODO 设置消息已处理
		Set<String> userids = new HashSet<String>();
		userids.add(receiverid);
		try {
			Util_Message.updateBizState(userids,syscode+"_"+flowid,"1");
		} catch (Exception e) {
			log.error("消息已处理异常——userids："+userids+"，syscode+_+flowid："+syscode+"_"+flowid+", state:1",e);
		}
		return buildReceiveTodoRequest(
				syscode,
				OfsLog.DataType_WfData,
				OfsLog.OperType_AutoEdit,
				OfsLog.OperResult_Success,
				returnMessage
		);
	}

	/**
	 * 处理已办流程(变为办结map格式)
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> processOverRequestByMap(Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}

		return processOverRequest(
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				receiver,
				pcurl,
				appurl,
				receivets
		);
	}

	/**
	 * 处理办结流程（变为办结json格式）
	 * @param json
	 * @return
	 */
	public String processOverRequestByJson(String json){
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = processOverRequestByMap(dataMap);
		return OfsUtils.mapToJson(resultMap);
	}
	/**
	 * 处理办结流程(变为办结xml格式)
	 * @param xml
	 * @return
	 */
	public String processOverRequestByXml(String xml){
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = processOverRequestByMap(dataMap);
		return OfsUtils.mapToXml(resultMap,RESULT_XML_ROOT);
	}
	/**
	 * 处理办结流程
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param receiver
	 * @param pcurl
	 * @param appurl
	 * @param receivets
	 * @return
	 */
	public Map<String,String> processOverRequest(
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String receiver,
			String pcurl,
			String appurl,
			String receivets
	){
		Map<String,String> resultMap = new HashMap<String, String>();

		String isremark = OfsLog.IsRemark_Over;

		String creator = "";
		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//校验flowid不能为空
		resultMap = validateFlowid("",
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;

		int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);

		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//获取主键

		String returnMessage = "";

		if(OfsTodoData_id == 0){//异构系统流程数据不存在
			//增加办结记录
			String currentDateString = TimeUtil.getCurrentTimeString();
			String dateStr = currentDateString.substring(0,10);
			String timeStr = currentDateString.substring(11);
			//新增流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveOverRequest(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					dateStr,
					timeStr,
					receivets
			);

			if(!OfsTodoData_insert_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003841,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						dateStr,
						timeStr
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003842,weaver.general.ThreadVarLanguage.getLang())+"";
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					dateStr,
					timeStr,receivets
			);
		}else{
			//更新已办变为办结
			boolean OfsTodoData_update_flag = ofsTodoDataService.processOverRequest(
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					receiver,
					pcurl,
					appurl,
					receivets
			);
			if(!(OfsTodoData_update_flag)){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003843,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003844,weaver.general.ThreadVarLanguage.getLang())+"";
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}

		//将所有已办且iscomplete=0变更为iscomplete=1；不处理待办情况
		ofsTodoDataService.processOverRequestComplete(syscode,flowid);

		updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);
		//TODO 设置消息已处理
		Set<String> userids = new HashSet<String>();
		userids.add(receiverid);
		try {
			Util_Message.updateBizState(userids,syscode+"_"+flowid,"1");
		} catch (Exception e) {
			log.error("消息已处理异常——userids："+userids+"，syscode+_+flowid："+syscode+"_"+flowid+", state:1",e);
		}
		return buildReceiveTodoRequest(
				syscode,
				OfsLog.DataType_WfData,
				OfsLog.OperType_AutoEdit,
				OfsLog.OperResult_Success,
				returnMessage
		);
	}

	/**
	 * ip检测
	 * securityip为空，表示任何地址者可以访问；
	 * securityip不为空，则检查clientIp是否在securityip中指定了；
	 * @param securityip 指定的ip范围
	 * @param clientIp 当前访问ip
	 * @return
	 */
	private boolean checkIp(final String securityip,final String clientIp){
		return !securityip.equals("")?(","+securityip+",").indexOf(","+clientIp+",") > -1 : true;
	}

	/**
	 * 发送RTX消息
	 * @param requestname
	 * @param sysname
	 * @param receiverid
	 * @param remindPcUrl
	 */
	private void sendMessageByRTX(
			String requestname,
			String sysname,
			String receiverid,
			String remindPcUrl
	) {
		new Thread(new OfsRemindRTXManager(Integer.parseInt(receiverid),sysname.equals("")?requestname:"("+sysname+"):"+requestname,remindPcUrl)).start();
	}

	/**
	 * 发送Elink消息
	 * @param requestname
	 * @param workflowname
	 * @param receivedate
	 * @param receivetime
	 * @param id
	 * @param sysname
	 * @param receiverid
	 * @param remindPcUrl
	 */
	private void sendMessageByElink(
			String requestname,
			String workflowname,
			String receivedate,
			String receivetime,
			int id,
			String sysname,
			String receiverid,
			String remindPcUrl) {
		StringBuffer messageJson = new StringBuffer();
		messageJson.append("{");
		messageJson.append("\"id\":\""+id+"\",");
		messageJson.append("\"sysname\":\""+sysname+"\",");
		messageJson.append("\"requestname\":\""+requestname+"\",");
		messageJson.append("\"workflowname\":\""+workflowname+"\",");
		messageJson.append("\"receivedate\":\""+receivedate+"\",");
		messageJson.append("\"receivetime\":\""+receivetime+"\"");
		messageJson.append("}");

		new Thread(new OfsRemindElinkManager(Integer.parseInt(receiverid),messageJson.toString(),remindPcUrl)).start();
	}

	/**
	 * 向其他IM发送消息
	 * @param requestname
	 * @param workflowname
	 * @param sysname
	 * @param creatorid
	 * @param receiverid
	 * @param remindPcUrl
	 */
	private void sendMessageByOther(
			String requestname,
			String workflowname,
			String sysname,
			String creatorid,
			String receiverid,
			String remindPcUrl
	) {
		StringBuffer messageJson = new StringBuffer();
		messageJson.append("{");
		messageJson.append("\"sender\":\""+creatorid+"\",");
		if(sysname.equals("")){
			messageJson.append("\"title\":\""+workflowname+"\",");
		}else{
			messageJson.append("\"title\":\""+sysname+":"+workflowname+"\",");
		}
		messageJson.append("\"content\":\""+requestname+"\"");
		messageJson.append("}");

		new Thread(new OfsRemindOtherManager(Integer.parseInt(receiverid),messageJson.toString(),remindPcUrl)).start();
	}

	/**
	 * 发送APP消息
	 * @param requestname
	 * @param workflowname
	 * @param sysname
	 * @param receiverid
	 * @param remindAppUrl
	 * @param messagetypeid
	 */
	private void sendMessageByApp(
			String requestname,
			String workflowname,
			String sysname,
			String receiverid,
			String remindAppUrl,
			String messagetypeid
	) {
		new Thread(new OfsRemindAppManager(Integer.parseInt(receiverid),requestname,remindAppUrl,messagetypeid)).start();
	}

	/**
	 * 发送OA提醒消息
	 * @param receiverid
	 * @param requestid
	 * @param remindPcUrl
	 */
	private void sendMessageByOA(
			String receiverid,
			int requestid,
			String remindPcUrl
	) {
		new Thread(new OfsRemindOAManager(Integer.parseInt(receiverid),requestid+"",remindPcUrl)).start();
	}

	/**
	 * 发送emessage提醒消息
	 * @param sysname
	 * @param requestname
	 * @param receiverid
	 * @param remindPcUrl
	 * @param creatorid
	 * @param createdate
	 * @param createtime
	 */
	private void sendMessageByEmessage(
			String sysname,
			String requestname,
			String receiverid,
			String remindPcUrl,
			String creatorid,
			String createdate,
			String createtime
	) {
		ResourceComInfo rci = null;
		try {
			rci = new ResourceComInfo();
		} catch (Exception e) {
			e.printStackTrace();
		}
		String lastname = Util.null2String(rci.getLastname(creatorid));
		if (Util.isEnableMultiLang()){// 开启多语言
			lastname = Util.formatMultiLang(lastname , User.getUserLang(Integer.parseInt(receiverid))+"") ;
		}
		String requestdetails = ""+ SystemEnv.getHtmlLabelName(505766,weaver.general.ThreadVarLanguage.getLang())+""+lastname+"<br>"+ SystemEnv.getHtmlLabelName(10003845,weaver.general.ThreadVarLanguage.getLang())+""+createdate+" "+createtime;
		new Thread(new OfsRemindEmessageManager(Integer.parseInt(receiverid),sysname,requestname,requestdetails,remindPcUrl)).start();
	}

	/**
	 * 发送微信提醒消息
	 * @param receiverid
	 * @param requestid
	 * @param requestname
	 * @param remindAppUrl
	 * @param remindebridgetemplate
	 */
	private void sendMessageByEbridge(
			String receiverid,
			String requestid,
			String requestname,
			String remindAppUrl,
			String remindebridgetemplate
	) {
		log.error("sendMessageByEbridge");
		new Thread(new OfsRemindEbridgeManager(Integer.parseInt(receiverid),requestid,requestname,remindAppUrl,remindebridgetemplate)).start();
	}

	/**
	 *
	 */

	private String getEntranceUrl(String entranceurl, int OfsTodoData_id){

		String url = "";
		String param = "tododataid="+OfsTodoData_id;

		if(!"".equals(entranceurl)){
			if(entranceurl.contains("?")){
				url = entranceurl+"&"+param;
			}else{
				url = entranceurl+"?"+param;
			}
		}
		return url;
	}

	/**
	 * 根据syscode和flowid区分出不同的json_arr批量处理数据
	 * #599419
	 * 概述：优化了【统一待办中心集成】批量提交接口的功能
	 * @param json
	 */
	public void batchReceiveRequestInfoByJson(String json){
		JSONArray json_arr = JSONArray.fromObject(json);
		HashMap<String,JSONArray> map=new HashMap<String,JSONArray>();//key:syscode_flowid Value:相同flowid的JsonArray
		if(json_arr!=null&&json_arr.size()>0) {
			for (int i = 0; i < json_arr.size(); i++) {
				map = OfsUtils.putMap(json_arr.getJSONObject(i), map);
			}
			log.info("共有"+map.size()+"条数据");
			for (Map.Entry<String, JSONArray> entry:map.entrySet()) {
				log.info("syscode_flowid: "+entry.getKey()+"共有"+entry.getValue().size()+"条数据");
				dobatchReceiveRequestInfoByJson(entry.getValue());
			}
		}
	}

	/**
	 * 批量处理数据
	 * @param json_arr
	 */
	public void dobatchReceiveRequestInfoByJson(JSONArray json_arr){
		if(json_arr!=null){
			if(json_arr.size()>0){
				Map<String,String> data0Map = OfsUtils.jsonToMap(json_arr.getJSONObject(0).toString());

				String syscode = OfsUtils.getStringValueByMapKey(data0Map,"syscode");
				String flowid = OfsUtils.getStringValueByMapKey(data0Map,"flowid");
				String workflowname = OfsUtils.getStringValueByMapKey(data0Map,"workflowname");

				Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
				Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
				int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

				Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
				int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
				int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);

				if(validateReceiveRequestInfoCommonData(OfsSettingMap,OfsSysInfoMap,OfsWorkflowMap,requestid,data0Map)){
					OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
					//生成批量执行sql
					for(int i=0; i<json_arr.size(); i++){
						Map<String,String> dataMap = OfsUtils.jsonToMap(json_arr.getJSONObject(i).toString());
						getReceiveRequestInfoSql(OfsSettingMap,OfsSysInfoMap,OfsWorkflowMap,requestid,dataMap);	//获取要存储数据库的数据


					}
				}
			}
		}

		batchProcessOverRequstComplet(json_arr);//批量处理办结情况
	}

	private void batchProcessOverRequstComplet(JSONArray json_arr) {
		Map<String,String> dataMap = OfsUtils.jsonToMap(json_arr.getJSONObject(0).toString());
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String isremark = OfsUtils.getStringValueByMapKey(dataMap,"isremark");

		//将所有已办且iscomplete=0变更为iscomplete=1；不处理待办情况
		if(isremark.equals(OfsTodoData.IsRemark_Done)){//已办的处理
			ofsTodoDataService.processOverRequestComplete(syscode,flowid);
		}else if(isremark.equals(OfsTodoData.IsRemark_Over)){//办结的处理
			ofsTodoDataService.processOverRequestComplete(syscode,flowid);
		}
	}

	/**
	 * 批量删除流程
	 * @param json
	 */
	public void batchDeleteUserRequestInfoByJson(String json){
		List<String> list_deleteParm = new ArrayList<String>();
		JSONArray json_arr = JSONArray.fromObject(json);
		if(json_arr!=null){
			for(int i=0; i<json_arr.size(); i++){
				Map<String,String> dataMap = OfsUtils.jsonToMap(json_arr.getJSONObject(i).toString());
				String deldatasql = getDeleteUserRequestInfoSql(dataMap);	//获取要删除数据库的数据
				if(StringUtils.isNotBlank(deldatasql)){

					list_deleteParm.add(deldatasql);
				}
			}
		}

		if(list_deleteParm!=null && list_deleteParm.size()>0){

			StringBuilder sb = new StringBuilder();
			sb.append(" delete from ").append(OfsTableName.Ofs_Todo_Data);
			sb.append(" where syscode=? ");
			sb.append(" and flowid=? ");
			sb.append(" and receiver=? ");

			String sql = sb.toString();

			BatchRecordSet brd = new BatchRecordSet();
			brd.executeSqlBatch(sql, list_deleteParm);
		}
	}


	/**
	 * 批量更新流程
	 * @param dataMap
	 * @return 返回值格式("opt=1","data=XXXX","otherdata=XXXX"),1:新增，2:更新,data为批处理数据，3:对办结流程修改iscomplete=1
	 */
	public Map<String,String> getReceiveRequestInfoSql(Map<String,String> OfsSettingMap,Map<String,String> OfsSysInfoMap,Map<String,String>  OfsWorkflowMap,int requestid,Map<String,String> dataMap){
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String isremark = OfsUtils.getStringValueByMapKey(dataMap,"isremark");
		String viewtype = OfsUtils.getStringValueByMapKey(dataMap,"viewtype");
		String createdatetime = OfsUtils.getStringValueByMapKey(dataMap,"createdatetime");
		String creator = OfsUtils.getStringValueByMapKey(dataMap,"creator");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String receivedatetime = OfsUtils.getStringValueByMapKey(dataMap,"receivedatetime");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}

		Map<String, String> resultMap = new HashMap<String, String>();

		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		createdate = createdatetime.substring(0,10);
		createtime = createdatetime.length()>11 ? createdatetime.substring(11):createtime;

		receivedate = receivedatetime.substring(0,10);
		receivetime = receivedatetime.length()>11 ? receivedatetime.substring(11):receivetime;

		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id
//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id

		String OfsSysInfo_sysname = buildSysName(OfsSettingMap,OfsSysInfoMap);//系统显示名称

		String isremarkName = buildIsRemarkName(isremark);

		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键

		String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;

		String returnMessage ="";

		if(OfsTodoData_id == 0){//流程数据不存在
			//保存流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveRequestInfoInsert(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					isremark,
					viewtype,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets
			);


			if(!(OfsTodoData_insert_flag)){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003836,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(498,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003836,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(25008,weaver.general.ThreadVarLanguage.getLang())+"";
			//获取主键
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData+ LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}else{
			//数据存在，做更新操作
			boolean isNeedUpdate = ofsTodoDataService.isNeedUpdate(OfsTodoData_id,receivets);
			boolean OfsTodoData_update_flag = false;
			if(isNeedUpdate){
				//保存流程数据；
				OfsTodoData_update_flag = ofsTodoDataService.receiveRequestInfoUpdate(
						OfsTodoData_id+"",
						syscode,
						OfsSysInfo_sysid+"",
						requestid+"",
						flowid,
						flowguid,
						requestname,
						workflowname,
						OfsWorkflow_workflowid+"",
						nodename,
						isremark,
						viewtype,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime,
						receivets
				);
			}else{
				//数据库里的时间戳新，无需更新
				OfsTodoData_update_flag = true;
			}

			if(!(OfsTodoData_update_flag)){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(82604,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(498,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(82604,weaver.general.ThreadVarLanguage.getLang())+""+isremarkName+""+ SystemEnv.getHtmlLabelName(25008,weaver.general.ThreadVarLanguage.getLang())+"";
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}



		Map<String, String> msgUrlMap = updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);
		if((isremark.equals(OfsTodoData.IsRemark_Todo) || isremark.equals("8") || isremark.equals("9")) && viewtype.equals(OfsTodoData.ViewType_None)){//待办且未查看才发送消息提醒
			sendMessage(
					OfsSettingMap,
					OfsSysInfoMap,
					OfsSysInfo_sysname,
					workflowname,
					requestname,
					msgUrlMap.get("pcurl"),
                    msgUrlMap.get("appurl"),
					creatorid,
					createdate,
					createtime,
					receiverid,
					receivedate,
					receivetime,
					OfsTodoData_id,
					requestid
			);
		}
		//TODO 设置消息已处理
		if(isremark.equals("2") || isremark.equals("4")){
			Set<String> userids = new HashSet<String>();
			userids.add(receiverid);
			try {
				Util_Message.updateBizState(userids,syscode+"_"+flowid,"1");
			} catch (Exception e) {
				log.error("消息已处理异常——userids："+userids+"，syscode+_+flowid："+syscode+"_"+flowid+", state:1",e);
			}
		}
		return resultMap;
	}

	/**
	 * 批量删除流程
	 * @param dataMap
	 * @return
	 */
	public String getDeleteUserRequestInfoSql(Map<String,String> dataMap){
		String delsql = "";
		char flag = Util.getSeparator();
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String userid=OfsUtils.getStringValueByMapKey(dataMap,"userid");
		if(syscode==null||"".equals(syscode)){
			String OfsLog_OperType = OfsLog.OperType_Del;
			String message = ""+ SystemEnv.getHtmlLabelName(10003846,weaver.general.ThreadVarLanguage.getLang())+",syscode"+ SystemEnv.getHtmlLabelName(385284,weaver.general.ThreadVarLanguage.getLang())+"";
			buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Failure,
					message
			);
			return "";
		}
		if(flowid==null||"".equals(flowid)){
			String OfsLog_OperType = OfsLog.OperType_Del;
			String message = ""+ SystemEnv.getHtmlLabelName(10003846,weaver.general.ThreadVarLanguage.getLang())+",flowid"+ SystemEnv.getHtmlLabelName(385284,weaver.general.ThreadVarLanguage.getLang())+"";
			buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Failure,
					message
			);
			return "";
		}
		if(userid==null||"".equals(userid)){
			String OfsLog_OperType = OfsLog.OperType_Del;
			String message = ""+ SystemEnv.getHtmlLabelName(10003846,weaver.general.ThreadVarLanguage.getLang())+",userid"+ SystemEnv.getHtmlLabelName(385284,weaver.general.ThreadVarLanguage.getLang())+"";
			buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Failure,
					message
			);
			return "";
		}

		int tododataCnt = ofsTodoDataService.getTodoDataCnt(syscode,flowid,userid);
		if(tododataCnt==0){
			String message = ""+ SystemEnv.getHtmlLabelName(10003846,weaver.general.ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(10003847,weaver.general.ThreadVarLanguage.getLang())+"";
			String OfsLog_OperType = OfsLog.OperType_Del;
			buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Failure,
					message
			);
			return "";
		}else{
			StringBuilder sb2 = new StringBuilder();
			sb2.append(syscode).append(flag);
			sb2.append(flowid).append(flag);
			sb2.append(userid);
			delsql = sb2.toString();

			String message = ""+ SystemEnv.getHtmlLabelName(10003848,weaver.general.ThreadVarLanguage.getLang())+"";
			String OfsLog_OperType = OfsLog.OperType_Del;

			buildReceiveTodoRequest(
					syscode,
					OfsLog.DataType_WfData,
					OfsLog_OperType,
					OfsLog.OperResult_Success,
					message
			);
			//TODO 删除消息
			RecordSet rs1 = new RecordSet();
			rs1.executeQuery("select * from ofs_todo_data where syscode = ? and flowid = ? and receiver = ?",syscode,flowid,userid);
			Set<String> userids = new HashSet<String>();
			rs1.next();
			userids.add(rs1.getString("userid"));


			try {
				MessageBean messageBean = Util_Message.createMessage();
				messageBean.setUserList(userids);//接收人id
				messageBean.setTargetId(syscode+"_"+flowid);
				Util_Message.delMessageTargetid(messageBean);
			} catch (Exception e) {
				e.printStackTrace();
				log.error("删除消息异常",e);
			}
			return delsql;
		}
	}

	private boolean checkDateTime(String datetime) {
		return Pattern.compile("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}(:\\d{2})?$").matcher(datetime).matches();
	}

	private Map<String, String> validateFlowid(
			String createdatetime,
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(StringUtils.isBlank(flowid)){//流程id不能为空
			resultMap = saveLog(
					"0",
					OfsLog.DataType_IsUse + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"flowid"+ SystemEnv.getHtmlLabelName(18622,weaver.general.ThreadVarLanguage.getLang())+"",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateReceivets(
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime,String receivets
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		try{
			Long num = Long.parseLong(receivets);
		}catch (Exception e){
			resultMap = saveLog(
					"0",
					OfsLog.DataType_IsUse + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"时间戳不合法，当前时间戳为："+receivets,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}

		return resultMap;
	}

	private Map<String, String> validateCreateDateTime(
			String createdatetime,
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!checkDateTime(createdatetime)){//校验创建日期格式
			resultMap = saveLog(
					"0",
					OfsLog.DataType_IsUse + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"创建日期不合法，合法格式：yyyy-mm-dd hh:MM:ss",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateReceiveDateTime(
			String receivedatetime,
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!checkDateTime(receivedatetime)){//校验接收日期格式
			resultMap = saveLog(
					"0",
					OfsLog.DataType_IsUse + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"接收日期不合法，合法格式：yyyy-mm-dd hh:MM:ss",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsSettingIsuse(
			String OfsSetting_isuse,
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!OfsSetting.IsUse_Yes.equals(OfsSetting_isuse)){//关闭统一待办中心状态
			resultMap = saveLog(
					"0",
					OfsLog.DataType_IsUse + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"统一待办中心未启用",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateSyscode(
			int syscodeCnt,
			String syscode, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(syscodeCnt == 0){//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
			resultMap = saveLog(
					"0",
					OfsLog.DataType_OtherSys + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"异构系统标识【"+syscode+"】未注册",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateReceiver(
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(Util.null2String(receiver).equals("")){//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程数据【"+requestname+"】检测接收人为空",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateReceiverid(
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(Util.null2String(receiverid).equals("0")){//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
			return saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程数据【"+requestname+"】检测接收人不存在",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsSysInfoSecurityIP(
			String securityip, String clientIp,
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!checkIp(securityip,clientIp)){
		    //检测当前IP是否在许可IP范围内
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_OtherSys + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"异构系统标识【"+syscode+"】当前IP（"+this.clientIp+"）未授权",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateWorkflowname(
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(workflowname.equals("")){//记录系统日志：流程类型-检测-失败-流程类型未填写
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfType + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程类型未填写",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateRequestname(
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(requestname.equals("")){//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
			return saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程标题未填写",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsSysInfoReceiveWfData(
			int OfsSysInfo_receivewfdata,
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(OfsSysInfo_receivewfdata == 0){//异构系统不允许接收流程数据
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_OtherSys + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"异构系统标识【"+syscode+"】不允许接收流程数据",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(
			int OfsSysInfo_autocreatewftype, int workflownameCnt,
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(OfsSysInfo_autocreatewftype == 0 && workflownameCnt == 0){//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_OtherSys + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"异构系统标识【"+syscode+"】不允许创建流程类型",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsWorkflowReceiveWfData(
			int OfsWorkflow_receivewfdata,
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(OfsWorkflow_receivewfdata == 0){//流程类型不允许接收流程数据
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfType + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程类型【"+workflowname+"】不允许接收流程数据",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateIsRemark(
			String syscode,int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,String isremark,
			String pcurl, String appurl,
			String creator, String creatorid, String createdate,String createtime,
			String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!isremark.equals(OfsTodoData.IsRemark_Todo) &&
				!isremark.equals(OfsTodoData.IsRemark_Done) &&
				!isremark.equals(OfsTodoData.IsRemark_Over)&&
				!isremark.equals("8")&&
				!isremark.equals("9")){//检测isremark不合法
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程数据【"+requestname+"】检测isremark不合法",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateViewType(String viewtype,
												 String syscode,int OfsSysInfo_sysid, String flowid,
												 String requestname, String workflowname, String nodename,String isremark,
												 String pcurl, String appurl,
												 String creator, String creatorid, String createdate,String createtime,
												 String receiver, String receiverid, String receivedate,String receivetime
	) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(!viewtype.equals(OfsTodoData.ViewType_None) &&
				!viewtype.equals(OfsTodoData.ViewType_Over) ){//检查viewtype值是否合法
			resultMap = saveLog(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
					OfsLog.OperType_Check,
					OfsLog.OperResult_Failure,
					"流程数据【"+requestname+"】检测viewtype不合法",
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime
			);
		}
		return resultMap;
	}

	private Map<String, String> validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
			int OfsSysInfo_autocreatewftype, int workflownameCnt,int OfsSysInfo_receivewfdata,
			String syscode, int OfsSysInfo_sysid, String flowid,
			String requestname, String workflowname, String nodename,
			String isremark, String pcurl, String appurl, String creator,
			String creatorid, String createdate, String createtime,
			String receiver, String receiverid, String receivedate,
			String receivetime) {
		Map<String, String> resultMap = new HashMap<String, String>();
		if(OfsSysInfo_autocreatewftype == 1 && workflownameCnt == 0){//异构系统的【自动创建流程类型】开启  并且  流程类型不存在
			//流程类型不存在
			//相同flowid历史数据中的流程类型是否存在
			List<HashMap<String, String>> historyOfsWfTypeExistList = ofsTodoDataService.getHistoryOfsWfTypeExistList(OfsSysInfo_sysid+"",workflowname,flowid);
			//历史数据中的流程类型不存在
			if(historyOfsWfTypeExistList.size()==0){//不存在，自动新增
				//创建流程类型；
				boolean ofswftypeInsertFlag = ofsWorkflowService.insert(
						OfsSysInfo_sysid+"",workflowname,OfsSysInfo_receivewfdata+"",OfsWorkflow.Cancel_No+"",SYSADMIN_ID);

				if(ofswftypeInsertFlag){//记录系统日志：流程类型-自动创建-成功
					//自动创建流程成功后要重新获取流程类型数据
					Map<String,String> OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
					int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id

					ofsLogService.insert(
							OfsSysInfo_sysid+"",
							OfsLog.DataType_WfType + LINK_CHAR + OfsWorkflow_workflowid,
							OfsLog.OperType_AutoNew,
							OfsLog.OperResult_Success,
							"流程类型【"+workflowname+"】自动创建成功",
							syscode,
							flowid,
							requestname,
							workflowname,
							nodename,
							isremark,
							pcurl,
							appurl,
							creator,
							creatorid,
							createdate,
							createtime,
							receiver,
							receiverid,
							receivedate,
							receivetime,""
					);
				}else{//记录系统日志：流程类型-自动创建-失败-流程类型【XXXX】保存失败
					resultMap = saveLog(
							OfsSysInfo_sysid+"",
							OfsLog.DataType_WfType + LINK_CHAR + DEFAULT_DATA_ID,
							OfsLog.OperType_AutoNew,
							OfsLog.OperResult_Failure,
							"流程类型【"+workflowname+"】自动创建失败",
							syscode,
							flowid,
							requestname,
							workflowname,
							nodename,
							isremark,
							pcurl,
							appurl,
							creator,
							creatorid,
							createdate,
							createtime,
							receiver,
							receiverid,
							receivedate,
							receivetime
					);
				}
			}else{//存在，自动更新
				//更新流程类型；
				boolean ofswftypeUpdateFlag = ofsWorkflowService.updateWorkflowName(OfsSysInfo_sysid+"",workflowname,SYSADMIN_ID,historyOfsWfTypeExistList);

				if(ofswftypeUpdateFlag){//记录系统日志：流程类型-自动创建-成功
					//自动创建流程成功后要重新获取流程类型数据
					Map<String,String> OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
					int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id

					ofsLogService.insert(
							OfsSysInfo_sysid+"",
							OfsLog.DataType_WfType + LINK_CHAR + OfsWorkflow_workflowid,
							OfsLog.OperType_AutoEdit,
							OfsLog.OperResult_Success,
							"流程类型【"+workflowname+"】自动更新成功",
							syscode,
							flowid,
							requestname,
							workflowname,
							nodename,
							isremark,
							pcurl,
							appurl,
							creator,
							creatorid,
							createdate,
							createtime,
							receiver,
							receiverid,
							receivedate,
							receivetime,""
					);
				}else{//记录系统日志：流程类型-自动创建-失败-流程类型【XXXX】保存失败
					resultMap = saveLog(
							OfsSysInfo_sysid+"",
							OfsLog.DataType_WfType + LINK_CHAR + DEFAULT_DATA_ID,
							OfsLog.OperType_AutoEdit,
							OfsLog.OperResult_Failure,
							"流程类型【"+workflowname+"】自动更新失败",
							syscode,
							flowid,
							requestname,
							workflowname,
							nodename,
							isremark,
							pcurl,
							appurl,
							creator,
							creatorid,
							createdate,
							createtime,
							receiver,
							receiverid,
							receivedate,
							receivetime
					);
				}
			}
		}
		return resultMap;
	}

	private String buildPcUrl(Map<String, String> OfsSysInfoMap,int OfsTodoDataId,String pcurl){
		String OfsSysInfo_pcentranceurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"pcentranceurl");//PC单点登录页面
		if(!"".equals(OfsSysInfo_pcentranceurl)){
			return getEntranceUrl(OfsSysInfo_pcentranceurl,OfsTodoDataId);
		}
		return pcurl;
	}

	private String buildAppUrl(Map<String, String> OfsSysInfoMap,int OfsTodoDataId,String appurl){
		String OfsSysInfo_pcentranceurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"appentranceurl");//PC单点登录页面
		if(!"".equals(OfsSysInfo_pcentranceurl)){
			return getEntranceUrl(OfsSysInfo_pcentranceurl,OfsTodoDataId);
		}
		return appurl;
	}

	private Map<String,String> updatePcurlAndAppurl(String pcurl, String appurl,Map<String, String> OfsSysInfoMap, int OfsTodoData_id,String flowid) {
		//单点登录地址
		String pcurlsrc = pcurl;
		pcurl = buildPcUrl(OfsSysInfoMap, OfsTodoData_id, pcurl);

		String appurlsrc = appurl;
		appurl = buildAppUrl(OfsSysInfoMap, OfsTodoData_id, appurl);

		//更新地址
		ofsTodoDataService.updateUrl(OfsTodoData_id,flowid,pcurlsrc,pcurl,appurlsrc,appurl);

		Map<String,String> map = new HashMap<String,String>();
        map.put("pcurl",pcurl);
        map.put("appurl",appurl);

        return map;
	}
	
	private String buildSysName(Map<String, String> OfsSettingMap,Map<String, String> OfsSysInfoMap){
		String OfsSetting_showsysname = OfsUtils.getStringValueByMapKey(OfsSettingMap,"showsysname");//显示异构系统名称
		String OfsSysInfo_sysshortname = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"sysshortname");//异构系统简称
		String OfsSysInfo_sysfullname = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"sysfullname");//异构系统全称

		String OfsSysInfo_sysname = "";
		if(OfsSetting_showsysname.equalsIgnoreCase(OfsSetting.ShowSysName_None)){
			OfsSysInfo_sysname = "";
		}else if(OfsSetting_showsysname.equalsIgnoreCase(OfsSetting.ShowSysName_Short)){
			OfsSysInfo_sysname = OfsSysInfo_sysshortname;
		}else if(OfsSetting_showsysname.equalsIgnoreCase(OfsSetting.ShowSysName_Full)){
			OfsSysInfo_sysname = OfsSysInfo_sysfullname;
		}

		return OfsSysInfo_sysname;
	}

	private void sendMessage(
			Map<String, String> OfsSettingMap,
			Map<String, String> OfsSysInfoMap,
			String sysname,
			String workflowname,
			String requestname,
			String pcurl,
			String appurl,
			String creatorid,
			String createdate,
			String createtime,
			String receiverid,
			String receivedate,
			String receivetime,
			int OfsTodoDataId,
			int requestid
	) {
		String OfsSysInfo_pcprefixurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"pcprefixurl");//PC地址前缀
		String OfsSysInfo_appprefixurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"appprefixurl");//APP地址前缀



		//待办才发送消息提醒
		String remindPcUrl = (OfsSysInfo_pcprefixurl+""+pcurl);
		String remindAppUrl = (OfsSysInfo_appprefixurl+""+appurl);
		
		//TODO 如果有中转页面，推送给消息中心的是中转页面地址
        RecordSet rsrtx = new RecordSet();
        String sqlStr = "select * from SystemSet";
        rsrtx.executeSql(sqlStr);
        rsrtx.next();
        String oaaddress = rsrtx.getString("oaaddress");
        String appentranceurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"appentranceurl");//APP地址前缀
        if(StringUtils.isNotBlank(appentranceurl)){
            remindAppUrl = oaaddress+appurl;
        }

        String pcentranceurl = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"pcentranceurl");//APP地址前缀
        if(StringUtils.isNotBlank(pcentranceurl)){
            remindPcUrl = oaaddress+pcurl;
        }

		if(pcurl.startsWith("http") || pcurl.startsWith("https")){
			remindPcUrl = pcurl;
		}
		if(appurl.startsWith("http") || appurl.startsWith("https")){
			remindAppUrl = appurl;
		}
		log.error("消息通知 app访问地址："+remindAppUrl);
		log.error("消息通知 pc访问地址："+remindPcUrl);
		RTXConfig config = new RTXConfig();
		String RtxOrElinkType = config.getPorp(RTXConfig.RtxOrElinkType);//IM提醒类型
		String isusedtx = config.getPorp("isusedtx");//开启IM集成

		log.error("=======================sendMessage start....====================");

		//todo 用消息中心了
		ConfigManager configManager = new ConfigManager();
		Map<WeaMessageTypeConfig,List<String>> accessConfig=configManager.defaultRuleCheckConfig(MessageType.OTHER_MAILWAIT_REMIND, Util.getIntValue(receiverid),null);
		boolean b = false;
		if (accessConfig != null && accessConfig.size() > 0) {
			b = true;
			for (Map.Entry<WeaMessageTypeConfig,List<String>> entry:accessConfig.entrySet()){
				//TodoCenterTodoMessageSender todoCenterTodoMessageSender = new TodoCenterTodoMessageSender(OfsSettingMap, OfsSysInfoMap, sysname, workflowname, requestname, remindPcUrl, remindAppUrl, creatorid, createdate, createtime, receiverid, receivedate, receivetime, OfsTodoDataId, requestid);
				//new Thread(todoCenterTodoMessageSender).start();
				// 4、构造消息实体
				MessageBean message = null;
				try {
					User user = User.getUser(Util.getIntValue(creatorid),0);
					int langId = 7;
					String userName = "";
					if (user != null) {
						langId = user.getLanguage();
						userName = user.getLastname();
					}
					String detailContent = SystemEnv.getHtmlLabelName(882, langId) + ":" + userName;
					detailContent += "<br />";
					detailContent += SystemEnv.getHtmlLabelName(1339, langId) + ":" + createdate + " " + createtime;

					message = Util_Message.createMessage(MessageType.OTHER_MAILWAIT_REMIND, Util.getIntValue( receiverid,0),  requestname,""+"${}"+sysname+"", detailContent, remindPcUrl, remindAppUrl, Util.getIntValue( creatorid,0));
					message.setBizState("0");
//TODO 获取syscode和flowid作为TargetId
                    RecordSet rs = new RecordSet();
					rs.executeQuery("select * from ofs_todo_data where id = ?" ,OfsTodoDataId);
					rs.next();
                    String syscode = rs.getString("syscode");
                    String flowid = rs.getString("flowid");
					message.setTargetId(syscode+"_"+flowid);
                    Map<String, Object> detailTitleParams = message.getDetailTitleParams();
                    detailTitleParams.put("workflow_name", workflowname);
                    detailTitleParams.put("system_name", sysname);
                } catch (IOException e) {
					e.printStackTrace();
				}


				// 5、获取新的自定义消息类型
				WeaMessageTypeConfig config1 = entry.getKey();

				// 6、新的自定义消息类型相关信息通知到消息实体bean上
				message.setMessageConfig(config1);

				// 7、设置检查配置通过需要发送消息的用户
				message.setUserList(Sets.newHashSet(entry.getValue()));
				String s = JSONObject.toJSONString(message);
				new BaseBean().writeLog("推送消息==="+s);
				new BaseBean().writeLog("推送消息类==="+this.getClass().getName());
				// 8、发送消息
				try {
					Util_Message.sendAndpublishMessage(message);
				} catch (IOException e) {
					e.printStackTrace();
				}

			}
		}

		String OfsParam_remindim = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindim",OfsSetting.RemindIM_No);//提醒到IM
		if(b&&isusedtx.equals("1") && OfsSetting.RemindIM_Yes.equals(OfsParam_remindim)){//开启提醒到IM
			if(RtxOrElinkType.equals("RTX")){//RTX
				sendMessageByRTX(
						requestname,
						sysname,
						receiverid,
						remindPcUrl);
			}else if(RtxOrElinkType.equals("ELINK")){//ELINK
				sendMessageByElink(requestname,
						workflowname,
						receivedate,
						receivetime,
						OfsTodoDataId,
						sysname,
						receiverid,
						remindPcUrl);
			}else {//Other
				sendMessageByOther(
						requestname,
						workflowname,
						sysname,
						creatorid,
						receiverid,
						remindPcUrl);
			}
		}

		String OfsParam_remindapp = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindapp",OfsSetting.RemindApp_No);//提醒到手机版
		if(b&&OfsSetting.RemindApp_Yes.equals(OfsParam_remindapp)){//开启提醒到手机版
			String OfsSetting_messagetypeid = OfsUtils.getStringValueByMapKey(OfsSettingMap,"messagetypeid",OfsSetting.Default_MessageTypeId);//手机提醒通道号
			sendMessageByApp(
					requestname,
					workflowname,
					sysname,
					receiverid,
					remindAppUrl,
					OfsSetting_messagetypeid);
		}

		/*String OfsParam_remindoa = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindoa",OfsSetting.RemindOA_No);//提醒到OA
		if(OfsSetting.RemindOA_Yes.equals(OfsParam_remindoa)){//开启提醒到OA
			sendMessageByOA(
					receiverid,
					requestid,
					remindPcUrl);

		}*/

		String OfsParam_remindemessage = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindemessage",OfsSetting.RemindEmessage_No);//提醒到emessage
		if(b&&OfsSetting.RemindEmessage_Yes.equals(OfsParam_remindemessage)){//开启提醒到emessage
			sendMessageByEmessage(
					sysname,
					requestname,
					receiverid,
					remindPcUrl,
					creatorid,
					createdate,
					createtime);
		}

		String OfsParam_remindebridge = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindebridge",OfsSetting.RemindEbridge_No);//提醒到微信
		if(b&&OfsSetting.RemindEbridge_Yes.equals(OfsParam_remindebridge)){//开启提醒到微信
			String OfsSetting_remindebridgetemplate = OfsUtils.getStringValueByMapKey(OfsSettingMap,"remindebridgetemplate",OfsSetting.Default_RemindEbridgeTemplate);//云桥提醒模板
			sendMessageByEbridge(
					receiverid,
					requestid+"",
					requestname,
					remindAppUrl,
					OfsSetting_remindebridgetemplate);
		}
	}

	private String buildIsRemarkName(String isremark) {
		String isRemarkName = "";
		if(isremark.equals(OfsTodoData.IsRemark_Todo)){
			isRemarkName = ""+ SystemEnv.getHtmlLabelName(16658,weaver.general.ThreadVarLanguage.getLang())+"";
		}else if(isremark.equals(OfsTodoData.IsRemark_Done)){
			isRemarkName = ""+ SystemEnv.getHtmlLabelName(24627,weaver.general.ThreadVarLanguage.getLang())+"";
		}else if(isremark.equals(OfsTodoData.IsRemark_Over)){
			isRemarkName = ""+ SystemEnv.getHtmlLabelName(22487,weaver.general.ThreadVarLanguage.getLang())+"";
		}else if(isremark.equals("8")){
			isRemarkName = ""+ SystemEnv.getHtmlLabelName(10003849,weaver.general.ThreadVarLanguage.getLang())+"";
		}else if(isremark.equals("9")){
			isRemarkName = ""+ SystemEnv.getHtmlLabelName(10003849,weaver.general.ThreadVarLanguage.getLang())+"";
		}
		return isRemarkName;
	}

	private boolean validateReceiveRequestInfoCommonData(Map<String,String> OfsSettingMap,Map<String,String> OfsSysInfoMap,Map<String,String>  OfsWorkflowMap,int requestid,Map<String,String> dataMap){
		Map<String, String> resultMap = new HashMap<String, String>();

		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String isremark = OfsUtils.getStringValueByMapKey(dataMap,"isremark");
		String viewtype = OfsUtils.getStringValueByMapKey(dataMap,"viewtype");
		String createdatetime = OfsUtils.getStringValueByMapKey(dataMap,"createdatetime");
		String creator = OfsUtils.getStringValueByMapKey(dataMap,"creator");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String receivedatetime = OfsUtils.getStringValueByMapKey(dataMap,"receivedatetime");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}

		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";

		//校验创建日期时间
		resultMap = validateCreateDateTime(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}
		//校验flowid不能为空
		resultMap = validateFlowid(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}
		createdate = createdatetime.substring(0,10);
		createtime = createdatetime.length()>11 ? createdatetime.substring(11):createtime;

		//校验接收日期时间
		resultMap = validateReceiveDateTime(receivedatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}
		receivedate = receivedatetime.substring(0,10);
		receivetime = receivedatetime.length()>11 ? receivedatetime.substring(11):receivetime;

		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid",OfsSysInfo.Default_SysId);//异构系统id

		//检测isremark不合法
		resultMap = validateIsRemark(
				syscode, OfsSysInfo_sysid,flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//检查viewtype值是否合法
		resultMap = validateViewType(viewtype,
				syscode, OfsSysInfo_sysid,flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		/*resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}*/

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
       /* resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}*/

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return false;
		}

		return true;
	}

	//TODO 抄送
	/**
	 * 接收抄送流程(json格式)
	 * @param json
	 * @return
	 */
	public String receiveCCRequestByJson(String json) {
		Map<String,String> dataMap = OfsUtils.jsonToMap(json);
		Map<String,String> resultMap = receiveCCRequestByMap(dataMap);
		String resultJson = OfsUtils.mapToJson(resultMap);

		return resultJson;
	}

	/**
	 * 接收抄送流程(xml格式)
	 * @param xml
	 * @return
	 */
	public String receiveCCRequestByXml(String xml) {
		xml = SecurityMethodUtil.clearEntity(xml);
		Map<String,String> dataMap = OfsUtils.xmlToMap(xml);
		Map<String,String> resultMap = receiveCCRequestByMap(dataMap);

		String toXml = OfsUtils.mapToXml(resultMap, RESULT_XML_ROOT);

		return toXml;

	}

	/**
	 * 接收抄送流程
	 * @param dataMap
	 * @return
	 */
	public Map<String,String> receiveCCRequestByMap(Map<String, String> dataMap) {
		String syscode = OfsUtils.getStringValueByMapKey(dataMap,"syscode");
		String viewType = OfsUtils.getStringValueByMapKey(dataMap,"viewType");
		String flowid = OfsUtils.getStringValueByMapKey(dataMap,"flowid");
		String requestname = OfsUtils.getStringValueByMapKey(dataMap,"requestname");
		String workflowname = OfsUtils.getStringValueByMapKey(dataMap,"workflowname");
		String nodename = OfsUtils.getStringValueByMapKey(dataMap,"nodename");
		String pcurl = OfsUtils.getStringValueByMapKey(dataMap,"pcurl");
		String appurl = OfsUtils.getStringValueByMapKey(dataMap,"appurl");
		String createdatetime = OfsUtils.getStringValueByMapKey(dataMap,"createdatetime");
		String creator = OfsUtils.getStringValueByMapKey(dataMap,"creator");
		String receiver = OfsUtils.getStringValueByMapKey(dataMap,"receiver");
		String receivedatetime = OfsUtils.getStringValueByMapKey(dataMap,"receivedatetime");
		String receivets = OfsUtils.getStringValueByMapKey(dataMap,"receivets");	//时间戳字段，客户端使用线程调用接口的时候，根据此字段判断是否需要更新数据，防止后发的请求数据被之前的覆盖
		//对于未传时间戳的数据，用系统当前时间做时间戳
		if("".equals(receivets)){
			receivets = String.valueOf(System.currentTimeMillis());
		}
		Map<String, String> map = receiveCCRequest(
				syscode,
				flowid,
				requestname,
				workflowname,
				nodename,
				pcurl,
				appurl,
				creator,
				createdatetime,
				receiver,
				receivedatetime,
				receivets,viewType);

		return map;
	}

	/**
	 * 接收抄送信息
	 * @param syscode
	 * @param flowid
	 * @param requestname
	 * @param workflowname
	 * @param nodename
	 * @param pcurl
	 * @param appurl
	 * @param creator
	 * @param createdatetime
	 * @param receiver
	 * @param receivedatetime
	 * @param receivets
	 * @return
	 */
	public Map<String,String> receiveCCRequest(
			String syscode,
			String flowid,
			String requestname,
			String workflowname,
			String nodename,
			String pcurl,
			String appurl,
			String creator,
			String createdatetime,
			String receiver,
			String receivedatetime,
			String receivets,
			String viewType
	) {
		Map<String, String> resultMap = new HashMap<String, String>();

		String isremark = "8";

		String creatorid = "0";
		String createdate = "";
		String createtime = "";
		String receiverid = "0";
		String receivedate = "";
		String receivetime = "";
//校验时间戳
		resultMap = validateReceivets(
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime,receivets);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		//校验创建日期时间
		resultMap = validateCreateDateTime(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		//校验flowid不能为空
		resultMap = validateFlowid(createdatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(!resultMap.isEmpty()){
			return resultMap;
		}
		createdate = createdatetime.substring(0,10);
		createtime = createdatetime.length()>11 ? createdatetime.substring(11):createtime;

		//校验接收日期时间
		resultMap = validateReceiveDateTime(receivedatetime,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}
		receivedate = receivedatetime.substring(0,10);
		receivetime = receivedatetime.length()>11 ? receivedatetime.substring(11):receivetime;

		Map<String,String> OfsSettingMap = ofsSettingService.getOneMap();
		String OfsSetting_isuse = OfsUtils.getStringValueByMapKey(OfsSettingMap,"isuse",OfsSetting.IsUse_No);//是否启用统一待办中心状态

		//关闭统一待办中心状态
		resultMap = validateOfsSettingIsuse(OfsSetting_isuse,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		int syscodeCnt = this.ofsSysInfoService.getCnt(syscode);//获取指定异构系统标识的数量

		//记录系统日志：异构系统-检测-失败-异构系统标识【XXXX】未注册
		resultMap = validateSyscode(syscodeCnt,
				syscode, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		Map<String,String> OfsSysInfoMap = ofsSysInfoService.getOneMap(syscode);
		int OfsSysInfo_sysid = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"sysid", OfsSysInfo.Default_SysId);//异构系统id

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人为空
		resultMap = validateReceiver(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		String OfsSysInfo_HrmTransRule = OfsUtils.getStringValueByMapKey(OfsSysInfoMap, "hrmtransrule");//人员转换规则
		creatorid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,creator);
		receiverid = ofsSysInfoService.getHrmResourceIdByHrmTransRule(OfsSysInfo_HrmTransRule,receiver);

		//保存失败，记录系统日志：流程数据-检测-失败-流程数据【"+requestname+"】检测接收人不存在
		resultMap = validateReceiverid(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		String OfsSysInfo_securityip = OfsUtils.getStringValueByMapKey(OfsSysInfoMap,"securityip");//异构许可ip

		//检测当前IP是否在许可IP范围内
		resultMap = validateOfsSysInfoSecurityIP(OfsSysInfo_securityip,this.clientIp,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		//记录系统日志：流程类型-检测-失败-流程类型未填写
		resultMap = validateWorkflowname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		//保存失败，记录系统日志：流程数据-检测-失败-流程标题未填写
		resultMap = validateRequestname(
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		int OfsSysInfo_receivewfdata = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"receivewfdata",OfsSysInfo.ReceiveWfData_No);//异构系统允许接收流程数据

		//异构系统不允许接收流程数据
		resultMap = validateOfsSysInfoReceiveWfData(OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		int OfsSysInfo_autocreatewftype = OfsUtils.getIntValueByMapKey(OfsSysInfoMap,"autocreatewftype",OfsSysInfo.AutoCreateWfType_No);//异构系统自动创建流程类型
		int workflownameCnt = ofsWorkflowService.getCnt(OfsSysInfo_sysid,workflowname);//是否新流程类型：1旧，0新

		//异构系统的【自动创建流程类型】关闭  并且  流程类型不存在
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCnt(OfsSysInfo_autocreatewftype,workflownameCnt,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		//异构系统的【自动创建流程类型】开启  并且  流程类型不存在，自动新增流程类型
		resultMap = validateOfsSysInfoAutoCreateWfTypeAndWorkflownameCntAndAuto(
				OfsSysInfo_autocreatewftype, workflownameCnt,OfsSysInfo_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		//根据异构系统id和流程类型名称获取异构系统流程类型信息
		Map<String,String>  OfsWorkflowMap = ofsWorkflowService.getOneMap(OfsSysInfo_sysid, workflowname);
		int OfsWorkflow_workflowid = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"workflowid",OfsWorkflow.Default_WorkflowId);//获取异构系统流程类型id
		//TODO 创建成功，添加默认选中

		log.error("flowid:"+OfsWorkflow_workflowid);
		int OfsWorkflow_receivewfdata = OfsUtils.getIntValueByMapKey(OfsWorkflowMap,"receivewfdata",OfsWorkflow.ReceiveWfData_No);//接收流程数据

		//流程类型不允许接收流程数据
		resultMap = validateOfsWorkflowReceiveWfData(OfsWorkflow_receivewfdata,
				syscode,OfsSysInfo_sysid, flowid, requestname, workflowname,nodename,isremark, pcurl, appurl,
				creator, creatorid, createdate, createtime,
				receiver,receiverid, receivedate,receivetime);
		if(resultMap.size()>1){
			return resultMap;
		}

		String flowguid = syscode + LINK_CHAR + OfsWorkflow_workflowid + LINK_CHAR + flowid + LINK_CHAR + receiver;
		int requestid = ofsTodoDataService.buildRequestid(OfsSysInfo_sysid,OfsWorkflow_workflowid,flowid);
		int OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);//主键

		String returnMessage = "";
		if(OfsTodoData_id == OfsTodoData.Default_TodoDataId){//流程数据不存在
			//新增流程数据；
			boolean OfsTodoData_insert_flag = ofsTodoDataService.receiveCCRequest(
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets,
					viewType
			);

			if(!OfsTodoData_insert_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003850,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoNew,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003851,weaver.general.ThreadVarLanguage.getLang())+"";
			//获取主键
			OfsTodoData_id = ofsTodoDataService.getTodoDataId(syscode,flowid,receiver);
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoNew,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);

		}else{//流程数据存在
			//更新 流程数据
			boolean OfsTodoData_update_flag = ofsTodoDataService.updateCCRequest(
					OfsTodoData_id+"",
					syscode,
					OfsSysInfo_sysid+"",
					requestid+"",
					flowid,
					flowguid,
					requestname,
					workflowname,
					OfsWorkflow_workflowid+"",
					nodename,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,
					receivets,
					viewType
			);

			if(!OfsTodoData_update_flag){//保存失败，记录系统日志：流程数据-自动创建-失败-流程数据【XXXX】保存失败
				returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003852,weaver.general.ThreadVarLanguage.getLang())+"";
				return saveLog(
						OfsSysInfo_sysid+"",
						OfsLog.DataType_WfData + LINK_CHAR + DEFAULT_DATA_ID,
						OfsLog.OperType_AutoEdit,
						OfsLog.OperResult_Failure,
						returnMessage,
						syscode,
						flowid,
						requestname,
						workflowname,
						nodename,
						isremark,
						pcurl,
						appurl,
						creator,
						creatorid,
						createdate,
						createtime,
						receiver,
						receiverid,
						receivedate,
						receivetime
				);
			}
			returnMessage = ""+ SystemEnv.getHtmlLabelName(10003831,weaver.general.ThreadVarLanguage.getLang())+""+requestname+"】"+ SystemEnv.getHtmlLabelName(10003853,weaver.general.ThreadVarLanguage.getLang())+"";
			ofsLogService.insert(
					OfsSysInfo_sysid+"",
					OfsLog.DataType_WfData + LINK_CHAR + OfsTodoData_id,
					OfsLog.OperType_AutoEdit,
					OfsLog.OperResult_Success,
					returnMessage,
					syscode,
					flowid,
					requestname,
					workflowname,
					nodename,
					isremark,
					pcurl,
					appurl,
					creator,
					creatorid,
					createdate,
					createtime,
					receiver,
					receiverid,
					receivedate,
					receivetime,receivets
			);
		}

		Map<String, String> msgUrlMap = updatePcurlAndAppurl(pcurl, appurl, OfsSysInfoMap, OfsTodoData_id, flowid);

		String OfsSysInfo_sysname = buildSysName(OfsSettingMap,OfsSysInfoMap);//系统显示名称

		sendMessage(
				OfsSettingMap,
				OfsSysInfoMap,
				OfsSysInfo_sysname,
				workflowname,
				requestname,
				msgUrlMap.get("pcurl"),
				msgUrlMap.get("appurl"),
				creatorid,
				createdate,
				createtime,
				receiverid,
				receivedate,
				receivetime,
				OfsTodoData_id,
				requestid
		);
		Map<String, String> stringStringMap = buildReceiveTodoRequest(
				syscode,
				OfsLog.DataType_WfData,
				OfsLog.OperType_AutoNew,
				OfsLog.OperResult_Success,
				returnMessage
		);

		return stringStringMap;
	}
}
