From 46772647e7ea3253183e095e90953a818339143b Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Thu, 2 Nov 2023 17:33:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E6=BB=A1=E7=AE=B1=E5=85=A5?=
=?UTF-8?q?=E5=BA=93=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Consts/DictConst.cs | 5 +
.../Entity/EqpEquipment.cs | 5 +
.../Dto/PrdManage/InstockInput.cs | 8 ++
.../Entity/PrdReport.cs | 4 +-
.../IPrdInstockService.cs | 7 +
.../Tnb.ProductionMgr/PrdInstockService.cs | 128 ++++++++++++++++++
6 files changed, 155 insertions(+), 2 deletions(-)
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs
diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
index 3d130676..da84b4d4 100644
--- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
+++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
@@ -163,6 +163,11 @@ public static class DictConst
/// andon状态已完成
///
public const string AndonStatusYWC = "5";
+
+ ///
+ /// 产成品入库单
+ ///
+ public const string CHANCHENGPINRUKUDAN = "40";
#endregion
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs
index c94ec696..aa667ea2 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipment.cs
@@ -212,5 +212,10 @@ public partial class EqpEquipment : BaseEntity
/// 挤出件类型
///
public string? tube { get; set; }
+
+ ///
+ /// 入库库位id
+ ///
+ public string? as_location_id { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs
new file mode 100644
index 00000000..c7413345
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/InstockInput.cs
@@ -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; }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
index d1980bec..e24a66f2 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
@@ -126,8 +126,8 @@ public partial class PrdReport : BaseEntity
public string? process_id { get; set; }
///
- /// 料箱二维码
+ /// 料箱编号
///
- public string material_box_qrcode { get; set; }
+ public string material_box_code { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
index 5e6b5e87..5cca73d3 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
@@ -21,5 +21,12 @@ namespace Tnb.ProductionMgr.Interfaces
/// source_id
///
public Task SyncInstock(Dictionary dic);
+
+ ///
+ /// 注塑满箱到位后入库申请
+ ///
+ ///
+ ///
+ public Task InstockTypeOne(InstockInput inut);
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
index 2e5d2d2f..a854e8d2 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
@@ -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;
}
+
+ ///
+ /// 注塑满箱到位后入库申请
+ ///
+ ///
+ ///
+ ///
+ [AllowAnonymous]
+ public async Task 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().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().SingleAsync(x=>x.id==equipment.as_location_id);
+ if(basLocation==null) throw Oops.Bah("未找到入库库位");
+ PrdReport prdReport = await db.Queryable()
+ .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 prdInstockDs = new List() { };
+ DbResult result2 = new DbResult();
+ BasMaterial basMaterial = await db.Queryable().SingleAsync(x=>x.id==prdReport.material_id);
+ DbResult 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();
+ mesCreateInstockInput.instockcodes = new List();
+ 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 header = new Dictionary()
+ {
+ ["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(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(prdInstockDs).ExecuteCommandAsync();
+ }
+ });
+
+ }
+ }
+
+ if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ return result2.IsSuccess ? "申请成功" : result2.ErrorMessage;
+ }
}
}
\ No newline at end of file