注塑满箱入库申请接口
This commit is contained in:
@@ -164,6 +164,11 @@ public static class DictConst
|
||||
/// </summary>
|
||||
public const string AndonStatusYWC = "5";
|
||||
|
||||
/// <summary>
|
||||
/// 产成品入库单
|
||||
/// </summary>
|
||||
public const string CHANCHENGPINRUKUDAN = "40";
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -213,4 +213,9 @@ public partial class EqpEquipment : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? tube { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库库位id
|
||||
/// </summary>
|
||||
public string? as_location_id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class InstockInput
|
||||
{
|
||||
public string equip_code { get; set; }
|
||||
public string as_location_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -126,8 +126,8 @@ public partial class PrdReport : BaseEntity<string>
|
||||
public string? process_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 料箱二维码
|
||||
/// 料箱编号
|
||||
/// </summary>
|
||||
public string material_box_qrcode { get; set; }
|
||||
public string material_box_code { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,12 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <param name="dic">source_id</param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> SyncInstock(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 注塑满箱到位后入库申请
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> InstockTypeOne(InstockInput inut);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using SQLitePCL;
|
||||
using SqlSugar.Extensions;
|
||||
|
||||
@@ -261,5 +262,132 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
return result.IsSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注塑满箱到位后入库申请
|
||||
/// </summary>
|
||||
/// <param name="inut"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[AllowAnonymous]
|
||||
public async Task<dynamic> InstockTypeOne(InstockInput inut)
|
||||
{
|
||||
string equip_code = inut.equip_code;
|
||||
string as_location_code = inut.as_location_code;
|
||||
if (!string.IsNullOrEmpty(equip_code)) throw Oops.Bah("请传机台号");
|
||||
var db = _repository.AsSugarClient();
|
||||
EqpEquipment equipment = await db.Queryable<EqpEquipment>().Where(x => x.code == equip_code).FirstAsync();
|
||||
if(equipment==null ) throw Oops.Bah("未找到机台");
|
||||
if(string.IsNullOrEmpty(equipment.as_location_id)) throw Oops.Bah("未找到入库库位");
|
||||
BasLocation basLocation = await db.Queryable<BasLocation>().SingleAsync(x=>x.id==equipment.as_location_id);
|
||||
if(basLocation==null) throw Oops.Bah("未找到入库库位");
|
||||
PrdReport prdReport = await db.Queryable<PrdReport>()
|
||||
.Where(x => x.equip_id == equipment.id && x.status == 0).OrderByDescending(x => x.create_time)
|
||||
.FirstAsync();
|
||||
if(prdReport==null) throw Oops.Bah("未找到提报记录");
|
||||
|
||||
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 = basLocation.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 = basLocation?.wh_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 = basLocation?.wh_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
location_code = basLocation.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();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user