| | |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.production.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.dto.ProductionReportDailySummaryDto; |
| | | import com.ruoyi.production.dto.ProductionReportStateDto; |
| | | import com.ruoyi.production.enums.ProductProcessEnum; |
| | | import com.ruoyi.production.dto.*; |
| | | import com.ruoyi.production.mapper.ProductionProductReportDailyMapper; |
| | | import com.ruoyi.production.pojo.ProductionProductReportDaily; |
| | | import com.ruoyi.production.mapper.*; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ProductionProductMainDto> listPageProductionProductMainDailyDto(Page<ProductionProductMainDto> page, ProductionProductMainDto productionProductMainDto) { |
| | | if (productionProductMainDto == null) { |
| | | productionProductMainDto = new ProductionProductMainDto(); |
| | | } |
| | | IPage<ProductionProductMainDto> result = productionProductMainMapper.listPageProductionProductMainDailyDto(page, productionProductMainDto); |
| | | fillHourDefaults(result.getRecords()); |
| | | return result; |
| | | public List<ProductionProductMainSummaryExportDto> listSummaryExportData(ProductionProductMainDto productionProductMainDto) { |
| | | return listPageProductionProductMainDto(new Page<>(1, -1), productionProductMainDto) |
| | | .getRecords() |
| | | .stream() |
| | | .map(item -> { |
| | | ProductionProductMainSummaryExportDto exportDto = new ProductionProductMainSummaryExportDto(); |
| | | exportDto.setProcess(item.getProcess()); |
| | | exportDto.setWorkOrderNo(item.getWorkOrderNo()); |
| | | exportDto.setSalesContractNo(item.getSalesContractNo()); |
| | | exportDto.setProductOrderNpsNo(item.getProductOrderNpsNo()); |
| | | exportDto.setProductName(item.getProductName()); |
| | | exportDto.setProductModelName(item.getProductModelName()); |
| | | exportDto.setUnit(item.getUnit()); |
| | | exportDto.setProjectTotalHours(item.getProjectTotalHours()); |
| | | exportDto.setProcessStandardHours(item.getProcessStandardHours()); |
| | | exportDto.setActualReportHours(item.getActualReportHours()); |
| | | exportDto.setDailyPersonHours(item.getDailyPersonHours()); |
| | | exportDto.setOutputTotalQuantity(item.getOutputTotalQuantity()); |
| | | exportDto.setScrapTotalQuantity(item.getScrapTotalQuantity()); |
| | | return exportDto; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductionProductMainDetailExportDto> listDetailExportData(ProductionProductMainDto productionProductMainDto) { |
| | | return listPageProductionProductMainDetailDto(new Page<>(1, -1), productionProductMainDto) |
| | | .getRecords() |
| | | .stream() |
| | | .map(item -> { |
| | | ProductionProductMainDetailExportDto exportDto = new ProductionProductMainDetailExportDto(); |
| | | exportDto.setProductNo(item.getProductNo()); |
| | | exportDto.setNickName(item.getNickName()); |
| | | exportDto.setProcess(item.getProcess()); |
| | | exportDto.setWorkOrderNo(item.getWorkOrderNo()); |
| | | exportDto.setSalesContractNo(item.getSalesContractNo()); |
| | | exportDto.setProductOrderNpsNo(item.getProductOrderNpsNo()); |
| | | exportDto.setProductName(item.getProductName()); |
| | | exportDto.setProductModelName(item.getProductModelName()); |
| | | exportDto.setQuantity(item.getQuantity()); |
| | | exportDto.setScrapQty(item.getScrapQty()); |
| | | exportDto.setUnit(item.getUnit()); |
| | | exportDto.setProcessStandardHours(item.getProcessStandardHours()); |
| | | exportDto.setActualReportHours(item.getActualReportHours()); |
| | | exportDto.setDailyPersonHours(item.getDailyPersonHours()); |
| | | exportDto.setCreateTime(item.getCreateTime()); |
| | | return exportDto; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private void fillHourDefaults(List<ProductionProductMainDto> records) { |
| | |
| | | |
| | | @Override |
| | | public ProductionReportStateDto reportState(Long workOrderId, Long productProcessRouteItemId) { |
| | | ProductionProductMain running = getRunning(workOrderId, productProcessRouteItemId); |
| | | ProductionReportStateDto dto = new ProductionReportStateDto(); |
| | | ProductWorkOrder workOrder = productWorkOrderMapper.selectById(workOrderId); |
| | | if (workOrder != null) { |
| | | BigDecimal planQty = workOrder.getPlanQuantity() == null ? BigDecimal.ZERO : workOrder.getPlanQuantity(); |
| | | BigDecimal completeQty = workOrder.getCompleteQuantity() == null ? BigDecimal.ZERO : workOrder.getCompleteQuantity(); |
| | | // 生产报工数量已完成 |
| | | if (planQty.compareTo(BigDecimal.ZERO) > 0 && completeQty.compareTo(planQty) >= 0) { |
| | | dto.setState(3); |
| | | return dto; |
| | | } |
| | | } |
| | | |
| | | ProductionProductMain running = getRunning(workOrderId, productProcessRouteItemId); |
| | | if (running == null) { |
| | | dto.setState(1); |
| | | return dto; |
| | |
| | | LocalDateTime endTime = LocalDateTime.now(); |
| | | long durationSeconds = Duration.between(productionProductMain.getReportStartTime(), endTime).getSeconds(); |
| | | BigDecimal durationMinutes = secondsToMinutesExact(durationSeconds); |
| | | |
| | | int finishRows = productionProductMainMapper.update( |
| | | null, |
| | | Wrappers.<ProductionProductMain>lambdaUpdate() |
| | |
| | | } |
| | | |
| | | // 无工艺路线场景:报工即计入生产订单完成数量 |
| | | // int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty); |
| | | // if (poRows <= 0) { |
| | | // ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId()); |
| | | // throw new ServiceException("本次生产数量不能大于订单剩余数量,剩余数量: " |
| | | // + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity()))); |
| | | // } |
| | | List<ProductProcessRouteItemDto> productProcessRouteItemDtos = productProcessRouteItemMapper.listItem(productOrder.getId()); |
| | | ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId()); |
| | | if (productProcessRouteItemDtos.get(productProcessRouteItemDtos.size() - 1).getId().equals(dto.getProductProcessRouteItemId())) { |
| | | int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty); |
| | | if (poRows <= 0) { |
| | | ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId()); |
| | | throw new ServiceException("本次生产数量不能大于订单剩余数量,剩余数量: " |
| | | + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity()))); |
| | | } |
| | | ProductOrder latestOrder = productOrderMapper.selectById(productOrder.getId()); |
| | | } |
| | | if (needQuality |
| | | && latestOrder != null |
| | | && latestOrder.getCompleteQuantity() != null |
| | | && latestOrder.getQuantity() != null |
| | | && latestOrder.getCompleteQuantity().compareTo(latestOrder.getQuantity()) >= 0) { |
| | | && currentOrder != null |
| | | && currentOrder.getCompleteQuantity() != null |
| | | && currentOrder.getQuantity() != null |
| | | && currentOrder.getCompleteQuantity().compareTo(currentOrder.getQuantity()) >= 0) { |
| | | // 订单完成时新增出厂检 |
| | | createQualityInspect(productionProductMain.getId(), outputProductModelId, productQty, 2, null); |
| | | } |
| | |
| | | if (process == null || process.getType() == null) { |
| | | return "其他"; |
| | | } |
| | | for (ProductProcessEnum value : ProductProcessEnum.values()) { |
| | | if (value.getCode().equals(process.getType())) { |
| | | return value.getInfo(); |
| | | } |
| | | } |
| | | return "其他"; |
| | | String dictLabel = DictUtils.getDictLabel("product_process_type", String.valueOf(process.getType())); |
| | | return (dictLabel == null || dictLabel.isEmpty()) ? "其他" : dictLabel; |
| | | } |
| | | |
| | | private void saveDailyDurations(ProductionProductMain main, LocalDateTime start, LocalDateTime end) { |