物料签收
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class NewMaterialReceiptInput
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工位id
|
||||||
|
/// </summary>
|
||||||
|
public string station_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 载具编号
|
||||||
|
/// </summary>
|
||||||
|
public string? carry_code { get; set; }
|
||||||
|
|
||||||
|
public List<NewMaterialReceiptDInput>? details { get; set; } = new List<NewMaterialReceiptDInput>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存在不属于该任务单的原材料也要签收
|
||||||
|
/// </summary>
|
||||||
|
public bool sure { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NewMaterialReceiptDInput
|
||||||
|
{
|
||||||
|
public string material_id{get;set;}
|
||||||
|
public decimal num {get;set;}
|
||||||
|
public string batch {get;set;}
|
||||||
|
public string unit_id {get;set;}
|
||||||
|
public string barcode {get;set;}
|
||||||
|
public string member_carry_id {get;set;}
|
||||||
|
public string member_carry_code {get;set;}
|
||||||
|
public string supplier_id {get;set;}
|
||||||
|
public DateTime? instock_time {get;set;}
|
||||||
|
public string check_conclusion {get;set;}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,7 +77,7 @@ public partial class PrdMaterialReceiptD : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 入库时间
|
/// 入库时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime instock_time { get; set; }
|
public DateTime? instock_time { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检验结论
|
/// 检验结论
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ namespace Tnb.ProductionMgr
|
|||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IOrganizeService _organizeService;
|
private readonly IOrganizeService _organizeService;
|
||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
|
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||||
|
|
||||||
public PrdMaterialReceiptService(
|
public PrdMaterialReceiptService(
|
||||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||||
IBillRullService billRullService,
|
IBillRullService billRullService,
|
||||||
IOrganizeService organizeService,
|
IOrganizeService organizeService,
|
||||||
|
IPrdMoTaskService prdMoTaskService,
|
||||||
IUserManager userManager
|
IUserManager userManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,7 @@ namespace Tnb.ProductionMgr
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_organizeService = organizeService;
|
_organizeService = organizeService;
|
||||||
_billRullService = billRullService;
|
_billRullService = billRullService;
|
||||||
|
_prdMoTaskService = prdMoTaskService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -170,9 +172,9 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
foreach (Dictionary<string, object> item in input.details)
|
foreach (Dictionary<string, object> item in input.details)
|
||||||
{
|
{
|
||||||
if (!inputMaterials.Contains(item["material_id"]) && !input.sure)
|
if (!inputMaterials.Contains(item["material_id"]))
|
||||||
{
|
{
|
||||||
throw new Exception("存在不属于生产bom的投入物料,确认签收吗");
|
throw new Exception("该物料不是生产bom投入物料,不能签收");
|
||||||
}
|
}
|
||||||
|
|
||||||
list.Add(new PrdMaterialReceiptD
|
list.Add(new PrdMaterialReceiptD
|
||||||
@@ -206,6 +208,125 @@ namespace Tnb.ProductionMgr
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
//签收后调用载具签收接口
|
||||||
|
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||||
|
// {
|
||||||
|
// org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||||
|
// create_id = _userManager.UserId,
|
||||||
|
// carry_code = input.carry_code ?? "",
|
||||||
|
// });
|
||||||
|
|
||||||
|
MESCarrySignInput mesCarrySignInput = new()
|
||||||
|
{
|
||||||
|
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
carry_code = input.carry_code ?? "",
|
||||||
|
};
|
||||||
|
|
||||||
|
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||||
|
Dictionary<string, object> header = new()
|
||||||
|
{
|
||||||
|
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||||
|
};
|
||||||
|
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||||
|
Log.Information(sendResult);
|
||||||
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
|
result2 = authResponse.code != 200
|
||||||
|
? throw Oops.Bah(authResponse.msg)
|
||||||
|
: await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
_ = await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||||
|
_ = await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return !result.IsSuccess
|
||||||
|
? throw Oops.Bah(result.ErrorMessage)
|
||||||
|
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> SaveDataNew(NewMaterialReceiptInput input)
|
||||||
|
{
|
||||||
|
ISqlSugarClient db = _repository.AsSugarClient();
|
||||||
|
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>(){
|
||||||
|
{"station_id",input.station_id}
|
||||||
|
});
|
||||||
|
DbResult<bool> result2 = new();
|
||||||
|
PrdMaterialReceiptH? prdMaterialReceiptH = null;
|
||||||
|
List<PrdMaterialReceiptD> list = new();
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||||
|
.Where(x => x.mbom_id == moTask.bom_id)
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(moTask.mbom_process_id), x => x.mbom_process_id == moTask.mbom_process_id)
|
||||||
|
.Select(x => x.material_id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
|
||||||
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode);
|
||||||
|
WmsCarryH carry = await db.Queryable<WmsCarryH>().Where(x=>x.carry_code==input.carry_code).FirstAsync();
|
||||||
|
|
||||||
|
|
||||||
|
prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||||
|
{
|
||||||
|
code = code,
|
||||||
|
station_id = input.station_id,
|
||||||
|
mo_task_id = moTask.id,
|
||||||
|
process_id = moTask.process_id,
|
||||||
|
equip_id = moTask.eqp_id,
|
||||||
|
workshop_id = workshop?.Id ?? "",
|
||||||
|
carry_id = carry.id,
|
||||||
|
workline_id = workline?.Id ?? "",
|
||||||
|
carry_code = input.carry_code,
|
||||||
|
mbom_process_id = moTask.mbom_process_id,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||||
|
};
|
||||||
|
|
||||||
|
if (input.details != null && input.details.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in input.details)
|
||||||
|
{
|
||||||
|
if (!inputMaterials.Contains(item.material_id) && !input.sure)
|
||||||
|
{
|
||||||
|
throw new Exception("存在不属于生产bom的投入物料,确认签收吗");
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(new PrdMaterialReceiptD
|
||||||
|
{
|
||||||
|
material_receipt_id = prdMaterialReceiptH.id,
|
||||||
|
material_id = item.material_id,
|
||||||
|
num = item.num,
|
||||||
|
batch = item.batch,
|
||||||
|
unit_id = item.unit_id,
|
||||||
|
carry_id = carry.id,
|
||||||
|
barcode = item.barcode,
|
||||||
|
is_all_feeding = 0,
|
||||||
|
member_carry_id = item.member_carry_id,
|
||||||
|
member_carry_code = item.member_carry_code,
|
||||||
|
feeding_num = 0,
|
||||||
|
supplier_id = item.supplier_id,
|
||||||
|
instock_time = item.instock_time,
|
||||||
|
check_conclusion = item.check_conclusion,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("没有签收物料");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||||
|
// await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
//签收后调用载具签收接口
|
//签收后调用载具签收接口
|
||||||
|
|||||||
@@ -735,7 +735,7 @@ namespace Tnb.ProductionMgr
|
|||||||
batch = a.batch,
|
batch = a.batch,
|
||||||
supplier_name = d.supplier_name,
|
supplier_name = d.supplier_name,
|
||||||
check_conclusion = c.check_conclusion,
|
check_conclusion = c.check_conclusion,
|
||||||
instock_time = c.instock_time.ToString(DbTimeFormat.SS),
|
instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS),
|
||||||
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS),
|
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS),
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
@@ -848,8 +848,8 @@ namespace Tnb.ProductionMgr
|
|||||||
batch = a.batch,
|
batch = a.batch,
|
||||||
supplier_name = d.supplier_name,
|
supplier_name = d.supplier_name,
|
||||||
check_conclusion = c.check_conclusion,
|
check_conclusion = c.check_conclusion,
|
||||||
instock_time = c.instock_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS),
|
||||||
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lastPrdReportIds != null && lastPrdReportIds.Count > 0)
|
if (lastPrdReportIds != null && lastPrdReportIds.Count > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user