412 lines
17 KiB
C#
412 lines
17 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading;
|
||
using System.Web.Http;
|
||
using System.Web.Http.Description;
|
||
using ESCG = CommercialApi.GeneralMethod;
|
||
using ESCM = CommercialApi.Model;
|
||
using Newtonsoft.Json;
|
||
using HZQR.Common;
|
||
|
||
namespace CommercialApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 分析说明表相关接口
|
||
/// 2023/3/30 23:37:32自动生成
|
||
/// </summary>
|
||
public class AnalysisController : BaseController
|
||
{
|
||
#region 获取分析说明表列表
|
||
/// <summary>
|
||
/// 获取分析说明表列表
|
||
/// </summary>
|
||
/// <param name="searchModel">查询条件对象</param>
|
||
/// <returns></returns>
|
||
[Route("Analysis/GetANALYSISINSList")]
|
||
[AcceptVerbs("POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.ANALYSISINSModel>>))]
|
||
public IHttpActionResult GetANALYSISINSList(ESCM.SearchModel<ESCM.ANALYSISINSModel> searchModel)
|
||
{
|
||
string Parameter = "入参信息:" + JsonConvert.SerializeObject(searchModel);
|
||
try
|
||
{
|
||
int TotalCount = 0;
|
||
//获取分析说明表列表
|
||
List<ESCM.ANALYSISINSModel> ANALYSISINSList = ESCG.ANALYSISINSHelper.GetANALYSISINSList(
|
||
transaction, ref TotalCount, searchModel);
|
||
|
||
//转化json形式
|
||
Models.JsonList<ESCM.ANALYSISINSModel> jsonList = Models.JsonList<ESCM.ANALYSISINSModel>.Success(
|
||
ANALYSISINSList, TotalCount, searchModel.PageIndex, searchModel.PageSize);
|
||
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.ANALYSISINSModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetANALYSISINSList");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 获取分析说明表明细
|
||
/// <summary>
|
||
/// 获取分析说明表明细
|
||
/// </summary>
|
||
/// <param name="ANALYSISINSId">分析说明表内码</param>
|
||
/// <returns></returns>
|
||
[Route("Analysis/GetANALYSISINSDetail")]
|
||
[AcceptVerbs("GET")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.ANALYSISINSModel>))]
|
||
public IHttpActionResult GetANALYSISINSDetail(int ANALYSISINSId)
|
||
{
|
||
string Parameter = "入参信息:分析说明表内码【" + ANALYSISINSId + "】";
|
||
try
|
||
{
|
||
//获取分析说明表明细
|
||
ESCM.ANALYSISINSModel analysisinsModel = ESCG.ANALYSISINSHelper.GetANALYSISINSDetail(transaction, ANALYSISINSId);
|
||
|
||
return Ok(Models.JsonMsg<ESCM.ANALYSISINSModel>.Success(analysisinsModel, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetANALYSISINSDetail");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 同步分析说明表
|
||
/// <summary>
|
||
/// 同步分析说明表
|
||
/// </summary>
|
||
/// <param name="analysisinsModel"></param>
|
||
/// <returns></returns>
|
||
[Route("Analysis/SynchroANALYSISINS")]
|
||
[AcceptVerbs("POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.ANALYSISINSModel>))]
|
||
public IHttpActionResult SynchroANALYSISINS(ESCM.ANALYSISINSModel analysisinsModel)
|
||
{
|
||
try
|
||
{
|
||
//新增分析说明表
|
||
bool SynchroFlag = ESCG.ANALYSISINSHelper.SynchroANALYSISINS(transaction, analysisinsModel);
|
||
|
||
if (SynchroFlag)
|
||
{
|
||
return Ok(ESCG.Common.ReturnJson(100, "同步成功", analysisinsModel));
|
||
}
|
||
else
|
||
{
|
||
return Ok(ESCG.Common.ReturnJson(200, "更新失败,数据不存在!"));
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_SynchroANALYSISINS");
|
||
return Ok(ESCG.Common.ReturnJson(999, "同步失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删除分析说明表
|
||
///// <summary>
|
||
///// 删除分析说明表
|
||
///// </summary>
|
||
///// <param name="ANALYSISINSId">分析说明表内码</param>
|
||
///// <returns></returns>
|
||
//[Route("Analysis/DeleteANALYSISINS")]
|
||
//[AcceptVerbs("GET", "POST")]
|
||
//[ResponseType(typeof(Models.JsonMsg<string>))]
|
||
//public IHttpActionResult DeleteANALYSISINS(int ANALYSISINSId)
|
||
//{
|
||
// string Parameter = "入参信息:分析说明表内码【" + ANALYSISINSId + "】";
|
||
// try
|
||
// {
|
||
// //删除分析说明表
|
||
// bool DeleteFlag = ESCG.ANALYSISINSHelper.DeleteANALYSISINS(transaction, ANALYSISINSId);
|
||
|
||
// if (DeleteFlag)
|
||
// {
|
||
// return Ok(ESCG.Common.ReturnJson(100, "删除成功"));
|
||
// }
|
||
// else
|
||
// {
|
||
// return Ok(ESCG.Common.ReturnJson(200, "删除失败,数据不存在!"));
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// //事务回滚
|
||
// transaction.Rollback();
|
||
// LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
// DateTime.Now.ToString("yyyyMMdd") + "_DeleteANALYSISINS");
|
||
// return Ok(ESCG.Common.ReturnJson(999, "删除失败" + ex.Message));
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
#region 测试接口
|
||
/// <summary>
|
||
/// 测试接口
|
||
/// </summary>
|
||
/// <param name="OverTime">延迟时间,默认10s</param>
|
||
/// <returns></returns>
|
||
//[Route("Analysis/OverTimeTest")]
|
||
//[AcceptVerbs("POST")]
|
||
//[ResponseType(typeof(string))]
|
||
//public IHttpActionResult OverTimeTest(int OverTime = 10)
|
||
//{
|
||
// try
|
||
// {
|
||
// //延迟10s返回结果
|
||
// Thread.Sleep(OverTime * 1000);
|
||
|
||
// return Ok(ESCG.Common.ReturnJson(100, "测试成功"));
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// //事务回滚
|
||
// transaction.Rollback();
|
||
// LogUtil.WriteLog(null, "测试失败!失败原因:" + ex.Message,
|
||
// DateTime.Now.ToString("yyyyMMdd") + "_OverTimeTest");
|
||
// return Ok(ESCG.Common.ReturnJson(999, "测试失败" + ex.Message));
|
||
// }
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 获取门店营收数据
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 返参:<br/>
|
||
/// name:门店名称<br/>
|
||
/// value:营收<br/>
|
||
/// data:日期<br/>
|
||
/// key:服务区名称
|
||
/// </remarks>
|
||
/// <param name="ShopName">门店名称</param>
|
||
/// <param name="StartDate">开始日期</param>
|
||
/// <param name="EndDate">结束日期</param>
|
||
[Route("Analysis/GetShopRevenue")]
|
||
[AcceptVerbs("GET", "POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>))]
|
||
public IHttpActionResult GetShopRevenue(string ShopName, string StartDate, string EndDate)
|
||
{
|
||
try
|
||
{
|
||
List<ESCM.CommonKeyModel> AnalysisList = ESCG.ANALYSISINSHelper.GetShopRevenue(
|
||
transaction, ShopName, StartDate, EndDate);
|
||
|
||
Models.JsonList<ESCM.CommonKeyModel> jsonList = Models.JsonList<ESCM.CommonKeyModel>.Success(AnalysisList);
|
||
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetShopRevenue");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取门店商家信息
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 返参:<br/>
|
||
/// name:门店名称<br/>
|
||
/// value:商家名称<br/>
|
||
/// key:服务区名称
|
||
/// </remarks>
|
||
/// <param name="ShopName">门店名称</param>
|
||
[Route("Analysis/GetShopMerchant")]
|
||
[AcceptVerbs("GET", "POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>))]
|
||
public IHttpActionResult GetShopMerchant(string ShopName)
|
||
{
|
||
try
|
||
{
|
||
List<ESCM.CommonKeyModel> AnalysisList = ESCG.ANALYSISINSHelper.GetShopMerchant(transaction, ShopName);
|
||
|
||
Models.JsonList<ESCM.CommonKeyModel> jsonList = Models.JsonList<ESCM.CommonKeyModel>.Success(AnalysisList);
|
||
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetShopMerchant");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 生成时段客单交易分析数据
|
||
/// <summary>
|
||
/// 生成时段客单交易分析数据
|
||
/// </summary>
|
||
/// <param name="analysisParamModel"></param>
|
||
[Route("Analysis/SolidTransactionAnalysis")]
|
||
[AcceptVerbs("POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<string>))]
|
||
public IHttpActionResult SolidTransactionAnalysis(ESCM.AnalysisParamModel analysisParamModel)
|
||
{
|
||
string Parameter = "入参信息:" + JsonConvert.SerializeObject(analysisParamModel);
|
||
|
||
try
|
||
{
|
||
if (analysisParamModel.AmountRangeList == null || analysisParamModel.AmountRangeList.Length == 0)
|
||
{
|
||
return Ok(ESCG.Common.ReturnJson(200, "生成失败!请传入正确的参数"));
|
||
}
|
||
|
||
ESCG.TransactionHelper.SolidTransactionAnalysis(transaction, analysisParamModel.StatisticsMonth,
|
||
analysisParamModel.ServerpartShopId, analysisParamModel.AmountRangeList);
|
||
|
||
return Ok(ESCG.Common.ReturnJson(100, "生成成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "生成失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_SolidTransactionAnalysis");
|
||
return Ok(ESCG.Common.ReturnJson(999, "生成失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取时段客单交易分析数据
|
||
/// <summary>
|
||
/// 获取时段客单交易分析数据
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// </remarks>
|
||
/// <param name="tapModel"></param>
|
||
/// <remarks>
|
||
/// 涉及到的数据表:<br/>
|
||
/// 月度时段交易分析表【PLATFORM_DASHBOARD.T_TRANSACTIONANALYSIS】
|
||
/// </remarks>
|
||
/// <example>
|
||
/// <!--
|
||
/// 入参样例:
|
||
/// {
|
||
/// "ServerpartId": "416",
|
||
/// "ServerpartShopId": "",
|
||
/// "StartMonth": "202408",
|
||
/// "EndMonth": "202408"
|
||
/// }
|
||
/// 返回结果样例:
|
||
/// -->
|
||
/// </example>
|
||
/// <returns>
|
||
/// 返参:<br/>
|
||
/// name:<br/>
|
||
/// value:<br/>
|
||
/// key:
|
||
/// </returns>
|
||
[Route("Analysis/GetTransactionAnalysis")]
|
||
[AcceptVerbs("POST")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>))]
|
||
public IHttpActionResult GetTransactionAnalysis(ESCM.TAPModel tapModel)
|
||
{
|
||
try
|
||
{
|
||
List<ESCM.CommonKeyModel> AnalysisList = ESCG.TransactionHelper.GetTransactionAnalysis(transaction, tapModel);
|
||
|
||
Models.JsonList<ESCM.CommonKeyModel> jsonList = Models.JsonList<ESCM.CommonKeyModel>.Success(AnalysisList);
|
||
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CommonKeyModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
string Parameter = "入参信息:服务区内码【" + tapModel.ServerpartId + "】,门店内码【" + tapModel.ServerpartShopId + "】," +
|
||
"开始月份【" + tapModel.StartMonth + "】,结束月份【" + tapModel.EndMonth + "】";
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetTransactionAnalysis");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 解析语义内容中的关键字信息
|
||
/// <summary>
|
||
/// 解析语义内容中的关键字信息
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// </remarks>
|
||
/// <param name="Sentence">语义内容</param>
|
||
/// <param name="DialogCode">对话框编码</param>
|
||
/// <param name="ProvinceCode">省份编码</param>
|
||
/// <returns></returns>
|
||
[Route("Analysis/TranslateSentence")]
|
||
[AcceptVerbs("GET")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.RecognizerModel>))]
|
||
public IHttpActionResult TranslateSentence(string Sentence, string DialogCode = "", string ProvinceCode = "340000")
|
||
{
|
||
try
|
||
{
|
||
ESCM.RecognizerModel recognizerModel = ESCG.RecognizeHelper.TranslateSentence(
|
||
transaction, Sentence, DialogCode, ProvinceCode);
|
||
|
||
return Ok(Models.JsonMsg<ESCM.RecognizerModel>.Success(recognizerModel, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
string Parameter = "入参信息:语义内容【" + Sentence + "】";
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_TranslateSentence");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取地图参数配置
|
||
/// <summary>
|
||
/// 获取地图参数配置
|
||
/// </summary>
|
||
/// <param name="ProvinceCode">省份编码</param>
|
||
/// <returns></returns>
|
||
[Route("Analysis/GetMapConfigByProvinceCode")]
|
||
[AcceptVerbs("GET")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.MapModel>))]
|
||
public IHttpActionResult GetMapConfigByProvinceCode(string ProvinceCode)
|
||
{
|
||
try
|
||
{
|
||
ESCM.MapModel mapModel = ESCG.RecognizeHelper.GetMapConfigByProvinceCode(
|
||
transaction, ProvinceCode);
|
||
|
||
return Ok(Models.JsonMsg<ESCM.MapModel>.Success(mapModel, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//事务回滚
|
||
transaction.Rollback();
|
||
string Parameter = "入参信息:省份编码【" + ProvinceCode + "】";
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetMapConfigByProvinceCode");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|