小鹏汽车智慧材料数据库系统项目总成数据同步

1、定时任务处理

2、提供了接口

小鹏方面提供的推送的数据表结构:

这几个表总数为100多万,经过条件筛选过滤后大概2万多条数据

小鹏的人给的示例图:

界面:

SQL:

-- 查询车型
select bmm.md_material_id, bmm.material_num, bmm.material_name, bmm.material_name_en
from bm_md_material bmm
where bmm.md_material_id in(SELECT bpa.master_part_idfrom (SELECT bpa.master_part_id, bpa.sub_part_id FROM bm_part_assembly bpa WHERE bpa.bom_type = 'PART') aINNER JOIN bm_part_assembly bpa on bpa.sub_part_id = a.master_part_id AND bpa.bom_type = 'EBOM');# 根据车型材料id(md_material_id)总成主数据
select
bpa.bm_part_assembly_id as bmPartAssemblyId,
bpa.master_part_id as master_part_id,
bpa.sub_part_id as sub_part_id,
bpa.update_date as update_date,
bpa.quantity as useNumber,
bpa.weight_tag as weight,
bpa.dev_type as developStatus,
bpa.employee_id as bomResponsibleEngineer,
bpa.suggest_sourcing as procurementType,
bpa.bom_type,
bpa.change_id,
bpae.importance_level severity,
bpae.torque as tighteningTorque,
bpae.note as connectionsCodeZhDescribe,
bpae.vehicleproject as inheritedRemodeledModels,
bmm.material_num
from bm_part_assembly bpaleft join bm_part_assembly_ext bpae on bpae.bm_part_assembly_ext_id = bpa.part_assembly_ext_idinner join bm_md_material bmm on bmm.md_material_id = bpa.sub_part_id
where (bpa.bom_type = 'EBOM' or bpa.bom_type = 'PART')and is_latest = 1 -- 最新版本and active_status = 'current' -- 生效状态and bpa.update_date > '2024-07-01'
#          and bpa.master_part_id = '98535' -- 车型 md_material_id 23821, 根据 sub_part_id  4010809DF1-00-03 64332   车型的  23821and bpa.master_part_id = '23821' -- 车型 md_material_id 23821, 根据 sub_part_id  4010809DF1-00-03 64332   车型的  23821
#          and bpa.master_part_id = '98532' -- 车型 md_material_id 23821, 根据 sub_part_id  4010809DF1-00-03 64332   车型的  23821
#          and bpa.master_part_id = '193598' -- 车型 md_material_id 23821, 根据 sub_part_id  4010809DF1-00-03 64332   车型的  23821and bpa.master_part_id = '64332' -- 车型 md_material_id 23821, 根据 sub_part_id  4010809DF1-00-03 64332   车型的  23821   如:根据子件id:64332查询,递归去查询,直到无下级
#          and bpa.sub_part_id like '64332'and material_num = '4010809DF1-00-03'
;

Mapper和Mapper.xml

