package com.ruoyi.web.base.service.impl;

import com.ruoyi.web.base.domain.ProductionPlan;
import com.ruoyi.web.base.mapper.ProductionPlanMapper;
import com.ruoyi.web.base.service.IProductionPlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 生产计划单表 服务实现类
 * </p>
 *
 * @author author
 * @since 2026-03-16
 */
@Service
public class ProductionPlanServiceImpl extends ServiceImpl<ProductionPlanMapper, ProductionPlan> implements IProductionPlanService {

    @Override
    public String generateOrderNum(String orgId, Date orderDate) {
        String dateText = new SimpleDateFormat("yyyyMMdd").format(orderDate);
        Integer maxSeq = baseMapper.selectOrderNumMaxSeq(orgId, dateText);
        int nextSeq = (maxSeq == null ? 0 : maxSeq) + 1;
        return dateText + String.format("%04d", nextSeq);
    }
}
