From c9cc74fad46adaa4bc448cba673e830baf705fce Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期二, 24 六月 2025 17:40:45 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java | 417 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 192 insertions(+), 225 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java index df6ebb3..18f1a94 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.dncFlow.service.impl; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -8,7 +9,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.flowable.engine.TaskService; @@ -16,16 +16,18 @@ import org.flowable.task.api.Task; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.dnc.constant.DncPassLogPassType; +import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; +import org.jeecg.modules.dnc.dto.TransferPackage; import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; -import org.jeecg.modules.dnc.ext.NcTxtFilePathInfo; import org.jeecg.modules.dnc.response.*; import org.jeecg.modules.dnc.service.*; +import org.jeecg.modules.dnc.service.impl.FileFerryService; 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.dncFlow.entity.AssignFileStream; -import org.jeecg.modules.dncFlow.entity.ToEquipmentTask; import org.jeecg.modules.dncFlow.ext.AssignFileStreamExt; import org.jeecg.modules.dncFlow.mapper.AssignFileStreamMapper; import org.jeecg.modules.dncFlow.request.ApproveBatchRequest; @@ -33,9 +35,9 @@ import org.jeecg.modules.dncFlow.request.AssignFileStreamQueryRequest; import org.jeecg.modules.dncFlow.request.TaskRequest; import org.jeecg.modules.dncFlow.service.IAssignFileStreamService; -import org.jeecg.modules.dncFlow.service.IToEquipmentTaskService; import org.jeecg.modules.dncFlow.vo.AssignFlowTaskVo; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; import org.jeecg.modules.flowable.apithird.service.FlowCommonService; import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; @@ -43,47 +45,29 @@ import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.service.IMdcEquipmentService; -import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.io.IOException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service("IAssignFileStreamService") public class AssignFileStreamServiceImpl extends ServiceImpl<AssignFileStreamMapper, AssignFileStream> implements IAssignFileStreamService , FlowCallBackServiceI { private static final String PROCESS_KEY = "assign_nc_to_device"; - private static final String APPLY_VARIABLE = "apply_user"; - private static final String APPROVE_VARIABLE = "approve_users"; private static final String SEND_CODE = "SEND"; - @Value("${flowable.enable}") private Boolean flowableEnable; - + @Value("${fileHomePath}") + private String fileHomePath; @Autowired private IDocInfoService docInfoService; @Autowired - private IProcessStreamService processStreamService; - @Autowired - private IWorkStepService workStepService; - @Autowired - private IPermissionStreamNewService permissionStreamNewService; - @Autowired private IDocClassificationService classificationService; - @Autowired - private IToEquipmentTaskService equipmentTaskService; - @Autowired - private IDeviceInfoService deviceInfoService; @Autowired private IDocFileService docFileService; @Autowired @@ -91,15 +75,11 @@ @Autowired private ISynchronizedFlagService synchronizedFlagService; @Autowired - private IDeviceGroupService deviceGroupService; - @Autowired private IDeviceCharactersService iDeviceCharactersService; @Autowired private IMdcEquipmentService iMdcEquipmentService; @Autowired private IMdcProductionService iMdcProductionService; - @Autowired - private StringRedisTemplate redisTemplate; @Autowired private TaskService taskService; @Resource @@ -108,21 +88,33 @@ private IFlowDefinitionService flowDefinitionService; @Autowired private IFlowTaskService flowTaskService; - - @Value("${securedoc.whether}") - private String whether; - @Value("${securedoc.localFilePath}") - private String localFilePath; - + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private PermissionService permissionService; + @Autowired + private IDncPassLogService dncPassLogService; + @Value("${deploy.secretFolder}") + private String secretFolder; //娑夊瘑缃戜紶杈搉c鏂囦欢澶� + @Autowired + private FileFerryService ferryService; + @Autowired + private IDocClassificationService iDocClassificationService; @Override @Transactional(rollbackFor = {Exception.class}) - public Result applyAssignFile(AssignFileStream stream) { + public Result<?> applyAssignFile(AssignFileStream stream) { synchronized (this){ //鍒ゆ柇璁惧鐗规畩瀛楃 String specialChar = getDeviceSpecialChar(stream.getDeviceId(),stream.getFileId()); if (StrUtil.isNotEmpty(specialChar)){ //鎶涘嚭鐗规畩瀛楃寮傚父 return Result.error("鏂囦欢鍚嶇О瀛樺湪璁惧鐗规畩瀛楃"); + } + //鏌ヨ鏂囨。鐨勭姸鎬侊紝鎵瑰噯鐘舵�佹墠鍙互鎸囨淳 + DocInfo docInfo=getDocInfo(stream); + DocClassification docClassification=iDocClassificationService.getById(docInfo.getClassificationId()); + if (docInfo.getDocDispatchStatus()!=null&&docInfo.getDocDispatchStatus()!=3&&docClassification.getClassificationCode().equals("nc")){ + return Result.error("璇ユ枃浠剁姸鎬佷笉鍏佽鎸囨淳,璇峰厛瀹屾垚瀹$娴佺▼"); } if(flowableEnable) { return applyAssignFileActive(stream); @@ -139,7 +131,6 @@ */ public String getDeviceSpecialChar(String deviceId, String fileId){ //鏇挎崲涓簃dc璁惧琛� -// DeviceInfo deviceInfo = deviceInfoService.getById(deviceId); MdcEquipment mdcEquipment = iMdcEquipmentService.getById(deviceId); if(mdcEquipment == null) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); @@ -192,15 +183,18 @@ DocInfo docInfo = getDocInfo(stream); MdcEquipment mdcEquipment = getMdcEquipment(stream); DocFile docFile = docFileService.getById(stream.getFileId()); - DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 4, stream.getDeviceId()); + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 7, stream.getDeviceId()); if (deviceDoc != null) { handleExistingDeviceDoc(docFile, mdcEquipment, stream.getDeviceId()); } - deviceDoc = docInfoService.findByAttrAndDocName(docInfo.getDocName(), 4, stream.getDeviceId()); + deviceDoc = docInfoService.findByAttrAndDocName(docInfo.getDocName(), 7, stream.getDeviceId()); if (deviceDoc != null) { handleExistingDeviceDoc(docFile, mdcEquipment, stream.getDeviceId()); } PermissionStreamNew permissionStreams = getPermissionStreams(stream); + if (permissionStreams==null){ + return Result.error("鐢ㄦ埛娌℃湁鏉冮檺"); + } LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); saveBusinessObject(stream, userId); @@ -209,8 +203,19 @@ stream.getStreamId(), "IAssignFileStreamService", "assign_nc_to_device", null); Map<String, Object> variables = new HashMap<>(); variables.put("dataId", stream.getStreamId()); - variables.put("organization", stream.getApplyReason()); - return flowDefinitionService.startProcessInstanceByKey("assign_nc_to_device", variables); + if (stream.getApplyReason() != null) { + variables.put("organization", stream.getApplyReason()); + }else { + variables.put("organization", ""); + } + Result result= flowDefinitionService.startProcessInstanceByKey("assign_nc_to_device", variables); + if (result.isSuccess()){ + return Result.OK("鎿嶄綔鎴愬姛"); + }else { + super.removeById(stream.getStreamId()); + + return Result.error("鎿嶄綔澶辫触"); + } } @Override @@ -219,9 +224,12 @@ //鏉冮檺鏍¢獙 validateParams(stream); DocInfo docInfo = getDocInfo(stream); + //淇敼鍘熸湁鐘舵�� + docInfo.setDocDispatchStatus(4); + docInfoService.updateById(docInfo); MdcEquipment mdcEquipment = getMdcEquipment(stream); DocFile docFile = getDocFile(stream); - DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 4, stream.getDeviceId()); + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 7, stream.getDeviceId()); if(deviceDoc != null) { // 鍒犻櫎 澶囦唤 瑕嗙洊 鍘熸湁鐨� List<String> strings=iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); @@ -231,16 +239,6 @@ docFile.getFileName(), docFile.getFileSuffix()); } } - /*deviceDoc = docInfoService.findByAttrAndDocName(docInfo.getDocName(), 4, stream.getDeviceId()); - if(deviceDoc != null) { - // 鍒犻櫎 澶囦唤 瑕嗙洊 鍘熸湁鐨� - List<String> strings = deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId()); - if (strings != null && !strings.isEmpty()) { - String path = StringUtils.join(strings.toArray(), "/"); - boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/"+ deviceInfo.getDeviceNo(), - docFile.getFileName(), docFile.getFileSuffix()); - } - }*/ getPermissionStreams(stream); //鎻掑叆鏂囨。鍒拌澶囧彂閫佹枃妗� if(deviceDoc == null) { @@ -250,7 +248,7 @@ DocRelative docRelative = new DocRelative(); docRelative.setDocId(docInfo.getDocId()); docRelative.setClassificationId(classification.getClassificationId()); - docRelative.setAttributionType(4); + docRelative.setAttributionType(7); docRelative.setAttributionId(stream.getDeviceId()); boolean b = docRelativeService.save(docRelative); if(!b) { @@ -258,8 +256,19 @@ } } + List<DocRelative> docRelativeList=docRelativeService. + list(new QueryWrapper<DocRelative>() + .eq("attribution_type",stream.getAttributionType()) + .eq("attribution_id",stream.getAttributionId()) + .eq("doc_id",stream.getDocId())); + if (docRelativeList.isEmpty()){ + ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); + } handleFileTransfer(mdcEquipment, docFile); - handleFileProcessing(docFile, mdcEquipment, whether, localFilePath); + //NC鏂囦欢鐨勬嫹璐� + handleFileProcessing(docFile, mdcEquipment, secretFolder); + //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐� + handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); synchronizedFlagService.updateFlag(2); return Result.OK("鎿嶄綔鎴愬姛"); } @@ -288,6 +297,34 @@ //flowable澶勭悊 FlowTaskVo flowTaskVo = new FlowTaskVo(); BeanUtils.copyProperties(assignFlowTaskVo, flowTaskVo); + + List<FlowMyBusiness> businessList = flowMyBusinessService.list( + new QueryWrapper<FlowMyBusiness>() + .eq("process_instance_id", assignFlowTaskVo.getInstanceId()) + ); + if (businessList.isEmpty()) { + return false; + } + FlowMyBusiness flowMyBusiness = businessList.get(0); + List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); + if (todoUsers == null || !todoUsers.contains(user.getUsername())) { + return false; + } + + // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛� + String taskId = flowMyBusiness.getTaskId(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if (task == null) { + return false; + } + if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { + return false; + } + taskService.claim(taskId, user.getUsername()); + Map<String, Object> values=new HashMap<>(); + values.put("dataId", assignFlowTaskVo.getDataId()); + flowTaskVo.setTaskId(assignFlowTaskVo.getTaskId()); + flowTaskVo.setValues(values); flowTaskService.complete(flowTaskVo); //鏇存柊瀵硅薄灏佽 AssignFileStream up = new AssignFileStream(); @@ -300,23 +337,20 @@ if(!b) ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); if(up.getStatus() == 2) { - DocInfo docInfo; //鍚屾剰鎿嶄綔 - if (StrUtil.isNotEmpty(en.getStepId())){ - //宸ユ鎸囨淳 - docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 6, en.getStepId()); - }else { - docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 5, en.getProcessId()); - } - if(docInfo == null || docInfo.getDocStatus() == 3) - ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); + DocInfo docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), Integer.valueOf(en.getAttributionType()), en.getAttributionId()); + if(docInfo == null ) + ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); MdcEquipment mdcEquipment = iMdcEquipmentService.getById(en.getDeviceId()); if(mdcEquipment == null) ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE); DocFile docFile = docFileService.getById(en.getFileId()); if(docFile == null) ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); - DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(en.getDocId(),4, en.getDeviceId()); + //淇敼鍘熸湁鐘舵�� + docInfo.setDocDispatchStatus(4); + docInfoService.updateById(docInfo); + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(en.getDocId(),7, en.getDeviceId()); if(deviceDoc != null) { // 鍒犻櫎 澶囦唤 瑕嗙洊 鍘熸湁鐨� List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); @@ -325,7 +359,7 @@ boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/"+ mdcEquipment.getEquipmentId(), docFile.getFileName(), docFile.getFileSuffix()); /* //docInfoService.getBaseMapper().deleteById(deviceDoc.getDocId()); - boolean doc = docRelativeService.deleteCopyDocByAttrNext(deviceDoc.getDocId(),4,stream.getDeviceId()); + boolean doc = docRelativeService.deleteCopyDocByAttrNext(deviceDoc.getDocId(),7,stream.getDeviceId()); if (!doc) { ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR_DELEVE); }*/ @@ -339,7 +373,7 @@ DocRelative docRelative = new DocRelative(); docRelative.setDocId(docInfo.getDocId()); docRelative.setClassificationId(classification.getClassificationId()); - docRelative.setAttributionType(4); + docRelative.setAttributionType(7); docRelative.setAttributionId(en.getDeviceId()); b = docRelativeService.save(docRelative); } @@ -360,6 +394,20 @@ } } } + List<DocRelative> docRelativeList=docRelativeService. + list(new QueryWrapper<DocRelative>() + .eq("attribution_type",en.getAttributionType()) + .eq("attribution_id",en.getAttributionId()) + .eq("doc_id",en.getDocId())); + if (docRelativeList.isEmpty()){ + ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); + } + //娑夊瘑缃戣繘琛孨C鏂囦欢鐨勬嫹璐� + handleFileTransfer(mdcEquipment, docFile); + //NC鏂囦欢鐨勬嫹璐� + handleFileProcessing(docFile, mdcEquipment, secretFolder); + //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐� + handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); return synchronizedFlagService.updateFlag(1); }else if(up.getStatus() == 3) { //鎷掔粷鎿嶄綔 浠�涔堜篃涓嶅仛 @@ -402,14 +450,6 @@ List<TaskRequest> list = approveBatchRequest.getTaskArr(); if(list == null || list.isEmpty()) ExceptionCast.cast(CommonCode.INVALID_PARAM); -// list.forEach(item -> { -// AssignFileStream stream = new AssignFileStream(); -// stream.setApproveContent(approveBatchRequest.getApproveContent()); -// stream.setStatus(approveBatchRequest.getStatus()); -// boolean b = approveAssignFile(item.getId(), item.getBusinessKey(), stream); -// if(!b) -// ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); -// }); return synchronizedFlagService.updateFlag(1); } @@ -463,64 +503,6 @@ return false; } - @Override - @Transactional(rollbackFor = {Exception.class}) - public boolean transferDocFile(String pnCode, String deviceNo) { - List<ProcessStream> streams = processStreamService.validateDeviceProcessInfo(pnCode, deviceNo); - DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo); - if(deviceInfo == null) - ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST); - //鍒犻櫎鍘熸潵璁惧涓嬬殑鎵�鏈夋枃妗� - docRelativeService.deleteByDocAttr(4, deviceInfo.getDeviceId()); - List<DocInfo> docInfoList = docInfoService.getByProcessIds(streams); - if(docInfoList == null || docInfoList.isEmpty()) - ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - if(!ValidateUtil.validateString(userId)) - ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); - for(DocInfo docInfo : docInfoList) { - DocFile docFile = docFileService.getById(docInfo.getPublishFileId()); - if(docFile == null) - ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); - //鎻掑叆鏂囨。鍒拌澶囧彂閫佹枃妗� - DocClassification classification = classificationService.getByCode(SEND_CODE); - if(classification == null) - ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR); - DocRelative docRelative = new DocRelative(); - docRelative.setDocId(docInfo.getDocId()); - docRelative.setClassificationId(classification.getClassificationId()); - docRelative.setAttributionType(4); - docRelative.setAttributionId(deviceInfo.getDeviceId()); - boolean b = docRelativeService.save(docRelative); - if(!b) - ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); - //鎻掑叆鏂囦欢浼犺緭浠诲姟琛� - ToEquipmentTask equipmentTask = new ToEquipmentTask(); - //涓嶈兘鐩存帴浠巇oc涓嬁fileId 鍜寁ersion 鍙兘浼氬瓨鍦ㄦ枌鏇� - //equipmentTask.setFileId(docInfo.getPublishFileId()); - //equipmentTask.setDocVersion(docInfo.getPublishVersion()); - equipmentTask.setDocId(docInfo.getDocId()); - equipmentTask.setSyncFlag(1); - equipmentTask.setDeviceNo(deviceInfo.getDeviceNo()); - equipmentTask.setDeviceId(deviceInfo.getDeviceId()); - equipmentTask.setDepartId(deviceInfo.getDepartId()); - //鏂囦欢鐩稿叧淇℃伅 - equipmentTask.setFileId(docFile.getFileId()); - equipmentTask.setDocVersion(docFile.getDocVersion()); - equipmentTask.setFileName(docInfo.getDocName()); - equipmentTask.setFileEncodeName(docFile.getFileEncodeName()); - equipmentTask.setFilePath(docFile.getFilePath()); - equipmentTask.setFileSuffix(docFile.getFileSuffix()); - equipmentTask.setFileSize(docFile.getFileSize()); - b = equipmentTaskService.save(equipmentTask); - if(!b) { - ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); - } - } - return synchronizedFlagService.updateFlag(1); - } - //浼犲弬楠岃瘉 private void validateParams(AssignFileStream stream) { if (stream == null) { @@ -551,7 +533,7 @@ //鑾峰彇鏂囦欢 private void handleExistingDeviceDoc(DocFile docFile, MdcEquipment mdcEquipment, String deviceId) { - List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getEquipmentId()); + List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { String path = StringUtils.join(strings.toArray(), "/"); boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/" + mdcEquipment.getEquipmentId(), @@ -559,8 +541,8 @@ if (!copyFileNc) { ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); } else { - DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(deviceId, 4, deviceId); - boolean doc = docRelativeService.deleteDocByAttr(deviceDoc.getDocId(), 4, deviceId); + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(deviceId, 7, deviceId); + boolean doc = docRelativeService.deleteDocByAttr(deviceDoc.getDocId(), 7, deviceId); if (!doc) { ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR_DELEVE); } @@ -568,54 +550,13 @@ } } - //鏉冮檺鏍¢獙 private PermissionStreamNew getPermissionStreams(AssignFileStream stream) { - PermissionStreamNew permissionStreams; - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - 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(processStream.getProcessId()); - permissionStreams = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(),user.getId(),"5"); - } 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.setStepId(workStep.getId()); - permissionStreams = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),user.getId(),"6"); - } - if (permissionStreams == null ) { + PermissionStreamNew permissionStreamNew = permissionService.getPermissionStreams(stream); + if (permissionStreamNew == null) { ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); } - return permissionStreams; + return permissionStreamNew ; } - - //鑾峰彇閮ㄩ棬淇℃伅 - //todo 淇敼 - private List<String> getDepartIds(List<PermissionStream> permissionStreams, String userId) { - Map<String, MdcProduction> map = iMdcProductionService.getUserAssignedDepart(userId); - List<String> departIds = permissionStreams.stream() - .filter(item -> map.containsKey(item.getDepartId())) - .map(PermissionStream::getDepartId) - .collect(Collectors.toList()); - if (departIds.isEmpty()) { - ExceptionCast.cast(ActivitiCode.ACT_USER_NOT_PERM); - } - return departIds; - } - //灏佽鏁版嵁 private void saveBusinessObject(AssignFileStream stream, String userId) { @@ -629,19 +570,6 @@ ExceptionCast.cast(ActivitiCode.ACT_BUSINESS_SAVE_ERROR); } } - - //寮�濮嬪伐浣滄祦 -// private ProcessInstance startProcessInstance(AssignFileStream stream, List<String> userIdList) { -// String approveUsers = String.join(",", userIdList); -// Map<String, Object> avariableMap = new HashMap<>(); -// avariableMap.put(APPLY_VARIABLE, stream.getApplyUserId()); -// avariableMap.put(APPROVE_VARIABLE, approveUsers); -// ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(PROCESS_KEY, stream.getStreamId(), avariableMap); -// if (processInstance == null) { -// ExceptionCast.cast(ActivitiCode.ACT_APPROVE_USERS_NONE); -// } -// return processInstance; -// } //鎷惧彇浠诲姟 private void completeTask(ProcessInstance processInstance, String userId) { @@ -672,7 +600,8 @@ } //鎻掑叆鏂囦欢浼犺緭浠诲姟琛� - private void handleFileTransfer(MdcEquipment mdcEquipment, DocFile docFile) { + @Override + public void handleFileTransfer(MdcEquipment mdcEquipment, DocFile docFile) { List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { String path = StringUtils.join(strings.toArray(), "/"); @@ -691,46 +620,84 @@ } //灏佽澶勭悊鏂囦欢 - private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String whether, String localFilePath) { - if (whether.equals("true") && !docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { - String size = FileUtilS.fileSizeNC(docFile.getFilePath(), docFile.getFileEncodeName()); + private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String secretFolder) { + if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { + DncPassLog passInfoTxt = new DncPassLog(); + String path = StringUtils.join(strings.toArray(), "/"); Date dateFirst = DateUtil.getNow(); - NcTxtFilePathInfo ncTxt = new NcTxtFilePathInfo(); - ncTxt.setEquipmentId(mdcEquipment.getEquipmentId()); - ncTxt.setFileNcName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY)); - ncTxt.setFileTxtName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY)); - ncTxt.setFilePath(path + "/" + mdcEquipment.getEquipmentId() + "/"); - ncTxt.setOrigFileName(docFile.getFileName()); - ncTxt.setOrigFileSuffix(docFile.getFileSuffix()); - ncTxt.setFileAddOrDelete(1); - String loFilePath = localFilePath + ncTxt.getFileTxtName() + ".nc"; - try { - String allList = ncTxt.getFileTxtName() + "\n" - + ncTxt.getFileNcName() + "\n" - + ncTxt.getOrigFileName() + "\n" - + ncTxt.getOrigFileSuffix() + "\n" - + ncTxt.getFilePath() + "\n" - + ncTxt.getEquipmentId() + "\n" - + ncTxt.getFileAddOrDelete().toString() + "\n" - + size + "\n"; - FileUtilS.fileWriterSql(loFilePath, allList); - boolean copyFileNc = FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" + - docFile.getFileName(), - localFilePath + ncTxt.getFileNcName(), - docFile.getFileSuffix(), "NC"); - if (!copyFileNc) { - FileUtilS.deleteNcFile(loFilePath); - } - } catch (IOException e) { - throw new RuntimeException("鏂囦欢澶勭悊澶辫触", e); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileNc =0; + if (dncPassLog !=null) { + fileNc = dncPassLog.getSequenceNumber() + 1; + } else { + fileNc = 1; } + //澶勭悊鏂囦欢鍚嶇О 鏂囦欢璺緞 + String sequenceNc = String.format("%06d",fileNc); + DncPassLog passInfoNc = new DncPassLog(); + passInfoNc.setSequenceNumber(fileNc); + passInfoNc.setSequenceOrder(sequenceNc); + passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + passInfoNc.setPassType("02"); + passInfoNc.setPassName(docFile.getFileName()); + try { + Thread.sleep(1000); + Date date = new Date(); + passInfoNc.setCreateTime(date); + System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + dncPassLogService.save(passInfoNc); + FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" + + docFile.getFileName(), + secretFolder +"/"+"10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc+"_"+mdcEquipment.getEquipmentId(), + docFile.getFileSuffix(), "NC"); } } } + /** + * 澶勭悊瀵瑰簲浜у搧缁撴瀯鏍戙�乶c鏂囦欢銆佸垁鍏峰垪琛ㄣ�佺▼搴忓姞宸ョ‘璁よ〃灏佽 + * @param docInfo + */ + private void handleProductTree(DocInfo docInfo,DocRelative docRelative,String equipmentId) { + /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/ + //浼戠湢 500姣 + DncPassLog passInfoTxt = new DncPassLog(); + Date dateFirst = DateUtil.getNow(); + passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); + int fileTxt = 0, fileNc =0; + if (dncPassLog !=null) { + fileTxt = dncPassLog.getSequenceNumber() + 1; + } else { + fileTxt = 1; + } + String sequence = String.format("%06d",fileTxt); + passInfoTxt.setSequenceNumber(fileTxt); + passInfoTxt.setCreateTime(dateFirst); + passInfoTxt.setSequenceOrder(sequence); + System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME)); + passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode()); + dncPassLogService.save(passInfoTxt); + String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY); + if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){ + //宸ュ簭瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath); + }else { + //宸ユ瀵瑰簲璁惧绫� + String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath); + } + } @Override public void afterFlowHandle(FlowMyBusiness business) { business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 @@ -750,6 +717,6 @@ @Override public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { - return Lists.newArrayList("jeecg"); + return null; } } -- Gitblit v1.9.3