From f2f8241dd52ef12ec109f6f4f0f13042055338ac Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 14 二月 2025 14:55:56 +0800 Subject: [PATCH] 修改指派设备 修改设备结构树权限 优化查询 优化排序 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/activiti/service/impl/AssignFileStreamServiceImpl.java | 147 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 98 insertions(+), 49 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/activiti/service/impl/AssignFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/activiti/service/impl/AssignFileStreamServiceImpl.java index 18c2067..9e4f927 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/activiti/service/impl/AssignFileStreamServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/activiti/service/impl/AssignFileStreamServiceImpl.java @@ -16,6 +16,7 @@ import org.activiti.engine.task.Task; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; +import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.activiti.entity.AssignFileStream; import org.jeecg.modules.activiti.entity.ToEquipmentTask; @@ -38,6 +39,9 @@ import org.jeecg.modules.dnc.utils.ValidateUtil; import org.jeecg.modules.dnc.utils.date.DateUtil; import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.service.IMdcEquipmentService; +import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; @@ -67,6 +71,8 @@ @Autowired private IProcessStreamService processStreamService; @Autowired + private IWorkStepService workStepService; + @Autowired private IPermissionStreamService permissionStreamService; @Autowired private IDepartmentService departmentService; @@ -92,7 +98,10 @@ private IDncPassLogService dncPassLogService; @Autowired private IDeviceCharactersService iDeviceCharactersService; - + @Autowired + private IMdcEquipmentService iMdcEquipmentService; + @Autowired + private IMdcProductionService iMdcProductionService; @Autowired private StringRedisTemplate redisTemplate; @@ -135,15 +144,17 @@ * 璁惧ID锛屾枃浠禝D */ public String getDeviceSpecialChar(String deviceId, String fileId){ - DeviceInfo deviceInfo = deviceInfoService.getById(deviceId); - if(deviceInfo == null) + //鏇挎崲涓簃dc璁惧琛� +// DeviceInfo deviceInfo = deviceInfoService.getById(deviceId); + MdcEquipment mdcEquipment = iMdcEquipmentService.getById(deviceId); + if(mdcEquipment == null) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); // DocFile docFile = docFileService.getById(fileId); DocInfo docInfo = docInfoService.getOne(new QueryWrapper<DocInfo>().eq("publish_file_id",fileId)); if(docInfo == null) ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); List<DeviceCharacters> deviceCharactersList=iDeviceCharactersService.list( - new LambdaQueryWrapper<DeviceCharacters>().eq(DeviceCharacters::getDeviceNo,deviceInfo.getDeviceNo())); + new LambdaQueryWrapper<DeviceCharacters>().eq(DeviceCharacters::getDeviceNo,mdcEquipment.getEquipmentId())); if (deviceCharactersList.isEmpty()){ return ""; }else { @@ -186,16 +197,17 @@ //鏍¢獙寮�濮� if(stream == null) ExceptionCast.cast(CommonCode.INVALID_PARAM); - if(!ValidateUtil.validateString(stream.getProcessId()) || !ValidateUtil.validateString(stream.getDocId()) - || !ValidateUtil.validateString(stream.getFileId())) + if(!ValidateUtil.validateString(stream.getAttributionId()) || !ValidateUtil.validateString(stream.getDocId()) + || !ValidateUtil.validateString(stream.getFileId())||!ValidateUtil.validateString(stream.getAttributionType()) ) ExceptionCast.cast(ActivitiCode.ACT_BUSINESS_SAVE_ERROR); if(!ValidateUtil.validateString(stream.getDeviceId())) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); if(!ValidateUtil.validateString(userId)) ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); - DocInfo docInfo = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 5, stream.getProcessId()); + //淇敼涓哄墠绔紶鍏� + DocInfo docInfo = docInfoService.getByDocAttrAndDocId(stream.getDocId(), Integer.parseInt(stream.getAttributionType()), stream.getAttributionId()); if(docInfo == null || docInfo.getDocStatus() == 3) ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); DeviceInfo deviceInfo = deviceInfoService.getById(stream.getDeviceId()); @@ -306,21 +318,22 @@ public ResponseResult applyAssignFileNonActive(AssignFileStream stream) { if(stream == null) ExceptionCast.cast(CommonCode.INVALID_PARAM); - if(!ValidateUtil.validateString(stream.getProcessId()) || !ValidateUtil.validateString(stream.getDocId()) - || !ValidateUtil.validateString(stream.getFileId())) + if(!ValidateUtil.validateString(stream.getAttributionId()) || !ValidateUtil.validateString(stream.getDocId()) + || !ValidateUtil.validateString(stream.getFileId())||!ValidateUtil.validateString(stream.getAttributionType())) ExceptionCast.cast(CommonCode.INVALID_PARAM); if(!ValidateUtil.validateString(stream.getDeviceId())) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); if(!ValidateUtil.validateString(userId)) ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); - DocInfo docInfo = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 5, stream.getProcessId()); + DocInfo docInfo = docInfoService.getByDocAttrAndDocId(stream.getDocId(), Integer.parseInt(stream.getAttributionType()), stream.getAttributionId()); if(docInfo == null || docInfo.getDocStatus() == 3) ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); - DeviceInfo deviceInfo = deviceInfoService.getById(stream.getDeviceId()); - if(deviceInfo == null) + MdcEquipment mdcEquipment = iMdcEquipmentService.getById(stream.getDeviceId()); +// DeviceInfo deviceInfo = deviceInfoService.getById(stream.getDeviceId()); + if(mdcEquipment == null) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); DocFile docFile = docFileService.getById(stream.getFileId()); if(docFile == null) @@ -328,10 +341,10 @@ DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 4, stream.getDeviceId()); if(deviceDoc != null) { // 鍒犻櫎 澶囦唤 瑕嗙洊 鍘熸湁鐨� - List<String> strings = deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId()); + List<String> strings=iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { String path = StringUtils.join(strings.toArray(), "/"); - boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/"+ deviceInfo.getDeviceNo(), + boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/"+ mdcEquipment.getEquipmentId(), docFile.getFileName(), docFile.getFileSuffix()); } } @@ -346,29 +359,62 @@ docFile.getFileName(), docFile.getFileSuffix()); } }*/ - ProcessStream processStream = processStreamService.getById(stream.getProcessId()); - if(processStream == null) - ExceptionCast.cast(CommonCode.INVALID_PARAM); - stream.setProductId(processStream.getProductId()); - stream.setComponentId(processStream.getComponentId()); - stream.setPartsId(processStream.getPartsId()); - List<PermissionStream> permissionStreams = null; - if(ValidateUtil.validateString(processStream.getPartsId())) { - //杩涘叆闆朵欢 - permissionStreams = permissionStreamService.getByPartsId(stream.getProductId(), stream.getComponentId(), stream.getPartsId()); - }else if(ValidateUtil.validateString(processStream.getComponentId())) { - //杩涘叆閮ㄤ欢鐨勫鐞� - permissionStreams = permissionStreamService.getByComponentId(stream.getProductId(), stream.getComponentId()); - } - if(permissionStreams == null || permissionStreams.isEmpty()) - ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); List<String> departIds = new ArrayList<>(); - Map<String, Department> map = departmentService.getMapByUserId(userId); - permissionStreams.forEach(item -> { - if(map.containsKey(item.getDepartId())) { - departIds.add(item.getDepartId()); + if (stream.getAttributionType().equals("5")){ + //宸ュ簭 + ProcessStream processStream = processStreamService.getById(stream.getAttributionId()); + if(processStream == null) + ExceptionCast.cast(CommonCode.INVALID_PARAM); + stream.setProductId(processStream.getProductId()); + stream.setComponentId(processStream.getComponentId()); + stream.setPartsId(processStream.getPartsId()); + stream.setProcessId(stream.getAttributionId()); + List<PermissionStream> permissionStreams = null; + if(ValidateUtil.validateString(processStream.getPartsId())) { + //杩涘叆闆朵欢 + permissionStreams = permissionStreamService.getByPartsId(stream.getProductId(), stream.getComponentId(), stream.getPartsId()); + }else if(ValidateUtil.validateString(processStream.getComponentId())) { + //杩涘叆閮ㄤ欢鐨勫鐞� + permissionStreams = permissionStreamService.getByComponentId(stream.getProductId(), stream.getComponentId()); } - }); + if(permissionStreams == null || permissionStreams.isEmpty()) + ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); + Map<String, Department> map = departmentService.getMapByUserId(userId); + permissionStreams.forEach(item -> { + if(map.containsKey(item.getDepartId())) { + departIds.add(item.getDepartId()); + } + }); + }else{ + //宸ユ + WorkStep workStep=workStepService.getById(stream.getAttributionId()); + if(workStep == null) + ExceptionCast.cast(CommonCode.INVALID_PARAM); + stream.setProductId(workStep.getProductId()); + stream.setComponentId(workStep.getComponentId()); + stream.setPartsId(workStep.getPartsId()); + stream.setProcessId(workStep.getProcessId()); + stream.setProcessId(stream.getAttributionId()); + List<PermissionStream> permissionStreams = null; + if(ValidateUtil.validateString(workStep.getProcessId())) { + //杩涘叆宸ュ簭 + permissionStreams=permissionStreamService.getByProcessId(stream.getProductId(), stream.getComponentId(), stream.getPartsId(),stream.getProcessId()); + }else if(ValidateUtil.validateString(workStep.getPartsId())) { + //杩涘叆闆朵欢 + permissionStreams = permissionStreamService.getByPartsId(stream.getProductId(), stream.getComponentId(), stream.getPartsId()); + }else if(ValidateUtil.validateString(workStep.getComponentId())) { + //杩涘叆閮ㄤ欢鐨勫鐞� + permissionStreams = permissionStreamService.getByComponentId(stream.getProductId(), stream.getComponentId()); + } + if(permissionStreams == null || permissionStreams.isEmpty()) + ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); + Map<String, Department> map = departmentService.getMapByUserId(userId); + permissionStreams.forEach(item -> { + if(map.containsKey(item.getDepartId())) { + departIds.add(item.getDepartId()); + } + }); + } if(departIds.isEmpty()) ExceptionCast.cast(ActivitiCode.ACT_USER_NOT_PERM); //deviceDoc = docInfoService.findByAttrAndDocName(docInfo.getDocName(), 4, stream.getDeviceId()); @@ -394,16 +440,16 @@ //TODO //鎻掑叆鏂囦欢浼犺緭浠诲姟琛� - List<String> strings = deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId()); + List<String> strings=iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { String path = StringUtils.join(strings.toArray(), "/"); - boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ deviceInfo.getDeviceNo(), + boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ mdcEquipment.getEquipmentId(), docFile.getFileEncodeName(), docFile.getFileName(),docFile.getFileSuffix()); if (!copyFileNc) { ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); } else { - FileUtilS.deleteZipFromToSend(path + "/"+ deviceInfo.getDeviceNo(), + FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(), docFile.getFileName(),docFile.getFileSuffix()); } @@ -462,10 +508,10 @@ dncPassLogService.save(passInfoNc); NcTxtFilePathInfo ncTxt = new NcTxtFilePathInfo(); - ncTxt.setEquipmentId(deviceInfo.getDeviceNo()); + ncTxt.setEquipmentId(mdcEquipment.getEquipmentId()); ncTxt.setFileNcName("02A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc); ncTxt.setFileTxtName("02A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequence); - ncTxt.setFilePath(path + "/"+ deviceInfo.getDeviceNo() + "/" ); + ncTxt.setFilePath(path + "/"+ mdcEquipment.getEquipmentId() + "/" ); ncTxt.setOrigFileName(docFile.getFileName()); ncTxt.setOrigFileSuffix(docFile.getFileSuffix()); ncTxt.setFileAddOrDelete(1); @@ -494,7 +540,7 @@ localFilePath + "\\" + ncTxt.getFileNcName(), docFile.getFileSuffix()); */ - boolean copyFileNc = FileUtilS.copyFileUpName(path + "/"+ deviceInfo.getDeviceNo() +"/send/" + + boolean copyFileNc = FileUtilS.copyFileUpName(path + "/"+ mdcEquipment.getEquipmentId() +"/send/" + docFile.getFileName(), localFilePath + ncTxt.getFileNcName(), // localFilePath + "\\" + ncTxt.getFileNcName(), @@ -511,8 +557,8 @@ } @Override - public List<ActTaskExt> getUndoTaskList() { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + public IPage<ActTaskExt> getUndoTaskList(Integer pageNo,Integer pageSize) { + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); if(!ValidateUtil.validateString(userId)) return null; @@ -536,7 +582,10 @@ ext.setAssignFileStream(streamDetail); extList.add(ext); }); - return extList; + //灏佽Page + IPage<ActTaskExt> page = new Page<>(pageNo,pageSize); + page.setRecords(extList); + return page; } @Override @@ -551,7 +600,7 @@ public boolean approveAssignFile(String taskId, String streamId, AssignFileStream stream) { if(!ValidateUtil.validateString(taskId) || !ValidateUtil.validateString(streamId) || stream == null) ExceptionCast.cast(CommonCode.INVALID_PARAM); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); if(!ValidateUtil.validateString(userId)) ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); @@ -693,7 +742,7 @@ } @Override - public QueryPageResponseResult<AssignFileStreamExt> findPageList(int page, int size, AssignFileStreamQueryRequest request) { + public Result<?> findPageList(int page, int size, AssignFileStreamQueryRequest request) { if(page < 1 || size < 1) { ExceptionCast.cast(CommonCode.INVALID_PAGE); } @@ -716,7 +765,7 @@ } } IPage<AssignFileStreamExt> streamExtIPage = super.getBaseMapper().findByPage(pageData, lambdaQueryWrapper); - return new QueryPageResponseResult<>(CommonCode.SUCCESS, streamExtIPage); + return Result.ok(streamExtIPage); } @Override -- Gitblit v1.9.3