From 1dcf43467f34eb70002be3c2f3cd7605ceb5dcdd Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期一, 17 二月 2025 10:18:18 +0800 Subject: [PATCH] 设备权限与车间权限 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 107 insertions(+), 12 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 e22d52e..b6d842d 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 @@ -3,6 +3,7 @@ import cn.hutool.core.util.StrUtil; 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; @@ -14,16 +15,20 @@ 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; @@ -45,6 +50,12 @@ private INcLogInfoService iNcLogInfoService; @Autowired private IPermissionStreamService permissionStreamService; + @Autowired + private IProcessionDepartmentService processionDepartmentService; + @Autowired + private IWorkStepService workStepService; + @Autowired + private IDocRelativeService iDocRelativeService; @Override @Transactional(rollbackFor = {Exception.class}) @@ -160,18 +171,16 @@ ProcessStream en = super.getById(id); if(en == null) ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); - boolean b = docInfoService.deleteByProcessId(en.getProcessId()); - if(!b) - ExceptionCast.cast(CommonCode.FAIL); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(4); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("宸ュ簭鍙凤細"+en.getProcessCode()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); + //楠岃瘉宸ュ簭涓嬫槸鍚︽湁宸ユ + 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); + } return super.removeById(id); } @@ -264,4 +273,90 @@ 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; + } + } -- Gitblit v1.9.3