2025-03-26 18:15:56 +08:00
|
|
|
package com.ruoyi.web.app;
|
|
|
|
|
2025-03-28 12:42:23 +08:00
|
|
|
import com.ruoyi.bst.device.domain.DeviceVO;
|
|
|
|
import com.ruoyi.bst.device.service.DeviceService;
|
|
|
|
import com.ruoyi.bst.fault.domain.Fault;
|
|
|
|
import com.ruoyi.bst.fault.domain.FaultQuery;
|
2025-03-27 07:32:13 +08:00
|
|
|
import com.ruoyi.bst.fault.domain.FaultVO;
|
2025-03-28 16:21:17 +08:00
|
|
|
import com.ruoyi.bst.fault.domain.enums.FaultHandleStatus;
|
|
|
|
import com.ruoyi.bst.fault.domain.enums.FaultStatus;
|
2025-03-26 18:15:56 +08:00
|
|
|
import com.ruoyi.bst.fault.service.FaultService;
|
2025-03-29 18:08:10 +08:00
|
|
|
import com.ruoyi.bst.order.domain.OrderVO;
|
2025-03-28 12:42:23 +08:00
|
|
|
import com.ruoyi.bst.order.service.OrderService;
|
2025-03-27 21:50:48 +08:00
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
2025-03-26 18:15:56 +08:00
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
2025-03-28 16:21:17 +08:00
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
2025-03-29 18:08:10 +08:00
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
2025-03-27 07:32:13 +08:00
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
2025-03-29 18:08:10 +08:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.checkerframework.checker.units.qual.A;
|
2025-03-26 18:15:56 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2025-03-28 12:42:23 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2025-03-26 18:15:56 +08:00
|
|
|
|
2025-03-27 07:32:13 +08:00
|
|
|
/**
|
2025-03-28 12:42:23 +08:00
|
|
|
* 故障申报前台
|
2025-03-27 07:32:13 +08:00
|
|
|
*/
|
2025-03-26 18:15:56 +08:00
|
|
|
@RestController
|
2025-03-27 07:32:13 +08:00
|
|
|
@RequestMapping("/app/fault")
|
2025-03-27 21:50:48 +08:00
|
|
|
public class AppFaultController extends BaseController {
|
2025-03-26 18:15:56 +08:00
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private FaultService faultService;
|
2025-03-27 07:32:13 +08:00
|
|
|
|
2025-03-28 12:42:23 +08:00
|
|
|
@Autowired
|
|
|
|
private DeviceService deviceService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private OrderService orderService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增
|
|
|
|
* @param fault
|
|
|
|
* @return
|
|
|
|
*/
|
2025-03-29 18:08:10 +08:00
|
|
|
@ApiOperation("故障申报")
|
2025-03-28 12:42:23 +08:00
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody Fault fault) {
|
2025-03-29 18:08:10 +08:00
|
|
|
DeviceVO device = deviceService.selectDeviceBySn(fault.getVehicleCode());
|
|
|
|
|
|
|
|
if (device ==null) {
|
|
|
|
return error("当前车辆不存在");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device.getOrderId() != null) {
|
|
|
|
OrderVO order = orderService.selectOrderById(device.getOrderId());
|
|
|
|
if (order.getEndTime() != null) {
|
|
|
|
fault.setOrderEndTime(DateUtils.toDate(order.getEndTime()));
|
|
|
|
}
|
|
|
|
fault.setOrderId(device.getOrderId());
|
|
|
|
}
|
|
|
|
String vehicleNum = device.getVehicleNum();
|
|
|
|
if (vehicleNum != null) {
|
|
|
|
fault.setVehicleNum(vehicleNum);
|
|
|
|
}
|
2025-03-28 12:42:23 +08:00
|
|
|
faultService.insertFault(fault);
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-03-29 18:08:10 +08:00
|
|
|
/**
|
|
|
|
* 处理或者驳回申报信息
|
|
|
|
* @param fault
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@ApiOperation("处理申报信息")
|
2025-03-28 16:21:17 +08:00
|
|
|
@PutMapping
|
|
|
|
public AjaxResult update(@RequestBody Fault fault) {
|
|
|
|
FaultVO faultVO = faultService.selectFaultById(fault.getId());
|
|
|
|
if (faultVO.getAppealStatus().equals(FaultStatus.PENGDING.getCode()) && fault.getHandle().equals(FaultHandleStatus.REJECTED.getCode())) {
|
|
|
|
faultVO.setAppealStatus(FaultStatus.REJECTED.getCode());
|
|
|
|
}else
|
|
|
|
if (faultVO.getAppealStatus().equals(FaultStatus.PENGDING.getCode()) && fault.getHandle().equals(FaultHandleStatus.DO.getCode())) {
|
|
|
|
faultVO.setAppealStatus(FaultStatus.REPAIRING.getCode());
|
|
|
|
}else
|
|
|
|
if (faultVO.getAppealStatus().equals(FaultStatus.REPAIRING.getCode()) && fault.getHandle().equals(FaultHandleStatus.DO.getCode())) {
|
|
|
|
faultVO.setAppealStatus(FaultStatus.COMPLETED.getCode());
|
|
|
|
}
|
|
|
|
faultService.updateFault(faultVO);
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 历史申报查询
|
|
|
|
* @param query
|
|
|
|
* @return
|
|
|
|
*/
|
2025-03-29 18:08:10 +08:00
|
|
|
@ApiOperation("查询历史申报")
|
2025-03-28 12:42:23 +08:00
|
|
|
@GetMapping
|
2025-03-28 16:21:17 +08:00
|
|
|
public TableDataInfo get(FaultQuery query) {
|
|
|
|
startPage();
|
2025-03-28 12:42:23 +08:00
|
|
|
query.setUserId(getUserId());
|
|
|
|
List<FaultVO> list = faultService.selectFaultList(query);
|
2025-03-29 18:08:10 +08:00
|
|
|
return getDataTable(list);
|
2025-03-26 18:15:56 +08:00
|
|
|
}
|
2025-03-29 18:08:10 +08:00
|
|
|
|
|
|
|
}
|