You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

115 lines
4.3 KiB

<?php
class CounterSignTaskHandler
{
private $currentNode;
private $flowContext;
private $formData;
const DEFAULT_MERGE_OPTION = "AND";
function __construct($node, FlowContext $Context, $formData)
{
$this->currentNode = $node;
$this->flowContext = $Context;
$this->formData = $formData;
}
/**
* 1.从流程图中解析出下个节点的Code 更新
*/
function doWork()
{
//1.获取表单数据中的split_members 为字符串 成员1,成员2,
$currentNode = $this->flowContext->getCurrentNode();
$assignClass = $currentNode->getAssignClass();
$currentAssigner = $this->flowContext->getCurrentUser();
$currentFormKey = $this->flowContext->getFormKey();
$this->flowContext->getCurrentNode()
->setFlow($this->flowContext);
$this->flowContext->getCurrentNode()
->setformData($this->formData);
if (!$currentNode->checkTrust($assignClass, Employee::lead_code($currentAssigner))) {
$handler = new FlowNodeHandler($this->currentNode, $this->flowContext, $this->formData);
$handler->doWork();
/// Subflow::updateCurrentUser($currentFormKey, $this->flowContext->nextAssigner);
return;
}
$splitMembers = explode(',', $this->formData['split_members']);
//2.遍历$splitMembers数组 ,对其调用,AssignerStringParser::process(),获取具体的签核人员
$nextAssigners = array();
$sm = new SubflowManager(new Flow($currentFormKey));
var_dump($splitMembers);
foreach ($splitMembers as $member) {
var_dump($member);
$nextAssigners = explode(
',',
AssignerStringParser::process($member, $format = "employee_no", ",")
);
#生成待签
$seq = 0;
foreach ($nextAssigners as $assigner) {
if (empty($assigner)) continue;
$flowCode = $this->currentNode->getFLowCode();
$childFlow = new Flow();
$childFlow->setSystemId($this->flowContext->getSystemId())
->setFormId($this->flowContext->getFormId())
->setFlowId($this->flowContext->getFlowId())
->setFlowCode($flowCode)
->insert();
$subflow = new Subflow($childFlow);
$subflow->setCurrentUser($assigner)->insert();
$sm->append($subflow, $currentAssigner);
#生成任务1
$task = new NodeTask();
$task->setFormKey($childFlow->getFormKey())
->setFlowCode($flowCode)
->setState("OPEN")
->setTaskType("COUNTER_SIGN_SUBTASK")
->setNecessary('Y')
->setPhase("SUBMIT")
->setCreator($currentAssigner);
TaskManager::insertTask($task);
#生成任务1结束
#生成任务2
$task = new NodeTask();
$task->setFormKey($childFlow->getFormKey())
->setFlowCode($flowCode)
->setState("OPEN")
->setTaskType("NEXT_ASSIGNER_MODIFY_TASK")
->setNecessary('Y')
->setWfCondition("NEXT")
->setJoinRole("select code_name assign_status,
case code_name when 'F1' then '00000-回传申请单位'
when 'Y1' then '00000-回传申请单位' end assigner_string from code
where code_name in('Y1','F1') and field_name='assign_status'")
->setRoleType("SQL")
->setPhase("LOAD")
->setCreator($currentAssigner);
TaskManager::insertTask($task);
#生成任务2结束 $_SERVER['HTTP_HOST']
}
}
$nextAssigner = $this->flowContext->nextAssigner;
#变更流程下位签核者
Subflow::updateCurrentUser($currentFormKey, $nextAssigner);
#挂起该流程
Subflow::suspend($currentFormKey);
}
private function processAssignStatusFH()
{
}
private function processAssignStatusX3()
{
}
}