服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-10-24 4e7803e64656655103a96c4e426bf1bf2563e3f7
Tiger.Business.MES/BIZ/BIZ_MES_WO.cs
@@ -329,27 +329,34 @@
            try
            {
                //保存前的判断
                if (input.WORK_ORDER.IsNullOrEmpty())
                if (input.WORK_ORDER.IsNullOrEmpty() && input.PROD_CODE.IsNullOrEmpty())
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"工单号不能为空!");
                    result.LocaleMsg = new($"工单号或者产品编码不能为空!");
                    return result;
                }
                List<BAS_LABEL_VAR_WO> varWoList = new();
                string imageFileName = Path.GetFileNameWithoutExtension(input.LABEL_VIEW_PATH);
                string path = @$"{BizConfig.Configuration["UploadAddress"]}//Upload/Template//Temp//{ imageFileName}.png";
                string path = @$"{BizConfig.Configuration["UploadAddress"]}//Upload/Template//Temp//{imageFileName}.png";
                if (File.Exists(path))
                {
                    varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == input.LABEL_ID && x.WORK_ORDER == input.WORK_ORDER).ToListAsync();
                    foreach (var item in varWoList) {
                    varWoList = await Biz.Db.Queryable<BAS_LABEL_VAR_WO>()
                        .Where(x => x.LABEL_ID == input.LABEL_ID)
                        .WhereIF(!input.WORK_ORDER.IsNullOrEmpty(), x => x.WORK_ORDER == input.WORK_ORDER)
                        .WhereIF(!input.PROD_CODE.IsNullOrEmpty(), x => x.PROD_CODE == input.PROD_CODE)
                        .ToListAsync();
                    foreach (var item in varWoList)
                    {
                        item.LABEL_VIEW_PATH = $"{BizConfig.Configuration["DownloadAddress"]}//Template//Temp//{imageFileName}.png";
                    }
                }
                var db = Biz.Db;
                var dbTran = db.UseTran(() =>
                {
                    Expression<Func<BAS_LABEL_VAR_WO, object>> predicate = !input.WORK_ORDER.IsNullOrEmpty() ? t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW } :
                    !input.PROD_CODE.IsNullOrEmpty() ? t => new { t.LABEL_ID, t.PROD_CODE, t.VAR_NAME, t.GHOST_ROW } : t => new { t.LABEL_ID, t.VAR_NAME, t.GHOST_ROW };
                    var y = db.Storageable(input)
                       .WhereColumns(t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW })
                       .WhereColumns(predicate)
                       .ToStorage();
                    y.AsInsertable.ExecuteCommand();
                    y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
@@ -403,7 +410,7 @@
                var queryable = Biz.Db.Queryable<BAS_LABEL_VAR_WO>()
                    .Where(q => q.LABEL_ID.Equals(labeltemp.ID))
                    .WhereIF(!input.WorkOrder.IsNullOrEmpty(), q => q.WORK_ORDER.Equals(input.WorkOrder))
                    .WhereIF(!input.ProdCode.IsNullOrEmpty(), q=>q.PROD_CODE.Equals(input.ProdCode))
                    .WhereIF(!input.ProdCode.IsNullOrEmpty(), q => q.PROD_CODE.Equals(input.ProdCode))
                    .WhereIF(!input.CustCode.IsNullOrEmpty(), q => q.PROD_CODE.Equals(input.CustCode));
                query.page = await queryable.ToPageAsync(input.page, input.pageSize);
                //如果不存在,则返回初始数据
@@ -426,6 +433,7 @@
                            var list = queryable.ToList().Where(q => q.VAR_NAME == item.VAR_NAME).First();
                            item.ID = list?.ID;
                            item.WORK_ORDER = input.WorkOrder;
                            item.PROD_CODE = input.ProdCode;
                            item.VAR_VALUE = list?.VAR_VALUE;
                            item.LABEL_VIEW_PATH = list?.LABEL_VIEW_PATH;
                        }
@@ -442,5 +450,37 @@
            }
            return result;
        }
        /// <summary>
        /// 获取重打标签信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiAction<LOG_LABEL_PRINT>> GetRePrintInfo(RePrintInput input)
        {
            var result = new ApiAction<LOG_LABEL_PRINT>();
            try
            {
                //先查出工单条码中是否存在
                var woSn = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.SN.Equals(input.Code) || q.FLOW_SN.Equals(input.Code)).FirstAsync();
                if (woSn == null)
                {
                    result.IsSuccessed = false;
                    result.LocaleMsg = new($"条码不存在!");
                    return result;
                }
                result.Data = await Biz.Db.Queryable<LOG_LABEL_PRINT>()
                    .WhereIF(input.ReqType == 0, q => q.SN.Equals(input.Code)) //白盒标签
                    .WhereIF(input.ReqType == 1, q => q.SN.Equals(woSn.OUTER_SN)) //箱标签
                    .FirstAsync();
            }
            catch (Exception ex)
            {
                result.CatchExceptionWithLog(ex, "获取重打标签信息异常");
            }
            return result;
        }
    }
}