2025-03-26 14:39:07 +08:00
|
|
|
package com.ruoyi.web.bst;
|
|
|
|
|
2025-04-15 18:16:16 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
2025-04-21 18:19:00 +08:00
|
|
|
import com.ruoyi.bst.fault.domain.FaultVerifyDTO;
|
|
|
|
import com.ruoyi.bst.order.domain.dto.OrderVerifyDTO;
|
2025-04-15 18:16:16 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
2025-04-21 18:19:00 +08:00
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-04-15 18:16:16 +08:00
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
|
2025-03-26 14:39:07 +08:00
|
|
|
import com.ruoyi.bst.fault.domain.Fault;
|
|
|
|
import com.ruoyi.bst.fault.domain.FaultQuery;
|
|
|
|
import com.ruoyi.bst.fault.domain.FaultVO;
|
|
|
|
import com.ruoyi.bst.fault.service.FaultService;
|
2025-04-02 20:06:50 +08:00
|
|
|
import com.ruoyi.bst.fault.service.FaultValidator;
|
2025-03-26 14:39:07 +08:00
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
2025-04-15 18:16:16 +08:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
2025-03-26 14:39:07 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 故障Controller
|
|
|
|
*
|
|
|
|
* @author ruoyi
|
|
|
|
* @date 2025-03-26
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/bst/fault")
|
|
|
|
public class FaultController extends BaseController
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
private FaultService faultService;
|
2025-04-15 18:16:16 +08:00
|
|
|
|
2025-04-02 20:06:50 +08:00
|
|
|
@Autowired
|
|
|
|
private FaultValidator faultValidator;
|
2025-03-26 14:39:07 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询故障列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:list')")
|
|
|
|
@GetMapping("/list")
|
|
|
|
public TableDataInfo list(FaultQuery query)
|
|
|
|
{
|
|
|
|
startPage();
|
|
|
|
startOrderBy();
|
2025-04-01 18:17:31 +08:00
|
|
|
query.setScope(true);
|
2025-04-15 18:16:16 +08:00
|
|
|
query.addAreaPermission(AreaJoinPermission.FAULT_VIEW.getCode());
|
2025-03-26 14:39:07 +08:00
|
|
|
List<FaultVO> list = faultService.selectFaultList(query);
|
|
|
|
return getDataTable(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出故障列表
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:export')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.EXPORT)
|
|
|
|
@PostMapping("/export")
|
|
|
|
public void export(HttpServletResponse response, FaultQuery query)
|
|
|
|
{
|
2025-04-15 18:16:16 +08:00
|
|
|
query.addAreaPermission(AreaJoinPermission.FAULT_VIEW.getCode());
|
2025-03-26 14:39:07 +08:00
|
|
|
List<FaultVO> list = faultService.selectFaultList(query);
|
|
|
|
ExcelUtil<FaultVO> util = new ExcelUtil<FaultVO>(FaultVO.class);
|
|
|
|
util.exportExcel(response, list, "故障数据");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取故障详细信息
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:query')")
|
|
|
|
@GetMapping(value = "/{id}")
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
{
|
2025-04-02 13:17:28 +08:00
|
|
|
return success(faultService.selectFaultById(id,true));
|
2025-03-26 14:39:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-03-26 18:15:56 +08:00
|
|
|
* 新增故障信息
|
2025-03-26 14:39:07 +08:00
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:add')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody Fault fault)
|
|
|
|
{
|
|
|
|
return toAjax(faultService.insertFault(fault));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-03-26 18:15:56 +08:00
|
|
|
* 修改故障信息
|
2025-03-26 14:39:07 +08:00
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:edit')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
|
|
|
public AjaxResult edit(@RequestBody Fault fault)
|
|
|
|
{
|
|
|
|
return toAjax(faultService.updateFault(fault));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-03-26 18:15:56 +08:00
|
|
|
* 删除故障信息
|
2025-03-26 14:39:07 +08:00
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:remove')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
{
|
|
|
|
return toAjax(faultService.deleteFaultByIds(ids));
|
|
|
|
}
|
2025-04-01 18:02:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-04-21 18:19:00 +08:00
|
|
|
* 审核待处理故障申报
|
|
|
|
* @param dto
|
2025-04-01 18:02:44 +08:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:edit')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.UPDATE)
|
2025-04-21 18:19:00 +08:00
|
|
|
@ApiOperation("审核待处理故障申报")
|
2025-04-01 18:02:44 +08:00
|
|
|
@PutMapping("/handle")
|
2025-04-21 18:19:00 +08:00
|
|
|
public AjaxResult handle(@RequestBody @Validated FaultVerifyDTO dto) {
|
|
|
|
if (!faultValidator.canEdit(dto.getId())){
|
|
|
|
return AjaxResult.error("您没有权限处理id为" + dto.getId() + "的故障申报");
|
2025-04-01 18:02:44 +08:00
|
|
|
}
|
2025-04-21 18:19:00 +08:00
|
|
|
return toAjax(faultService.verify(dto));
|
2025-04-01 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
2025-04-21 18:19:00 +08:00
|
|
|
/**
|
|
|
|
* 完成维修中故障申报
|
|
|
|
* @param dto
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('bst:fault:edit')")
|
|
|
|
@Log(title = "故障", businessType = BusinessType.UPDATE)
|
|
|
|
@ApiOperation("完成维修中故障申报")
|
|
|
|
@PutMapping("/complete")
|
|
|
|
public AjaxResult complete(@RequestBody @Validated FaultVerifyDTO dto) {
|
|
|
|
if (!faultValidator.canEdit(dto.getId())){
|
|
|
|
return AjaxResult.error("您没有权限处理id为" + dto.getId() + "的故障申报");
|
|
|
|
}
|
|
|
|
return toAjax(faultService.complete(dto));
|
|
|
|
}
|
2025-03-26 14:39:07 +08:00
|
|
|
}
|