using Tiger.Model;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq.Expressions;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Rhea.Common;
|
using System.Net;
|
using System.Linq;
|
using Newtonsoft.Json;
|
using Tiger.IBusiness;
|
using static Tiger.Business.Biz;
|
using Microsoft.AspNetCore.Http;
|
|
namespace Tiger.Business.MES
|
{
|
public partial class BizMesWo : IBIZ_MES_WO
|
{
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="wo"></param>
|
/// <returns></returns>
|
public async Task<ApiAction> SaveMesWo(BIZ_MES_WO wo)
|
{
|
var result = new ApiAction();
|
try
|
{
|
var _wo = Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == wo.ORDER_NO).First();
|
if (_wo != null && _wo.STATUS != (int)BIZ_MES_WO.STATUSs.Init)
|
{
|
result.IsSuccessed = false;
|
result.LocaleMsg = new($"工单已经存在且不是初始化状态,不能保存修改!");
|
return result;
|
}
|
var db = Db;
|
var dbTran = db.UseTran(() =>
|
{
|
var y = db.Storageable(wo)
|
.WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW })
|
.ToStorage();
|
y.AsInsertable.ExecuteCommand();
|
y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
|
});
|
if (!dbTran.IsSuccess)
|
{
|
result.IsSuccessed = false;
|
result.Message = $"保存工单异常";
|
}
|
}
|
catch (Exception ex)
|
{
|
result.CatchExceptionWithLog(ex, "保存工单异常");
|
}
|
return await Task.FromResult(result);
|
}
|
|
/// <summary>
|
/// 删除工单
|
/// </summary>
|
/// <param name="woId"></param>
|
/// <returns></returns>
|
public async Task<ApiAction> DeleteMesWo(string woId)
|
{
|
var result = new ApiAction();
|
try
|
{
|
//查询是否已经有工单在用
|
var _wo = Db.Queryable<BIZ_MES_WO>().Where(x => x.ID == woId).First();
|
if (_wo != null && _wo.STATUS != (int)BIZ_MES_WO.STATUSs.Init)
|
{
|
result.IsSuccessed = false;
|
result.LocaleMsg = new($"工单不是初始化状态,不能删除!");
|
return result;
|
}
|
var db = Db;
|
var dbTran = db.UseTran(() =>
|
{
|
db.Deleteable<BIZ_MES_WO>().Where(x => x.ID == woId).ExecuteCommand();
|
});
|
if (!dbTran.IsSuccess)
|
{
|
result.IsSuccessed = false;
|
result.LocaleMsg = new($"删除工单异常");
|
}
|
}
|
catch (Exception ex)
|
{
|
result.CatchExceptionWithLog(ex, "删除工单异常");
|
}
|
return await Task.FromResult(result);
|
}
|
}
|
}
|