Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -32,5 +32,12 @@ namespace Tnb.BasicData.Interfaces
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetMaterialByQueryJson(MaterialQueryInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的入库仓库
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetInboundWarehouseById(Dictionary<string, string> dic);
|
||||
}
|
||||
}
|
||||
@@ -220,6 +220,22 @@ namespace Tnb.BasicData
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetInboundWarehouseById(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
||||
|
||||
return await _repository.AsSugarClient().Queryable<BasMaterialInboundWh>()
|
||||
.LeftJoin<BasWarehouse>((a, b) => a.wh_id == b.id)
|
||||
.Where((a, b) => a.material_id == id)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
warehouse_id = a.wh_id,
|
||||
warehouse_code = b.whcode,
|
||||
warehouse_name = b.whname
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料清单下所子集物料id
|
||||
/// </summary>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>$(NoWarn);CS1591;</NoWarn>
|
||||
<NoWarn>$(NoWarn);CS1570;CS1587;CS1591;CS8601;CS8602;CS8603;CS8618;</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -208,11 +208,6 @@ public partial class EqpEquipment : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? qrcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 挤出件类型
|
||||
/// </summary>
|
||||
public string? tube { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库库位id
|
||||
/// </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; }
|
||||
}
|
||||
}
|
||||
@@ -60,5 +60,10 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
public string? mbom_process_id { get; set; }
|
||||
|
||||
public List<Dictionary<string, object>>? details { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存在不属于该任务单的原材料也要签收
|
||||
/// </summary>
|
||||
public bool sure { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class NewMaterialReceiptInput
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string station_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 载具编号
|
||||
/// </summary>
|
||||
public string? carry_code { get; set; }
|
||||
|
||||
public List<NewMaterialReceiptDInput>? details { get; set; } = new List<NewMaterialReceiptDInput>();
|
||||
|
||||
/// <summary>
|
||||
/// 存在不属于该任务单的原材料也要签收
|
||||
/// </summary>
|
||||
public bool sure { get; set; } = false;
|
||||
}
|
||||
|
||||
public class NewMaterialReceiptDInput
|
||||
{
|
||||
public string material_id{get;set;}
|
||||
public decimal codeqty {get;set;}
|
||||
public string code_batch {get;set;}
|
||||
public string unit_id {get;set;}
|
||||
public string barcode {get;set;}
|
||||
public string member_carryid {get;set;}
|
||||
public string member_carrycode {get;set;}
|
||||
public string supplier_id {get;set;}
|
||||
public DateTime? instock_time {get;set;}
|
||||
public string check_conclusion {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -127,10 +127,6 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public string? act_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 挤出件类型
|
||||
/// </summary>
|
||||
public string? tube { get; set; }
|
||||
/// <summary>
|
||||
/// 最小包装
|
||||
/// </summary>
|
||||
public decimal? minpacking { get; set; }
|
||||
@@ -154,5 +150,21 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 称重点位名称
|
||||
/// </summary>
|
||||
public string? weight_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料分类ID
|
||||
/// </summary>
|
||||
public string category_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 入库仓库id
|
||||
/// </summary>
|
||||
public string warehouse_id { get; set; }
|
||||
|
||||
public string warehouse_code { get; set; }
|
||||
|
||||
public string warehouse_name { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public partial class PrdMaterialReceiptD : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 入库时间
|
||||
/// </summary>
|
||||
public DateTime instock_time { get; set; }
|
||||
public DateTime? instock_time { get; set; }
|
||||
/// <summary>
|
||||
/// 检验结论
|
||||
/// </summary>
|
||||
|
||||
@@ -129,5 +129,10 @@ public partial class PrdReport : BaseEntity<string>
|
||||
/// 料箱编号
|
||||
/// </summary>
|
||||
public string material_box_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 长管挤出入库库位
|
||||
/// </summary>
|
||||
public string location_code { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -36,5 +36,12 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> InstockTubeOne(PrdReport prdReport);
|
||||
|
||||
/// <summary>
|
||||
/// 长管管挤出入库申请
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> InstockTubeThree(PrdReport prdReport);
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,11 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GeneralOutstock(GeneralOutstockInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 物料出库申请
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> MaterialOutstock(MaterialOutstockInput input);
|
||||
}
|
||||
}
|
||||
@@ -263,6 +263,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
string equip_code = inut.equip_code;
|
||||
string as_location_code = inut.as_location_code;
|
||||
string warehouse_id = "2";
|
||||
if (!string.IsNullOrEmpty(equip_code))
|
||||
{
|
||||
throw Oops.Bah("请传机台号");
|
||||
@@ -315,7 +316,8 @@ namespace Tnb.ProductionMgr
|
||||
workline_id = workline?.Id ?? "",
|
||||
workshop_id = workshop?.Id ?? "",
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
warehouse_id = basLocation?.wh_id,
|
||||
// warehouse_id = basLocation?.wh_id,
|
||||
warehouse_id = warehouse_id,
|
||||
status = 0,
|
||||
};
|
||||
|
||||
@@ -341,7 +343,8 @@ namespace Tnb.ProductionMgr
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = basLocation?.wh_id,
|
||||
// warehouse_id = basLocation?.wh_id,
|
||||
warehouse_id = warehouse_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = prdReport.material_box_code,
|
||||
@@ -397,8 +400,118 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<string> InstockTubeOne(PrdReport prdReport)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
string location_code = "JMXHC-01";
|
||||
string warehouse_id = "26103348825381";
|
||||
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);
|
||||
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 = 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 = 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.barcode + "0001",
|
||||
quantity = (int)prdReport.reported_qty,
|
||||
});
|
||||
});
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
MESCreateInstockInput mesCreateInstockInput = new()
|
||||
{
|
||||
instock = new MESWmsInstockHInput()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = DictConst.CHANCHENGPINRUKUDAN,
|
||||
warehouse_id = warehouse_id,
|
||||
source_id = prdInstockH.id,
|
||||
create_id = _userManager.UserId,
|
||||
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.barcode + "0001",
|
||||
codeqty = (int)prdReport.reported_qty,
|
||||
});
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
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 || !authResponse.data.ObjToBool()
|
||||
? 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";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 长管管挤出入库申请
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> InstockTubeThree(PrdReport prdReport)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
string location_code = prdReport.location_code;
|
||||
string warehouse_id = "27209786980373";//长件挤出缓存仓
|
||||
|
||||
PrdInstockH? prdInstockH = null;
|
||||
List<PrdInstockD> prdInstockDs = new() { };
|
||||
|
||||
@@ -34,12 +34,13 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IOrganizeService _organizeService;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||
|
||||
public PrdMaterialReceiptService(
|
||||
ISqlSugarRepository<PrdMaterialReceiptH> repository,
|
||||
IBillRullService billRullService,
|
||||
IOrganizeService organizeService,
|
||||
IPrdMoTaskService prdMoTaskService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
@@ -47,6 +48,7 @@ namespace Tnb.ProductionMgr
|
||||
_userManager = userManager;
|
||||
_organizeService = organizeService;
|
||||
_billRullService = billRullService;
|
||||
_prdMoTaskService = prdMoTaskService;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,5 +245,129 @@ namespace Tnb.ProductionMgr
|
||||
? throw Oops.Bah(result.ErrorMessage)
|
||||
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveDataNew(NewMaterialReceiptInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask moTask = await _prdMoTaskService.GetPrdMoTaskInfoByStationId(new Dictionary<string, string>(){
|
||||
{"station_id",input.station_id}
|
||||
});
|
||||
DbResult<bool> result2 = new();
|
||||
PrdMaterialReceiptH? prdMaterialReceiptH = null;
|
||||
List<PrdMaterialReceiptD> list = new();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
List<string> inputMaterials = await db.Queryable<BasMbomInput>()
|
||||
.Where(x => x.mbom_id == moTask.bom_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(moTask.mbom_process_id), x => x.mbom_process_id == moTask.mbom_process_id)
|
||||
.Select(x => x.material_id)
|
||||
.ToListAsync();
|
||||
|
||||
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
|
||||
OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorklineCode);
|
||||
OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(input.station_id, DictConst.RegionCategoryWorkshopCode);
|
||||
WmsCarryH carry = await db.Queryable<WmsCarryH>().Where(x=>x.carry_code==input.carry_code).FirstAsync();
|
||||
|
||||
|
||||
prdMaterialReceiptH = new PrdMaterialReceiptH()
|
||||
{
|
||||
code = code,
|
||||
station_id = input.station_id,
|
||||
mo_task_id = moTask.id,
|
||||
process_id = moTask.process_id,
|
||||
equip_id = moTask.eqp_id,
|
||||
workshop_id = workshop?.Id ?? "",
|
||||
carry_id = carry.id,
|
||||
workline_id = workline?.Id ?? "",
|
||||
carry_code = input.carry_code,
|
||||
mbom_process_id = moTask.mbom_process_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
|
||||
if (input.details != null && input.details.Count > 0)
|
||||
{
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
if (!inputMaterials.Contains(item.material_id) && !input.sure)
|
||||
{
|
||||
throw new Exception("存在不属于生产bom的投入物料,确认签收吗");
|
||||
}
|
||||
|
||||
list.Add(new PrdMaterialReceiptD
|
||||
{
|
||||
material_receipt_id = prdMaterialReceiptH.id,
|
||||
material_id = item.material_id,
|
||||
num = item.codeqty,
|
||||
batch = item.code_batch,
|
||||
unit_id = item.unit_id,
|
||||
carry_id = carry.id,
|
||||
barcode = item.barcode,
|
||||
is_all_feeding = 0,
|
||||
member_carry_id = item.member_carryid,
|
||||
member_carry_code = item.member_carrycode,
|
||||
feeding_num = 0,
|
||||
supplier_id = item.supplier_id,
|
||||
instock_time = item.instock_time,
|
||||
check_conclusion = item.check_conclusion,
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("没有签收物料");
|
||||
}
|
||||
|
||||
|
||||
// await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
// await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
//签收后调用载具签收接口
|
||||
// await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
|
||||
// {
|
||||
// org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
// create_id = _userManager.UserId,
|
||||
// carry_code = input.carry_code ?? "",
|
||||
// });
|
||||
|
||||
MESCarrySignInput mesCarrySignInput = new()
|
||||
{
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
create_id = _userManager.UserId,
|
||||
carry_code = input.carry_code ?? "",
|
||||
};
|
||||
|
||||
string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host;
|
||||
Dictionary<string, object> header = new()
|
||||
{
|
||||
["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
|
||||
};
|
||||
string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN, JsonConvert.SerializeObject(mesCarrySignInput), header);
|
||||
Log.Information(sendResult);
|
||||
AuthResponse authResponse = JsonConvert.DeserializeObject<AuthResponse>(sendResult);
|
||||
result2 = authResponse.code != 200
|
||||
? throw Oops.Bah(authResponse.msg)
|
||||
: await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
_ = await db.Insertable<PrdMaterialReceiptH>(prdMaterialReceiptH).ExecuteCommandAsync();
|
||||
_ = await db.Insertable<PrdMaterialReceiptD>(list).ExecuteCommandAsync();
|
||||
});
|
||||
}
|
||||
|
||||
if (result.ErrorMessage == "存在不属于生产bom的投入物料,确认签收吗")
|
||||
{
|
||||
return "存在不属于生产bom的投入物料,确认签收吗";
|
||||
}
|
||||
return !result.IsSuccess
|
||||
? throw Oops.Bah(result.ErrorMessage)
|
||||
: !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -735,7 +735,7 @@ namespace Tnb.ProductionMgr
|
||||
batch = a.batch,
|
||||
supplier_name = d.supplier_name,
|
||||
check_conclusion = c.check_conclusion,
|
||||
instock_time = c.instock_time.ToString(DbTimeFormat.SS),
|
||||
instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS),
|
||||
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
}).ToListAsync();
|
||||
|
||||
@@ -848,8 +848,8 @@ namespace Tnb.ProductionMgr
|
||||
batch = a.batch,
|
||||
supplier_name = d.supplier_name,
|
||||
check_conclusion = c.check_conclusion,
|
||||
instock_time = c.instock_time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
instock_time = c.instock_time==null ? "" : c.instock_time.Value.ToString(DbTimeFormat.SS),
|
||||
feeding_time = e.create_time == null ? "" : e.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
});
|
||||
|
||||
if (lastPrdReportIds != null && lastPrdReportIds.Count > 0)
|
||||
|
||||
@@ -1114,6 +1114,11 @@ namespace Tnb.ProductionMgr
|
||||
throw Oops.Bah("已开始的不能再开始");
|
||||
}
|
||||
|
||||
if (await db.Queryable<PrdMoTask>().AnyAsync(x => x.workstation_id == item.workstation_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id))
|
||||
{
|
||||
throw Oops.Bah("该工位已有生产中的任务单");
|
||||
}
|
||||
|
||||
if (item.mo_task_status is not DictConst.ToBeStartedEnCode and not DictConst.MoStatusPauseCode)
|
||||
{
|
||||
throw Oops.Bah("状态错误无法开始");
|
||||
@@ -1444,6 +1449,7 @@ namespace Tnb.ProductionMgr
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
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);
|
||||
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);
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
@@ -1709,10 +1715,20 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
if (equip.tube == "1")
|
||||
if (!string.IsNullOrEmpty(basMaterial.category_id))
|
||||
{
|
||||
string resultMsg = await _prdInstockService.InstockTubeOne(report);
|
||||
return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
|
||||
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);
|
||||
}
|
||||
|
||||
if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请
|
||||
{
|
||||
string resultMsg = await _prdInstockService.InstockTubeThree(report);
|
||||
return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GeneralOutstock(GeneralOutstockInput generalOutstockInput)
|
||||
{
|
||||
try
|
||||
@@ -243,5 +244,120 @@ namespace Tnb.ProductionMgr
|
||||
throw Oops.Bah(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> MaterialOutstock(MaterialOutstockInput materialOutstockInput)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
string warehouse_id = "27209786980373";//长件挤出缓存仓
|
||||
|
||||
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_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),
|
||||
tube = f.tube,
|
||||
minpacking = b.minpacking,
|
||||
main_num = k.number_of_primary_unit,
|
||||
deputy_num = k.number_of_auxiliary_unit,
|
||||
third_equip_code = f.third_equip_code,
|
||||
weight_name = l.label_name
|
||||
weight_name = l.label_name,
|
||||
category_id = b.category_id
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
public static class CustomLoggerExtenstions
|
||||
{
|
||||
public static void Debug(this ILogger logger, string message, params object[] parameters)
|
||||
{
|
||||
logger.Debug(message, parameters);
|
||||
}
|
||||
|
||||
public static void Information(this ILogger logger, string message, params object[] parameters)
|
||||
{
|
||||
logger.LogInformation(message, parameters);
|
||||
|
||||
@@ -194,7 +194,6 @@ namespace Tnb.WarehouseMgr
|
||||
finally
|
||||
{
|
||||
//向队列写入消息
|
||||
Logger.Information("调用预任务生成");
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TemplateContext
|
||||
#if DEBUG
|
||||
BasePath = CodeHelper.GetSolutionDirectoryPath(false)!;
|
||||
#else
|
||||
BasePath = FileVariable.GenerateCodePath;
|
||||
BasePath = JNPF.Common.Configuration.FileVariable.GenerateCodePath;
|
||||
#endif
|
||||
ModuleCode = moduleCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user