diff --git a/HJGL_DS/BLL/API/APIWeldServices.cs b/HJGL_DS/BLL/API/APIWeldServices.cs index 3966e92..fe51019 100644 --- a/HJGL_DS/BLL/API/APIWeldServices.cs +++ b/HJGL_DS/BLL/API/APIWeldServices.cs @@ -420,7 +420,9 @@ namespace BLL.API { var usingPlans = from x in db.Weld_UsingPlan where x.UnitStoreId == unitStoreId && x.UsingManOne == wED_ID - && (x.IsCancel==false || x.IsCancel==null) + && (x.IsCancel == false || x.IsCancel == null) + && x.IsSubmit == true && (x.OrderDate.Value.Date == DateTime.Now.Date || x.OrderDate.Value.AddDays(1) > DateTime.Now) + && !(from y in db.Weld_UsingMat where y.UsingPlanId == x.UsingPlanId select y).Any() select x; if (usingPlans.Count() > 0) { @@ -499,6 +501,7 @@ namespace BLL.API if (!string.IsNullOrEmpty(planItem.UsingManOne)) { planItem.UsingManOneName = db.HJGL_BS_Welder.Where(x => x.WED_ID == planItem.UsingManOne).Select(x => x.WED_Name).FirstOrDefault(); + planItem.UsingManOneCode = db.HJGL_BS_Welder.Where(x => x.WED_ID == planItem.UsingManOne).Select(x => x.WED_Code).FirstOrDefault(); } if (!string.IsNullOrEmpty(planItem.UsingManTwo)) { @@ -525,6 +528,88 @@ namespace BLL.API return respone; } + public static Model.ResponeData saveUsingMat(string usingPlanId, string unitStoreId, string amountStr) + { + Model.ResponeData respone = new ResponeData(); + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var plan = BLL.UsingPlanService.GetUsingPlanById(usingPlanId); + if (plan != null) + { + decimal amount = Funs.GetNewDecimalOrZero(amountStr); + if (amount > plan.Amount) + { + respone.code = 0; + respone.message = "领用数量要不能大于计划数量,请重新录入数量!"; + } + if (amount > 0) + { + string UsingMan = string.Empty; + string UsingMatId = string.Empty; + var stockIn = (from x in db.Weld_StockIn where x.UnitStoreId == unitStoreId && x.WeldId == plan.WeldId && (x.Amount - (x.UsingAmount.HasValue ? x.UsingAmount.Value : 0) + (x.RecycleAmount.HasValue ? x.RecycleAmount.Value : 0)) >= amount orderby x.InStockDate ascending select x).FirstOrDefault(); + if (stockIn != null) + { + string stockInId = stockIn.StockInId; + Model.Weld_UsingMat usingMat = new Model.Weld_UsingMat(); + usingMat.UsingMatId = BLL.SQLHelper.GetNewID(typeof(Model.Weld_UsingMat)); + UsingMatId = usingMat.UsingMatId; + var project = BLL.Base_ProjectService.GetProjectByProjectId(plan.ProjectId); + usingMat.ProjectId = plan.ProjectId; + usingMat.UsingPlanId = usingPlanId; + usingMat.Amount = amount; + usingMat.TwoAmount = 0; + usingMat.UsingMan = plan.UsingManOne; + UsingMan = usingMat.UsingMan; + usingMat.UsingDate = DateTime.Now; + usingMat.Warrantybook = stockIn.Warrantybook; + if (!string.IsNullOrEmpty(stockIn.Number)) + { + usingMat.Number = stockIn.Number; + } + else + { + string perfix = project.ProjectCode + "-"; + usingMat.Number = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCodeByProjectId", "dbo.Weld_UsingMat", "Number", plan.ProjectId, perfix); + } + usingMat.StockInId = stockInId; + usingMat.UsePosition = plan.UsePosition; + usingMat.WeldId = plan.WeldId; + + //var user = BLL.StoremanInfoService.GetStoremanByUserId(CurrUser.UserId); + var user = db.Weld_Storeman.FirstOrDefault(); + if (user != null) + { + usingMat.StoreMan = user.StoremanId; + } + + if (amount == plan.Amount) //全部领取 + { + BLL.UsingMatService.AddUsingMat(usingMat); + // 修改库存已使用的数量 + BLL.StockInService.UpdateStockInUsingAmount(usingMat.StockInId, usingMat.Amount, usingMat.TwoAmount); + } + else + { + + } + + } + else + { + respone.code = 0; + respone.message = "焊材库没有对应焊材的库存!"; + } + } + else + { + respone.code = 0; + respone.message = "无领用数量!"; + } + } + } + return respone; + } + public static Model.ResponeData welderQueIsPass(string welderId, string steelType, bool isSteelStru) { Model.ResponeData respone = new ResponeData(); diff --git a/HJGL_DS/Model/APIItem/UsingPlanItem.cs b/HJGL_DS/Model/APIItem/UsingPlanItem.cs index 310d757..df180da 100644 --- a/HJGL_DS/Model/APIItem/UsingPlanItem.cs +++ b/HJGL_DS/Model/APIItem/UsingPlanItem.cs @@ -47,7 +47,8 @@ namespace Model.APIItem */ public string UsingManOne { get; set; } - public string UsingManOneName { get; set; } + public string UsingManOneCode { get; set; } + public string UsingManOneName { get; set; } /** * 第二领料人 diff --git a/HJGL_DS/WebAPI/Controllers/WeldController.cs b/HJGL_DS/WebAPI/Controllers/WeldController.cs index 6148264..5560089 100644 --- a/HJGL_DS/WebAPI/Controllers/WeldController.cs +++ b/HJGL_DS/WebAPI/Controllers/WeldController.cs @@ -353,5 +353,31 @@ namespace WebAPI.Controllers } return respone; } + + [HttpGet] + public Model.ResponeData saveUsingMat(string usingPlanId, string unitStoreCode, string amount) + { + Model.ResponeData respone = new ResponeData(); + try + { + using (Model.SGGLDB db = new Model.SGGLDB(BLL.Funs.ConnString)) + { + var unitStore = db.Weld_UnitStore.FirstOrDefault(x => x.UnitStoreCode == unitStoreCode); + if (unitStore == null) + { + respone.code = 0; + respone.message = "对应编码的仓库不存在!"; + return respone; + } + return APIWeldServices.saveUsingMat(usingPlanId, unitStore.UnitStoreId, amount); + } + } + catch (Exception e) + { + respone.code = 0; + respone.message = e.Message; + } + return respone; + } } } \ No newline at end of file