| | |
| | | import com.aps.common.core.utils.uuid.IdUtils; |
| | | import com.aps.common.security.utils.SecurityUtils; |
| | | import com.aps.core.domain.*; |
| | | import com.aps.core.domain.ApsPlate.ApsPlateStandardRequireError; |
| | | import com.aps.core.mapper.*; |
| | | import com.aps.core.service.IApsGasMaterialUsageService; |
| | | import com.aps.core.service.IApsGasPipingRouteStatService; |
| | | import com.aps.core.service.IApsStandardProcessService; |
| | | import com.aps.core.mapper.ApsPlateStandardRequireErrorMapper; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.*; |
| | |
| | | |
| | | @Autowired |
| | | private IApsStandardProcessService apsStandardProcessService; |
| | | |
| | | @Autowired |
| | | private ApsPlateStandardRequireErrorMapper apsPlateStandardRequireErrorMapper; |
| | | |
| | | /** |
| | | * 查询气体管路产能负载统计 |
| | |
| | | // 处理手工气体工单数据 - 使用联合查询获取所有相关数据 |
| | | List<Map<String, Object>> moDataList = apsGasPipingRouteStatMapper.selectMoRouteData(); |
| | | |
| | | // 获取所有的MO数据,用于检查哪些MO没有关联到工艺路线 |
| | | List<Map<String, Object>> allMoData = apsGasPipingRouteStatMapper.selectAllMoData(); |
| | | |
| | | // 记录已关联工艺路线的MO编号 |
| | | Set<String> processedMoSet = new HashSet<>(); |
| | | |
| | | // 按工单号分组,便于处理同一工单的不同工序 |
| | | Map<String, List<Map<String, Object>>> moGroups = moDataList.stream() |
| | | .collect(Collectors.groupingBy(data -> data.get("work_order_no").toString())); |
| | |
| | | // 处理每个工单的工艺路线 |
| | | for (String workOrderNo : moGroups.keySet()) { |
| | | List<Map<String, Object>> workOrderData = moGroups.get(workOrderNo); |
| | | |
| | | // 标记该工单已处理 |
| | | processedMoSet.add(workOrderNo); |
| | | |
| | | // 按工序号排序 |
| | | workOrderData.sort((a, b) -> { |
| | |
| | | } |
| | | } |
| | | |
| | | // 处理没有关联到工艺路线的MO数据 |
| | | List<ApsPlateStandardRequireError> errorList = new ArrayList<>(); |
| | | for (Map<String, Object> moData : allMoData) { |
| | | String workOrderNo = moData.get("mo").toString(); |
| | | // 如果该工单没有被处理过,说明没有关联到工艺路线 |
| | | if (!processedMoSet.contains(workOrderNo)) { |
| | | ApsPlateStandardRequireError error = ApsPlateStandardRequireError.builder() |
| | | .id(Long.valueOf(IdUtils.fastSimpleUUID().hashCode())) |
| | | .batchNumber(batchNumber) |
| | | .requireId(IdUtil.getSnowflakeNextId()) |
| | | .docNum(workOrderNo) |
| | | .itemNum(moData.get("material_code").toString()) |
| | | .orgCode(moData.get("factory").toString()) |
| | | .message("标准工艺路线不存在") |
| | | .delFlag("0") |
| | | .build(); |
| | | |
| | | // 设置基类属性 |
| | | error.setCreateBy(SecurityUtils.getUsername()); |
| | | error.setCreateTime(truncateToSeconds(DateUtils.getNowDate())); |
| | | |
| | | errorList.add(error); |
| | | } |
| | | } |
| | | |
| | | // 批量插入异常数据 |
| | | if (!errorList.isEmpty()) { |
| | | apsPlateStandardRequireErrorMapper.batchInsert(errorList); |
| | | } |
| | | |
| | | // 批量插入数据 |
| | | if (!statList.isEmpty()) { |
| | | for (int i = 0; i < statList.size(); i += 500) { |