1、搜索最子级,无关的记录也出来了
This commit is contained in:
parent
2d3e271709
commit
9a366156e5
|
|
@ -8,6 +8,7 @@ import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.*;
|
import com.nflg.product.bomnew.pojo.vo.*;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -69,4 +70,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
|
||||||
Integer getCountForWaitReviewByMaterialNo(@Param("materialNo") String materialNo);
|
Integer getCountForWaitReviewByMaterialNo(@Param("materialNo") String materialNo);
|
||||||
|
|
||||||
void updateRootForWaitReview();
|
void updateRootForWaitReview();
|
||||||
|
|
||||||
|
Set<String> getMaterialParent(@Param("materialNos") Collection<String> materialNos ,@Param("createdBy") String createdBy);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
return returnResult;
|
return returnResult;
|
||||||
}
|
}
|
||||||
List<String> materialNos = new ArrayList<>();
|
List<String> materialNos = new ArrayList<>();
|
||||||
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
|
// List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList());
|
||||||
materialNos.add(materialNo);
|
//获取父级物料
|
||||||
|
List<String> parentMaterialByMaterialNo=getParentMaterial(ImmutableList.of(materialNo) ,!userRoleService.technician()).stream().collect(Collectors.toList());
|
||||||
|
// materialNos.add(materialNo);
|
||||||
materialNos.addAll(parentMaterialByMaterialNo);
|
materialNos.addAll(parentMaterialByMaterialNo);
|
||||||
if (CollUtil.isNotEmpty(materialNos)) {
|
if (CollUtil.isNotEmpty(materialNos)) {
|
||||||
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(materialNos, query.getDataType());
|
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(materialNos, query.getDataType());
|
||||||
|
|
@ -221,6 +223,31 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取父级物料 (包含查询物料本身)
|
||||||
|
* @param materialNoList
|
||||||
|
* @param bomType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<String> getParentMaterial(List<String> materialNoList, Boolean bomType) {
|
||||||
|
Set<String> result = new HashSet<>();
|
||||||
|
result.addAll(materialNoList);
|
||||||
|
|
||||||
|
Set<String> useMaterialSku = this.getBaseMapper().getMaterialParent(materialNoList,bomType?SessionUtil.getUserCode():null);
|
||||||
|
|
||||||
|
while (CollUtil.isNotEmpty(useMaterialSku)) {
|
||||||
|
//防止数据错误(循环依赖)-死循环
|
||||||
|
Set<String> difference = Sets.difference(useMaterialSku, result);
|
||||||
|
if (CollUtil.isNotEmpty(difference)) {
|
||||||
|
useMaterialSku = this.getBaseMapper().getMaterialParent(difference,bomType?SessionUtil.getUserCode():null);
|
||||||
|
result.addAll(difference);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量获取物料所有父节点
|
* 批量获取物料所有父节点
|
||||||
|
|
|
||||||
|
|
@ -282,4 +282,16 @@
|
||||||
<select id="getCountForWaitReviewByMaterialNo" resultType="java.lang.Integer">
|
<select id="getCountForWaitReviewByMaterialNo" resultType="java.lang.Integer">
|
||||||
select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1
|
select COUNT(1) from t_bom_new_ebom_child where material_no=#{materialNo} and edit_status=1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getMaterialParent" resultType="java.lang.String">
|
||||||
|
select a.material_no from t_bom_new_ebom_parent a join t_bom_new_ebom_child b on a.row_id=b.parent_row_id
|
||||||
|
where a.last_version_is=1
|
||||||
|
<if test="createdBy!=null and createdBy!=''">
|
||||||
|
and a.created_by=#{createdBy}
|
||||||
|
</if>
|
||||||
|
and b.material_no in
|
||||||
|
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue