using Apache.NMS;
|
using Newtonsoft.Json;
|
using Rhea.Common;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Mvc;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using Tiger.IBusiness;
|
using Tiger.Model;
|
using System.Xml.Linq;
|
using System.Collections;
|
|
namespace Tiger.Business.WMS
|
{
|
public partial class BS
|
{
|
/// <summary>
|
/// 完工入库,物料转卖
|
/// </summary>
|
/// <returns></returns>
|
public ApiAction MaterialResale(string billcode, string whcode, string org_code)
|
{
|
try
|
{
|
var action = new ApiAction();
|
var wh_id = GetWmsCode(whcode);//库位id
|
var items = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.TRANS_NO == billcode).ToList();
|
var items_pkg = Biz.Db.Queryable<WMS_ITEM_PKG>().Where(q => q.TRANS_NO == billcode).ToList();
|
var ProdIn = Biz.Db.Queryable<BIZ_ERP_PROD_IN>().Where(q => q.BILLCODE == billcode).First();
|
if (items.Count() == 0)
|
{
|
action.Message = "库存表查无数据";
|
action.IsSuccessed = false;
|
return action;
|
}
|
if (items_pkg.Count() == 0)
|
{
|
action.Message = "包装表查无数据";
|
action.IsSuccessed = false;
|
return action;
|
}
|
if (ProdIn.IsNullOrEmpty())
|
{
|
action.Message = "查无此单据";
|
action.IsSuccessed = false;
|
return action;
|
}
|
foreach (var item in items)
|
{
|
item.AUTH_ORG = org_code;
|
item.WH_ID = wh_id.Result;
|
item.ERP_WH = whcode;
|
}
|
foreach (var item in items_pkg)
|
{
|
item.AUTH_ORG = org_code;
|
item.WH_ID = wh_id.Result;
|
item.ERP_WH = whcode;
|
}
|
ProdIn.STATUS = BIZ_ERP_PROD_IN.STATUSs.COMPLETE.GetValue();
|
|
var db = Business.Biz.Db;
|
//入库
|
|
var dbTran = db.UseTran(() =>
|
{
|
db.Updateable(items).ExecuteCommand();
|
db.Updateable(items_pkg).ExecuteCommand();
|
db.Updateable(ProdIn).ExecuteCommand();
|
});
|
if (!dbTran.IsSuccess)
|
{
|
action.Message = "转卖失败";
|
}
|
else
|
{
|
action.Message = "转卖成功";
|
}
|
|
return action;
|
}
|
catch (Exception ex)
|
{
|
|
throw;
|
}
|
}
|
}
|
}
|