| | |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-flow-api</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.tika</groupId> |
| | | <artifactId>tika-core</artifactId> |
| | | <version>3.2.0</version> |
| | | </dependency> |
| | | <!--<dependency> |
| | | <groupId>org.springblade</groupId> |
| | | <artifactId>blade-starter-transaction</artifactId> |
| | |
| | | if (StringUtil.isNoneBlank(processInstanceId, comment)) { |
| | | taskService.addComment(taskId, processInstanceId, comment); |
| | | } |
| | | |
| | | |
| | | // éç©ºå¤æ |
| | | if (Func.isEmpty(variables)) { |
| | | variables = Kv.create(); |
| | |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.flow.excution.AutoAssignUsersService; |
| | | import org.springblade.mdm.flow.vo.TaskAssignVO; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private NcProgramService ncProgramService; |
| | | @Autowired |
| | | private NcNodeService ncNodeService; |
| | | @Autowired |
| | | private MachineService machineService; |
| | | /** |
| | | * åºåæµç¨çkey |
| | |
| | | */ |
| | | public void start(long programId){ |
| | | Map<String, Object> vars = new HashMap<>(); |
| | | NcProgram prog = ncProgramService.getById(programId); |
| | | Machine machine = machineService.getByCode(prog.getMachineCode()); |
| | | //NcProgram prog = ncProgramService.getById(programId); |
| | | NcNode progNode = ncNodeService.getById(programId); |
| | | Machine machine = machineService.getByCode(progNode.getMachineCode()); |
| | | vars.put("machineCode",machine.getCode()); |
| | | vars.put("machineMode",machine.getName()); |
| | | vars.put("processEdition",prog.getProcessEdition()); |
| | | vars.put("programId",prog.getProcessEdition()); |
| | | vars.put("program",prog); |
| | | vars.put("processEdition",progNode.getProcessEdition()); |
| | | vars.put("programId",programId); |
| | | vars.put("program",progNode); |
| | | |
| | | |
| | | //vars.put("processNo",startVO.getProcessNo());prog.getProcessEdition() |
| | | //vars.put("processName",startVO.getProcessName()); |
| | | /* |
| | | Map<String,Object> preAssignee = autoAssignUsersService.autoAssignUsers(startVO.getProducePlanId()); |
| | | Map<String, Object> vars = new HashMap<>(preAssignee); |
| | | |
| | | vars.put("machineCode",startVO.getMachineCode()); |
| | | vars.put("machineMode",startVO.getMachineMode()); |
| | | |
| | | vars.put("processNo",startVO.getProcessNo()); |
| | | vars.put("processName",startVO.getProcessName()); |
| | | vars.put("processEdition",startVO.getProcessEdition()); |
| | | |
| | | vars.put("craftEdition",startVO.getCraftEdition()); |
| | | vars.put("planStartTime",startVO.getPlanStartTime()); |
| | | vars.put("drawingNo",startVO.getDrawingNo()); |
| | | vars.put("drawingNoEdition",startVO.getDrawingNoEdition()); |
| | | vars.put("planLockDays",startVO.getPlanLockDays()); |
| | | |
| | | //é¶ç»ä»¶ä»£ç |
| | | String partNo = generatePartNo(startVO); |
| | | vars.put("partNo",partNo); |
| | | |
| | | NcProgram curedNcProgram = ncProgramService.getCuredNcProgram(partNo,startVO.getMachineCode()); |
| | | vars.put("curedNcProgram",curedNcProgram); |
| | | |
| | | //设置æ¯å¦æåºåç¨åºæ è®° |
| | | vars.put("hasCuredProgram",curedNcProgram != null ? "Y":"N"); |
| | | */ |
| | | String businessKey = "0";//ä¸å¡è¡¨key |
| | | |
| | | identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置æµç¨å起人 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.flow.service; |
| | | |
| | | import org.flowable.engine.IdentityService; |
| | | import org.flowable.engine.RuntimeService; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.flow.excution.AutoAssignUsersService; |
| | | import org.springblade.mdm.flow.vo.TaskAssignVO; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * åºåæµç¨æå¡ |
| | | */ |
| | | @Service |
| | | public class DispatchFlowService { |
| | | |
| | | @Autowired |
| | | private RuntimeService runtimeService; |
| | | @Autowired |
| | | private AutoAssignUsersService autoAssignUsersService; |
| | | @Autowired |
| | | private IdentityService identityService; |
| | | |
| | | @Autowired |
| | | private NcProgramService ncProgramService; |
| | | @Autowired |
| | | private MachineService machineService; |
| | | /** |
| | | * åºåæµç¨çkey |
| | | */ |
| | | private static final String PROCESS_KEY = "program-cure"; |
| | | |
| | | /** |
| | | * ç¼å¶èç¹éè¿åï¼æ£æ¥ç¨åºæ¯å¦åå¨ |
| | | * @param processInstanceId æµç¨å®ä¾id |
| | | */ |
| | | public boolean programExists(String processInstanceId) { |
| | | |
| | | return false; |
| | | } |
| | | |
| | | } |
| | |
| | | private NcProgramService ncProgramService; |
| | | public void execute(DelegateExecution execution) { |
| | | //空åçï¼æ°å å
¥ä¸æ¡ç¨åºæ°æ®ï¼å¹¶ä¸å°å·¥åºç次processEditionè®¾ç½®ä¸ºç¨æ·è¾å
¥çæ°çæ¬ |
| | | |
| | | /* |
| | | NcProgram ncProgram = (NcProgram)execution.getVariable("curedNcProgram"); |
| | | //å°ç°æç¨åºè®¾ç½®ä¸ºéææ°ç |
| | | ncProgram.setIsLastEdition(0); |
| | |
| | | ncProgramService.save(newNcProgram); |
| | | |
| | | log.info("空åçå®æï¼æ°çç¨åºid为{}",newNcProgram.getId()); |
| | | |
| | | */ |
| | | } |
| | | } |
| | |
| | | |
| | | package org.springblade.mdm.program.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.basesetting.machine.vo.MachineQueryVO; |
| | | import org.springblade.mdm.basesetting.machine.vo.MachineVO; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramQueryVO; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramVO; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | List<NcNodeVO> list = ncNodeService.lazyList(parentId); |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * å页 |
| | | */ |
| | | @Operation(summary = "ç¨åºå页æ¥è¯¢", description = "ç¨äºå¨ç¼å¶èç¹éæ©æµç¨å¯¹åºçç¨åº") |
| | | @GetMapping("/programpickpage") |
| | | public R<IPage<NcNodeProgramVO>> page(NcNodeProgramQueryVO query) { |
| | | IPage<NcNodeProgramVO> pages = ncNodeService.programPageQuery(query); |
| | | return R.data(pages); |
| | | } |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | @Operation(summary = "ä¸ä¼ ", description = "ä¸ä¼ ç¨åº/éä»¶æä»¶") |
| | | public R<Boolean> upload(@RequestParam MultipartFile file,Long nodeId, |
| | | @RequestParam String category) { |
| | | ncProgramService.uploadNcFile(file,nodeId,category); |
| | | ncProgramService.uploadProgramFile(file,nodeId,category); |
| | | return R.<Boolean>status(true); |
| | | } |
| | | |
| | | @PostMapping("/remove") |
| | | @Operation(summary = "å é¤ç¨åºæä»¶", description = "") |
| | | public R<Boolean> removeFile(Long id) { |
| | | try { |
| | | ncProgramService.removeProgram(id); |
| | | return R.success(); |
| | | }catch(Exception e) { |
| | | log.error("å é¤æä»¶å¤±è´¥",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/content") |
| | | @Operation(summary = "è·åæä»¶å
容", description = "ä»
éææ¬æ ¼å¼çå
容ï¼äºè¿å¶æä»¶å°è¿å空串") |
| | | public R<String> fileContent(Long id) { |
| | | try { |
| | | return R.data(ncProgramService.getFileContent(id)); |
| | | }catch(Exception e) { |
| | | log.error("å é¤æä»¶å¤±è´¥",e); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | |
| | | @PostMapping("/export-dnc") |
| | | @Operation(summary = "æ°æ§ç¨åºå¯¼åºdnc", description = "æ°æ§ç¨åºå¯¼åºå°å·¥æ§ç½") |
| | | public void exportDnc(Long nodeId, HttpServletResponse response) { |
| | | |
| | | //return R.<Boolean>status(true); |
| | | } |
| | | /* |
| | | @PostMapping("/import-dnc-file") |
| | | @Operation(summary = "ä¸ä¼ å·¥æ§ç½åä¼ æä»¶", description = "ä¸ä¼ ç¨åº/éä»¶æä»¶") |
| | | public R<Boolean> importDncFile(@RequestParam MultipartFile file) { |
| | | ncProgramService.uploadNcPkgFile(file); |
| | | return R.<Boolean>status(true); |
| | | |
| | | }*/ |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | |
| | | package org.springblade.mdm.program.controller; |
| | | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * ç¨åºæ¶å¯ç½-å·¥æ§ç½äº¤æ¢æ¥å£ |
| | | * |
| | | * @author yangys |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @RequestMapping("/program/exchange") |
| | | @AllArgsConstructor |
| | | @Tag(name = "导åºDNC", description = "æ¶å¯ç½æ²ç¼å¯¼åºDNC") |
| | | @Slf4j |
| | | public class NcProgramExportDNCController { |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | |
| | | @PostMapping("/export-dnc") |
| | | @Operation(summary = "æ°æ§ç¨åºå¯¼åºdnc", description = "æ°æ§ç¨åºå¯¼åºå°å·¥æ§ç½") |
| | | public void exportDnc(Long nodeId, HttpServletResponse response) { |
| | | |
| | | //return R.<Boolean>status(true); |
| | | } |
| | | |
| | | } |
| | |
| | | public class NcNode extends BizEntity { |
| | | private String name; |
| | | private Long parentId; |
| | | |
| | | /** |
| | | * ä¸çº§ç¶idéå |
| | | */ |
| | | private String parentIds; |
| | | /** |
| | | * 设å¤ç¼å· |
| | | */ |
| | | private String machineCode; |
| | | /** |
| | | * å¾å· |
| | | */ |
| | | private String drawingNo; |
| | | /** |
| | | * å¾å·ç次 |
| | | */ |
| | | private String drawingNoEdition; |
| | | |
| | | /** |
| | | * å·¥åºï¼å¦âç²¾é£â |
| | | */ |
| | | private String processName; |
| | | |
| | | /** |
| | | * å·¥åºç次 |
| | | */ |
| | | private String processEdition; |
| | | |
| | | /** |
| | | * å·¥èºç次 |
| | | */ |
| | | private String craftEdition; |
| | | /** |
| | | * é¶ç»ä»¶å· |
| | | */ |
| | | private String partNo; |
| | | |
| | | /** |
| | | * æ¯å¦åºå |
| | | */ |
| | | private Integer isCured; |
| | | /** |
| | | * è¿ææ¥æ |
| | | */ |
| | | private LocalDate expireDate; |
| | | /** |
| | | * æ¯å¦éå® |
| | | */ |
| | | private Integer isLocked; |
| | | /** |
| | | * èç¹ç±»åï¼åå
¸ |
| | | */ |
| | |
| | | private String description; |
| | | private String remark; |
| | | |
| | | |
| | | } |
| | |
| | | @Getter |
| | | @TableName("mdm_nc_program") |
| | | public class NcProgram extends BizEntity { |
| | | /** |
| | | * æä»¶å |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 对象åå¨ä¸çåç§° |
| | | */ |
| | | private String ossName; |
| | | private String code; |
| | | /** |
| | | * æå±èç¹idï¼å¿
é¡»æªâç¨åºå
å"çèç¹ |
| | | */ |
| | | private long ncNodeId; |
| | | /** |
| | | * ç¨åºå
å |
| | | */ |
| | | private String packageName; |
| | | //private String packageName; |
| | | /** |
| | | * æä»¶å°å |
| | | */ |
| | | private String url; |
| | | /** |
| | | * æä»¶ç±»å |
| | | */ |
| | | private String category; |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºææ¬ç±»å |
| | | */ |
| | | private Boolean isTextFile; |
| | | /** |
| | | * å·¥åºï¼å¦âç²¾é£â |
| | | */ |
| | | //private String processName; |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | //private String remark; |
| | | /** |
| | | * 设å¤ï¼æºåºï¼ç¼ç |
| | | */ |
| | | private String machineCode; |
| | | //private String machineCode; |
| | | /** |
| | | * é¶ç»ä»¶å· |
| | | */ |
| | | private String partNo; |
| | | //private String partNo; |
| | | |
| | | /** |
| | | * æ¯å¦åºå |
| | | */ |
| | | private Integer isCured; |
| | | //private Integer isCured; |
| | | /** |
| | | * è¿ææ¥æ |
| | | */ |
| | | private LocalDate expireDate; |
| | | //private LocalDate expireDate; |
| | | /** |
| | | * å·¥åºç次 |
| | | */ |
| | | private String processEdition; |
| | | //private String processEdition; |
| | | /** |
| | | * æ¯å¦ææ°ç次ï¼1ï¼ææ°ç次ï¼0:åå²ç次 |
| | | */ |
| | | private Integer isLastEdition; |
| | | //private Integer isLastEdition; |
| | | /** |
| | | * æ¯å¦éå® |
| | | */ |
| | |
| | | // |
| | | return taskAssignTime.plusMonths(effectiveMonths).isBefore(LocalDateTime.now()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package org.springblade.mdm.program.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.core.mp.mapper.BladeMapper; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramQueryVO; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramVO; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | |
| | | import java.util.List; |
| | |
| | | public interface NcNodeMapper extends BladeMapper<NcNode> { |
| | | List<NcNodeVO> lazyList(Long parentId); |
| | | |
| | | /** |
| | | * è·åææ°åºåç¨åº |
| | | * @param partNo é¶ç»ä»¶å· |
| | | * @param machineGroupCode æºåºç»ä»£ç |
| | | * @return |
| | | IPage<NcNodeProgramVO> programPageQuery(@Param("page")IPage<NcNodeProgramVO> page, @Param("query") NcNodeProgramQueryVO query); |
| | | |
| | | /** |
| | | * æ ¹æ®åç§°è·åææ°çç¨åºå
èç¹ |
| | | * @param name ç¨åºåç§°ï¼ç¨åºå
åç§°ï¼ |
| | | * @return ç¨åºèç¹ |
| | | */ |
| | | //NcProgram getCuredNcProgram(@Param("partNo")String partNo,@Param("machineGroupCode")String machineGroupCode); |
| | | NcNode getLastProgramNode(String name); |
| | | } |
| | |
| | | parent_id = n.id and is_deleted = 0 |
| | | ) AS "has_children" from mdm_nc_node n where is_deleted=0 and parent_id=#{parentId} |
| | | </select> |
| | | <select id="programPageQuery" resultType="org.springblade.mdm.program.vo.NcNodeProgramVO"> |
| | | select id,parent_id,machine_code,drawing_no,drawing_no_edition,part_no,process_name,craft_edition from mdm_nc_node n |
| | | <where> |
| | | <if test="query.name!=null and query.name!=''"> |
| | | and n.name like CONCAT('%', #{query.name,jdbcType=VARCHAR},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!--è·å ææ°çæ¬çç¨åºï¼å³ç¨åºå
å èç¹ node_type=60ï¼--> |
| | | <select id="getLastProgramNode" resultType="org.springblade.mdm.program.entity.NcNode"> |
| | | select <include refid="all_columns"/> from mdm_nc_node |
| | | where is_deleted=0 and node_type='60' and is_last_edition=1 order by create_time desc limit 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | * @param name ç¨åºåç§° |
| | | * @return ncç¨åº |
| | | */ |
| | | NcProgram getLastNcProgram(String name); |
| | | //NcProgram getLastNcProgram(String name); |
| | | } |
| | |
| | | order by create_time desc |
| | | limit 1 |
| | | </select> |
| | | <!-- |
| | | <select id="getLastNcProgram" resultType="org.springblade.mdm.program.entity.NcProgram"> |
| | | select <include refid="all_columns"/> from mdm_nc_program |
| | | where is_deleted=0 and is_last_edition=1 order by create_time desc limit 1 |
| | | </select> |
| | | --> |
| | | </mapper> |
| | |
| | | /** |
| | | * BladeX Commercial License Agreement |
| | | * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. |
| | | * <p> |
| | | * Use of this software is governed by the Commercial License Agreement |
| | | * obtained after purchasing a license from BladeX. |
| | | * <p> |
| | | * 1. This software is for development use only under a valid license |
| | | * from BladeX. |
| | | * <p> |
| | | * 2. Redistribution of this software's source code to any third party |
| | | * without a commercial license is strictly prohibited. |
| | | * <p> |
| | | * 3. Licensees may copyright their own code but cannot use segments |
| | | * from this software for such purposes. Copyright of this software |
| | | * remains with BladeX. |
| | | * <p> |
| | | * Using this software signifies agreement to this License, and the software |
| | | * must not be used for illegal purposes. |
| | | * <p> |
| | | * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is |
| | | * not liable for any claims arising from secondary or illegal development. |
| | | * <p> |
| | | * Author: Chill Zhuang (bladejava@qq.com) |
| | | */ |
| | | |
| | | package org.springblade.mdm.program.service; |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; |
| | | import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; |
| | | import org.apache.commons.compress.archivers.zip.ZipFile; |
| | | import org.apache.commons.compress.utils.IOUtils; |
| | | import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; |
| | | import org.flowable.engine.*; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.FileUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.flow.service.CureFlowService; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Enumeration; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class DncSendBackService { |
| | | |
| | | //private final RepositoryService repositoryService; |
| | | //private final RuntimeService runtimeService; |
| | | //private final HistoryService historyService; |
| | | //private final ProcessEngine processEngine; |
| | | private final NcNodeService ncNodeService; |
| | | private final NcProgramService ncProgramService; |
| | | private final CureFlowService cureFlowService; |
| | | private final NcProgramExchangeMapper ncProgramExchangeMapper; |
| | |
| | | public void dncFileAccept(String ids) { |
| | | List<Long> idList = Func.toLongList(ids); |
| | | NcProgramExchange exchange; |
| | | NcProgram program; |
| | | //NcProgram program; |
| | | NcNode programNode; |
| | | |
| | | for (Long id : idList) { |
| | | exchange = ncProgramExchangeMapper.selectById(id); |
| | | exchange.setStatus(2);//å·²å
¥åºç¶æ |
| | | program = ncProgramService.getLastNcProgram(exchange.getName()); |
| | | programNode = ncNodeService.getLastProgramNode(exchange.getName()); |
| | | |
| | | //妿æ¯å·²ç»åºåçåä¸éè¦å¯å¨æµç¨ |
| | | //å¯å¨åºåæµç¨ |
| | | if(program.getIsCured() !=1) {//æªåºåçç¨åºï¼å¯å¨åºåæµç¨ |
| | | cureFlowService.start(program.getId()); |
| | | if(programNode.getIsCured() !=1) {//æªåºåçç¨åºï¼å¯å¨åºåæµç¨ |
| | | cureFlowService.start(programNode.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | package org.springblade.mdm.program.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.vo.MachineVO; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.mapper.NcNodeMapper; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramQueryVO; |
| | | import org.springblade.mdm.program.vo.NcNodeProgramVO; |
| | | import org.springblade.mdm.program.vo.NcNodeVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | BeanUtils.copyProperties(vo, ncNode); |
| | | ncNode.setId(null); |
| | | ncNode.setParentIds(buildParentIds(vo.getParentId())); |
| | | |
| | | this.save(ncNode); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºç¶idèç¹ |
| | | * @param nodeId èç¹id |
| | | * @return |
| | | */ |
| | | String buildParentIds(long nodeId){ |
| | | if(nodeId == 0L){ |
| | | return "0"; |
| | | } |
| | | NcNode pNode = this.baseMapper.selectById(nodeId); |
| | | |
| | | return pNode.getParentIds()+","+pNode.getId(); |
| | | } |
| | | /** |
| | | * æ´æ°èç¹ |
| | | * @param vo |
| | |
| | | ncNode.setNodeType(vo.getNodeType()); |
| | | ncNode.setDescription(vo.getDescription()); |
| | | ncNode.setRemark(vo.getRemark()); |
| | | ncNode.setMachineCode(vo.getMachineCode()); |
| | | this.updateById(ncNode); |
| | | } |
| | | |
| | |
| | | |
| | | return baseMapper.lazyList(parentId); |
| | | } |
| | | |
| | | /** |
| | | * ç¨åºèç¹ |
| | | * @param query |
| | | * @return |
| | | */ |
| | | public IPage<NcNodeProgramVO> programPageQuery(NcNodeProgramQueryVO query) { |
| | | return this.getBaseMapper().programPageQuery(Condition.getPage(query),query); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç°æåºåçç¨åºï¼æå®æ¡ä»¶ï¼é¶ç»ä»¶å·ç¸åï¼ä¸æ¯å䏿ºåºç» |
| | | * * @param name ç¨åºåç§° |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public NcNode getLastProgramNode(String name) { |
| | | return this.getBaseMapper().getLastProgramNode(name); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | |
| | | package org.springblade.mdm.program.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; |
| | | import org.apache.commons.compress.archivers.zip.ZipFile; |
| | | import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; |
| | | 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.tool.utils.FileUtil; |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Enumeration; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ä¸å/åä¼ ç¨åºç»è®¡ |
| | | * |
| | | * @author yangys |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class NcProgramExportDNCService extends BizServiceImpl<NcProgramExchangeMapper, NcProgramExchange> { |
| | | |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ |
| | | * @param query æ¥è¯¢åæ° |
| | | * @return |
| | | */ |
| | | public IPage<DncSendBackData> dncSendBackPageQuery(Query query) { |
| | | |
| | | IPage<DncSendBackData> page = this.getBaseMapper().dncSendBackpageQuery(Condition.getPage(query),query); |
| | | |
| | | return page; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.flowable.engine.*; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.oss.OssTemplate; |
| | | import org.springblade.core.oss.model.BladeFile; |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.program.mapper.NcProgramMapper; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @AllArgsConstructor |
| | | public class NcProgramService extends BizServiceImpl<NcProgramMapper, NcProgram> { |
| | | |
| | | private final ObjectMapper objectMapper; |
| | | private final RepositoryService repositoryService; |
| | | private final RuntimeService runtimeService; |
| | | private final HistoryService historyService; |
| | | private final TaskService taskService; |
| | | private final ProcessEngine processEngine; |
| | | private final MachineService machineService; |
| | | |
| | | private final OssTemplate ossTemplate; |
| | | /** |
| | | * æ¥è¯¢ç°æåºåçç¨åºï¼æå®æ¡ä»¶ï¼é¶ç»ä»¶å·ç¸åï¼ä¸æ¯å䏿ºåºç» |
| | | * @param partNo |
| | |
| | | return this.getBaseMapper().getCuredNcProgram(partNo,machine.getMachineGroupCode()); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç°æåºåçç¨åºï¼æå®æ¡ä»¶ï¼é¶ç»ä»¶å·ç¸åï¼ä¸æ¯å䏿ºåºç» |
| | | * @param name ç¨åºåç§° |
| | | * @return |
| | | */ |
| | | public NcProgram getLastNcProgram(String name) { |
| | | return this.getBaseMapper().getLastNcProgram(name); |
| | | } |
| | | |
| | | /** |
| | | * ä¸ä¼ ç¨åºæä»¶å°æå®èç¹ |
| | | * @param file |
| | | * @param nodeId |
| | | * @param category |
| | | * @param category æä»¶åç±»ï¼ç¨åºæä»¶/å
¶ä»æä»¶ï¼ |
| | | */ |
| | | public void uploadNcFile(MultipartFile file, Long nodeId, String category) { |
| | | public void uploadProgramFile(MultipartFile file, Long nodeId, String category) { |
| | | BladeFile bfile = ossTemplate.putFile(file); |
| | | String link = bfile.getLink(); |
| | | //ä¿åprofame |
| | | NcProgram prog = new NcProgram(); |
| | | prog.setName(file.getOriginalFilename()); |
| | | prog.setNcNodeId(nodeId); |
| | | prog.setOssName(bfile.getName()); |
| | | boolean isTextFile = false; |
| | | try { |
| | | isTextFile = FileContentUtil.isTextFile(file.getInputStream()); |
| | | } catch (IOException e) { |
| | | log.warn("夿æ¯å¦ææ¬æä»¶å¼å¸¸",e); |
| | | } |
| | | prog.setIsTextFile(isTextFile); |
| | | prog.setUrl(link); |
| | | prog.setCategory(category); |
| | | |
| | | this.save(prog); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ä¸ä¸ªç¨åº |
| | | * @param id |
| | | */ |
| | | public String getFileContent(Long id) { |
| | | String result =""; |
| | | |
| | | NcProgram prog = this.getById(id); |
| | | String fileName = prog.getOssName(); |
| | | try (InputStream inputStream = ossTemplate.statFileStream(fileName)) { |
| | | result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * å é¤ä¸ä¸ªç¨åº |
| | | * @param id |
| | | */ |
| | | public void removeProgram(Long id) { |
| | | NcProgram prog = this.getById(id); |
| | | ossTemplate.removeFile(prog.getOssName()); |
| | | this.getBaseMapper().deleteById(id); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.program.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springblade.core.mp.support.Query; |
| | | |
| | | /** |
| | | * å页æçº¿å¢ |
| | | */ |
| | | |
| | | @Schema(description = "æºåºåä¼ æä»¶æ¥è¯¢å¯¹è±¡") |
| | | @Setter |
| | | @Getter |
| | | public class NcNodeProgramQueryVO extends Query { |
| | | @Schema(description = "ç¨åºåç§°") |
| | | private String name; |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.program.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springblade.mdm.commons.vo.BaseVO; |
| | | |
| | | @Setter |
| | | @Getter |
| | | public class NcNodeProgramVO extends BaseVO { |
| | | @Schema(description = "èç¹åç§°") |
| | | private String name; |
| | | @Schema(description = "ç¶ID,æ ¹èç¹ç¶id=0") |
| | | private Long parentId; |
| | | @Schema(description = "设å¤ç¼å·") |
| | | private String machineCode; |
| | | @Schema(description = "èç¹ç±»åï¼åå
¸(ç¨åºèç¹ç±»ånc_node_type)") |
| | | private String nodeType; |
| | | @Schema(description = "æè¿°") |
| | | private String description; |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | |
| | | @Schema(description = "å¾å·") |
| | | private String drawingNo; |
| | | |
| | | @Schema(description = "å¾å·ç次") |
| | | private String drawingNoEdition; |
| | | |
| | | @Schema(description = "å·¥åºï¼å¦âç²¾é£â") |
| | | private String processName; |
| | | |
| | | @Schema(description = "å·¥èºç次") |
| | | private String craftEdition; |
| | | |
| | | @Schema(description = "é¶ç»ä»¶å·") |
| | | private String partNo; |
| | | } |
| | |
| | | private String name; |
| | | @Schema(description = "ç¶ID,æ ¹èç¹ç¶id=0") |
| | | private Long parentId; |
| | | @Schema(description = "设å¤ç¼å·") |
| | | private String machineCode; |
| | | @Schema(description = "èç¹ç±»åï¼åå
¸(ç¨åºèç¹ç±»ånc_node_type)") |
| | | private String nodeType; |
| | | @Schema(description = "æ¯å¦æåèç¹") |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.utils; |
| | | |
| | | import org.apache.tika.Tika; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | public class FileContentUtil { |
| | | |
| | | /** |
| | | * 夿æ¯å¦ææ¬ç±»å |
| | | * @param inputStream |
| | | * @return |
| | | */ |
| | | public static boolean isTextFile(InputStream inputStream) { |
| | | Tika tika = new Tika(); |
| | | try { |
| | | String mimeType = tika.detect(inputStream); |
| | | //String mimeType = tika.detect(file); |
| | | return mimeType.startsWith("text/") |
| | | || mimeType.equals("application/xml") |
| | | || mimeType.equals("application/json"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | |
| | | `id` bigint NOT NULL, |
| | | `tenant_id` varchar(6) DEFAULT NULL COMMENT 'æå±ç§æ·', |
| | | `name` varchar(100) NOT NULL COMMENT 'èç¹åç§°', |
| | | `drawing_no` varchar(40) NULL COMMENT 'å¾å·', |
| | | `process_name` varchar(20) NULL COMMENT 'å·¥åºåç§°', |
| | | `machine_code` varchar(100) DEFAULT NULL COMMENT '设å¤ç¼å·/æºåºç¼å·', |
| | | `part_no` varchar(100) NULL COMMENT 'é¶ç»ä»¶ç¼å·', |
| | | `is_cured` int DEFAULT NULL COMMENT 'æ¯å¦åºå,1æ¯;0å¦', |
| | | `expire_date` date DEFAULT NULL COMMENT 'å°ææ¶é´,æ ¹æ®ææææ¶é¿è®¡ç®èæ¥', |
| | | `process_edition` varchar(40) DEFAULT NULL COMMENT 'å·¥åºç次ï¼åçå°±æ¯åæ´æ¹è¯¥å段ï¼éè¦ä¿çåå²è®°å½', |
| | | `description` varchar(100) NOT NULL COMMENT 'æè¿°', |
| | | `remark` varchar(200) NOT NULL COMMENT '夿³¨', |
| | | `parent_id` bigint DEFAULT NULL COMMENT 'æå±æºåºç»ID', |
| | | `parent_id` bigint DEFAULT NULL COMMENT 'ä¸çº§èç¹ID', |
| | | `parent_ids` varchar(100) DEFAULT NULL COMMENT 'ä¸çº§èç¹IDéåï¼idéå·åé', |
| | | `node_type` varchar(20) DEFAULT NULL COMMENT 'èç¹ç±»åï¼ä¸å¡åå
¸å®ä¹', |
| | | `status` int DEFAULT NULL COMMENT 'ä¸å¡ç¶æ', |
| | | `create_dept` bigint DEFAULT NULL COMMENT 'å建åä½', |
| | |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='ç¨åºèç¹ç®å½'; |
| | | |
| | | /**æµç¨å®ä¾ä¸èç¹å
³è表ï¼è®°å½åå»ºæ¶æºï¼ç¨æ·å¨ç¨åºç¼å¶èç¹æå¨å
³è*/ |
| | | DROP TABLE IF EXISTS `mdm_process_node_ref`; |
| | | CREATE TABLE `mdm_process_node_ref` ( |
| | | `id` bigint NOT NULL, |
| | | `tenant_id` varchar(6) DEFAULT NULL COMMENT 'æå±ç§æ·', |
| | | `nc_node_id` bigint DEFAULT NULL COMMENT 'èç¹idï¼å¯¹åº ç¨åºå
å èç¹id', |
| | | `process_instance_id` varchar(100) NOT NULL COMMENT 'æµç¨å®ä¾id', |
| | | `status` int DEFAULT NULL COMMENT 'ä¸å¡ç¶æ', |
| | | `create_dept` bigint DEFAULT NULL COMMENT 'å建åä½', |
| | | `is_deleted` int DEFAULT NULL, |
| | | `create_time` datetime DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `create_user` bigint DEFAULT NULL COMMENT 'å建人', |
| | | `update_time` datetime DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `update_user` bigint DEFAULT NULL COMMENT 'æ´æ°äºº', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='æµç¨å®ä¾ä¸èç¹å
³è表'; |
| | | |
| | | |
| | | |
| | | DROP TABLE IF EXISTS `mdm_nc_program`; |
| | | CREATE TABLE `mdm_nc_program` ( |
| | | `id` bigint NOT NULL, |
| | | `tenant_id` varchar(6) DEFAULT NULL COMMENT 'æå±ç§æ·', |
| | | `nc_node_id` bigint DEFAULT NULL COMMENT 'æå±èç¹id', |
| | | `nc_node_id` bigint DEFAULT NULL COMMENT 'æå±èç¹idï¼åºè¯¥å±äºæä¸ªæ°æ§ç¨åºèç¹', |
| | | `code` varchar(100) NOT NULL COMMENT 'ç¨åºç¼å·', |
| | | `name` varchar(100) NOT NULL COMMENT 'ç¨åºåç§°', |
| | | `package_name` varchar(100) NOT NULL COMMENT 'ç¨åºå
å', |
| | | `oss_name` varchar(100) NULL COMMENT 'ossä¸çæä»¶å', |
| | | `category` varchar(2) NULL COMMENT 'æä»¶åç±»', |
| | | |
| | | `drawing_no` varchar(40) NULL COMMENT 'å¾å·', |
| | | `process_name` varchar(20) NULL COMMENT 'å·¥åºåç§°', |
| | | `remark` varchar(100) NULL COMMENT '夿³¨', |
| | | `is_text_file` int DEFAULT NULL COMMENT 'æ¯å¦ææ¬æä»¶', |
| | | `url` varchar(400) NOT NULL COMMENT 'æä»¶å°å', |
| | | `machine_code` bigint DEFAULT NULL COMMENT '设å¤ç¼å·/æºåºç¼å·', |
| | | `part_no` varchar(100) NOT NULL COMMENT 'é¶ç»ä»¶ç¼å·', |
| | | `machine_code` varchar(100) DEFAULT NULL COMMENT '设å¤ç¼å·/æºåºç¼å·', |
| | | `part_no` varchar(100) NULL COMMENT 'é¶ç»ä»¶ç¼å·', |
| | | `is_cured` int DEFAULT NULL COMMENT 'æ¯å¦åºå,1æ¯;0å¦', |
| | | `expire_date` date DEFAULT NULL COMMENT 'å°ææ¶é´,æ ¹æ®ææææ¶é¿è®¡ç®èæ¥', |
| | | `process_edition` varchar(40) DEFAULT NULL COMMENT 'å·¥åºç次ï¼åçå°±æ¯åæ´æ¹è¯¥å段ï¼éè¦ä¿çåå²è®°å½', |
| | |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='æ°æ§ç¨åº'; |
| | | |
| | | |
| | | DROP TABLE IF EXISTS `mdm_nc_program_approved`; |
| | | CREATE TABLE `mdm_nc_program_approved` ( |
| | | `id` bigint NOT NULL, |
| | | `tenant_id` varchar(6) DEFAULT NULL COMMENT 'æå±ç§æ·', |
| | | `program_name` varchar(100) NOT NULL COMMENT 'ç¨åºåç§°', |
| | | `program_id` bigint NOT NULL COMMENT 'ç¨åºid,æåææ°çç¨åºè®°å½', |
| | | `status` int DEFAULT NULL COMMENT 'ä¸å¡ç¶æ', |
| | | `exchange_type` int DEFAULT NULL COMMENT '交æ¢ç±»å,1:ä¸å;2:åºå(dncåä¼ )', |
| | | `create_dept` bigint DEFAULT NULL COMMENT 'å建åä½', |
| | | `is_deleted` int DEFAULT NULL, |
| | | `create_time` datetime DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `create_user` bigint DEFAULT NULL COMMENT 'å建人', |
| | | `update_time` datetime DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `update_user` bigint DEFAULT NULL COMMENT 'æ´æ°äºº', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='æ°æ§ç¨åºå®¡æ¹è¡¨'; |
| | | |
| | | |
| | | |
| | | DROP TABLE IF EXISTS `mdm_nc_program_exchange`; |
| | | CREATE TABLE `mdm_nc_program_exchange` ( |
| | | `id` bigint NOT NULL, |