This commit is contained in:
parent
0e4a1e2b73
commit
7d28aab41f
@ -45,7 +45,7 @@ public class MaterialController {
|
|||||||
.initialCapacity(10)
|
.initialCapacity(10)
|
||||||
.maximumSize(300)
|
.maximumSize(300)
|
||||||
.recordStats()
|
.recordStats()
|
||||||
.build(new CacheLoader<String,String>() {
|
.build(new CacheLoader<String, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -64,18 +64,19 @@ public class MaterialController {
|
|||||||
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key) {
|
@Parameter(description = "搜索关键词") @RequestParam(required = false, defaultValue = "") String key) {
|
||||||
boolean hasLike = Strings.isNotBlank(key);
|
boolean hasLike = Strings.isNotBlank(key);
|
||||||
key = String.format("%%%s%%", key);
|
key = String.format("%%%s%%", key);
|
||||||
return materialService.page(Page.of(page, size),Wrappers.<Material>lambdaQuery()
|
return materialService.page(Page.of(page, size), Wrappers.<Material>lambdaQuery()
|
||||||
|
|
||||||
.like(hasLike, Material::getName, key)
|
.like(hasLike, Material::getName, key)
|
||||||
.or()
|
.or()
|
||||||
.like(hasLike, Material::getCode, key)
|
.like(hasLike, Material::getCode, key)
|
||||||
.eq(type != null, Material::getType, type)
|
.or()
|
||||||
|
.like(hasLike, Material::getType, key)
|
||||||
.orderByDesc(Material::getUpdatedTime));
|
.orderByDesc(Material::getUpdatedTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("material/list")
|
@GetMapping("material/list")
|
||||||
@Operation(summary = "查询所有物料列表")
|
@Operation(summary = "查询所有物料列表")
|
||||||
public List<Material> all(){
|
public List<Material> all() {
|
||||||
return materialService.list();
|
return materialService.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ public class MaterialController {
|
|||||||
throw BizException.create("保存物料失败!");
|
throw BizException.create("保存物料失败!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (materialService.update(material, Wrappers.<Material> lambdaUpdate().eq(Material::getId, material.getId()))) {
|
if (materialService.update(material, Wrappers.<Material>lambdaUpdate().eq(Material::getId, material.getId()))) {
|
||||||
return material;
|
return material;
|
||||||
} else {
|
} else {
|
||||||
throw BizException.create("更新物料失败!");
|
throw BizException.create("更新物料失败!");
|
||||||
@ -133,14 +134,14 @@ public class MaterialController {
|
|||||||
// 批量生成条形码
|
// 批量生成条形码
|
||||||
@PostMapping("material/{id}/generate-barcodes")
|
@PostMapping("material/{id}/generate-barcodes")
|
||||||
@Operation(summary = "批量生成条形码")
|
@Operation(summary = "批量生成条形码")
|
||||||
public List<String> generateBarcodes(@Parameter(description = "物料id", required = true) @PathVariable Long id,
|
public List<String> generateBarcodes(@Parameter(description = "物料id", required = true) @PathVariable Long id,
|
||||||
@Parameter(description = "条形码数量", required = true) @RequestParam(name = "count") int count) {
|
@Parameter(description = "条形码数量", required = true) @RequestParam(name = "count") int count) {
|
||||||
List<String> res = new ArrayList<>();
|
List<String> res = new ArrayList<>();
|
||||||
Material byId = materialService.getById(id);
|
Material byId = materialService.getById(id);
|
||||||
if (byId != null && count > 0) {
|
if (byId != null && count > 0) {
|
||||||
String code = byId.getCode();
|
String code = byId.getCode();
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
res.add(code + BarcodeUtil.generateBarcode());
|
res.add(code + BarcodeUtil.generateBarcode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("生成条形码成功,条形码列表:{}", res);
|
log.info("生成条形码成功,条形码列表:{}", res);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user