注塑车间报表初版
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class ZhuSuBiInput
|
||||
{
|
||||
public string day { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class ZhuSuBiOutput
|
||||
{
|
||||
public DayMonthYieldOutput day_month_yield { get; set; }
|
||||
|
||||
public List<EquipPieOutput> equip_pie_list { get; set; }
|
||||
|
||||
public List<EquipPieOutput> equip_info_list { get; set; }
|
||||
public List<ReportRecordOutput> report_record_list { get; set; }
|
||||
}
|
||||
|
||||
public class DayMonthYieldOutput
|
||||
{
|
||||
public decimal month_qty;
|
||||
public decimal day_qty;
|
||||
public decimal month_qualified_percent;
|
||||
public decimal day_qualified_percent;
|
||||
}
|
||||
|
||||
public class ReportRecordOutput
|
||||
{
|
||||
public string mo_task_code { get; set; }
|
||||
public string material_name { get; set; }
|
||||
public string workline_name { get; set; }
|
||||
public string report_type { get; set; }
|
||||
public int qty { get; set; }
|
||||
public string repoter_name { get; set; }
|
||||
public int plan_qty { get; set; }
|
||||
public int remain_plan_qty { get; set; }
|
||||
public string report_time { get; set; }
|
||||
}
|
||||
|
||||
public class EquipPieOutput
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int value { get; set; }
|
||||
|
||||
public string status { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,13 @@ public partial class PrdMoTaskDefect : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? mo_task_id { get; set; }
|
||||
|
||||
public string org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
@@ -27,7 +34,7 @@ public partial class PrdMoTaskDefect : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
public DateTime create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 次品分类id
|
||||
|
||||
@@ -19,6 +19,11 @@ public partial class PrdReport : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? mo_task_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织id
|
||||
/// </summary>
|
||||
public string org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
@@ -37,7 +42,7 @@ public partial class PrdReport : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
public DateTime create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
|
||||
135
ProductionMgr/Tnb.ProductionMgr/BiService.cs
Normal file
135
ProductionMgr/Tnb.ProductionMgr/BiService.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev.Engine.Enum.VisualDevModelData;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Microsoft.AspNetCore.Components.Route("api/[area]/[controller]/[action]")]
|
||||
public class BiService: IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public BiService(ISqlSugarRepository<Material> repository,
|
||||
IBillRullService billRuleService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<ZhuSuBiOutput> GetZhuSuBiData(ZhuSuBiInput input)
|
||||
{
|
||||
string dayStr = input.day!=null && !input.day.IsEmpty() ? input.day : DateTime.Now.ToString("yyyy-MM-dd");
|
||||
string monthStr = dayStr.Substring(0, 7);
|
||||
ZhuSuBiOutput output = new ZhuSuBiOutput();
|
||||
output.day_month_yield = new DayMonthYieldOutput();
|
||||
int? monthQualifiedQty = await _db.Queryable<PrdReport>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.create_time.ToString("yyyy-MM") == monthStr && b.category_id.Contains("ZSJ"))
|
||||
.GroupBy((a, b) => a.org_id)
|
||||
.Select((a, b) => SqlFunc.AggregateSum(a.reported_qty))
|
||||
.FirstAsync();
|
||||
|
||||
int? monthUnQualifiedQty = await _db.Queryable<PrdMoTaskDefect>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.create_time.ToString("yyyy-MM") == monthStr && b.category_id.Contains("ZSJ"))
|
||||
.GroupBy((a, b) => a.org_id)
|
||||
.Select((a, b) => SqlFunc.AggregateSum(a.scrap_qty))
|
||||
.FirstAsync();
|
||||
|
||||
int? dayQualifiedQty = await _db.Queryable<PrdReport>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.create_time.ToString("yyyy-MM-dd") == monthStr && b.category_id.Contains("ZSJ"))
|
||||
.GroupBy((a, b) => a.org_id)
|
||||
.Select((a, b) => SqlFunc.AggregateSum(a.reported_qty))
|
||||
.FirstAsync();
|
||||
|
||||
int? dayUnQualifiedQty = await _db.Queryable<PrdMoTaskDefect>()
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.create_time.ToString("yyyy-MM-dd") == monthStr && b.category_id.Contains("ZSJ"))
|
||||
.GroupBy((a, b) => a.org_id)
|
||||
.Select((a, b) => SqlFunc.AggregateSum(a.scrap_qty))
|
||||
.FirstAsync();
|
||||
output.day_month_yield.month_qty = monthQualifiedQty!=null ? monthQualifiedQty.Value : 0;
|
||||
output.day_month_yield.day_qty = dayQualifiedQty !=null ? dayQualifiedQty.Value : 0;
|
||||
output.day_month_yield.month_qualified_percent = output.day_month_yield.month_qty==0 ? 0 :decimal.Parse((monthQualifiedQty.Value/(monthQualifiedQty.Value+monthUnQualifiedQty.Value)).ToString("F"));
|
||||
output.day_month_yield.day_qualified_percent = output.day_month_yield.day_qty==0 ? 0 : decimal.Parse((dayQualifiedQty.Value/(dayQualifiedQty.Value+dayUnQualifiedQty.Value)).ToString("F"));
|
||||
|
||||
var queryable1 =_db.Queryable<PrdReport>()
|
||||
.LeftJoin<PrdMoTask>((a,b)=>a.mo_task_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<UserEntity>((a,b,c,d)=>a.create_id==d.Id)
|
||||
.LeftJoin<OrganizeEntity>((a,b,c,d,e)=>b.workline_id==e.Id)
|
||||
.Where((a,b,c)=>(b.mo_task_status==DictConst.MoStatusPauseCode || b.mo_task_status==DictConst.InProgressEnCode) && c.category_id.Contains("ZSJ"))
|
||||
.Select((a,b,c,d,e)=>new ReportRecordOutput
|
||||
{
|
||||
mo_task_code = b.mo_task_code,
|
||||
material_name = c.name,
|
||||
workline_name = e.FullName,
|
||||
report_type = "合格",
|
||||
qty = a.reported_qty.Value,
|
||||
repoter_name = d.RealName,
|
||||
plan_qty = b.scheduled_qty.Value,
|
||||
remain_plan_qty = b.scheduled_qty.Value-(b.reported_work_qty!=null ? b.reported_work_qty.Value : 0)-(b.scrap_qty!=null ? b.scrap_qty.Value : 0),
|
||||
report_time = a.create_time.ToString(DbTimeFormat.SS)
|
||||
});
|
||||
|
||||
var queryable2 =_db.Queryable<PrdMoTaskDefect>()
|
||||
.LeftJoin<PrdMoTask>((a,b)=>a.mo_task_id==b.id)
|
||||
.LeftJoin<BasMaterial>((a,b,c)=>a.material_id==c.id)
|
||||
.LeftJoin<UserEntity>((a,b,c,d)=>a.create_id==d.Id)
|
||||
.LeftJoin<OrganizeEntity>((a,b,c,d,e)=>b.workline_id==e.Id)
|
||||
.Where((a,b,c)=>(b.mo_task_status==DictConst.MoStatusPauseCode || b.mo_task_status==DictConst.InProgressEnCode) && c.category_id.Contains("ZSJ"))
|
||||
.Select((a,b,c,d,e)=>new ReportRecordOutput
|
||||
{
|
||||
mo_task_code = b.mo_task_code,
|
||||
material_name = c.name,
|
||||
workline_name = e.FullName,
|
||||
report_type = "不合格",
|
||||
qty = a.scrap_qty,
|
||||
repoter_name = d.RealName,
|
||||
plan_qty = b.scheduled_qty.Value,
|
||||
remain_plan_qty = b.scheduled_qty.Value-(b.reported_work_qty!=null ? b.reported_work_qty.Value : 0)-(b.scrap_qty!=null ? b.scrap_qty.Value : 0),
|
||||
report_time = a.create_time.ToString(DbTimeFormat.SS)
|
||||
});
|
||||
output.report_record_list = await _db.UnionAll(queryable1, queryable2)
|
||||
.OrderByDescending(a => a.report_time)
|
||||
.ToListAsync();
|
||||
|
||||
output.equip_pie_list = await _db.Queryable<EqpEquipment>()
|
||||
.GroupBy(x => x.status)
|
||||
.Select(x => new EquipPieOutput
|
||||
{
|
||||
name = x.status,
|
||||
value = SqlFunc.AggregateCount(x.id)
|
||||
}).ToListAsync();
|
||||
|
||||
output.equip_info_list = await _db.Queryable<EqpEquipment>()
|
||||
.LeftJoin<EqpEquipType>((x,y)=>x.equip_type_id==y.id)
|
||||
.Where((x,y)=>y.code=="ZSJ")
|
||||
.Select(x => new EquipPieOutput
|
||||
{
|
||||
name = x.name,
|
||||
status = x.status
|
||||
}).ToListAsync();
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1709,6 +1709,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
report = input.Adapt<PrdReport>();
|
||||
report.id = SnowflakeIdHelper.NextId();
|
||||
report.org_id = WmsWareHouseConst.AdministratorOrgId;
|
||||
report.reported_qty = input.reported_qty;
|
||||
report.weight = input.weight;
|
||||
report.material_box_code = input.material_box_code;
|
||||
@@ -2341,6 +2342,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
mo_task_id = input.mo_task_id,
|
||||
material_id = prdMoTask.material_id,
|
||||
org_id = WmsWareHouseConst.AdministratorOrgId,
|
||||
batch = batch,
|
||||
defective_cagetory_id = categoryItem.category_id,
|
||||
defective_item = dItem.defective_item,
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Tnb.ProductionMgr
|
||||
reported_qty = x.reported_qty,
|
||||
create_id = y.RealName,
|
||||
create_id_id = x.create_id,
|
||||
create_time = x.create_time == null ? "" : x.create_time.Value.ToString(DbTimeFormat.MM),
|
||||
create_time = x.create_time.ToString(DbTimeFormat.MM),
|
||||
batch = x.batch,
|
||||
material_box_code = x.material_box_code,
|
||||
weight = x.weight
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace Tnb.WarehouseMgr
|
||||
thirdWebapiRecord.third_name = WmsWareHouseConst.BIP;
|
||||
thirdWebapiRecord.name = "采购入库";
|
||||
thirdWebapiRecord.method = "POST";
|
||||
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purarrvial/save";
|
||||
thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN+"uapws/rest/purchaseIn/save";
|
||||
thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData);
|
||||
thirdWebapiRecord.create_time = DateTime.Now;
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Tnb.WarehouseMgr
|
||||
erpRequestData.Add("dbilldate",purchase.create_time.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
erpRequestData.Add("dmakedate",nowStr);
|
||||
erpRequestData.Add("ntotalastnum",purchaseDs.Sum(x=>x.purchase_arriveqty));
|
||||
erpRequestData.Add("pk_arriveorder","");
|
||||
erpRequestData.Add("pk_arriveorder",null);
|
||||
// erpRequestData.Add("pk_dept","1001A1100000000JRLI1");
|
||||
// erpRequestData.Add("pk_dept_v","0001A11000000007GGO8");
|
||||
erpRequestData.Add("pk_org",erpOrg.pk_org);
|
||||
@@ -165,8 +165,8 @@ namespace Tnb.WarehouseMgr
|
||||
erpRequestDataDetails.Add(new Dictionary<string, object>()
|
||||
{
|
||||
["castunitid"] = erpExtendFields.Find(x=>x.table_id==(unitDatas.Find(x=>x.EnCode==item.unit_id)?.Id ?? ""))?.cunitid ?? "",
|
||||
["cfirstbid"] = "",
|
||||
["cfirstid"] = "",
|
||||
["cfirstbid"] = wmsPurchaseOrderH?.erp_pk ?? "",
|
||||
["cfirstid"] = wmsPurchaseOrderDs.erp_line_pk,
|
||||
["cfirsttypecode"] = "",
|
||||
["crececountryid"] = "0001Z010000000079UJJ",
|
||||
["crowno"] = (dList.FindIndex(x=>x.id==item.id)+1) * 10,
|
||||
@@ -186,8 +186,8 @@ namespace Tnb.WarehouseMgr
|
||||
["nplannum"] = item.purchase_qty,
|
||||
["apfinanceorg"] = erpOrg.pk_org,
|
||||
["pk_apfinanceorg_v"] = erpOrg.pk_org_v,
|
||||
["pk_arriveorder"] = "",
|
||||
["pk_arriveorder_b"] = "",
|
||||
["pk_arriveorder"] = null,
|
||||
["pk_arriveorder_b"] = null,
|
||||
["pk_group"] = "",
|
||||
["csourcebid"] = wmsPurchaseOrderDs.erp_line_pk,
|
||||
["csourceid"] = wmsPurchaseOrderH?.erp_pk ?? "",
|
||||
@@ -203,6 +203,7 @@ namespace Tnb.WarehouseMgr
|
||||
["pk_reqstoorg_v"] = erpOrg.pk_org_v,
|
||||
["pk_srcmaterial"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",
|
||||
["vbatchcode"] = item.code_batch,
|
||||
["Vfree1"] = item.code_batch,
|
||||
});
|
||||
}
|
||||
erpRequestData.Add("dtls",erpRequestDataDetails);
|
||||
|
||||
@@ -33,24 +33,27 @@ public static class ConfigureSqlSugarExtensions
|
||||
},
|
||||
});
|
||||
|
||||
foreach (var item in conn.ConfigList)
|
||||
if (conn.ConfigList != null)
|
||||
{
|
||||
connectConfigList.Add(new ConnectionConfig
|
||||
foreach (var item in conn.ConfigList)
|
||||
{
|
||||
ConnectionString = item.connectionStr,
|
||||
DbType = item.dbType,
|
||||
IsAutoCloseConnection = true,
|
||||
ConfigId = item.ServiceName,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
connectConfigList.Add(new ConnectionConfig
|
||||
{
|
||||
IsAutoRemoveDataCache = true, // 自动清理缓存
|
||||
IsAutoToUpper = false,
|
||||
//PgSqlIsAutoToLower = false,
|
||||
DisableNvarchar = true
|
||||
},
|
||||
});
|
||||
ConnectionString = item.connectionStr,
|
||||
DbType = item.dbType,
|
||||
IsAutoCloseConnection = true,
|
||||
ConfigId = item.ServiceName,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
IsAutoRemoveDataCache = true, // 自动清理缓存
|
||||
IsAutoToUpper = false,
|
||||
//PgSqlIsAutoToLower = false,
|
||||
DisableNvarchar = true
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
services.AddSqlSugar(connectConfigList, client =>
|
||||
|
||||
Reference in New Issue
Block a user