From 74472c9d22dddcb41383794caf0011043b20f817 Mon Sep 17 00:00:00 2001 From: kimi <kimi42345@gmail.com> Date: 星期二, 31 三月 2020 13:25:47 +0800 Subject: [PATCH] fix 数据权限 --- src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 89 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java b/src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java index fa14220..87fb86e 100644 --- a/src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java +++ b/src/main/java/com/highdatas/mdm/service/impl/FlowsServiceImpl.java @@ -1,10 +1,23 @@ package com.highdatas.mdm.service.impl; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.highdatas.mdm.entity.Flows; +import com.highdatas.mdm.entity.MaintainField; +import com.highdatas.mdm.entity.TUserRole; import com.highdatas.mdm.mapper.FlowsMapper; -import com.highdatas.mdm.service.IFlowsService; +import com.highdatas.mdm.mapper.SysFieldMapper; +import com.highdatas.mdm.pojo.ActivitiBusinessType; +import com.highdatas.mdm.pojo.ActivitiStatus; +import com.highdatas.mdm.pojo.NextTaskUserInfo; +import com.highdatas.mdm.service.*; import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.highdatas.mdm.service.act.TaskService; +import com.highdatas.mdm.util.DbUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.List; /** * <p> @@ -16,5 +29,80 @@ */ @Service public class FlowsServiceImpl extends ServiceImpl<FlowsMapper, Flows> implements IFlowsService { + @Autowired + IMaintainFieldService maintainFieldService; + @Autowired + TaskService taskService; + @Autowired + SysFieldMapper fieldMapper; + @Autowired + ITUserRoleService userRoleService; + @Autowired + IMasterModifiedService masterModifiedService; + @Autowired + IMaintainService maintainService; + @Override + public MaintainField createNowVerion(String tableName, String maintainId, String userId) { + MaintainField nowMaintain = maintainFieldService.getNextMaintain(tableName, userId); + // 鎼繍鏂扮増鏈瓧娈� + String maintainParams; + if (StringUtils.isEmpty(maintainId)) { + maintainParams = "maintain_field_id is null and table_name = " + DbUtils.quotedStr(tableName); + }else { + maintainParams = "maintain_field_id = " + DbUtils.quotedStr(maintainId); + } + + if (nowMaintain != null) { + String maintainFieldId = DbUtils.quotedStr(nowMaintain.getId()); + fieldMapper.tansNewVersion(maintainFieldId, maintainParams); + } + + return nowMaintain; + } + + @Override + public ActivitiStatus getStatusByBusinessId(String businessId) { + Flows flows = selectOne(new EntityWrapper<Flows>().eq("business_id", businessId)); + if (flows == null){ + return null; + } + return flows.getStatus(); + } + + @Override + public boolean isNextAudit(Flows flows, String userId) { + NextTaskUserInfo nestTaskAssignee = taskService.getNestTaskAssignee(flows.getWorkflowId()); + if (nestTaskAssignee == null){ + return false; + } + String taskAssigneeUserId = nestTaskAssignee.getUserId(); + if (!StringUtils.isEmpty(taskAssigneeUserId)){ + return taskAssigneeUserId.equalsIgnoreCase(userId); + } + String roleId = nestTaskAssignee.getRoleId(); + if (StringUtils.isEmpty(roleId)) { + return false; + } + List<TUserRole> userRoles = userRoleService.selectList(new EntityWrapper<TUserRole>().eq("role_id", roleId)); + long count = userRoles.stream().map(tUserRole -> tUserRole.getUserId()).filter(s -> s.equalsIgnoreCase(userId)).count(); + if (count == 0) { + return false; + }else { + return true; + } + } + + @Override + public void aduitFinish(Flows flows) { + if (flows.getBusinessType().equals(ActivitiBusinessType.maintain)){ + String maintainId = flows.getBusinessId(); + masterModifiedService.dealFlow(maintainId, flows.getStatus()); + maintainService.dealFlow(maintainId, flows.getStatus()); + } + if (flows.getBusinessType().equals(ActivitiBusinessType.field)){ + String maintainId = flows.getBusinessId(); + maintainFieldService.dealFlow(maintainId, flows.getStatus()); + } + } } -- Gitblit v1.8.0