diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java index 6f6e017..db775e5 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java @@ -17,7 +17,7 @@ public class TreeNode { private long id; - private String label; + private String name; private long parentId; @@ -27,6 +27,9 @@ public class TreeNode { @JsonInclude(JsonInclude.Include.NON_EMPTY) private String unitName; + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private String manageType; + @JsonInclude(JsonInclude.Include.NON_EMPTY) private String companyId; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java index e542757..78ef868 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java @@ -1,6 +1,9 @@ package com.bonus.material.device.controller; +import cn.hutool.core.convert.Convert; +import com.bonus.common.biz.config.ListPagingUtil; import com.bonus.common.biz.domain.BmCompanyInfo; +import com.bonus.common.core.utils.ServletUtils; import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; @@ -17,6 +20,9 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.List; +import static com.bonus.common.core.web.page.TableSupport.PAGE_NUM; +import static com.bonus.common.core.web.page.TableSupport.PAGE_SIZE; + /** * 设备信息Controller * @@ -35,11 +41,12 @@ public class DevInfoController extends BaseController { */ // @RequiresPermissions("equip:info:list") @ApiOperation(value = "装备列表") - @GetMapping("/list") - public TableDataInfo list(DevInfoVo devInfo) { - startPage(); + @PostMapping("/list") + public AjaxResult list(@RequestBody DevInfoVo devInfo) { List list = devInfoService.selectDevInfoList(devInfo); - return getDataTable(list); + Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); + Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java index 2d3564e..ddf7bd0 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java @@ -1,10 +1,8 @@ package com.bonus.material.home.controller; -import cn.hutool.core.lang.tree.Tree; import com.bonus.common.biz.domain.TypeInfo; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.material.device.domain.vo.DevInfoVo; import com.bonus.material.home.service.MaTypeInfoSevice; import io.swagger.annotations.Api; @@ -34,9 +32,8 @@ public class MaTypeInfoController extends BaseController { */ @ApiOperation("首页搜索分类树") @GetMapping("/getEquipmentType") - public TableDataInfo getEquipmentType() { - List> list = maTypeInfoSevice.getMaTypeInfoList(); - return getDataTable(list); + public AjaxResult getEquipmentType() { + return maTypeInfoSevice.getMaTypeInfoList(); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java index 8e0fba8..5e8c071 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java @@ -1,6 +1,7 @@ package com.bonus.material.home.mapper; +import com.bonus.common.biz.domain.TreeNode; import com.bonus.common.biz.domain.TypeInfo; import com.bonus.material.device.domain.vo.DevInfoVo; @@ -16,7 +17,7 @@ public interface MaTypeInfoMapper { * 查询设备类型列表 * @return */ - public List getMaTypeInfoList() ; + public List getMaTypeInfoList() ; /** * 热搜设备 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java index 51a7b2a..49b40bf 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java @@ -1,7 +1,7 @@ package com.bonus.material.home.service; -import cn.hutool.core.lang.tree.Tree; import com.bonus.common.biz.domain.TypeInfo; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.device.domain.vo.DevInfoVo; import java.util.List; @@ -15,7 +15,7 @@ public interface MaTypeInfoSevice { * 查询分类树 * @return */ - public List> getMaTypeInfoList(); + public AjaxResult getMaTypeInfoList(); /** * 首页搜索热搜装备 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java index ac4c480..61037f9 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java @@ -1,20 +1,22 @@ package com.bonus.material.home.service.impl; -import cn.hutool.core.lang.tree.Tree; -import cn.hutool.core.lang.tree.TreeNode; -import cn.hutool.core.lang.tree.TreeUtil; +import com.bonus.common.biz.domain.TreeBuild; +import com.bonus.common.biz.domain.TreeNode; import com.bonus.common.biz.domain.TypeInfo; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.device.domain.vo.DevInfoVo; import com.bonus.material.home.mapper.MaTypeInfoMapper; import com.bonus.material.home.service.MaTypeInfoSevice; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; @Service +@Slf4j public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { @Resource @@ -25,11 +27,21 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { * @return */ @Override - public List> getMaTypeInfoList() { - List maTypeInfoList = maTypeInfoMapper.getMaTypeInfoList(); - List> collect = maTypeInfoList - .stream().map(getNodeFunction()).collect(Collectors.toList()); - return TreeUtil.build(collect,0L); + public AjaxResult getMaTypeInfoList() { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = maTypeInfoMapper.getMaTypeInfoList(); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("设备类型树-查询失败", e); + } + return AjaxResult.success(groupList); } /** @@ -51,19 +63,4 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { return maTypeInfoMapper.getTypeList(typeInfo); } - /** - * 获取节点转换函数方法抽取 - * @return - */ - private Function> getNodeFunction() { - - return typeInfo -> { - TreeNode node = new TreeNode<>(); - node.setId(typeInfo.getTypeId()); - node.setName(typeInfo.getTypeName()); - node.setParentId(typeInfo.getParentId()); - node.setWeight(typeInfo.getLevel()); - return node; - }; - } } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 2f69584..286a295 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -89,24 +89,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0' and d.ma_id = #{maId} - and d.ma_status = #{maStatus} and d.code = #{code} and d.device_name like concat('%',#{deviceName},'%') - - and d.type_id = #{typeId} - - - and mt3.type_id = #{typeId} - - - and mt2.type_id = #{typeId} - - - and mt1.type_id = #{typeId} - + + + and d.type_id = #{typeId} + + + and mt3.type_id = #{typeId} + + + and mt2.type_id = #{typeId} + + + and mt1.type_id = #{typeId} + + and d.ma_status = #{maStatus} and d.lease_scope = #{leaseScope} @@ -120,6 +121,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) >= #{ageMin} * 365 and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) <= #{ageMax} * 365 + + and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) > #{ageMax} * 365 + and d.working_hours >= #{workingHoursMin} and d.working_hours <= #{workingHoursMax} @@ -129,7 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and d.description = #{description} and d.gps_code = #{gpsCode} - and d.own_co = #{companyId} + and d.own_co = #{companyId} and d.specification = #{specification} and d.deposit = #{deposit} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml index fc08fe5..5bfa3e2 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml @@ -19,11 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where del_flag = '0' - + + \ No newline at end of file