Commit de39ea68 by Neo Turing

优化

parent 33bc7b8d
......@@ -57,7 +57,13 @@ namespace Kivii.Third.Scjgj
}
return rtns;
}
internal static PlanDetail ConvertTo(this PlanDetail item, IDbConnection conn = null)
/// <summary>
/// 此方法是将原始的PlanDetail数据从其他子表中将数据丰富完善
/// </summary>
/// <param name="item"></param>
/// <param name="conn"></param>
/// <returns></returns>
internal static PlanDetail DataFilling(this PlanDetail item, IDbConnection conn = null)
{
PlanDetail rtns = new PlanDetail();
bool connDispose = false;
......@@ -282,16 +288,16 @@ namespace Kivii.Third.Scjgj
switch (item.CHECK_TYPE)
{
case "1":
rtns = item.ConvertToNormal(conn);
rtns = item.DataFillingNormal(conn);
break;
case "2":
rtns = item.ConvertToMarket(conn);
rtns = item.DataFillingMarket(conn);
break;
case "3":
rtns = item.ConvertToCommerce(conn);
rtns = item.DataFillingCommerce(conn);
break;
case "4":
rtns = item.ConvertToOther(conn);
rtns = item.DataFillingOther(conn);
break;
default:
break;
......@@ -306,8 +312,13 @@ namespace Kivii.Third.Scjgj
/// <param name="item"></param>
/// <param name="conn"></param>
/// <returns></returns>
internal static PlanDetail ConvertToNormal(this PlanDetail item, IDbConnection conn)
internal static PlanDetail DataFillingNormal(this PlanDetail item, IDbConnection conn)
{
var rtns = new PlanDetail();
item.Cary = new Cary();
item.ProduceUnit = new ProduceUnit();
item.ExecUint = new ExecUint();
item.Other= new Other();
if (item.CARY_ID != null)
{
item.Cary = GetCaryById(conn, item.CARY_ID);
......@@ -322,7 +333,8 @@ namespace Kivii.Third.Scjgj
{
item.ExecUint = GetExecUintById(conn, item.EXEC_ID);
}
return item;
rtns.PopulateWith(item);
return rtns;
}
/// <summary>
/// 市场买样
......@@ -330,8 +342,13 @@ namespace Kivii.Third.Scjgj
/// <param name="item"></param>
/// <param name="conn"></param>
/// <returns></returns>
internal static PlanDetail ConvertToMarket(this PlanDetail item, IDbConnection conn)
internal static PlanDetail DataFillingMarket(this PlanDetail item, IDbConnection conn)
{
var rtns = new PlanDetail();
item.Cary = new Cary();
item.ProduceUnit = new ProduceUnit();
item.ExecUint = new ExecUint();
item.Other= new Other();
if (item.CARY_ID != null)
{
item.Cary = GetCaryById(conn, item.CARY_ID);
......@@ -346,7 +363,8 @@ namespace Kivii.Third.Scjgj
{
item.ProduceUnit = GetProduceUnitById(conn, item.PRO_ID);
}
return item;
rtns.PopulateWith(item);
return rtns;
}
/// <summary>
/// 电商买样
......@@ -354,8 +372,13 @@ namespace Kivii.Third.Scjgj
/// <param name="item"></param>
/// <param name="conn"></param>
/// <returns></returns>
internal static PlanDetail ConvertToCommerce(this PlanDetail item, IDbConnection conn)
internal static PlanDetail DataFillingCommerce(this PlanDetail item, IDbConnection conn)
{
var rtns = new PlanDetail();
item.Cary = new Cary();
item.ProduceUnit = new ProduceUnit();
item.ExecUint = new ExecUint();
item.Other= new Other();
if (item.CARY_ID != null)
{
item.Cary = GetCaryById(conn, item.CARY_ID);
......@@ -375,8 +398,8 @@ namespace Kivii.Third.Scjgj
{
item.ProduceUnit = GetProduceUnitById(conn, item.PRO_ID);
}
return item;
rtns.PopulateWith(item);
return rtns;
}
/// <summary>
/// 其他抽样
......@@ -384,8 +407,13 @@ namespace Kivii.Third.Scjgj
/// <param name="item"></param>
/// <param name="conn"></param>
/// <returns></returns>
internal static PlanDetail ConvertToOther(this PlanDetail item, IDbConnection conn)
internal static PlanDetail DataFillingOther(this PlanDetail item, IDbConnection conn)
{
var rtns = new PlanDetail();
item.Cary = new Cary();
item.ProduceUnit = new ProduceUnit();
item.ExecUint = new ExecUint();
item.Other= new Other();
if (item.CARY_ID != null)
{
item.Cary = GetCaryById(conn, item.CARY_ID);
......@@ -405,8 +433,8 @@ namespace Kivii.Third.Scjgj
{
item.ProduceUnit = GetProduceUnitById(conn, item.PRO_ID);
}
return item;
rtns.PopulateWith(item);
return rtns;
}
/// <summary>
......@@ -417,9 +445,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static Plan GetPlan(IDbConnection conn, string plancode)
{
var rtns = new Plan();
if (plancode == null) return rtns;
var query = conn.From<Plan>();
query.Where(o => o.PLAN_CODE == plancode);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new Plan();
return rtns;
}
/// <summary>
/// 受检单位信息
......@@ -429,11 +462,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static Cary GetCaryById(IDbConnection conn, int? caryId)
{
if (caryId == null) return null;
var rtns = new Cary();
if (caryId == null) return rtns;
var query = conn.From<Cary>();
query.Where(o => o.ID == caryId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new Cary();
return rtns;
}
/// <summary>
/// 生产单位信息
......@@ -443,11 +479,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static ProduceUnit GetProduceUnitById(IDbConnection conn, int? proId)
{
if (proId == null) return null;
var rtns = new ProduceUnit();
if (proId == null) return rtns;
var query = conn.From<ProduceUnit>();
query.Where(o => o.ID == proId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new ProduceUnit();
return rtns;
}
/// <summary>
/// 抽样机构信息
......@@ -457,11 +496,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static ExecUint GetExecUintById(IDbConnection conn, int? execId)
{
if (execId == null) return null;
var rtns = new ExecUint();
if (execId == null) return rtns;
var query = conn.From<ExecUint>();
query.Where(o => o.ID == execId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new ExecUint();
return rtns;
}
/// <summary>
/// 电商单位信息
......@@ -471,11 +513,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static EcPlatform GetEcPlatformById(IDbConnection conn, int? ecId)
{
if (ecId == null) return null;
var rtns = new EcPlatform();
if (ecId == null) return rtns;
var query = conn.From<EcPlatform>();
query.Where(o => o.EC_ID == ecId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new EcPlatform();
return rtns;
}
/// <summary>
/// 其他来源单位信息
......@@ -485,11 +530,14 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static Other GetOtherById(IDbConnection conn, int? otherId)
{
if (otherId == null) return null;
var rtns = new Other();
if (otherId == null) return rtns;
var query = conn.From<Other>();
query.Where(o => o.ID == otherId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new Other();
return rtns;
}
/// <summary>
/// 直播平台信息
......@@ -499,23 +547,31 @@ namespace Kivii.Third.Scjgj
/// <returns></returns>
internal static Live GetLiveById(IDbConnection conn, int? liveId)
{
if (liveId == null) return null;
var rtns = new Live();
if (liveId == null) return rtns;
var query = conn.From<Live>();
query.Where(o => o.LIVE_ID == liveId);
return conn.Single(query);
rtns = conn.Single(query);
if (rtns == null) rtns = new Live();
return rtns;
}
/// <summary>
/// 任务来源对照表
/// </summary>
/// <param name="conn"></param>
/// <param name="TaskSource"></param>
/// <param name="taskSource"></param>
/// <returns></returns>
internal static TaskSource GetTaskSource(IDbConnection conn, string TaskSource)
internal static TaskSource GetTaskSource(IDbConnection conn, string taskSource)
{
var rtns = new TaskSource();
if (taskSource == null) return rtns;
var query = conn.From<TaskSource>();
query.Where(o => o.TASK_SOURCE == TaskSource);
return conn.Single(query);
query.Where(o => o.TASK_SOURCE == taskSource);
rtns = conn.Single(query);
if (rtns == null) rtns = new TaskSource();
return rtns;
}
/// <summary>
......
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("5.4.2024.6270")]
[assembly: AssemblyFileVersion("5.4.2024.6270")]
......@@ -97,7 +97,9 @@ namespace Kivii.Third.Scjgj
if (Take.HasValue && Take.Value > 0) query.Take(Take.Value);
if (!OrderBy.IsNullOrEmpty()) query.OrderBy(OrderBy);
var results = conn.Select(query);
var total = conn.Scalar<PlanDetail, int>(o => Sql.Count(o.ID));
int total = 0;
if (!QueryValues.IsNullOrEmpty()) total = conn.Scalar<PlanDetail, int>(o => Sql.Count(o.ID), o => o.PLAN_CODE.Contains(QueryValues));
else total = conn.Scalar<PlanDetail, int>(o => Sql.Count(o.ID));
rtns.Results = results;
rtns.Total = total;
}
......@@ -131,12 +133,12 @@ namespace Kivii.Third.Scjgj
public string PlanNumber { get; set; }//计划批次号LOT_NUM
public bool ToReport { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
BatchNumber.ThrowIfNullOrEmpty("请传入计划编号");
PlanNumber.ThrowIfNullOrEmpty("请传入批次号");
var rtns = new RestfulQueryResponse<PlanDetail>();
rtns.Results = new List<PlanDetail>();
var result = new PlanDetail();
var factory = Kivii.Linq.LinqUtils.GetLinqConnectionFactory(Configs.ConnectionString, Configs.ConnectionProviderName);
using (var conn = factory.OpenDbConnection())
{
......@@ -146,8 +148,8 @@ namespace Kivii.Third.Scjgj
query.Where(o => o.PLAN_CODE == BatchNumber && o.LOT_NUM == PlanNumber);
var planDetail = conn.Single(query);
if (planDetail == null) throw new Exception("未找到此任务单");
var result = planDetail.ConvertTo(conn);
rtns.Results.Add(result);
result = planDetail.DataFilling(conn);
}
catch (Exception ex)
{
......@@ -155,21 +157,18 @@ namespace Kivii.Third.Scjgj
}
}
if (!ToReport)
{
var rtns=new RestfulReadResponse<PlanDetail>();
rtns.Result = result;
return rtns;
}
}
[RequiresAnyRole(MemberRoles.Everyone)]
public class PlanDetailConvertToReport : RestfulExecution<PlanDetail>
{
public PlanDetail Item { get; set; }
public override object OnExecution(IRequest req, IResponse res)
else
{
var rtns = new RestfulReadResponse<Report>();
rtns.Result = Item.ConvertTo();
rtns.Result = result.ConvertTo();
return rtns;
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment