其他出库记录、原材料到中储仓入库接口变更

This commit is contained in:
2024-09-20 08:59:07 +08:00
parent 4ea75cc677
commit 28742d05d0
11 changed files with 448 additions and 6 deletions

View File

@@ -1123,7 +1123,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 获取下到输送线9和10的未完成的转库单
List<WmsMaterialTransfer> WmsMaterialTransfers = db_Floor2UpMachinecodetimer.Queryable<WmsMaterialTransfer>()
.InnerJoin<WmsMaterialTransferCarry>((a, b) => a.id == b.bill_id)
.Where((a, b) => (a.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZCC_ID || a.warehouse_instock == WmsWareHouseConst.WAREHOUSE_HCC_ID) && a.warehouse_outstock == "2" && a.remainbindracknum > 0
.Where((a, b) => (a.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZCC_ID || a.warehouse_instock == WmsWareHouseConst.WAREHOUSE_HCC_ID || a.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID) && a.warehouse_outstock == "2" && a.remainbindracknum > 0
&& b.carry_code == barcode).ToList();
if (WmsMaterialTransfers.Count() == 0)

View File

@@ -243,6 +243,10 @@ public class ModuleConsts
/// </summary>
public const string MODULE_WMSPURCHASE_ID = "29975280336405";
/// <summary>
/// 模块标识-其他出库 todo
/// </summary>
public const string MODULE_OtherOutstockH_ID = "MODULE_OtherOutstockH_ID";
/// <summary>
/// 模块标识-在库物料维护
/// </summary>
public const string MODULE_WMSINSTKMIN_ID = "27124095468309";

View File

@@ -21,6 +21,14 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
public decimal codeqty { get; set; }
public int is_out { get; set; }
public string? unit_id { get; set; }
/// <summary>
/// 辅助属性(供应商)
/// </summary>
public string? auxprop_gys { get; set; }
/// <summary>
/// 辅助属性(小批号)
/// </summary>
public string? auxprop_xph { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
public class OtherOutstockAddDetailInput
{
public string? department { get; set; }
public string? salesman { get; set; }
public string? warehouse_code { get; set; }
public string source_id { get; set; }
public string source_detail_id { get; set; }
public string source_bill_code { get; set; }
public List<OtherOutstockAddDetailDetail> details { get; set; }
}
public class OtherOutstockAddDetailDetail
{
public string? material_id { get; set; }
public string? material_code { get; set; }
public string? material_name { get; set; }
public string? unit { get; set; }
public decimal? qty { get; set; }
public decimal? actual_outstock_qty { get; set; }
public string batchno { get; set; }
public string auxprop_xph { get; set; }
public string auxprop_gys { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
namespace Tnb.WarehouseMgr.Entities.Dto
{
/// <summary>
/// 库房业务更新输入参数
/// </summary>
public class QueryQTCKInput
{
/// <summary>
/// 组织ID
/// </summary>
public string org_id { get; set; }
/// <summary>
/// 入库仓库
/// </summary>
public string warehouse_instock { get; set; }
/// <summary>
/// 出库仓库
/// </summary>
public string warehouse_outstock { get; set; }
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.WarehouseMgr.Entities.Entity
{
[SugarTable("other_outstock_d")]
public partial class OtherOutstockD : BaseEntity<string>
{
public OtherOutstockD()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 主表id
/// </summary>
public string? fk_id { get; set; }
/// <summary>
/// 物料编号
/// </summary>
public string? material_code { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string? material_name { get; set; }
/// <summary>
/// 单位
/// </summary>
public string? unit { get; set; }
/// <summary>
/// 数量
/// </summary>
public decimal? qty { get; set; }
/// <summary>
/// 实际出库数量
/// </summary>
public decimal? actual_outstock_qty { get; set; }
/// <summary>
/// 仓库id
/// </summary>
public string? warehouse_id { get; set; }
/// <summary>
/// 物料id
/// </summary>
public string? material_id { get; set; }
/// <summary>
/// 批号
/// </summary>
public string? batchno { get; set; }
/// <summary>
/// 辅助属性(小批号)
/// </summary>
public string? auxprop_xph { get; set; }
/// <summary>
/// 供应商(辅助属性)
/// </summary>
public string? auxprop_gys { get; set; }
/// <summary>
/// 入库数量
/// </summary>
public decimal? rk_qty { get; set; }
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.WarehouseMgr.Entities.Entity
{
[SugarTable("other_outstock_h")]
public partial class OtherOutstockH : BaseEntity<string>
{
public OtherOutstockH()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 创建用户
/// </summary>
public string create_id { get; set; } = string.Empty;
/// <summary>
/// 创建时间
/// </summary>
public DateTime create_time { get; set; } = DateTime.Now;
/// <summary>
/// 最后修改人员ID
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 最后修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 所属组织ID
/// </summary>
public string? org_id { get; set; }
/// <summary>
/// 出库类型
/// </summary>
public string? outstock_type { get; set; }
/// <summary>
/// 部门
/// </summary>
public string? department { get; set; }
/// <summary>
/// 业务员
/// </summary>
public string? salesman { get; set; }
/// <summary>
/// 其他出库单号
/// </summary>
public string? bill_code { get; set; }
/// <summary>
/// 下发状态
/// </summary>
public string? issuance_status { get; set; }
/// <summary>
/// 出库仓库
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
///
/// </summary>
public string? source_id { get; set; }
/// <summary>
///
/// </summary>
public string? source_bill_code { get; set; }
/// <summary>
///
/// </summary>
public string? source_detail_id { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
namespace Tnb.WarehouseMgr.Interfaces
{
public interface IOtherOutstockHService
{
Task<bool> AddDetail(OtherOutstockAddDetailInput input, ISqlSugarClient dbConn = null);
}
}

View File

@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.OpenXmlFormats;
using NPOI.OpenXmlFormats.Dml.Diagram;
using Org.BouncyCastle.Utilities.Net;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.Common.Utils;
using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Enums;
using Tnb.QcMgr.Interfaces;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.BasicData;
using Tnb.ProductionMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Entity;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using JNPF.VisualDev.Interfaces;
using JNPF.VisualDev.Entitys;
using static NPOI.HSSF.Util.HSSFColor;
namespace Tnb.WarehouseMgr
{
/// <summary>
/// 其他出库
/// </summary>
[OverideVisualDev(ModuleConsts.MODULE_OtherOutstockH_ID)]
public class OtherOutstockHService : BaseWareHouseService, IOtherOutstockHService
{
private readonly IBillRullService _billRullService;
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
private readonly IWareHouseService _wareHouseService;
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
public OtherOutstockHService(ISqlSugarRepository<WmsPurchaseH> repo, IUserManager userManager, IQcCheckPlanService qcCheckPlanService, IBillRullService billRullService,
IWareHouseService wareHouseService, IRunService runService,
IVisualDevService visualDevService)
{
_db = repo.AsSugarClient();
_userManager = userManager;
_billRullService = billRullService;
_wareHouseService = wareHouseService;
_runService = runService;
_visualDevService = visualDevService;
}
public async Task<bool> AddDetail(OtherOutstockAddDetailInput input, ISqlSugarClient dbConn = null)
{
var db = dbConn;
if (dbConn == null)
db = _db;
string Code = await _billRullService.GetBillNumber("OtherDeliverySlips");
OtherOutstockH otherOutstockH = new OtherOutstockH();
otherOutstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
otherOutstockH.outstock_type = "其它出库";
otherOutstockH.bill_code = Code;
otherOutstockH.create_id = _userManager?.User?.Id;
otherOutstockH.create_time = DateTime.Now;
otherOutstockH.department = input.department;
otherOutstockH.salesman = input.salesman;
otherOutstockH.issuance_status = "未下发";
otherOutstockH.warehouse_code = input.warehouse_code;
otherOutstockH.source_id = input.source_id;
otherOutstockH.source_bill_code = input.source_bill_code;
otherOutstockH.source_detail_id = input.source_detail_id;
List<OtherOutstockD> otherOutstockDs = new List<OtherOutstockD>();
foreach (var detail in input.details.GroupBy(g => new { g.material_id, g.material_code, g.material_name, g.unit, g.batchno }))
{
decimal? qty = detail.Sum(r => r.actual_outstock_qty);
OtherOutstockD otherOutstockD = new OtherOutstockD();
otherOutstockD.fk_id = otherOutstockH.id;
otherOutstockD.material_id = detail.Key.material_id;
otherOutstockD.material_code = detail.Key.material_code;
otherOutstockD.material_name = detail.Key.material_name;
otherOutstockD.unit = detail.Key.unit;
otherOutstockD.batchno = detail.Key.batchno;
otherOutstockD.actual_outstock_qty = qty;
otherOutstockD.rk_qty = 0;
otherOutstockD.qty = qty;
otherOutstockD.auxprop_gys = detail.ToList()[0].auxprop_gys;
otherOutstockD.auxprop_xph = detail.ToList()[0].auxprop_xph;
otherOutstockDs.Add(otherOutstockD);
}
await _db.Insertable(otherOutstockH).ExecuteCommandAsync();
await _db.Insertable(otherOutstockDs).ExecuteCommandAsync();
Logger.LogInformation($"转库单{input.source_bill_code} 生成其它出库单{Code}");
return true;
}
}
}

View File

@@ -46,6 +46,7 @@ namespace Tnb.WarehouseMgr
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
private readonly IWareHouseService _wareHouseService;
private readonly IOtherOutstockHService _otherOutstockHService;
public WmsMaterialSignHService(
ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager,
@@ -54,7 +55,8 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IWmsPDAScanInStockService wmsPDAScanInStock,
IWmsCarryUnbindService wmsCarryUnbindService,
IWareHouseService wareHouseService)
IWareHouseService wareHouseService,
IOtherOutstockHService otherOutstockHService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
@@ -64,6 +66,7 @@ namespace Tnb.WarehouseMgr
_wmsPDAScanInStock = wmsPDAScanInStock;
_wmsCarryUnbindService = wmsCarryUnbindService;
_wareHouseService = wareHouseService;
_otherOutstockHService = otherOutstockHService;
}
/// <summary>
@@ -125,7 +128,29 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($"【MaterialSign】载具{input.carry_code}任务{wmsDistaskH.bill_code}的业务类型异常", 500);
}
wmsMaterialSignH.biz_type = wmsDistaskH.biz_type;
// wms其它出库记录主表
OtherOutstockAddDetailInput otherOutstockAddDetailInput = new OtherOutstockAddDetailInput();
switch (wmsDistaskH.biz_type)
{
case WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID:
{
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().Where(r => r.id == wmsDistaskH.source_id).FirstAsync();
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().Where(r => r.id == wmsMaterialTransferD.bill_id).FirstAsync();
otherOutstockAddDetailInput.source_detail_id = wmsMaterialTransferD.id;
otherOutstockAddDetailInput.source_id = wmsMaterialTransfer.id;
otherOutstockAddDetailInput.source_bill_code = wmsMaterialTransfer.bill_code;
otherOutstockAddDetailInput.department = "";
otherOutstockAddDetailInput.salesman = "";
otherOutstockAddDetailInput.warehouse_code = wmsMaterialTransfer.warehouse_outstock;
break;
}
}
List<WmsMaterialSignD> wmsMaterialSignDs = new List<WmsMaterialSignD>();
List<OtherOutstockAddDetailDetail> details = new List<OtherOutstockAddDetailDetail>();
await _db.Ado.BeginTranAsync();
foreach (var item in input.details)
{
@@ -173,6 +198,26 @@ namespace Tnb.WarehouseMgr
}
await _db.Updateable<WmsTempCode>().SetColumns(r => r.codeqty == wmsCarryCode.codeqty)
.Where(r => r.barcode == wmsCarryCode.barcode).ExecuteCommandAsync();
// wms其他出库记录明细
OtherOutstockAddDetailDetail otherOutstockAddDetailDetail = new OtherOutstockAddDetailDetail();
otherOutstockAddDetailDetail.actual_outstock_qty = item.sign_qty;
otherOutstockAddDetailDetail.auxprop_xph = wmsCarryCode.auxprop_xph;
otherOutstockAddDetailDetail.auxprop_gys = wmsCarryCode.auxprop_gys;
otherOutstockAddDetailDetail.qty = item.sign_qty;
otherOutstockAddDetailDetail.unit = wmsCarryCode.unit_id;
otherOutstockAddDetailDetail.batchno = wmsCarryCode.code_batch;
otherOutstockAddDetailDetail.material_code = basMaterial.code;
otherOutstockAddDetailDetail.material_id = basMaterial.id;
otherOutstockAddDetailDetail.material_name = basMaterial.name;
details.Add(otherOutstockAddDetailDetail);
}
if (!string.IsNullOrEmpty(otherOutstockAddDetailInput.warehouse_code))
{
otherOutstockAddDetailInput.details = details;
await _otherOutstockHService.AddDetail(otherOutstockAddDetailInput, _db);
}
// 如果没有条码 设置载具状态为空闲

View File

@@ -442,6 +442,34 @@ namespace Tnb.WarehouseMgr
return await ToApiResult(HttpStatusCode.OK, "成功");
}
[HttpPost, NonUnify, AllowAnonymous]
public async Task<Entities.Dto.Outputs.Result> QtckList(QueryQTCKInput input)
{
var res = _db.Queryable<WmsMaterialTransfer>()
.InnerJoin<OtherOutstockH>((a, b) => a.id == b.source_id)
.InnerJoin<WmsMaterialTransferD>((a, b, c) => b.source_detail_id == c.id)
.InnerJoin<OtherOutstockD>((a, b, c, d) => b.id == d.fk_id)
.WhereIF(!string.IsNullOrEmpty(input.warehouse_outstock), (a, b, c) => a.warehouse_outstock == input.warehouse_outstock)
.WhereIF(!string.IsNullOrEmpty(input.warehouse_instock), (a, b, c) => a.warehouse_instock == input.warehouse_instock)
.Where((a, b, c,d) => d.rk_qty < d.actual_outstock_qty)
.Select((a, b, c, d) => new
{
materialtransfer_billcode = a.bill_code,
otheroutstock_id = b.id,
otheroutstock_billcode = b.bill_code,
outstock_time = b.create_time,
material_id=c.material_id,
material_code=c.material_code,
material_name=c.material_ex,
material_spec=c.material_specification,
unit_code = c.unit_id,
code_batch = c.code_batch,
remainqty = d.actual_outstock_qty - d.rk_qty
}).ToList();
return await ToApiResult(HttpStatusCode.OK, "成功", res);
}
/// <summary>
/// PDA操作(8线到中储仓)
/// </summary>
@@ -454,8 +482,17 @@ namespace Tnb.WarehouseMgr
{
if (string.IsNullOrEmpty(input.source_id))
{
throw new AppFriendlyException("来源单id不可为空", 500);
throw new AppFriendlyException("来源其它出库单id不可为空", 500);
}
OtherOutstockH otherOutstockH = await _db.Queryable<OtherOutstockH>().Where(r => r.id == input.source_id).FirstAsync();
if (string.IsNullOrEmpty(otherOutstockH.source_detail_id))
{
throw new AppFriendlyException("来源其它出库单中的转库单明细id为空", 500);
}
string materialtransferid = otherOutstockH.source_detail_id;
OtherOutstockD otherOutstockD_first = await _db.Queryable<OtherOutstockD>().Where(r => r.fk_id == input.source_id).FirstAsync();
if (input.details.Count == 0)
{
throw new AppFriendlyException("请先扫描料箱", 500);
@@ -474,7 +511,7 @@ namespace Tnb.WarehouseMgr
});
await _s_taskExecuteSemaphore_F1ZCCInstock.WaitAsync();
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == materialtransferid);
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
if (wmsMaterialTransferD.yxfqty_rk >= wmsMaterialTransferD.qty)
@@ -518,7 +555,7 @@ namespace Tnb.WarehouseMgr
commonCreatePretaskInput.endlocation_id = endLocation.id;
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID;
commonCreatePretaskInput.source_id = input.source_id;
commonCreatePretaskInput.source_id = materialtransferid;
commonCreatePretaskInput.carry_id = wmsCarryHs[index].id;
commonCreatePretaskInput.carry_code = wmsCarryHs[index].carry_code;
commonCreatePretaskInput.isExcuteMission = false;
@@ -544,6 +581,8 @@ namespace Tnb.WarehouseMgr
carryMaterialDetail.code_batch = wmsMaterialTransferD.code_batch;
carryMaterialDetail.barcode = wmsCarryHs[index].carry_code;
carryMaterialDetail.unit_id = wmsMaterialTransferD.unit_id;
carryMaterialDetail.auxprop_gys = otherOutstockD_first.auxprop_gys;
carryMaterialDetail.auxprop_xph = otherOutstockD_first.auxprop_xph;
carryMaterialDetails.Add(carryMaterialDetail);
carryMaterialBindInput.details = carryMaterialDetails;
await _wmsCarryBindService.CarryMaterialBind(carryMaterialBindInput, _db);
@@ -553,7 +592,7 @@ namespace Tnb.WarehouseMgr
}
// 更新子表已下发数量
await _db.Updateable<WmsMaterialTransferD>().SetColumns(r => r.yxfqty_rk == r.yxfqty_rk + qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
await _db.Updateable<WmsMaterialTransferD>().SetColumns(r => r.yxfqty_rk == r.yxfqty_rk + qty).Where(r => r.id == materialtransferid).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
}