Bug
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Tnb.ProductionMgr
|
|||||||
private readonly IBillRullService _billRullService;
|
private readonly IBillRullService _billRullService;
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
public PrdOutstockService(ISqlSugarRepository<PrdOutstockH> repository, IOrganizeService organizeService, IBillRullService billRullService,IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
|
public PrdOutstockService(ISqlSugarRepository<PrdOutstockH> repository, IOrganizeService organizeService, IBillRullService billRullService, IRunService runService, IUserManager userManager, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
@@ -98,7 +98,7 @@ namespace Tnb.ProductionMgr
|
|||||||
string domain = _userManager.Domain;
|
string domain = _userManager.Domain;
|
||||||
Dictionary<string, object> header = new()
|
Dictionary<string, object> header = new()
|
||||||
{
|
{
|
||||||
["Authorization"] = App.HttpContext!=null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
||||||
};
|
};
|
||||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||||
Log.Information(sendResult);
|
Log.Information(sendResult);
|
||||||
@@ -190,7 +190,7 @@ namespace Tnb.ProductionMgr
|
|||||||
string domain = _userManager.Domain;
|
string domain = _userManager.Domain;
|
||||||
Dictionary<string, object> header = new()
|
Dictionary<string, object> header = new()
|
||||||
{
|
{
|
||||||
["Authorization"] = App.HttpContext!=null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
||||||
};
|
};
|
||||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||||
Log.Information(sendResult);
|
Log.Information(sendResult);
|
||||||
@@ -267,8 +267,8 @@ namespace Tnb.ProductionMgr
|
|||||||
input.outstock = new MESWmsOutstockHInput();
|
input.outstock = new MESWmsOutstockHInput();
|
||||||
input.outstockDs = new List<MESWmsOutstockDInput>();
|
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||||
|
|
||||||
PrdMoTask prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x=>x.id==materialOutstockInput.mo_task_id);
|
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();
|
BasLocation location = await db.Queryable<BasLocation>().Where(x => x.location_code == materialOutstockInput.location_code).FirstAsync();
|
||||||
if (location == null) throw Oops.Bah("未找到库位");
|
if (location == null) throw Oops.Bah("未找到库位");
|
||||||
string locationId = location.id;
|
string locationId = location.id;
|
||||||
|
|
||||||
@@ -289,11 +289,11 @@ namespace Tnb.ProductionMgr
|
|||||||
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(materialOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(materialOutstockInput.workstation_id, DictConst.RegionCategoryWorklineCode);
|
||||||
|
|
||||||
List<string> materialIds = materialOutstockInput.details.Select(x => x.material_id).ToList();
|
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();
|
List<BasMaterial> basMaterials = await db.Queryable<BasMaterial>().Where(x => materialIds.Contains(x.id)).ToListAsync();
|
||||||
Dictionary<string,object> unitIdDic = await db.Queryable<BasMaterial>()
|
Dictionary<string, object> unitIdDic = await db.Queryable<BasMaterial>()
|
||||||
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit)
|
.LeftJoin<DictionaryTypeEntity>((a, b) => b.EnCode == DictConst.MeasurementUnit)
|
||||||
.LeftJoin<DictionaryDataEntity>((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode)
|
.LeftJoin<DictionaryDataEntity>((a, b, c) => b.Id == c.DictionaryTypeId && a.unit_id == c.EnCode)
|
||||||
.Where((a,b,c)=>materialIds.Contains(a.id))
|
.Where((a, b, c) => materialIds.Contains(a.id))
|
||||||
.Select((a, b, c) => new
|
.Select((a, b, c) => new
|
||||||
{
|
{
|
||||||
key = a.id,
|
key = a.id,
|
||||||
@@ -306,7 +306,7 @@ namespace Tnb.ProductionMgr
|
|||||||
input.outstockDs.Add(new MESWmsOutstockDInput()
|
input.outstockDs.Add(new MESWmsOutstockDInput()
|
||||||
{
|
{
|
||||||
material_id = item.material_id,
|
material_id = item.material_id,
|
||||||
material_code = basMaterials.First(x=>x.id==item.material_id).code,
|
material_code = basMaterials.First(x => x.id == item.material_id).code,
|
||||||
pr_qty = item.num,
|
pr_qty = item.num,
|
||||||
unit_id = unitIdDic[item.material_id].ToString()
|
unit_id = unitIdDic[item.material_id].ToString()
|
||||||
});
|
});
|
||||||
@@ -315,9 +315,9 @@ namespace Tnb.ProductionMgr
|
|||||||
string domain = _userManager.Domain;
|
string domain = _userManager.Domain;
|
||||||
Dictionary<string, object> header = new Dictionary<string, object>()
|
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
["Authorization"] = App.HttpContext!=null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
|
||||||
};
|
};
|
||||||
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK,JsonConvert.SerializeObject(input),header);
|
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK, JsonConvert.SerializeObject(input), header);
|
||||||
Log.Information(sendResult);
|
Log.Information(sendResult);
|
||||||
|
|
||||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
@@ -346,8 +346,8 @@ namespace Tnb.ProductionMgr
|
|||||||
prdOutstockDs.Add(new PrdOutstockD()
|
prdOutstockDs.Add(new PrdOutstockD()
|
||||||
{
|
{
|
||||||
material_id = item.material_id,
|
material_id = item.material_id,
|
||||||
material_code = basMaterials.First(x=>x.id==item.material_id).code,
|
material_code = basMaterials.First(x => x.id == item.material_id).code,
|
||||||
material_name = basMaterials.First(x=>x.id==item.material_id).name,
|
material_name = basMaterials.First(x => x.id == item.material_id).name,
|
||||||
pr_qty = item.num,
|
pr_qty = item.num,
|
||||||
unit_id = unitIdDic[item.material_id].ToString(),
|
unit_id = unitIdDic[item.material_id].ToString(),
|
||||||
outstock_id = prdOutstockH.id,
|
outstock_id = prdOutstockH.id,
|
||||||
@@ -355,7 +355,132 @@ namespace Tnb.ProductionMgr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> MaterialOutstockTest(MaterialOutstockInput materialOutstockInput)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var db = _repository.AsSugarClient();
|
||||||
|
string warehouse_id = "1";//一楼原材料仓
|
||||||
|
|
||||||
|
MESCreateOutstockInput input = new MESCreateOutstockInput();
|
||||||
|
input.outstock = new MESWmsOutstockHInput();
|
||||||
|
input.outstockDs = new List<MESWmsOutstockDInput>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
PrdOutstockH prdOutstockH = new()
|
||||||
|
{
|
||||||
|
bill_code = await _billRullService.GetBillNumber(CodeTemplateConst.PRDOUTSTOCK_CODE),
|
||||||
|
};
|
||||||
|
|
||||||
|
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 ?? "";
|
||||||
|
input.outstock.source_code = prdOutstockH.bill_code;
|
||||||
|
input.outstock.source_id = prdOutstockH.id;
|
||||||
|
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 = _userManager.Domain;
|
||||||
|
Dictionary<string, object> header = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
["Authorization"] = App.HttpContext != null ? 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.bill_type = DictConst.SHENGCHANLINGLIAO;
|
||||||
|
prdOutstockH.type = "2";
|
||||||
|
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.create_time = DateTime.Now;
|
||||||
|
prdOutstockH.workstation_id = materialOutstockInput.workstation_id;
|
||||||
|
prdOutstockH.workline = workline?.Id ?? "";
|
||||||
|
prdOutstockH.status = DictConst.OUTSTOCKSTATUSADD;
|
||||||
|
prdOutstockH.mo_task_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 = ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
await _repository.InsertAsync(prdOutstockH);
|
await _repository.InsertAsync(prdOutstockH);
|
||||||
if (prdOutstockDs.Count > 0)
|
if (prdOutstockDs.Count > 0)
|
||||||
@@ -381,3 +506,4 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ namespace Tnb.ProductionMgr
|
|||||||
//扫码入库
|
//扫码入库
|
||||||
private void ScanInStock(object state)
|
private void ScanInStock(object state)
|
||||||
{
|
{
|
||||||
var carry_code = "carry_code";
|
var carry_code = "carry_code";//从数采读取
|
||||||
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == carry_code);
|
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == carry_code);
|
||||||
if (carry != null)
|
if (carry != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (carryCodesPart?.Count > 0)
|
if (carryCodesPart?.Count > 0)
|
||||||
{
|
{
|
||||||
decimal codeQty = carryCodes.Sum(x => x.codeqty);
|
decimal codeQty = carryCodesPart.Sum(x => x.codeqty);
|
||||||
if (codeQty < os.pr_qty)
|
if (codeQty < os.pr_qty)
|
||||||
{
|
{
|
||||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||||
@@ -708,12 +708,22 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
List<WmsPointH> points = new List<WmsPointH>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
points.Add(sPoint);
|
||||||
|
points.Add(ePoint);
|
||||||
|
|
||||||
|
}
|
||||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||||
if (points?.Count > 0)
|
if (points?.Count > 0)
|
||||||
{
|
{
|
||||||
if (points.Count <= 2)
|
if (points.Count < 2)
|
||||||
{
|
{
|
||||||
throw new AppFriendlyException("该路径不存在", 500);
|
throw new AppFriendlyException("该路径不存在", 500);
|
||||||
}
|
}
|
||||||
@@ -730,6 +740,11 @@ namespace Tnb.WarehouseMgr
|
|||||||
startlocation_code = sPoint?.location_code ?? string.Empty,
|
startlocation_code = sPoint?.location_code ?? string.Empty,
|
||||||
endlocation_id = ePoint?.location_id ?? string.Empty,
|
endlocation_id = ePoint?.location_id ?? string.Empty,
|
||||||
endlocation_code = ePoint?.location_code ?? string.Empty,
|
endlocation_code = ePoint?.location_code ?? string.Empty,
|
||||||
|
startpoint_id = sPoint.id,
|
||||||
|
startpoint_code = sPoint.point_code,
|
||||||
|
endpoint_id = ePoint.id,
|
||||||
|
endpoint_code = ePoint.point_code,
|
||||||
|
|
||||||
start_floor = sPoint?.floor.ToString(),
|
start_floor = sPoint?.floor.ToString(),
|
||||||
end_floor = ePoint?.floor.ToString(),
|
end_floor = ePoint?.floor.ToString(),
|
||||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||||
|
|||||||
@@ -117,11 +117,22 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
if (sPoint != null && ePoint != null)
|
||||||
{
|
{
|
||||||
List<WmsPointH> points = await _wareHouseService!.PathAlgorithms(sPoint.id, ePoint.id);
|
List<WmsPointH> points=new List<WmsPointH>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
points = await _wareHouseService!.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
points.Add(sPoint);
|
||||||
|
points.Add(ePoint);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||||
if (points?.Count > 0)
|
if (points?.Count > 0)
|
||||||
{
|
{
|
||||||
if (points.Count <= 2)
|
if (points.Count < 2)
|
||||||
{
|
{
|
||||||
throw new AppFriendlyException("该路径不存在", 500);
|
throw new AppFriendlyException("该路径不存在", 500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user