mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增装配设置 - 分解模式左侧树平铺接口
This commit is contained in:
+10
@@ -5,6 +5,8 @@ import com.cf.imes.framework.common.pojo.CommonResult;
|
|||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
@@ -65,6 +67,14 @@ public class AssemblyListController {
|
|||||||
return CommonResult.success(assemblyListService.getComponentList(reqVO));
|
return CommonResult.success(assemblyListService.getComponentList(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/flat-list")
|
||||||
|
@Operation(summary = "装配清单-获取按名称汇总的平铺部件层级列表")
|
||||||
|
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||||
|
public CommonResult<List<AssemblyListComponentFlatRespVO>> getComponentFlatList(
|
||||||
|
@Valid @RequestBody AssemblyListComponentFlatReqVO reqVO) {
|
||||||
|
return success(assemblyListService.getComponentFlatList(reqVO));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/component/direct-children")
|
@PostMapping("/component/direct-children")
|
||||||
@Operation(summary = "装配清单-获取部件直接下级列表")
|
@Operation(summary = "装配清单-获取部件直接下级列表")
|
||||||
@Parameter(name = "componentId", description = "部件 ID", required = true, example = "1024")
|
@Parameter(name = "componentId", description = "部件 ID", required = true, example = "1024")
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cf.imes.module.executor.controller.admin.assemblylist.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "管理后台 - 装配清单平铺部件查询")
|
||||||
|
public class AssemblyListComponentFlatReqVO {
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
@Schema(description = "订单 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private List<Long> orderIds;
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.cf.imes.module.executor.controller.admin.assemblylist.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装配清单 - 按名称汇总后的平铺部件。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "管理后台 - 装配清单按名称汇总的平铺部件")
|
||||||
|
public class AssemblyListComponentFlatRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "排序代表节点 ID(同名节点中层级最深、ID 最大的节点)")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "部件名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "层级序号")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
@Schema(description = "同名部件数量")
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
@Schema(description = "被汇总的原始部件 ID,按层级倒序、ID 倒序")
|
||||||
|
private List<Long> componentIds;
|
||||||
|
}
|
||||||
+6
@@ -17,6 +17,12 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
||||||
|
/**
|
||||||
|
* 查询订单下部件id、level、name列表,按层级倒序、id正序
|
||||||
|
* @param orderIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrderComponentDO> selectAllForFlatList(@Param("orderIds") List<Long> orderIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单详情部件列表查询
|
* 订单详情部件列表查询
|
||||||
|
|||||||
+10
@@ -2,6 +2,8 @@ package com.cf.imes.module.executor.service.assemblylist;
|
|||||||
|
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
||||||
@@ -35,6 +37,14 @@ public interface AssemblyListService {
|
|||||||
*/
|
*/
|
||||||
List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO);
|
List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取按名称汇总的平铺部件层级列表
|
||||||
|
*
|
||||||
|
* @param reqVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<AssemblyListComponentFlatRespVO> getComponentFlatList(AssemblyListComponentFlatReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部件的直接下级列表。
|
* 获取部件的直接下级列表。
|
||||||
*
|
*
|
||||||
|
|||||||
+44
@@ -19,6 +19,8 @@ import com.cf.imes.framework.common.util.json.JsonUtils;
|
|||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
|
||||||
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentPageReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatReqVO;
|
||||||
|
import com.cf.imes.module.executor.controller.admin.assemblylist.vo.AssemblyListComponentFlatRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderPageReqVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrdersViewCadViewInfoRespVO;
|
||||||
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.AssemblyComponentChildPrintReqVO;
|
||||||
@@ -179,6 +181,48 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
|||||||
return BeanUtil.copyToList(allNodesOnTopIds, OrderComponentRespVO.class);
|
return BeanUtil.copyToList(allNodesOnTopIds, OrderComponentRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AssemblyListComponentFlatRespVO> getComponentFlatList(
|
||||||
|
AssemblyListComponentFlatReqVO reqVO) {
|
||||||
|
List<OrderComponentDO> components =
|
||||||
|
orderComponentMapper.selectAllForFlatList(reqVO.getOrderIds());
|
||||||
|
if (CollUtil.isEmpty(components)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据父子关系和雪花 ID 生成类似 1、1-1、1-2 的显示序号。
|
||||||
|
// 底层优先;同一层按雪花 ID 倒序,明确保留 1-1、1-2 这类层级顺序信息。
|
||||||
|
components.sort(Comparator.comparingInt(OrderComponentDO::getLevel)
|
||||||
|
.reversed()
|
||||||
|
.thenComparing(OrderComponentDO::getId, Comparator.reverseOrder()));
|
||||||
|
|
||||||
|
Map<String, List<OrderComponentDO>> grouped = components.stream()
|
||||||
|
.collect(Collectors.groupingBy(OrderComponentDO::getName,
|
||||||
|
LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
return grouped.values().stream().map(list -> {
|
||||||
|
// 同名合并时以更低层级(level 数值更大)的节点为准;同层取 ID 更大的节点。
|
||||||
|
OrderComponentDO representative = list.stream()
|
||||||
|
.max(Comparator.comparingInt(OrderComponentDO::getLevel)
|
||||||
|
.thenComparing(OrderComponentDO::getId))
|
||||||
|
.orElseThrow();
|
||||||
|
AssemblyListComponentFlatRespVO result = BeanUtil.copyProperties(
|
||||||
|
representative, AssemblyListComponentFlatRespVO.class);
|
||||||
|
result.setCount(list.size());
|
||||||
|
// 数据库 level 从 0 开始,接口返回层级从 1 开始。
|
||||||
|
result.setLevel(list.stream()
|
||||||
|
.map(OrderComponentDO::getLevel)
|
||||||
|
.distinct()
|
||||||
|
.sorted(Comparator.reverseOrder())
|
||||||
|
.map(level -> String.valueOf(level + 1))
|
||||||
|
.collect(Collectors.joining(",")));
|
||||||
|
result.setComponentIds(list.stream()
|
||||||
|
.map(OrderComponentDO::getId)
|
||||||
|
.toList());
|
||||||
|
return result;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AssemblyComponentChildPrintRespVO> getDirectChildComponentList(AssemblyComponentChildPrintReqVO reqVO) {
|
public List<AssemblyComponentChildPrintRespVO> getDirectChildComponentList(AssemblyComponentChildPrintReqVO reqVO) {
|
||||||
|
|
||||||
|
|||||||
+14
@@ -1,6 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper">
|
<mapper namespace="com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper">
|
||||||
|
<select id="selectAllForFlatList"
|
||||||
|
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
|
||||||
|
SELECT oc.id,
|
||||||
|
oc.level,
|
||||||
|
oc.name
|
||||||
|
FROM order_component oc
|
||||||
|
WHERE oc.deleted = 0
|
||||||
|
AND oc.order_id IN
|
||||||
|
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||||
|
#{orderId}
|
||||||
|
</foreach>
|
||||||
|
ORDER BY oc.level DESC, oc.id ASC
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getOrderDetailComponentIds" resultType="java.lang.Long">
|
<select id="getOrderDetailComponentIds" resultType="java.lang.Long">
|
||||||
select comp_id from order_item i
|
select comp_id from order_item i
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user