|
@@ -12,6 +12,7 @@ using ZR.Model.Dto.Inspect;
|
|
|
using ZR.Model.Models.Inspect;
|
|
|
using ZR.Service.Business.Inspect;
|
|
|
using UAParser;
|
|
|
+using System.Net.Security;
|
|
|
|
|
|
namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
{
|
|
@@ -163,6 +164,13 @@ namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
return SUCCESS(response);
|
|
|
}
|
|
|
|
|
|
+ [HttpPost("QueryInspectRecordData")]
|
|
|
+ public IActionResult QueryInspectRecordData(string deliverNo,string materialSpecCode)
|
|
|
+ {
|
|
|
+ var response = _QaInspectRecordService.GetCheckedSapDeliverRecordList(deliverNo,materialSpecCode);
|
|
|
+ return SUCCESS(response);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 添加质检记录,并更新对应的交验单明细
|
|
|
/// </summary>
|
|
@@ -177,25 +185,104 @@ namespace ZR.Admin.WebApi.Controllers.Inspect
|
|
|
{
|
|
|
throw new CustomException("请求实体不能为空");
|
|
|
}
|
|
|
- SapDeliverRecord sapDeliverRecordMd = parm.Adapt<SapDeliverRecord>().ToUpdate(HttpContext);
|
|
|
- QaInspectRecord qaInspectRecordMd = parm.Adapt<QaInspectRecord>();
|
|
|
- sapDeliverRecordMd.CheckQty += parm.CheckOkQty;
|
|
|
- if (sapDeliverRecordMd.CheckQty >= sapDeliverRecordMd.Qty)
|
|
|
+
|
|
|
+
|
|
|
+ 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)
|
|
|
{
|
|
|
- sapDeliverRecordMd.CheckResult = "OK";
|
|
|
+ throw new CustomException($"交验单:{parm.DeliverNo} 未查询到物料号:{parm.MaterialSpec} 的明细数据!");
|
|
|
}
|
|
|
- qaInspectRecordMd.InspectNo = parm.DeliverNo;
|
|
|
- qaInspectRecordMd.InspectedBy = HttpContext.GetName();
|
|
|
- qaInspectRecordMd.InspectTime = DateTime.Now;
|
|
|
- qaInspectRecordMd.CreateBy = HttpContext.GetName();
|
|
|
- qaInspectRecordMd.CreateTime = DateTime.Now;
|
|
|
- qaInspectRecordMd.UpdateBy = HttpContext.GetName();
|
|
|
- qaInspectRecordMd.UpdateTime = DateTime.Now;
|
|
|
- qaInspectRecordMd.Result = "OK";
|
|
|
- qaInspectRecordMd.CheckQty = parm.CheckOkQty;
|
|
|
-
|
|
|
- int response = _SapDeliverRecordService.UpdateSapDeliverRecord(sapDeliverRecordMd);
|
|
|
- int response1 = _QaInspectRecordService.AddQaInspectRecord(qaInspectRecordMd);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ 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 = (int)sapDeliverMd.CheckQty;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ QaInspectList.Add(qaInspectRecord);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ allotNum += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckQty += tmpNeedNum;
|
|
|
+ sapDeliverMd.CheckResult = "OK";
|
|
|
+ sapDeliverMd.UpdateBy = HttpContext.GetName();
|
|
|
+ sapDeliverMd.UpdateTime = DateTime.Now;
|
|
|
+ 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 = (int)sapDeliverMd.CheckQty;
|
|
|
+ qaInspectRecord.BnSnCode = parm.BnSnCode;
|
|
|
+ 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]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //SapDeliverRecord sapDeliverRecordMd = parm.Adapt<SapDeliverRecord>().ToUpdate(HttpContext);
|
|
|
+ //QaInspectRecord qaInspectRecordMd = parm.Adapt<QaInspectRecord>();
|
|
|
+ //sapDeliverRecordMd.CheckQty += parm.CheckOkQty;
|
|
|
+ //if (sapDeliverRecordMd.CheckQty >= sapDeliverRecordMd.Qty)
|
|
|
+ //{
|
|
|
+ // sapDeliverRecordMd.CheckResult = "OK";
|
|
|
+ //}
|
|
|
+ //qaInspectRecordMd.InspectNo = parm.DeliverNo;
|
|
|
+ //qaInspectRecordMd.InspectedBy = HttpContext.GetName();
|
|
|
+ //qaInspectRecordMd.InspectTime = DateTime.Now;
|
|
|
+ //qaInspectRecordMd.CreateBy = HttpContext.GetName();
|
|
|
+ //qaInspectRecordMd.CreateTime = DateTime.Now;
|
|
|
+ //qaInspectRecordMd.UpdateBy = HttpContext.GetName();
|
|
|
+ //qaInspectRecordMd.UpdateTime = DateTime.Now;
|
|
|
+ //qaInspectRecordMd.Result = "OK";
|
|
|
+ //qaInspectRecordMd.CheckQty = parm.CheckOkQty;
|
|
|
+
|
|
|
+ //int response = _SapDeliverRecordService.UpdateSapDeliverRecord(sapDeliverRecordMd);
|
|
|
+ //int response1 = _QaInspectRecordService.AddQaInspectRecord(qaInspectRecordMd);
|
|
|
|
|
|
return ToResponse(response + response1);
|
|
|
}
|