|
|
@@ -1,28 +1,39 @@
|
|
|
package com.zd.airbottle.controller;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zd.airbottle.domain.DbBeacon;
|
|
|
import com.zd.airbottle.domain.DbStock;
|
|
|
import com.zd.airbottle.domain.bo.DbBeaconBo;
|
|
|
import com.zd.airbottle.domain.vo.DbBeaconPrintVo;
|
|
|
+import com.zd.airbottle.domain.vo.DbBeaconVo;
|
|
|
import com.zd.airbottle.service.DbBeaconService;
|
|
|
import com.zd.airbottle.service.DbStockService;
|
|
|
import com.zd.airbottle.utils.PageUtil;
|
|
|
import com.zd.common.core.annotation.Log;
|
|
|
import com.zd.common.core.annotation.PreAuthorize;
|
|
|
import com.zd.common.core.log.BusinessType;
|
|
|
+import com.zd.common.core.utils.DictUtils;
|
|
|
import com.zd.common.core.utils.StringUtils;
|
|
|
import com.zd.common.core.web.controller.AbstractController;
|
|
|
import com.zd.model.domain.ResultData;
|
|
|
import com.zd.model.domain.per.PerFun;
|
|
|
import com.zd.model.domain.per.PerPrefix;
|
|
|
+import com.zd.system.api.entity.SysDictData;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @Description 东北大学信标
|
|
|
* @Author hzw
|
|
|
@@ -130,10 +141,58 @@ public class DbBeaconController extends AbstractController {
|
|
|
if (StringUtils.isNotBlank(dbBeaconBo.getSearchValue())) {
|
|
|
queryWrapper.like(DbBeacon::getBeaconTag, dbBeaconBo.getSearchValue());
|
|
|
}
|
|
|
+ //state条件
|
|
|
+ if (StringUtils.isNotNull(dbBeaconBo.getState())) {
|
|
|
+ queryWrapper.eq(DbBeacon::getState, dbBeaconBo.getState());
|
|
|
+ }
|
|
|
//倒叙
|
|
|
queryWrapper.orderByDesc(DbBeacon::getId);
|
|
|
IPage<DbBeacon> result = dbBeaconService.page(PageUtil.getQuery(dbBeaconBo.getPageNum(), dbBeaconBo.getPageSize()), queryWrapper);
|
|
|
- return ResultData.success(result);
|
|
|
+ IPage<DbBeaconVo> newResult = new Page <>();
|
|
|
+ if(!result.getRecords().isEmpty()){
|
|
|
+ List <String> beaconTags = Optional.ofNullable(result.getRecords()).orElseGet(Collections::emptyList)
|
|
|
+ .stream()
|
|
|
+ .map(a->a.getBeaconTag())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //查询条件
|
|
|
+ LambdaQueryWrapper<DbStock> stockWrapper = new LambdaQueryWrapper<>();
|
|
|
+ stockWrapper.in(DbStock::getBeaconTag,beaconTags);
|
|
|
+ List<DbStock> dbStockList = dbStockService.list(stockWrapper);
|
|
|
+ List<DbBeaconVo> beaconVoList = new ArrayList <>();
|
|
|
+
|
|
|
+ List<SysDictData> bottleSpecifList = DictUtils.getDictCache("gasBottleSpecification");
|
|
|
+ List<SysDictData> bottleLevelList = DictUtils.getDictCache("gasBottleLevel");
|
|
|
+ StringBuilder bottleSpecif = new StringBuilder();
|
|
|
+ for(DbBeacon dbBeacon:result.getRecords()){
|
|
|
+ DbBeaconVo dbBeaconVo = new DbBeaconVo();
|
|
|
+ BeanUtil.copyProperties(dbBeacon,dbBeaconVo);
|
|
|
+ for(DbStock dbStock:dbStockList){
|
|
|
+ if(dbBeacon.getBeaconTag().equals(dbStock.getBeaconTag())){
|
|
|
+ dbBeaconVo.setGasName(dbStock.getGasName());
|
|
|
+ for(SysDictData dictData:bottleLevelList){
|
|
|
+ if(dictData.getDictValue().equals(dbStock.getLevel()+"")){
|
|
|
+ bottleSpecif.append(dictData.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bottleSpecif.append("-");
|
|
|
+
|
|
|
+ for(SysDictData dictData:bottleSpecifList){
|
|
|
+ if(dictData.getDictValue().equals(dbStock.getSize()+"")){
|
|
|
+ bottleSpecif.append(dictData.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbBeaconVo.setSize(bottleSpecif.toString());
|
|
|
+ dbBeaconVo.setSubjectName(dbStock.getSubjectName());
|
|
|
+ bottleSpecif.setLength(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ beaconVoList.add(dbBeaconVo);
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(result,newResult);
|
|
|
+ newResult.setRecords(beaconVoList);
|
|
|
+ }
|
|
|
+ return ResultData.success(newResult);
|
|
|
}
|
|
|
|
|
|
/**
|