xiejun
2024-09-04 ac3f3629a261770f573f27e5e23f7ec19d096c2a
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebProcessCommandServiceImpl.java
@@ -1,11 +1,19 @@
package com.vci.web.service.impl;
import com.vci.client.bof.ClientLinkObject;
import com.vci.corba.common.PLException;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.data.LinkObject;
import com.vci.corba.workflow.data.FlowInstanceInfo;
import com.vci.corba.workflow.data.MapTransfersInfo;
import com.vci.corba.workflow.data.TasksAssignedInfo;
import com.vci.file.dto.VciFileObjectDTO;
import com.vci.dto.ProcessTemplateVO;
import com.vci.dto.VciFileObjectDTO;
import com.vci.omd.utils.ObjectTool;
import com.vci.pagemodel.ProcessNodeVO;
import com.vci.pagemodel.ProcessOutcomeVO;
import com.vci.pagemodel.ProcessTaskVO;
import com.vci.pagemodel.ProcessUserVO;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.enumpck.DataSecretEnum;
import com.vci.starter.web.exception.VciBaseException;
@@ -16,11 +24,10 @@
import com.vci.web.annotation.FlowNotifyAfter;
import com.vci.web.annotation.FlowNotifyBefore;
import com.vci.web.annotation.FlowNotifyWeb;
import com.vci.web.bo.FlowNoticeInfo;
import com.vci.web.constant.WFVariablesKeyConstant;
import com.vci.bo.FlowNoticeInfo;
import com.vci.constant.WFVariablesKeyConstant;
import com.vci.web.dao.WebProcessDaoI;
import com.vci.web.dto.ProcessStartConfigDTO;
import com.vci.web.pageModel.*;
import com.vci.dto.ProcessStartConfigDTO;
import com.vci.web.properties.WebProperties;
import com.vci.web.service.*;
import com.vci.web.util.BusAnnotationUtil;
@@ -92,6 +99,13 @@
        return false;
    }
    /**
     * 启动流程
     * @param config 启动流程相关配置
     * @param processNodeUsers 各个节点的负责人信息
     * @param variablesInfo 相关变量
     * @throws VciBaseException
     */
    @Override
    public void startProcess(ProcessStartConfigDTO config,
                             Map<String, List<ProcessUserVO>> processNodeUsers,
@@ -106,7 +120,6 @@
        if (config.getTitle().length() > 127) {
            config.setTitle(config.getTitle().substring(0, 127));
        }
        //SessionInfo si = WebUtil.getSessionInfo(request);
        //weidy修改获取当前用户的方法
        SessionInfo si = WebUtil.getCurrentUserSessionInfo();
@@ -146,7 +159,7 @@
        Map<String, String> conditionMap = WebUtil.getOidQuery(config.getOids());
        conditionMap.put(WebBoServiceI.QUERY_FILTER_SECRET, "false");
        conditionMap.put(WebBoServiceI.QUERY_FILTER_DATARIGHT, "false");
        List<com.vci.client.bof.ClientBusinessObject> allCbo = boService.queryCBO(config.getBtmType().toLowerCase().trim(), conditionMap);
        List<BusinessObject> allCbo = boService.queryCBO(config.getBtmType().toLowerCase().trim(), conditionMap);
        if (allCbo == null || allCbo.size() == 0) {
            throw new VciBaseException(msgCodePrefix + "dataNotNull", new String[]{});
        }
@@ -154,11 +167,11 @@
        //查询数据是否已经发起了流程
        //查询input连接里是不是有流程实例,并且流程实例不等于终止
        conditionMap.put("oid", " in (select f_oid from platformlt_" + processDao.getTaskDataLink() + " where oid " + conditionMap.get("oid").replace("\\IN", " in ") + ")");
        List<com.vci.client.bof.ClientBusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        List<BusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        if (workInstanceCbos != null && workInstanceCbos.size() > 0) {
            for (com.vci.client.bof.ClientBusinessObject workInstance : workInstanceCbos) {
                if (!workInstance.getLcStatus().equalsIgnoreCase("Obsoleted")) {
                    throw new VciBaseException(msgCodePrefix + "dataSubmitedToProcess", new String[]{workInstance.getName(), workInstance.getCreator()});
            for (BusinessObject workInstance : workInstanceCbos) {
                if (!workInstance.lcStatus.equalsIgnoreCase("Obsoleted")) {
                    throw new VciBaseException(msgCodePrefix + "dataSubmitedToProcess", new String[]{workInstance.name, workInstance.creator});
                }
            }
        }
@@ -167,14 +180,14 @@
        String[][] objectPropertyValues = new String[allCbo.size()][4];
        String[] objIds = new String[allCbo.size()];//业务数据的组件
        for (int i = 0; i < allCbo.size(); i++) {
            com.vci.client.bof.ClientBusinessObject cbo = allCbo.get(i);
            BusinessObject cbo = allCbo.get(i);
            String[] values = new String[4];
            values[0] = cbo.getOid();
            values[1] = cbo.getRevisionid();
            values[2] = cbo.getNameoid();
            values[3] = cbo.getBtmName();
            values[0] = cbo.oid;
            values[1] = cbo.revisionid;
            values[2] = cbo.nameoid;
            values[3] = cbo.btName;
            objectPropertyValues[i] = values;
            objIds[i] = cbo.getOid();
            objIds[i] = cbo.oid;
        }
        FlowInstanceInfo flowInstanceInfo = new FlowInstanceInfo();
@@ -192,7 +205,7 @@
        long currentTime =0L;
        try{
//            currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
            currentTime = platformClientUtil.getFrameworkService().getSystemTime();
        }catch (Throwable e){
           throw  new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[0],e);
        }
@@ -203,50 +216,50 @@
        noticeInfo.setProcessTemplateVO(template);
        BusAnnotationUtil.callForAnnotation(FlowNotifyWeb.class, FlowNotifyBefore.class,noticeInfo);
        String processInstanceId = "";
//        try {
//            if (config.isAutoSubmitFirst()) {
//                processInstanceId =  processDao.getWorkService().startProcessAndExecuteFirstNode(template.getOid(),
//                        flowInstanceInfo,
//                        objIds,
//                        getUserEntityInfo(),
//                        firstNodeUserNames,
//                        "",
//                        allTaskName,
//                        allTaskNameUsers,
//                        allVariables,
//                        objectPropertyKeys,
//                        objectPropertyValues);
//            }else{
//                processInstanceId = processDao.getWorkService().startPocessByPLM_v1(
//                        /**
//                         * String processDefinitionKey, 流程模板主键
//                         * FlowInstanceInfo flowInstanceInfo, 流程实例
//                         * String[] objId, 数据对象id
//                         * UserEntityInfo userEntityInfo, 用户Info
//                         * String[] userName, 用户名
//                         * String outcome, 指向
//                         * String[] tasknames, 业务名称
//                         * String[][] taskUserNames, 所属用户名
//                         * MapTransfersInfo[] mapTransfersInfos,  移交Info
//                         * String[] objectProperty, 业务属性
//                         * String[][] objectPropertyValues 业务属性值
//                         */
//                        template.getOid(),
//                        flowInstanceInfo,
//                        objIds,
//                        getUserEntityInfo(),
//                        firstNodeUserNames,
//                        "",
//                        allTaskName,
//                        allTaskNameUsers,
//                        allVariables,
//                        objectPropertyKeys,
//                        objectPropertyValues
//                );
//            }
//        } catch (VCIError e) {
//            throw WebUtil.getVciBaseException(e);
//        }
        try {
            if (config.isAutoSubmitFirst()) {
                processInstanceId =  processDao.getWorkService().startProcessAndExecuteFirstNode(template.getOid(),
                        flowInstanceInfo,
                        objIds,
                        getUserEntityInfo(),
                        firstNodeUserNames,
                        "",
                        allTaskName,
                        allTaskNameUsers,
                        allVariables,
                        objectPropertyKeys,
                        objectPropertyValues);
            }else{
                processInstanceId = processDao.getWorkService().startPocessByPLMv1(
                        /**
                         * String processDefinitionKey, 流程模板主键
                         * FlowInstanceInfo flowInstanceInfo, 流程实例
                         * String[] objId, 数据对象id
                         * UserEntityInfo userEntityInfo, 用户Info
                         * String[] userName, 用户名
                         * String outcome, 指向
                         * String[] tasknames, 业务名称
                         * String[][] taskUserNames, 所属用户名
                         * MapTransfersInfo[] mapTransfersInfos,  移交Info
                         * String[] objectProperty, 业务属性
                         * String[][] objectPropertyValues 业务属性值
                         */
                        template.getOid(),
                        flowInstanceInfo,
                        objIds,
                        getUserEntityInfo(),
                        firstNodeUserNames,
                        "",
                        allTaskName,
                        allTaskNameUsers,
                        allVariables,
                        objectPropertyKeys,
                        objectPropertyValues
                );
            }
        } catch (PLException e) {
            throw WebUtil.getVciBaseException(e);
        }
        if (StringUtils.isNotBlank(config.getStartStatus())) {
            lifeCycleService.transCboStatus(allCbo, config.getStartStatus());
        }
@@ -260,7 +273,7 @@
    private void callBefore(List<Map> preWorkitemList,String outcome,String note,long currentTime){
        if(currentTime == 0L) {
            try {
//                currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
                currentTime = platformClientUtil.getFrameworkService().getSystemTime();
            } catch (Throwable e) {
                throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[0], e);
            }
@@ -471,15 +484,15 @@
        Map<String, String> conditionMap = new HashMap<String, String>();
        conditionMap.put("f_btwname", processDao.getWorkitemBtmType());
        conditionMap.put("f_oid", QueryOptionConstant.IN + "(" + WebUtil.toInSql(taskIds) + ")");
        List<ClientLinkObject> allLinkData = loService.queryCLO(processDao.getTaskDataLink(), conditionMap);
        List<LinkObject> allLinkData = loService.queryCLO(processDao.getTaskDataLink(), conditionMap);
        String[][] objectPropertyValues = new String[allLinkData.size()][4];
        for (int i = 0; i < allLinkData.size(); i++) {
            ClientLinkObject clo = allLinkData.get(i);
            LinkObject clo = allLinkData.get(i);
            String[] values = new String[4];
            values[0] = clo.getToOid();
            values[1] = clo.getToRevisionOid();
            values[2] = clo.getToNameOid();
            values[3] = clo.getToBTMName();
            values[0] = clo.toOid;
            values[1] = clo.toRevOid;
            values[2] = clo.toNameOid;
            values[3] = clo.toBTName;
            objectPropertyValues[i] = values;
        }
        if ("未命名路由".equalsIgnoreCase(outCome)) {
@@ -488,20 +501,20 @@
        List<Map> workitemList = processDao.getTaskCBOByOid(taskIds);
        long currentTime = 0L;
        try {
//            currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
            currentTime = platformClientUtil.getFrameworkService().getSystemTime();
        } catch (Throwable e) {
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[0], e);
        }
        callBefore(workitemList,outCome,note,currentTime);
//        try {
//            if (jbpmTaskIds.length == 1) {
//                processDao.getWorkService().completeTaskByPlatform_v1(jbpmTaskIds[0], outCome, nextTaskName, note, getUserEntityInfo(), nextTaskUsers, objectPropertyKeys, objectPropertyValues);
//            } else {
//                processDao.getWorkService().completeTasksByPlatform_v1(jbpmTaskIds, outCome, nextTaskName, note, getUserEntityInfo(), nextTaskUsers, objectPropertyKeys, objectPropertyValues);
//            }
//        } catch (VCIError e) {
//            throw WebUtil.getVciBaseException(e);
//        }
        try {
            if (jbpmTaskIds.length == 1) {
                processDao.getWorkService().completeTaskByPlatformv1(jbpmTaskIds[0], outCome, nextTaskName, note, getUserEntityInfo(), nextTaskUsers, objectPropertyKeys, objectPropertyValues);
            } else {
                processDao.getWorkService().completeTasksByPlatformv1(jbpmTaskIds, outCome, nextTaskName, note, getUserEntityInfo(), nextTaskUsers, objectPropertyKeys, objectPropertyValues);
            }
        } catch (PLException e) {
            throw WebUtil.getVciBaseException(e);
        }
        callAfter((String)workitemList.get(0).get("executionid"),null,workitemList,currentTime);
    }
@@ -528,11 +541,11 @@
        String[] taskOidArray = taskOids.split(",");
        for (String taskOid : taskOidArray) {
            if (StringUtils.isNotBlank(taskOid)) {
//                try {
//                    processDao.getWorkService().transmitTask(taskOid, "user:" + userIds, getUserEntityInfo());
//                } catch (VCIError vciError) {
//                    throw WebUtil.getVciBaseException(vciError);
//                }
                try {
                    processDao.getWorkService().transmitTask(taskOid, "user:" + userIds, getUserEntityInfo());
                } catch (PLException vciError) {
                    throw WebUtil.getVciBaseException(vciError);
                }
            }
        }
    }
@@ -564,7 +577,7 @@
        WebUtil.alertNotNull(executionId, "流程执行实例的主键");
        long currentTime = 0L;
        try {
//            currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
            currentTime = platformClientUtil.getFrameworkService().getSystemTime();
        } catch (Throwable e) {
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[0], e);
        }
