feat(ebom): 从excel导入逻辑调整(旧版本是正式表则升级小版本;旧版本是工作表且是其他人创建则提示,旧版本是工作表且是自己创建则覆盖)
This commit is contained in:
parent
acc2e770fd
commit
a54b186845
|
|
@ -75,7 +75,8 @@ public class EBomImportService {
|
|||
List<BomNewEbomParentEntity> importRoots = pcs.getLeft().stream().filter(BomNewEbomParentEntity::isImportRoot).collect(Collectors.toList());
|
||||
//VUtils.isTure(importRoots.size() > 1).throwMessage("不支持一次导入多个bom");
|
||||
importRoots.forEach(it -> {
|
||||
VUtils.isTure(checkInconsistentData(pcs.getLeft().get(0), pcs.getLeft(), pcs.getRight())).throwMessage("导入的数据已存在,请勿重复导入");
|
||||
//VUtils.isTure(checkInconsistentData(pcs.getLeft().get(0), pcs.getLeft(), pcs.getRight())).throwMessage("导入的数据已存在,请勿重复导入");
|
||||
checkData(it, pcs.getLeft(), pcs.getRight());
|
||||
});
|
||||
|
||||
save(pcs.getLeft(), pcs.getRight());
|
||||
|
|
@ -110,7 +111,7 @@ public class EBomImportService {
|
|||
});
|
||||
} else {
|
||||
parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> {
|
||||
it.setCurrentVersion(VersionUtil.getNextVersion(p.getCurrentVersion()));
|
||||
it.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(p.getCurrentVersion()));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -119,6 +120,22 @@ public class EBomImportService {
|
|||
bomNewEbomChildService.saveBatch(children);
|
||||
}
|
||||
|
||||
private void checkData(BomNewEbomParentEntity parent, List<BomNewEbomParentEntity> parents, List<BomNewEbomChildEntity> children) {
|
||||
log.debug("checkData,entity:" + JSON.toJSONString(parent));
|
||||
BomNewEbomParentEntity oldParent = bomNewEbomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
VUtils.isTure(oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()
|
||||
&& !StrUtil.equals(parent.getCreatedBy(), SessionUtil.getUserCode()))
|
||||
.throwMessage(StrUtil.format("{}正由{}编辑中,请联系Ta处理", oldParent.getMaterialNo(), oldParent.getCreatedBy()));
|
||||
}
|
||||
Set<String> cmn = children.stream()
|
||||
.filter(c -> c.getParentRowId().equals(parent.getRowId()))
|
||||
.map(BomNewEbomChildEntity::getMaterialNo)
|
||||
.collect(Collectors.toSet());
|
||||
List<BomNewEbomParentEntity> cps = parents.stream().filter(p -> cmn.contains(p.getMaterialNo())).collect(Collectors.toList());
|
||||
cps.forEach(ps -> checkData(ps, parents, children));
|
||||
}
|
||||
|
||||
private boolean checkInconsistentData(BomNewEbomParentEntity parent, List<BomNewEbomParentEntity> parents,
|
||||
List<BomNewEbomChildEntity> children) {
|
||||
log.debug("checkInconsistentData,entity:" + JSON.toJSONString(parent));
|
||||
|
|
|
|||
|
|
@ -532,12 +532,12 @@
|
|||
<select id="getLatestByMaterialNo" resultType="com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity">
|
||||
SELECT p1.*
|
||||
FROM t_bom_new_ebom_parent p1
|
||||
INNER JOIN (SELECT material_no,MAX(row_id) row_id FROM t_bom_new_ebom_parent GROUP BY material_no) p2 ON
|
||||
p1.row_id=p2.row_id
|
||||
WHERE p1.material_no IN
|
||||
LEFT JOIN t_bom_new_ebom_parent p2
|
||||
ON p1.material_no = p2.material_no AND p1.current_version < p2.current_version
|
||||
WHERE p2.current_version IS NULL AND p1.material_no IN
|
||||
<foreach collection="materialNos" item="materialNo" index="index" open="(" close=")" separator=",">
|
||||
#{materialNo}
|
||||
</foreach>
|
||||
</foreach>;
|
||||
</select>
|
||||
|
||||
<insert id="insertEBomFormalParent">
|
||||
|
|
|
|||
Loading…
Reference in New Issue