124 lines
6.2 KiB
C#
124 lines
6.2 KiB
C#
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 mo_type = queryJson.ContainsKey("mo_type") ? queryJson["mo_type"].ToString() : "";//工单类型
|
|
string name = queryJson.ContainsKey("name") ? queryJson["name"].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)
|
|
.LeftJoin<EqpEquipment>((a, b, c, d, e, f, g) => a.eqp_id == g.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))
|
|
.WhereIF(!string.IsNullOrEmpty(mo_type), (a, b, c, d, e) => d.mo_type == mo_type)
|
|
.WhereIF(!string.IsNullOrEmpty(name), (a, b, c, d, e) => b.name.Contains(name))
|
|
.Where(a => a.act_start_date != null)
|
|
.OrderBy($"{input.sidx} {input.sort}")
|
|
.Select((a, b, c, d, e, f, g) => 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,
|
|
eqp_code = g.code,
|
|
act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
|
|
create_time = a.create_time.HasValue ? a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
|
|
tablefield102 = SqlFunc.Subqueryable<PrdInstockH>()
|
|
.LeftJoin<UserEntity>((x, y) => x.create_id == y.Id)
|
|
.LeftJoin<DictionaryDataEntity>((x, y, z) => x.bill_type == z.Id)
|
|
.LeftJoin<WmsCarryH>((x, y, z, j) => x.carry_code == j.id)
|
|
.LeftJoin<BasLocation>((x, y, z, j, k) => x.location_code == k.id)
|
|
.Where(x => x.mo_task_id == a.id).ToList((x, y, z, j, k) => new PrdInstockRecordUpListChildOutPut()
|
|
{
|
|
id = x.id,
|
|
code = x.code,
|
|
bill_type = z.FullName,
|
|
carry_code = j.carry_code,
|
|
location_code = k.location_code,
|
|
create_id = y.RealName,
|
|
bill_date = x.bill_date == null ? "" : x.bill_date.ToString(DbTimeFormat.SS),
|
|
is_sync_bip = x.is_sync_bip.HasValue ? x.is_sync_bip.Value : 0
|
|
}),
|
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
|
return PageResult<PrdInstockRecordUpListOutPut>.SqlSugarPageResult(result);
|
|
}
|
|
}
|
|
} |