| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.aps.common.core.utils.DateUtils; |
| | |
| | | import com.aps.core.domain.ApsMaterialStorageManagement; |
| | | import com.aps.core.mapper.ApsMaterialStorageManagementMapper; |
| | | import com.aps.core.service.IApsMaterialStorageManagementService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 物料库存管理Service业务层处理 |
| | |
| | | * @date 2025-04-17 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ApsMaterialStorageManagementServiceImpl implements IApsMaterialStorageManagementService |
| | | { |
| | | @Autowired |
| | |
| | | @Override |
| | | public boolean setStorageDataToRedis(String orgCode) { |
| | | try { |
| | | log.info("开始同步 物料库存至Redis!"); |
| | | Set<String> keys = redisTemplate.keys("MaterialStorage:Material_*"); |
| | | if (keys != null && !keys.isEmpty()) { |
| | | redisTemplate.delete(keys); |
| | | } |
| | | ApsMaterialStorageManagement temp = new ApsMaterialStorageManagement(); |
| | | if(!StringUtils.isEmpty(orgCode)){ |
| | | temp.setApplicableFactories(orgCode); |
| | |
| | | bulkData.put("MaterialStorage:Material_"+apsMaterialStorageManagement.getApplicableFactories()+"_"+apsMaterialStorageManagement.getItemNumber(), jsonObject); |
| | | }); |
| | | redisTemplate.opsForValue().multiSet(bulkData); |
| | | log.info("完成同步 物料库存至Redis!"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("同步物料库存至Redis失败!"+e.getMessage()); |
| | | return false; |
| | | } |
| | | // Set<String> keys = redisTemplate.keys("MaterialStorage:Material_*"); |
| | | // if (keys != null && !keys.isEmpty()) { |
| | | // redisTemplate.delete(keys); |
| | | // } |
| | | return true; |
| | | } |
| | | |