短管挤出入库申请

This commit is contained in:
2023-11-06 16:20:10 +08:00
parent bab70ddd51
commit 9ee80fe00f
3 changed files with 135 additions and 7 deletions

View File

@@ -389,5 +389,115 @@ namespace Tnb.ProductionMgr
if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
}
[HttpPost]
public async Task<string> InstockTubeOne(PrdReport prdReport)
{
var db = _repository.AsSugarClient();
string location_code = "JMXHC-01";
string warehouse_id = "26103348825381";
PrdInstockH prdInstockH = null;
List<PrdInstockD> prdInstockDs = new List<PrdInstockD>() { };
DbResult<bool> result2 = new DbResult<bool>();
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 MESCreateInstockInput();
mesCreateInstockInput.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,
};
mesCreateInstockInput.instockds = new List<MESWmsInstockDInput>();
mesCreateInstockInput.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 Dictionary<string, object>()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
};
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header);
Log.Information(sendResult);
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
if (authResponse.code != 200 || !authResponse.data.ObjToBool())
{
throw Oops.Bah(authResponse.msg);
}
else
{
result2 = await db.Ado.UseTranAsync(async () =>
{
await _repository.InsertAsync(prdInstockH);
if (prdInstockDs.Count > 0)
{
await db.Insertable<PrdInstockD>(prdInstockDs).ExecuteCommandAsync();
}
});
}
}
return result2.IsSuccess ? "true" : "false";
}
}
}