| | |
| | | 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.conditions.query.QueryWrapper; |
| | | 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.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | |
| | | 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.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class ProcessSpecVersionServiceImpl extends ServiceImpl<ProcessSpecVersionMapper, ProcessSpecVersion> implements IProcessSpecVersionService{ |
| | |
| | | @Autowired |
| | | private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService; |
| | | @Autowired |
| | | private IProductMixService productMixService; |
| | | @Autowired |
| | | private IWorkStepService workStepService; |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | @Autowired |
| | | @Lazy |
| | | private IDocInfoService docInfoService; |
| | | /** |
| | | * 根据用户id获取授权的工艺规程版本表信息 |
| | | * @param userId |
| | |
| | | if(ProcessSpecVersion == null) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionName())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NAME_NONE); |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProductId())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getComponentId())) |
| | |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionCode())) |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE); |
| | | ProcessSpecVersion en = getByCode(ProcessSpecVersion.getProcessSpecVersionCode()); |
| | | ProcessSpecVersion en = getByCode(ProcessSpecVersion.getPartsId(),ProcessSpecVersion.getProcessSpecVersionCode()); |
| | | if(en != null) |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加结构树 |
| | | ProductMix productMix = new ProductMix(Long.parseLong(ProcessSpecVersion.getId()),Long.parseLong(ProcessSpecVersion.getPartsId()) |
| | | ,ProcessSpecVersion.getProcessSpecVersionName(), |
| | | ProcessSpecVersion.getProcessSpecVersionCode(),4,new Date()); |
| | | productMixService.save(productMix); |
| | | //添加用户权限 |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(ProcessSpecVersion.getId()); |
| | | stream.setBusinessType("4"); |
| | | stream.setUserId(userId); |
| | | return permissionStreamNewService.save(stream); |
| | | return permissionStreamNewService.addPermissionStreamNew(stream); |
| | | } |
| | | |
| | | /** |
| | |
| | | processSpecVersion.setComponentId(null); |
| | | processSpecVersion.setPartsId(null); |
| | | boolean b = super.updateById(processSpecVersion); |
| | | //同步修改结构树 |
| | | ProductMix productMix = productMixService.getById(Long.parseLong(id)); |
| | | productMix.setName(processSpecVersion.getProcessSpecVersionName()); |
| | | productMix.setCode(processSpecVersion.getProcessSpecVersionCode()); |
| | | productMixService.updateById(productMix); |
| | | if(!b) |
| | | return false; |
| | | ProcessSpecVersionPermission permission = processSpecVersionPermissionService.getByPsvIdAndUserId(id, userId); |
| | |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); |
| | | List<ProcessStream> processStreams = processStreamService.findBypsvId(id); |
| | | if(processStreams!= null &&!processStreams.isEmpty()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST); |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_PROCESS_EXIST); |
| | | boolean b = processSpecVersionPermissionService.deleteByPsvId(processSpecVersion.getId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","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 processSpecVersionCode) { |
| | | public ProcessSpecVersion getByCode(String partId,String processSpecVersionCode) { |
| | | if(ValidateUtil.validateString(processSpecVersionCode)) { |
| | | List<ProcessSpecVersion> list = super.lambdaQuery().eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list(); |
| | | 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 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 (treeInfoRequest.getAttributionType()==4){ |
| | | 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); |
| | | 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(4); |
| | | return docInfoService.findListByDocQuery(docQuery); |
| | | } |
| | | } |
| | | } |