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

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

parent 6d6dc83f
......@@ -7,8 +7,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
......@@ -22,7 +24,7 @@ import java.util.List;
@Accessors(chain = true)
@TableName("wl_equipment_category")
@ApiModel(value="EquipmentCategory装备分类实体", description="装备分类")
public class EquipmentCategory extends BaseEntity {
public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentCategory, Long> {
private static final long serialVersionUID = 1L;
......@@ -56,5 +58,24 @@ public class EquipmentCategory extends BaseEntity {
@TableField(exist=false)
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{
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")
@ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回")
......
......@@ -45,8 +45,8 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecificVo>
* @param equipmentId
* @return
*/
List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @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);
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, @Param("equipmentIdList") List<Long> equipmentIdList);
/**
......
......@@ -5,7 +5,11 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
......@@ -25,4 +29,19 @@ public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService
public List<EquipmentCategory> 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;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper;
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.IEquipmentCategoryService;
import com.yeejoin.amos.fas.business.util.TreeUtil;
import com.yeejoin.amos.fas.business.vo.AssoEquipsVo;
import com.yeejoin.amos.fas.business.vo.EquipmentPointVo;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 装备配置 服务实现类
......@@ -28,7 +27,8 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
@Autowired
EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
IEquipmentCategoryService categoryService;
@Override
public List<FmeaEquipmentPoint> upDateEquimentPoint(FmeaBindParam fmeaBindParam) {
......@@ -71,15 +71,33 @@ public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
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
public Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize ,String equipmentId) {
Map<String, Object> map = new HashMap<>();
pageNumber = pageNumber*pageSize;
code = checkid(code);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId, null);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId, null);
map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount);
return map;
......
......@@ -53,4 +53,6 @@ public interface EquipmentSpecificService {
* @return
*/
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 {
*/
List<EquipmentCategory> list( );
/**
* 获取装备树
* @return
*/
List<EquipmentCategory> getAllTree(Long root);
}
......@@ -60,6 +60,12 @@
<if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId}
</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}
</select>
......@@ -86,6 +92,12 @@
<if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId}
</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 id="getFireEquiments" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpeVo">
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