Commit dd50eab5 authored by 马33's avatar 马33

设备列表增加SN搜索条件

parent 166dc5af
...@@ -78,20 +78,22 @@ public class DeviceController { ...@@ -78,20 +78,22 @@ public class DeviceController {
*/ */
@ApiOperation(value = "获取设备列表接口", notes = "用于获取设备列表") @ApiOperation(value = "获取设备列表接口", notes = "用于获取设备列表")
@GetMapping("list") @GetMapping("list")
@MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName},#{status}", businessType = BusinessType.SELECT) @MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName},#{sn},#{status}", businessType = BusinessType.SELECT)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示多少页", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页显示多少页", required = true, dataType = "int"),
@ApiImplicitParam(name = "appName", value = "应用名"), @ApiImplicitParam(name = "appName", value = "应用名"),
@ApiImplicitParam(name = "userName", value = "用户名"), @ApiImplicitParam(name = "userName", value = "用户名"),
@ApiImplicitParam(name = "sn", value = "设备编码"),
@ApiImplicitParam(name = "status", value = "状态", dataType = "int") @ApiImplicitParam(name = "status", value = "状态", dataType = "int")
}) })
public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<DeviceVo> getDeviceList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize", defaultValue = "0") int pageSize, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "appName", required = false) String appName, @RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "userName", required = false) String userName, @RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "sn", required = false) String sn,
@RequestParam(value = "status", required = false) Integer status) { @RequestParam(value = "status", required = false) Integer status) {
PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo, pageSize, appName, userName, status); PageInfoModel<DeviceVo> records = deviceService.getDeviceList(pageNo, pageSize, appName, userName, sn, status);
int total = records.getTotal(); int total = records.getTotal();
int pages = total / pageSize;//pages为总页数 int pages = total / pageSize;//pages为总页数
int mod = total % pageSize; int mod = total % pageSize;
......
...@@ -13,7 +13,7 @@ import java.util.List; ...@@ -13,7 +13,7 @@ import java.util.List;
* @since 2022-06-08 * @since 2022-06-08
*/ */
public interface DeviceMapper extends BaseMapper<Device> { public interface DeviceMapper extends BaseMapper<Device> {
List<DeviceVo> getDeviceList(String appName, String userName, Integer status); List<DeviceVo> getDeviceList(String appName, String userName, String sn, Integer status);
boolean addDevice(String sn, String appId); boolean addDevice(String sn, String appId);
} }
...@@ -13,7 +13,7 @@ import iot.sixiang.license.model.vo.DeviceVo; ...@@ -13,7 +13,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
* @since 2022-06-08 * @since 2022-06-08
*/ */
public interface DeviceService extends IService<Device> { public interface DeviceService extends IService<Device> {
PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, Integer status); PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, String sn, Integer status);
boolean addDevice(String appId, int count); boolean addDevice(String appId, int count);
......
...@@ -35,11 +35,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -35,11 +35,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@Override @Override
public PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, Integer status) { public PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName, String sn, Integer status) {
if (pageNo == 0 || pageSize == 0) { if (pageNo == 0 || pageSize == 0) {
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg());
} }
List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName, userName, status); List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName, userName, sn, status);
deviceTypes = deviceTypes.stream().sorted(Comparator.comparing(DeviceVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList()); deviceTypes = deviceTypes.stream().sorted(Comparator.comparing(DeviceVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<DeviceVo> result = new ArrayList<>(); List<DeviceVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
<if test="null != userName and '' != userName"> <if test="null != userName and '' != userName">
and user_name like concat('%',#{userName},'%') and user_name like concat('%',#{userName},'%')
</if> </if>
<if test="null != sn and '' != sn">
and sn like concat('%',#{sn},'%')
</if>
<if test="null != status"> <if test="null != status">
and status = #{status} and status = #{status}
</if> </if>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
SELECT * FROM pms_use_log SELECT * FROM pms_use_log
where 1=1 where 1=1
<if test="null != sn and '' != sn"> <if test="null != sn and '' != sn">
and sn = #{sn} and sn like concat('%',#{sn},'%')
</if> </if>
<if test="null != status"> <if test="null != status">
and status = #{status} and status = #{status}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment