From 9858d97e0814bf61b97c937ef209222403fa1f27 Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期五, 04 七月 2025 02:43:31 +0800 Subject: [PATCH] dnc导出修改 --- blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java | 70 +++++++++++++++++++++++++++++++++- 1 files changed, 67 insertions(+), 3 deletions(-) diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java index 46c4b00..3b5791f 100644 --- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java +++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramApprovedService.java @@ -8,11 +8,13 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.compress.archivers.zip.ZipUtil; +import org.apache.commons.lang3.StringUtils; import org.springblade.core.mp.base.BizEntity; import org.springblade.core.mp.base.BizServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.oss.OssTemplate; +import org.springblade.core.tool.utils.Func; import org.springblade.mdm.flow.entity.ApproveRecord; import org.springblade.mdm.flow.service.ApproveRecordService; import org.springblade.mdm.program.entity.NcNode; @@ -91,10 +93,47 @@ * @param zipOut */ void addDataJson(ZipOutputStream zipOut, List<Long> programIdList) throws IOException { - // + addProgramDataJson(zipOut, programIdList); addApproveRecordDataJson(zipOut, programIdList); addNcNodeDataJson(zipOut, programIdList); + } + + /** + * 瀵煎叆绋嬪簭璁板綍 + * @param zipOut + * @param programIdList + */ + void addProgramDataJson(ZipOutputStream zipOut, List<Long> programIdList) throws IOException { + LambdaQueryWrapper<NcProgram> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(NcProgram::getId, programIdList); + List<NcProgram> programList = progService.list(queryWrapper); + JSONArray jsonArray = new JSONArray(); + for(NcProgram program : programList){ + JSONObject recObj = new JSONObject(); + recObj.put("id", program.getId()); + recObj.put("code", program.getCode()); + recObj.put("ossName",program.getOssName()); + recObj.put("isTextFile",program.getIsTextFile()); + recObj.put("category",program.getCategory()); + recObj.put("description",program.getDescription()); + recObj.put("name",program.getName()); + recObj.put("partNo",program.getPartNo()); + recObj.put("ncNodeId",program.getNcNodeId()); + recObj.put("url",program.getUrl()); + recObj.put("isCured",program.getIsCured()); + recObj.put("isLocked",program.getIsLocked()); + recObj.put("isTest",program.getIsTest()); + recObj.put("machineCode",program.getMachineCode()); + recObj.put("processEdition",program.getProcessEdition()); + recObj.put("taskAssignTime",program.getTaskAssignTime()); + + addSuperProperties(recObj,program); + + jsonArray.add(recObj); + } + addInputStreamToZip(zipOut,new ByteArrayInputStream(jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8)),"exp_mdm_nc_program.json"); + } /** @@ -138,28 +177,53 @@ List<NcProgram> programs = progService.list(queryWrapper); JSONArray jsonArray = new JSONArray(); - ArrayList<NcNode> nodeList = new ArrayList<>(); + + ArrayList<Long> exportNodeIdList = new ArrayList<>(); for(NcProgram program : programs){ JSONObject recObj = new JSONObject(); + if(!exportNodeIdList.contains(program.getNcNodeId())){ + exportNodeIdList.add(program.getNcNodeId()); + } NcNode ncNode = ncNodeService.getById(program.getNcNodeId()); - nodeList.add(ncNode); + if(StringUtils.isNotEmpty(ncNode.getParentIds())){ + List<Long> pids = Func.toLongList(ncNode.getParentIds()); + for(Long nodeId : pids){ + if(!exportNodeIdList.contains(nodeId)){ + exportNodeIdList.add(nodeId); + } + } + + } } + LambdaQueryWrapper<NcNode> nodeQueryWrapper = new LambdaQueryWrapper<>(); + nodeQueryWrapper.in(NcNode::getId, exportNodeIdList); + List<NcNode> nodeList =ncNodeService.list(nodeQueryWrapper); for(NcNode node : nodeList){ JSONObject recObj = new JSONObject(); recObj.put("id", node.getId()); recObj.put("nodeType", node.getNodeType()); recObj.put("machineCode",node.getMachineCode()); + recObj.put("parentId",node.getParentId()); + recObj.put("description",node.getDescription()); + recObj.put("name",node.getName()); + recObj.put("remark",node.getRemark()); + recObj.put("partNo",node.getPartNo()); + recObj.put("parentIds",node.getParentIds()); + recObj.put("processName",node.getProcessName()); addSuperProperties(recObj,node); + + jsonArray.add(recObj); } addInputStreamToZip(zipOut,new ByteArrayInputStream(jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8)),"exp_mdm_nc_node.json"); } void addSuperProperties(JSONObject recObj, BizEntity entity){ + recObj.put("tenantId",entity.getTenantId()); recObj.put("createTime",entity.getCreateTime()); recObj.put("updateTime",entity.getUpdateTime()); recObj.put("createUser",entity.getCreateUser()); -- Gitblit v1.9.3