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-26 18:15:56 +08:00
|
|
|
import com.ruoyi.bst.fault.service.FaultService;
|
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-27 07:32:13 +08:00
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
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
|
|
|
|
*/
|
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody Fault fault) {
|
|
|
|
faultService.insertFault(fault);
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping
|
|
|
|
public AjaxResult get(FaultQuery query) {
|
|
|
|
query.setUserId(getUserId());
|
|
|
|
List<FaultVO> list = faultService.selectFaultList(query);
|
|
|
|
List<FaultVO> validList = new ArrayList<>();
|
|
|
|
|
|
|
|
list.forEach(faultVO -> {
|
|
|
|
DeviceVO deviceVO = deviceService.selectDeviceBySn(faultVO.getVehicleCode());
|
|
|
|
if (deviceVO == null){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Long orderId = deviceVO.getOrderId();
|
|
|
|
if (orderId == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
LocalDateTime orderEndTime = orderService.selectOrderById(orderId).getEndTime();
|
|
|
|
if (orderEndTime == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
faultVO.setOrderEndTime(orderEndTime);
|
|
|
|
validList.add(faultVO);
|
|
|
|
});
|
|
|
|
return success(validList);
|
2025-03-27 07:32:13 +08:00
|
|
|
}
|
2025-03-26 18:15:56 +08:00
|
|
|
}
|