| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.ApsPlate.ApsPlateStandardRequire; |
| | | import com.aps.core.domain.ApsPlate.ApsPlateStandardRequireError; |
| | | import com.aps.core.domain.ApsStandardProcessRouteHeader; |
| | | import com.aps.core.mapper.ApsPlateStandardRequireErrorMapper; |
| | | import com.aps.core.mapper.ApsStandardProcessRouteHeaderMapper; |
| | | import com.aps.core.service.ApsPlate.IApsPlateStandardRequireErrorService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsStandardProcessRouteLineMapper; |
| | | import com.aps.core.domain.ApsStandardProcessRouteLine; |
| | |
| | | { |
| | | @Autowired |
| | | private ApsStandardProcessRouteLineMapper apsStandardProcessRouteLineMapper; |
| | | @Resource |
| | | ApsStandardProcessRouteHeaderMapper standardProcessRouteHeaderMapper; |
| | | @Resource |
| | | IApsPlateStandardRequireErrorService requireErrorService; |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * 查询标准工艺路线Line |
| | |
| | | { |
| | | return apsStandardProcessRouteLineMapper.deleteApsStandardProcessRouteLineById(id); |
| | | } |
| | | /** |
| | | * 根据料号 查询工艺路线 及其下的工序,计算工艺路线总工时 |
| | | * @param require 需求信息 |
| | | * @return 工艺路线总工时 |
| | | */ |
| | | @Override |
| | | public ApsStandardProcessRouteLine getRouteLineTotalTime(ApsPlateStandardRequire require) { |
| | | // 初始化总工时为0 |
| | | BigDecimal totalRouteTime = BigDecimal.ZERO; |
| | | //工厂 |
| | | String plant=require.getOrgCode(); |
| | | // 物料号 |
| | | String itemNumber=require.getBomLineCode(); |
| | | long routId=0L; |
| | | ApsStandardProcessRouteLine ret=new ApsStandardProcessRouteLine(); |
| | | ret.setRouteId(String.valueOf(routId)); |
| | | ret.setRouteTime(BigDecimal.ZERO); |
| | | // 查询标准工艺路线头部信息 |
| | | Optional<ApsStandardProcessRouteHeader> firstProcessRoute = standardProcessRouteHeaderMapper.queryStandardProcessRouteHeaderByPlantAndItemCode(plant, itemNumber).stream().findFirst(); |
| | | if (firstProcessRoute.isPresent()) { |
| | | ApsStandardProcessRouteHeader routeHeader = firstProcessRoute.get(); |
| | | // 构建工艺路线行参数对象 |
| | | ApsStandardProcessRouteLine routeLineParam =new ApsStandardProcessRouteLine(); |
| | | routeLineParam.setRouteId(routeHeader.getRouteId()); |
| | | // 查询标准工艺路线行信息 |
| | | BigDecimal standardTime = apsStandardProcessRouteLineMapper.selectTotalStandTime(routeHeader.getRouteId()).getStandardTime(); |
| | | totalRouteTime =standardTime.multiply(require.getNetRequirement()); |
| | | ret.setRouteTime(totalRouteTime); |
| | | ret.setRouteId(routeHeader.getRouteId()); |
| | | }else { |
| | | requireErrorService.saveRequireError(require,"标准工艺路线不存在"); |
| | | } |
| | | // 返回总工时 |
| | | return ret; |
| | | } |
| | | @Override |
| | | public ApsStandardProcessRouteLine getRouteHeaderRouteTime(ApsPlateStandardRequire require){ |
| | | |
| | | //工厂 |
| | | String plant=require.getOrgCode(); |
| | | // 物料号 |
| | | String itemCode=require.getBomLineCode(); |
| | | // 净需求 |
| | | BigDecimal netRequirement= require.getNetRequirement(); |
| | | //构建Redis Key |
| | | String key = "ROUTE:ROUTE_"+plant+"_"+itemCode; |
| | | |
| | | BigDecimal totalRouteTime = BigDecimal.ZERO; |
| | | ApsStandardProcessRouteLine ret=new ApsStandardProcessRouteLine(); |
| | | ret.setRouteId("0"); |
| | | ret.setRouteTime(totalRouteTime); |
| | | |
| | | Object routeHeaderObj = redisTemplate.opsForValue().get(key); |
| | | if (routeHeaderObj != null) { |
| | | totalRouteTime = (BigDecimal) routeHeaderObj; |
| | | ret.setRouteId("0"); |
| | | ret.setRouteTime(totalRouteTime.multiply(netRequirement)); |
| | | return ret; |
| | | } else { |
| | | requireErrorService.saveRequireError(require,"标准工艺路线不存在"); |
| | | /*// 查询标准工艺路线头部信息 |
| | | Optional<ApsStandardProcessRouteHeader> firstProcessRoute = standardProcessRouteHeaderMapper.queryStandardProcessRouteHeaderByPlantAndItemCode(plant, itemCode).stream().findFirst(); |
| | | if (firstProcessRoute.isPresent()) { |
| | | ApsStandardProcessRouteHeader routeHeader = firstProcessRoute.get(); |
| | | // 构建工艺路线行参数对象 |
| | | ApsStandardProcessRouteLine routeLineParam =new ApsStandardProcessRouteLine(); |
| | | routeLineParam.setRouteId(routeHeader.getRouteId()); |
| | | // 查询标准工艺路线行信息 |
| | | BigDecimal standardTime = apsStandardProcessRouteLineMapper.selectTotalStandTime(routeHeader.getRouteId()).getStandardTime(); |
| | | totalRouteTime =standardTime.multiply(netRequirement); |
| | | // 计算返回的数据 |
| | | ret.setRouteTime(totalRouteTime); |
| | | ret.setRouteId(routeHeader.getRouteId()); |
| | | *//*存储至Redis*//* |
| | | redisTemplate.opsForValue().set(key, standardTime); |
| | | }else { |
| | | saveRequireError(require,"标准工艺路线不存在"); |
| | | }*/ |
| | | return ret; |
| | | } |
| | | } |
| | | |
| | | } |