| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.flowable.engine.*; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | public IPage<NcProgramVO> pageQuery(NcNodeProgramQueryVO query) { |
| | | return this.getBaseMapper().pageQuery(Condition.getPage(query),query); |
| | | } |
| | | |
| | | /** |
| | | * 下发给你机床 |
| | | * @param bindNcNodeId 与程序绑定的节点id |
| | | */ |
| | | public void sendByBindNodeId(Long bindNcNodeId) throws IOException { |
| | | //NcNode node = this.nodeService.getById(bindNodeId); |
| | | LambdaQueryWrapper<NcProgram> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(NcProgram::getBindNcNodeId, bindNcNodeId); |
| | | wrapper.eq(NcProgram::getIsLastEdition,1); |
| | | NcProgram prog = this.getOne(wrapper); |
| | | String filePath = prog.getName(); |
| | | try(InputStream ins = ossTemplate.statFileStream(prog.getOssName());){ |
| | | File targetFile = new File(filePath); |
| | | FileUtils.copyInputStreamToFile(ins, targetFile); |
| | | } |
| | | } |
| | | |
| | | String getFilePath(NcProgram prog){ |
| | | Machine machine = machineService.getByCode(prog.getMachineCode()); |
| | | String dirPath = machine.getProgSendDir(); |
| | | |
| | | dirPath = StringUtils.removeEnd(StringUtils.removeEnd(dirPath,"/"),"\\"); |
| | | File dirs = new File(dirPath); |
| | | if(!dirs.exists()){ |
| | | dirs.mkdirs(); |
| | | } |
| | | |
| | | return dirPath+File.separator+prog.getName(); |
| | | } |
| | | } |