154 lines
5.4 KiB
Java
154 lines
5.4 KiB
Java
package com.ruoyi.system.controller;
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.PageQuery;
|
|
import com.ruoyi.common.core.domain.R;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
import com.ruoyi.common.core.validate.EditGroup;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.system.domain.bo.CutProblemCreationBo;
|
|
import com.ruoyi.system.domain.vo.CutProblemCreationVo;
|
|
import com.ruoyi.system.service.ICutProblemCreationService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.constraints.NotEmpty;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.io.*;
|
|
import java.util.*;
|
|
|
|
/**
|
|
* 切割问题创建
|
|
*
|
|
* @author ruoyi
|
|
* @date 2024-06-21
|
|
*/
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RequestMapping("/system/problemCreation")
|
|
public class CutProblemCreationController extends BaseController {
|
|
|
|
private final ICutProblemCreationService iCutProblemCreationService;
|
|
|
|
/**
|
|
* 查询切割问题创建列表
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:list")
|
|
@GetMapping("/list")
|
|
public TableDataInfo<CutProblemCreationVo> list(CutProblemCreationBo bo, PageQuery pageQuery) {
|
|
return iCutProblemCreationService.queryPageList(bo, pageQuery);
|
|
}
|
|
|
|
/**
|
|
* 导出切割问题创建列表
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:export")
|
|
@Log(title = "切割问题创建", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(CutProblemCreationBo bo, HttpServletResponse response) {
|
|
List<CutProblemCreationVo> list = iCutProblemCreationService.queryList(bo);
|
|
ExcelUtil.exportExcel(list, "切割问题创建", CutProblemCreationVo.class, response);
|
|
}
|
|
|
|
/**
|
|
* 获取切割问题创建详细信息
|
|
*
|
|
* @param id 主键
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:query")
|
|
@GetMapping("/{id}")
|
|
public R<CutProblemCreationVo> getInfo(@NotNull(message = "主键不能为空")
|
|
@PathVariable Long id) {
|
|
return R.ok(iCutProblemCreationService.queryById(id));
|
|
}
|
|
|
|
/**
|
|
* 新增切割问题创建
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:add")
|
|
@Log(title = "切割问题创建", businessType = BusinessType.INSERT)
|
|
@RepeatSubmit()
|
|
@PostMapping()
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody CutProblemCreationBo bo) {
|
|
|
|
return toAjax(iCutProblemCreationService.insertByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 修改切割问题创建
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:edit")
|
|
@Log(title = "切割问题创建", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping()
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody CutProblemCreationBo bo) {
|
|
return toAjax(iCutProblemCreationService.updateByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 删除切割问题创建
|
|
*
|
|
* @param ids 主键串
|
|
*/
|
|
@SaCheckPermission("system:problemCreation:remove")
|
|
@Log(title = "切割问题创建", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}")
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] ids) {
|
|
return toAjax(iCutProblemCreationService.deleteWithValidByIds(Arrays.asList(ids), true));
|
|
}
|
|
|
|
/**
|
|
* 执行求解器程序
|
|
*/
|
|
@Log(title = "执行求解器程序", businessType = BusinessType.OTHER)
|
|
@RepeatSubmit()
|
|
@PostMapping("/executeExe")
|
|
public R<Void> executeExe() {
|
|
List<String> command = new ArrayList<>();
|
|
command.add("cmd.exe");
|
|
command.add("/c");
|
|
command.add("start");
|
|
command.add("D:\\文件\\同规格无拼接线材下料\\test_glpk\\Release\\test_glpk.exe");
|
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
|
try {
|
|
Process process = processBuilder.start();
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
String exeOutput;
|
|
while ((exeOutput = reader.readLine()) != null) {
|
|
System.out.println(exeOutput);
|
|
}
|
|
int exitCode = process.waitFor();
|
|
System.out.println("Ecode: " + exitCode);
|
|
} catch (IOException | InterruptedException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
return R.ok();
|
|
}
|
|
|
|
@Log(title = "获取计算结果", businessType = BusinessType.OTHER)
|
|
@RepeatSubmit()
|
|
@PostMapping("/processFile")
|
|
public R<Void> processFile() throws IOException {
|
|
String filePath = "D:\\文件\\同规格无拼接线材下料\\test_glpk\\data\\result.txt";
|
|
int i = iCutProblemCreationService.processFile(filePath);
|
|
if (i==1){
|
|
return R.ok();
|
|
}else {
|
|
return R.fail();
|
|
}
|
|
}
|
|
|
|
|
|
}
|