182 lines
6.7 KiB
C#
182 lines
6.7 KiB
C#
using BLL.API;
|
|
using Model;
|
|
using Model.APIItem;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
|
|
namespace WebAPI.Controllers
|
|
{
|
|
public class WeldController : ApiController
|
|
{
|
|
[HttpGet]
|
|
public Model.ResponeData usingPlanList(string weldName, string userId, string useState, int page, int pageSize)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(weldName) || weldName == "null")
|
|
{
|
|
weldName = "";
|
|
}
|
|
//if (string.IsNullOrEmpty(needConfirm) || needConfirm == "null")
|
|
//{
|
|
// needConfirm = "";
|
|
//}
|
|
if (string.IsNullOrEmpty(userId) || userId == "null")
|
|
{
|
|
userId = "";
|
|
}
|
|
if (string.IsNullOrEmpty(useState) || useState == "null")
|
|
{
|
|
useState = "";
|
|
}
|
|
return APIWeldServices.usingPlanList(weldName, userId, useState, page, pageSize);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = e.Message;
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
[HttpGet]
|
|
public Model.ResponeData getUsingPlanById(string usingPlanId)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
try
|
|
{
|
|
|
|
return APIWeldServices.getUsingPlanById(usingPlanId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = e.Message;
|
|
}
|
|
return respone;
|
|
}
|
|
[HttpGet]
|
|
public Model.ResponeData welderQueIsPass(string welderId, string steelType, bool isSteelStru)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(welderId) || welderId == "null")
|
|
{
|
|
welderId = "";
|
|
}
|
|
if (string.IsNullOrEmpty(steelType) || steelType == "null")
|
|
{
|
|
steelType = "";
|
|
}
|
|
|
|
return APIWeldServices.welderQueIsPass(welderId, steelType, isSteelStru);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = e.Message;
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
[HttpGet]
|
|
public Model.ResponeData isHaveWeld(string welderId, string unitStoreId)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
try
|
|
{
|
|
Model.SGGLDB db = BLL.Funs.DB;
|
|
var q = from x in db.Weld_WeldInfo
|
|
where (from y in db.Weld_StockIn where y.UnitStoreId == unitStoreId && y.WeldId == welderId select y.Amount ?? 0).Sum() - (from y in db.Weld_StockIn where y.UnitStoreId == unitStoreId && y.WeldId == welderId select y.UsingAmount ?? 0).Sum() + (from y in db.Weld_StockIn where y.UnitStoreId == unitStoreId && y.WeldId == welderId select y.RecycleAmount ?? 0).Sum() > 0 && (x.IsLock == null || x.IsLock == false)
|
|
orderby x.WeldCode
|
|
select x;
|
|
if (q.Count() == 0)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = "所选焊材无库存,请联系仓库保管员!";
|
|
return respone;
|
|
}
|
|
else
|
|
{
|
|
respone.code = 1;
|
|
return respone;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = e.Message;
|
|
}
|
|
return respone;
|
|
}
|
|
|
|
[HttpPost]
|
|
public Model.ResponeData addUsingPlan([FromBody] UsingPlanItem usingPlan)
|
|
{
|
|
Model.ResponeData respone = new ResponeData();
|
|
try
|
|
{
|
|
var weld = BLL.WeldInfoService.GetWeldInfoById(usingPlan.WeldId);
|
|
if (weld != null)
|
|
{
|
|
var weldtype = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
|
|
var welder = BLL.HJGL_PersonManageService.GetWelderByWenId(usingPlan.UsingManOne);
|
|
if (welder.MaxHanTiao != null && welder.MaxHanTiao != null)
|
|
{
|
|
if (usingPlan.Amount > 0)
|
|
{
|
|
if (weldtype.WeldTypeName.Contains("焊条"))
|
|
{
|
|
if (usingPlan.Amount > welder.MaxHanTiao)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = "超过该焊工的最大领用数量,请重新录入计划领用数量!";
|
|
return respone;
|
|
}
|
|
|
|
}
|
|
if (weldtype.WeldTypeName.Contains("焊丝"))
|
|
{
|
|
if (usingPlan.Amount > welder.MaxWeldingWire)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = "超过该焊工的最大领用数量,请重新录入计划领用数量!";
|
|
return respone;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(weld.WeldSpec))
|
|
{
|
|
var spec = from x in BLL.Funs.DB.Weld_Specifications where x.Specifications == weld.WeldSpec && x.WeldTypeId == weld.WeldTypeId select x;
|
|
if (spec.Count() > 0)
|
|
{
|
|
if (usingPlan.Amount > 0)
|
|
{
|
|
if (usingPlan.Amount > spec.First().MaxUsingNum)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = "超过最大领用数量,请重新录入计划领用数量!";
|
|
return respone;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return APIWeldServices.addUsingPlan(usingPlan);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
respone.code = 0;
|
|
respone.message = e.Message;
|
|
}
|
|
return respone;
|
|
|
|
}
|
|
}
|
|
} |