Эх сурвалжийг харах

质量问题审核流程转审修改

wangliang 1 жил өмнө
parent
commit
e9f0b00b34

+ 5 - 5
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -93,7 +93,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
      * @param resourceEntity
      */
     protected void parseXml(String xml, ResourceEntity resourceEntity) {
-        log.info("ENTITY_CREATED,xml:{}", xml);
+//        log.info("ENTITY_CREATED,xml:{}", xml);
         try {
             Document doc = DocumentHelper.parseText(xml);
             Element rootElement = doc.getRootElement();
@@ -106,7 +106,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 Element element = (Element) iterator.next();
                 List<Attribute> attributes = element.attributes();
                 for (Attribute attr : attributes) {
-                    log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
+//                    log.info("属性:{},---值:{}", attr.getName(), attr.getValue());
                     if (Objects.equals(attr.getName(), SystemConstant.ID) &&
                             (Objects.equals(attr.getValue(), TFCustomTypeEnum.OFFICE_SOP_FLOW.name())
                                     || Objects.equals(attr.getValue(), TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW.name())
@@ -122,10 +122,10 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                     FlowTaskResult flowTaskResult = new FlowTaskResult();
                     Element node = (Element) itt.next();
                     attributes = node.attributes();
-                    log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
+//                    log.info("节点:{},---值:{}", node.getName(), node.getStringValue());
                     if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.START_EVENT) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
                         for (Attribute attr : attributes) {
-                            log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
+//                            log.info("节点属性:{},---节点值:{}", attr.getName(), attr.getValue());
                             if (Objects.equals(node.getName(), SystemConstant.USER_TASK) || Objects.equals(node.getName(), SystemConstant.END_EVENT)) {
                                 if (Objects.equals(attr.getName(), SystemConstant.ID)) {
                                     flowTaskResult.setTaskKey(attr.getValue());
@@ -200,7 +200,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 setupMap.put(tmpEntry.getKey(), flowTaskResult);
             }
             FlowResult flowResult = new FlowResult(resourceEntity.getDeploymentId(), resourceEntity.getName(), setupMap);
-            log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
+//            log.info("flowResult:{}", JacksonUtil.parseJson(flowResult));
             TFCustomFlowService tfCustomFlowService = SpringContextHolder.getBean(TFCustomFlowService.class);
             TFCustomFlow tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowResult.getFlowDeploymentId()));
             if (Objects.isNull(tfCustomFlow)) {

+ 12 - 9
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -178,10 +178,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                                            String approveRemark,
                                            Map<String, Object> map) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        approveUserIds = new ArrayList<>();
-        if (approve == FlowApprovePassEnum.START || approve == FlowApprovePassEnum.DRAFT) {//第一步只能是当前用户
-            approveUserIds.add(String.valueOf(sysUser.getId()));//否则是当前登录用户
-        } else if (CollectionUtils.isEmpty(approveUserIds) && approve == FlowApprovePassEnum.PASS) {
+        if (CollectionUtils.isEmpty(approveUserIds) && (approve == FlowApprovePassEnum.START || approve == FlowApprovePassEnum.DRAFT || approve == FlowApprovePassEnum.PASS)) {
+            approveUserIds = new ArrayList<>();
             approveUserIds.add(String.valueOf(sysUser.getId()));//否则是当前登录用户
         }
         String processFlowId = null;
@@ -461,10 +459,10 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Transactional
     public Boolean taskApproverExchange(Long userId, Long taskId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
         if (Objects.equals(String.valueOf(sysUser.getId()), String.valueOf(userId))) {
             throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
         }
+
         boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_EXCHANGE_PREFIX + taskId, taskId, SystemConstant.LOCK_FLOW_TIME_OUT);
         if (!lock) {
             throw ExceptionResultEnum.ERROR.exception("正在转审中,请稍候再试!");
@@ -475,16 +473,16 @@ public class ActivitiServiceImpl implements ActivitiService {
 
             BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
             FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
-            Integer nrOfCompletedInstances = null, nrOfInstances = null;
             boolean multiInstance = false;
             if (currFlow.getBehavior() instanceof MultiInstanceActivityBehavior) {//会签
-                nrOfCompletedInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_COMPLETED_INSTANCES);
-                nrOfInstances = (Integer) taskService.getVariable(task.getId(), SystemConstant.NR_OF_INSTANCES);
                 multiInstance = true;
 
                 List<Task> taskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
                 List<String> taskApproveList = new ArrayList<>();
                 for (Task t : taskList) {
+                    if (Objects.equals(String.valueOf(t.getAssignee()), String.valueOf(userId))) {
+                        throw ExceptionResultEnum.ERROR.exception("不能转给自己!");
+                    }
                     taskApproveList.add(t.getAssignee());
                 }
                 if (taskApproveList.contains(userId)) {
@@ -515,8 +513,13 @@ public class ActivitiServiceImpl implements ActivitiService {
                     Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), String.valueOf(userId));
             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.EXCHANGE);
             SysUser exchangeUser = sysUserService.getById(userId);
+            Optional.ofNullable(exchangeUser).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("转审人为空"));
+
+            SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
             SysOrg exchangeOrg = commonCacheService.orgCache(exchangeUser.getOrgId());
-            tfFlowLog.setApproveRemark(sysUser.getRealName() + "(" + sysOrg.getName() + ")转" + exchangeUser.getRealName() + "(" + exchangeOrg.getName() + ")审批");
+            String orgName = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
+            String exchangeOrgName = Objects.nonNull(exchangeOrg) ? exchangeOrg.getName() : "无机构";
+            tfFlowLog.setApproveRemark(sysUser.getRealName() + "(" + orgName + ")转" + exchangeUser.getRealName() + "(" + exchangeOrgName + ")审批");
             tfFlowLogService.save(tfFlowLog);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);