package org.jeecg.modules.dnc.service.impl;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.apache.shiro.SecurityUtils;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
|
import org.jeecg.modules.dnc.entity.*;
|
import org.jeecg.modules.dnc.exception.ExceptionCast;
|
import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
|
import org.jeecg.modules.dnc.mapper.PartsInfoMapper;
|
import org.jeecg.modules.dnc.mapper.ProcessSpecVersionMapper;
|
import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
|
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
|
import org.jeecg.modules.dnc.request.TreeInfoRequest;
|
import org.jeecg.modules.dnc.response.*;
|
import org.jeecg.modules.dnc.service.*;
|
import org.jeecg.modules.dnc.utils.ValidateUtil;
|
import org.jeecg.modules.system.entity.MdcProduction;
|
import org.jeecg.modules.system.entity.SysUser;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Lazy;
|
import org.springframework.stereotype.Service;
|
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
@Service
|
public class ProcessSpecVersionServiceImpl extends ServiceImpl<ProcessSpecVersionMapper, ProcessSpecVersion> implements IProcessSpecVersionService{
|
@Autowired
|
private ProductInfoMapper productInfoMapper;
|
@Autowired
|
private ComponentInfoMapper componentInfoMapper;
|
@Autowired
|
private PartsInfoMapper partsInfoMapper;
|
@Autowired
|
private IPermissionStreamNewService permissionStreamNewService;
|
@Autowired
|
@Lazy
|
private IProcessStreamService processStreamService;
|
@Autowired
|
private IProcessSpecVersionPermissionService processSpecVersionPermissionService;
|
@Autowired
|
private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService;
|
@Autowired
|
private IProductMixService productMixService;
|
@Autowired
|
private IWorkStepService workStepService;
|
@Autowired
|
private IProductPermissionService productPermissionService;
|
@Autowired
|
@Lazy
|
private IDocInfoService docInfoService;
|
/**
|
* 根据用户id获取授权的工艺规程版本表信息
|
* @param userId
|
* @return
|
*/
|
@Override
|
public List<ProcessSpecVersion> getByUserPerms(String userId){
|
if(!ValidateUtil.validateString(userId))
|
return Collections.emptyList();
|
return super.getBaseMapper().getByUserPerms(userId);
|
}
|
|
/**
|
* 根据用户id获取授权的工艺规程版本表信息
|
* @param userId
|
* @param queryParam 查询条件
|
* @return
|
*/
|
@Override
|
public List<ProcessSpecVersion> getByUserPerms(String userId,String queryParam){
|
if(!ValidateUtil.validateString(userId))
|
return Collections.emptyList();
|
if(!ValidateUtil.validateString(queryParam))
|
return Collections.emptyList();
|
LambdaQueryWrapper<ProcessSpecVersion> queryWrapper = Wrappers.lambdaQuery();
|
if(ValidateUtil.validateString(queryParam)) {
|
queryWrapper.and(wrapper->wrapper.like(ProcessSpecVersion::getProcessSpecVersionName, queryParam)
|
.or()
|
.like(ProcessSpecVersion::getProcessSpecVersionName, queryParam));
|
}
|
queryWrapper.orderByAsc(ProcessSpecVersion::getCreateTime);
|
return super.list(queryWrapper);
|
}
|
|
/**
|
* 新增工艺规程版本表信息
|
* @param processSpecVersion
|
* @return
|
*/
|
@Override
|
public boolean addProcessSpecVersion(ProcessSpecVersion processSpecVersion){
|
if(processSpecVersion == null)
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionName()))
|
ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE);
|
if(!ValidateUtil.validateString(processSpecVersion.getProductId()))
|
ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
|
if(!ValidateUtil.validateString(processSpecVersion.getComponentId()))
|
ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
|
if(!ValidateUtil.validateString(processSpecVersion.getPartsId()))
|
ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE);
|
if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionCode()))
|
ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE);
|
ProcessSpecVersion en = getByCode(processSpecVersion.getPartsId(),processSpecVersion.getProcessSpecVersionCode());
|
if(en != null)
|
ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
|
ProductInfo productInfo = productInfoMapper.selectById(processSpecVersion.getProductId());
|
if(productInfo == null)
|
ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
|
ComponentInfo componentInfo = componentInfoMapper.selectById(processSpecVersion.getComponentId());
|
if(componentInfo == null)
|
ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
|
PartsInfo partsInfo = partsInfoMapper.selectById(processSpecVersion.getPartsId());
|
if(partsInfo == null)
|
ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
|
//相同零件号下面版本号不能重复
|
List<ProcessSpecVersion> list = super.list(new LambdaQueryWrapper<ProcessSpecVersion>().eq(ProcessSpecVersion::getPartsId,partsInfo.getPartsId()));
|
if (list != null && list.size() > 0) {
|
list.forEach(processSpecVersion1 -> {
|
if (processSpecVersion1.getProcessSpecVersionCode().equals(processSpecVersion.getProcessSpecVersionCode())) {
|
ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
|
}
|
});
|
}
|
boolean b = super.save(processSpecVersion);
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
//添加部门权限
|
List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(processSpecVersion.getPartsId(), DocAttributionTypeEnum.PARTS.getCode().toString(),"1");
|
if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
|
List<ProcessSpecVersionDepartment> processSpecVersionDepartmentList = new ArrayList<>();
|
List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
|
oldDepartPermList.forEach(item -> {
|
ProcessSpecVersionDepartment pd = new ProcessSpecVersionDepartment();
|
pd.setDepartId(item.getDepartId());
|
pd.setPsvId(processSpecVersion.getId());
|
processSpecVersionDepartmentList.add(pd);
|
PermissionStreamNew perm = new PermissionStreamNew();
|
perm.setDepartId(item.getDepartId());
|
perm.setBusinessId(processSpecVersion.getId());
|
perm.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
|
permissionStreamList.add(perm);
|
});
|
if(!processSpecVersionDepartmentList.isEmpty()) {
|
b = processSpecVersionDepartmentService.saveBatch(processSpecVersionDepartmentList);
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
}
|
if(!permissionStreamList.isEmpty()) {
|
b = permissionStreamNewService.saveBatch(permissionStreamList);
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
}
|
}
|
//添加用户权限
|
b = productPermissionService.add(processSpecVersion.getId(), userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
|
if (!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
|
}
|
//添加结构树
|
ProductMix productMix = new ProductMix(Long.parseLong(processSpecVersion.getId()),Long.parseLong(processSpecVersion.getPartsId())
|
,processSpecVersion.getProcessSpecVersionName(),
|
processSpecVersion.getProcessSpecVersionCode(),DocAttributionTypeEnum.OPERATION.getCode(),new Date());
|
productMixService.save(productMix);
|
//添加用户权限
|
PermissionStreamNew stream = new PermissionStreamNew();
|
stream.setBusinessId(processSpecVersion.getId());
|
stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
|
stream.setUserId(userId);
|
return permissionStreamNewService.addPermissionStreamNew(stream);
|
}
|
|
/**
|
* 编辑工艺规程版本表信息
|
* @param id
|
* @param processSpecVersion
|
* @return
|
*/
|
@Override
|
public boolean editProcessSpecVersion(String id ,ProcessSpecVersion processSpecVersion){
|
if(!ValidateUtil.validateString(id) || processSpecVersion == null)
|
ExceptionCast.cast(CommonCode.SUCCESS);
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
|
ProcessSpecVersion en = super.getById(id);
|
if(en == null)
|
ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
|
processSpecVersion.setId(id);
|
processSpecVersion.setProductId(null);
|
processSpecVersion.setComponentId(null);
|
processSpecVersion.setPartsId(null);
|
boolean b = super.updateById(processSpecVersion);
|
//同步修改结构树
|
ProductMix productMix = productMixService.getById(Long.parseLong(id));
|
productMix.setTreeName(processSpecVersion.getProcessSpecVersionName());
|
productMix.setTreeCode(processSpecVersion.getProcessSpecVersionCode());
|
productMixService.updateById(productMix);
|
if(!b)
|
return false;
|
ProcessSpecVersionPermission permission = processSpecVersionPermissionService.getByPsvIdAndUserId(id, userId);
|
if(permission == null) {
|
permission = new ProcessSpecVersionPermission(id,userId);
|
b = processSpecVersionPermissionService.save(permission);
|
if(!b)
|
return false;
|
}
|
PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
|
if(stream == null) {
|
stream = new PermissionStreamNew();
|
stream.setBusinessId(id);
|
stream.setUserId(userId);
|
return permissionStreamNewService.save(stream);
|
}
|
return b;
|
}
|
|
/**
|
* 删除工艺规程版本表信息
|
* @param id
|
* @return
|
*/
|
@Override
|
public boolean deleteProcessSpecVersion(String id){
|
if(!ValidateUtil.validateString(id))
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
ProcessSpecVersion processSpecVersion = super.getById(id);
|
if(processSpecVersion == null)
|
ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
|
List<ProcessStream> processStreams = processStreamService.findBypsvId(id);
|
if(processStreams!= null &&!processStreams.isEmpty())
|
ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_PROCESS_EXIST);
|
boolean b = processSpecVersionPermissionService.deleteByPsvId(processSpecVersion.getId());
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
b = processSpecVersionDepartmentService.deleteByPsvId(processSpecVersion.getId());
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"0");
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"1");
|
if(!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
b = productMixService.removeById(processSpecVersion.getId());
|
if (!b)
|
ExceptionCast.cast(CommonCode.FAIL);
|
return super.removeById(processSpecVersion.getId());
|
}
|
|
@Override
|
public ProcessSpecVersion getByCode(String partId,String processSpecVersionCode) {
|
if(ValidateUtil.validateString(processSpecVersionCode)) {
|
List<ProcessSpecVersion> list = super.lambdaQuery()
|
.eq(ProcessSpecVersion::getPartsId, partId)
|
.eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list();
|
if(list == null || list.isEmpty())
|
return null;
|
return list.get(0);
|
}
|
return null;
|
}
|
|
@Override
|
public List<ProcessSpecVersion> getByPartsId(String partsId) {
|
if(ValidateUtil.validateString(partsId)) {
|
List<ProcessSpecVersion> list = super.lambdaQuery().eq(ProcessSpecVersion::getPartsId, partsId).list();
|
if(list == null || list.isEmpty())
|
return null;
|
return list;
|
}
|
return null;
|
}
|
|
/**
|
* 根据一组零件id获取
|
* @param partsIds
|
* @return
|
*/
|
@Override
|
public List<ProcessSpecVersion> getByPartsIds(List<String> partsIds){
|
if(partsIds == null || partsIds.isEmpty())
|
return Collections.emptyList();
|
List<ProcessSpecVersion> list = super.lambdaQuery().in(ProcessSpecVersion::getPartsId, partsIds).list();
|
if(list == null || list.isEmpty())
|
return null;
|
else
|
return list;
|
}
|
|
|
/**
|
* 分配用户权限
|
* @param processSpecVersion
|
* @param userList
|
* @return
|
*/
|
@Override
|
public boolean assignAddUser(ProcessSpecVersion processSpecVersion, Collection<SysUser> userList){
|
if(processSpecVersion == null || userList == null || userList.isEmpty())
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
List<ProcessSpecVersionPermission> permissionList = new ArrayList<>();
|
List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
|
userList.forEach(item -> {
|
ProcessSpecVersionPermission en = processSpecVersionPermissionService.getByPsvIdAndUserId(processSpecVersion.getId(), item.getId());
|
if(en == null) {
|
en = new ProcessSpecVersionPermission();
|
en.setUserId(item.getId());
|
en.setPsvId(processSpecVersion.getId());
|
permissionList.add(en);
|
}
|
PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
|
if(stream == null) {
|
stream = new PermissionStreamNew();
|
stream.setUserId(item.getId());
|
stream.setBusinessId(processSpecVersion.getId());
|
stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
|
permissionStreamList.add(stream);
|
}
|
});
|
if(!permissionList.isEmpty()) {
|
boolean b = processSpecVersionPermissionService.saveBatch(permissionList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
if(!permissionStreamList.isEmpty()) {
|
boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
return true;
|
}
|
|
|
/**
|
* 移除用户权限
|
* @param processSpecVersion
|
* @param userList
|
* @return
|
*/
|
@Override
|
public boolean assignRemoveUser(ProcessSpecVersion processSpecVersion, Collection<SysUser> userList){
|
if(processSpecVersion == null || userList == null || userList.isEmpty())
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
List<ProcessSpecVersionPermission> permissionList = new ArrayList<>();
|
List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
|
userList.forEach(item -> {
|
ProcessSpecVersionPermission en = processSpecVersionPermissionService.getByPsvIdAndUserId(processSpecVersion.getId(), item.getId());
|
if(en != null) {
|
permissionList.add(en);
|
}
|
PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
|
if(stream != null) {
|
permissionStreamList.add(stream);
|
}
|
});
|
//清空用户权限校验
|
if(!permissionList.isEmpty()) {
|
boolean b = processSpecVersionPermissionService.removeByCollection(permissionList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
if(!permissionStreamList.isEmpty()) {
|
boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
return true;
|
}
|
/**
|
* 分配部门权限
|
* @param processSpecVersion
|
* @param departmentList
|
* @return
|
*/
|
@Override
|
public boolean assignAddDepart(ProcessSpecVersion processSpecVersion, Collection<MdcProduction> departmentList){
|
if(processSpecVersion == null || departmentList == null || departmentList.isEmpty())
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
List<ProcessSpecVersionDepartment> partsDepartments = new ArrayList<>();
|
List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
|
departmentList.forEach(item -> {
|
ProcessSpecVersionDepartment en = processSpecVersionDepartmentService.getByProcessSpecVersionIdAndDepartId(processSpecVersion.getId(), item.getId());
|
if(en == null) {
|
en = new ProcessSpecVersionDepartment();
|
en.setDepartId(item.getId());
|
en.setPsvId(processSpecVersion.getId());
|
partsDepartments.add(en);
|
}
|
PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
|
if(stream == null) {
|
stream = new PermissionStreamNew();
|
stream.setDepartId(item.getId());
|
stream.setBusinessId(processSpecVersion.getId());
|
stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
|
permissionStreamList.add(stream);
|
}
|
});
|
if(!partsDepartments.isEmpty()) {
|
boolean b = processSpecVersionDepartmentService.saveBatch(partsDepartments);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
if(!permissionStreamList.isEmpty()) {
|
boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
return true;
|
}
|
|
/**
|
* 分配部门权限
|
* @param processSpecVersion
|
* @param departmentList
|
* @return
|
*/
|
@Override
|
public boolean assignRemoveDepart(ProcessSpecVersion processSpecVersion, Collection<MdcProduction> departmentList){
|
if(processSpecVersion == null || departmentList == null || departmentList.isEmpty())
|
ExceptionCast.cast(CommonCode.INVALID_PARAM);
|
List<ProcessSpecVersionDepartment> partsDepartments = new ArrayList<>();
|
List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
|
departmentList.forEach(item -> {
|
ProcessSpecVersionDepartment en = processSpecVersionDepartmentService.getByProcessSpecVersionIdAndDepartId(processSpecVersion.getId(), item.getId());
|
if(en != null) {
|
partsDepartments.add(en);
|
}
|
PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),"3");
|
if(stream != null) {
|
permissionStreamList.add(stream);
|
}
|
});
|
if(!partsDepartments.isEmpty()) {
|
boolean b = processSpecVersionDepartmentService.removeByCollection(partsDepartments);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
if(!permissionStreamList.isEmpty()) {
|
boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
|
if(!b) {
|
ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
|
}
|
}
|
return true;
|
}
|
|
/**
|
* 根据工艺规程id查询,下级工序工步数量
|
* @param processSpecId
|
* @return
|
*/
|
@Override
|
public Result<?> getProcessSpecVersionCount(String processSpecId){
|
List<ProcessStream> list = processStreamService.findBypsvId(processSpecId);
|
List<WorkStep> workStepList=workStepService.list(new LambdaQueryWrapper<WorkStep>().eq(WorkStep::getPsvId,processSpecId));
|
return null;
|
}
|
|
/**
|
* 通过零件号、材质等查询对应电子样板
|
* @param treeInfoRequest
|
* @return
|
*/
|
@Override
|
public List<DocInfo> getByProcessSpecVersion(TreeInfoRequest treeInfoRequest){
|
LambdaQueryWrapper<ProcessSpecVersion> queryWrapper = new LambdaQueryWrapper<>();
|
if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
|
queryWrapper.in(ProcessSpecVersion::getProductId, treeInfoRequest.getProductIds());
|
}
|
if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
|
queryWrapper.in(ProcessSpecVersion::getComponentId, treeInfoRequest.getComponentIds());
|
}
|
if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
|
queryWrapper.in(ProcessSpecVersion::getPartsId, treeInfoRequest.getPartsIds());
|
}
|
if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
|
queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ProcessSpecVersion::getId,treeInfoRequest.getAttributionId());
|
}
|
queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ProcessSpecVersion::getProcessSpecVersionName, treeInfoRequest.getTreeName());
|
queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName());
|
queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime);
|
List<ProcessSpecVersion> list = super.list(queryWrapper);
|
List<DocInfo> docInfos;
|
if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){
|
return new ArrayList<>();
|
}else {
|
String ids=list.stream().map(ProcessSpecVersion::getId).collect(Collectors.joining(","));
|
DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
|
BeanUtil.copyProperties(treeInfoRequest,docQuery);
|
docQuery.setAttributionIds(ids);
|
docQuery.setDocClassCode("OTHER");
|
docQuery.setAttributionType(DocAttributionTypeEnum.OPERATION.getCode());
|
docInfos=docInfoService.findListByDocQuery(docQuery);
|
if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
|
List<String> id =new ArrayList<>();
|
id.add(treeInfoRequest.getAttributionId());
|
treeInfoRequest.setPsvIds(id);
|
//工序
|
List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest);
|
docInfos.addAll(processStreams);
|
//工步
|
List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest);
|
docInfos.addAll(workSteps);
|
}
|
}
|
return docInfos;
|
}
|
|
@Override
|
public boolean assignPermission(Object entity, Collection<SysUser> userList, boolean isAdd){
|
if (isAdd) {
|
return assignAddUser((ProcessSpecVersion) entity, userList);
|
} else {
|
return assignRemoveUser((ProcessSpecVersion) entity, userList);
|
}
|
}
|
@Override
|
public boolean assignDepartPermission(Object entity, Collection<MdcProduction> departments, boolean isAdd) {
|
if (isAdd) {
|
return assignAddDepart((ProcessSpecVersion) entity, departments);
|
} else {
|
return assignRemoveDepart((ProcessSpecVersion) entity, departments);
|
}
|
}
|
}
|