1完成酸轧轧辊调整
2完成双机架工艺规格串联 3完成双机架计划串联 4完成双机架wip快捷录入检索 5完成双机架实绩串联
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.domain.DrMillProcessRecipe;
|
||||
import com.klp.domain.WmsProcessSpec;
|
||||
import com.klp.domain.WmsProductionLine;
|
||||
import com.klp.mapper.WmsProcessSpecMapper;
|
||||
import com.klp.mapper.WmsProductionLineMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 双机架工艺方案 → L3规程(wms_process_spec)同步服务
|
||||
* <p>
|
||||
* 注意:此 Service 不标注 @DS,默认走 master 数据源,
|
||||
* 供 Controller 在 double-rack 查询完方案列表后调用,
|
||||
* 将缺失的 wms_process_spec 记录自动补齐。
|
||||
* </p>
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DrRecipeSyncService {
|
||||
|
||||
/** 双机架产线编号,与 wms_production_line.line_code 对应 */
|
||||
private static final String DR_LINE_CODE = "DR";
|
||||
private static final String DR_LINE_NAME = "双机架轧机";
|
||||
|
||||
/** spec_code 前缀,区分同名方案号属于哪条产线 */
|
||||
private static final String SPEC_CODE_PREFIX = "DR-";
|
||||
|
||||
private final WmsProcessSpecMapper specMapper;
|
||||
private final WmsProductionLineMapper lineMapper;
|
||||
|
||||
/**
|
||||
* 检查并补充 wms_process_spec:
|
||||
* 对列表中每条方案,若在 L3 规程表中不存在则自动新增。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncRecipesToSpec(List<DrMillProcessRecipe> recipes) {
|
||||
if (recipes == null || recipes.isEmpty()) return;
|
||||
|
||||
Long lineId = getOrCreateDrLineId();
|
||||
|
||||
int created = 0;
|
||||
for (DrMillProcessRecipe recipe : recipes) {
|
||||
String specCode = SPEC_CODE_PREFIX + recipe.getRecipeNo();
|
||||
LambdaQueryWrapper<WmsProcessSpec> qw = Wrappers.lambdaQuery();
|
||||
qw.eq(WmsProcessSpec::getSpecCode, specCode);
|
||||
if (specMapper.selectCount(qw) == 0) {
|
||||
WmsProcessSpec spec = new WmsProcessSpec();
|
||||
spec.setSpecCode(specCode);
|
||||
spec.setSpecName(recipe.getRecipeNo());
|
||||
spec.setSpecType("PROCESS");
|
||||
spec.setLineId(lineId);
|
||||
spec.setIsEnabled(1);
|
||||
spec.setRemark("由双机架工艺方案自动同步");
|
||||
specMapper.insert(spec);
|
||||
created++;
|
||||
log.info("[DR同步] 新增 wms_process_spec: specCode={}, recipeId={}",
|
||||
specCode, recipe.getRecipeId());
|
||||
}
|
||||
}
|
||||
if (created > 0) {
|
||||
log.info("[DR同步] 本次共补充 {} 条 L3 工艺规程", created);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找或创建双机架产线记录,返回 line_id。
|
||||
*/
|
||||
private Long getOrCreateDrLineId() {
|
||||
LambdaQueryWrapper<WmsProductionLine> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsProductionLine::getLineCode, DR_LINE_CODE);
|
||||
WmsProductionLine line = lineMapper.selectOne(lqw);
|
||||
if (line == null) {
|
||||
line = new WmsProductionLine();
|
||||
line.setLineCode(DR_LINE_CODE);
|
||||
line.setLineName(DR_LINE_NAME);
|
||||
line.setCapacity(BigDecimal.ZERO);
|
||||
line.setUnit("t");
|
||||
line.setIsEnabled(1);
|
||||
line.setRemark("双机架轧机产线,系统自动创建");
|
||||
lineMapper.insert(line);
|
||||
log.info("[DR同步] 新建 wms_production_line: lineCode={}, lineId={}",
|
||||
DR_LINE_CODE, line.getLineId());
|
||||
}
|
||||
return line.getLineId();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user