1
This commit is contained in:
@@ -421,6 +421,8 @@ namespace BLL.API
|
|||||||
var usingPlans = from x in db.Weld_UsingPlan
|
var usingPlans = from x in db.Weld_UsingPlan
|
||||||
where x.UnitStoreId == unitStoreId && x.UsingManOne == wED_ID
|
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;
|
select x;
|
||||||
if (usingPlans.Count() > 0)
|
if (usingPlans.Count() > 0)
|
||||||
{
|
{
|
||||||
@@ -499,6 +501,7 @@ namespace BLL.API
|
|||||||
if (!string.IsNullOrEmpty(planItem.UsingManOne))
|
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.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))
|
if (!string.IsNullOrEmpty(planItem.UsingManTwo))
|
||||||
{
|
{
|
||||||
@@ -525,6 +528,88 @@ namespace BLL.API
|
|||||||
return respone;
|
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)
|
public static Model.ResponeData welderQueIsPass(string welderId, string steelType, bool isSteelStru)
|
||||||
{
|
{
|
||||||
Model.ResponeData respone = new ResponeData();
|
Model.ResponeData respone = new ResponeData();
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace Model.APIItem
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public string UsingManOne { get; set; }
|
public string UsingManOne { get; set; }
|
||||||
|
public string UsingManOneCode { get; set; }
|
||||||
public string UsingManOneName { get; set; }
|
public string UsingManOneName { get; set; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -353,5 +353,31 @@ namespace WebAPI.Controllers
|
|||||||
}
|
}
|
||||||
return respone;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user