故障日志
parent
be2fc79d49
commit
2ad4794e78
|
@ -72,6 +72,18 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.carrotsearch.thirdparty</groupId>
|
||||
<artifactId>simple-xml-safe</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.attoparser</groupId>
|
||||
<artifactId>attoparser</artifactId>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -71,6 +71,6 @@ public class SysCarFault extends BaseEntity {
|
|||
/**
|
||||
* 启用状态(1.待处理 2.处理中 3.已处理 4.忽略)
|
||||
*/
|
||||
@Schema(defaultValue = "启用状态",type = "String",description = "启用状态")
|
||||
@Schema(defaultValue = "启用状态",type = "String",description = "启用状态(1.待处理 2.处理中 3.已处理 4.忽略)")
|
||||
private String state;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,39 @@
|
|||
package com.muyu.fault.controller;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.fault.common.FaultLog;
|
||||
import com.muyu.fault.service.impl.FaultLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
public class FaultLogController{
|
||||
@Autowired
|
||||
private FaultLogService faultLogService;
|
||||
|
||||
/**
|
||||
* 查询车辆故障日志列表
|
||||
*/
|
||||
@RequestMapping(value = "/logList", method = RequestMethod.GET)
|
||||
public Result<List<FaultLog>> logList(){
|
||||
List<FaultLog> list = faultLogService.logList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加车辆故障日志
|
||||
* @param faultLog
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/addLog",method = RequestMethod.POST)
|
||||
public Result addLog(@RequestBody FaultLog faultLog){
|
||||
return Result.success(faultLogService.save(faultLog));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
package com.muyu.fault.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.fault.common.FaultLog;
|
||||
import com.muyu.fault.common.SysCarFault;
|
||||
import com.muyu.fault.service.impl.FaultLogService;
|
||||
import com.muyu.fault.service.impl.SysCarFaultService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.muyu.fault.common.SysCarFault;
|
||||
import com.muyu.fault.service.impl.SysCarFaultService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/faultInfo")
|
||||
public class SysCarFaultController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private SysCarFaultService sysCarFaultService;
|
||||
@Autowired
|
||||
private FaultLogService faultLogService;
|
||||
|
||||
/**
|
||||
* 查询车辆故障列表
|
||||
|
@ -62,10 +66,6 @@ public class SysCarFaultController extends BaseController
|
|||
public Result<Integer> add(
|
||||
@Validated @RequestBody SysCarFault sysCarFault)
|
||||
{
|
||||
|
||||
if (sysCarFaultService.checkIdUnique(sysCarFault)) {
|
||||
return error("新增 车辆故障 '" + sysCarFault + "'失败,车辆故障已存在");
|
||||
}
|
||||
String prefix = "GT"; // 随机码的前缀
|
||||
int minNumber = 1; // 随机数字的最小值
|
||||
int maxNumber = 999; // 随机数字的最大值
|
||||
|
@ -83,6 +83,16 @@ public class SysCarFaultController extends BaseController
|
|||
//赋值
|
||||
sysCarFault.setFaultCode(randomCode);
|
||||
sysCarFault.setCreateBy(SecurityUtils.getUsername());
|
||||
FaultLog faultLog = new FaultLog();
|
||||
faultLog.setFaultLogCodes(sysCarFault.getFaultCode());
|
||||
faultLog.setFaultLogVIN(sysCarFault.getCarVin());
|
||||
DateTime startTime = DateTime.now(); // 获取当前时间作为开始时间
|
||||
faultLog.setFaultLogStartTime(startTime);
|
||||
faultLog.setFaultLogEndTime(startTime);
|
||||
faultLogService.save(faultLog);
|
||||
if (sysCarFaultService.checkIdUnique(sysCarFault)) {
|
||||
return error("新增 车辆故障 '" + sysCarFault + "'失败,车辆故障已存在");
|
||||
}
|
||||
return toAjax(sysCarFaultService.save(sysCarFault));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,5 +3,10 @@ package com.muyu.fault.service.impl;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.fault.common.FaultLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FaultLogService extends IService<FaultLog> {
|
||||
List<FaultLog> logList();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,12 @@ import com.muyu.fault.common.FaultLog;
|
|||
import com.muyu.fault.mapper.FaultLogMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> implements FaultLogService{
|
||||
@Override
|
||||
public List<FaultLog> logList() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import org.simpleframework.xml.Text;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Random;
|
||||
|
||||
@Text
|
||||
public class Text01 {
|
||||
public static void main(String[] args) {
|
||||
// String prefix = "GT"; // 随机码的前缀
|
||||
// int minNumber = 1; // 随机数字的最小值
|
||||
// int maxNumber = 999; // 随机数字的最大值
|
||||
// Random random = new Random(); // 创建一个随机对象
|
||||
// // 生成一个随机数字
|
||||
// int number = random.nextInt(maxNumber - minNumber + 1) + minNumber;
|
||||
// // 将数字格式化为三位字符串,不足三位前面补0
|
||||
// String formattedNumber = String.format("%03d", number);
|
||||
// // 生成一个随机字母
|
||||
// String alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
// String randomLetter = alphabets.charAt(random.nextInt(alphabets.length())) + "";
|
||||
// // 拼接前缀、随机字母和随机数字
|
||||
// String randomCode = prefix + randomLetter + formattedNumber;
|
||||
// System.out.println(randomCode); // 输出随机码
|
||||
// LocalDateTime startTime = LocalDateTime.now(); // 开始时间
|
||||
// LocalDateTime endTime = startTime.plusHours(2); // 结束时间设置为开始时间后2小时
|
||||
//
|
||||
// System.out.println("Start Time: " + startTime);
|
||||
// System.out.println("End Time: " + endTime);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue