| | |
| | | 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; |
| | |
| | | @Autowired |
| | | private IProcessStreamService processStreamService; |
| | | @Autowired |
| | | private IWorkStepService workStepService; |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | @Autowired |
| | | private IDepartmentService departmentService; |
| | |
| | | private IDncPassLogService dncPassLogService; |
| | | @Autowired |
| | | private IDeviceCharactersService iDeviceCharactersService; |
| | | |
| | | @Autowired |
| | | private IMdcEquipmentService iMdcEquipmentService; |
| | | @Autowired |
| | | private IMdcProductionService iMdcProductionService; |
| | | @Autowired |
| | | private StringRedisTemplate redisTemplate; |
| | | |
| | |
| | | * 设备ID,文件ID |
| | | */ |
| | | public String getDeviceSpecialChar(String deviceId, String fileId){ |
| | | DeviceInfo deviceInfo = deviceInfoService.getById(deviceId); |
| | | if(deviceInfo == null) |
| | | //替换为mdc设备表 |
| | | // 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 { |
| | |
| | | //校验开始 |
| | | 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()); |
| | |
| | | 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); |
| | |
| | | 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) |
| | |
| | | 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()); |
| | | } |
| | | } |
| | |
| | | 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()); |
| | |
| | | |
| | | //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()); |
| | | |
| | | } |
| | |
| | | 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); |
| | |
| | | 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(), |