package com.aps.core.controller.mainPlan;
|
|
import com.aps.common.core.utils.poi.ExcelUtil;
|
import com.aps.common.core.web.controller.BaseController;
|
import com.aps.common.core.web.domain.AjaxResult;
|
import com.aps.common.core.web.page.TableDataInfo;
|
import com.aps.common.log.annotation.Log;
|
import com.aps.common.log.enums.BusinessType;
|
import com.aps.common.security.annotation.RequiresPermissions;
|
import com.aps.core.domain.ApsGasPipelineMo;
|
import com.aps.core.service.IApsGasPipelineMoService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.servlet.http.HttpServletResponse;
|
import lombok.SneakyThrows;
|
import org.apache.commons.io.IOUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.net.URLEncoder;
|
import java.nio.charset.StandardCharsets;
|
import java.util.List;
|
|
/**
|
* 管路手工气体工单数据Controller
|
*
|
* @author sfd
|
* @date 2025-05-19
|
*/
|
|
@Tag(name = "管路手工气体工单数据", description = "管路手工气体工单数据接口")
|
@RestController
|
@RequestMapping("/gasPipelineMo")
|
public class ApsGasPipelineMoController extends BaseController
|
{
|
@Autowired
|
private IApsGasPipelineMoService apsGasPipelineMoService;
|
|
/**
|
* 查询管路手工气体工单数据列表
|
*/
|
@Operation(summary = "查询管路手工气体工单数据列表", description = "分页查询")
|
@RequiresPermissions("gasPipeline:mo:list")
|
@GetMapping("/list")
|
public TableDataInfo list(ApsGasPipelineMo apsGasPipelineMo)
|
{
|
startPage();
|
List<ApsGasPipelineMo> list = apsGasPipelineMoService.selectApsGasPipelineMoList(apsGasPipelineMo);
|
return getDataTable(list);
|
}
|
|
|
@Operation(summary = "导入管路手工气体工单数据", description = "批量导入")
|
@Log(title = "导入管路手工气体工单数据", businessType = BusinessType.IMPORT)
|
@RequiresPermissions("gasPipeline:mo:import")
|
@PostMapping("/importData")
|
public AjaxResult importData(MultipartFile file) throws Exception {
|
|
apsGasPipelineMoService.batchInsertGasPipelineMo(file);
|
return toAjax(true);
|
}
|
|
/**
|
* 导出管路手工气体工单数据列表
|
*/
|
@Operation(summary = "导出管路手工气体工单数据列表", description = "导出")
|
@RequiresPermissions("gasPipeline:mo:export")
|
@Log(title = "管路手工气体工单数据", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, ApsGasPipelineMo apsGasPipelineMo)
|
{
|
List<ApsGasPipelineMo> list = apsGasPipelineMoService.selectApsGasPipelineMoList(apsGasPipelineMo);
|
ExcelUtil<ApsGasPipelineMo> util = new ExcelUtil<ApsGasPipelineMo>(ApsGasPipelineMo.class);
|
util.exportExcel(response, list, "管路手工气体工单数据数据");
|
}
|
|
/**
|
* 获取管路手工气体工单数据详细信息
|
*/
|
@Operation(summary = "获取管路手工气体工单数据详细信息", description = "根据id获取")
|
@RequiresPermissions("gasPipeline:mo:query")
|
@GetMapping(value = "/{id}")
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
{
|
return success(apsGasPipelineMoService.selectApsGasPipelineMoById(id));
|
}
|
|
/**
|
* 新增管路手工气体工单数据
|
*/
|
@Operation(summary = "新增管路手工气体工单数据", description = "单个新增")
|
@RequiresPermissions("gasPipeline:mo:add")
|
@Log(title = "管路手工气体工单数据", businessType = BusinessType.INSERT)
|
@PostMapping
|
public AjaxResult add(@RequestBody ApsGasPipelineMo apsGasPipelineMo)
|
{
|
return toAjax(apsGasPipelineMoService.insertApsGasPipelineMo(apsGasPipelineMo));
|
}
|
|
/**
|
* 修改管路手工气体工单数据
|
*/
|
@Operation(summary = "修改管路手工气体工单数据", description = "单个修改")
|
@RequiresPermissions("gasPipeline:mo:edit")
|
@Log(title = "管路手工气体工单数据", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public AjaxResult edit(@RequestBody ApsGasPipelineMo apsGasPipelineMo)
|
{
|
return toAjax(apsGasPipelineMoService.updateApsGasPipelineMo(apsGasPipelineMo));
|
}
|
|
/**
|
* 删除管路手工气体工单数据
|
*/
|
@Operation(summary = "删除管路手工气体工单数据", description = "批量删除")
|
@RequiresPermissions("gasPipeline:mo:remove")
|
@Log(title = "管路手工气体工单数据", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public AjaxResult remove(@PathVariable Long[] ids)
|
{
|
return toAjax(apsGasPipelineMoService.deleteApsGasPipelineMoByIds(ids));
|
}
|
|
/**
|
* 下载气体预测数据导入模板
|
*/
|
@SneakyThrows
|
@Operation(summary = "下载气体工单数据导入模板", description = "下载气体工单数据导入模板")
|
// @RequiresPermissions("gasPipeline:mo:template")
|
// @Log(title = "下载气体工单数据导入模板", businessType = BusinessType.EXPORT)
|
@GetMapping("/template")
|
public ResponseEntity<ByteArrayResource> exportTemplate() {
|
byte[] file = IOUtils.resourceToByteArray("/templates/气体工单数据模板v1.0.xlsx");
|
ByteArrayResource resource = new ByteArrayResource(file);
|
return ResponseEntity.ok()
|
.header(HttpHeaders.CONTENT_DISPOSITION,
|
String.format("attachment;filename=%s", URLEncoder.encode("气体工单数据模板.xlsx", StandardCharsets.UTF_8)))
|
.header(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
.contentLength(file.length)
|
.body(resource);
|
}
|
}
|