添加文件和实现接口
This commit is contained in:
parent
683688c4c3
commit
efe611101b
|
@ -38,7 +38,7 @@ namespace Competition.Common.Util
|
|||
/// </summary>
|
||||
public class Tool
|
||||
{
|
||||
private static string appkey = "bridge-fenglin0903";
|
||||
private static string appkey = "";
|
||||
private static int vs = 0;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/7/18 14:01:07 N/A 初版
|
||||
* V0.01 2024/7/18 15:05:57 N/A 初版
|
||||
*
|
||||
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||
*┌──────────────────────────────────┐
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/7/18 14:01:07 N/A 初版
|
||||
* V0.01 2024/7/18 15:05:57 N/A 初版
|
||||
*
|
||||
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||
*┌──────────────────────────────────┐
|
||||
|
@ -53,12 +53,11 @@ namespace Competition.Mysql.DAL
|
|||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("insert into v_business_statistics(");
|
||||
strSql.Append("StatisticsId,TitleName,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3)");
|
||||
strSql.Append("StatisticsId,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3)");
|
||||
strSql.Append(" values (");
|
||||
strSql.Append("@StatisticsId,@TitleName,@StatisticsTime,@StatisticsContent,@CreateTime,@Remark1,@Remark2,@Remark3)");
|
||||
strSql.Append("@StatisticsId,@StatisticsTime,@StatisticsContent,@CreateTime,@Remark1,@Remark2,@Remark3)");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@StatisticsId", SqlDbType.VarChar,50),
|
||||
new SqlParameter("@TitleName", SqlDbType.VarChar,255),
|
||||
new SqlParameter("@StatisticsTime", SqlDbType.DateTime),
|
||||
new SqlParameter("@StatisticsContent", SqlDbType.Text),
|
||||
new SqlParameter("@CreateTime", SqlDbType.DateTime),
|
||||
|
@ -66,13 +65,12 @@ namespace Competition.Mysql.DAL
|
|||
new SqlParameter("@Remark2", SqlDbType.VarChar,255),
|
||||
new SqlParameter("@Remark3", SqlDbType.VarChar,255)};
|
||||
parameters[0].Value = model.StatisticsId;
|
||||
parameters[1].Value = model.TitleName;
|
||||
parameters[2].Value = model.StatisticsTime;
|
||||
parameters[3].Value = model.StatisticsContent;
|
||||
parameters[4].Value = model.CreateTime;
|
||||
parameters[5].Value = model.Remark1;
|
||||
parameters[6].Value = model.Remark2;
|
||||
parameters[7].Value = model.Remark3;
|
||||
parameters[1].Value = model.StatisticsTime;
|
||||
parameters[2].Value = model.StatisticsContent;
|
||||
parameters[3].Value = model.CreateTime;
|
||||
parameters[4].Value = model.Remark1;
|
||||
parameters[5].Value = model.Remark2;
|
||||
parameters[6].Value = model.Remark3;
|
||||
|
||||
int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
|
||||
if (rows > 0)
|
||||
|
@ -91,7 +89,6 @@ namespace Competition.Mysql.DAL
|
|||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("update v_business_statistics set ");
|
||||
strSql.Append("TitleName=@TitleName,");
|
||||
strSql.Append("StatisticsTime=@StatisticsTime,");
|
||||
strSql.Append("StatisticsContent=@StatisticsContent,");
|
||||
strSql.Append("CreateTime=@CreateTime,");
|
||||
|
@ -100,7 +97,6 @@ namespace Competition.Mysql.DAL
|
|||
strSql.Append("Remark3=@Remark3");
|
||||
strSql.Append(" where StatisticsId=@StatisticsId ");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@TitleName", SqlDbType.VarChar,255),
|
||||
new SqlParameter("@StatisticsTime", SqlDbType.DateTime),
|
||||
new SqlParameter("@StatisticsContent", SqlDbType.Text),
|
||||
new SqlParameter("@CreateTime", SqlDbType.DateTime),
|
||||
|
@ -108,14 +104,13 @@ namespace Competition.Mysql.DAL
|
|||
new SqlParameter("@Remark2", SqlDbType.VarChar,255),
|
||||
new SqlParameter("@Remark3", SqlDbType.VarChar,255),
|
||||
new SqlParameter("@StatisticsId", SqlDbType.VarChar,50)};
|
||||
parameters[0].Value = model.TitleName;
|
||||
parameters[1].Value = model.StatisticsTime;
|
||||
parameters[2].Value = model.StatisticsContent;
|
||||
parameters[3].Value = model.CreateTime;
|
||||
parameters[4].Value = model.Remark1;
|
||||
parameters[5].Value = model.Remark2;
|
||||
parameters[6].Value = model.Remark3;
|
||||
parameters[7].Value = model.StatisticsId;
|
||||
parameters[0].Value = model.StatisticsTime;
|
||||
parameters[1].Value = model.StatisticsContent;
|
||||
parameters[2].Value = model.CreateTime;
|
||||
parameters[3].Value = model.Remark1;
|
||||
parameters[4].Value = model.Remark2;
|
||||
parameters[5].Value = model.Remark3;
|
||||
parameters[6].Value = model.StatisticsId;
|
||||
|
||||
int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
|
||||
if (rows > 0)
|
||||
|
@ -178,7 +173,7 @@ namespace Competition.Mysql.DAL
|
|||
{
|
||||
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select top 1 StatisticsId,TitleName,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 from v_business_statistics ");
|
||||
strSql.Append("select top 1 StatisticsId,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 from v_business_statistics ");
|
||||
strSql.Append(" where StatisticsId=@StatisticsId ");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@StatisticsId", SqlDbType.VarChar,50) };
|
||||
|
@ -209,10 +204,6 @@ namespace Competition.Mysql.DAL
|
|||
{
|
||||
model.StatisticsId=row["StatisticsId"].ToString();
|
||||
}
|
||||
if(row["TitleName"]!=null)
|
||||
{
|
||||
model.TitleName=row["TitleName"].ToString();
|
||||
}
|
||||
if(row["StatisticsTime"]!=null && row["StatisticsTime"].ToString()!="")
|
||||
{
|
||||
model.StatisticsTime=DateTime.Parse(row["StatisticsTime"].ToString());
|
||||
|
@ -247,7 +238,7 @@ namespace Competition.Mysql.DAL
|
|||
public DataSet GetList(string strWhere)
|
||||
{
|
||||
StringBuilder strSql=new StringBuilder();
|
||||
strSql.Append("select StatisticsId,TitleName,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 ");
|
||||
strSql.Append("select StatisticsId,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 ");
|
||||
strSql.Append(" FROM v_business_statistics ");
|
||||
if(strWhere.Trim()!="")
|
||||
{
|
||||
|
@ -267,7 +258,7 @@ namespace Competition.Mysql.DAL
|
|||
{
|
||||
strSql.Append(" top "+Top.ToString());
|
||||
}
|
||||
strSql.Append(" StatisticsId,TitleName,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 ");
|
||||
strSql.Append(" StatisticsId,StatisticsTime,StatisticsContent,CreateTime,Remark1,Remark2,Remark3 ");
|
||||
strSql.Append(" FROM v_business_statistics ");
|
||||
if(strWhere.Trim()!="")
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* Ver 变更日期 负责人 变更内容
|
||||
* ───────────────────────────────────
|
||||
* V0.01 2024/7/18 14:01:07 N/A 初版
|
||||
* V0.01 2024/7/18 15:05:57 N/A 初版
|
||||
*
|
||||
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
||||
*┌──────────────────────────────────┐
|
||||
|
@ -27,7 +27,6 @@ namespace Competition.Mysql.Model
|
|||
{}
|
||||
#region Model
|
||||
private string _statisticsid;
|
||||
private string _titlename;
|
||||
private DateTime _statisticstime;
|
||||
private string _statisticscontent;
|
||||
private DateTime _createtime;
|
||||
|
@ -43,14 +42,6 @@ namespace Competition.Mysql.Model
|
|||
get{return _statisticsid;}
|
||||
}
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string TitleName
|
||||
{
|
||||
set{ _titlename=value;}
|
||||
get{return _titlename;}
|
||||
}
|
||||
/// <summary>
|
||||
/// 统计时间
|
||||
/// </summary>
|
||||
public DateTime StatisticsTime
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="wwwroot\Json\**" />
|
||||
<Content Remove="wwwroot\Json\**" />
|
||||
<EmbeddedResource Remove="wwwroot\Json\**" />
|
||||
<None Remove="wwwroot\Json\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Controllers\demo\p3k2d4gz.r22~" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,11 +1,42 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Competition.Common.Util;
|
||||
using CompetitionAPI.api;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CompetitionAPI.Controllers.statistics
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GetBusinessStatisticsController : ControllerBase
|
||||
public class GetBusinessStatisticsController : Controller
|
||||
{
|
||||
Competition.Mysql.BLL.v_business_statistics bll = new Competition.Mysql.BLL.v_business_statistics();
|
||||
|
||||
public GetBusinessStatisticsController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取业务统计接口
|
||||
/// </summary>
|
||||
/// <param name="StatisticsTime">统计时间/param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public JsonResult Index(string StatisticsTime = "")
|
||||
{
|
||||
var model = bll.GetModelList(" StatisticsTime='" + StatisticsTime + "' ").FirstOrDefault();
|
||||
if (model == null)
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, new List<string>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = JsonConvert.DeserializeObject<List<BusinessStatistics>>(model.StatisticsContent);
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, content));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Competition.Common.Util;
|
||||
using CompetitionAPI.api;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace CompetitionAPI.Controllers.statistics
|
||||
{
|
||||
|
@ -7,5 +11,102 @@ namespace CompetitionAPI.Controllers.statistics
|
|||
[ApiController]
|
||||
public class ImportBusinessStatisticsController : Controller
|
||||
{
|
||||
Competition.Mysql.BLL.v_business_statistics bll = new Competition.Mysql.BLL.v_business_statistics();
|
||||
|
||||
public ImportBusinessStatisticsController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入业务统计接口
|
||||
/// </summary>
|
||||
/// <param name="Files">文件/param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public JsonResult Index([FromForm] IFormFile Files)
|
||||
{
|
||||
if (Files.Length <= 0)
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件不能为空"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileExtension = Path.GetExtension(Files.FileName);
|
||||
var table = Tool.ExcelToDataTable(Files.OpenReadStream(), fileExtension, "", 0, true, false);
|
||||
if (null != table && table.Rows.Count > 1)
|
||||
{
|
||||
var year_month = "";
|
||||
var list = new List<BusinessStatistics>();
|
||||
for (int i = 0, len = table.Rows.Count; i < len; i++)
|
||||
{
|
||||
var row = table.Rows[i];
|
||||
var model = new BusinessStatistics();
|
||||
if (!string.IsNullOrEmpty(row[0].ToString()))
|
||||
{
|
||||
model.BusinessLine = row[0].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
model.BusinessLine = table.Rows[i-1][0].ToString();
|
||||
table.Rows[i][0] = model.BusinessLine;
|
||||
}
|
||||
model.BusinessName = row[1].ToString();
|
||||
model.Unit = row[2].ToString();
|
||||
model.Years = row[3].ToString();
|
||||
if (i == 0)
|
||||
{
|
||||
year_month = row[3].ToString();
|
||||
}
|
||||
model.YoY = row[4].ToString();
|
||||
model.YearInterval = row[5].ToString();
|
||||
model.YearsYoY = row[6].ToString();
|
||||
list.Add(model);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(year_month))
|
||||
{
|
||||
var StatisticsTime = DateTime.Parse(year_month);
|
||||
var model = bll.GetModelList(" StatisticsTime='" + StatisticsTime + "' ").FirstOrDefault();
|
||||
if (model == null)
|
||||
{
|
||||
model = new Competition.Mysql.Model.v_business_statistics();
|
||||
model.StatisticsId = Guid.NewGuid().ToString("N");
|
||||
model.StatisticsContent = JsonConvert.SerializeObject(list);
|
||||
model.StatisticsTime = StatisticsTime;
|
||||
model.CreateTime = DateTime.Now;
|
||||
if (bll.Add(model))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, "导入成功"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "导入失败"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.StatisticsContent = JsonConvert.SerializeObject(list);
|
||||
if (bll.Update(model))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, "导入成功"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "导入失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件里数据格式不对"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "文件里没有数据"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
namespace CompetitionAPI.api
|
||||
{
|
||||
public class BusinessStatistics
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务种类
|
||||
/// </summary>
|
||||
public string BusinessLine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务名称
|
||||
/// </summary>
|
||||
public string BusinessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年月
|
||||
/// </summary>
|
||||
public string Years { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同比
|
||||
/// </summary>
|
||||
public string YoY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年月区间
|
||||
/// </summary>
|
||||
public string YearInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同比
|
||||
/// </summary>
|
||||
public string YearsYoY { get; set; }
|
||||
}
|
||||
}
|
|
@ -6,8 +6,9 @@
|
|||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"MySQL": "server=172.16.1.162;uid=sa;pwd=p@ssw0rd;database=SHJGEnt_HNHG;"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
//"MySQL": "server=172.16.1.162;uid=sa;pwd=p@ssw0rd;database=SHJGEnt_HNHG;"
|
||||
"MySQL": "server=172.16.1.253;uid=sa;pwd=Unity3du#d112233;database=SHJGEnt_HNHG;"
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue