package com.huigou.topsun.sap.nonProdApply.controller;


import com.huigou.context.Operator;
import com.huigou.context.OrgUnit;
import com.huigou.topsun.base.dictionary.GlobalCode;
import com.huigou.topsun.sap.statsIndicators.application.SapStatsIndicatorsApplication;
import com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicators;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.common.BizBillStatus;
import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO;
import org.springframework.stereotype.Controller;

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

@Controller
@ControllerMapping("/sapNonProdApply")
public class NonProdApplyController extends CommonController {

    protected String getPagePath() {
        return "/biz/topsun/sap/nonProdApply/";
    }

    public static String generateApplicationNo() {
        String dateStamp =getCurrentDate("yyyyMMdd");
        // 生成10位随机数
        String randomNumber = String.format("%010d", (int) (Math.random() * 10000000000L));
        // 组合申请单编号
        String applicationNumber = dateStamp + "-" + "M" + "-" + randomNumber;
        return applicationNumber;
    }

    public static String getCurrentDate(String format) {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        String formattedDate = dateFormat.format(date);
        return formattedDate;
    }

    public String forwardNonProdApplyDetail(){
        this.putAttribute("applicationId",generateApplicationNo());
        this.putAttribute("applicationDate",getCurrentDate("yyyy/MM/dd"));
        return forward("nonProdApplyDetail");
    }

}