This commit is contained in:
yang.lee
2023-11-23 10:43:31 +08:00
6 changed files with 222 additions and 35 deletions

View File

@@ -88,5 +88,10 @@ public partial class EqpDaq : BaseEntity<string>
/// 流程引擎Id
/// </summary>
public string? f_flowid { get; set; }
/// <summary>
/// 库位号
/// </summary>
public string? location_code { get; set; }
}

View File

@@ -99,9 +99,14 @@
public string? station { get; set; }
/// <summary>
/// 料箱二维
/// 料箱
/// </summary>
public string material_box_qrcode { get; set; }
public string material_box_code { get; set; }
/// <summary>
/// 入库库位
/// </summary>
public string location_code { get; set; }
}
}

View File

@@ -131,7 +131,7 @@ public partial class PrdReport : BaseEntity<string>
public string material_box_code { get; set; }
/// <summary>
/// 长管挤出入库库位
/// 入库库位
/// </summary>
public string location_code { get; set; }

View File

@@ -30,12 +30,20 @@ namespace Tnb.ProductionMgr.Interfaces
/// <returns></returns>
public Task<dynamic> InstockTypeOne(InstockInput input);
// /// <summary>
// /// 短管挤出入库申请
// /// </summary>
// /// <param name="input"></param>
// /// <returns></returns>
// public Task<string> InstockTubeOne(PrdReport prdReport);
/// <summary>
/// 短管挤出入库申请
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public Task<string> InstockTubeOne(PrdReport prdReport);
public Task<string> InstockTubeOne(InstockInput input);
/// <summary>
/// 长管管挤出入库申请

View File

