You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
9.9 KiB
C#
200 lines
9.9 KiB
C#
using BP.DA;
|
|
using BP.Sys;
|
|
using BP.WF;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BP.Demo
|
|
{
|
|
public class DoEvn : BP.Sys.Base.EventBase
|
|
{
|
|
public override void Do()
|
|
{
|
|
switch (this.EventSource)
|
|
{
|
|
//同步创建类表单 WorkArrive
|
|
case EventListNode.SendSuccess://工作到达时
|
|
this.SucessInfo = "执行成功.";
|
|
try
|
|
{
|
|
if (this.NodeID ==2105) {
|
|
updateFrm();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.SucessInfo = "err@对应流程数据未成功同步。";
|
|
BP.DA.Log.DebugWriteError(ex.Message);
|
|
}
|
|
break;
|
|
|
|
//同步创建类表单
|
|
case EventListNode.WorkArrive://工作到达时
|
|
this.SucessInfo = "执行成功.";
|
|
try
|
|
{
|
|
updateFrm();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.SucessInfo = "err@对应流程数据未成功同步。";
|
|
BP.DA.Log.DebugWriteError(ex.Message);
|
|
}
|
|
break;
|
|
}
|
|
|
|
//throw new NotImplementedException();
|
|
}
|
|
public void updateFrm()
|
|
{
|
|
//获取流程信息
|
|
GenerWorkFlow gwf = new GenerWorkFlow(this.WorkID);
|
|
Flow fl = new Flow(gwf.FlowNo);
|
|
Node nd = new Node(gwf.NodeID);
|
|
|
|
//审批流程
|
|
string[] flowAttr = { "002", "021" };
|
|
if (Array.IndexOf(flowAttr, gwf.FlowNo) >= 0)
|
|
{
|
|
try
|
|
{
|
|
string empsHuiqian = "";//获取会签处理人员
|
|
string empsShengHe = "";//获取审核处理人员
|
|
string empsJiaoDui = "";//获取校对处理人员
|
|
string empsPiZhun = "";//获取批准处理人员
|
|
string[] massArr = { "008", "009", "029" };//质量要点流程编号集合
|
|
|
|
//获取主表数据
|
|
string ptable = BP.DA.DBAccess.RunSQLReturnString("select PTable from WF_Flow where No='" + gwf.FlowNo + "'");
|
|
BP.WF.GERpt hisGERpt = new BP.WF.GERpt(ptable);
|
|
GERpt rpt = hisGERpt;
|
|
rpt.OID = gwf.WorkID;
|
|
rpt.RetrieveFromDBSources();
|
|
|
|
string lcbh = rpt.GetValStrByKey("LCBH");//跳转前流程编号
|
|
string bfoid = rpt.GetValStrByKey("BFOID"); //之前OID
|
|
|
|
if (DataType.IsNullOrEmpty(lcbh))
|
|
{
|
|
throw new Exception("err@跳转流程编号为空,请检查");
|
|
}
|
|
|
|
//技术协议与质量要点审批
|
|
if (gwf.FlowNo == "002")
|
|
{
|
|
string zlydbh = rpt.GetValStrByKey("ZLYDBH");//质量要点编号
|
|
string jsbzxybh = rpt.GetValStrByKey("JSBZXYBH"); //技术协议编号
|
|
|
|
|
|
empsHuiqian = BP.DA.DBAccess.RunSQLReturnString("select wm_concat(emptot) from ND2TRACK where workID =" + gwf.WorkID + " AND ndfrom IN('201', '205') AND ACTIONTYPE != 22");
|
|
|
|
empsShengHe = BP.DA.DBAccess.RunSQLReturnString("select wm_concat(emptot) from ND2TRACK where workID =" + gwf.WorkID + " AND ndfrom IN('203') AND ACTIONTYPE != 22");
|
|
|
|
empsJiaoDui = BP.DA.DBAccess.RunSQLReturnString("select EmpName from wf_generworkerlist where WorkID=" + gwf.WorkID + " AND FK_Node IN('206')");
|
|
|
|
empsPiZhun = BP.DA.DBAccess.RunSQLReturnString("select EmpName from wf_generworkerlist where WorkID=" + gwf.WorkID + " AND FK_Node IN('207')");
|
|
|
|
ptable = BP.DA.DBAccess.RunSQLReturnString("select PTable from WF_Flow where No=" + lcbh + "");
|
|
BP.WF.GERpt hisGERpt2 = new BP.WF.GERpt(ptable);
|
|
GERpt rpt2 = hisGERpt2;
|
|
rpt2.OID = gwf.WorkID;
|
|
rpt2.RetrieveFromDBSources();
|
|
string sh = rpt2.GetValStrByKey("SH");//审核
|
|
string xd = rpt2.GetValStrByKey("XD");//校对
|
|
string pz = rpt2.GetValStrByKey("PZ");//批准
|
|
|
|
ptable = BP.DA.DBAccess.RunSQLReturnString("select PTable from WF_Flow where No=" + lcbh + "");
|
|
|
|
//更新主表字段
|
|
if (DataType.IsNullOrEmpty(sh) && DataType.IsNullOrEmpty(xd) && DataType.IsNullOrEmpty(pz))
|
|
{
|
|
if (Array.IndexOf(massArr, lcbh) >= 0)
|
|
{
|
|
string hq = rpt2.GetValStrByKey("HQ");
|
|
BP.DA.DBAccess.RunSQL("update " + ptable + " set SH = '" + empsShengHe + "', XD = '" + empsJiaoDui + "', PZ = '" + empsPiZhun + "',HQ = '" + empsHuiqian + "' WHERE OID=" + bfoid + "");
|
|
}
|
|
else
|
|
{
|
|
BP.DA.DBAccess.RunSQL("update " + ptable + " set SH = '" + empsShengHe + "', XD = '" + empsJiaoDui + "', PZ = '" + empsPiZhun + "' WHERE OID=" + bfoid + "");
|
|
}
|
|
|
|
}
|
|
|
|
//更新对应履历表明细表
|
|
string dtlNo = BP.DA.DBAccess.RunSQLReturnString("SELECT PTable from Sys_MapDtl WHERE FK_MapData = " + ptable + " AND Name LIKE '%履历表%'");
|
|
if (dtlNo == "" || dtlNo == null)
|
|
{
|
|
this.SucessInfo = "err@对应流程" + lcbh + "的履历表未查询到,履历表未同步数据。";
|
|
BP.DA.Log.DebugWriteError(this.SucessInfo);
|
|
}
|
|
int num = BP.DA.DBAccess.RunSQLReturnValInt("select oid from " + dtlNo + " WHERE RefPK = " + bfoid);
|
|
string starter = BP.DA.DBAccess.RunSQLReturnString("select startername from wf_generworkflow where workid =" + bfoid);
|
|
starter = starter + ",";
|
|
if (num == 0)
|
|
{
|
|
BP.DA.DBAccess.RunSQL("INSERT INTO " + dtlNo + " (BZSHR, PZR,) VALUES(" + starter + empsShengHe + ", " + empsPiZhun + "");
|
|
}
|
|
|
|
}
|
|
|
|
//工艺卡审批
|
|
if (gwf.FlowNo == "021")
|
|
{
|
|
|
|
empsShengHe = BP.DA.DBAccess.RunSQLReturnString("SELECT EmptoT FROM ND21TRACK WHERE WorkID=" + gwf.WorkID + " AND ndfrom ='2101'AND ndto = '2102' ");
|
|
|
|
empsJiaoDui = BP.DA.DBAccess.RunSQLReturnString("select wm_concat(emptot) from ND21TRACK where workID =" + gwf.WorkID + " AND ndfrom ='2103' AND ACTIONTYPE != 22");
|
|
|
|
empsPiZhun = BP.DA.DBAccess.RunSQLReturnString("select EmpName from wf_generworkerlist where WorkID=" + gwf.WorkID + " AND FK_Node = '2105'");
|
|
|
|
ptable = BP.DA.DBAccess.RunSQLReturnString("select PTable from WF_Flow where No=" + lcbh + "");
|
|
BP.WF.GERpt hisGERpt2 = new BP.WF.GERpt(ptable);
|
|
GERpt rpt2 = hisGERpt2;
|
|
rpt2.OID = gwf.WorkID;
|
|
rpt2.RetrieveFromDBSources();
|
|
string sh = rpt2.GetValStrByKey("RIVIEWER");//审核
|
|
string xd = rpt2.GetValStrByKey("APPROVER");//校对
|
|
string pz = rpt2.GetValStrByKey("PROOFREADER");//批准
|
|
|
|
string pc_NO = rpt2.GetValStrByKey("RC_NO");//工艺卡编号
|
|
string qp_NO = rpt2.GetValStrByKey("QP_NO");//质量要点编号
|
|
|
|
ptable = BP.DA.DBAccess.RunSQLReturnString("select PTable from WF_Flow where No=" + lcbh + "");
|
|
|
|
if (DataType.IsNullOrEmpty(sh) && DataType.IsNullOrEmpty(xd) && DataType.IsNullOrEmpty(pz))
|
|
{
|
|
BP.DA.DBAccess.RunSQL("update " + ptable + " set RIVIEWER = '" + empsShengHe + "', PROOFREADER = '" + empsJiaoDui + "', APPROVER= '" + empsPiZhun + "' WHERE OID=" + bfoid + "");
|
|
}
|
|
|
|
//更新对应工艺卡履历表明细表
|
|
string dtlNo = BP.DA.DBAccess.RunSQLReturnString("SELECT PTable from Sys_MapDtl WHERE FK_MapData = " + ptable + " AND Name LIKE '%履历表%'");
|
|
if (dtlNo == "" || dtlNo == null)
|
|
{
|
|
this.SucessInfo = "err@对应流程" + lcbh + "的履历表未查询到,履历表未同步数据。";
|
|
BP.DA.Log.DebugWriteError(this.SucessInfo);
|
|
}
|
|
int num = BP.DA.DBAccess.RunSQLReturnValInt("select oid from " + dtlNo + " WHERE RefPK = " + bfoid);
|
|
string starter = BP.DA.DBAccess.RunSQLReturnString("select startername from wf_generworkflow where workid =" + bfoid);
|
|
starter = starter + ",";
|
|
if (num == 0)
|
|
{
|
|
BP.DA.DBAccess.RunSQL("INSERT INTO " + dtlNo + " (RC_NO, QP_NO,) VALUES(" + pc_NO + ", " + qp_NO + "");
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BP.DA.Log.DebugWriteError(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|