mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
1、新增查看下级部件接口;2、/assembly/list支持单独查看id/name精准查询;
This commit is contained in:
+9
-1
@@ -59,10 +59,18 @@ public class AssemblyListController {
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "装配清单-获取部件列表")
|
||||
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||
public CommonResult<List<OrderComponentRespVO>> getComponentList(@RequestBody AssemblyListComponentPageReqVO reqVO) {
|
||||
public CommonResult<List<OrderComponentRespVO>> getComponentList(@Valid @RequestBody AssemblyListComponentPageReqVO reqVO) {
|
||||
return CommonResult.success(assemblyListService.getComponentList(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/component/{componentId}/children")
|
||||
@Operation(summary = "装配清单-获取部件直接下级列表")
|
||||
@Parameter(name = "componentId", description = "部件 ID", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||
public CommonResult<List<OrderComponentRespVO>> getDirectChildComponentList(@PathVariable Long componentId) {
|
||||
return success(assemblyListService.getDirectChildComponentList(componentId));
|
||||
}
|
||||
|
||||
@PostMapping("/list/view/plate/page")
|
||||
@Operation(summary = "装配清单-获取订单部件下的板件视图分页列表数据")
|
||||
@PreAuthorize("@ss.hasPermission('production:assemblyList:query')")
|
||||
|
||||
+14
@@ -1,6 +1,8 @@
|
||||
package com.cf.imes.module.executor.controller.admin.assemblylist.vo;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.executor.enums.ordercomponent.OrderComponentProcessStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -8,6 +10,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -32,4 +35,15 @@ public class AssemblyListComponentPageReqVO extends PageParam {
|
||||
@Schema(description = "部件编号", example = "[1,2]")
|
||||
@Size(max = 200, message = "{order.detail.component.list.query.componentIds.max}")
|
||||
private Set<Long> componentIds;
|
||||
|
||||
@Schema(description = "部件 ID", example = "1024")
|
||||
private Long componentId;
|
||||
|
||||
@Schema(description = "部件名称", example = "部件")
|
||||
@Length(max = 64, message = "{order.component.assemble.req.name.max}")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "加工状态:0不加工、1未加工、2已加工、3部分加工", example = "[1, 2]")
|
||||
@InEnum(OrderComponentProcessStatusEnum.class)
|
||||
private List<Integer> processStatus;
|
||||
}
|
||||
|
||||
+6
@@ -34,4 +34,10 @@ public class OrderComponentRespVO {
|
||||
|
||||
@Schema(description = "部件深度")
|
||||
private Double depth;
|
||||
|
||||
@Schema(description = "柜名")
|
||||
private String bodyName;
|
||||
|
||||
@Schema(description = "房名")
|
||||
private String roomName;
|
||||
}
|
||||
|
||||
+3
@@ -35,6 +35,9 @@ public class OrdersTopComponentListReqVO {
|
||||
@Length(max = 64, message = "{order.component.assemble.req.name.max}")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "部件ID", example = "1024")
|
||||
private Long componentId;
|
||||
|
||||
@Schema(description = "加工状态:0不加工、1未加工、2已加工、3部分加工", example = "1")
|
||||
@InEnum(OrderComponentProcessStatusEnum.class)
|
||||
private List<Integer> processStatus;
|
||||
|
||||
+10
@@ -114,4 +114,14 @@ public class OrderComponentDO extends BaseDO {
|
||||
* 附加加工状态:不加工/部分加工(只有顶级)
|
||||
*/
|
||||
private Integer extraProcessStatus;
|
||||
|
||||
/**
|
||||
* 柜名
|
||||
*/
|
||||
private String bodyName;
|
||||
|
||||
/**
|
||||
* 房名
|
||||
*/
|
||||
private String roomName;
|
||||
}
|
||||
|
||||
+27
-2
@@ -49,10 +49,35 @@ public interface OrderComponentMapper extends BaseMapperX<OrderComponentDO> {
|
||||
*
|
||||
* @param orderIds
|
||||
* @param processStatus
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<OrderComponentDO> getOrderTopComponentListByAssemblyStatus(@Param("orderIds") List<Long> orderIds, @Param("assemblyStatusList") List<Integer> processStatus, @Param("name") String name);
|
||||
List<OrderComponentDO> getOrderTopComponentListByAssemblyStatus(@Param("orderIds") List<Long> orderIds,
|
||||
@Param("assemblyStatusList") List<Integer> processStatus);
|
||||
|
||||
/**
|
||||
* 查询符合节点条件的顶级部件 ID。
|
||||
*
|
||||
* @param orderIds 订单 ID 列表
|
||||
* @param componentIds 部件 ID 列表
|
||||
* @param componentId 部件 ID
|
||||
* @param name 部件名称
|
||||
* @param processStatus 节点加工状态(仅已加工、未加工)
|
||||
* @return 顶级部件 ID 列表
|
||||
*/
|
||||
List<Long> getTopIdsByComponentAndProcessStatus(@Param("orderIds") List<Long> orderIds,
|
||||
@Param("componentIds") Set<Long> componentIds,
|
||||
@Param("componentId") Long componentId,
|
||||
@Param("name") String name,
|
||||
@Param("processStatus") List<Integer> processStatus);
|
||||
|
||||
/**
|
||||
* 按部件 ID 或名称查询命中的部件节点,并计算装配状态。
|
||||
*/
|
||||
List<OrderComponentDO> getComponentsByIdOrNameAndProcessStatus(@Param("orderIds") List<Long> orderIds,
|
||||
@Param("componentIds") Set<Long> componentIds,
|
||||
@Param("componentId") Long componentId,
|
||||
@Param("name") String name,
|
||||
@Param("processStatus") List<Integer> processStatus);
|
||||
|
||||
/**
|
||||
* 查询订单topid下的所有大于level层级的部件列表
|
||||
|
||||
+8
@@ -33,6 +33,14 @@ public interface AssemblyListService {
|
||||
*/
|
||||
List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取部件的直接下级列表。
|
||||
*
|
||||
* @param componentId 部件 ID
|
||||
* @return 当前部件及其直接下级部件列表
|
||||
*/
|
||||
List<OrderComponentRespVO> getDirectChildComponentList(Long componentId);
|
||||
|
||||
/**
|
||||
* 获取部件和下级所有的板件视图列表
|
||||
* @param reqVO
|
||||
|
||||
+46
-82
@@ -7,7 +7,6 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
|
||||
@@ -38,6 +37,7 @@ import com.cf.imes.module.executor.enums.ordercomponent.OrderComponentProcessSta
|
||||
import com.cf.imes.module.system.api.assemblyconfig.AssemblyConfigApi;
|
||||
import com.cf.imes.module.system.api.assemblyconfig.dto.AssemblyConfigRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@@ -134,24 +134,28 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
public List<OrderComponentRespVO> getComponentList(AssemblyListComponentPageReqVO reqVO) {
|
||||
Set<Long> componentIds = reqVO.getComponentIds();
|
||||
List<Long> orderIds = reqVO.getOrderIds();
|
||||
if (CollUtil.isEmpty(componentIds)) {
|
||||
if (CollUtil.isEmpty(orderIds)
|
||||
|| (CollUtil.isEmpty(componentIds) && reqVO.getComponentId() == null
|
||||
&& CharSequenceUtil.isEmpty(reqVO.getName()))) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 查询入参部件
|
||||
List<OrderComponentDO> componentDOS = orderComponentMapper.selectList(new LambdaUpdateWrapper<OrderComponentDO>()
|
||||
.in(OrderComponentDO::getId, componentIds)
|
||||
.in(OrderComponentDO::getOrderId, orderIds));
|
||||
if (CollUtil.isEmpty(componentDOS) || componentDOS.size() != componentIds.size()) {
|
||||
throw new ServiceException(ORDER_COMPONENT_NOT_EXIST);
|
||||
// 按部件 ID 或名称查询时,仅展示命中的节点,不展开其所在的整棵树。
|
||||
if (reqVO.getComponentId() != null || CharSequenceUtil.isNotEmpty(reqVO.getName())) {
|
||||
List<OrderComponentDO> components = orderComponentMapper.getComponentsByIdOrNameAndProcessStatus(
|
||||
orderIds, componentIds, reqVO.getComponentId(), reqVO.getName(), reqVO.getProcessStatus());
|
||||
return BeanUtil.copyToList(components, OrderComponentRespVO.class);
|
||||
}
|
||||
|
||||
// 查询部件的所有顶级id
|
||||
List<Long> topIds = componentDOS.stream()
|
||||
.map(OrderComponentDO::getTopId)
|
||||
.toList();
|
||||
// 第一步:按部件 ID、名称及加工状态查询符合条件的 top_id。
|
||||
List<Long> topIds = orderComponentMapper.getTopIdsByComponentAndProcessStatus(
|
||||
orderIds, componentIds, reqVO.getComponentId(), reqVO.getName(),
|
||||
reqVO.getProcessStatus());
|
||||
if (CollUtil.isEmpty(topIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 查询所有top节点下的子节点
|
||||
// 第二步:按 top_id 查询整棵树的所有节点。
|
||||
List<OrderComponentDO> allNodesOnTopIds = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.in(OrderComponentDO::getTopId, topIds)
|
||||
.in(OrderComponentDO::getOrderId, orderIds)
|
||||
@@ -168,6 +172,31 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
return BeanUtil.copyToList(allNodesOnTopIds, OrderComponentRespVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderComponentRespVO> getDirectChildComponentList(Long componentId) {
|
||||
OrderComponentDO parent = orderComponentMapper.selectOne(new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.eq(OrderComponentDO::getId, componentId)
|
||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName,
|
||||
OrderComponentDO::getWidth, OrderComponentDO::getHeight, OrderComponentDO::getDepth,
|
||||
OrderComponentDO::getCadViewFileId));
|
||||
if (parent == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<OrderComponentDO> children = orderComponentMapper.selectList(new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.eq(OrderComponentDO::getPid, componentId)
|
||||
.eq(OrderComponentDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
|
||||
.select(OrderComponentDO::getId, OrderComponentDO::getPid, OrderComponentDO::getName,
|
||||
OrderComponentDO::getWidth, OrderComponentDO::getHeight, OrderComponentDO::getDepth,
|
||||
OrderComponentDO::getBodyName, OrderComponentDO::getRoomName));
|
||||
|
||||
List<OrderComponentRespVO> result = new ArrayList<>(children.size() + 1);
|
||||
result.add(BeanUtil.toBean(parent, OrderComponentRespVO.class));
|
||||
result.addAll(BeanUtil.copyToList(children, OrderComponentRespVO.class));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据装配设置计算部件节点的加工状态
|
||||
*
|
||||
@@ -836,78 +865,13 @@ public class AssemblyListServiceImpl implements AssemblyListService {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 查询顶级部件
|
||||
List<OrderComponentDO> result = orderComponentMapper.getOrderTopComponentListByAssemblyStatus(reqVO.getOrderIds(), reqVO.getProcessStatus(), reqVO.getName());
|
||||
return BeanUtil.copyToList(result, OrderComponentRespVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 整理状态对应的树数据
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
private List<TopComponentState> buildTopComponentStates(OrdersTopComponentListReqVO reqVO) {
|
||||
// 查询顶级部件
|
||||
List<OrderComponentDO> topComponents = orderComponentMapper.getOrderTopComponentListByAssemblyStatus(reqVO.getOrderIds(), reqVO.getProcessStatus(), reqVO.getName());
|
||||
|
||||
if (CollUtil.isEmpty(topComponents)) {
|
||||
if (reqVO.getComponentId() != null || StringUtils.isNotEmpty(reqVO.getName())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> names = topComponents.stream()
|
||||
.map(OrderComponentDO::getName)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
List<Long> topIds = topComponents.stream()
|
||||
.map(OrderComponentDO::getId)
|
||||
.toList();
|
||||
|
||||
// 查询不加工配置
|
||||
CommonResult<List<AssemblyConfigRespDTO>> configResult =
|
||||
assemblyConfigApi.getNotProcessAssemblyConfigByPartNameList(names);
|
||||
|
||||
if (configResult.isError()) {
|
||||
throw new ServiceException(ORDER_COMPONENT_ASSEMBLY_CONFIG_QUERY_ERROR);
|
||||
}
|
||||
|
||||
Set<String> configSet = configResult.getData().stream()
|
||||
.map(dto -> dto.getComponentName() + "#" + dto.getStructureHash())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 查询整棵树
|
||||
List<OrderComponentDO> allNodes = orderComponentMapper.selectList(
|
||||
new LambdaQueryWrapperX<OrderComponentDO>()
|
||||
.in(OrderComponentDO::getTopId, topIds)
|
||||
.in(OrderComponentDO::getOrderId, reqVO.getOrderIds())
|
||||
.select(OrderComponentDO::getId,
|
||||
OrderComponentDO::getPid,
|
||||
OrderComponentDO::getName,
|
||||
OrderComponentDO::getProcessStatus)
|
||||
);
|
||||
|
||||
List<OrderComponentTreeCompareVO> tree = buildTree(allNodes);
|
||||
|
||||
List<TopComponentState> result = new ArrayList<>();
|
||||
|
||||
for (OrderComponentTreeCompareVO root : tree) {
|
||||
|
||||
ProcessStats stats = analyzeTree(root);
|
||||
|
||||
TopComponentState state = new TopComponentState();
|
||||
|
||||
state.node = root;
|
||||
state.rootProcessed = ObjectUtil.equals(root.getProcessStatus(), OrderComponentProcessStatusEnum.PROCESSED.getStatus());
|
||||
state.allUnprocessed = stats.allUnprocessed;
|
||||
state.anyChildProcessed = stats.anyChildProcessed;
|
||||
state.notProcessConfig =
|
||||
configSet.contains(root.getName() + "#" + root.getStructureHash());
|
||||
|
||||
result.add(state);
|
||||
}
|
||||
|
||||
return result;
|
||||
// 查询顶级部件
|
||||
List<OrderComponentDO> result = orderComponentMapper.getOrderTopComponentListByAssemblyStatus(reqVO.getOrderIds(), reqVO.getProcessStatus());
|
||||
return BeanUtil.copyToList(result, OrderComponentRespVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+85
-3
@@ -82,9 +82,6 @@
|
||||
END AS processStatus
|
||||
FROM order_component top
|
||||
WHERE top.pid = 0
|
||||
<if test="name != null and name != ''">
|
||||
AND top.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
AND top.order_id IN
|
||||
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
@@ -109,6 +106,91 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getTopIdsByComponentAndProcessStatus" resultType="java.lang.Long">
|
||||
SELECT DISTINCT oc.top_id
|
||||
FROM order_component oc
|
||||
WHERE oc.order_id IN
|
||||
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
<if test="componentIds != null and componentIds.size() > 0">
|
||||
AND oc.top_id IN
|
||||
<foreach item="id" collection="componentIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="componentId != null or (name != null and name != '')">
|
||||
AND (
|
||||
<if test="componentId != null">
|
||||
oc.id = #{componentId}
|
||||
</if>
|
||||
<if test="componentId != null and name != null and name != ''">
|
||||
OR
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
oc.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="processStatus != null and processStatus.size() > 0">
|
||||
AND oc.process_status IN
|
||||
<foreach item="status" collection="processStatus" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getComponentsByIdOrNameAndProcessStatus"
|
||||
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
|
||||
SELECT * FROM (
|
||||
SELECT oc.id,
|
||||
oc.pid,
|
||||
oc.name,
|
||||
oc.width,
|
||||
oc.height,
|
||||
oc.depth,
|
||||
CASE
|
||||
WHEN oc.extra_process_status = 0 THEN 0
|
||||
WHEN oc.pid = 0 AND oc.extra_process_status = 3 THEN 3
|
||||
WHEN oc.process_status = 2 THEN 2
|
||||
WHEN oc.process_status = 1
|
||||
AND (oc.extra_process_status IS NULL OR oc.extra_process_status != 0) THEN 1
|
||||
ELSE -1
|
||||
END AS process_status
|
||||
FROM order_component oc
|
||||
WHERE oc.order_id IN
|
||||
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
AND oc.deleted = 0
|
||||
<if test="componentIds != null and componentIds.size() > 0">
|
||||
AND oc.top_id IN
|
||||
<foreach item="id" collection="componentIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="componentId != null or (name != null and name != '')">
|
||||
AND (
|
||||
<if test="componentId != null">
|
||||
oc.id = #{componentId}
|
||||
</if>
|
||||
<if test="componentId != null and name != null and name != ''">
|
||||
OR
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
oc.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
) component
|
||||
<if test="processStatus != null and processStatus.size() > 0">
|
||||
WHERE component.process_status IN
|
||||
<foreach item="status" collection="processStatus" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getComponentListOnTopLevel"
|
||||
resultType="com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO">
|
||||
select * from order_component oc
|
||||
|
||||
Reference in New Issue
Block a user