接口联调优化

This commit is contained in:
mashuai 2024-12-01 16:26:11 +08:00
parent 77e577c22d
commit d60dba621b
9 changed files with 161 additions and 49 deletions

View File

@ -33,8 +33,8 @@ public class MaTypeInfoController extends BaseController {
*/ */
@ApiOperation("首页搜索分类树") @ApiOperation("首页搜索分类树")
@GetMapping("/getEquipmentType") @GetMapping("/getEquipmentType")
public AjaxResult getEquipmentType() { public AjaxResult getEquipmentType(TypeInfo typeInfo) {
return maTypeInfoSevice.getMaTypeInfoList(); return maTypeInfoSevice.getMaTypeInfoList(typeInfo);
} }
/** /**

View File

@ -16,9 +16,10 @@ public interface MaTypeInfoMapper {
/** /**
* 查询设备类型列表 * 查询设备类型列表
* @param typeInfo
* @return * @return
*/ */
public List<TreeNode> getMaTypeInfoList() ; public List<TreeNode> getMaTypeInfoList(TypeInfo typeInfo) ;
/** /**
* 热搜设备 * 热搜设备
@ -32,7 +33,7 @@ public interface MaTypeInfoMapper {
* @param typeInfo * @param typeInfo
* @return * @return
*/ */
List<TypeInfo> getTypeList(TypeInfo typeInfo); List<TypeInfo> getParentIdList(TypeInfo typeInfo);
/** /**
* 租用需求大厅区域 * 租用需求大厅区域
@ -40,4 +41,11 @@ public interface MaTypeInfoMapper {
* @return * @return
*/ */
List<AreaVo> getArea(AreaVo areaVo); List<AreaVo> getArea(AreaVo areaVo);
/**
* 查询设备类型
* @param typeInfo
* @return
*/
TypeInfo getTypeId(TypeInfo typeInfo);
} }

View File

