开发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); queryWrapper.like(OtaBaCxList::getCpmc, cpmc);
} }
String cpxh = req.getParameter("cpmc"); String cpxh = req.getParameter("cpxh");
if (StringUtils.isNotBlank(cpxh)) { if (StringUtils.isNotBlank(cpxh)) {
cpxh = cpxh.replace("%", "\\%"); cpxh = cpxh.replace("%", "\\%");
queryWrapper.like(OtaBaCxList::getCpxh, cpxh); queryWrapper.like(OtaBaCxList::getCpxh, cpxh);
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result; import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.ota.entity.OtaBaSjGnxtwh; import com.jero.modules.ota.entity.OtaBaSjGnxtwh;
@@ -22,13 +23,13 @@ import io.swagger.annotations.ApiOperation;
import com.jero.common.aspect.annotation.AutoLog; import com.jero.common.aspect.annotation.AutoLog;
/** /**
* @Description: 车型备案-功能系统维护 * @Description: 车型备案-功能系统维护
* @Author: jero-boot * @Author: jero-boot
* @Date: 2023-03-28 * @Date: 2023-03-28
* @Version: V1.0 * @Version: V1.0
*/ */
@Api(tags="车型备案-功能系统维护") @Api(tags = "车型备案-功能系统维护")
@RestController @RestController
@RequestMapping("/ota/otaBaSjGnxtwh") @RequestMapping("/ota/otaBaSjGnxtwh")
@Slf4j @Slf4j
@@ -46,11 +47,11 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-分页列表查询") @AutoLog(value = "车型备案-功能系统维护-分页列表查询")
@ApiOperation(value="车型备案-功能系统维护-分页列表查询", notes="车型备案-功能系统维护-分页列表查询") @ApiOperation(value = "车型备案-功能系统维护-分页列表查询", notes = "车型备案-功能系统维护-分页列表查询")
@GetMapping(value = "/page") @GetMapping(value = "/page")
public Result<?> queryPageList(OtaBaSjGnxtwh otaBaSjGnxtwh, public Result<?> queryPageList(OtaBaSjGnxtwh otaBaSjGnxtwh,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) { HttpServletRequest req) {
QueryWrapper<OtaBaSjGnxtwh> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjGnxtwh, req.getParameterMap()); QueryWrapper<OtaBaSjGnxtwh> queryWrapper = QueryGenerator.initQueryWrapper(otaBaSjGnxtwh, req.getParameterMap());
Page<OtaBaSjGnxtwh> page = new Page<OtaBaSjGnxtwh>(pageNo, pageSize); Page<OtaBaSjGnxtwh> page = new Page<OtaBaSjGnxtwh>(pageNo, pageSize);
@@ -65,7 +66,7 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-列表查询") @AutoLog(value = "车型备案-功能系统维护-列表查询")
@ApiOperation(value="车型备案-功能系统维护-列表查询", notes="车型备案-功能系统维护-列表查询") @ApiOperation(value = "车型备案-功能系统维护-列表查询", notes = "车型备案-功能系统维护-列表查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public Result<List<OtaBaSjGnxtwh>> queryList() { public Result<List<OtaBaSjGnxtwh>> queryList() {
List<OtaBaSjGnxtwh> list = otaBaSjGnxtwhService.queryList(); List<OtaBaSjGnxtwh> list = otaBaSjGnxtwhService.queryList();
@@ -79,10 +80,14 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-添加") @AutoLog(value = "车型备案-功能系统维护-添加")
@ApiOperation(value="车型备案-功能系统维护-添加", notes="车型备案-功能系统维护-添加") @ApiOperation(value = "车型备案-功能系统维护-添加", notes = "车型备案-功能系统维护-添加")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) { public Result<?> add(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
try {
otaBaSjGnxtwhService.add(otaBaSjGnxtwh); otaBaSjGnxtwhService.add(otaBaSjGnxtwh);
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.OK("添加成功!"); return Result.OK("添加成功!");
} }
@@ -93,10 +98,14 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-编辑") @AutoLog(value = "车型备案-功能系统维护-编辑")
@ApiOperation(value="车型备案-功能系统维护-编辑", notes="车型备案-功能系统维护-编辑") @ApiOperation(value = "车型备案-功能系统维护-编辑", notes = "车型备案-功能系统维护-编辑")
@PutMapping(value = "/edit") @PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) { public Result<?> edit(@Validated @RequestBody OtaBaSjGnxtwh otaBaSjGnxtwh) {
try {
otaBaSjGnxtwhService.editById(otaBaSjGnxtwh); otaBaSjGnxtwhService.editById(otaBaSjGnxtwh);
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.OK("编辑成功!"); return Result.OK("编辑成功!");
} }
@@ -107,9 +116,9 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-通过id删除") @AutoLog(value = "车型备案-功能系统维护-通过id删除")
@ApiOperation(value="车型备案-功能系统维护-通过id删除", notes="车型备案-功能系统维护-通过id删除") @ApiOperation(value = "车型备案-功能系统维护-通过id删除", notes = "车型备案-功能系统维护-通过id删除")
@DeleteMapping(value = "/delete") @DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) { public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
otaBaSjGnxtwhService.deleteById(id); otaBaSjGnxtwhService.deleteById(id);
return Result.OK("删除成功!"); return Result.OK("删除成功!");
} }
@@ -121,9 +130,9 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-批量删除") @AutoLog(value = "车型备案-功能系统维护-批量删除")
@ApiOperation(value="车型备案-功能系统维护-批量删除", notes="车型备案-功能系统维护-批量删除") @ApiOperation(value = "车型备案-功能系统维护-批量删除", notes = "车型备案-功能系统维护-批量删除")
@DeleteMapping(value = "/deleteBatch") @DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) { public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.otaBaSjGnxtwhService.deleteByIds(Arrays.asList(ids.split(","))); this.otaBaSjGnxtwhService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!"); return Result.OK("批量删除成功!");
} }
@@ -135,11 +144,11 @@ public class OtaBaSjGnxtwhController extends JeroController<OtaBaSjGnxtwh, IOtaB
* @return * @return
*/ */
@AutoLog(value = "车型备案-功能系统维护-通过id查询") @AutoLog(value = "车型备案-功能系统维护-通过id查询")
@ApiOperation(value="车型备案-功能系统维护-通过id查询", notes="车型备案-功能系统维护-通过id查询") @ApiOperation(value = "车型备案-功能系统维护-通过id查询", notes = "车型备案-功能系统维护-通过id查询")
@GetMapping(value = "/queryById") @GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) { public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
OtaBaSjGnxtwh otaBaSjGnxtwh = otaBaSjGnxtwhService.queryById(id); OtaBaSjGnxtwh otaBaSjGnxtwh = otaBaSjGnxtwhService.queryById(id);
if(otaBaSjGnxtwh==null) { if (otaBaSjGnxtwh == null) {
return Result.error("未找到对应数据"); return Result.error("未找到对应数据");
} }
return Result.OK(otaBaSjGnxtwh); return Result.OK(otaBaSjGnxtwh);
@@ -19,7 +19,7 @@ public interface IOtaBaSjGnxtwhService extends IService<OtaBaSjGnxtwh> {
* @param otaBaSjGnxtwh * @param otaBaSjGnxtwh
* @return * @return
*/ */
void add(OtaBaSjGnxtwh otaBaSjGnxtwh); void add(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception;
/** /**
* 更新 * 更新
@@ -27,7 +27,7 @@ public interface IOtaBaSjGnxtwhService extends IService<OtaBaSjGnxtwh> {
* @param otaBaSjGnxtwh * @param otaBaSjGnxtwh
* @return * @return
*/ */
void editById(OtaBaSjGnxtwh otaBaSjGnxtwh); void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception;
/** /**
* 通过id删除 * 通过id删除
@@ -1,8 +1,10 @@
package com.jero.modules.ota.service.impl; 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.entity.OtaBaSjGnxtwh;
import com.jero.modules.ota.mapper.OtaBaSjGnxtwhMapper; import com.jero.modules.ota.mapper.OtaBaSjGnxtwhMapper;
import com.jero.modules.ota.service.IOtaBaSjGnxtwhService; import com.jero.modules.ota.service.IOtaBaSjGnxtwhService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@@ -26,10 +28,28 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
* @return * @return
*/ */
@Override @Override
public void add(OtaBaSjGnxtwh otaBaSjGnxtwh) { public void add(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception {
Date now = new Date(); Date now = new Date();
otaBaSjGnxtwh.setCreateTime(now); otaBaSjGnxtwh.setCreateTime(now);
otaBaSjGnxtwh.setUpdateTime(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); save(otaBaSjGnxtwh);
} }
@@ -40,9 +60,26 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
* @return * @return
*/ */
@Override @Override
public void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) { public void editById(OtaBaSjGnxtwh otaBaSjGnxtwh) throws Exception {
Date now = new Date(); Date now = new Date();
otaBaSjGnxtwh.setUpdateTime(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]);
}
}
}
String res = queryGnxtByKzq(otaBaSjGnxtwh);
if (null != res) {
throw new JeroBootException("对应控制器重复:" + res);
}
} else {
throw new JeroBootException("对应控制器不能为空");
}
saveOrUpdate(otaBaSjGnxtwh); saveOrUpdate(otaBaSjGnxtwh);
} }
@@ -79,6 +116,24 @@ public class OtaBaSjGnxtwhServiceImpl extends ServiceImpl<OtaBaSjGnxtwhMapper, O
return getById(id); 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 @Override
public String queryGnxtByKzq(String kzq) { public String queryGnxtByKzq(String kzq) {