| | |
| | | package com.se.nsl.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.se.nsl.domain.po.Simu; |
| | | import com.se.nsl.domain.po.SimuData; |
| | | import com.se.nsl.domain.vo.R; |
| | | import com.se.nsl.domain.vo.SimuVo; |
| | | import com.se.nsl.service.ResolveService; |
| | | import com.se.nsl.service.SimuService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "2-推演模拟") |
| | | @Api(tags = "03-推演模拟") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/simu") |
| | |
| | | public class SimuController extends BaseController { |
| | | @Resource |
| | | SimuService simuService; |
| | | |
| | | @Resource |
| | | ResolveService resolveService; |
| | | |
| | | /** |
| | | * 分页查询推演模拟 |
| | |
| | | */ |
| | | @ApiOperation(value = "deleteByIds") |
| | | @DeleteMapping("/deleteByIds") |
| | | public R<Object> deleteByIds(java.util.List<Integer> ids) { |
| | | public R<Object> deleteByIds(@RequestParam List<Integer> ids) { |
| | | try { |
| | | return success(simuService.deleteByIds(ids)); |
| | | } catch (Exception ex) { |
| | |
| | | * @return 新增成功的记录数 |
| | | */ |
| | | @ApiOperation(value = "insert") |
| | | @PostMapping("/insert") |
| | | public R<Object> insert(Simu simu) { |
| | | @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") |
| | | public R<Object> insert(@RequestBody Simu simu) { |
| | | try { |
| | | return success(simuService.insert(simu)); |
| | | if (StringUtils.isEmpty(simu.getData())) return fail("data为空"); |
| | | |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | if (null == data) return fail("data数据格式(JSON)不正确"); |
| | | |
| | | int rows = simuService.insert(simu); |
| | | |
| | | return success(rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "start") |
| | | @GetMapping(value = "/start", produces = "application/json; charset=UTF-8") |
| | | public R<Object> start(Integer id) { |
| | | try { |
| | | if (null == id || id < 1) return fail("id为空"); |
| | | |
| | | Simu simu = simuService.selectById(id); |
| | | if (null == simu) return fail("方案找不到"); |
| | | if (StringUtils.isEmpty(simu.getData())) return fail("方案数据(JSON)为空"); |
| | | |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | if (null == data) return fail("方案数据格式(JSON)不正确"); |
| | | |
| | | if (simu.getStatus() != 0) return fail("方案正在运行或已完成"); |
| | | |
| | | int rows = resolveService.start(simu); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | |
| | | * @return 修改成功的记录数 |
| | | */ |
| | | @ApiOperation(value = "updateById") |
| | | @PutMapping("/updateById") |
| | | public R<Object> updateById(Simu simu) { |
| | | @PutMapping(value = "/updateById", produces = "application/json; charset=UTF-8") |
| | | public R<Object> updateById(@RequestBody Simu simu) { |
| | | try { |
| | | return success(simuService.updateById(simu)); |
| | | } catch (Exception ex) { |