@@ -317,6 +317,7 @@ namespace Tnb.ProductionMgr
throw Oops.Bah("未找到提报记录");
}
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
@@ -421,17 +422,176 @@ namespace Tnb.ProductionMgr
return !result2.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result2.IsSuccess ? "申请成功" : result2.ErrorMessage);
}
// [HttpPost]
// public async Task<string> InstockTubeOne(PrdReport prdReport)
// {
// ISqlSugarClient db = _repository.AsSugarClient();
// 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);
// string create_id = prdReport.create_id;
// UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id);
// string org_id = user.OrganizeId;
// 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 = create_id,
// 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 = org_id,
// 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.mo_task_code,
// quantity = (int)prdReport.reported_qty,
// });
// });
//
// if (result.IsSuccess)
// {
// MESCreateInstockInput mesCreateInstockInput = new()
// {
// instock = new MESWmsInstockHInput()
// {
// org_id = org_id,
// bill_date = DateTime.Now,
// bill_type = DictConst.CHANCHENGPINRUKUDAN,
// warehouse_id = warehouse_id,
// source_id = prdInstockH.id,
// create_id = create_id,
// 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.mo_task_code,
// codeqty = (int)prdReport.reported_qty,
// });
// // string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
// string domain = "http://tnb.tuotong-tech.com";
// 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 || !(bool)authResponse.data
// ? 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";
// }
[HttpPost]
public async Task<string> InstockTubeOne(PrdReport prdReport)
public async Task<string> InstockTubeOne(InstockInput input)
{
string equip_code = input.equip_code;
string label_code = input.label_code;
if (string.IsNullOrEmpty(equip_code))
{
throw Oops.Bah("请传机台号");
}
if (string.IsNullOrEmpty(label_code))
{
throw Oops.Bah("请传标签号");
}
ISqlSugarClient db = _repository.AsSugarClient();
string location_code = "ZCR01";//todo 短管挤出件目标库位之后改
// string location_code = "ZCR01";//todo 短管挤出件目标库位之后改
string warehouse_id = "2";
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
EqpEquipment equipment = null;
try
{
equipment = await db.Queryable<EqpEquipment>()
.LeftJoin<EqpDaq>((x,y)=>x.id==y.equip_id)
.Where((x,y) => y.equip_code==equip_code && y.label_name==label_code && y.label_point=="提报装箱称重点位")
.Select((x,y)=>x)
.FirstAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
if (equipment == null)
{
throw Oops.Bah("未找到机台");
}
EqpDaq daq = await db.Queryable<EqpDaq>().Where(x =>
x.equip_id == equipment.id && x.label_name == label_code && x.label_point == "提报装箱称重点位").FirstAsync();
if (daq == null)
{
throw Oops.Bah("未找到数采信号");
}
string location_code = daq.location_code;
PrdReport prdReport = await db.Queryable<PrdReport>()
.Where(x => x.equip_id == equipment.id && x.status == 0).OrderByDescending(x => x.create_time)
.FirstAsync();
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
string create_id = prdReport.create_id;
UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id);
string org_id = user.OrganizeId;
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
@@ -441,14 +601,14 @@ namespace Tnb.ProductionMgr
{
bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now,
create_id = _userManager.UserId,
create_id = create_id,
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,
org_id = org_id,
warehouse_id = warehouse_id,
status = 0,
};
@@ -461,7 +621,7 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
quantity = (int)prdReport.reported_qty,
});
});
@@ -472,12 +632,12 @@ namespace Tnb.ProductionMgr
{
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
org_id = org_id,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
create_id = create_id,
carry_code = prdReport.material_box_code,
location_code = location_code,
is_check = 1,
@@ -500,19 +660,19 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
codeqty = (int)prdReport.reported_qty,
});
// string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
string domain = "http://tnb.tuotong-tech.com";
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
// ["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()
result2 = authResponse.code != 200 || !(bool)authResponse.data
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
@@ -543,6 +703,9 @@ namespace Tnb.ProductionMgr
List<PrdInstockD> prdInstockDs = new() { };
DbResult<bool> result2 = new();
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdReport.material_id);
string create_id = prdReport.create_id;
UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id);
string org_id = user.OrganizeId;
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode);
@@ -552,14 +715,14 @@ namespace Tnb.ProductionMgr
{
bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now,
create_id = _userManager.UserId,
create_id = create_id,
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,
org_id = org_id,
warehouse_id = warehouse_id,
status = 0,
};
@@ -572,7 +735,7 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
quantity = (int)prdReport.reported_qty,
});
});
@@ -583,12 +746,12 @@ namespace Tnb.ProductionMgr
{
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
org_id = org_id,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
create_id = create_id,
carry_code = prdReport.material_box_code,
location_code = location_code,
is_check = 1,
@@ -601,7 +764,7 @@ namespace Tnb.ProductionMgr
material_id = prdReport.material_id,
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
code_batch = prdReport.barcode,
code_batch = prdReport.mo_task_code,
pr_qty = (int)prdReport.reported_qty,
});
@@ -611,19 +774,19 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
codeqty = (int)prdReport.reported_qty,
});
// string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
string domain = "http://tnb.tuotong-tech.com";
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
// ["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()
result2 = authResponse.code != 200 || !(bool)authResponse.data
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{
@@ -708,10 +871,14 @@ namespace Tnb.ProductionMgr
List<PrdReport> prdReports = await db.Queryable<PrdReport>().Where(x => reportIds.Contains(x.id)).ToListAsync();
if (prdReports == null || prdReports.Count<=0)
{
throw Oops.Bah("未找到提报记录");
}
string create_id = prdReports[0].create_id;
UserEntity user = await db.Queryable<UserEntity>().SingleAsync(x => x.Id == create_id);
string org_id = user.OrganizeId;
PrdInstockH? prdInstockH = null;
List<PrdInstockD> prdInstockDs = new() { };
@@ -727,14 +894,14 @@ namespace Tnb.ProductionMgr
{
bill_type = DictConst.CHANCHENGPINRUKUDAN,
bill_date = DateTime.Now,
create_id = _userManager.UserId,
create_id = create_id,
location_code = basLocation.location_code,
carry_code = prdOutPacking.code,
is_check = 1,
station_id = station.Id,
workline_id = workline?.Id ?? "",
workshop_id = workshop?.Id ?? "",
org_id = _userManager.GetUserInfo().Result.organizeId,
org_id = org_id,
// warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id,
status = 0,
@@ -750,7 +917,7 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
quantity = (int)prdReport.reported_qty,
});
}
@@ -762,13 +929,13 @@ namespace Tnb.ProductionMgr
{
instock = new MESWmsInstockHInput()
{
org_id = _userManager.GetUserInfo().Result.organizeId,
org_id = org_id,
bill_date = DateTime.Now,
bill_type = DictConst.CHANCHENGPINRUKUDAN,
// warehouse_id = basLocation?.wh_id,
warehouse_id = warehouse_id,
source_id = prdInstockH.id,
create_id = _userManager.UserId,
create_id = create_id,
carry_code = prdOutPacking.code,
location_code = basLocation.location_code,
is_check = 1,
@@ -784,7 +951,7 @@ namespace Tnb.ProductionMgr
material_id = prdReport.material_id,
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
code_batch = prdReport.barcode,
code_batch = prdReport.mo_task_code,
pr_qty = (int)prdReport.reported_qty,
});
@@ -794,7 +961,7 @@ namespace Tnb.ProductionMgr
material_code = basMaterial.code,
unit_id = prdReport.unit_id,
barcode = prdReport.barcode,
code_batch = prdReport.barcode + "0001",
code_batch = prdReport.mo_task_code,
codeqty = (int)prdReport.reported_qty,
});
}
@@ -803,12 +970,12 @@ namespace Tnb.ProductionMgr
string domain = "http://tnb.tuotong-tech.com";
Dictionary<string, object> header = new()
{
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
// ["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()
result2 = authResponse.code != 200 || !(bool)authResponse.data
? throw Oops.Bah(authResponse.msg)
: await db.Ado.UseTranAsync(async () =>
{

View File

@@ -1500,7 +1500,8 @@ namespace Tnb.ProductionMgr
report = input.Adapt<PrdReport>();
report.id = SnowflakeIdHelper.NextId();
report.reported_qty = input.reported_qty;
report.material_box_code = input.material_box_qrcode;
report.material_box_code = input.material_box_code;
report.location_code = input.location_code;
report.create_id = _userManager.UserId;
report.create_time = DateTime.Now;
// report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
@@ -1730,8 +1731,9 @@ namespace Tnb.ProductionMgr
string[] arr = JsonConvert.DeserializeObject<string[]>(basMaterial.category_id);
if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请
{
string resultMsg = await _prdInstockService.InstockTubeOne(report);
return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
// string resultMsg = await _prdInstockService.InstockTubeOne(report);
// return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
return true;
}
if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请