| | |
| | | import org.jeecg.modules.dnc.response.*; |
| | | |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.ucenter.Department; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | |
| | | |
| | | import org.jeecg.modules.dnc.request.ProcessStreamRequest; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | |
| | | private INcLogInfoService iNcLogInfoService; |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | @Autowired |
| | | private IProcessionDepartmentService processionDepartmentService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | queryWrapper.orderByAsc(ProcessStream::getCreateTime); |
| | | return super.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddDepart(ProcessStream processStream, Collection<MdcProduction> departmentList) { |
| | | if(processStream == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ProcessionDepartment> processionDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | ProcessionDepartment en = processionDepartmentService.getByProcessIdAndDepartId(processStream.getProcessId(), item.getId()); |
| | | if(en == null) { |
| | | en = new ProcessionDepartment(); |
| | | en.setDepartId(item.getId()); |
| | | en.setProcessId(processStream.getProcessId()); |
| | | processionDepartmentList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByProcessIdAndDepartId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId(),processStream.getProcessId(),item.getId()); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setProductId(processStream.getProductId()); |
| | | stream.setComponentId(processStream.getComponentId()); |
| | | stream.setPartsId(processStream.getPartsId()); |
| | | stream.setProcessId(processStream.getProcessId()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!processionDepartmentList.isEmpty()) { |
| | | boolean b = processionDepartmentService.saveBatch(processionDepartmentList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessStream> getByComponentIdList(String productId, List<String> componentIds, List<String> partsIds) { |
| | | return super.baseMapper.findByPartsAndComponents(productId,componentIds,partsIds); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 分配部门权限 |
| | | * @param processStream |
| | | * @param departmentList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean assignRemoveDepart(ProcessStream processStream, Collection<MdcProduction> departmentList){ |
| | | if(processStream == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ProcessionDepartment> processionDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | ProcessionDepartment en = processionDepartmentService.getByProcessIdAndDepartId(processStream.getProcessId(), item.getId()); |
| | | if(en != null) { |
| | | processionDepartmentList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByProcessIdAndDepartId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId() |
| | | ,processStream.getProcessId(), item.getId()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!processionDepartmentList.isEmpty()) { |
| | | boolean b = processionDepartmentService.removeByCollection(processionDepartmentList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |