|
@@ -10,10 +10,12 @@ import com.fjhx.constants.IotManagementLockConstant;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.FileInfo;
|
|
|
import com.fjhx.entity.bom.Bom;
|
|
|
+import com.fjhx.entity.bom.BomDetails;
|
|
|
import com.fjhx.enums.bom.BomTypeEnum;
|
|
|
import com.fjhx.mapper.bom.BomMapper;
|
|
|
import com.fjhx.params.bom.BomEx;
|
|
|
import com.fjhx.params.bom.BomVo;
|
|
|
+import com.fjhx.service.bom.BomDetailsService;
|
|
|
import com.fjhx.service.bom.BomService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.FileClientUtil;
|
|
@@ -42,11 +44,13 @@ public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomSe
|
|
|
|
|
|
private final RedisLockClient redisLockClient;
|
|
|
|
|
|
+ private final BomDetailsService bomDetailsService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<BomEx> getPage(Map<String, String> condition) {
|
|
|
|
|
|
- QueryWrapper<?> wrapper = WrapperUtil.init(condition)
|
|
|
- .eq("p.classify_id", "classifyId") // 分类查询
|
|
|
+ QueryWrapper<?> wrapper = WrapperUtil.init(condition).eq("p.classify_id", "classifyId") // 产品分类id
|
|
|
+ .eq("p.type", "productType") // 产品类型
|
|
|
.keyword("p.name", "p.code") // 关键字查询
|
|
|
.getWrapper();
|
|
|
|
|
@@ -61,8 +65,8 @@ public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomSe
|
|
|
Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(records, Bom::getUpdateUser);
|
|
|
|
|
|
// 文件信息
|
|
|
- Map<Long, FileInfo> fileInfoMap = FileClientUtil.getFileInfoMap(
|
|
|
- records.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
|
|
+ List<Long> fileInfoIdList = records.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
+ Map<Long, FileInfo> fileInfoMap = FileClientUtil.getFileInfoMap(fileInfoIdList);
|
|
|
|
|
|
records.forEach(item -> {
|
|
|
item.setUpdateUserName(userNameMap.get(item.getUpdateUser()));
|
|
@@ -128,6 +132,7 @@ public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomSe
|
|
|
@Override
|
|
|
public void delete(BomVo bomVo) {
|
|
|
removeById(bomVo.getId());
|
|
|
+ bomDetailsService.remove(q -> q.eq(BomDetails::getBomId, bomVo.getId()));
|
|
|
FileClientUtil.relieveBindingFile(bomVo.getId());
|
|
|
}
|
|
|
|
|
@@ -136,4 +141,23 @@ public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomSe
|
|
|
return baseMapper.getBomRelationProductClassify();
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void updateVersion(Bom bom) {
|
|
|
+
|
|
|
+ Long productId = bom.getProductId();
|
|
|
+ Assert.notEmpty(productId, "产品id不能为空");
|
|
|
+
|
|
|
+ Long id = bom.getId();
|
|
|
+ Assert.notEmpty(id, "启用bom版本id不能为空");
|
|
|
+
|
|
|
+ // 保证一个产品只有一个bom是启用状态
|
|
|
+ Boolean flag = redisLockClient.lockFair(IotManagementLockConstant.BOM_EDITION_LOCK + productId, () -> {
|
|
|
+ update(q -> q.eq(Bom::getProductId, productId).set(Bom::getCurrentEdition, StatusConstant.NO));
|
|
|
+ update(q -> q.eq(BaseEntity::getId, id).set(Bom::getCurrentEdition, StatusConstant.YES));
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ Assert.eqTrue(flag, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
}
|