chenzx
2024-11-25 68f761dcdef9149f148508e5df8f1c2970934f15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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();
        /// <summary>
        ///获取补贴列表数据
        /// </summary>
        /// <param name="PageNumber"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [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);
            }
        }
        /// <summary>
        ///访问Moonshot
        /// </summary>
        /// <param name="CompanyName"></param>
        /// <returns></returns>
        [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();
            }
        }
        /// <summary>
        ///访问Moonshot
        /// </summary>
        /// <param name="CompanyName"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetPolicyAnswer(string CompanyName)
        {
            try
            {
                var id = OperatorProvider.Instance.Current.UserId;
                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();
            }
        }
     
        
    }
}