1完成酸轧轧辊调整
2完成双机架工艺规格串联 3完成双机架计划串联 4完成双机架wip快捷录入检索 5完成双机架实绩串联
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.klp.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.klp.common.helper.LoginHelper;
|
||||
import com.klp.domain.DrMillProcessPass;
|
||||
import com.klp.domain.DrMillProcessRecipeVersion;
|
||||
import com.klp.mapper.DrMillProcessPassMapper;
|
||||
import com.klp.mapper.DrMillProcessRecipeVersionMapper;
|
||||
import com.klp.service.IDrMillProcessRecipeVersionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@DS("double-rack")
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class DrMillProcessRecipeVersionServiceImpl implements IDrMillProcessRecipeVersionService {
|
||||
|
||||
private final DrMillProcessRecipeVersionMapper versionMapper;
|
||||
private final DrMillProcessPassMapper passMapper;
|
||||
|
||||
@Override
|
||||
public List<DrMillProcessRecipeVersion> listByRecipeId(Long recipeId) {
|
||||
return versionMapper.selectByRecipeId(recipeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DrMillProcessRecipeVersion getDetailById(Long versionId) {
|
||||
DrMillProcessRecipeVersion v = versionMapper.selectById(versionId);
|
||||
if (v != null) {
|
||||
v.setPassList(passMapper.selectByVersionId(versionId));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long save(DrMillProcessRecipeVersion version) {
|
||||
String user = LoginHelper.getUsername();
|
||||
version.setCreateBy(user);
|
||||
version.setUpdateBy(user);
|
||||
versionMapper.insert(version);
|
||||
savePassList(version);
|
||||
return version.getVersionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DrMillProcessRecipeVersion version) {
|
||||
version.setUpdateBy(LoginHelper.getUsername());
|
||||
versionMapper.update(version);
|
||||
passMapper.deleteByVersionId(version.getVersionId());
|
||||
savePassList(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void activate(Long versionId) {
|
||||
DrMillProcessRecipeVersion v = versionMapper.selectById(versionId);
|
||||
if (v == null) throw new RuntimeException("版本不存在");
|
||||
versionMapper.deactivateOthers(v.getRecipeId(), versionId);
|
||||
versionMapper.activate(versionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteById(Long versionId) {
|
||||
passMapper.deleteByVersionId(versionId);
|
||||
versionMapper.deleteById(versionId);
|
||||
}
|
||||
|
||||
private void savePassList(DrMillProcessRecipeVersion version) {
|
||||
List<DrMillProcessPass> list = version.getPassList();
|
||||
if (list == null || list.isEmpty()) return;
|
||||
String user = LoginHelper.getUsername();
|
||||
for (DrMillProcessPass p : list) {
|
||||
p.setRecipeId(version.getRecipeId());
|
||||
p.setVersionId(version.getVersionId());
|
||||
p.setCreateBy(user);
|
||||
p.setUpdateBy(user);
|
||||
}
|
||||
passMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user