@ -16,7 +16,7 @@ public interface MaTypeInfoSevice {
* 查询分类树 * 查询分类树
* @return * @return
*/ */
public AjaxResult getMaTypeInfoList(); public AjaxResult getMaTypeInfoList(TypeInfo typeInfo);
/** /**
* 首页搜索热搜装备 * 首页搜索热搜装备

View File

@ -28,11 +28,11 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
* @return * @return
*/ */
@Override @Override
public AjaxResult getMaTypeInfoList() { public AjaxResult getMaTypeInfoList(TypeInfo typeInfo) {
List<TreeNode> groupList = new ArrayList<>(); List<TreeNode> groupList = new ArrayList<>();
List<TreeNode> list = new ArrayList<>(); List<TreeNode> list = new ArrayList<>();
try { try {
list = maTypeInfoMapper.getMaTypeInfoList(); list = maTypeInfoMapper.getMaTypeInfoList(typeInfo);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
// 创建树形结构数据集合作为参数 // 创建树形结构数据集合作为参数
TreeBuild treeBuild = new TreeBuild(list); TreeBuild treeBuild = new TreeBuild(list);
@ -62,7 +62,23 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
*/ */
@Override @Override
public List<TypeInfo> getTypeList(TypeInfo typeInfo) { public List<TypeInfo> getTypeList(TypeInfo typeInfo) {
return maTypeInfoMapper.getTypeList(typeInfo); ArrayList<TypeInfo> infoArrayList = new ArrayList<>();
if (typeInfo.getTypeId() == null) {
return maTypeInfoMapper.getParentIdList(typeInfo);
}
List<TypeInfo> 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<TypeInfo> list = maTypeInfoMapper.getParentIdList(info1);
if (CollectionUtils.isNotEmpty(list)) {
infoArrayList.addAll(list);
}
}
infoArrayList.addAll(typeList);
return infoArrayList;
} }
/** /**

View File

@ -119,6 +119,12 @@ public class MaLeaseInfo extends BaseEntity implements Serializable {
@ApiModelProperty(value = "区域名称") @ApiModelProperty(value = "区域名称")
private String areaName; private String areaName;
@ApiModelProperty(value = "装备类目id集合")
private List<String> typeIds;
@ApiModelProperty(value = "装备类目id集合")
private String ids;
@ApiModelProperty(value = "文件信息") @ApiModelProperty(value = "文件信息")
private List<BmFileInfo> fileInfoList; private List<BmFileInfo> fileInfoList;
} }

View File

@ -50,9 +50,6 @@ public class MaLeaseVo extends MaLeaseInfo {
@ApiModelProperty(value = "装备三级类目名称") @ApiModelProperty(value = "装备三级类目名称")
private String thirdName; private String thirdName;
@ApiModelProperty(value = "装备类目id集合")
private List<String> typeIds;
@ApiModelProperty(value = "浏览次数") @ApiModelProperty(value = "浏览次数")
private Integer searchNum; private Integer searchNum;
} }

View File

@ -25,8 +25,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 租赁需求大厅实现层 * 租赁需求大厅实现层
@ -58,6 +60,9 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService {
// 2. 生成需求编号及其他字段 // 2. 生成需求编号及其他字段
populateLeaseInfoFields(maLeaseInfo); populateLeaseInfoFields(maLeaseInfo);
// 3. 插入租赁需求 // 3. 插入租赁需求
if (CollectionUtils.isNotEmpty(maLeaseInfo.getTypeIds())) {
maLeaseInfo.setIds(String.join(",", maLeaseInfo.getTypeIds()));
}
int result = leaseInfoMapper.insert(maLeaseInfo); int result = leaseInfoMapper.insert(maLeaseInfo);
if (result <= 0 || maLeaseInfo.getId() == null) { if (result <= 0 || maLeaseInfo.getId() == null) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); 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()); 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); int result = leaseInfoMapper.updateDevInfo(maLeaseInfo);
//首先根据id查询文件信息是否存在 //首先根据id查询文件信息是否存在
BmFileInfo bmFileInfo = new BmFileInfo(); BmFileInfo bmFileInfo = new BmFileInfo();
@ -129,11 +137,14 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService {
if (CollectionUtil.isNotEmpty(fileList)) { if (CollectionUtil.isNotEmpty(fileList)) {
maLeaseVo.setFileInfoList(fileList); maLeaseVo.setFileInfoList(fileList);
} }
list.add(maLeaseVo.getFirstId()); if (StringUtils.isNotBlank(maLeaseVo.getIds())) {
list.add(maLeaseVo.getSecondId()); // 使用 StringUtils.split() 按逗号分割 ids 字符串
list.add(maLeaseVo.getThirdId()); String[] idsArray = StringUtils.split(maLeaseVo.getIds(), ",");
list.add(String.valueOf(maLeaseVo.getTypeId())); // 将分割后的元素添加到 list
maLeaseVo.setTypeIds(list); // 将分割出来的 id 添加到 list
list.addAll(Arrays.asList(idsArray));
maLeaseVo.setTypeIds(list);
}
//更新搜索量 //更新搜索量
try { try {
//只针对于待接单状态租赁需求更新浏览量 //只针对于待接单状态租赁需求更新浏览量

View File

@ -55,16 +55,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 5 LIMIT 5
</select> </select>
<select id="getTypeList" resultType="com.bonus.common.biz.domain.TypeInfo"> <select id="getParentIdList" resultType="com.bonus.common.biz.domain.TypeInfo">
select select
type_id as typeId, parent_id as parentId, type_name as typeName, `level` as level, del_flag as delFlag, unit_name as unitName 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 from ma_type
where del_flag = '0' and level = '1' where del_flag = '0'
<if test="typeId == null">
and level = '1'
</if>
<if test="typeName != null and typeName != ''"> <if test="typeName != null and typeName != ''">
and type_name like concat('%',#{typeName},'%') and type_name like concat('%',#{typeName},'%')
</if> </if>
<if test="parentId != null and parentId != ''"> <if test="typeId != null">
and parent_id = #{parentId} and parent_id = #{typeId}
</if> </if>
</select> </select>
@ -89,4 +92,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</select> </select>
<select id="getTypeId" resultType="com.bonus.common.biz.domain.TypeInfo">
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'
<if test="typeId != null">
and type_id = #{typeId}
</if>
</select>
</mapper> </mapper>

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leaseName != null and leaseName != ''">lease_name,</if> <if test="leaseName != null and leaseName != ''">lease_name,</if>
<if test="leaseCode != null and leaseCode != ''">lease_code,</if> <if test="leaseCode != null and leaseCode != ''">lease_code,</if>
<if test="typeId != null">type_id,</if> <if test="typeId != null">type_id,</if>
<if test="ids != null">type_ids,</if>
<if test="companyId != null">company_id,</if> <if test="companyId != null">company_id,</if>
<if test="areaId != null">area_id,</if> <if test="areaId != null">area_id,</if>
<if test="leaseStatus != null">lease_status,</if> <if test="leaseStatus != null">lease_status,</if>
@ -27,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leaseName != null and leaseName != ''">#{leaseName},</if> <if test="leaseName != null and leaseName != ''">#{leaseName},</if>
<if test="leaseCode != null and leaseCode != ''">#{leaseCode},</if> <if test="leaseCode != null and leaseCode != ''">#{leaseCode},</if>
<if test="typeId != null">#{typeId},</if> <if test="typeId != null">#{typeId},</if>
<if test="ids != null">#{ids},</if>
<if test="companyId != null">#{companyId},</if> <if test="companyId != null">#{companyId},</if>
<if test="areaId != null">#{areaId},</if> <if test="areaId != null">#{areaId},</if>
<if test="leaseStatus != null">#{leaseStatus},</if> <if test="leaseStatus != null">#{leaseStatus},</if>
@ -53,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="leaseName != null and leaseName != ''">lease_name = #{leaseName},</if> <if test="leaseName != null and leaseName != ''">lease_name = #{leaseName},</if>
<if test="typeId != null">type_id = #{typeId},</if> <if test="typeId != null">type_id = #{typeId},</if>
<if test="ids != null">type_ids = #{ids},</if>
<if test="companyId != null">company_id = #{companyId},</if> <if test="companyId != null">company_id = #{companyId},</if>
<if test="areaId != null">area_id = #{areaId},</if> <if test="areaId != null">area_id = #{areaId},</if>
<if test="leaseDay != null ">lease_day = #{leaseDay},</if> <if test="leaseDay != null ">lease_day = #{leaseDay},</if>
@ -89,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.lease_name as leaseName, m.lease_name as leaseName,
m.lease_code as leaseCode, m.lease_code as leaseCode,
m.type_id as typeId, m.type_id as typeId,
m.type_ids as ids,
mt4.type_name as typeName, mt4.type_name as typeName,
m.company_id as companyId, m.company_id as companyId,
c.company_name as companyName, c.company_name as companyName,
@ -108,7 +112,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt2.type_name as secondName, mt2.type_name as secondName,
mt1.type_id as firstId, mt1.type_id as firstId,
mt1.type_name as firstName, 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.publish_user as publishUser,
m.area_id as areaId, m.area_id as areaId,
b.name as areaName b.name as areaName
@ -190,34 +220,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="leaseList" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo"> <select id="leaseList" resultType="com.bonus.material.lease.domain.vo.MaLeaseVo">
SELECT SELECT
m.id as id, m.id as id,
m.lease_name as leaseName, m.lease_name as leaseName,
m.lease_code as leaseCode, m.lease_code as leaseCode,
m.type_id as typeId, m.type_id as typeId,
mt4.type_name as typeName, mt4.type_name as typeName,
m.company_id as companyId, m.company_id as companyId,
c.company_name as companyName, c.company_name as companyName,
c.operate_address as operateAddress, c.operate_address as operateAddress,
m.lease_status as leaseStatus, m.lease_status as leaseStatus,
m.lease_day as leaseDay, m.lease_day as leaseDay,
m.lease_num as leaseNum, m.lease_num as leaseNum,
m.start_time as startTime, m.start_time as startTime,
m.end_time as endTime, m.end_time as endTime,
m.person as person, m.person as person,
m.person_phone as personPhone, m.person_phone as personPhone,
m.description as description, m.description as description,
mt3.type_id as thirdId, mt3.type_id as thirdId,
mt3.type_name as thirdName, mt3.type_name as thirdName,
mt2.type_id as secondId, mt2.type_id as secondId,
mt2.type_name as secondName, mt2.type_name as secondName,
mt1.type_id as firstId, mt1.type_id as firstId,
mt1.type_name as firstName, mt1.type_name as firstName,
GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName, CASE
m.publish_user as publishUser, -- 第一级
b.id as areaId, WHEN mt1.type_id IS NULL
b.name as areaName 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,
b.id as areaId,
b.name as areaName
FROM FROM
ma_lease_info m ma_lease_info m
LEFT JOIN bm_company_info c ON m.company_id = c.company_id LEFT JOIN bm_company_info c ON m.company_id = c.company_id
LEFT JOIN base_address b ON b.id = m.area_id LEFT JOIN base_address b ON b.id = m.area_id
LEFT JOIN sys_user su ON m.publish_user = su.user_id LEFT JOIN sys_user su ON m.publish_user = su.user_id
@ -238,7 +294,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and mt2.type_id = #{typeId} and mt2.type_id = #{typeId}
</when> </when>
<when test="level != null and level == 1"> <when test="level != null and level == 1">
and mt1.type_id = #{typeId} and (
mt1.type_id = 1
OR mt2.type_id = 1
OR mt3.type_id = 1
OR mt4.type_id = 1
)
</when> </when>
</choose> </choose>
</if> </if>