This commit is contained in:
2023-11-27 10:59:59 +08:00
5 changed files with 260 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
namespace Tnb.ProductionMgr.Entities.Dto
{
public class PrdInstockRecordUpListOutPut
{
public string id { get; set; }
public string mo_task_code { get; set; }
public string mo_task_status { get; set; }
public string mo_id { get; set; }
public string material_id { get; set; }
public string workstation_id { get; set; }
public string workline_id { get; set; }
public string act_start_date { get; set; }
public List<PrdInstockRecordUpListChildOutPut> tablefield102 { get; set; } = new List<PrdInstockRecordUpListChildOutPut>();
}
public class PrdInstockRecordUpListChildOutPut
{
public string id { get; set; }
public string bill_code { get; set; }
public string bill_type { get; set; }
public string carry_code { get; set; }
public string create_id { get; set; }
public string bill_date { get; set; }
}
public class PrdInstockRecordUpListDownOutPut
{
public string id { get; set; }
public string material_id { get; set; }
public string material_code { get; set; }
public string unit_id { get; set; }
public string quantity { get; set; }
public string code_batch { get; set; }
/// <summary>
/// 条码编号
/// </summary>
public string barcode { get; set; } = string.Empty;
}
}

View File

@@ -75,5 +75,15 @@ public partial class PrdInstockH : BaseEntity<string>
/// 状态 0 申请入库 1 已入库 /// 状态 0 申请入库 1 已入库
/// </summary> /// </summary>
public int? status { get; set; } public int? status { get; set; }
/// <summary>
/// 生产任务单id
/// </summary>
public string? mo_task_id { get; set; }
/// <summary>
/// 入库单编号
/// </summary>
public string? code { get; set; }
} }

View File

