From e5bd30e774dba285e0e22bbfa5e4e0d936d88e6b Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期四, 12 三月 2026 10:32:26 +0800
Subject: [PATCH] 430代码 SQL server
---
src/main/java/com/lxzn/activiti/service/impl/AssignFileStreamServiceImpl.java | 148 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/lxzn/activiti/service/impl/AssignFileStreamServiceImpl.java b/src/main/java/com/lxzn/activiti/service/impl/AssignFileStreamServiceImpl.java
index d2535a8..1213b9c 100644
--- a/src/main/java/com/lxzn/activiti/service/impl/AssignFileStreamServiceImpl.java
+++ b/src/main/java/com/lxzn/activiti/service/impl/AssignFileStreamServiceImpl.java
@@ -7,6 +7,8 @@
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;
@@ -27,6 +29,7 @@
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;
@@ -52,6 +55,8 @@
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;
@@ -107,6 +112,10 @@
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})
@@ -764,6 +773,7 @@
dncLogService.save(dncLog);
return false;
}
+ //宸ュ簭澶╁姞閫昏緫
processCode = processCode.split("_")[0];
ProcessStream stream = processStreamService.findByProcessEquipment(equipmentId,
processCode,description,compTotal.getComponentId(),part.getPartsId());
@@ -857,4 +867,142 @@
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();
+ //涓嶈兘鐩存帴浠巇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) {
+ 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);
+ }
}
--
Gitblit v1.9.3