服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-04-13 db7f57324b8b0e0afc669a7d8127b696766168bc
盟祺-查询条码API
已添加3个文件
164 ■■■■■ 文件已修改
Tiger.Api/Controllers/WMS/WMSController.MqSNData.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/MengQi/Biz.Mq.SNData.cs 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness/WMS/MengQi/IMqSNData.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api/Controllers/WMS/WMSController.MqSNData.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Mvc;
using Rhea.Common;
using System.Collections.Generic;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Api.Controllers.WMS
{
    public partial class WMSController : ControllerBase
    {
        /// <summary>
        /// é€€å›žåˆ é™¤
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/[action]")]
        public async Task<IActionResult> ReturnSN([FromBody] ApiAction action)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<IMqSNData>().ReturnSN(action.Data?.ToString()));
            }
            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> GetSNDataHis([FromBody] ApiAction<PageAble<SNData_His>> action)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<IMqSNData>().GetSNDataHis(action.Data));
            }
            catch (System.Exception ex)
            {
                response = response.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}
Tiger.Business/WMS/MengQi/Biz.Mq.SNData.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,94 @@
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
using static Tiger.Business.Biz;
namespace Tiger.Business
{
    public partial class Biz
    {
        /// <summary>
        /// SN操作
        /// </summary>
        public partial class MqSNData : IMqSNData
        {
            /// <summary>
            /// é€€å›žåˆ é™¤æ¡ç 
            /// </summary>
            /// <param name="barcode"></param>
            /// <returns></returns>
            public async Task<ApiAction> ReturnSN(string barcode)
            {
                var result = new ApiAction();
                try
                {
                    SNData_His data_His = await Db.Queryable<SNData_His>().Where(x => x.OriginalSN == barcode).FirstAsync();
                    if (data_His == null)
                    {
                        result.IsSuccessed = false;
                        result.Message = $"退回删除条码不存在";
                        return result;
                    }
                    List<SNData> sndatas = await Db.Queryable<SNData>().Where(x => x.SN == barcode || x.SN == data_His.SN).ToListAsync();
                    if (sndatas == null && sndatas.Count>0)
                    {
                        result.IsSuccessed = false;
                        result.Message = $"退回删除条码不存在";
                        return result;
                    }
                    var db = Db;
                    var dbTran = db.UseTran(() =>
                    {
                        db.Deleteable(data_His).ExecuteCommand();
                        db.Deleteable(sndatas).ExecuteCommand();
                    });
                    if (!dbTran.IsSuccess)
                    {
                        result.IsSuccessed = false;
                        result.Message = $"退回删除条码异常";
                    }
                }
                catch (Exception ex)
                {
                    result.CatchExceptionWithLog(ex, "退回删除条码异常");
                }
                return result;
            }
            /// <summary>
            /// åˆ†é¡µ
            /// </summary>
            /// <param name="pageList"></param>
            /// <returns></returns>
            public async Task<ApiAction<PageAble<SNData_His>>> GetSNDataHis(PageAble<SNData_His> pageList)
            {
                var res = new ApiAction<PageAble<SNData_His>>();
                try
                {
                    string[] strTime = pageList.sqlcmd?.Split(',');
                    RefAsync<int> total = 0;
                    pageList.data = await Db.Queryable<SNData_His>()
                        .WhereIF(!string.IsNullOrEmpty(strTime[0]), x => Convert.ToDateTime(x.ScanTime) > Convert.ToDateTime(strTime[0]))
                        .WhereIF(!string.IsNullOrEmpty(strTime[1]) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < Convert.ToDateTime(strTime[1]))
                        .WhereIF(!string.IsNullOrEmpty(strTime[2]), x => x.ModelCode.Equals(strTime[2]))
                        .WhereIF(!string.IsNullOrEmpty(strTime[3]), x => x.CustomerCode.Equals(strTime[3]))
                        .ToPageListAsync(pageList.pageIndex, pageList.pageSize, total);
                    pageList.totals = total;
                }
                catch (Exception ex)
                {
                    res.CatchExceptionWithLog(ex, "查询异常");
                }
                res.Data = pageList;
                return res;
            }
        }
    }
}
Tiger.IBusiness/WMS/MengQi/IMqSNData.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 IMqSNData
    {
        public Task<ApiAction> ReturnSN(string barcode);
        public Task<ApiAction<PageAble<SNData_His>>> GetSNDataHis(PageAble<SNData_His> pageList);
    }
}