mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
组件保存优化结构新结构适配
This commit is contained in:
+14
@@ -80,11 +80,25 @@ public class BoardLayoutResultSummary {
|
||||
*/
|
||||
private List<String> materialIds;
|
||||
|
||||
/**
|
||||
* 自定义材质编号列表,对应 MES 提交给组件的材质标识。
|
||||
*
|
||||
* <p>组件的 {@link #materialIds} 为组件内部材质 ID,不能用于本地关联。</p>
|
||||
*/
|
||||
private List<String> customMaterialNos;
|
||||
|
||||
/**
|
||||
* 已优化排版ID列表
|
||||
*/
|
||||
private List<String> placedBlockIds;
|
||||
|
||||
/**
|
||||
* 自定义板件编号列表,对应 MES 的板件短号。
|
||||
*
|
||||
* <p>组件的 {@link #placedBlockIds} 为组件内部板件 ID,不能用于本地关联。</p>
|
||||
*/
|
||||
private List<String> customBlockNos;
|
||||
|
||||
/**
|
||||
* 开始开料板ID列表
|
||||
*/
|
||||
|
||||
+6
-4
@@ -1575,15 +1575,17 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// 重置优化状态
|
||||
resetPlanPlateOptimizeStatus(planId, orderIds);
|
||||
if (CollUtil.isNotEmpty(layoutResultSummary)) {
|
||||
List<String> optimizatePlateNoList = layoutResultSummary.stream().flatMap(summary -> summary.getPlacedBlockIds().stream()).toList();
|
||||
List<String> optimizatePlateNoList = layoutResultSummary.stream()
|
||||
.flatMap(summary -> summary.getCustomBlockNos().stream())
|
||||
.toList();
|
||||
BoardLayoutResultSummary boardLayoutResultSummary = layoutResultSummary.get(0);
|
||||
// 已排大板数量
|
||||
int boardCount = boardLayoutResultSummary.getBoardCount();
|
||||
// 优化大板编号
|
||||
List<String> materialIds = boardLayoutResultSummary.getMaterialIds();
|
||||
List<String> customMaterialNos = boardLayoutResultSummary.getCustomMaterialNos();
|
||||
String materialId = null;
|
||||
if (CollUtil.isNotEmpty(materialIds)) {
|
||||
materialId = materialIds.get(0);
|
||||
if (CollUtil.isNotEmpty(customMaterialNos)) {
|
||||
materialId = customMaterialNos.get(0);
|
||||
}
|
||||
|
||||
// 更新参与优化的板材的优化状态
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.cf.imes.module.executor.service.optimizeplan;
|
||||
|
||||
import com.cf.imes.framework.common.enums.PlanStatusEnum;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.component.BoardLayoutResultSummary;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.component.FlowSessionSavedContent;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.component.OptimizationResultsReqVO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||
import com.cf.imes.module.executor.enums.plan.FlowProcessStatus;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class OptimizePlanServiceImplComponentResultTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfo() {
|
||||
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), PlanDO.class);
|
||||
}
|
||||
|
||||
@Mock
|
||||
private PlanMapper planMapper;
|
||||
@Mock
|
||||
private PlateMapper plateMapper;
|
||||
|
||||
@InjectMocks
|
||||
private OptimizePlanServiceImpl optimizePlanService;
|
||||
|
||||
@Test
|
||||
void shouldUseCustomNosWhenSavingComponentOptimizationResult() {
|
||||
Long planId = 1001L;
|
||||
PlanDO plan = new PlanDO();
|
||||
plan.setId(planId);
|
||||
plan.setOrderNos("[2001]");
|
||||
plan.setStatus(PlanStatusEnum.NOCUTTING.getStatus());
|
||||
when(planMapper.selectById(planId)).thenReturn(plan);
|
||||
when(plateMapper.updatePlanPlateOptimizeStatus(
|
||||
eq(planId), eq(List.of(2001L)), eq(List.of("custom-block-1"))))
|
||||
.thenReturn(1);
|
||||
|
||||
optimizePlanService.saveComponentOptimizationResults(request(planId));
|
||||
|
||||
verify(plateMapper).updatePlanPlateOptimizeStatus(
|
||||
planId, List.of(2001L), List.of("custom-block-1"));
|
||||
ArgumentCaptor<LambdaUpdateWrapper<PlanDO>> planUpdateCaptor = ArgumentCaptor.forClass(LambdaUpdateWrapper.class);
|
||||
verify(planMapper, times(2)).update(planUpdateCaptor.capture());
|
||||
assertThat(planUpdateCaptor.getAllValues().get(1).getParamNameValuePairs())
|
||||
.containsValue("custom-material-1")
|
||||
.doesNotContainValue("component-material-id");
|
||||
}
|
||||
|
||||
private OptimizationResultsReqVO request(Long planId) {
|
||||
BoardLayoutResultSummary summary = new BoardLayoutResultSummary();
|
||||
summary.setBoardCount(1);
|
||||
summary.setMaterialIds(List.of("component-material-id"));
|
||||
summary.setCustomMaterialNos(List.of("custom-material-1"));
|
||||
summary.setPlacedBlockIds(List.of("component-block-id"));
|
||||
summary.setCustomBlockNos(List.of("custom-block-1"));
|
||||
|
||||
FlowSessionSavedContent content = new FlowSessionSavedContent();
|
||||
content.setProcessStatus(FlowProcessStatus.NOT_STARTED.getStatus());
|
||||
content.setLayoutResultSummary(List.of(summary));
|
||||
|
||||
OptimizationResultsReqVO request = new OptimizationResultsReqVO();
|
||||
request.setPlanId(planId);
|
||||
request.setFlowSessionSavedContent(content);
|
||||
return request;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user