| | |
| | | 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.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.lxzn.activiti.dao.AssignFileStreamMapper; |
| | | import com.lxzn.activiti.service.IActivitiDefinitionService; |
| | | import com.lxzn.activiti.service.IAssignFileStreamService; |
| | |
| | | import com.lxzn.framework.domain.nc.*; |
| | | import com.lxzn.framework.domain.nc.response.DeviceCode; |
| | | import com.lxzn.framework.domain.nc.response.DocumentCode; |
| | | import com.lxzn.framework.domain.plm.PdmProgramSource; |
| | | import com.lxzn.framework.domain.ucenter.Department; |
| | | import com.lxzn.framework.domain.ucenter.response.UcenterCode; |
| | | import com.lxzn.framework.exception.ExceptionCast; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private String serverIp; |
| | | @Value("${securedoc.serverPort}") |
| | | private int serverPort; |
| | | @Value("${ncPdm.file_path}") |
| | | private String localFilePath; |
| | | @Value("${fileHomePath}") |
| | | private String fileHomePath; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | dncLogService.save(dncLog); |
| | | return false; |
| | | } |
| | | //工序天加逻辑 |
| | | processCode = processCode.split("_")[0]; |
| | | ProcessStream stream = processStreamService.findByProcessEquipment(equipmentId, |
| | | processCode,description,compTotal.getComponentId(),part.getPartsId()); |
| | |
| | | dncLogService.save(dncLog); |
| | | return synchronizedFlagService.updateFlag(0); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param docInfo |
| | | * @param source |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean saveListNcFromPdm(DocInfo docInfo, PdmProgramSource source) { |
| | | |
| | | DncLog dncLog = new DncLog(); |
| | | DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo("PDMMES"); |
| | | if(deviceInfo == null) { |
| | | dncLog.setRemarks("DNC中设备不存在,无此设备的程序下发_PDMMES" ); |
| | | dncLogService.save(dncLog); |
| | | return false; |
| | | } |
| | | DocFile docFile = docFileService.getById(docInfo.getPublishFileId()); |
| | | if(docFile == null) { |
| | | return false; |
| | | } |
| | | String id = IdWorker.getIdStr(); |
| | | String name = DateUtil.format(DateUtil.getNow(),DateUtil.STR_YEARMONTHDAY); |
| | | String newPath = "/securedoc" + docFile.getFilePath(); |
| | | String loFilePath = fileHomePath + newPath + "\\" + name +"_" + id; |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String json = mapper.writeValueAsString(source); |
| | | try { |
| | | FileUtil.fileWriterSql(loFilePath,json); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //插入文档到设备发送文档 |
| | | DocClassification classification = classificationService.getByCode(SEND_CODE); |
| | | if(classification == null) |
| | | return false; |
| | | 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) { |
| | | return false; |
| | | } |
| | | |
| | | //复制文件,进行预定密 |
| | | b = FileUtil.copyFile(docFile.getFilePath(), newPath, docFile.getFileEncodeName()); |
| | | if(!b){ |
| | | return false; |
| | | } |
| | | |
| | | String absPath = FileUtil.getFileAbsPath(newPath, docFile.getFileEncodeName()); |
| | | if(absPath == null){ |
| | | return false; |
| | | } |
| | | try { |
| | | secureDocService.binByFileLable(absPath); |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | try { |
| | | secureDocService.editLabelByPath(absPath); |
| | | }catch (Exception e) { |
| | | return false; |
| | | } |
| | | //插入文件传输任务表 |
| | | ToEquipmentTask equipmentTask = new ToEquipmentTask(); |
| | | //不能直接从doc中拿fileId 和version 可能会存在变更 |
| | | |
| | | //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) { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | //TODO |
| | | //复制文件,进行预定密 |
| | | String absPathTxt = FileUtil.getFileAbsPathTxt(loFilePath); |
| | | if(absPathTxt == null){ |
| | | return false; |
| | | } |
| | | try { |
| | | secureDocService.binByFileLable(absPathTxt); |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | try { |
| | | secureDocService.editLabelByPath(absPathTxt); |
| | | }catch (Exception e) { |
| | | return false; |
| | | } |
| | | |
| | | ToEquipmentTask equipmentTaskTxt = new ToEquipmentTask(); |
| | | /*equipmentTaskTxt.setDocId(docInfo.getDocId());*/ |
| | | equipmentTaskTxt.setSyncFlag(1); |
| | | equipmentTaskTxt.setDeviceNo(deviceInfo.getDeviceNo()); |
| | | equipmentTaskTxt.setDeviceId(deviceInfo.getDeviceId()); |
| | | equipmentTaskTxt.setDepartId(deviceInfo.getDepartId()); |
| | | //文件相关信息 |
| | | /*equipmentTaskTxt.setFileId(docFile.getFileId());*/ |
| | | equipmentTaskTxt.setDocVersion("a.1"); |
| | | equipmentTaskTxt.setFileName( name +"_" + id); |
| | | equipmentTaskTxt.setFileEncodeName( name +"_" + id); |
| | | equipmentTaskTxt.setFilePath(docFile.getFilePath()); |
| | | equipmentTaskTxt.setFileSuffix("txt"); |
| | | equipmentTaskTxt.setFileSize(FileUtil.selectFileSize(new File(loFilePath))); |
| | | boolean txt = equipmentTaskService.save(equipmentTaskTxt); |
| | | if(!txt) { |
| | | return false; |
| | | } |
| | | |
| | | dncLog.setIsSuccess(LogCodeUtil.success_is_true); |
| | | dncLog.setRemarks("下发成功"); |
| | | dncLogService.save(dncLog); |
| | | return synchronizedFlagService.updateFlag(0); |
| | | } |
| | | } |