bug
This commit is contained in:
@@ -30,7 +30,7 @@ public static class DictConst
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注塑工单
|
/// 注塑工单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string PrdMoTypeZS = "25572555259157";
|
public const string PrdMoTypeZS = "25019163616533";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 挤出工单
|
/// 挤出工单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
|
|
||||||
public string? act_end_date { get; set; }
|
public string? act_end_date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 类型 1注塑挤出 2 组装包装
|
||||||
|
/// </summary>
|
||||||
|
public int type { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -137,7 +142,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PrdMoReverseFromMaterialOutput
|
public class PrdMoReverseFromMaterialput
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料ID
|
/// 物料ID
|
||||||
@@ -237,4 +242,80 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
public string process_name { get; set; }
|
public string process_name { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PrdMoReverseFromOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料ID
|
||||||
|
/// </summary>
|
||||||
|
public string material_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string material_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string material_name { get; set; }
|
||||||
|
/// 条码数量
|
||||||
|
/// </summary>
|
||||||
|
public decimal barcode_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 批次
|
||||||
|
/// </summary>
|
||||||
|
public string code_batch { get; set;}
|
||||||
|
/// <summary>
|
||||||
|
/// 单位ID
|
||||||
|
/// </summary>
|
||||||
|
public string unit_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 入库单号
|
||||||
|
/// </summary>
|
||||||
|
public string in_bill_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 入库时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime instock_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 出库单号
|
||||||
|
/// </summary>
|
||||||
|
public string out_bill_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 出库时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? outstock_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库ID
|
||||||
|
/// </summary>
|
||||||
|
public string warehouse_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 仓库名称
|
||||||
|
/// </summary>
|
||||||
|
public string warehouse_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 库位ID
|
||||||
|
/// </summary>
|
||||||
|
public string location_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 库位编号
|
||||||
|
/// </summary>
|
||||||
|
public string location_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料状态
|
||||||
|
/// </summary>
|
||||||
|
public string material_status { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 销售出库单号
|
||||||
|
/// </summary>
|
||||||
|
public string sale_outstock_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客户名称
|
||||||
|
/// </summary>
|
||||||
|
public string customer_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 发货时间
|
||||||
|
/// </summary>
|
||||||
|
public string delivery_time { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -407,6 +407,7 @@ namespace Tnb.ProductionMgr
|
|||||||
id = a.id,
|
id = a.id,
|
||||||
mo_code = a.mo_code,
|
mo_code = a.mo_code,
|
||||||
material_id = a.material_id,
|
material_id = a.material_id,
|
||||||
|
type = (a.mo_type==DictConst.PrdMoTypeZS || a.mo_type==DictConst.PrdMoTypeJC ) ? 1 : 2,
|
||||||
material_code = b.code,
|
material_code = b.code,
|
||||||
material_name = b.name,
|
material_name = b.name,
|
||||||
material_standard = b.material_standard,
|
material_standard = b.material_standard,
|
||||||
@@ -870,7 +871,7 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PageResult<PrdMoReverseFromMaterialOutput> output = JsonConvert.DeserializeObject<PageResult<PrdMoReverseFromMaterialOutput>>(authResponse.data.ToString(),new Tnb.Common.Utils.DateTimeJsonConverter());
|
PageResult<PrdMoReverseFromMaterialput> output = JsonConvert.DeserializeObject<PageResult<PrdMoReverseFromMaterialput>>(authResponse.data.ToString(),new Tnb.Common.Utils.DateTimeJsonConverter());
|
||||||
if (output.list != null && output.list.Count > 0)
|
if (output.list != null && output.list.Count > 0)
|
||||||
{
|
{
|
||||||
output.list[0].feeding_num = await _db.Queryable<PrdMaterialReceiptD>()
|
output.list[0].feeding_num = await _db.Queryable<PrdMaterialReceiptD>()
|
||||||
@@ -931,7 +932,7 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料反向追溯查出信息
|
/// 物料反向追溯产出信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dic"></param>
|
/// <param name="dic"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -939,8 +940,123 @@ namespace Tnb.ProductionMgr
|
|||||||
public async Task<dynamic> PrdMoReverseFromOutInfo(Dictionary<string, string> dic)
|
public async Task<dynamic> PrdMoReverseFromOutInfo(Dictionary<string, string> dic)
|
||||||
{
|
{
|
||||||
string feeding_detail_id = dic.ContainsKey("feeding_detail_id") ? dic["feeding_detail_id"] : "";
|
string feeding_detail_id = dic.ContainsKey("feeding_detail_id") ? dic["feeding_detail_id"] : "";
|
||||||
|
PrdFeedingD prdFeedingD = await _db.Queryable<PrdFeedingD>().FirstAsync(x => x.id == feeding_detail_id);
|
||||||
|
if(prdFeedingD.use_num<=0) return Array.Empty<string>();
|
||||||
|
PrdFeedingH prdFeedingH = await _db.Queryable<PrdFeedingH>().FirstAsync(x => x.id == prdFeedingD.feeding_id);
|
||||||
|
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().FirstAsync(x => x.id == prdFeedingH.mo_task_id);
|
||||||
|
List<PrdFeedingD> prdFeedingDs = await _db.Queryable<PrdFeedingD>()
|
||||||
|
.LeftJoin<PrdFeedingH>((a, b) => a.feeding_id == b.id)
|
||||||
|
.Where((a, b) => a.material_id == prdFeedingD.material_id && b.mo_task_id == prdFeedingH.mo_task_id && b.create_time<=prdFeedingH.create_time && a.id!=prdFeedingD.id)
|
||||||
|
.Select((a, b) => a).ToListAsync();
|
||||||
|
decimal beforeIn = prdFeedingDs.Sum(x => x.num);
|
||||||
|
List<string> reportIds = new List<string>();
|
||||||
|
if (prdMoTask.schedule_type == 1)
|
||||||
|
{
|
||||||
|
BasEbomH basEbomH = await _db.Queryable<BasEbomH>().SingleAsync(x => x.id == prdMoTask.ebom_id);
|
||||||
|
List<BasEbomD> basEbomDs = await _db.Queryable<BasEbomD>().Where(x => x.ebom_id == prdMoTask.ebom_id).ToListAsync();
|
||||||
|
BasEbomD basEbomD = basEbomDs.Where(x => x.material_id == prdFeedingD.material_id).FirstOrDefault();
|
||||||
|
if (basEbomD != null)
|
||||||
|
{
|
||||||
|
List<PrdReport> prdReports = await _db.Queryable<PrdReport>().Where(x => x.mo_task_id == prdMoTask.id).OrderBy(x=>x.create_time).ToListAsync();
|
||||||
|
if (prdReports != null && prdReports.Count > 0)
|
||||||
|
{
|
||||||
|
bool flag = true;
|
||||||
|
decimal residueNeed = 0;
|
||||||
|
foreach (var prdReport in prdReports)
|
||||||
|
{
|
||||||
|
var needNum = (prdReport.reported_qty ?? 0) / basEbomH.quantity * basEbomD.quantity;
|
||||||
|
if (beforeIn - needNum >= 0)
|
||||||
|
{
|
||||||
|
beforeIn -= needNum;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
if (prdFeedingD.num > needNum - beforeIn)
|
||||||
|
{
|
||||||
|
residueNeed = prdFeedingD.num - (needNum - beforeIn);
|
||||||
|
reportIds.Add(prdReport.id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reportIds.Add(prdReport.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
flag = false;
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (residueNeed - needNum > 0)
|
||||||
|
{
|
||||||
|
residueNeed -= needNum;
|
||||||
|
reportIds.Add(prdReport.id);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
reportIds.Add(prdReport.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<string> barCodes = await _db.Queryable<PrdReport>().Where(x=>reportIds.Contains(x.id)).Select(x=>x.barcode).ToListAsync();
|
||||||
|
|
||||||
|
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"]
|
||||||
|
};
|
||||||
|
Dictionary<string, object> postData = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
["org_id"] = _userManager.GetUserInfo().Result.organizeId,
|
||||||
|
["barcode"] = barCodes,
|
||||||
|
["currentPage"] = 1,
|
||||||
|
["pageSize"] = int.MaxValue,
|
||||||
|
};
|
||||||
|
var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_FETCH_IN_OUT_STOCK_INFO_BY_BAR_CODE,JsonConvert.SerializeObject(postData),header);
|
||||||
|
Log.Information(sendResult);
|
||||||
|
|
||||||
|
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||||
|
if (authResponse.code != 200)
|
||||||
|
{
|
||||||
|
throw Oops.Bah(authResponse.msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().FirstAsync(x => x.id == prdMoTask.material_id);
|
||||||
|
PageResult<PrdMoReverseFromOutput> output = JsonConvert.DeserializeObject<PageResult<PrdMoReverseFromOutput>>(authResponse.data.ToString(),new Tnb.Common.Utils.DateTimeJsonConverter());
|
||||||
|
if (output.list != null && output.list.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in output.list)
|
||||||
|
{
|
||||||
|
item.material_name = basMaterial.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output.list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// var queryable = _db.Queryable<PrdMoTask>()
|
||||||
|
// .LeftJoin<BasMbomProcess>((a,b)=>a.mbom_process_id==b.id)
|
||||||
|
// .LeftJoin<PrdReport>((a,b,c)=>a.id==c.mo_task_id)
|
||||||
|
// .Where((a,b,c)=>a.)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user