|
@@ -17,6 +17,12 @@ using ZR.Model.Models.Statistics;
|
|
|
using ZR.Model.Dto.OutStore;
|
|
|
using ZR.Model.Models.OutStore;
|
|
|
using ZR.Model.Dto.Statistics;
|
|
|
+using ZR.Model.Models.Balance;
|
|
|
+using ZR.Model.Models.InStore;
|
|
|
+using ZR.Service.Business.IBusinessService.Balance;
|
|
|
+using ZR.Service.Business.IBusinessService.InStore;
|
|
|
+using ZR.Model.Models;
|
|
|
+using ZR.Service.Business.IBusinessService.OutStore;
|
|
|
|
|
|
namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
{
|
|
@@ -37,15 +43,24 @@ namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
/// </summary>
|
|
|
private readonly ISapDeliverRecordService _SapDeliverRecordService;
|
|
|
private readonly IQaInspectRecordService _QaInspectRecordService;
|
|
|
+ private readonly IInInstoreRecordService _InInstoreRecordService;
|
|
|
+ private readonly IStkBalanceDtlService _StkBalanceDtlService;
|
|
|
+ private readonly IOutOutstoreRecordService _OutOutstoreRecordService;
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
/// </summary>
|
|
|
public QaInspectRecordController(
|
|
|
ISapDeliverRecordService SapDeliverRecordService,
|
|
|
- IQaInspectRecordService QaInspectRecordService)
|
|
|
+ IQaInspectRecordService QaInspectRecordService,
|
|
|
+ IInInstoreRecordService InInstoreRecordService,
|
|
|
+ IStkBalanceDtlService StkBalanceDtlService,
|
|
|
+ IOutOutstoreRecordService OutOutstoreRecordService)
|
|
|
{
|
|
|
_QaInspectRecordService = QaInspectRecordService;
|
|
|
_SapDeliverRecordService = SapDeliverRecordService;
|
|
|
+ _InInstoreRecordService = InInstoreRecordService;
|
|
|
+ _StkBalanceDtlService = StkBalanceDtlService;
|
|
|
+ _OutOutstoreRecordService = OutOutstoreRecordService;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -417,5 +432,253 @@ namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ #region 20240428 孙亚龙新增 质检完成后,直接出库过账的功能。 用于装配段紧急需要物料是使用。
|
|
|
+ /*
|
|
|
+ * 1、质检完成后,直接出库过账的功能。使用场景:装配段紧急需要物料时使用。
|
|
|
+ * 2、需要在操作界面端,增加密码校验功能,防止随意使用该功能。
|
|
|
+ */
|
|
|
+ /// <summary>
|
|
|
+ /// 质检完成后,质检记录数据直接出库过账。
|
|
|
+ /// 需要保存完整的数据流,包括:
|
|
|
+ /// 1、SAP交验单数据。
|
|
|
+ /// 2、质检记录数据。
|
|
|
+ /// 3、入库记录数据。
|
|
|
+ /// 4、库存记录数据。
|
|
|
+ /// 5、出库记录数据。(直接使用交验单的生产令号-bom号作为出库单号)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parm">已质检的交验单明细Dto实体类</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="CustomException"></exception>
|
|
|
+ [HttpPost("InspectOneClickOutStore")]
|
|
|
+ [ActionPermissionFilter(Permission = "business:QaInspectRecord:InspectOneClickOutStore")]
|
|
|
+ public IActionResult InspectOneClickOutStore([FromBody] SapDeliverRecordExtDto parm)
|
|
|
+ {
|
|
|
+ if (parm == null)
|
|
|
+ {
|
|
|
+ throw new CustomException("请求实体不能为空");
|
|
|
+ }
|
|
|
+ List<SapDeliverRecord> sapDeliverList = _SapDeliverRecordService.Queryable()
|
|
|
+ .Where(x => x.DeliverNo == parm.DeliverNo && x.MaterialSpec == parm.MaterialSpec && x.CheckQty < x.Qty)
|
|
|
+ .OrderBy(x => x.Id)
|
|
|
+ .OrderBy(x => x.Qty)
|
|
|
+ .ToList();
|
|
|
+ if (sapDeliverList == null || sapDeliverList.Count <= 0)
|
|
|
+ {
|
|
|
+ throw new CustomException($"交验单:{parm.DeliverNo} 未查询到物料号:{parm.MaterialSpec} 的明细数据!");
|
|
|
+ }
|
|
|
+
|
|
|
+ int sumCheckOkQty = parm.CheckOkQty;
|
|
|
+ int allotNum = 0;
|
|
|
+ List<SapDeliverRecord> allotList = new();
|
|
|
+ List<QaInspectRecord> QaInspectList = new();
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ SapDeliverRecord? sapDeliverMd = sapDeliverList.FirstOrDefault(x => x.CheckQty < x.Qty);
|
|
|
+ if (sapDeliverMd == null || allotNum >= sumCheckOkQty)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ int tmpNeedNum = sapDeliverMd.Qty - (int)sapDeliverMd.CheckQty;
|
|
|
+
|
|
|
+ if ((allotNum + tmpNeedNum) > sumCheckOkQty)
|
|
|
+ {
|
|
|
+ int realNeedNum = sumCheckOkQty - allotNum;
|
|
|
+ allotNum += realNeedNum;
|
|
|
+ sapDeliverMd.CheckQty += realNeedNum;
|
|
|
+ sapDeliverMd.CheckResult = "PartOk";
|
|
|
+ sapDeliverMd.UpdateBy = HttpContext.GetName();
|
|
|
+ sapDeliverMd.UpdateTime = DateTime.Now;
|
|
|
+ sapDeliverMd.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ allotList.Add(sapDeliverMd);
|
|
|
+ QaInspectRecord qaInspectRecord = sapDeliverMd.Adapt<QaInspectRecord>();
|
|
|
+ qaInspectRecord.InspectNo = parm.DeliverNo;
|
|
|
+ qaInspectRecord.InspectedBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.InspectTime = DateTime.Now;
|
|
|
+ qaInspectRecord.CreateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.CreateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.UpdateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.UpdateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.Result = "OK";
|
|
|
+ qaInspectRecord.CheckQty = realNeedNum;
|
|
|
+ qaInspectRecord.InstoreQty += tmpNeedNum;
|
|
|
+ qaInspectRecord.InstoreResult = 99;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ qaInspectRecord.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ QaInspectList.Add(qaInspectRecord);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ allotNum += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckQty += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckResult = "OK";
|
|
|
+ sapDeliverMd.UpdateBy = HttpContext.GetName();
|
|
|
+ sapDeliverMd.UpdateTime = DateTime.Now;
|
|
|
+ sapDeliverMd.SubmitInspectResult = true;
|
|
|
+ sapDeliverMd.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ allotList.Add(sapDeliverMd);
|
|
|
+ QaInspectRecord qaInspectRecord = sapDeliverMd.Adapt<QaInspectRecord>();
|
|
|
+ qaInspectRecord.InspectNo = parm.DeliverNo;
|
|
|
+ qaInspectRecord.InspectedBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.InspectTime = DateTime.Now;
|
|
|
+ qaInspectRecord.CreateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.CreateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.UpdateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.UpdateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.Result = "OK";
|
|
|
+ qaInspectRecord.CheckQty = tmpNeedNum;
|
|
|
+ qaInspectRecord.InstoreQty += tmpNeedNum;
|
|
|
+ qaInspectRecord.InstoreResult = 99;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ qaInspectRecord.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ QaInspectList.Add(qaInspectRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parm.CheckNgQty > 0)
|
|
|
+ {
|
|
|
+ int allotNgNum = 0;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ SapDeliverRecord? sapDeliverMd = sapDeliverList.FirstOrDefault(x => x.CheckQty < x.Qty);
|
|
|
+ if (sapDeliverMd == null || allotNgNum >= parm.CheckNgQty)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ int tmpNeedNum = sapDeliverMd.Qty - (int)sapDeliverMd.CheckQty;
|
|
|
+
|
|
|
+ if ((allotNgNum + tmpNeedNum) > parm.CheckNgQty)
|
|
|
+ {
|
|
|
+ int realNeedNum = parm.CheckNgQty - allotNgNum;
|
|
|
+ allotNgNum += realNeedNum;
|
|
|
+ sapDeliverMd.CheckQty += realNeedNum;
|
|
|
+ sapDeliverMd.CheckResult = "PartOk";
|
|
|
+ sapDeliverMd.UpdateBy = HttpContext.GetName();
|
|
|
+ sapDeliverMd.UpdateTime = DateTime.Now;
|
|
|
+ sapDeliverMd.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ allotList.Add(sapDeliverMd);
|
|
|
+ QaInspectRecord qaInspectRecord = sapDeliverMd.Adapt<QaInspectRecord>();
|
|
|
+ qaInspectRecord.InspectNo = parm.DeliverNo;
|
|
|
+ qaInspectRecord.InspectedBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.InspectTime = DateTime.Now;
|
|
|
+ qaInspectRecord.CreateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.CreateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.UpdateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.UpdateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.Result = "NG";
|
|
|
+ qaInspectRecord.CheckQty = realNeedNum;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ qaInspectRecord.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ QaInspectList.Add(qaInspectRecord);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ allotNgNum += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckQty += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckResult = "NG";
|
|
|
+ sapDeliverMd.UpdateBy = HttpContext.GetName();
|
|
|
+ sapDeliverMd.UpdateTime = DateTime.Now;
|
|
|
+ sapDeliverMd.SubmitInspectResult = true;
|
|
|
+ sapDeliverMd.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ allotList.Add(sapDeliverMd);
|
|
|
+ QaInspectRecord qaInspectRecord = sapDeliverMd.Adapt<QaInspectRecord>();
|
|
|
+ qaInspectRecord.InspectNo = parm.DeliverNo;
|
|
|
+ qaInspectRecord.InspectedBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.InspectTime = DateTime.Now;
|
|
|
+ qaInspectRecord.CreateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.CreateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.UpdateBy = HttpContext.GetName();
|
|
|
+ qaInspectRecord.UpdateTime = DateTime.Now;
|
|
|
+ qaInspectRecord.Result = "NG";
|
|
|
+ qaInspectRecord.CheckQty = tmpNeedNum;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ qaInspectRecord.Remark = "质检完成后,质检记录数据直接出库过账。";
|
|
|
+ QaInspectList.Add(qaInspectRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int response = 0;
|
|
|
+ int response1 = 0;
|
|
|
+ for (int i = 0; i < allotList.Count; i++)
|
|
|
+ {
|
|
|
+ response += _SapDeliverRecordService.UpdateSapDeliverRecord(allotList[i]);
|
|
|
+ response1 = _QaInspectRecordService.AddQaInspectRecord(QaInspectList[i]);
|
|
|
+ }
|
|
|
+ List<StkBalanceDtl> StkBalanceLst = new();
|
|
|
+ int response3 = 0;
|
|
|
+ foreach (QaInspectRecord item in QaInspectList)
|
|
|
+ {
|
|
|
+ if (item.Result == "OK")
|
|
|
+ {
|
|
|
+ TypeAdapterConfig config = new();
|
|
|
+ config.ForType<QaInspectRecord, InInstoreRecord>()
|
|
|
+ .Ignore(dest => dest.Result)
|
|
|
+ .NameMatchingStrategy(NameMatchingStrategy.IgnoreCase);
|
|
|
+ InInstoreRecord inInstoreRecordMd = item.Adapt<InInstoreRecord>(config);
|
|
|
+ inInstoreRecordMd.InStoreNo = item.DeliverNo;
|
|
|
+ inInstoreRecordMd.Result = 99;
|
|
|
+ inInstoreRecordMd.CreateBy = HttpContext.GetName();
|
|
|
+ inInstoreRecordMd.CreateTime = DateTime.Now;
|
|
|
+ inInstoreRecordMd.CreateBy = HttpContext.GetName();
|
|
|
+ inInstoreRecordMd.CreateTime = DateTime.Now;
|
|
|
+ inInstoreRecordMd.UpdateBy = HttpContext.GetName();
|
|
|
+ inInstoreRecordMd.UpdateTime = DateTime.Now;
|
|
|
+
|
|
|
+ StkBalanceDtl stkBalanceDtlMd = item.Adapt<StkBalanceDtl>();
|
|
|
+ stkBalanceDtlMd.RegionId = 1;
|
|
|
+ stkBalanceDtlMd.BinId = 1;
|
|
|
+ stkBalanceDtlMd.CreateBy = HttpContext.GetName();
|
|
|
+ stkBalanceDtlMd.CreateTime = DateTime.Now;
|
|
|
+ stkBalanceDtlMd.CreateBy = HttpContext.GetName();
|
|
|
+ stkBalanceDtlMd.CreateTime = DateTime.Now;
|
|
|
+ stkBalanceDtlMd.UpdateBy = HttpContext.GetName();
|
|
|
+ stkBalanceDtlMd.UpdateTime = DateTime.Now;
|
|
|
+ stkBalanceDtlMd.BalanceQty = inInstoreRecordMd.InStoreQty;
|
|
|
+ stkBalanceDtlMd.Status = 55;
|
|
|
+
|
|
|
+
|
|
|
+ response3 += _InInstoreRecordService.AddInInstoreRecord(inInstoreRecordMd);
|
|
|
+ int stkBalanceId = _StkBalanceDtlService.AddStkBalanceDtlReturnIdentity(stkBalanceDtlMd);
|
|
|
+ stkBalanceDtlMd.BalanceId = stkBalanceId;
|
|
|
+ StkBalanceLst.Add(stkBalanceDtlMd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (StkBalanceDtl item in StkBalanceLst)
|
|
|
+ {
|
|
|
+ OutOutstoreRecord outOutstoreMd = item.Adapt<OutOutstoreRecord>();
|
|
|
+ if (string.IsNullOrWhiteSpace(item.BomNo))
|
|
|
+ {
|
|
|
+ outOutstoreMd.BomNo = "FastOutStore001";
|
|
|
+ outOutstoreMd.OutSotreNo = "FastOutStore001";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ outOutstoreMd.OutSotreNo = "FastOutStore001";
|
|
|
+ }
|
|
|
+ outOutstoreMd.BnSnCode = item.BnSnCode;
|
|
|
+ outOutstoreMd.OutStoreQty = item.BalanceQty;
|
|
|
+ outOutstoreMd.Result = 99;
|
|
|
+ outOutstoreMd.CreateBy = HttpContext.GetName();
|
|
|
+ outOutstoreMd.CreateTime = DateTime.Now;
|
|
|
+ outOutstoreMd.CreateBy = HttpContext.GetName();
|
|
|
+ outOutstoreMd.CreateTime = DateTime.Now;
|
|
|
+ outOutstoreMd.UpdateBy = HttpContext.GetName();
|
|
|
+ outOutstoreMd.UpdateTime = DateTime.Now;
|
|
|
+ response3 += _OutOutstoreRecordService.Insert(outOutstoreMd);
|
|
|
+
|
|
|
+ item.OutQty += item.BalanceQty;
|
|
|
+ item.UpdateBy = HttpContext.GetName();
|
|
|
+ item.UpdateTime = DateTime.Now;
|
|
|
+ item.Status = 88;
|
|
|
+ response3 += _StkBalanceDtlService.Update(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ToResponse(response + response1 + response3);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|