| | |
| | | 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> |
| | |
| | | */ |
| | | @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()); |
| | | } |
| | | } |
| | | } |