# M3ForecastNameController.java

    package cloud.wconnect.finance.controller.pl;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.util.I18nMessageUtils;
    import cloud.wconnect.commonlib.util.YearMonthUtils;
    import cloud.wconnect.finance.entity.pl.M3ForecastName;
    import cloud.wconnect.finance.service.pl.IM3ForecastsNameService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;

    import java.util.List;

    /**
     * M3 Forecast 控制层
     *
     * @author lichen
     * @date 2025/9/29
     */
    @RestController
    @RequestMapping("/pl/forecast-name")
    public class M3ForecastNameController {

        @Autowired
        private SessionContext sessionContext;
        @Autowired
        private IM3ForecastsNameService m3ForecastsNameService;
        @Autowired
        private I18nMessageUtils i18nMessageUtils;

        /**
         * 获取M3 Forecast Name集合
         *
         * @param property 资产标识
         * @return java.util.List<cloud.wconnect.finance.entity.pl.M3ForecastName>
         * @author lichen
         * @date 2025/9/29
         */
        @ApiId(1611)
        @GetMapping
        public List<M3ForecastName> list(String property, String yearMonth) {
            int propertyId = sessionContext.getPropertyId(property);
            try {
                //查询年份
                int year = YearMonthUtils.getYearMonth(yearMonth).getYear();
                return m3ForecastsNameService.listByYear(propertyId, year);
            } catch (Exception e) {
                throw new BadRequestException(CommonErrorI18nConstant.FORMAT_INCORRECT,
                        i18nMessageUtils.getErrorParamMapNotNeedTranslate("yearMonth", BaseConstant.DATE_FORMAT_YYYYMM),
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "The yearMonth format error");
            }

        }

    }