开发OTA备案工具-车辆升级

This commit is contained in:
高嵩
2023-03-30 17:25:07 +08:00
parent fcc1d8bee5
commit 58aa8598af
4 changed files with 190 additions and 126 deletions
@@ -87,7 +87,7 @@ public class OtaBaCxListController extends JeroController<OtaBaCxList, IOtaBaCxL
queryWrapper.like(OtaBaCxList::getCpmc, cpmc);
}
String cpxh = req.getParameter("cpmc");
String cpxh = req.getParameter("cpxh");
if (StringUtils.isNotBlank(cpxh)) {
cpxh = cpxh.replace("%", "\\%");
queryWrapper.like(OtaBaCxList::getCpxh, cpxh);
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaSjGnxtwh;
@@ -22,147 +23,155 @@ import io.swagger.annotations.ApiOperation;
import com.jero.common.aspect.annotation.AutoLog;
/**
/**
* @Description: 车型备案-功能系统维护
* @Author: jero-boot
* @Date: 2023-03-28
* @Date: 2023-03-28
* @Version: V1.0
*/
@Api(tags="车型备案-功能系统维护")
@Api(tags = "车型备案-功能系统维护")
@RestController
@RequestMapping("/ota/otaBaSjGnxtwh")
@Slf4j
public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaBaSjGnxtwhService> {
@Autowired
private IOtaBaSjGnxtwhService otaBaSjGnxtwhService;
/**
* 分页列表查询
*
* @param otaBaSjGnxtwh
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-分页列表查询")
@ApiOperation(value="车型备案-功能系统维护-分页列表查询", notes="车型备案-功能系统维护-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaSjGnxtwh otaBaSjGnxtwh,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaSjGnxtwh> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjGnxtwh, req.getParameterMap());
Page<OtaBaSjGnxtwh> page = new Page<OtaBaSjGnxtwh>(pageNo, pageSize);
queryWrapper.orderByDesc("create_time");
IPage<OtaBaSjGnxtwh> pageList = otaBaSjGnxtwhService.page(page, queryWrapper);
return Result.OK(pageList);
}
@Autowired
private IOtaBaSjGnxtwhService otaBaSjGnxtwhService;
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-列表查询")
@ApiOperation(value="车型备案-功能系统维护-列表查询", notes="车型备案-功能系统维护-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaSjGnxtwh>> queryList() {
* 分页列表查询
*
* @param otaBaSjGnxtwh
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-分页列表查询")
@ApiOperation(value = "车型备案-功能系统维护-分页列表查询", notes = "车型备案-功能系统维护-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaSjGnxtwh otaBaSjGnxtwh,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OtaBaSjGnxtwh> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjGnxtwh, req.getParameterMap());
Page<OtaBaSjGnxtwh> page = new Page<OtaBaSjGnxtwh>(pageNo, pageSize);
queryWrapper.orderByDesc("create_time");
IPage<OtaBaSjGnxtwh> pageList = otaBaSjGnxtwhService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-列表查询")
@ApiOperation(value = "车型备案-功能系统维护-列表查询", notes = "车型备案-功能系统维护-列表查询")
@GetMapping(value = "/list")
public Result<List<OtaBaSjGnxtwh>> queryList() {
List<OtaBaSjGnxtwh> list = otaBaSjGnxtwhService.queryList();
return Result.OK(list);
}
/**
* 添加
*
* @param otaBaSjGnxtwh
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-添加")
@ApiOperation(value="车型备案-功能系统维护-添加", notes="车型备案-功能系统维护-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
otaBaSjGnxtwhService.add(otaBaSjGnxtwh);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaSjGnxtwh
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-编辑")
@ApiOperation(value="车型备案-功能系统维护-编辑", notes="车型备案-功能系统维护-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
otaBaSjGnxtwhService.editById(otaBaSjGnxtwh);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-通过id删除")
@ApiOperation(value="车型备案-功能系统维护-通过id删除", notes="车型备案-功能系统维护-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
otaBaSjGnxtwhService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-批量删除")
@ApiOperation(value="车型备案-功能系统维护-批量删除", notes="车型备案-功能系统维护-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.otaBaSjGnxtwhService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-通过id查询")
@ApiOperation(value="车型备案-功能系统维护-通过id查询", notes="车型备案-功能系统维护-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
OtaBaSjGnxtwh otaBaSjGnxtwh = otaBaSjGnxtwhService.queryById(id);
if(otaBaSjGnxtwh==null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaSjGnxtwh);
}
}
/**
* 导出excel
*
* @param request
* @param otaBaSjGnxtwh
*/
* 添加
*
* @param otaBaSjGnxtwh
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-添加")
@ApiOperation(value = "车型备案-功能系统维护-添加", notes = "车型备案-功能系统维护-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
try {
otaBaSjGnxtwhService.add(otaBaSjGnxtwh);
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param otaBaSjGnxtwh
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-编辑")
@ApiOperation(value = "车型备案-功能系统维护-编辑", notes = "车型备案-功能系统维护-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
try {
otaBaSjGnxtwhService.editById(otaBaSjGnxtwh);
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-通过id删除")
@ApiOperation(value = "车型备案-功能系统维护-通过id删除", notes = "车型备案-功能系统维护-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
otaBaSjGnxtwhService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-批量删除")
@ApiOperation(value = "车型备案-功能系统维护-批量删除", notes = "车型备案-功能系统维护-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.otaBaSjGnxtwhService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "车型备案-功能系统维护-通过id查询")
@ApiOperation(value = "车型备案-功能系统维护-通过id查询", notes = "车型备案-功能系统维护-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
OtaBaSjGnxtwh otaBaSjGnxtwh = otaBaSjGnxtwhService.queryById(id);
if (otaBaSjGnxtwh == null) {
return Result.error("未找到对应数据");
}
return Result.OK(otaBaSjGnxtwh);
}
/**
* 导出excel
*
* @param request
* @param otaBaSjGnxtwh
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, OtaBaSjGnxtwh otaBaSjGnxtwh) {
return super.exportXls(request, otaBaSjGnxtwh, OtaBaSjGnxtwh.class, "车型备案-功能系统维护");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, OtaBaSjGnxtwh.class);
@@ -19,7 +19,7 @@ public interface IOtaBaSjGnxtwhService extends IService<OtaBaSjGnxtwh> {
* @param otaBaSjGnxtwh
* @return
*/
void add(OtaBaSjGnxtwh otaBaSjGnxtwh);
void add(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception;
/**
* 更新
@@ -27,7 +27,7 @@ public interface IOtaBaSjGnxtwhService extends IService<OtaBaSjGnxtwh> {
* @param otaBaSjGnxtwh
* @return
*/
void editById(OtaBaSjGnxtwh otaBaSjGnxtwh);
void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception;
/**
* 通过id删除
@@ -1,8 +1,10 @@
package com.jero.modules.ota.service.impl;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.ota.entity.OtaBaSjGnxtwh;
import com.jero.modules.ota.mapper.OtaBaSjGnxtwhMapper;
import com.jero.modules.ota.service.IOtaBaSjGnxtwhService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -26,10 +28,28 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
* @return
*/
@Override
public void add(OtaBaSjGnxtwh otaBaSjGnxtwh) {
public void add(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception {
Date now = new Date();
otaBaSjGnxtwh.setCreateTime(now);
otaBaSjGnxtwh.setUpdateTime(now);
String str = otaBaSjGnxtwh.getDykzq();
if (StringUtils.isNotEmpty(str)) {
String[] arr = str.split(",");
for (int i = 0; i < arr.length - 1; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i].equals(arr[j])) {
throw new JeroBootException("对应控制器重复:" + arr[i]);
}
}
}
for (String s : arr) {
if (null != queryGnxtByKzq(s)) {
throw new JeroBootException("对应控制器重复:" + s);
}
}
} else {
throw new JeroBootException("对应控制器不能为空");
}
save(otaBaSjGnxtwh);
}
@@ -40,9 +60,26 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
* @return
*/
@Override
public void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) {
public void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception {
Date now = new Date();
otaBaSjGnxtwh.setUpdateTime(now);
String str = otaBaSjGnxtwh.getDykzq();
if (StringUtils.isNotEmpty(str)) {
String[] arr = str.split(",");
for (int i = 0; i < arr.length - 1; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i].equals(arr[j])) {
throw new JeroBootException("对应控制器重复:" + arr[i]);
}
}
}
String res = queryGnxtByKzq(otaBaSjGnxtwh);
if (null != res) {
throw new JeroBootException("对应控制器重复:" + res);
}
} else {
throw new JeroBootException("对应控制器不能为空");
}
saveOrUpdate(otaBaSjGnxtwh);
}
@@ -79,6 +116,24 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
return getById(id);
}
public String queryGnxtByKzq(OtaBaSjGnxtwh kzq) {
List<OtaBaSjGnxtwh> list = list();
for (OtaBaSjGnxtwh wh : list) {
if (kzq.getId().equals(wh.getId())) {
continue;
}
String[] strs = wh.getDykzq().split(",");
String[] strs1 = kzq.getDykzq().split(",");
for (String str : strs) {
for (String str1 : strs1) {
if (str.equals(str1)) {
return str;
}
}
}
}
return null;
}
@Override
public String queryGnxtByKzq(String kzq) {