<!-- 总成主数据 --><select id="syncDataByPage" resultType="com.ruiyada.whole.domain.vo.BomAssemblyVo">selectbpa.bm_part_assembly_id as syncPartAssemblyId,bpa.master_part_id as masterPartId, -- 父件id(父物料id)bpa.sub_part_id as subPartId, -- 子件id(子物料id)bpa.update_date as lastSyncUpdateDate,  -- 同步版本号bpa.quantity as useNumber, -- 用量bpa.weight_tag as weight, -- 重量bpa.dev_type as developStatus, -- 开发状态bpa.employee_id as employeeId, -- 员工id 根据这个员工id去员工表查询 责任工程师bpa.suggest_sourcing as procurementType, -- 采购类型bpa.bom_type as bomType,bpa.change_id as changeId,bpae.importance_level as severity, -- 重要度bpae.torque as tighteningTorque, -- 紧固力矩bpae.note as connectionsCodeZhDescribe, -- 连接点代码中文描述bpae.vehicleproject as inheritedRemodeledModelsfrom bm_part_assembly bpaleft join bm_part_assembly_ext bpae on bpae.bm_part_assembly_ext_id = bpa.part_assembly_ext_idinner join bm_md_material bmm on bmm.md_material_id = bpa.sub_part_idwhere (bpa.bom_type = 'EBOM' or bpa.bom_type = 'PART')and is_latest = 1 -- 最新版本and active_status = 'current'<if test="lastSyncUpdateDate!='' and lastSyncUpdateDate!=null">and bpa.update_date &gt; #{lastSyncUpdateDate}</if><if test="masterPartId!='' and masterPartId!=null">and bpa.master_part_id = #{masterPartId}</if>ORDER BY bpa.update_date DESCLIMIT #{start}, #{pageSize}</select><!-- 车型数据 --><select id="selectCarData" resultType="com.ruiyada.whole.domain.vo.BomAssemblyVo">select bmm.md_material_id as materielId,bmm.material_num as materielCode,bmm.material_name as materielCnName,bmm.material_name_en as materielEnNamefrom bm_md_material bmmwhere bmm.md_material_id in (SELECT bpa.master_part_id from(SELECT  bpa.master_part_id, bpa.sub_part_id FROM bm_part_assembly bpaWHERE bpa.bom_type  = 'PART') aINNER JOIN bm_part_assembly bpa on bpa.sub_part_id  = a.master_part_id AND bpa.bom_type  = 'EBOM')</select><!-- BOM责任工程师 --><select id="bomResponsibleEngineer" resultType="com.ruiyada.whole.domain.vo.BomAssemblyVo">select bau.user_id userId,bau.user_name userName,bau.organization_id organizationIdfrom bm_acct_user bau where user_id = #{employeeId};</select><!-- 责任部门 --><select id="bomResponsibleDepartment" resultType="com.ruiyada.whole.domain.vo.BomAssemblyVo">selectbao.id as orgId, bao.org_name as bomResponsibleDepartment, bao.org_name_en as orgNameEnfrom bm_acct_organization baowhere id = #{organizationId}</select><!--生效ECN编号--><select id="selectEcnNumberEffect" resultType="string">select bmc.change_code AS ecnNumberEffectfrom bm_md_change bmc where md_change_id = #{changeId}</select><!-- 查询已同步的最新的一条版本号 --><select id="selectLastSyncUpdateDate" resultType="java.time.LocalDateTime">select DATE_FORMAT(last_sync_update_time, '%Y-%m-%d') as last_sync_update_time from bom_assembly_material_parts order by last_sync_update_time desc limit 1;</select><!-- 根据物料id查询总成下级 --><select id="selectByMaterialId" resultType="com.ruiyada.whole.domain.vo.BomAssemblyVo">select bmm.md_material_id as materielId,bmm.material_name as materielCnName,bmm.material_name_en as materielEnName,bmm.material_num as materielCodefrom  bm_md_material bmmwhere md_material_id in<foreach item="item" index="index" collection="materialIds" open="(" separator="," close=")">#{item}</foreach></select><!-- 统计车型下的总成总数 --><select id="assentlyCount" resultType="java.lang.Integer">selectcount(1)from bm_part_assembly bpaleft join bm_part_assembly_ext bpae on bpae.bm_part_assembly_ext_id = bpa.part_assembly_ext_idinner join bm_md_material bmm on bmm.md_material_id = bpa.sub_part_idwhere (bpa.bom_type = 'EBOM' or bpa.bom_type = 'PART')and is_latest = 1 -- 最新版本and active_status = 'current' -- 生效状态and bpa.master_part_id = #{masterPartId}</select>
@Mapper
public interface BomAssemblyMaterialPartsMapper extends BaseMapper<BomAssemblyMaterialParts> {List<BomAssembyMaterialPartsVO> ListById(@Param("bom_id") String bomId);/*** 查询已同步的最新的一条版本号*/LocalDateTime selectLastSyncUpdateDate();/*** 分页查询总成主数据* @param start* @param pageSize* @param lastSyncUpdateDate* @return*/List<BomAssemblyVo> syncDataByPage(@Param("start") int start, @Param("pageSize") int pageSize,@Param("lastSyncUpdateDate") String lastSyncUpdateDate,@Param("masterPartId") String masterPartId);/*** 车型数据* @return*/List<BomAssemblyVo>  selectCarData();/*** BOM责任工程师* @return*/BomAssemblyVo  bomResponsibleEngineer(@Param("employeeId") String employeeId);/*** 责任部门* @return*/BomAssemblyVo  bomResponsibleDepartment(@Param("organizationId") String organizationId);/*** 生效ECN编号* @return*/String  selectEcnNumberEffect(@Param("changeId") String changeId);/*** 根据物料id查询总成下级数据* @param materialIds* @return*/List<BomAssemblyVo>  selectByMaterialId(@Param("materialIds") List<String> materialIds);/*** 统计车型下的总成总数* @param masterPartId* @return*/Integer assentlyCount(@Param("masterPartId") String masterPartId);}
/*** <p>* BOM总成材料零件表 服务实现类* </p>** @author 袁腾飞* @since 2024-10-14*/
@Slf4j
@Service
public class BomAssemblyMaterialPartsServiceImpl extends ServiceImpl<BomAssemblyMaterialPartsMapper, BomAssemblyMaterialParts> implements BomAssemblyMaterialPartsService {@Autowiredprivate BomAssemblyMaterialPartsMapper bomAssemblyMaterialPartsMapper;@Autowiredprivate BomCategoryService bomCategoryService;
@Overridepublic List<BomAssemblyMaterialParts> syncDataByPage(int pageSize) {// 获取上一次同步数据的更新时间LocalDateTime lastSyncUpdateDate = selectLastSyncUpdateDate();String formatLastSyncUpdateDate = lastSyncUpdateDate==null ? "" : lastSyncUpdateDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));// 组装数据List<BomAssemblyDto> bomAssemblyDtos = assemblingData(pageSize, formatLastSyncUpdateDate);// 把组装后的数据转换为BomAssemblyMaterialParts对象// bomAssemblyDtos在里面取出每个字段// bomAssemblyDtos的父级,给BomAssemblyMaterialParts对象父级设置parentId为0,id自动生成;里层的children的parentId为外层的id// 父级的parentId设为0List<BomAssemblyMaterialParts> partsList = convertToBomAssemblyMaterialParts(bomAssemblyDtos, "0");// partsList里面的children取出与父节点一起保存if (!partsList.isEmpty()) {bomAssemblyMaterialPartSaveBatch(partsList);}return partsList;}private void bomAssemblyMaterialPartSaveBatch(List<BomAssemblyMaterialParts> partsList) {// 收集所有需要保存的节点List<BomAssemblyMaterialParts> allNodes = collectAllNodes(partsList);// 批量插入所有节点// 判断allNodes里面的syncPartAssemblyId是否在数据库中存在,如果不存在,则插入,如果存在,则更新// List<String> list = allNodes.stream().map(BomAssemblyMaterialParts::getSyncPartAssemblyId).collect(Collectors.toList());allNodes.stream().map(item -> item).forEach(item -> {// 判断item是否在数据库中存在LambdaQueryWrapper<BomAssemblyMaterialParts> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(BomAssemblyMaterialParts::getSyncPartAssemblyId, item.getSyncPartAssemblyId());BomAssemblyMaterialParts bomAssemblyMaterialParts = bomAssemblyMaterialPartsMapper.selectOne(queryWrapper);if (bomAssemblyMaterialParts == null) {// 不存在,则插入bomAssemblyMaterialPartsMapper.insert(item);} else {// 存在,则更新bomAssemblyMaterialPartsMapper.update(item, queryWrapper);}});// bomAssemblyMaterialPartsMapper.insertOrUpdate(allNodes);}private List<BomAssemblyMaterialParts> collectAllNodes(List<BomAssemblyMaterialParts> nodes) {List<BomAssemblyMaterialParts> allNodes = new ArrayList<>();for (BomAssemblyMaterialParts node : nodes) {allNodes.add(node);if (node.getChildren() != null && !node.getChildren().isEmpty()) {allNodes.addAll(collectAllNodes(node.getChildren()));}}return allNodes;}private List<BomAssemblyDto> convertToBomAssemblyDtos(List<BomAssemblyVo> bomAssemblyVos, String ecnNumberEffect) {if (bomAssemblyVos == null || bomAssemblyVos.isEmpty()) {return Collections.emptyList();}return bomAssemblyVos.stream().map(vo -> {BomAssemblyDto dto = new BomAssemblyDto();BeanUtils.copyProperties(vo, dto);dto.setChildren(convertToBomAssemblyDtos(vo.getChildren(), ecnNumberEffect));return dto;}).collect(Collectors.toList());}private List<BomAssemblyMaterialParts> convertToBomAssemblyMaterialParts(List<BomAssemblyDto> dtos, String parentId) {List<BomAssemblyMaterialParts> collect = dtos.stream().map(dto -> {String id = "";// 判断item是否在数据库中存在LambdaQueryWrapper<BomAssemblyMaterialParts> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(BomAssemblyMaterialParts::getSyncPartAssemblyId, dto.getSyncPartAssemblyId());BomAssemblyMaterialParts bomAssemblyMaterialParts = bomAssemblyMaterialPartsMapper.selectOne(queryWrapper);if (bomAssemblyMaterialParts == null) {// 不存在,则就生成idid = IdUtil.simpleUUID();} else {// 存在,id 和 parentId 保持不变id = bomAssemblyMaterialParts.getId();}BomAssemblyMaterialParts parts = new BomAssemblyMaterialParts();String bomCategoryId = dto.getBomCategoryId();BeanUtils.copyProperties(dto, parts);parts.setId(id);parts.setParentId(parentId);parts.setBomId(bomCategoryId);List<BomAssemblyDto> children = dto.getChildren();if (!children.isEmpty()) {List<BomAssemblyMaterialParts> partsList = convertToBomAssemblyMaterialParts(dto.getChildren(), parts.getId());// 这里的partList里面的数据bomId没有给赋值,需要给bomId赋值:bomCategoryId// parts.setBomId(bomCategoryId);partsList.forEach(part -> part.setBomId(bomCategoryId));parts.setChildren(partsList);}parts.setLastSyncUpdateTime(dto.getLastSyncUpdateDate());parts.setCreateTime(LocalDateTime.now());parts.setUpdateTime(LocalDateTime.now());return parts;}).collect(Collectors.toList());return collect;}/*** 组装数据** @param pageSize          每页大小* @param lastSyncVersionNo 上一次同步的版本号* @return*/private List<BomAssemblyDto> assemblingData(int pageSize, String lastSyncVersionNo) {// 先查询车型List<BomAssemblyVo> selectedCarData = selectCarData();// todo 暂时过滤一下数据,只查询一个车型// List<BomAssemblyVo> collect = selectedCarData.stream().filter(bomAssemblyVo -> bomAssemblyVo.getMaterielId().equals("23821")).collect(Collectors.toList());// 构建 md_material_id 到 BomAssemblyVo 的映射Map<String, BomAssemblyVo> carDataMap = selectedCarData.stream().collect(Collectors.toMap(BomAssemblyVo::getMaterielId, vo -> vo));// Map<String, BomAssemblyVo> carDataMap = collect.stream().collect(Collectors.toMap(BomAssemblyVo::getMaterielId, vo -> vo));/*步骤:1、先是查询出基础总成数据2、先查询车型,拿到车型的md_material_id3、根据拿到每个车型的md_material_id 查询 bm_part_assembly表的master_part_id,就得到了得到sub_part_id4、得到sub_part_id 查询bm_md_material表,得到了下级总成,循环类推,递归5、查询的下级放在BomAssemblyVo里面的children集合里面6、拼装数据,把查询生效ECN编号、数据量很大,100多万数据能不能用stream流、递归、树形结构select bmm.md_material_id as materialId, bmm.material_name materielName, bmm.material_num from  bm_md_material bmmwhere md_material_id in #{materialId}*/List<BomAssemblyDto> result = new ArrayList<>();// 用carDataMap key查询数据carDataMap.forEach((masterPartId, value) -> {// 获取总数Integer totalCount = assentlyCount(masterPartId);double totalPage = Math.ceil((double) totalCount / pageSize);// 分页处理for (int currentPage = 0; currentPage < totalPage; currentPage++) {int offset = currentPage * pageSize;// 根据查询的车型的id的这个key查询获取sub_part_id,在这里bomAssemblyVos获取sub_part_id值,获得sub_part_id值后再次用bomAssemblyMaterialPartsMapper.syncDataByPage查询,把查询到的sub_part_id值传入到key的位置,直到查询不到数据// 第一次查询的是父节点,递归出来的后面的查询是子节点放在children里面List<BomAssemblyVo> bomAssemblyVos = bomAssemblyMaterialPartsMapper.syncDataByPage(offset, pageSize, lastSyncVersionNo, masterPartId);// todo 临时测试用// List<BomAssemblyVo> bomAssemblyVos = bomAssemblyVoList.stream().filter(bomAssemblyVo -> bomAssemblyVo.getSubPartId().equals("64332")).collect(Collectors.toList());// List<BomAssemblyVo> bomAssemblyVos = bomAssemblyVoList.stream().filter(bomAssemblyVo -> bomAssemblyVo.getSubPartId().equals("98535")).collect(Collectors.toList());// List<BomAssemblyVo> bomAssemblyVos = bomAssemblyVoList.stream().filter(bomAssemblyVo -> bomAssemblyVo.getSubPartId().equals("64332")).collect(Collectors.toList());// BOM分类车型数据LambdaQueryWrapper<BomCategory> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(BomCategory::getIsCar, 1);List<BomCategory> bomCategories = bomCategoryService.list(queryWrapper);// 车型名称String carType = value.getMaterielCnName();// 在这里获取所有的分类名称(categoryName)和id,如果categoryName与carType比较,// 如果匹配上就把bomCategories的id给BomAssemblyVo对象的bomCategoryId并保存数据,否则就不保存数据// 查找匹配的车型分类Optional<BomCategory> categoryOptional = bomCategories.stream().filter(cat -> cat.getCategoryName().equals(carType)).findFirst();if (categoryOptional.isPresent()) {String categoryId = categoryOptional.get().getId();// 设置categoryId到每个BomAssemblyVo对象setCategoryIdRecursively(bomAssemblyVos, categoryId);} else {// 如果没有匹配的分类,则跳过这些数据return;}// 补充 materialName 和 materialNum 对于父节点Set<String> parentIds = bomAssemblyVos.stream().map(BomAssemblyVo::getSubPartId).filter(Objects::nonNull).collect(Collectors.toSet());if (!parentIds.isEmpty()) {List<BomAssemblyVo> parentDetails = selectByMaterialIds(new ArrayList<>(parentIds));Map<String, BomAssemblyVo> parentDetailMap = parentDetails.stream().collect(Collectors.toMap(BomAssemblyVo::getMaterielId, vo -> vo));for (BomAssemblyVo assembly : bomAssemblyVos) {BomAssemblyVo detail = parentDetailMap.get(assembly.getSubPartId());if (detail != null) {assembly.setMaterielCnName(detail.getMaterielCnName());assembly.setMaterielEnName(detail.getMaterielEnName());assembly.setMaterielCode(detail.getMaterielCode());assembly.setPartCode(detail.getPartCode());assembly.setCarType(detail.getCarType());assembly.setEcnNumberEffect(detail.getEcnNumberEffect());assembly.setPartNumber(detail.getPartNumber());assembly.setBomType(detail.getBomType());}}}// 再组装数据for (BomAssemblyVo assembly : bomAssemblyVos) {buildTree(assembly, offset, pageSize, lastSyncVersionNo);String changeId = assembly.getChangeId();String changeCode = selectEcnNumberEffect(changeId);String employeeId = assembly.getEmployeeId();String userName = "";String organizationId = "";if (StringUtils.isNotBlank(employeeId)) {// BOM责任工程师BomAssemblyVo bomAssemblyVo = bomResponsibleEngineer(employeeId);if (bomAssemblyVo != null) {userName = bomAssemblyVo.getUserName();organizationId = bomAssemblyVo.getOrganizationId();}}String bomResponsibleDepartment = "";if (StringUtils.isNotBlank(organizationId)) {// BOM责任部门BomAssemblyVo assemblyVo = bomResponsibleDepartment(organizationId);if (assemblyVo != null) {bomResponsibleDepartment = assemblyVo.getBomResponsibleDepartment();}}assembly.setUserName(userName);assembly.setBomResponsibleDepartment(bomResponsibleDepartment);BomAssemblyDto bomAssemblyDto = new BomAssemblyDto();BeanUtils.copyProperties(assembly, bomAssemblyDto);bomAssemblyDto.setChildren(convertToBomAssemblyDtos(assembly.getChildren(), changeCode));result.add(bomAssemblyDto);}}});log.info("result:::::::::" + result);// 拼装数据,包括生效ECN编号等信息// convertToBomAssemblyMaterialParts(result);return result;}private void setCategoryIdRecursively(List<BomAssemblyVo> bomAssemblyVos, String categoryId) {for (BomAssemblyVo assembly : bomAssemblyVos) {assembly.setBomCategoryId(categoryId);if (assembly.getChildren() != null && !assembly.getChildren().isEmpty()) {setCategoryIdRecursively(assembly.getChildren(), categoryId);}}}private void buildTree(BomAssemblyVo parent, int pageNo, int pageSize, String lastSyncVersionNo) {if (parent == null || parent.getSubPartId() == null) {return;}List<BomAssemblyVo> children = bomAssemblyMaterialPartsMapper.syncDataByPage(pageNo, pageSize, lastSyncVersionNo, parent.getSubPartId());// 补充 materialName 和 materialNumSet<String> subPartIds = children.stream().map(BomAssemblyVo::getSubPartId).filter(Objects::nonNull).collect(Collectors.toSet());if (!subPartIds.isEmpty()) {List<BomAssemblyVo> materialDetails = selectByMaterialIds(new ArrayList<>(subPartIds));Map<String, BomAssemblyVo> materialDetailMap = materialDetails.stream().collect(Collectors.toMap(BomAssemblyVo::getMaterielId, vo -> vo));for (BomAssemblyVo child : children) {BomAssemblyVo detail = materialDetailMap.get(child.getSubPartId());if (detail != null) {child.setMaterielCnName(detail.getMaterielCnName());child.setMaterielEnName(detail.getMaterielEnName());child.setMaterielCode(detail.getMaterielCode());child.setPartCode(detail.getPartCode());child.setCarType(detail.getCarType());child.setEcnNumberEffect(detail.getEcnNumberEffect());child.setPartNumber(detail.getPartNumber());child.setBomType(detail.getBomType());}}}parent.setChildren(children);for (BomAssemblyVo child : children) {buildTree(child, pageNo, pageSize, lastSyncVersionNo);}}/*** 查询车型** @return*/private List<BomAssemblyVo> selectCarData() {List<BomAssemblyVo> list = bomAssemblyMaterialPartsMapper.selectCarData();return list;}/*** 查询生效ECN编号** @return*/private String selectEcnNumberEffect(String changeId) {return bomAssemblyMaterialPartsMapper.selectEcnNumberEffect(changeId);}/*** 根据物料id查询总成下级数据** @param materialIds* @return*/private List<BomAssemblyVo> selectByMaterialIds(List<String> materialIds) {/*这个sql是这样的:select bmm.md_material_id as materialId, bmm.material_name materielName, bmm.material_num from  bm_md_material bmmwhere md_material_id in #{materialIds}*/if (materialIds == null || materialIds.isEmpty()) {return Collections.emptyList();}return bomAssemblyMaterialPartsMapper.selectByMaterialId(materialIds);}/*** BOM责任工程师** @return*/private BomAssemblyVo bomResponsibleEngineer(String employeeId) {return bomAssemblyMaterialPartsMapper.bomResponsibleEngineer(employeeId);}/*** BOM责任部门** @param organizationId* @return*/private BomAssemblyVo bomResponsibleDepartment(String organizationId) {return bomAssemblyMaterialPartsMapper.bomResponsibleDepartment(organizationId);}/*** 同步版本号** @return*/private LocalDateTime selectLastSyncUpdateDate() {LocalDateTime lastSyncUpdateDate = bomAssemblyMaterialPartsMapper.selectLastSyncUpdateDate();log.info("最新版本号:{}", lastSyncUpdateDate);return lastSyncUpdateDate;}@Overridepublic Integer assentlyCount(String masterPartId) {Integer assentlyCount = bomAssemblyMaterialPartsMapper.assentlyCount(masterPartId);return assentlyCount == null ? 0 : assentlyCount;}}
/*** <p>* BOM总成材料零件表 服务类* </p>** @author 袁腾飞* @since 2024-10-14*/
public interface BomAssemblyMaterialPartsService extends IService<BomAssemblyMaterialParts> {IPage<BomAssemblyMaterialParts> pageListCondition(PagingQuery pagingQuery, BomAssemblyQuery queryParam);List<BomAssembyMaterialPartsVO> ListById(String bomId);List<BomAssemblyMaterialParts> listCondition(PagingQuery pagingQuery, BomAssemblyQuery queryParam);List<BomAssemblyMaterialParts> syncDataByPage(int pageSize);Integer assentlyCount(String masterPartId);
}

定时任务层

/*** 同步总成数据*/
@Slf4j
@Lazy(value = false)
@Component
// @PropertySource(value = "classpath:jobTask.properties",encoding = "UTF-8")
public class SyncWholeData {@Autowiredprivate BomAssemblyMaterialPartsService bomAssemblyMaterialPartsService;@Resourceprivate StringRedisTemplate stringRedisTemplate;@Value("${pageSize}")private Integer pageSize;/*** 同步总成数据*/@Transactional(rollbackFor = Exception.class)@Async@Scheduled(cron = "${inactiveaccountCron}")public void syncWhole1() {String lockKey = "lock:sync:whole:";boolean isLocked = tryLock(lockKey);try {if (isLocked) {// 成功获取锁,执行同步逻辑bomAssemblyMaterialPartsService.syncDataByPage(pageSize);}} finally {unlock(lockKey);}}/*** 尝试获取锁** @param key* @return*/private boolean tryLock(String key) {// setIfAbsent 如果存在Boolean flag = stringRedisTemplate.opsForValue().setIfAbsent(key, "1", 2, TimeUnit.HOURS);return BooleanUtil.isTrue(flag);}/*** 释放锁** @param key*/private void unlock(String key) {stringRedisTemplate.delete(key);}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/61628.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Parker派克防爆电机在实际应用中的安全性能如何保证?

Parker防爆电机确保在实际应用中的安全性能主要通过以下几个方面来保证&#xff1a; 1.防爆外壳设计&#xff1a;EX系列电机采用强大的防爆外壳&#xff0c;设计遵循严格的防爆标准&#xff0c;能够承受内部可能发生的爆炸而不破损&#xff0c;利用间隙切断原理&#xff0c;防…

如何在Word文件中设置水印以及如何禁止修改水印

在日常办公和学习中&#xff0c;我们经常需要在Word文档中设置水印&#xff0c;以保护文件的版权或标明文件的机密性。水印可以是文字形式&#xff0c;也可以是图片形式&#xff0c;能够灵活地适应不同的需求。但仅仅设置水印是不够的&#xff0c;有时我们还需要确保水印不被随…

Linux高阶——1123—

1、服务器基础 1、服务器基本概述 在CS架构下&#xff0c;client and server下&#xff0c;工程师研发服务器&#xff0c;经典的后端程序&#xff0c;为前端&#xff08;客户端&#xff09;提供数据处理支持、数据中转、数据持久化等功能&#xff0c;在互联网中&#xff0c;几…

鸿蒙NEXT开发案例:字数统计

【引言】 本文将通过一个具体的案例——“字数统计”组件&#xff0c;来探讨如何在鸿蒙NEXT框架下实现这一功能。此组件不仅能够统计用户输入文本中的汉字、中文标点、数字、以及英文字符的数量&#xff0c;还具有良好的用户界面设计&#xff0c;使用户能够直观地了解输入文本…

贪心算法(1)

目录 柠檬水找零 题解&#xff1a; 代码&#xff1a; 将数组和减半的最少操作次数&#xff08;大根堆&#xff09; 题解&#xff1a; 代码&#xff1a; 最大数&#xff08;注意 sort 中 cmp 的写法&#xff09; 题解&#xff1a; 代码&#xff1a; 摆动序列&#xff0…

linux从0到1——shell编程7

声明&#xff01; 学习视频来自B站up主 **泷羽sec** 有兴趣的师傅可以关注一下&#xff0c;如涉及侵权马上删除文章&#xff0c;笔记只是方便各位师傅的学习和探讨&#xff0c;文章所提到的网站以及内容&#xff0c;只做学习交流&#xff0c;其他均与本人以及泷羽sec团队无关&a…

微软发布Win11 24H2系统11月可选更新KB5046740!

系统之家11月22日报道&#xff0c;微软针对Win11 24H2系统推出2024年11月最新可选更新补丁KB5046740&#xff0c;更新后系统版本后升至26100.2454&#xff0c;此次更新后修复当应用程序以PDF和XLSX格式导出图表对象时停止响应、无法使用API查找旋转信息等问题。以下小编将给大家…

五天SpringCloud计划——DAY2之使用Docker完成项目的部署

一、引言 刚刚学完了Docker的使用&#xff0c;现在知识在脑子里面还是热乎的&#xff0c;是时候把它总结一下了。 现在的我认为Docker时一个部署项目的工具(不知道是不是真的),相比于我以前使用宝塔面板部署项目&#xff0c;使用Docker更能让我看到代码之美&#xff0c;怎么一…

设计模式之 模板方法模式

模板方法模式是行为型设计模式的一种。它定义了一个算法的骨架&#xff0c;并将某些步骤的实现延迟到子类中。模板方法模式允许子类在不改变算法结构的情况下重新定义算法的某些特定步骤。 模板方法模式的核心在于&#xff1a; 封装算法的骨架&#xff1a;通过父类中的模板方…

Softing线上研讨会 | Ethernet-APL:推动数字时代的过程自动化

| &#xff08;免费&#xff09;线上研讨会时间&#xff1a;2024年11月19日 16:00~16:30 / 23:00~23:30 Ethernet-APL以10Mb/s的传输速率为过程工业中的现场设备带来了无缝以太网连接和本质安全电源&#xff0c;这不仅革新了新建工厂&#xff0c;也适用于改造现有工厂。 与现…

Idea修改Commit Changes模式、idea使用git缺少部分Commit Changes

文章目录 一、模式一1、页面效果如下2、如何打开为这种样式&#xff1f; 二、模式二1、页面效果如下2、如何打开为这种样式&#xff1f; 三、总结 前言&#xff1a;Idea中代码提交到git库时的commit Change有两种模式&#xff0c;每种模式的界面及功能都不太一样。 Commit Cha…

东土科技孵化的“网联汽车高速通信技术”前沿产品亮相2024WICV大会

2024世界智能网联汽车大会&#xff08;WICV&#xff09;于近日在北京召开。本次大会发布了由中国汽车工程学会组织全球200余位专家&#xff0c;联合评审遴选出未来十年对于智能网联汽车发展具有重要影响的十大技术趋势&#xff0c;包括“面向高级别自动驾驶的超级人工智能”“网…

使用itextpdf进行pdf模版填充中文文本时部分字不显示问题

在网上找了很多种办法 都解决不了; 最后发现是文本域字体设置出了问题; 在这不展示其他的代码 只展示重要代码; 1 引入扩展包 <dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</v…

HTML5实现剪刀石头布小游戏(附源码)

文章目录 1.设计来源1.1 主界面1.2 皮肤风格1.2 游戏中界面 2.效果和源码源码下载万套模板&#xff0c;程序开发&#xff0c;在线开发&#xff0c;在线沟通 作者&#xff1a;xcLeigh 文章地址&#xff1a;https://blog.csdn.net/weixin_43151418/article/details/143798520 HTM…

自动驾驶之激光雷达

这里写目录标题 1 什么是激光雷达2 激光雷达的关键参数3 激光雷达种类4 自动驾驶感知传感器5 激光雷达感知框架5.1 pointcloud_preprocess5.2 pointcloud_map_based_roi5.3 pointcloud_ground_detection5.4 lidar_detection5.5 lidar_detection_filter5.6 lidar_tracking 1 什么…

pycharm在使用conda虚拟环境时Terminal爆红问题

问题&#xff1a; 解决方法&#xff1a; 复制cmd.exe后面所有路径 添加到pycharm的shell path中&#xff1a;

《Python浪漫的烟花表白特效》

一、背景介绍 烟花象征着浪漫与激情&#xff0c;将它与表白结合在一起&#xff0c;会创造出别具一格的惊喜效果。使用Python的turtle模块&#xff0c;我们可以轻松绘制出动态的烟花特效&#xff0c;再配合文字表白&#xff0c;打造一段专属的浪漫体验。 接下来&#xff0c;让…

二次封装的天气时间日历选择组件

这个接口没调通 没有数据展示~ userStore.badgeDate是VUEX全部存的日历数据 <template><!-- 日历组件 --><el-date-pickerref"elPicker":size"size"v-model"dateTimeValue":type"dateType":range-separator"rang…

当你项目服务器磁盘报警

当你们公司运维收到这样的邮件&#xff0c;大概率日志文件过大引起的 在Linux下如何不停止服务,清空nohup.out文件呢&#xff1f; nohup.out会一直一直自己增长下去&#xff0c;如果你的服务器硬盘不给力的话&#xff0c;很容易把应用也挂掉&#xff08;硬盘没空间 &#xff0…

低速接口项目之串口Uart开发(四)——UART串口实现FPGA内部AXILITE寄存器的读写控制

本节目录 一、设计背景 二、设计思路 三、逻辑设计框架 四、仿真验证 五、上板验证 六、往期文章链接本节内容 一、设计背景 通常&#xff0c;芯片手册或者IP都会提供一系列的用户寄存器以及相关的定义&#xff0c;用于软件开发人员进行控制底层硬件来调试&#xff0c;或封装…