故障管理CURD
parent
21c796a9d9
commit
3fface7039
|
@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lenovo
|
* @author Lenovo
|
||||||
|
@ -18,6 +21,9 @@ import lombok.EqualsAndHashCode;
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@TableName("sys_car_fault")
|
@TableName("sys_car_fault")
|
||||||
public class BreakDown extends BaseEntity {
|
public class BreakDown extends BaseEntity {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu;
|
package com.muyu.breakdown;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
@ -18,6 +18,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class BreakDownApplication {
|
public class BreakDownApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(BreakDownApplication.class, args);
|
SpringApplication.run(BreakDownApplication.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,20 @@
|
||||||
package com.muyu.breakdown.controller;
|
package com.muyu.breakdown.controller;
|
||||||
|
|
||||||
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
import com.muyu.breakdown.service.BreakDownService;
|
import com.muyu.breakdown.service.BreakDownService;
|
||||||
|
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.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ Tool:IntelliJ IDEA
|
* @ Tool:IntelliJ IDEA
|
||||||
|
@ -20,6 +30,80 @@ public class BreakDownController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BreakDownService breakDownService;
|
private BreakDownService breakDownService;
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<BreakDown>> list(BreakDown breakDown)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出车辆故障列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, BreakDown breakDown)
|
||||||
|
{
|
||||||
|
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
|
||||||
|
ExcelUtil<BreakDown> util = new ExcelUtil<BreakDown>(BreakDown.class);
|
||||||
|
util.exportExcel(response, list, "车辆故障数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆故障详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<BreakDown>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(breakDownService.selectBreakDownById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody BreakDown breakDown)
|
||||||
|
{
|
||||||
|
if (breakDownService.checkIdUnique(breakDown)) {
|
||||||
|
return error("新增 车辆故障 '" + breakDown + "'失败,车辆故障已存在");
|
||||||
|
}
|
||||||
|
breakDown.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(breakDownService.save(breakDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody BreakDown breakDown)
|
||||||
|
{
|
||||||
|
if (!breakDownService.checkIdUnique(breakDown)) {
|
||||||
|
return error("修改 车辆故障 '" + breakDown + "'失败,车辆故障不存在");
|
||||||
|
}
|
||||||
|
breakDown.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(breakDownService.updateById(breakDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
breakDownService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.breakdown.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.breakdown.domain.BreakDown;
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ Tool:IntelliJ IDEA
|
* @ Tool:IntelliJ IDEA
|
||||||
* @ Author:CHX
|
* @ Author:CHX
|
||||||
|
@ -12,4 +14,27 @@ import com.muyu.breakdown.domain.BreakDown;
|
||||||
* @author Lenovo
|
* @author Lenovo
|
||||||
*/
|
*/
|
||||||
public interface BreakDownService extends IService<BreakDown> {
|
public interface BreakDownService extends IService<BreakDown> {
|
||||||
|
/**
|
||||||
|
* 精确查询车辆故障
|
||||||
|
*
|
||||||
|
* @param id 车辆故障主键
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
public BreakDown selectBreakDownById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障集合
|
||||||
|
*/
|
||||||
|
public List<BreakDown> selectBreakDownList(BreakDown breakDown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 车辆故障 id是否唯一
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(BreakDown breakDown);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package com.muyu.breakdown.service.impl;
|
package com.muyu.breakdown.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.breakdown.domain.BreakDown;
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
import com.muyu.breakdown.mapper.BreakDownMapper;
|
import com.muyu.breakdown.mapper.BreakDownMapper;
|
||||||
import com.muyu.breakdown.service.BreakDownService;
|
import com.muyu.breakdown.service.BreakDownService;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ Tool:IntelliJ IDEA
|
* @ Tool:IntelliJ IDEA
|
||||||
* @ Author:CHX
|
* @ Author:CHX
|
||||||
|
@ -16,4 +21,55 @@ import org.springframework.stereotype.Service;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService {
|
public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService {
|
||||||
|
/**
|
||||||
|
* 精确查询车辆故障
|
||||||
|
*
|
||||||
|
* @param id 车辆故障主键
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BreakDown selectBreakDownById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(BreakDown::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BreakDown> selectBreakDownList(BreakDown breakDown)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(breakDown.getFaultCode())){
|
||||||
|
queryWrapper.eq(BreakDown::getFaultCode, breakDown.getFaultCode());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(breakDown.getFaultType())){
|
||||||
|
queryWrapper.eq(BreakDown::getFaultType, breakDown.getFaultType());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(breakDown.getCarVin())){
|
||||||
|
queryWrapper.eq(BreakDown::getCarVin, breakDown.getCarVin());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(BreakDown breakDown) {
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BreakDown::getId, breakDown.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9701
|
port: 9702
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
|
@ -57,4 +57,4 @@ spring:
|
||||||
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.breakdown.mapper: DEBUG
|
||||||
|
|
Loading…
Reference in New Issue