package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule;

import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.Map;

/**
 * @Description :
 * @Reference :
 * @Author : Castle
 * @CreateDate : 2024/7/6 14:09
 * @Modify:
 **/
@Component
public class NoSortBarcodeGzNumberRuleStrategyService implements INumberRulePackAttributeStrategyService {
    @Override
    public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) {
        Date date = new Date();
        //年月日缩写
        genSerialNoModel.setYear(getYearShort(date));
        genSerialNoModel.setMonth(getMonthShort(date));
        genSerialNoModel.setDay(getDayShort(date));
        return genSerialNoModel;
    }

    private String getYearShort(Date date) {
        return MesExtEnumUtil.YEAR_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getYear(date)));
    }

    private String getMonthShort(Date date) {

        return MesExtEnumUtil.MONTH_SHORT.valueOfDescription(Integer.parseInt(TimeTool.getMonth(date)));
    }

    private String getDayShort(Date date) {
        return TimeTool.getDay(date);
    }
}
