using CommonHelper; using GasolineBlend.BLL; using GasolineBlend.Entity; using SqlSugar; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using System.Web.Razor.Tokenizer.Symbols; namespace GasolineBlend.Controllers { public class SubsidyDataController : BaseController { private SubsidyDataBLL _acc = new SubsidyDataBLL(); /// ///获取补贴列表数据 /// /// /// /// [HttpPost] public ActionResult GetSubsidyDataList(int PageNumber,int PageSize,string Keyword,string CompanyName) { try { var list = _acc.GetSubsidyDataList(PageNumber, PageSize, Keyword, CompanyName); if (list.Data == null) { return Error(); } var response = new { Data = list.Data, TotalCount = list.TotalCount, TotalPages = list.TotalPages }; return SuccessNoShow(data: response); } catch (Exception e) { LogHelper.Write(Level.Error, "获取政策列表数据 GetSubsidyDataList", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } [HttpPost] public ActionResult UploadFile(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { try { // 获取文件名 string fileName = Path.GetFileName(file.FileName); // 设置文件保存路径 string path = Path.Combine(Server.MapPath("~/HaoshuRobot"), fileName); // 保存文件到服务器 file.SaveAs(path); // 返回成功消息 return Json(new { success = true, message = "文件上传成功。", filePath = path }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { // 记录错误信息 // LogHelper.Write(Level.Error, "上传文件时发生错误", ex); return Json(new { success = false, message = "文件上传失败:" + ex.Message }, JsonRequestBehavior.AllowGet); } } else { return Json(new { success = false, message = "请选择一个文件上传。" }, JsonRequestBehavior.AllowGet); } } /// ///访问Moonshot /// /// /// [HttpPost] public ActionResult GetPolicyApplied(string CompanyName) { try { var list = _acc.GetPolicyApplied(CompanyName); if (list == null) { return SuccessNoShow(data: null); } var response = new { Data = list.Data, }; return SuccessNoShow(data: response); } catch (Exception e) { LogHelper.Write(Level.Error, "访问Moonshot GetPolicyApplied", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } /// ///访问Moonshot /// /// /// [HttpPost] public ActionResult GetPolicyAnswer(string CompanyName) { try { //var id = OperatorProvider.Instance.Current.UserId; var id = 1; if (id == 0) { return Error(message: "账户未登录!请登录后查询", data: "-1"); } string list = _acc.GetPolicyAnswer(id, CompanyName); if (list==null) { return Error(); } if (list == "-1") { return Error(message: "今日政策洞察额度已经用完,如有需要请联系管理员!", data: "-1"); } var response = new { Data = list, }; return SuccessNoShow(data: response); } catch (Exception e) { LogHelper.Write(Level.Error, "访问Moonshot GetPolicyAnswer", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } } }