投料保存 领料记录

This commit is contained in:
2023-11-07 16:56:05 +08:00
parent 64bb0ff680
commit d5eefbf9d5
13 changed files with 252 additions and 15 deletions

View File

@@ -18,6 +18,11 @@ public partial class EqpDaq : BaseEntity<string>
/// 数据源
/// </summary>
public string data_source { get; set; } = string.Empty;
/// <summary>
/// 机号
/// </summary>
public string? equip_code { get; set; }
/// <summary>
/// 标签名称

View File

@@ -0,0 +1,36 @@
namespace Tnb.ProductionMgr.Entities.Dto
{
public class FeedingInput
{
/// <summary>
/// 工位id
/// </summary>
public string station_id { get; set; } = string.Empty;
// /// <summary>
// /// 任务单id
// /// </summary>
// public string? mo_task_id { get; set; }
//
// /// <summary>
// /// 设备id
// /// </summary>
// public string? equip_id { get; set; }
/// <summary>
/// 二维码信息
/// </summary>
public string? carry_code { get; set; }
public List<FeedingDInput> details { get; set; } = new List<FeedingDInput>();
}
public class FeedingDInput
{
public string material_id { get; set; }
public string code_batch { get; set; }
public string unit_id { get; set; }
public decimal codeqty { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using JNPF.Common.Filter;
namespace Tnb.ProductionMgr.Entities.Dto
{
public class FeedingRecordInfoInput
{
public string id { get; set; }
public string type { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using JNPF.Common.Filter;
namespace Tnb.ProductionMgr.Entities.Dto
{
public class FeedingRecordInfoOutput
{
public string id { get; set; }
public string material_id { get; set; }
public string material_code { get; set; }
public string material_name { get; set; }
public decimal? num { get; set; }
public string unit_name { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using JNPF.Common.Filter;
namespace Tnb.ProductionMgr.Entities.Dto
{
public class FeedingRecordListInput : PageInputBase
{
/// <summary>
/// 工位id
/// </summary>
public string stationId { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace Tnb.ProductionMgr.Entities.Dto
{
public class FeedingRecordListOutput
{
public string id { get; set; }
public string code { get; set; }
public string type_name { get; set; }
public string type { get; set; }
public string create_name { get; set; }
public string create_time { get; set; }
public string status { get; set; }
}
}

View File

@@ -26,6 +26,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
public string material_id { get; set; }
public string material_code { get; set; }
public string category_id { get; set; }
public decimal? num { get; set; }
}
}

View File

@@ -93,5 +93,10 @@ public partial class PrdKittingOutH : BaseEntity<string>
/// 任务单
/// </summary>
public string? mo_task_id { get; set; }
/// <summary>
/// 状态 1 待配送 2 已完成
/// </summary>
public string status { get; set; }
}

View File

@@ -14,6 +14,7 @@ public partial class PrdOutstockH : BaseEntity<string>
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 出库单创建日期
/// </summary>
@@ -23,6 +24,11 @@ public partial class PrdOutstockH : BaseEntity<string>
/// 单据类型
/// </summary>
public string? bill_type { get; set; }
/// <summary>
/// 单据类型 1 一般出库 2 物料出库
/// </summary>
public string? type { get; set; }
/// <summary>
/// 发料仓库id
@@ -38,6 +44,11 @@ public partial class PrdOutstockH : BaseEntity<string>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 所属组织
@@ -58,6 +69,11 @@ public partial class PrdOutstockH : BaseEntity<string>
/// 所属产线
/// </summary>
public string? workline { get; set; }
/// <summary>
/// 状态 1 待配送 2 已完成
/// </summary>
public string status { get; set; }
/// <summary>
/// 流程任务Id

View File

@@ -1,12 +1,15 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Filter;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
@@ -335,7 +338,7 @@ namespace Tnb.ProductionMgr
/// <exception cref="Exception"></exception>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task<dynamic> Feeding(MaterialReceiptNewInput input)
public async Task<dynamic> Feeding(FeedingInput input)
{
ISqlSugarClient db = _repository.AsSugarClient();
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>()
@@ -375,7 +378,7 @@ namespace Tnb.ProductionMgr
station_id = input.station_id,
mo_task_id = moTask.id,
process_id = moTask.process_id,
equip_id = input.equip_id,
// equip_id = input.equip_id,
workshop_id = workshop?.Id,
carry_id = carry.id,
workline_id = moTask.workline_id,
@@ -389,24 +392,24 @@ namespace Tnb.ProductionMgr
if (input.details != null && input.details.Count > 0)
{
foreach (Dictionary<string, string> item in input.details)
foreach (var item in input.details)
{
if (!inputMaterials.Contains(item["material_id"]))
{
throw new Exception("该物料不是生产bom投入物料不能签收");
}
// if (!inputMaterials.Contains(item["material_id"]))
// {
// throw new Exception("该物料不是生产bom投入物料不能签收");
// }
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()
.Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync();
decimal num = Convert.ToDecimal(item["num"]);
decimal num = item.codeqty;
list.Add(new PrdFeedingD
{
feeding_id = prdFeedingH.id,
material_receipt_detail_id = detail?.id,
material_id = item["material_id"],
material_id = item.material_id,
num = num,
batch = item["batch"],
unit_id = item["unit_id"],
batch = item.code_batch,
unit_id = item.unit_id,
carry_id = carry.id,
status = "0",
use_num = 0,
@@ -440,7 +443,7 @@ namespace Tnb.ProductionMgr
}
else
{
throw new Exception("没有签收物料");
throw new Exception("没有签收物料,无法投料");
}
@@ -450,7 +453,7 @@ namespace Tnb.ProductionMgr
});
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "签收成功" : result.ErrorMessage);
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage);
}
[HttpPost]
@@ -496,5 +499,110 @@ namespace Tnb.ProductionMgr
.ToListAsync();
return result;
}
/// <summary>
/// pad app 领料记录列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> FeedingRecordList(FeedingRecordListInput input)
{
if (string.IsNullOrEmpty(input.stationId))
{
return new
{
pagination = new PageResult(),
list = Array.Empty<string>()
};
}
var db = _repository.AsSugarClient();
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
string? code = queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
// DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
// DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
if (string.IsNullOrEmpty(input.sidx))
{
input.sidx = "create_time";
input.sort = "desc";
}
var queryable1 = db.Queryable<PrdKittingOutH>()
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
.Select((a, b) => new FeedingRecordListOutput()
{
id = a.id,
code = a.code,
type_name = "齐套出库",
type = "0",
create_name = b.RealName,
create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
status = a.status
});
var queryable2 = db.Queryable<PrdOutstockH>()
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
.Select((a, b) => new FeedingRecordListOutput()
{
id = a.id,
code = a.bill_code,
type_name = a.type=="1" ? "一般出库" : "物料出库",
type = a.type,
create_name = b.RealName,
create_time = a.create_time==null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
status = a.status
});
var result = await db.UnionAll(queryable1,queryable2)
.MergeTable()
.OrderBy($"{input.sidx} {input.sort}")
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<FeedingRecordListOutput>.SqlSugarPageResult(result);
}
[HttpPost]
public async Task<dynamic> GetFeedingRecordInFoById(FeedingRecordInfoInput input)
{
var db = _repository.AsSugarClient();
if (input.type == "0")
{
var result = db.Queryable<PrdKittingOutD>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<DictionaryTypeEntity>((a,b,c)=>c.EnCode==DictConst.MeasurementUnit)
.LeftJoin<DictionaryDataEntity>((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id)
.Where((a, b) => a.kitting_out_id == input.id)
.Select((a, b,c,d) => new FeedingRecordInfoOutput
{
id = a.id,
material_id = a.material_id,
material_code = b.code,
material_name = b.name,
num = a.pr_qty,
unit_name = d.FullName
}).ToListAsync();
return result;
}
else
{
var result = db.Queryable<PrdOutstockD>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<DictionaryTypeEntity>((a,b,c)=>c.EnCode==DictConst.MeasurementUnit)
.LeftJoin<DictionaryDataEntity>((a,b,c,d)=>d.DictionaryTypeId==c.Id && a.unit_id==d.Id)
.Where((a, b) => a.outstock_id == input.id)
.Select((a, b,c,d) => new FeedingRecordInfoOutput
{
id = a.id,
material_id = a.material_id,
material_code = b.code,
material_name = b.name,
num = a.pr_qty,
unit_name = d.FullName
}).ToListAsync();
return result;
}
}
}
}

View File

@@ -2675,6 +2675,7 @@ namespace Tnb.ProductionMgr
{
material_id = x.material_id,
material_code = y.code,
category_id = y.category_id,
num = x.num
})

View File

@@ -42,13 +42,15 @@ namespace Tnb.ProductionMgr
private readonly IDictionaryDataService _dictionaryDataService;
private readonly IOrganizeService _organizeService;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdOutstockService(ISqlSugarRepository<PrdOutstockH> repository, IOrganizeService organizeService, IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
public PrdOutstockService(ISqlSugarRepository<PrdOutstockH> repository, IOrganizeService organizeService, IBillRullService billRullService,IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
{
_db = repository.AsSugarClient();
_runService = runService;
_visualDevService = visualDevService;
_billRullService = billRullService;
_dictionaryDataService = dictionaryDataService;
_repository = repository;
_userManager = userManager;
@@ -195,12 +197,15 @@ namespace Tnb.ProductionMgr
{
PrdOutstockH prdOutstockH = new()
{
bill_code = await _billRullService.GetBillNumber(CodeTemplateConst.PRDOUTSTOCK_CODE),
bill_type = DictConst.SHENGCHANLINGLIAO,
type = "1",
warehouse_id = warehouse_id,
location_code = generalOutstockInput.location_code,
create_id = _userManager.UserId,
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
create_time = DateTime.Now,
workstation = generalOutstockInput.workstation_id,
workline = workline?.Id ?? ""
};
@@ -311,12 +316,15 @@ namespace Tnb.ProductionMgr
else
{
PrdOutstockH prdOutstockH = new PrdOutstockH();
prdOutstockH.bill_code = await _billRullService.GetBillNumber(CodeTemplateConst.PRDOUTSTOCK_CODE);
prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO;
prdOutstockH.type = "2";
prdOutstockH.warehouse_id = warehouse_id;
prdOutstockH.location_code = materialOutstockInput.location_code;
prdOutstockH.create_id = _userManager.UserId;
prdOutstockH.org_id = _userManager.GetUserInfo().Result.organizeId;
prdOutstockH.bill_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
prdOutstockH.create_time = DateTime.Now;
prdOutstockH.workstation = materialOutstockInput.workstation_id;
prdOutstockH.workline = workline?.Id ?? "";

View File

@@ -464,7 +464,7 @@ namespace Tnb.ProductionMgr
minpacking = b.minpacking,
main_num = k.number_of_primary_unit,
deputy_num = k.number_of_auxiliary_unit,
third_equip_code = f.third_equip_code,
third_equip_code = l.equip_code,
weight_name = l.label_name,
category_id = b.category_id
})