From 1930b4e59d60c015ffa7bfee92e4bc227b90dcb3 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 28 五月 2025 15:41:41 +0800 Subject: [PATCH] 1.Dnc产品结构树检索nc文件 2.新增批次功能 3.新增审签查询流程 4.修改刀具系统查询 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 139 insertions(+), 0 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java index 8422256..07d23d7 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java @@ -5,20 +5,42 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.dnc.entity.Cutter; +import org.jeecg.modules.dnc.entity.DocFile; +import org.jeecg.modules.dnc.entity.DocInfo; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.mapper.CutterMapper; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.service.ICutterService; +import org.jeecg.modules.dnc.service.IDocFileService; +import org.jeecg.modules.dnc.service.IDocInfoService; import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.system.service.ISysDictService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; @Service +@Slf4j public class CutterServiceImpl extends ServiceImpl<CutterMapper, Cutter> implements ICutterService { + + @Autowired + private IDocInfoService docInfoService; + + @Autowired + private IDocFileService docFileService; + + @Autowired + private ISysDictService sysDictService; /** * 鏂板鍒�鍏蜂俊鎭� @@ -108,6 +130,8 @@ queryWrapper.eq(StrUtil.isNotEmpty(cutter.getAttributionId()),"attribution_id",cutter.getAttributionId()); queryWrapper.eq("attribution_type",cutter.getAttributionType()); queryWrapper.eq(StrUtil.isNotEmpty(cutter.getCutterCode()),"cutter_code",cutter.getCutterCode()); + queryWrapper.eq(StrUtil.isNotEmpty(cutter.getCutterType()),"cutter_type",cutter.getCutterType()); + queryWrapper.eq(StrUtil.isNotEmpty(cutter.getCutterSpacing()),"cutter_spacing",cutter.getCutterSpacing()); return baseMapper.selectList(queryWrapper); } @@ -123,6 +147,7 @@ if (cutter.getAttributionType() != null){ queryWrapper.eq("attribution_type",cutter.getAttributionType()); } + queryWrapper.eq(StrUtil.isNotEmpty(cutter.getDocId()),"doc_id",cutter.getDocId()); queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterCode()),"cutter_code",cutter.getCutterCode()); queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterName()),"cutter_name",cutter.getCutterName()); queryWrapper.orderByDesc("create_time"); @@ -130,4 +155,118 @@ IPage<Cutter> cutterIPage = baseMapper.selectPage(page, queryWrapper); return Result.OK(cutterIPage); } + + /** + * 浠嶯C鏂囦欢鍐呭鎻愬彇鍒�鍏蜂俊鎭苟淇濆瓨 + */ + @Override + @Transactional + public Result<?> extractAndSaveFromContent(String docId,String attributionId,Integer attributionType){ + DocInfo docInfo=docInfoService.getById(docId); + if (docInfo == null) { + return Result.error("鏈壘鍒板搴旀枃妗d俊鎭紝鏃犳硶鎻愬彇鍒�鍏蜂俊鎭�"); + } + docInfo.setAttributionId(attributionId); + docInfo.setAttributionType(attributionType); + DocFile docFile=docFileService.getById(docInfo.getPublishFileId()); + if (docFile == null) { + return Result.error("鏈壘鍒板搴旀枃浠朵俊鎭紝鏃犳硶鎻愬彇鍒�鍏蜂俊鎭�"); + } + String filePath = docFile.getFilePath(); + String fileEncodeName = docFile.getFileEncodeName(); + //鏂囨。鍐呭 + List<String> list = FileUtilS.readFile(fileEncodeName, filePath); + if (list == null || list.isEmpty()) { + return Result.error("鏂囨。鍐呭涓虹┖锛屾棤娉曟彁鍙栧垁鍏蜂俊鎭�"); + } + List<Cutter> cutterList = extractToolAfterM6(docInfo,list); + // 淇濆瓨鍒�鍏� + if (!cutterList.isEmpty()) { + this.saveBatch(cutterList); + //TODO鍙戦�佸垁鍏风鐞嗘暟鎹� + return Result.OK("鎻愬彇鍒�鍏蜂俊鎭垚鍔�"); + }else { + return Result.error("鏈彂鐜板垁鍏风殑鍙傛暟淇℃伅娉ㄩ噴锛屾棤娉曟彁鍙栧垁鍏蜂俊鎭�"); + } + } + + public List<Cutter> extractToolAfterM6(DocInfo docInfo, List<String> ncLines) { + List<Cutter> cutterList = new ArrayList<>(); + String currentToolCode = null; // 鐢ㄤ簬杩借釜褰撳墠鎹㈠垁鎸囦护鐨勫垁鍏峰彿 + + for (String line : ncLines) { + String trimmedLine = line.trim(); + + // 1. 鍖归厤 M6 鎹㈠垁鎸囦护锛屾彁鍙� T浠g爜锛堝 T01 M06 鎴� T 02 M06锛� + if (trimmedLine.contains("M6")||trimmedLine.contains("M06")) { + currentToolCode = extractToolCodeFromM6Line(trimmedLine); + } + + // 2. 鍖归厤鍒�鍏峰弬鏁版敞閲婏紙绱ц窡鍦� M6 鍚庣殑鎷彿鍐呭锛� + if (currentToolCode != null && trimmedLine.startsWith("(") && trimmedLine.endsWith(")")) { + String toolDescription = trimmedLine.substring(1, trimmedLine.length() - 1).trim(); + if (!toolDescription.isEmpty()) { + Cutter cutter = new Cutter(); + cutter.setDocId(docInfo.getDocId()); + cutter.setAttributionId(docInfo.getAttributionId()); + cutter.setAttributionType(docInfo.getAttributionType()); + cutter.setDescription(toolDescription); + + // 浠庡垁鍏锋弿杩颁腑鎻愬彇 cutterCode (渚嬪浠� "90E-10A" 涓彁鍙� "E") + extractToolInfoFromDescription(toolDescription, cutter); + + // 璁剧疆鍒�鍏烽棿璺濓紙浣跨敤T浠g爜鎴栧叾浠栭�昏緫锛� + cutter.setCutterSpacing(currentToolCode); + + // 鎷嗗垎鍒�鍏峰悕绉颁笌瑙勬牸锛堢畝鍗曟寜绌烘牸鍒嗗壊锛屽墠閮ㄥ垎涓哄悕绉帮紝鍚庨儴鍒嗕负瑙勬牸锛� + String[] parts = toolDescription.split(" ", 2); + if (parts.length >= 1) { + cutter.setCutterName(parts[0]); + } + cutterList.add(cutter); + currentToolCode = null; // 閲嶇疆锛岄伩鍏嶉噸澶嶅尮閰� + } + } + } + + return cutterList; + } + + /** + * 浠庡垁鍏锋弿杩颁腑鎻愬彇 cutterType 鍜� cutterCode + * 渚嬪: "8CH-90A" -> cutterType="CH", cutterCode="90A" + */ + private void extractToolInfoFromDescription(String description, Cutter cutter) { + // 鎻愬彇鍒�鍏峰瀷鍙凤紙涓�涓垨澶氫釜杩炵画鐨勫ぇ鍐欏瓧姣嶏級 + String cutterType = extractCutterType(description); + cutter.setCutterType(cutterType); + // 鎻愬彇鐮存姌鍙峰悗鐨勮鏍奸儴鍒� + String cutterSpec = ""; + int dashIndex = description.indexOf('-'); + if (dashIndex != -1 && dashIndex < description.length() - 1) { + cutterSpec = description.substring(dashIndex + 1).trim(); + cutter.setCutterSpec(cutterSpec); + } + } + + /** + * 鎻愬彇鍒�鍏峰瀷鍙凤紙涓�涓垨澶氫釜杩炵画鐨勫ぇ鍐欏瓧姣嶏級 + */ + private String extractCutterType(String description) { + Pattern pattern = Pattern.compile("[A-Z]+"); + Matcher matcher = pattern.matcher(description); + + if (matcher.find()) { + return matcher.group(); + } + + return description; + } + + // 杈呭姪鏂规硶锛氫粠 M6 琛屾彁鍙� T浠g爜锛堟敮鎸� T01 鎴� T 01 鏍煎紡锛� + private String extractToolCodeFromM6Line(String line) { + Matcher matcher = Pattern.compile("T(\\d+)").matcher(line); + return matcher.find() ? "T" + matcher.group(1).trim() : null; + } } + -- Gitblit v1.9.3