package BP.WF;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
import javax.xml.crypto.Data;
import org.apache.commons.lang.ObjectUtils.Null;
import org.apache.commons.lang.StringUtils;
import com.sun.star.util.DateTime;
import cn.jflow.common.util.ContextHolderUtils;
import BP.DA.*;
import BP.Port.*;
import BP.Web.*;
import BP.En.*;
import BP.WF.Port.WFEmp;
import BP.WF.Port.WFEmpAttr;
import BP.WF.Port.WFEmps;
import BP.WF.Template.*;
import BP.WF.Data.*;
import BP.WF.Entity.FrmWorkCheck;
import BP.Sys.*;
import BP.Tools.DateUtils;
import BP.Tools.StringHelper;
/**
此接口为程序员二次开发使用,在阅读代码前请注意如下事项.
1, CCFlow的对外的接口都是以静态方法来实现的.
2, 以 DB_ 开头的是需要返回结果集合的接口.
3, 以 Flow_ 是流程接口.
4, 以 Node_ 是节点接口.
5, 以 Port_ 是组织架构接口.
6, 以 DTS_ 是调度. data tranr system.
7, 以 UI_ 是流程的功能窗口
8, 以 WorkOpt_ 用工作处理器相关的接口。
*/
public class Dev2Interface
{
/**
写入消息
用途可以处理提醒.
@param sendToUserNo 发送给的操作员ID
@param sendDT 发送时间,如果null 则表示立刻发送。
@param title 标题
@param doc 内容
@param msgFlag 消息标记
@return 写入成功或者失败.
*/
public static void Port_SendSMS(String tel, String smsDoc, String msgType, String msgGroupFlag, String sender, String msgPK, String sendEmpNo) {
Port_SendSMS(tel, smsDoc, msgType, msgGroupFlag, sender, msgPK, sendEmpNo, null);
}
public static void Port_SendSMS(String tel, String smsDoc, String msgType, String msgGroupFlag, String sender, String msgPK) {
Port_SendSMS(tel, smsDoc, msgType, msgGroupFlag, sender, msgPK, null, null);
}
public static void Port_SendSMS(String tel, String smsDoc, String msgType, String msgGroupFlag, String sender) {
Port_SendSMS(tel, smsDoc, msgType, msgGroupFlag, sender, null, null, null);
}
public static void Port_SendSMS(String tel, String smsDoc, String msgType, String msgGroupFlag) {
Port_SendSMS(tel, smsDoc, msgType, msgGroupFlag, null, null, null, null);
}
public static boolean WriteToSMS(String sendToUserNo, String sendDT, String title, String doc, String msgFlag)
{
SMS.SendMsg(sendToUserNo, title, doc, msgFlag, "Info", "");
return true;
}
/**
待办工作数量
*/
public static int getTodolist_EmpWorks()
{
Paras ps = new Paras();
String dbstr = BP.Sys.SystemConfig.getAppCenterDBVarStr();
String wfSql = " WFState=" + WFState.Askfor.getValue() + " OR WFState=" + WFState.Runing.getValue() + " OR WFState=" + WFState.AskForReplay.getValue() + " OR WFState=" + WFState.Shift.getValue() + " OR WFState=" + WFState.ReturnSta.getValue() + " OR WFState=" + WFState.Fix.getValue();
String sql;
if (WebUser.getIsAuthorize() == false)
{
//不是授权状态
if (BP.WF.Glo.getIsEnableTaskPool() == true)
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp AND TaskSta!=1 ";
}
else
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp ";
}
ps.Add("FK_Emp", BP.Web.WebUser.getNo());
//throw new Exception(ps.SQL);
// BP.DA.Log.DebugWriteInfo(ps.SQL);
return BP.DA.DBAccess.RunSQLReturnValInt(ps);
}
//如果是授权状态, 获取当前委托人的信息.
WFEmp emp = new WFEmp(WebUser.getNo());
switch (emp.getHisAuthorWay())
{
case All:
if (BP.WF.Glo.getIsEnableTaskPool() == true)
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp AND TaskSta!=1 ";
}
else
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp ";
}
ps.Add("FK_Emp", BP.Web.WebUser.getNo());
break;
case SpecFlows:
if (BP.WF.Glo.getIsEnableTaskPool() == true)
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp AND FK_Flow IN " + emp.getAuthorFlows() + " AND TaskSta!=0 ";
}
else
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp AND FK_Flow IN " + emp.getAuthorFlows();
}
ps.Add("FK_Emp", BP.Web.WebUser.getNo());
break;
case None:
//不是授权状态
if (BP.WF.Glo.getIsEnableTaskPool() == true)
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp AND TaskSta!=1 ";
}
else
{
ps.SQL = "SELECT count(WorkID) as Num FROM WF_EmpWorks WHERE (" + wfSql + ") AND FK_Emp=" + dbstr + "FK_Emp ";
}
ps.Add("FK_Emp", BP.Web.WebUser.getNo());
return BP.DA.DBAccess.RunSQLReturnValInt(ps);
default:
throw new RuntimeException("no such way...");
}
return BP.DA.DBAccess.RunSQLReturnValInt(ps);
}
/**
抄送数量
*/
public static int getTodolist_CCWorks()
{
Paras ps = new Paras();
ps.SQL = "SELECT count(MyPK) as Num FROM WF_CCList WHERE CCTo=" + SystemConfig.getAppCenterDBVarStr() + "FK_Emp AND Sta=0";
ps.Add("FK_Emp", BP.Web.WebUser.getNo());
return DBAccess.RunSQLReturnValInt(ps, 0);
}
/**
获取抄送人员的
@param node
@return
*/
/*public static String GetNode_CCList(WorkNode wn)
{
String ccers = null;
if (wn.getHisNode().getHisCCRole() == CCRole.AutoCC || wn.getHisNode().getHisCCRole() == CCRole.HandAndAuto)
{
try
{
//如果是自动抄送
CC cc = wn.getHisNode().getHisCC();
DataTable table = cc.GenerCCers(wn.rptGe);
if (table.Rows.size() > 0)
{
String ccMsg = "@消息自动抄送给";
for (DataRow dr : table.Rows)
{
ccers += dr.getValue(0) + ",";
}
}
}
catch (RuntimeException ex)
{
throw new RuntimeException("@处理操送时出现错误:" + ex.getMessage());
}
}
///#region 执行抄送 BySysCCEmps
if (wn.getHisNode().getHisCCRole() == CCRole.BySysCCEmps)
{
CC cc = wn.getHisNode().getHisCC();
//取出抄送人列表
String temps = wn.rptGe.GetValStrByKey("SysCCEmps");
if (!StringHelper.isNullOrEmpty(temps))
{
String[] cclist = temps.split("[|]", -1);
java.util.Hashtable ht = new java.util.Hashtable();
for (String item : cclist)
{
String[] tmp = item.split("[,]", -1);
ccers += tmp[0] + ",";
}
}
}
return ccers;
}*/
/**
返回挂起流程数量
*/
public static int getTodolist_HungUpNum()
{
String sql = "select COUNT(WorkID) AS Num from WF_GenerWorkFlow where WFState=4 and WorkID in (SELECT distinct WorkID FROM WF_HungUp WHERE Rec='" + BP.Web.WebUser.getNo() + "')";
return BP.DA.DBAccess.RunSQLReturnValInt(sql);
}
/**
在途的工作数量
*/
public static int getTodolist_Runing()
{
String sql;
int state = WFState.Runing.getValue();
if (WebUser.getIsAuthorize())
{
//如果是授权状态.
WFEmp emp = new WFEmp(WebUser.getNo());
sql = "SELECT count( distinct a.WorkID ) as Num FROM WF_GenerWorkFlow A, WF_GenerWorkerlist B WHERE A.WorkID=B.WorkID AND B.FK_Emp='" + WebUser.getNo() + "' AND B.IsEnable=1 AND (B.IsPass=1 OR B.IsPass<0) AND A.FK_Flow IN " + emp.getAuthorFlows();
return BP.DA.DBAccess.RunSQLReturnValInt(sql);
}
else
{
Paras ps = new Paras();
ps.SQL = "SELECT count( distinct a.WorkID ) as Num FROM WF_GenerWorkFlow A, WF_GenerWorkerlist B WHERE A.WorkID=B.WorkID AND B.FK_Emp=" + SystemConfig.getAppCenterDBVarStr() + "FK_Emp AND B.IsEnable=1 AND (B.IsPass=1 OR B.IsPass<0