This commit is contained in:
2023-11-07 14:58:43 +08:00
parent b7ae473d8e
commit 64bb0ff680
9 changed files with 175 additions and 5 deletions

View File

@@ -263,6 +263,7 @@ namespace Tnb.ProductionMgr
{
string equip_code = inut.equip_code;
string as_location_code = inut.as_location_code;
string warehouse_id = "2";
if (!string.IsNullOrEmpty(equip_code))
{
throw Oops.Bah("请传机台号");
@@ -315,7 +316,8 @@ namespace Tnb.ProductionMgr
workline_id = workline?.Id ?? "",
workshop_id = workshop?.Id ?? "",
org_id = _userManager.GetUserInfo().Result.organizeId,
warehouse_id = basLocation?.wh_id,
// warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id,
status = 0,
};
@@ -341,7 +343,8 @@ namespace Tnb.ProductionMgr
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = basLocation?.wh_id,
// warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
@@ -397,8 +400,118 @@ namespace Tnb.ProductionMgr
public async Task<string> InstockTubeOne(PrdReport prdReport)
{
ISqlSugarClient db = _repository.AsSugarClient();
string location_code = "JMXHC-01";
string warehouse_id = "26103348825381";
string location_code = "ZCR01";//todo 短管挤出件目标库位之后改
string warehouse_id = "2";
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode);
prdInstockH = new PrdInstockH()
{
bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now,
create_id = _userManager.UserId,
location_code = location_code,
carry_code = prdReport.material_box_code,
is_check = 1,
station_id = prdReport.station,
workline_id = workline?.Id ?? "",
workshop_id = workshop?.Id ?? "",
org_id = _userManager.GetUserInfo().Result.organizeId,
warehouse_id = warehouse_id,
status = 0,
};
prdInstockDs.Add(new PrdInstockD()
{
instock_id = prdInstockH.id,
report_id = prdReport.create_id,
material_id = prdReport.material_id,
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
quantity = (int)prdReport.reported_qty,
});
});
if (result.IsSuccess)
{
MESCreateInstockInput mesCreateInstockInput = new()
{
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
carry_code = prdReport.material_box_code,
location_code = location_code,
is_check = 1,
},
instockds = new List<MESWmsInstockDInput>(),
instockcodes = new List<MESWmsInstockCodeInput>()
};
mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
{
material_id = prdReport.material_id,
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
code_batch = prdReport.barcode,
pr_qty = (int)prdReport.reported_qty,
});
mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
{
material_id = prdReport.material_id,
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
codeqty = (int)prdReport.reported_qty,
});
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_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
result2 = authResponse.code != 200 || !authResponse.data.ObjToBool()
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
_ = await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
_ = await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
return result2.IsSuccess ? "true" : "false";
}
/// <summary>
/// 长管管挤出入库申请
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> InstockTubeThree(PrdReport prdReport)
{
ISqlSugarClient db = _repository.AsSugarClient();
string location_code = prdReport.location_code;
string warehouse_id = "27209786980373";//长件挤出缓存仓
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };