From b864148d2a9afd5e1627b761da923cca8f8dfbd2 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 07 三月 2025 14:44:56 +0800 Subject: [PATCH] 修改产品结构树新增删除同步结构树表,新增刀具信息与设备类 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java | 330 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 271 insertions(+), 59 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java index 813f313..b3d3397 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java @@ -1,29 +1,28 @@ package org.jeecg.modules.dnc.service.impl; -import com.alibaba.fastjson.JSONObject; 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.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import org.apache.shiro.SecurityUtils; +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.ProcessStreamMapper; -import org.jeecg.modules.dnc.response.CommonCode; -import org.jeecg.modules.dnc.response.ComponentInfoCode; -import org.jeecg.modules.dnc.response.DeviceCode; -import org.jeecg.modules.dnc.response.ProcessInfoCode; - +import org.jeecg.modules.dnc.request.ProcessStreamRequest; +import org.jeecg.modules.dnc.response.*; import org.jeecg.modules.dnc.service.*; 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.jeecg.modules.system.entity.SysUser; 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; @@ -35,18 +34,27 @@ @Autowired private IProcessInfoService processInfoService; @Autowired - private IPartsInfoService partsInfoService; - @Autowired - private IDocInfoService docInfoService; + private IProcessSpecVersionService processSpecVersionService; @Autowired @Lazy private IDeviceInfoService deviceInfoService; @Autowired - private INcLogInfoService iNcLogInfoService; + private IPermissionStreamNewService permissionStreamNewService; + @Autowired + private IProcessionDepartmentService processionDepartmentService; + @Autowired + private IWorkStepService workStepService; + @Autowired + private IDocRelativeService iDocRelativeService; + @Autowired + private IProcessStreamPermissionService processStreamPermissionService; + @Autowired + private IProductMixService productMixService; @Override @Transactional(rollbackFor = {Exception.class}) public boolean addProcessStream(ProcessStream stream) { + List<PermissionStreamNew> oldDepartPermList=new ArrayList<>(); if(stream == null) ExceptionCast.cast(CommonCode.INVALID_PARAM); if(!ValidateUtil.validateString(stream.getProductId())) @@ -57,18 +65,23 @@ ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE); if(!ValidateUtil.validateString(stream.getProcessCode())) ExceptionCast.cast(ProcessInfoCode.PROCESS_CODE_NONE); - if(ValidateUtil.validateString(stream.getPartsId())) { - PartsInfo partsInfo = partsInfoService.getById(stream.getPartsId()); - if(partsInfo == null) - ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE); - if(!stream.getProductId().equals(partsInfo.getProductId())) + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = user.getId(); + if(!ValidateUtil.validateString(userId)) + ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); + if(ValidateUtil.validateString(stream.getPsvId())) { + ProcessSpecVersion psv = processSpecVersionService.getById(stream.getPsvId()); + if(psv == null) + ExceptionCast.cast(ProcessInfoCode.PROCESSSPECVERSION_NONE); + if(!stream.getProductId().equals(psv.getProductId())) ExceptionCast.cast(ProcessInfoCode.PROCESS_PRODUCT_NONE); - if(!stream.getComponentId().equals(partsInfo.getComponentId())) + if(!stream.getComponentId().equals(psv.getComponentId())) ExceptionCast.cast(ProcessInfoCode.PROCESS_COMPONENT_NONE); - ProcessStream en = findByProcessNoAndPartsId(stream.getProcessCode(), partsInfo.getPartsId()); + ProcessStream en = findByProcessNoAndPartsId(stream.getProcessCode(), psv.getId()); if(en != null) { ExceptionCast.cast(ProcessInfoCode.PROCESS_IS_EXIST); } + oldDepartPermList=permissionStreamNewService.loadPermissionStreamNewByBusinessId(psv.getId(),"4","1"); }else { ComponentInfo componentInfo = componentInfoService.getById(stream.getComponentId()); if(componentInfo == null) @@ -80,23 +93,53 @@ if(en != null) { ExceptionCast.cast(ProcessInfoCode.PROCESS_IS_EXIST); } + oldDepartPermList=permissionStreamNewService.loadPermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1"); } - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(2); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("宸ュ簭鍚嶇О锛�"+stream.getProcessName()+"锛屽伐搴忓彿锛�"+stream.getProcessCode()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); boolean b = super.save(stream); if(!b) ExceptionCast.cast(CommonCode.FAIL); - ProcessInfo processInfo = new ProcessInfo(); - processInfo.setProcessName(stream.getProcessName()); - processInfo.setDescription(stream.getDescription()); - return processInfoService.addOrEdit(processInfo); + //娣诲姞閮ㄩ棬鏉冮檺 + if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { + List<ProcessionDepartment> processionDepartmentList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); + oldDepartPermList.forEach(item -> { + ProcessionDepartment pd = new ProcessionDepartment(); + pd.setDepartId(item.getDepartId()); + pd.setProcessId(stream.getProcessId()); + processionDepartmentList.add(pd); + PermissionStreamNew perm = new PermissionStreamNew(); + perm.setDepartId(item.getDepartId()); + perm.setBusinessId(stream.getProcessId()); + perm.setBusinessType("5"); + permissionStreamList.add(perm); + }); + if(!processionDepartmentList.isEmpty()) { + b = processionDepartmentService.saveBatch(processionDepartmentList); + if(!b) + ExceptionCast.cast(CommonCode.FAIL); + } + if(!permissionStreamList.isEmpty()) { + b = permissionStreamNewService.saveBatch(permissionStreamList); + if(!b) + ExceptionCast.cast(CommonCode.FAIL); + } + } + //娣诲姞缁撴瀯鏍� + ProductMix productMix; + if (stream.getPartsId() != null) { + productMix = new ProductMix(Long.parseLong(stream.getProcessId()),Long.parseLong(stream.getPartsId()) + ,stream.getProcessName(),stream.getProcessCode(),"5"); + }else { + productMix = new ProductMix(Long.parseLong(stream.getProcessId()),Long.parseLong(stream.getComponentId()) + ,stream.getProcessName(),stream.getProcessCode(),"5"); + } + productMixService.save(productMix); + //娣诲姞鏉冮檺楠岃瘉 + PermissionStreamNew permissionStream = new PermissionStreamNew(); + permissionStream.setUserId(userId); + permissionStream.setBusinessId(stream.getProcessId()); + permissionStream.setBusinessType("5"); + return permissionStreamNewService.save(permissionStream); } @Override @@ -115,16 +158,6 @@ stream.setPartsId(null); stream.setProcessName(stream.getProcessName().toUpperCase()); stream.setProcessCode(null); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(3); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("宸ュ簭鍙凤細"+en.getProcessCode()); - ncLogInfo.setRemark(JSONObject.toJSONString(en)); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); boolean b = super.updateById(stream); if(!b) ExceptionCast.cast(CommonCode.FAIL); @@ -142,18 +175,19 @@ ProcessStream en = super.getById(id); if(en == null) ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); - boolean b = docInfoService.deleteByProcessId(en.getProcessId()); + //楠岃瘉宸ュ簭涓嬫槸鍚︽湁宸ユ + List<WorkStep> workStepList=workStepService.list(new QueryWrapper<WorkStep>().eq("process_id",id)); + if(workStepList != null && !workStepList.isEmpty()) { + ExceptionCast.cast(ProcessInfoCode.WORKSTEP_HAS_DATA); + } + //楠岃瘉鏄惁瀛樺湪鏂囨。 + List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","5").eq("attribution_id",id)); + if (!docRelativeList.isEmpty()){ + ExceptionCast.cast(ProcessInfoCode.PROCESS_HAS_DOC); + } + boolean b = productMixService.removeById(id); if(!b) ExceptionCast.cast(CommonCode.FAIL); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(4); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("宸ュ簭鍙凤細"+en.getProcessCode()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return super.removeById(id); } @@ -181,13 +215,13 @@ } @Override - public List<ProcessStream> findByPartsId(String partsId) { - return super.lambdaQuery().eq(ProcessStream::getPartsId, partsId).list(); + public List<ProcessStream> findBypsvId(String psvId) { + return super.lambdaQuery().eq(ProcessStream::getPsvId, psvId).list(); } @Override - public ProcessStream findByProcessNoAndPartsId(String processNo, String partsId) { - List<ProcessStream> list = super.lambdaQuery().eq(ProcessStream::getPartsId, partsId).eq(ProcessStream::getProcessCode, processNo).list(); + public ProcessStream findByProcessNoAndPartsId(String processNo, String psvsId) { + List<ProcessStream> list = super.lambdaQuery().eq(ProcessStream::getPsvId, psvsId).eq(ProcessStream::getProcessCode, processNo).list(); if(list == null || list.isEmpty()) return null; return list.get(0); @@ -223,4 +257,182 @@ ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); return list; } + + @Override + public List<ProcessStream> getByuserPerms(String userId){ + if(!ValidateUtil.validateString(userId)) + return Collections.emptyList(); + return super.getBaseMapper().getByUserPerms(userId); + } + + @Override + public List<ProcessStream> getByuserPerms(String userId,String queryParam){ + if(!ValidateUtil.validateString(userId)) + return Collections.emptyList(); + if(!ValidateUtil.validateString(queryParam)) + return Collections.emptyList(); + LambdaQueryWrapper<ProcessStream> queryWrapper = Wrappers.lambdaQuery(); + if(ValidateUtil.validateString(queryParam)) { + queryWrapper.and(wrapper->wrapper.like(ProcessStream::getProcessName, queryParam) + .or() + .like(ProcessStream::getProcessName, queryParam)); + } + 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<PermissionStreamNew> 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); + } + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processStream.getProcessId(),item.getId(),"5"); + if(stream == null) { + stream = new PermissionStreamNew(); + stream.setDepartId(item.getId()); + stream.setBusinessId(processStream.getProcessId()); + stream.setBusinessType("5"); + 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 = permissionStreamNewService.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<PermissionStreamNew> permissionStreamList = new ArrayList<>(); + departmentList.forEach(item -> { + ProcessionDepartment en = processionDepartmentService.getByProcessIdAndDepartId(processStream.getProcessId(), item.getId()); + if(en != null) { + processionDepartmentList.add(en); + } + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processStream.getProcessId(),item.getId(),"5"); + 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 = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); + if(!b) { + ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); + } + } + return true; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean assignAddUser(ProcessStream processStream, Collection<SysUser> userList) { + if(processStream == null || userList == null || userList.isEmpty()) + ExceptionCast.cast(CommonCode.INVALID_PARAM); + List<ProcessionPermission> permissionList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); + userList.forEach(item -> { + ProcessionPermission en = processStreamPermissionService.getByProcessIdAndUserId(processStream.getProcessId(), item.getId()); + if(en == null) { + en = new ProcessionPermission(); + en.setUserId(item.getId()); + en.setProcessId(processStream.getProcessId()); + permissionList.add(en); + } + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), item.getId(),"5"); + if(stream == null) { + stream = new PermissionStreamNew(); + stream.setUserId(item.getId()); + stream.setBusinessId(processStream.getProcessId()); + stream.setBusinessType("5"); + permissionStreamList.add(stream); + } + }); + if(!permissionList.isEmpty()) { + boolean b = processStreamPermissionService.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; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean assignRemoveUser(ProcessStream processStream, Collection<SysUser> userList) { + if(processStream == null || userList == null || userList.isEmpty()) + ExceptionCast.cast(CommonCode.INVALID_PARAM); + List<ProcessionPermission> permissionList = new ArrayList<>(); + List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); + userList.forEach(item -> { + ProcessionPermission en = processStreamPermissionService.getByProcessIdAndUserId(processStream.getProcessId(), item.getId()); + if(en != null) { + permissionList.add(en); + } + PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), item.getId(),"5"); + if(stream != null) { + permissionStreamList.add(stream); + } + }); + //娓呯┖鐢ㄦ埛鏉冮檺鏍¢獙 + if(!permissionList.isEmpty()) { + boolean b = processStreamPermissionService.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; + } + } -- Gitblit v1.9.3