diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
new file mode 100644
index 00000000..c3312e59
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs
@@ -0,0 +1,16 @@
+namespace Tnb.BasicData
+{
+ public static class WebApiConst
+ {
+ #region wms
+
+ //mes生产入库接口
+ public const string MES_CREATE_INSTOCK = "/api/wms/wms-in-stock/mes-create-instock";
+
+ //载具签收接口
+ public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign";
+
+ #endregion
+
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs
new file mode 100644
index 00000000..485e4233
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdInstockInput.cs
@@ -0,0 +1,34 @@
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class PrdInstockInput
+ {
+
+ ///
+ /// 单据类型
+ ///
+ public string bill_type { get; set; } = string.Empty;
+
+
+ ///
+ /// 载具编号
+ ///
+ public string carry_code { get; set; } = string.Empty;
+
+ ///
+ /// 起始库位编号
+ ///
+ public string location_code { get; set; } = string.Empty;
+
+
+ ///
+ /// 检验(0-未检 1-已检)
+ ///
+ public int is_check { get; set; }
+
+ ///
+ /// 子表明细
+ ///
+ public List> details { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs
index 7bff1e66..04c6db66 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockD.cs
@@ -37,7 +37,7 @@ public partial class PrdInstockD : BaseEntity
///
/// 数量
///
- public string quantity { get; set; } = string.Empty;
+ public int quantity { get; set; }
///
/// 批次
@@ -49,4 +49,9 @@ public partial class PrdInstockD : BaseEntity
///
public string barcode { get; set; } = string.Empty;
+ ///
+ /// 生产提报id
+ ///
+ public string report_id { get; set; } = string.Empty;
+
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs
index 9616f5d2..390c5651 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdInstockH.cs
@@ -38,16 +38,12 @@ public partial class PrdInstockH : BaseEntity
/// 起始库位编号
///
public string location_code { get; set; } = string.Empty;
-
- ///
- /// 来源单据ID
- ///
- public string source_id { get; set; } = string.Empty;
+
///
/// 检验(0-未检 1-已检)
///
- public string is_check { get; set; } = string.Empty;
+ public int is_check { get; set; }
///
/// 创建用户
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
index 4d48963a..5e6b5e87 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs
@@ -1,3 +1,5 @@
+using Tnb.ProductionMgr.Entities.Dto;
+
namespace Tnb.ProductionMgr.Interfaces
{
///
@@ -6,6 +8,13 @@ namespace Tnb.ProductionMgr.Interfaces
public interface IPrdInstockService
{
+ ///
+ /// 生产入库报错
+ ///
+ ///
+ ///
+ public Task SaveData(PrdInstockInput input);
+
///
/// 入库申请同步
///
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 9e5a8039..2a0d6aec 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -1,13 +1,16 @@
+using JNPF;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Utils;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.ClearScript.Util.Web;
+using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
@@ -16,6 +19,7 @@ using Tnb.ProductionMgr.Interfaces;
using Tnb.ProductionMgr.Entities.Consts;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities;
+using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -29,20 +33,20 @@ namespace Tnb.ProductionMgr
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
- private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
+ // private readonly WmsSignForDeliveryService _wmsSignForDeliveryService;
public PrdFeedingService(
ISqlSugarRepository repository,
IBillRullService billRullService,
- WmsSignForDeliveryService wmsSignForDeliveryService,
+ // WmsSignForDeliveryService wmsSignForDeliveryService,
IUserManager userManager
)
{
_repository = repository;
_userManager = userManager;
- _wmsSignForDeliveryService = _wmsSignForDeliveryService;
+ // _wmsSignForDeliveryService = _wmsSignForDeliveryService;
_billRullService = billRullService;
}
@@ -143,12 +147,12 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
//签收后调用载具签收接口
- await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
- {
- org_id = _userManager.GetUserInfo().Result.organizeId,
- create_id = _userManager.UserId,
- carry_code = input.carry_code ?? "",
- });
+ // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
+ // {
+ // org_id = _userManager.GetUserInfo().Result.organizeId,
+ // create_id = _userManager.UserId,
+ // carry_code = input.carry_code ?? "",
+ // });
}
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
@@ -257,12 +261,26 @@ namespace Tnb.ProductionMgr
if (result.IsSuccess)
{
//签收后调用载具签收接口
- await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
+ // await _wmsSignForDeliveryService.MESCarrySign(new MESCarrySignInput()
+ // {
+ // org_id = _userManager.GetUserInfo().Result.organizeId,
+ // create_id = _userManager.UserId,
+ // carry_code = input.carry_code ?? "",
+ // });
+
+ var mesCarrySignInput = new MESCarrySignInput()
{
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 header = new Dictionary()
+ {
+ ["Authorization"] = App.HttpContext.Request.Headers["Authorization"]
+ };
+ var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header);
}
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
index 5e8a2a63..4f2ededd 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs
@@ -1,12 +1,24 @@
+using JNPF;
using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Utils;
+using JNPF.FriendlyException;
+using JNPF.RemoteRequest;
using JNPF.Systems.Interfaces.System;
+using Mapster;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
using SqlSugar;
+using Tnb.BasicData.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Interfaces;
+using Tnb.WarehouseMgr;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
+using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -19,18 +31,112 @@ namespace Tnb.ProductionMgr
{
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
- private readonly IBillRullService _billRullService;
public PrdInstockService(
ISqlSugarRepository repository,
- IBillRullService billRullService,
IUserManager userManager
)
{
_repository = repository;
_userManager = userManager;
- _billRullService = billRullService;
+ }
+
+ [HttpPost]
+ public async Task SaveData(PrdInstockInput input)
+ {
+ var db = _repository.AsSugarClient();
+ var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code);
+ PrdInstockH prdInstockH = null;
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ prdInstockH = new PrdInstockH()
+ {
+ bill_type = input.bill_type,
+ bill_date = DateTime.Now,
+ create_id = _userManager.UserId,
+ location_code = input.location_code,
+ carry_code = input.carry_code,
+ is_check = input.is_check,
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ warehouse_id = location?.wh_id,
+ status = 0,
+ };
+
+ List prdInstockDs = new List() { };
+ foreach (var item in input.details)
+ {
+ prdInstockDs.Add(new PrdInstockD()
+ {
+ instock_id = prdInstockH.id,
+ report_id = item.ContainsKey("report_id") ? item["report_id"] : "",
+ material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
+ material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
+ unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
+ code_batch = item.ContainsKey("batch") ? item["batch"] : "",
+ barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
+ quantity = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
+ });
+ }
+
+ await _repository.InsertAsync(prdInstockH);
+
+ if (prdInstockDs.Count > 0)
+ {
+ await db.Insertable(prdInstockDs).ExecuteCommandAsync();
+ }
+
+ });
+
+ if (result.IsSuccess)
+ {
+ MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput();
+ mesCreateInstockInput.instock = new MESWmsInstockHInput()
+ {
+ org_id = _userManager.GetUserInfo().Result.organizeId,
+ bill_date = DateTime.Now,
+ bill_type = input.bill_type,
+ warehouse_id = location?.wh_id,
+ source_id = prdInstockH.id,
+ create_id = _userManager.UserId,
+ carry_code = input.carry_code,
+ location_code = input.location_code,
+ is_check = input.is_check,
+ };
+ mesCreateInstockInput.instockds = new List();
+ mesCreateInstockInput.instockcodes = new List();
+ foreach (var item in input.details)
+ {
+ mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput()
+ {
+ material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
+ material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
+ unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
+ code_batch = item.ContainsKey("batch") ? item["batch"] : "",
+ pr_qty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
+ });
+
+ mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput()
+ {
+ material_id = item.ContainsKey("material_id") ? item["material_id"] : "",
+ material_code = item.ContainsKey("material_code") ? item["material_code"] : "",
+ unit_id = item.ContainsKey("unit_id") ? item["unit_id"] : "",
+ code_batch = item.ContainsKey("batch") ? item["batch"] : "",
+ barcode = item.ContainsKey("batch") ? item["batch"]+"0001" : "",
+ codeqty = Convert.ToInt32(item.ContainsKey("quantity") ? item["quantity"] : "0"),
+ });
+ }
+ 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);
+ Console.WriteLine(sendResult);
+ }
+
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ return result.IsSuccess ? "保存成功" : result.ErrorMessage;
}
///
diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
index 832c4f03..6316cd83 100644
--- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
+++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj
@@ -15,7 +15,6 @@
-
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
index bc4576b2..3c20c3d1 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
@@ -5,10 +5,12 @@ using System.Text;
using System.Threading.Tasks;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
@@ -38,18 +40,41 @@ namespace Tnb.WarehouseMgr
{
dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name);
}
- var items = await _db.Queryable().Where(a => a.carry_id == carryId)
- .Select(a => new CarryCodeDetailOutput
- {
- barcode = a.barcode,
- code_batch = a.code_batch!,
- codeqty = a.codeqty,
- material_code = a.material_code,
- material_id = a.material_id,
- unit_id = a.unit_id,
- })
- .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "")
- .ToListAsync();
+ var carry = await _db.Queryable().SingleAsync(it=>it.id == carryId);
+ List items = new();
+ if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
+ {
+ var carryDs = await _db.Queryable().Where(it=>it.carry_id == carryId).ToListAsync();
+ var carryMIds = carryDs.Select(x=>x.membercarry_id).ToList();
+ items = await _db.Queryable().Where(a => carryMIds.Contains(a.carry_id))
+ .Select(a => new CarryCodeDetailOutput
+ {
+ barcode = a.barcode,
+ code_batch = a.code_batch!,
+ codeqty = a.codeqty,
+ material_code = a.material_code,
+ material_id = a.material_id,
+ unit_id = a.unit_id,
+ })
+ .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "")
+ .ToListAsync();
+ }
+ else
+ {
+ items = await _db.Queryable().Where(a => a.carry_id == carryId)
+ .Select(a => new CarryCodeDetailOutput
+ {
+ barcode = a.barcode,
+ code_batch = a.code_batch!,
+ codeqty = a.codeqty,
+ material_code = a.material_code,
+ material_id = a.material_id,
+ unit_id = a.unit_id,
+ })
+ .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "")
+ .ToListAsync();
+ }
+
return items ?? Enumerable.Empty();
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
index 95aefa47..a6d55e85 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
+using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -72,7 +73,11 @@ namespace Tnb.WarehouseMgr
{
foreach (var ko in kittingOuts)
{
- var carrys = await _db.Queryable().Where(it => it.collocation_scheme_id == ko.collocation_scheme_id && it.is_lock == 0).ToListAsync();
+ var carrys = await _db.Queryable()
+ .InnerJoin((a,b) => a.collocation_scheme_id == b.id)
+ .Where(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0)
+ .OrderBy((a,b)=>b.seq)
+ .ToListAsync();
if (carrys?.Count > 0)
{
var firstCarry = carrys.FirstOrDefault();
@@ -131,7 +136,7 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost]
- public async Task KittingOutByIsToBeShipped(IDbTransaction? tran = null)
+ public async Task KittingOutByIsToBeShipped()
{
try
{
@@ -152,10 +157,13 @@ namespace Tnb.WarehouseMgr
var carry = await _db.Queryable().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
{
+
WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id);
WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
{
+ //判断目标库位是否自动签收
+ var loc = await _db.Queryable().SingleAsync(it => it.id == ePoint.location_id);
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
if (points?.Count > 0)
@@ -165,36 +173,38 @@ namespace Tnb.WarehouseMgr
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
- WmsPretaskH preTask = new()
- {
- org_id = _userManager.User.OrganizeId,
- startlocation_id = sPoint?.location_id!,
- startlocation_code = sPoint?.location_code!,
- endlocation_id = ePoint?.location_id!,
- endlocation_code = ePoint?.location_code!,
- start_floor = sPoint?.floor.ToString(),
- end_floor = ePoint?.floor.ToString(),
- bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
- status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
- biz_type = ko.biz_type,
- task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
- carry_id = ko!.carry_id!,
- carry_code = ko!.carry_code!,
- area_id = sPoint?.area_id!,
- area_code = it.Key,
- require_id = ko.id,
- require_code = ko.bill_code,
- create_id = _userManager.UserId,
- create_time = DateTime.Now
- };
+ WmsPretaskH preTask = new();
+ preTask.org_id = _userManager.User.OrganizeId;
+ preTask.startlocation_id = sPoint?.location_id!;
+ preTask.startlocation_code = sPoint?.location_code!;
+ preTask.endlocation_id = ePoint?.location_id!;
+ preTask.endlocation_code = ePoint?.location_code!;
+ preTask.start_floor = sPoint?.floor.ToString();
+ preTask.end_floor = ePoint?.floor.ToString();
+ preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
+ preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
+ preTask.biz_type = ko.biz_type;
+ preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
+ preTask.carry_id = ko!.carry_id!;
+ preTask.carry_code = ko!.carry_code!;
+ preTask.area_id = sPoint?.area_id!;
+ preTask.area_code = it.Key;
+ preTask.require_id = ko.id;
+ preTask.require_code = ko.bill_code;
+ preTask.create_id = _userManager.UserId;
+ preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
+ if (loc.is_sign == 0)
+ {
+ preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
+ }
await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 });
-
+ await _db.Updateable().SetColumns(it => it.status == WmsWareHouseConst.BILLSTATUS_ON_ID).Where(it => it.id == ko.id).ExecuteCommandAsync();
}
}
}