电池基础信息(包含二维码)实现
This commit is contained in:
parent
0c1b29f74e
commit
a2e40fedbd
@ -5,13 +5,19 @@ import com.cdzy.common.model.request.PageParam;
|
|||||||
import com.cdzy.common.model.response.JsonResult;
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
import com.cdzy.operations.enums.BatteryStatus;
|
import com.cdzy.operations.enums.BatteryStatus;
|
||||||
import com.cdzy.operations.model.entity.EbikeBatteryInfo;
|
import com.cdzy.operations.model.entity.EbikeBatteryInfo;
|
||||||
|
import com.cdzy.operations.model.vo.EbikeBatteryInfoIdVo;
|
||||||
import com.cdzy.operations.model.vo.EbikeBatteryInfoVo;
|
import com.cdzy.operations.model.vo.EbikeBatteryInfoVo;
|
||||||
import com.cdzy.operations.service.EbikeBatteryInfoService;
|
import com.cdzy.operations.service.EbikeBatteryInfoService;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.core.update.UpdateChain;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.cdzy.operations.model.entity.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电池基本信息 控制层。
|
* 电池基本信息 控制层。
|
||||||
@ -39,13 +45,13 @@ public class EbikeBatteryInfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产电池二维码。
|
* 绑定电池二维码。
|
||||||
*
|
*
|
||||||
* @param batteryId 电池ID
|
* @param batteryId 电池ID
|
||||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||||
*/
|
*/
|
||||||
@GetMapping("bind")
|
@GetMapping("bind")
|
||||||
public JsonResult<?> bind(@RequestParam("batteryId")Long batteryId) throws Exception {
|
public JsonResult<?> bind(@RequestParam("batteryId")Long batteryId){
|
||||||
EbikeBatteryInfo batteryInfo = ebikeBatteryInfoService.getById(batteryId);
|
EbikeBatteryInfo batteryInfo = ebikeBatteryInfoService.getById(batteryId);
|
||||||
if (batteryInfo == null) {
|
if (batteryInfo == null) {
|
||||||
throw new EbikeException("电池ID错误");
|
throw new EbikeException("电池ID错误");
|
||||||
@ -55,14 +61,28 @@ public class EbikeBatteryInfoController {
|
|||||||
return JsonResult.success();
|
return JsonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量绑定电池二维码。
|
||||||
|
*
|
||||||
|
* @param ids 电池ID集合
|
||||||
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||||
|
*/
|
||||||
|
@GetMapping("batchBind")
|
||||||
|
public JsonResult<?> batchBind(@RequestBody EbikeBatteryInfoIdVo ids){
|
||||||
|
UpdateChain.of(EbikeBatteryInfo.class)
|
||||||
|
.set(EbikeBatteryInfo::getStatus, BatteryStatus.BIND)
|
||||||
|
.where(EbikeBatteryInfo::getBatteryId).in(ids.getBatteryIds());
|
||||||
|
return JsonResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主键删除电池二维码信息。
|
* 根据主键删除电池二维码信息。
|
||||||
*
|
*
|
||||||
* @param batteryId 主键
|
* @param batteryId 主键
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("remove")
|
@PostMapping("remove")
|
||||||
public JsonResult<?> remove(@RequestParam(value = "batteryId", required = true) Long batteryId) {
|
public JsonResult<?> remove(@RequestParam(value = "batteryId") Long batteryId) {
|
||||||
ebikeBatteryInfoService.removeById(batteryId);
|
ebikeBatteryInfoService.removeById(batteryId);
|
||||||
return JsonResult.success();
|
return JsonResult.success();
|
||||||
}
|
}
|
||||||
@ -86,8 +106,10 @@ public class EbikeBatteryInfoController {
|
|||||||
* @return 分页对象
|
* @return 分页对象
|
||||||
*/
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
public JsonResult<?> page(PageParam pageParam) {
|
public JsonResult<?> page(PageParam pageParam,Integer status) {
|
||||||
Page<EbikeBatteryInfo> page = ebikeBatteryInfoService.page(pageParam.getPage());
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BATTERY_INFO.STATUS.eq(status, Objects.nonNull(status)));
|
||||||
|
Page<EbikeBatteryInfo> page = ebikeBatteryInfoService.page(pageParam.getPage(),queryWrapper);
|
||||||
return JsonResult.success(page);
|
return JsonResult.success(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
package com.cdzy.operations.controller;
|
package com.cdzy.operations.controller;
|
||||||
|
|
||||||
import com.cdzy.common.model.response.JsonResult;
|
import com.cdzy.common.model.response.JsonResult;
|
||||||
|
import com.cdzy.operations.model.entity.EbikeInventory;
|
||||||
import com.cdzy.operations.model.vo.EbikeInventoryVo;
|
import com.cdzy.operations.model.vo.EbikeInventoryVo;
|
||||||
import com.cdzy.operations.service.EbikeInventoryService;
|
import com.cdzy.operations.service.EbikeInventoryService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 库存表 控制层。
|
* 库存表 控制层。
|
||||||
@ -46,4 +46,15 @@ public class EbikeInventoryController {
|
|||||||
return JsonResult.success();
|
return JsonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库存总览。
|
||||||
|
*
|
||||||
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||||
|
*/
|
||||||
|
@GetMapping("list")
|
||||||
|
public JsonResult<?> list() {
|
||||||
|
List<EbikeInventory> list = ebikeInventoryService.list();
|
||||||
|
return JsonResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.cdzy.operations.model.vo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池基本信息。
|
||||||
|
*
|
||||||
|
* @author attiya
|
||||||
|
* @since 2025-09-15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EbikeBatteryInfoIdVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "电池ID集合不能为空")
|
||||||
|
private List<Long> batteryIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -41,7 +41,8 @@ public class EbikeInventoryServiceImpl extends ServiceImpl<EbikeInventoryMapper,
|
|||||||
throw new EbikeException("添加库存时填入数量不能小于/等于0");
|
throw new EbikeException("添加库存时填入数量不能小于/等于0");
|
||||||
}
|
}
|
||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
.where(EBIKE_INVENTORY.INVENTORY_TYPE.eq(ebikeInventory.getInventoryType()));
|
.where(EBIKE_INVENTORY.INVENTORY_TYPE.eq(ebikeInventory.getInventoryType()))
|
||||||
|
.where(EBIKE_INVENTORY.OPERATOR_ID.eq(ebikeInventory.getOperatorId()));
|
||||||
EbikeInventory inventory = this.mapper.selectOneByQuery(queryWrapper);
|
EbikeInventory inventory = this.mapper.selectOneByQuery(queryWrapper);
|
||||||
if (inventory != null) {
|
if (inventory != null) {
|
||||||
long num = inventory.getInventoryNum() + ebikeInventory.getInventoryNum();
|
long num = inventory.getInventoryNum() + ebikeInventory.getInventoryNum();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user