服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-05-29 d27b448ee5b4d0b63c7d2955a62155995328c83d
车间更新
已重命名1个文件
已添加3个文件
163 ■■■■■ 文件已修改
Tiger.Api/Controllers/MES/MESController.MES_WORKSHOP.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/MES/Biz.MES_WORKSHOP.cs 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness/MES/IMES_WO.cs 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness/MES/IMES_WORKSHOP.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api/Controllers/MES/MESController.MES_WORKSHOP.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
using Microsoft.AspNetCore.Mvc;
using Rhea.Common;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Api.Controllers.MES
{
    public partial class MESController : ControllerBase
    {
        /// <summary>
        /// ä¿å­˜è½¦é—´
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/[action]")]
        public async Task<IActionResult> SaveMesWs([FromBody] ApiAction<MES_WORKSHOP> action)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<IMES_WORKSHOP>().SaveMesWs(action.Data));
            }
            catch (System.Exception ex)
            {
                response = response.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
        /// <summary>
        /// åˆ é™¤è½¦é—´
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/[action]")]
        public async Task<IActionResult> DeleteMesWs([FromBody] ApiAction action)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<IMES_WORKSHOP>().DeleteMesWs(action.Data?.ToString()));
            }
            catch (System.Exception ex)
            {
                response = response.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}
Tiger.Business/MES/Biz.MES_WORKSHOP.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,92 @@
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
{
    public partial class Biz
    {
        /// <summary>
        /// è½¦é—´
        /// </summary>
        public partial class BizMesWs : IMES_WORKSHOP
        {
            /// <summary>
            /// ä¿å­˜
            /// </summary>
            /// <param name="ws"></param>
            /// <returns></returns>
            public async Task<ApiAction> SaveMesWs(MES_WORKSHOP ws)
            {
                var result = new ApiAction();
                try
                {
                    if (Db.Queryable<MES_WORKSHOP>().Where(x => x.WS_CODE == ws.WS_CODE && x.ID != ws.ID).Any())
                    {
                        result.IsSuccessed = false;
                        result.LocaleMsg = new($"车间已经存在,不能新增!");
                        return result;
                    }
                    var db = Db;
                    var dbTran = db.UseTran(() =>
                    {
                        var y = db.Storageable(ws)
                           .WhereColumns(t => new { t.WS_CODE, 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="wsId"></param>
            /// <returns></returns>
            public async Task<ApiAction> DeleteMesWs(string wsId) {
                var result = new ApiAction();
                try
                {
                    //查询是否已经有车间在用
                    var db = Db;
                    var dbTran = db.UseTran(() =>
                    {
                        db.Deleteable<MES_WORKSHOP>().Where(x => x.ID == wsId).ExecuteCommand();
                    });
                    if (!dbTran.IsSuccess)
                    {
                        result.IsSuccessed = false;
                        result.LocaleMsg = new($"删除车间异常");
                    }
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, "删除车间异常");
                }
                return await Task.FromResult(result);
            }
        }
    }
}
Tiger.IBusiness/MES/IMES_WO.cs
Tiger.IBusiness/MES/IMES_WORKSHOP.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
namespace Tiger.IBusiness
{
    public interface IMES_WORKSHOP
    {
        public Task<ApiAction> SaveMesWs(MES_WORKSHOP ws);
        public Task<ApiAction> DeleteMesWs(string wsId);
    }
}