| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Hashtable; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.ApsPlateStandardRequire; |
| | | import com.aps.core.domain.ApsPlateStandardRequireError; |
| | | import com.aps.core.domain.ApsStandardProcessRouteHeader; |
| | | import com.aps.core.mapper.ApsPlateStandardRequireErrorMapper; |
| | | import com.aps.core.mapper.ApsStandardProcessRouteHeaderMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsStandardProcessRouteLineMapper; |
| | |
| | | { |
| | | @Autowired |
| | | private ApsStandardProcessRouteLineMapper apsStandardProcessRouteLineMapper; |
| | | |
| | | @Resource |
| | | ApsStandardProcessRouteHeaderMapper standardProcessRouteHeaderMapper; |
| | | @Resource |
| | | ApsPlateStandardRequireErrorMapper requireErrorMapper; |
| | | /** |
| | | * 查询标准工艺路线Line |
| | | * |
| | |
| | | { |
| | | return apsStandardProcessRouteLineMapper.deleteApsStandardProcessRouteLineById(id); |
| | | } |
| | | /** |
| | | * 根据料号 查询工艺路线 及其下的工序,计算工艺路线总工时 |
| | | * @param require 需求信息 |
| | | * @return 工艺路线总工时 |
| | | */ |
| | | @Override |
| | | public ApsStandardProcessRouteLine getRouteLineTotalTime(ApsPlateStandardRequire require) { |
| | | // 定义独占生产模式常量 |
| | | String productivityModel_monopolize = "独占"; |
| | | // 初始化总工时为0 |
| | | BigDecimal totalRouteTime = BigDecimal.ZERO; |
| | | //工厂 |
| | | String plant=require.getOrgCode(); |
| | | // 物料号 |
| | | String itemNumber=require.getBomLineCode(); |
| | | long routId=0L; |
| | | ApsStandardProcessRouteLine ret=ApsStandardProcessRouteLine.builder() |
| | | .routeId(String.valueOf(routId)) |
| | | .routeTime(BigDecimal.ZERO) |
| | | .build(); |
| | | // 查询标准工艺路线头部信息 |
| | | Optional<ApsStandardProcessRouteHeader> firstProcessRoute = standardProcessRouteHeaderMapper.queryStandardProcessRouteHeaderByPlantAndItemCode(plant, itemNumber).stream().findFirst(); |
| | | if (firstProcessRoute.isPresent()) { |
| | | ApsStandardProcessRouteHeader routeHeader = firstProcessRoute.get(); |
| | | // 构建工艺路线行参数对象 |
| | | ApsStandardProcessRouteLine routeLineParam = ApsStandardProcessRouteLine.builder() |
| | | .routeId(routeHeader.getRouteId()) |
| | | .build(); |
| | | // 查询标准工艺路线行信息 |
| | | List<ApsStandardProcessRouteLine> apsStandardProcessRouteLines = apsStandardProcessRouteLineMapper.selectApsStandardProcessRouteLineList(routeLineParam); |
| | | /*工艺路线Line 总工时*/ |
| | | |
| | | if(apsStandardProcessRouteLines.isEmpty()){ |
| | | saveRequireError(require,"工序不存在"); |
| | | }else { |
| | | // 遍历每个工艺路线行 |
| | | apsStandardProcessRouteLines.forEach(line -> { |
| | | // 默认将设计产能设置为路线时间 |
| | | line.setRouteTime(line.getDesignCapacity()); |
| | | // 如果生产模式为独占,则路线时间为设计产能乘以净需求量 |
| | | if (line.getProductivityModel().equals(productivityModel_monopolize)) { |
| | | line.setRouteTime(line.getDesignCapacity().multiply(require.getNetRequirement())); |
| | | } |
| | | // 累加路线时间到总工时中 |
| | | totalRouteTime.add(line.getRouteTime()); |
| | | }); |
| | | } |
| | | ret.setRouteTime(totalRouteTime); |
| | | ret.setRouteId(routeHeader.getRouteId()); |
| | | }else { |
| | | saveRequireError(require,"标准工艺路线不存在"); |
| | | } |
| | | // 返回总工时 |
| | | return ret; |
| | | } |
| | | |
| | | private void saveRequireError(ApsPlateStandardRequire require,String message) { |
| | | ApsPlateStandardRequireError data = ApsPlateStandardRequireError.builder() |
| | | .requireId(require.getId()) |
| | | .batchNumber(require.getBatchNumber()) |
| | | .docNum(require.getDocNum()) |
| | | .itemNum(require.getBomLineCode()) |
| | | .orgCode(require.getOrgCode()) |
| | | .message(message) |
| | | .delFlag("0") |
| | | .build(); |
| | | data.setCreateBy(SecurityUtils.getUsername()); |
| | | data.setCreateTime(DateUtils.getNowDate()); |
| | | requireErrorMapper.insertApsPlateStandardRequireError(data); |
| | | } |
| | | } |