@@ -0,0 +1,80 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Filter;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.Permission;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities;
namespace Tnb.ProductionMgr
{
/// <summary>
/// 物料签收记录pc端
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
[OverideVisualDev(ModuleId)]
public class PrdInstockRecordDownServicecs : IDynamicApiController, ITransient, IOverideVisualDevService
{
private readonly ISqlSugarRepository<PrdKittingOutH> _repository;
private readonly IUserManager _userManager;
private readonly IOrganizeService _organizeService;
private const string ModuleId = "30374696689685";
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdInstockRecordDownServicecs(
ISqlSugarRepository<PrdKittingOutH> repository,
IOrganizeService organizeService,
IUserManager userManager
)
{
_repository = repository;
_organizeService = organizeService;
_userManager = userManager;
OverideFuncs.GetListAsync = GetList;
}
private async Task<object> GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
Dictionary<string, object>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
string instock_id = queryJson.ContainsKey("instock_id") ? queryJson["instock_id"].ToString() : "";
if (string.IsNullOrEmpty(instock_id))
{
return new
{
pagination = new PageResult(),
list = Array.Empty<string>()
};
}
var result = await db.Queryable<PrdInstockD>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<DictionaryTypeEntity>((a,b,c)=>c.EnCode==DictConst.MeasurementUnit)
.LeftJoin<DictionaryDataEntity>((a,b,c,d)=>a.unit_id==d.EnCode && c.Id==d.DictionaryTypeId)
.WhereIF(!string.IsNullOrEmpty(instock_id),a=>a.instock_id==instock_id)
.Select((a, b, c,d) => new PrdInstockRecordUpListDownOutPut
{
id = a.id,
material_id = b.name,
material_code = b.code,
unit_id = d.FullName,
code_batch = a.code_batch,
barcode = a.barcode,
quantity = a.quantity.ToString(),
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<PrdInstockRecordUpListDownOutPut>.SqlSugarPageResult(result);
}
}
}

View File

@@ -0,0 +1,113 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Filter;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.Permission;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities;
namespace Tnb.ProductionMgr
{
/// <summary>
/// 生产入库记录pc端
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
[OverideVisualDev(ModuleId)]
public class PrdInstockRecordUpServicecs : IDynamicApiController, ITransient, IOverideVisualDevService
{
private readonly ISqlSugarRepository<PrdKittingOutH> _repository;
private readonly IUserManager _userManager;
private readonly IOrganizeService _organizeService;
private const string ModuleId = "30374667217173";
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdInstockRecordUpServicecs(
ISqlSugarRepository<PrdKittingOutH> repository,
IOrganizeService organizeService,
IUserManager userManager
)
{
_repository = repository;
_organizeService = organizeService;
_userManager = userManager;
OverideFuncs.GetListAsync = GetList;
}
private async Task<object> GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
Dictionary<string, object>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
string mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
string mo_code = queryJson.ContainsKey("mo_id") ? queryJson["mo_id"].ToString() : "";
// string workstation_id_str = queryJson.ContainsKey("workstation_id") ? queryJson["workstation_id"].ToString() : "";
// string workstation_id = "";
// if (!string.IsNullOrEmpty(workstation_id_str))
// {
// string[] workstation_arr = JsonConvert.DeserializeObject<string[]>(workstation_id_str);
// if (workstation_arr != null && workstation_arr.Length > 0)
// {
// workstation_id = workstation_arr[workstation_arr.Length - 1];
// }
// }
if (string.IsNullOrEmpty(input.sidx))
{
input.sidx = "a.create_time";
input.sort = "desc";
}
else
{
input.sidx = "a." + input.sidx;
}
var result = await db.Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<OrganizeEntity>((a,b,c)=>a.workstation_id==c.Id)
.LeftJoin<PrdMo>((a,b,c,d)=>a.mo_id==d.id)
.LeftJoin<DictionaryDataEntity>((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode)
.LeftJoin<OrganizeEntity>((a,b,c,d,e,f)=>a.workline_id==f.Id)
.WhereIF(!string.IsNullOrEmpty(mo_task_code),a=>a.mo_task_code.Contains(mo_task_code))
.WhereIF(!string.IsNullOrEmpty(mo_code),(a,b,c,d,e)=>d.mo_code.Contains(mo_code))
.Where(a=>a.act_start_date!=null)
.OrderBy($"{input.sidx} {input.sort}")
.Select((a, b, c, d,e,f) => new PrdInstockRecordUpListOutPut()
{
id = a.id,
mo_task_code = a.mo_task_code,
mo_id = d.mo_code,
material_id = b.name,
workstation_id = c.FullName,
mo_task_status = e.FullName,
workline_id = f.FullName,
act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
tablefield102 = SqlFunc.Subqueryable<PrdInstockH>()
.LeftJoin<UserEntity>((x,y)=>x.create_id==y.Id)
.LeftJoin<DictionaryDataEntity>((x,y,z)=>x.bill_type==z.Id)
.Where(x=>x.mo_task_id==a.id).ToList((x,y,z)=>new PrdInstockRecordUpListChildOutPut()
{
id = x.id,
bill_code = x.code,
bill_type = z.FullName,
carry_code = x.carry_code,
create_id = y.RealName,
bill_date = x.bill_date==null ? "" : x.bill_date.ToString(DbTimeFormat.SS),
}),
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<PrdInstockRecordUpListOutPut>.SqlSugarPageResult(result);
}
}
}

View File

@@ -11,6 +11,7 @@ using JNPF.FriendlyException;
using JNPF.Logging; using JNPF.Logging;
using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.Permission; using JNPF.Systems.Interfaces.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev; using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@@ -40,18 +41,22 @@ namespace Tnb.ProductionMgr
private readonly ISqlSugarRepository<PrdInstockH> _repository; private readonly ISqlSugarRepository<PrdInstockH> _repository;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IOrganizeService _organizeService; private readonly IOrganizeService _organizeService;
private readonly IBillRullService _billRuleService;
private const string ModuleId = "25572529329173"; private const string ModuleId = "25572529329173";
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdInstockService( public PrdInstockService(
ISqlSugarRepository<PrdInstockH> repository, ISqlSugarRepository<PrdInstockH> repository,
IOrganizeService organizeService, IOrganizeService organizeService,
IBillRullService billRullService,
IUserManager userManager IUserManager userManager
) )
{ {
_repository = repository; _repository = repository;
_organizeService = organizeService; _organizeService = organizeService;
_userManager = userManager; _userManager = userManager;
_billRuleService= billRullService;
OverideFuncs.GetListAsync = GetList; OverideFuncs.GetListAsync = GetList;
} }
@@ -327,8 +332,10 @@ namespace Tnb.ProductionMgr
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode); OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode);
string code = await _billRuleService.GetBillNumber(CodeTemplateConst.PRDINSTOCK_CODE);
prdInstockH = new PrdInstockH() prdInstockH = new PrdInstockH()
{ {
code = code,
bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now, bill_date = DateTime.Now,
create_id = create_id, create_id = create_id,
@@ -342,6 +349,7 @@ namespace Tnb.ProductionMgr
// warehouse_id = basLocation?.wh_id, // warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id, warehouse_id = warehouse_id,
status = 0, status = 0,
mo_task_id = prdReport.mo_task_id,
}; };
prdInstockDs.Add(new PrdInstockD() prdInstockDs.Add(new PrdInstockD()
@@ -600,9 +608,11 @@ namespace Tnb.ProductionMgr
{ {
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode); OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode);
string code = await _billRuleService.GetBillNumber(CodeTemplateConst.PRDINSTOCK_CODE);
prdInstockH = new PrdInstockH() prdInstockH = new PrdInstockH()
{ {
code = code,
bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now, bill_date = DateTime.Now,
create_id = create_id, create_id = create_id,
@@ -615,6 +625,7 @@ namespace Tnb.ProductionMgr
org_id = org_id, org_id = org_id,
warehouse_id = warehouse_id, warehouse_id = warehouse_id,
status = 0, status = 0,
mo_task_id = prdReport.mo_task_id,
}; };
prdInstockDs.Add(new PrdInstockD() prdInstockDs.Add(new PrdInstockD()
@@ -731,6 +742,7 @@ namespace Tnb.ProductionMgr
org_id = org_id, org_id = org_id,
warehouse_id = warehouse_id, warehouse_id = warehouse_id,
status = 0, status = 0,
mo_task_id = prdReport.mo_task_id,
}; };
prdInstockDs.Add(new PrdInstockD() prdInstockDs.Add(new PrdInstockD()
@@ -886,6 +898,7 @@ namespace Tnb.ProductionMgr
string create_id = prdReports[0].create_id; string create_id = prdReports[0].create_id;
UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id); UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id);
string org_id = user.OrganizeId; string org_id = user.OrganizeId;
string mo_task_id = prdReports[0].mo_task_id;
PrdInstockH? prdInstockH = null; PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { }; List<PrdInstockD> prdInstockDs = new() { };
@@ -896,9 +909,11 @@ namespace Tnb.ProductionMgr
{ {
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorklineCode); OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorklineCode);
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorkshopCode); OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(station.Id, DictConst.RegionCategoryWorkshopCode);
string code = await _billRuleService.GetBillNumber(CodeTemplateConst.PRDINSTOCK_CODE);
prdInstockH = new PrdInstockH() prdInstockH = new PrdInstockH()
{ {
code = code,
bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now, bill_date = DateTime.Now,
create_id = create_id, create_id = create_id,
@@ -912,6 +927,7 @@ namespace Tnb.ProductionMgr
// warehouse_id = basLocation?.wh_id, // warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id, warehouse_id = warehouse_id,
status = 0, status = 0,
mo_task_id = mo_task_id,
}; };
foreach (var prdReport in prdReports) foreach (var prdReport in prdReports)