fix(ebom): 一些优化

This commit is contained in:
曹鹏飞 2024-05-26 14:42:53 +08:00
parent b939212953
commit 31ca386f05
5 changed files with 38 additions and 18 deletions

View File

@ -102,10 +102,9 @@ public class EbomV2Api extends BaseApi {
LogRecordContext.putVariable("fileNme", file.getOriginalFilename()); LogRecordContext.putVariable("fileNme", file.getOriginalFilename());
List<OperationErrorMsgVO> result = eBomImportService.importBom(file); List<OperationErrorMsgVO> result = eBomImportService.importBom(file);
ebomChildService.getBaseMapper().updateEBomMaterialUse(); ebomChildService.updateEBomMaterialUse();
//这个方法有问题 //这个方法有问题
// ebomParentService.compucteLevelNum(); // ebomParentService.compucteLevelNum();
ebomParentService.resetAllBomExist();
return ResultVO.success(result); return ResultVO.success(result);
} }

View File

@ -102,4 +102,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void insertEBomFormalChild(@Param("parentRowIds") List<Long> parentRowIds); void insertEBomFormalChild(@Param("parentRowIds") List<Long> parentRowIds);
void delEBomHistory(@Param("parentRowIds") List<Long> parentRowIds); void delEBomHistory(@Param("parentRowIds") List<Long> parentRowIds);
List<BomNewEbomParentEntity> getLatestByMaterialNo(Collection<String> materialNos);
} }

View File

@ -27,11 +27,7 @@ import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.entity.*; import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery; import com.nflg.product.bomnew.pojo.query.*;
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.QueryMaterialsQuery;
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.EBom.*; import com.nflg.product.bomnew.service.domain.EBom.*;
import com.nflg.product.bomnew.util.*; import com.nflg.product.bomnew.util.*;
@ -2394,10 +2390,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
public List<BomNewEbomParentEntity> getLatestByMaterialNo(Collection<String> materialNos) { public List<BomNewEbomParentEntity> getLatestByMaterialNo(Collection<String> materialNos) {
return this.lambdaQuery() // return this.lambdaQuery()
.in(BomNewEbomParentEntity::getMaterialNo, materialNos) // .in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(BomNewEbomParentEntity::getLastVersionIs, 1) // .eq(BomNewEbomParentEntity::getLastVersionIs, 1)
.list(); // .list();
return this.getBaseMapper().getLatestByMaterialNo(materialNos);
} }
public void setLastVersionIs0(Set<String> pMaterialNos) { public void setLastVersionIs0(Set<String> pMaterialNos) {

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.service; package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -79,8 +78,7 @@ public class EBomImportService {
bomNewEbomParentService.resetAllBomExist(); bomNewEbomParentService.resetAllBomExist();
bomNewEbomParentService.batchCheckAndSaveEBomException(pcs.getLeft().stream() bomNewEbomParentService.batchCheckAndSaveEBomException(importRoots.stream()
.filter(p -> p.getRootIs() == 1)
.map(BomNewEbomParentEntity::getRowId) .map(BomNewEbomParentEntity::getRowId)
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
@ -99,6 +97,13 @@ public class EBomImportService {
if (!Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) { if (!Objects.equals(p.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
bomNewEbomParentService.getBaseMapper().deleteById(p.getRowId()); bomNewEbomParentService.getBaseMapper().deleteById(p.getRowId());
bomNewEbomChildService.deleteAllChildren(p.getRowId()); bomNewEbomChildService.deleteAllChildren(p.getRowId());
parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> {
it.setCurrentVersion(p.getCurrentVersion());
});
} else {
parents.stream().filter(it -> StrUtil.equals(it.getMaterialNo(), p.getMaterialNo())).forEach(it -> {
it.setCurrentVersion(VersionUtil.getNextVersion(p.getCurrentVersion()));
});
} }
}); });
bomNewEbomParentService.setLastVersionIs0(pMaterialNos); bomNewEbomParentService.setLastVersionIs0(pMaterialNos);
@ -123,7 +128,7 @@ public class EBomImportService {
return isSame; return isSame;
} }
isSame = Objects.equals(parent.getMaterialUnit(), oldParent.getMaterialUnit()) isSame = Objects.equals(parent.getMaterialUnit(), oldParent.getMaterialUnit())
&& NumberUtil.equals(parent.getNum(), oldParent.getNum()) && isEquals(parent.getNum(), oldParent.getNum())
&& Objects.equals(parent.getMaterialTexture(), oldParent.getMaterialTexture()); && Objects.equals(parent.getMaterialTexture(), oldParent.getMaterialTexture());
if (isSame) { if (isSame) {
@ -173,7 +178,7 @@ public class EBomImportService {
} }
} }
isSame = Objects.equals(child.getMaterialUnit(), oldChild.getMaterialUnit()) isSame = Objects.equals(child.getMaterialUnit(), oldChild.getMaterialUnit())
&& NumberUtil.equals(child.getNum(), oldChild.getNum()) && isEquals(child.getNum(), oldChild.getNum())
&& Objects.equals(child.getMaterialTexture(), oldChild.getMaterialTexture()); && Objects.equals(child.getMaterialTexture(), oldChild.getMaterialTexture());
if (isSame) { if (isSame) {
@ -373,7 +378,7 @@ public class EBomImportService {
BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
parent.setRowId(IdWorker.getId()); parent.setRowId(IdWorker.getId());
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); //parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
parent.setMaterialNo(data.getParentMaterialNo()); parent.setMaterialNo(data.getParentMaterialNo());
parent.setMaterialDesc(data.getParentMaterialDesc()); parent.setMaterialDesc(data.getParentMaterialDesc());
BaseMaterialVO vo = materialBaseInfos.stream() BaseMaterialVO vo = materialBaseInfos.stream()
@ -453,7 +458,7 @@ public class EBomImportService {
//parent.setUnitWeight(BigDecimal.ZERO); //parent.setUnitWeight(BigDecimal.ZERO);
parent.setNum(BigDecimal.ONE); parent.setNum(BigDecimal.ONE);
//parent.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight())); //parent.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight()));
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); //parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
// List<Long> cps = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getMaterialNo, materialNo) // List<Long> cps = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getMaterialNo, materialNo)
// .list() // .list()
// .stream() // .stream()
@ -512,4 +517,10 @@ public class EBomImportService {
child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()); child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue());
} }
} }
private boolean isEquals(BigDecimal a, BigDecimal b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
return a.compareTo(b) == 0;
}
} }

View File

@ -484,6 +484,17 @@
WHERE a.row_id = #{parentRowId} WHERE a.row_id = #{parentRowId}
</select> </select>
<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
<foreach collection="materialNos" item="materialNo" index="index" open="(" close=")" separator=",">
#{materialNo}
</foreach>
</select>
<insert id="insertEBomFormalParent"> <insert id="insertEBomFormalParent">
INSERT INTO `t_bom_new_ebom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time`) INSERT INTO `t_bom_new_ebom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time`)
select `row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time` t_bom_new_ebom_parent select `row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time` t_bom_new_ebom_parent