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 fb939d6..965baf3 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 @@ -33,8 +33,8 @@ public class MaTypeInfoController extends BaseController { */ @ApiOperation("首页搜索分类树") @GetMapping("/getEquipmentType") - public AjaxResult getEquipmentType() { - return maTypeInfoSevice.getMaTypeInfoList(); + public AjaxResult getEquipmentType(TypeInfo typeInfo) { + return maTypeInfoSevice.getMaTypeInfoList(typeInfo); } /** 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 62bf2be..687af6c 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 @@ -16,9 +16,10 @@ public interface MaTypeInfoMapper { /** * 查询设备类型列表 + * @param typeInfo * @return */ - public List getMaTypeInfoList() ; + public List getMaTypeInfoList(TypeInfo typeInfo) ; /** * 热搜设备 @@ -32,7 +33,7 @@ public interface MaTypeInfoMapper { * @param typeInfo * @return */ - List getTypeList(TypeInfo typeInfo); + List getParentIdList(TypeInfo typeInfo); /** * 租用需求大厅区域 @@ -40,4 +41,11 @@ public interface MaTypeInfoMapper { * @return */ List getArea(AreaVo areaVo); + + /** + * 查询设备类型 + * @param typeInfo + * @return + */ + TypeInfo getTypeId(TypeInfo typeInfo); } 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 be12bcc..3361395 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 @@ -16,7 +16,7 @@ public interface MaTypeInfoSevice { * 查询分类树 * @return */ - public AjaxResult getMaTypeInfoList(); + public AjaxResult getMaTypeInfoList(TypeInfo typeInfo); /** * 首页搜索热搜装备 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 8f6b137..fe2e48a 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 @@ -28,11 +28,11 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { * @return */ @Override - public AjaxResult getMaTypeInfoList() { + public AjaxResult getMaTypeInfoList(TypeInfo typeInfo) { List groupList = new ArrayList<>(); List list = new ArrayList<>(); try { - list = maTypeInfoMapper.getMaTypeInfoList(); + list = maTypeInfoMapper.getMaTypeInfoList(typeInfo); if (CollectionUtils.isNotEmpty(list)) { // 创建树形结构(数据集合作为参数) TreeBuild treeBuild = new TreeBuild(list); @@ -62,7 +62,23 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { */ @Override public List getTypeList(TypeInfo typeInfo) { - return maTypeInfoMapper.getTypeList(typeInfo); + ArrayList infoArrayList = new ArrayList<>(); + if (typeInfo.getTypeId() == null) { + return maTypeInfoMapper.getParentIdList(typeInfo); + } + List typeList = maTypeInfoMapper.getParentIdList(typeInfo); + TypeInfo info = maTypeInfoMapper.getTypeId(typeInfo); + if (info != null && info.getParentId() != null) { + Long parentId = info.getParentId(); + TypeInfo info1 = new TypeInfo(); + info1.setTypeId(parentId); + List list = maTypeInfoMapper.getParentIdList(info1); + if (CollectionUtils.isNotEmpty(list)) { + infoArrayList.addAll(list); + } + } + infoArrayList.addAll(typeList); + return infoArrayList; } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java index aa85da4..7267570 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/MaLeaseInfo.java @@ -119,6 +119,12 @@ public class MaLeaseInfo extends BaseEntity implements Serializable { @ApiModelProperty(value = "区域名称") private String areaName; + @ApiModelProperty(value = "装备类目id集合") + private List typeIds; + + @ApiModelProperty(value = "装备类目id集合") + private String ids; + @ApiModelProperty(value = "文件信息") private List fileInfoList; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java index 3b875bf..4b76d75 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/domain/vo/MaLeaseVo.java @@ -50,9 +50,6 @@ public class MaLeaseVo extends MaLeaseInfo { @ApiModelProperty(value = "装备三级类目名称") private String thirdName; - @ApiModelProperty(value = "装备类目id集合") - private List typeIds; - @ApiModelProperty(value = "浏览次数") private Integer searchNum; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java index 467f98d..9defb47 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/service/impl/MaLeaseInfoServiceImpl.java @@ -25,8 +25,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 租赁需求大厅实现层 @@ -58,6 +60,9 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService { // 2. 生成需求编号及其他字段 populateLeaseInfoFields(maLeaseInfo); // 3. 插入租赁需求 + if (CollectionUtils.isNotEmpty(maLeaseInfo.getTypeIds())) { + maLeaseInfo.setIds(String.join(",", maLeaseInfo.getTypeIds())); + } int result = leaseInfoMapper.insert(maLeaseInfo); if (result <= 0 || maLeaseInfo.getId() == null) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); @@ -94,6 +99,9 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService { return AjaxResult.error(HttpCodeEnum.LEASE_END_TIME_ERROR.getCode(), HttpCodeEnum.LEASE_END_TIME_ERROR.getMsg()); } } + if (CollectionUtils.isNotEmpty(maLeaseInfo.getTypeIds())) { + maLeaseInfo.setIds(String.join(",", maLeaseInfo.getTypeIds())); + } int result = leaseInfoMapper.updateDevInfo(maLeaseInfo); //首先根据id查询文件信息是否存在 BmFileInfo bmFileInfo = new BmFileInfo(); @@ -129,11 +137,14 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService { if (CollectionUtil.isNotEmpty(fileList)) { maLeaseVo.setFileInfoList(fileList); } - list.add(maLeaseVo.getFirstId()); - list.add(maLeaseVo.getSecondId()); - list.add(maLeaseVo.getThirdId()); - list.add(String.valueOf(maLeaseVo.getTypeId())); - maLeaseVo.setTypeIds(list); + if (StringUtils.isNotBlank(maLeaseVo.getIds())) { + // 使用 StringUtils.split() 按逗号分割 ids 字符串 + String[] idsArray = StringUtils.split(maLeaseVo.getIds(), ","); + // 将分割后的元素添加到 list 中 + // 将分割出来的 id 添加到 list 中 + list.addAll(Arrays.asList(idsArray)); + maLeaseVo.setTypeIds(list); + } //更新搜索量 try { //只针对于待接单状态租赁需求更新浏览量 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 b3133c1..1307063 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 @@ -55,16 +55,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LIMIT 5 - select type_id as typeId, parent_id as parentId, type_name as typeName, `level` as level, del_flag as delFlag, unit_name as unitName from ma_type - where del_flag = '0' and level = '1' + where del_flag = '0' + + and level = '1' + and type_name like concat('%',#{typeName},'%') - - and parent_id = #{parentId} + + and parent_id = #{typeId} @@ -89,4 +92,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + \ No newline at end of file diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml index a23e450..796f9c6 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml @@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lease_name, lease_code, type_id, + type_ids, company_id, area_id, lease_status, @@ -27,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{leaseName}, #{leaseCode}, #{typeId}, + #{ids}, #{companyId}, #{areaId}, #{leaseStatus}, @@ -53,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lease_name = #{leaseName}, type_id = #{typeId}, + type_ids = #{ids}, company_id = #{companyId}, area_id = #{areaId}, lease_day = #{leaseDay}, @@ -89,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.lease_name as leaseName, m.lease_code as leaseCode, m.type_id as typeId, + m.type_ids as ids, mt4.type_name as typeName, m.company_id as companyId, c.company_name as companyName, @@ -108,7 +112,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt2.type_name as secondName, mt1.type_id as firstId, mt1.type_name as firstName, - GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName, + CASE + -- 第一级 + WHEN mt1.type_id IS NULL + AND mt2.type_id IS NULL + AND mt3.type_id IS NULL + AND mt4.type_id IS NOT NULL THEN + mt4.type_name + -- 第二级 + WHEN mt1.type_id IS NULL + AND mt2.type_id IS NULL + AND mt3.type_id IS NOT NULL + AND mt4.type_id IS NOT NULL THEN + CONCAT( mt3.type_name, '/', mt4.type_name ) + -- 第三级 + WHEN mt1.type_id IS NULL + AND mt2.type_id IS NOT NULL + AND mt3.type_id IS NOT NULL + AND mt4.type_id IS NOT NULL THEN + CONCAT( mt2.type_name, '/', mt3.type_name, '/', mt4.type_name ) + -- 第四级 + WHEN mt1.type_id IS NOT NULL + AND mt2.type_id IS NOT NULL + AND mt3.type_id IS NOT NULL + AND mt4.type_id IS NOT NULL THEN + CONCAT( mt1.type_name, '/', mt2.type_name, '/', mt3.type_name, '/', mt4.type_name ) + ELSE NULL + END AS groupName, m.publish_user as publishUser, m.area_id as areaId, b.name as areaName @@ -190,34 +220,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"