Commit 2c2f7ce5 authored by 田涛's avatar 田涛

Bug-972修复 电力设备添加配套设备查询接口

parent 6d6dc83f
...@@ -7,8 +7,10 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -7,8 +7,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
...@@ -22,7 +24,7 @@ import java.util.List; ...@@ -22,7 +24,7 @@ import java.util.List;
@Accessors(chain = true) @Accessors(chain = true)
@TableName("wl_equipment_category") @TableName("wl_equipment_category")
@ApiModel(value="EquipmentCategory装备分类实体", description="装备分类") @ApiModel(value="EquipmentCategory装备分类实体", description="装备分类")
public class EquipmentCategory extends BaseEntity { public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentCategory, Long> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -56,5 +58,24 @@ public class EquipmentCategory extends BaseEntity { ...@@ -56,5 +58,24 @@ public class EquipmentCategory extends BaseEntity {
@TableField(exist=false) @TableField(exist=false)
private List<EquipmentCategory> children = new ArrayList<>(); //子集 private List<EquipmentCategory> children = new ArrayList<>(); //子集
@Override
public Long getMyParentId() {
return parentId;
}
@Override
public Long getMyId() {
return getId();
}
@Override
public void setChildren(Collection<EquipmentCategory> collection) {
this.children = new ArrayList<>(collection);
}
@Override
public int compareTo(EquipmentCategory o) {
return this.getId().compareTo(o.getId());
}
} }
...@@ -88,7 +88,15 @@ public class EquipmentSpecificController extends BaseController{ ...@@ -88,7 +88,15 @@ public class EquipmentSpecificController extends BaseController{
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpe(name, code, pageNumber, pageSize,equipmentId)); return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpe(name, code, pageNumber, pageSize,equipmentId));
} }
@GetMapping(value = "/getEquipmentBySpeV2")
@ApiOperation(httpMethod = "GET", value = "获取装备台账信息", notes = "获取装备台账信息")
public CommonResponse getEquipmentBySpeV2(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "pageNumber",required = false) int pageNumber,
@RequestParam(value = "pageSize",required = false) int pageSize,
@RequestParam(value = "equipmentId",required = false) Long equipmentId ) {
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpeV2(name, pageNumber, pageSize,equipmentId));
}
@GetMapping(value = "/list-tree", produces = "application/json;charset=UTF-8") @GetMapping(value = "/list-tree", produces = "application/json;charset=UTF-8")
@ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回") @ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回")
......
...@@ -45,8 +45,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecificVo> ...@@ -45,8 +45,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecificVo>
* @param equipmentId * @param equipmentId
* @return * @return
*/ */
List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId); List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId, @Param("equipmentIdList") List<Long> equipmentIdList);
int getEquipmentBySpeCount( @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId); int getEquipmentBySpeCount( @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId, @Param("equipmentIdList") List<Long> equipmentIdList);
/** /**
......
...@@ -5,7 +5,11 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService; ...@@ -5,7 +5,11 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory; import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.TreeBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -25,4 +29,19 @@ public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService ...@@ -25,4 +29,19 @@ public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService
public List<EquipmentCategory> list( ) { public List<EquipmentCategory> list( ) {
return equipmentCategoryMapper.list(); return equipmentCategoryMapper.list();
} }
@Override
public List<EquipmentCategory> getAllTree(Long root) {
List<EquipmentCategory> list = equipmentCategoryMapper.list();
if (list.isEmpty()) {
return Collections.emptyList();
}
Long root123 = -1L;
list.forEach(eq -> { if(eq.getParentId() == null) { eq.setParentId(root123);}});
if (root == null) {
root = root123;
}
Collection<EquipmentCategory> bulid = TreeBuilder.bulid(list, root);
return new ArrayList<>(bulid);
}
} }
...@@ -3,19 +3,18 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -3,19 +3,18 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper; import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper;
import com.yeejoin.amos.fas.business.param.FmeaBindParam; import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService; import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.vo.AssoEquipsVo; import com.yeejoin.amos.fas.business.vo.AssoEquipsVo;
import com.yeejoin.amos.fas.business.vo.EquipmentPointVo; import com.yeejoin.amos.fas.business.vo.EquipmentPointVo;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo; import com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint; import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 装备配置 服务实现类 * 装备配置 服务实现类
...@@ -28,7 +27,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService { ...@@ -28,7 +27,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
@Autowired @Autowired
EquipmentSpecificMapper equipmentSpecificMapper; EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
IEquipmentCategoryService categoryService;
@Override @Override
public List<FmeaEquipmentPoint> upDateEquimentPoint(FmeaBindParam fmeaBindParam) { public List<FmeaEquipmentPoint> upDateEquimentPoint(FmeaBindParam fmeaBindParam) {
...@@ -71,15 +71,33 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService { ...@@ -71,15 +71,33 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
return map; return map;
} }
@Override
public Map<String, Object> getEquipmentBySpeV2(String name, int pageNumber, int pageSize, Long equipmentId) {
Map<String, Object> map = new HashMap<>();
List<Long> equipmentIdList = null;
if (equipmentId != null) {
List<EquipmentCategory> allChildren = TreeUtil.getAllChildren(categoryService.getAllTree(equipmentId));
equipmentIdList = new LinkedList<>();
equipmentIdList.add(equipmentId);
if(!allChildren.isEmpty()){
List<Long> finalEquipmentIdList = equipmentIdList;
allChildren.forEach(cate -> finalEquipmentIdList.add(cate.getId()));
}
}
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, null,null, equipmentIdList);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, null,null, equipmentIdList);
map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount);
return map;
}
@Override @Override
public Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize ,String equipmentId) { public Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize ,String equipmentId) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
pageNumber = pageNumber*pageSize; pageNumber = pageNumber*pageSize;
code = checkid(code); code = checkid(code);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId); List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId, null);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId); int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId, null);
map.put("content",equipmentBySpe); map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount); map.put("totalElements",equipmentBySpeCount);
return map; return map;
......
...@@ -53,4 +53,6 @@ public interface EquipmentSpecificService { ...@@ -53,4 +53,6 @@ public interface EquipmentSpecificService {
* @return * @return
*/ */
Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize, String equipmentId); Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize, String equipmentId);
Map<String ,Object> getEquipmentBySpeV2(String name, int pageNumber, int pageSize, Long equipmentId);
} }
...@@ -17,4 +17,9 @@ public interface IEquipmentCategoryService { ...@@ -17,4 +17,9 @@ public interface IEquipmentCategoryService {
*/ */
List<EquipmentCategory> list( ); List<EquipmentCategory> list( );
/**
* 获取装备树
* @return
*/
List<EquipmentCategory> getAllTree(Long root);
} }
...@@ -60,6 +60,12 @@ ...@@ -60,6 +60,12 @@
<if test="equipmentId != null and equipmentId!='null' "> <if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId} and fire.equipment_id = #{equipmentId}
</if> </if>
<if test="equipmentIdList != null and equipmentIdList.size > 0 ">
and equ.category_id in
<foreach collection="equipmentIdList" item="equipmentId" open="(" close=")" separator=",">
#{equipmentId}
</foreach>
</if>
limit #{pageNumber},#{pageSize} limit #{pageNumber},#{pageSize}
</select> </select>
...@@ -86,6 +92,12 @@ ...@@ -86,6 +92,12 @@
<if test="equipmentId != null and equipmentId!='null' "> <if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId} and fire.equipment_id = #{equipmentId}
</if> </if>
<if test="equipmentIdList != null and equipmentIdList.size > 0 ">
and equ.category_id in
<foreach collection="equipmentIdList" item="equipmentId" open="(" close=")" separator=",">
#{equipmentId}
</foreach>
</if>
</select> </select>
<select id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo"> <select id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo">
select select
......
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