From 8a0db337026a6ab4587766a52761722fae5b2da1 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期六, 02 八月 2025 12:34:53 +0800
Subject: [PATCH] 程序上传接口,验证通过
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowProgramFileService.java | 93 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 88 insertions(+), 5 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowProgramFileService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowProgramFileService.java
index f74c5d5..a4593ff 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowProgramFileService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/FlowProgramFileService.java
@@ -11,11 +11,16 @@
import org.springblade.core.mp.base.BizServiceImpl;
import org.springblade.core.oss.OssTemplate;
import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.IResultCode;
+import org.springblade.core.tool.api.ResultCode;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.NumberUtil;
import org.springblade.mdm.flow.entity.FlowProgramFile;
import org.springblade.mdm.flow.mapper.FlowProgramFileMapper;
import org.springblade.mdm.flow.vo.ProgramUploadVO;
import org.springblade.mdm.program.entity.NcProgram;
import org.springblade.mdm.program.service.ProcessProgRefService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -32,11 +37,14 @@
*/
@Slf4j
@Service
-@AllArgsConstructor
public class FlowProgramFileService extends BizServiceImpl<FlowProgramFileMapper, FlowProgramFile> {
- private final OssTemplate ossTemplate;
- private final RuntimeService runtimeService;
- private final FlowCommonService flowCommonService;
+ @Autowired
+ private OssTemplate ossTemplate;
+ @Autowired
+ private RuntimeService runtimeService;
+ @Autowired
+ private FlowCommonService flowCommonService;
+
public void uploadFlowProgramFile(ProgramUploadVO uploadVO) {
//Map<String, Object> vars = runtimeService.getVariables(uploadVO.getProcessInstanceId());
@@ -84,11 +92,86 @@
}
}
+ /**
+ * 妫�鏌ユ枃浠跺悕鍚堟硶鎬�
+ * @param filename
+ * @param programProperties
+ */
void checkFilename(String filename,FlowProgramProperties programProperties){
//绋嬪簭鍚嶇О锛氶浂浠跺彿鍔犲伐搴忓彿锛屾枃浠跺悕搴旇浠ユ寮�澶�
String expectedProgramName = programProperties.getDrawingNo()+"-"+programProperties.getProcessNo();
if(!StringUtils.startsWith(filename,expectedProgramName)){
- throw new ServiceException("绋嬪簭鏂囦欢鍚嶄笉鍚堟硶锛屽簲涓猴細"+expectedProgramName+"-"+programProperties.getCraftEdition()+"-[娈垫暟]-[娈靛彿].[鏂囦欢鎵╁睍鍚峕");
+
+ IResultCode rc = new IResultCode() {
+ @Override
+ public String getMessage() {
+ return "绋嬪簭鏂囦欢鍚嶄笉鍚堟硶锛屽簲涓猴細"+expectedProgramName+"-"+programProperties.getCraftEdition()+"-[娈垫暟]-[娈靛彿].[鏂囦欢鎵╁睍鍚峕";
+ }
+
+ @Override
+ public int getCode() {
+ return 1;
+ }
+ };
+ throw new ServiceException(rc);
+ //throw new ServiceException("绋嬪簭鏂囦欢鍚嶄笉鍚堟硶锛屽簲涓猴細"+expectedProgramName+"-"+programProperties.getCraftEdition()+"-[娈垫暟]-[娈靛彿].[鏂囦欢鎵╁睍鍚峕");
+ }
+
+ //鎴彇鍚庨潰鐨勬鏁板拰绗嚑娈�
+ String endPart = StringUtils.removeStart(filename,expectedProgramName+"-"+programProperties.getCraftEdition()+"-");
+
+ //鍘绘帀鎵╁睍鍚�
+ if(endPart.contains(".")){
+ endPart = endPart.substring(0,endPart.indexOf("."));
+ }
+
+ int sepCount = StringUtils.countMatches(endPart,"-");
+ if(sepCount != 1){//- 鍙峰簲璇ユ槸1涓�
+ IResultCode rc = new IResultCode() {
+ @Override
+ public String getMessage() {
+ return "绋嬪簭鏂囦欢鍚嶄笉鍚堟硶锛屽簲涓猴細"+expectedProgramName+"-"+programProperties.getCraftEdition()+"-[娈垫暟]-[娈靛彿].[鏂囦欢鎵╁睍鍚峕";
+ }
+
+ @Override
+ public int getCode() {
+ return 2;
+ }
+ };
+ throw new ServiceException(rc);
+ //throw new ServiceException("绋嬪簭鏂囦欢鍚嶄笉鍚堟硶锛屽簲涓猴細"+expectedProgramName+"-"+programProperties.getCraftEdition()+"-[娈垫暟]-[娈靛彿].[鏂囦欢鎵╁睍鍚峕");
+ }
+
+ String[] arr = StringUtils.split(endPart,"-");
+ if(!StringUtils.isNumeric(arr[0]) || Func.toInt(arr[0]) >99 || Func.toInt(arr[0]) < 1){
+ IResultCode rc = new IResultCode() {
+ @Override
+ public String getMessage() {
+ return "绋嬪簭娈垫暟涓嶅悎娉曪紝搴斾负涓や綅浠ュ唴鏁存暟";
+ }
+
+ @Override
+ public int getCode() {
+ return 3;
+ }
+ };
+ throw new ServiceException(rc);
+ }
+ int segCount = Func.toInt(arr[0]);
+
+ if(!StringUtils.isNumeric(arr[1]) || Func.toInt(arr[1]) < 1 || Func.toInt(arr[1]) > segCount){
+ IResultCode rc = new IResultCode() {
+ @Override
+ public String getMessage() {
+ return "绋嬪簭娈靛彿涓嶅悎娉曪紝搴斾负涓や綅浠ュ唴鏁存暟涓斿皬浜庣瓑浜庢鏁般��";
+ }
+
+ @Override
+ public int getCode() {
+ return 4;
+ }
+ };
+ throw new ServiceException(rc);
}
}
--
Gitblit v1.9.3