@@ -592,30 +605,30 @@
        //查询流程实例
        Map<String, String> conditionMap = new HashMap<String, String>();
        conditionMap.put("executionid", executionId.trim() + "*");//会有子流程
        List<com.vci.client.bof.ClientBusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        List<BusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        if (workInstanceCbos == null || workInstanceCbos.size() == 0) {
            throw new VciBaseException(msgCodePrefix + "executionNotExist");
        }
        //判断是否都是执行状态,前端的判断能被跳过
        List<com.vci.client.bof.ClientBusinessObject> needUpdateCbos = new ArrayList<>();
        List<BusinessObject> needUpdateCbos = new ArrayList<>();
        List<String> workInstanceOids = new ArrayList<String>();
        for (com.vci.client.bof.ClientBusinessObject cbo : workInstanceCbos) {
            if (!cbo.getLcStatus().equalsIgnoreCase("Executing")) {
        for (BusinessObject cbo : workInstanceCbos) {
            if (!cbo.lcStatus.equalsIgnoreCase("Executing")) {
                throw new VciBaseException(msgCodePrefix + "processNotExecutionStatus");
            }
            needUpdateCbos.add(cbo);
            workInstanceOids.add(cbo.getAttributeValue("executionid"));
            workInstanceOids.add(ObjectTool.getBOAttributeValue(cbo,"executionid"));
        }
        //找相关的流程任务对象,并且是正在执行中的
        conditionMap.put("executionid", QueryOptionConstant.IN + "(" + WebUtil.toInSql(workInstanceOids.toArray(new String[0])) + ")");
        conditionMap.put("lcstatus", "Executing");
        List<com.vci.client.bof.ClientBusinessObject> workItemCbos = boService.queryCBO(processDao.getWorkitemBtmType(), conditionMap);
        List<BusinessObject> workItemCbos = boService.queryCBO(processDao.getWorkitemBtmType(), conditionMap);
        if (workItemCbos != null && workItemCbos.size() > 0) {
            needUpdateCbos.addAll(workItemCbos);
        }
        long currentTime = 0L;
        try {
//            currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
            currentTime = platformClientUtil.getFrameworkService().getSystemTime();
        } catch (Throwable e) {
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[0], e);
        }
@@ -632,30 +645,30 @@
        //查询流程实例
        Map<String, String> conditionMap = new HashMap<String, String>();
        conditionMap.put("executionid", executionId.trim() + "*");//会有子流程
        List<com.vci.client.bof.ClientBusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        List<BusinessObject> workInstanceCbos = boService.queryCBO(processDao.getWorkIntanceBtmType(), conditionMap);
        if (workInstanceCbos == null || workInstanceCbos.size() == 0) {
            throw new VciBaseException(msgCodePrefix + "executionNotExist");
        }
        //判断是否都是执行状态,前端的判断能被跳过
        List<com.vci.client.bof.ClientBusinessObject> needUpdateCbos = new ArrayList<>();
        List<BusinessObject> needUpdateCbos = new ArrayList<>();
        List<String> workInstanceOids = new ArrayList<String>();
        for (com.vci.client.bof.ClientBusinessObject cbo : workInstanceCbos) {
            if (!cbo.getLcStatus().equalsIgnoreCase("Suspended")) {
        for (BusinessObject cbo : workInstanceCbos) {
            if (!cbo.lcStatus.equalsIgnoreCase("Suspended")) {
                throw new VciBaseException(msgCodePrefix + "processNotSuspendedStatus");
            }
            needUpdateCbos.add(cbo);
            workInstanceOids.add(cbo.getOid());
            workInstanceOids.add(cbo.oid);
        }
        //找相关的流程任务对象,并且是正在执行中的
        conditionMap.put("executionid", QueryOptionConstant.IN + "(" + WebUtil.toInSql(workInstanceOids.toArray(new String[0])) + ")");
        conditionMap.put("lcstatus", "Suspended");
        List<com.vci.client.bof.ClientBusinessObject> workItemCbos = boService.queryCBO(processDao.getWorkitemBtmType(), conditionMap);
        List<BusinessObject> workItemCbos = boService.queryCBO(processDao.getWorkitemBtmType(), conditionMap);
        if (workItemCbos != null && workItemCbos.size() > 0) {
            needUpdateCbos.addAll(workItemCbos);
        }
        long currentTime = 0L;
        try {
//            currentTime = platformClientUtil.getLogonFactoryService().getFrameworkService().getSystemTime();
            currentTime = platformClientUtil.getFrameworkService().getSystemTime();
        } catch (Throwable e) {
            throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[0], e);
        }
@@ -706,7 +719,7 @@
            }
        }
        List<String> causeList = Arrays.asList(new String[]{primaryKeyName});
        List<com.vci.client.bof.ClientBusinessObject> cbos = boService.queryCBO(btmType, conditionMap, null, causeList);
        List<BusinessObject> cbos = boService.queryCBO(btmType, conditionMap, null, causeList);
        if (cbos == null || cbos.size() == 0) {
            throw new VciBaseException("发起流程的业务数据全部不符合要求");
        }
@@ -715,9 +728,9 @@
        for (String oid : oidArray) {
            oidSet.add(oid);
        }
        for (com.vci.client.bof.ClientBusinessObject cbo : cbos) {
            if (oidSet.contains(cbo.getAttributeValue(primaryKeyName))) {
                oidSet.remove(cbo.getAttributeValue(primaryKeyName));
        for (BusinessObject cbo : cbos) {
            if (oidSet.contains(ObjectTool.getBOAttributeValue(cbo,primaryKeyName))) {
                oidSet.remove(ObjectTool.getBOAttributeValue(cbo,primaryKeyName));
            }
        }
        if (oidSet.size() > 0) {