物料签收
This commit is contained in:
@@ -34,12 +34,13 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IOrganizeService _organizeService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||
|
||||
public PrdMaterialReceiptService(
|
||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||
IBillRullService billRullService,
|
||||
IOrganizeService organizeService,
|
||||
IPrdMoTaskService prdMoTaskService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
@@ -47,6 +48,7 @@ namespace Tnb.ProductionMgr
|
||||
_userManager = userManager;
|
||||
_organizeService = organizeService;
|
||||
_billRullService = billRullService;
|
||||
_prdMoTaskService = prdMoTaskService;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,9 +172,9 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
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
|
||||
@@ -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)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
|
||||
Reference in New Issue
Block a user