物料出库申请 + bug
This commit is contained in:
@@ -208,11 +208,6 @@ public partial class EqpEquipment : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? qrcode { get; set; }
|
public string? qrcode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 挤出件类型
|
|
||||||
/// </summary>
|
|
||||||
public string? tube { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 入库库位id
|
/// 入库库位id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto
|
||||||
|
{
|
||||||
|
public class MaterialOutstockInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 目标库位编号
|
||||||
|
/// </summary>
|
||||||
|
public string location_code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// 所属工位
|
||||||
|
/// </summary>
|
||||||
|
public string? workstation_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_task_id { get; set; }
|
||||||
|
|
||||||
|
public List<MaterialOutstockDInput> details { get; set; } = new List<MaterialOutstockDInput>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MaterialOutstockDInput
|
||||||
|
{
|
||||||
|
public string material_id { get; set; }
|
||||||
|
public string material_code { get; set; }
|
||||||
|
public string material_name { get; set; }
|
||||||
|
public decimal num { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -127,10 +127,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? act_end_date { get; set; }
|
public string? act_end_date { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 挤出件类型
|
|
||||||
/// </summary>
|
|
||||||
public string? tube { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 最小包装
|
/// 最小包装
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? minpacking { get; set; }
|
public decimal? minpacking { get; set; }
|
||||||
@@ -154,5 +150,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
/// 称重点位名称
|
/// 称重点位名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? weight_name { get; set; }
|
public string? weight_name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料分类ID
|
||||||
|
/// </summary>
|
||||||
|
public string category_id { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,5 +12,11 @@ namespace Tnb.ProductionMgr.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<dynamic> GeneralOutstock(GeneralOutstockInput input);
|
public Task<dynamic> GeneralOutstock(GeneralOutstockInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料出库申请
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<dynamic> MaterialOutstock(MaterialOutstockInput input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1444,6 +1444,7 @@ namespace Tnb.ProductionMgr
|
|||||||
ISqlSugarClient db = _repository.AsSugarClient();
|
ISqlSugarClient db = _repository.AsSugarClient();
|
||||||
PrdMoTask? prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
PrdMoTask? prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||||
EqpEquipment equip = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
EqpEquipment equip = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
||||||
|
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
|
||||||
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
@@ -1709,10 +1710,14 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
if (equip.tube == "1")
|
if (!string.IsNullOrEmpty(basMaterial.category_id))
|
||||||
{
|
{
|
||||||
string resultMsg = await _prdInstockService.InstockTubeOne(report);
|
string[] arr = JsonConvert.DeserializeObject<string[]>(basMaterial.category_id);
|
||||||
return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
|
if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请
|
||||||
|
{
|
||||||
|
string resultMsg = await _prdInstockService.InstockTubeOne(report);
|
||||||
|
return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,5 +243,119 @@ namespace Tnb.ProductionMgr
|
|||||||
throw Oops.Bah(e.Message);
|
throw Oops.Bah(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> MaterialOutstock(MaterialOutstockInput materialOutstockInput)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
string warehouse_id = "26103348825381";//二楼缓存仓
|
||||||
|
|
||||||
|
MESCreateOutstockInput input = new MESCreateOutstockInput();
|
||||||
|
input.outstock = new MESWmsOutstockHInput();
|
||||||
|
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||||
|
|
||||||
|
PrdMoTask prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x=>x.id==materialOutstockInput.mo_task_id);
|
||||||
|
BasLocation location = await db.Queryable<BasLocation>().Where(x=>x.location_code==materialOutstockInput.location_code).FirstAsync();
|
||||||
|
if (location == null) throw Oops.Bah("未找到库位");
|
||||||
|
string locationId = location.id;
|
||||||
|
|
||||||
|
input.outstock.bill_type = DictConst.SHENGCHANLINGLIAO;
|
||||||
|
// input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now;
|
||||||
|
input.outstock.bill_date = DateTime.Now;
|
||||||
|
input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId;
|
||||||
|
input.outstock.warehouse_id = warehouse_id;
|
||||||
|
input.outstock.create_id = _userManager.UserId;
|
||||||
|
input.outstock.location_code = location?.location_code ?? "";
|
||||||
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(materialOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
|
||||||
|
List<string> materialIds = materialOutstockInput.details.Select(x => x.material_id).ToList();
|
||||||
|
List<BasMaterial> basMaterials = await db.Queryable<BasMaterial>().Where(x=>materialIds.Contains(x.id)).ToListAsync();
|
||||||
|
Dictionary<string,object> unitIdDic = await db.Queryable<BasMaterial>()
|
||||||
|
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit)
|
||||||
|
.LeftJoin<DictionaryDataEntity>((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode)
|
||||||
|
.Where((a,b,c)=>materialIds.Contains(a.id))
|
||||||
|
.Select((a, b, c) => new
|
||||||
|
{
|
||||||
|
key = a.id,
|
||||||
|
value = c.Id
|
||||||
|
})
|
||||||
|
.ToDictionaryAsync(x => x.key, x => x.value);
|
||||||
|
|
||||||
|
foreach (var item in materialOutstockInput.details)
|
||||||
|
{
|
||||||
|
input.outstockDs.Add(new MESWmsOutstockDInput()
|
||||||
|
{
|
||||||
|
material_id = item.material_id,
|
||||||
|
material_code = basMaterials.First(x=>x.id==item.material_id).code,
|
||||||
|
pr_qty = item.num,
|
||||||
|
unit_id = unitIdDic[item.material_id].ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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_OUTSTOCK,JsonConvert.SerializeObject(input),header);
|
||||||
|
Log.Information(sendResult);
|
||||||
|
|
||||||
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
|
if (authResponse.code != 200)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(authResponse.msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrdOutstockH prdOutstockH = new PrdOutstockH();
|
||||||
|
prdOutstockH.bill_type = DictConst.SHENGCHANLINGLIAO;
|
||||||
|
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.workstation = materialOutstockInput.workstation_id;
|
||||||
|
prdOutstockH.workline = workline?.Id ?? "";
|
||||||
|
|
||||||
|
List<PrdOutstockD> prdOutstockDs = new List<PrdOutstockD>();
|
||||||
|
foreach (var item in materialOutstockInput.details)
|
||||||
|
{
|
||||||
|
prdOutstockDs.Add(new PrdOutstockD()
|
||||||
|
{
|
||||||
|
material_id = item.material_id,
|
||||||
|
material_code = basMaterials.First(x=>x.id==item.material_id).code,
|
||||||
|
material_name = basMaterials.First(x=>x.id==item.material_id).name,
|
||||||
|
pr_qty = item.num,
|
||||||
|
unit_id = unitIdDic[item.material_id].ToString(),
|
||||||
|
outstock_id = prdOutstockH.id,
|
||||||
|
source_id = prdMoTask.mo_task_code
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
await _repository.InsertAsync(prdOutstockH);
|
||||||
|
if (prdOutstockDs.Count > 0)
|
||||||
|
{
|
||||||
|
await db.Insertable<PrdOutstockD>(prdOutstockDs).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!result.IsSuccess)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(result.ErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
Log.Error(e.Message);
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,12 +461,12 @@ namespace Tnb.ProductionMgr
|
|||||||
act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
|
act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
|
||||||
act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS),
|
act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS),
|
||||||
plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS),
|
plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS),
|
||||||
tube = f.tube,
|
|
||||||
minpacking = b.minpacking,
|
minpacking = b.minpacking,
|
||||||
main_num = k.number_of_primary_unit,
|
main_num = k.number_of_primary_unit,
|
||||||
deputy_num = k.number_of_auxiliary_unit,
|
deputy_num = k.number_of_auxiliary_unit,
|
||||||
third_equip_code = f.third_equip_code,
|
third_equip_code = f.third_equip_code,
|
||||||
weight_name = l.label_name
|
weight_name = l.label_name,
|
||||||
|
category_id = b.category_id
|
||||||
})
|
})
|
||||||
.MergeTable()
|
.MergeTable()
|
||||||
.OrderBy($"{input.sidx} {input.sort}")
|
.OrderBy($"{input.sidx} {input.sort}")
|
||||||
|
|||||||
Reference in New Issue
Block a user