| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | 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.common.core.utils.StringUtils; |
| | | import com.aps.core.domain.ApsMaterialStorageManagement; |
| | | import com.aps.core.mapper.ApsMaterialStorageManagementMapper; |
| | | import com.aps.core.service.IApsMaterialStorageManagementService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsMaterialStorageManagementMapper; |
| | | import com.aps.core.domain.ApsMaterialStorageManagement; |
| | | import com.aps.core.service.IApsMaterialStorageManagementService; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * 物料库存管理Service业务层处理 |
| | |
| | | // 返回库存信息对象 |
| | | return ams; |
| | | } |
| | | |
| | | /** |
| | | * 设置库存数据到redis |
| | | * @param orgCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean setStorageDataToRedis(String orgCode) { |
| | | try { |
| | | ApsMaterialStorageManagement temp = new ApsMaterialStorageManagement(); |
| | | if(!StringUtils.isEmpty(orgCode)){ |
| | | temp.setApplicableFactories(orgCode); |
| | | } |
| | | List<ApsMaterialStorageManagement> list = apsMaterialStorageManagementMapper.selectApsMaterialStorageManagementList(temp); |
| | | Map<String, Object> bulkData = new HashMap<>(); |
| | | list.forEach(apsMaterialStorageManagement -> { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("id", apsMaterialStorageManagement.getId()); |
| | | jsonObject.put("itemNumber", apsMaterialStorageManagement.getItemNumber()); |
| | | jsonObject.put("remainderStock", apsMaterialStorageManagement.getRemainderStock()); |
| | | jsonObject.put("applicableFactories", apsMaterialStorageManagement.getApplicableFactories()); |
| | | bulkData.put("MaterialStorage:Material_"+apsMaterialStorageManagement.getApplicableFactories()+"_"+apsMaterialStorageManagement.getItemNumber(), jsonObject); |
| | | }); |
| | | redisTemplate.opsForValue().multiSet(bulkData); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | } |
| | | // Set<String> keys = redisTemplate.keys("MaterialStorage:Material_*"); |
| | | // if (keys != null && !keys.isEmpty()) { |
| | | // redisTemplate.delete(keys); |
| | | // } |
| | | return true; |
| | | } |
| | | } |