| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.uuid.IdUtils; |
| | |
| | | public ApsPlatePlan selectUnMatchPlateSubPlan(String plant, String itemNumber, Hashtable<String, List<ApsPlatePlan>> subPlans) { |
| | | if(subPlans.containsKey(itemNumber)) { |
| | | List<ApsPlatePlan> subPlanList = subPlans.get(itemNumber); |
| | | Optional<ApsPlatePlan> firstPlant = subPlanList.stream().filter(x -> x.getUnmatchedQuantity().compareTo(BigDecimal.ZERO) > 0).findFirst(); |
| | | return firstPlant.orElse(null); |
| | | Optional<ApsPlatePlan> planOptional = subPlanList.stream().filter(x -> x.getUnmatchedQuantity().compareTo(BigDecimal.ZERO) > 0).findFirst(); |
| | | return planOptional.orElse(null); |
| | | }else { |
| | | List<ApsPlatePlan> plans = apsPlatePlanMapper.selectUnMatchPlateSubPlanList(plant, itemNumber); |
| | | List<ApsPlatePlan> plans = getSubPlansFromRedis(itemNumber); |
| | | if (!plans.isEmpty()) { |
| | | subPlans.put(itemNumber, plans); |
| | | return selectUnMatchPlateSubPlan(plant, itemNumber, subPlans); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public List<ApsPlatePlan> getSubPlansFromRedis(String itemNumber) { |
| | | List<ApsPlatePlan> subPlans; |
| | | JSONArray jsonArray =(JSONArray) redisTemplate.opsForValue().get("PLATE_SUB_PLAN:" + itemNumber); |
| | | if (jsonArray != null && !jsonArray.isEmpty()) { |
| | | subPlans = jsonArray.stream().map(obj -> JSONObject.parseObject(String.valueOf(obj), ApsPlatePlan.class)).toList(); |
| | | subPlans.forEach(subPlan -> subPlan.setVersion(0)); |
| | | }else { |
| | | subPlans = apsPlatePlanMapper.selectUnMatchPlateSubPlanList("FORTUNA", itemNumber); |
| | | } |
| | | return subPlans; |
| | | } |
| | | } |