| | |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | db.Deleteable<BAS_LABEL_TEMP>().Where(x => x.ID == Id).ExecuteCommand(); |
| | | db.Deleteable<BAS_LABEL_VAR>().Where(x => x.LABEL_ID == Id).ExecuteCommand(); |
| | | db.Deleteable<BAS_LABEL_VAR_WO>().Where(x => x.LABEL_ID == Id).ExecuteCommand(); |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | |
| | | { |
| | | BAS_LABEL_TEMP? prodTemp = null; |
| | | BAS_LABEL_TEMP? prodCustTemp = null; |
| | | var ltemp = await Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(x => x.LABEL_CODE == input.Label.LABEL_CODE).FirstAsync(); |
| | | //如果传入的标签客户编码不为空 |
| | | if (!input.Label.CUST_CODE.IsNullOrEmpty()) |
| | | { |
| | | //如果查不到标签并且客户编码不为空 |
| | | if (!Biz.Db.Queryable<BAS_LABEL_TEMP>().Any(x => x.LABEL_CODE == input.Label.LABEL_CODE)) |
| | | if (ltemp == null) |
| | | { |
| | | prodCustTemp = input.Label; |
| | | prodTemp = input.Label.Clone(); |
| | |
| | | else |
| | | { |
| | | prodCustTemp = input.Label; |
| | | if (Biz.Db.Queryable<BAS_LABEL_TEMP>().Any(x => |
| | | x.LABEL_CODE == input.Label.LABEL_CODE && ( |
| | | (x.PROD_CODE != input.Label.PROD_CODE && x.CUST_CODE == input.Label.CUST_CODE) || |
| | | (x.PROD_CODE != input.Label.PROD_CODE && x.CUST_CODE != input.Label.CUST_CODE) || |
| | | (x.PROD_CODE == input.Label.PROD_CODE && x.CUST_CODE != input.Label.CUST_CODE)))) |
| | | if ((ltemp.PROD_CODE != input.Label.PROD_CODE && ltemp.CUST_CODE == input.Label.CUST_CODE) || |
| | | (ltemp.PROD_CODE != input.Label.PROD_CODE && ltemp.CUST_CODE != input.Label.CUST_CODE) || |
| | | (ltemp.PROD_CODE == input.Label.PROD_CODE && ltemp.CUST_CODE != input.Label.CUST_CODE)) |
| | | { |
| | | prodCustTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); |
| | | } |
| | |
| | | { |
| | | //如果客户编码为空 |
| | | prodTemp = input.Label; |
| | | if (Biz.Db.Queryable<BAS_LABEL_TEMP>().Any(x => x.LABEL_CODE == input.Label.LABEL_CODE && x.PROD_CODE != input.Label.PROD_CODE)) |
| | | if (ltemp != null && (ltemp.PROD_CODE.IsNullOrEmpty() || ltemp.PROD_CODE != input.Label.PROD_CODE)) |
| | | { |
| | | prodTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); |
| | | } |
| | |
| | | item.LABEL_ID = temp.ID; |
| | | } |
| | | } |
| | | db.Deleteable<BAS_LABEL_VAR_WO>(false).Where(x => x.LABEL_ID == input.LabelVarWos[0].LABEL_ID).ExecuteCommand(); |
| | | var o = db.Storageable(input.LabelVarWos) |
| | | .WhereColumns(t => new { t.LABEL_ID, t.VAR_NAME, t.GHOST_ROW }) |
| | | .WhereColumns(t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW }) |
| | | .ToStorage(); |
| | | o.AsInsertable.ExecuteCommand(); |
| | | o.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存标签模板变量 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> SaveLabelTemplateVar(BasLabelTempInput input) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | if (input.LabelVars != null && input.LabelVars.Count > 0) |
| | | { |
| | | db.Deleteable<BAS_LABEL_VAR>(false).Where(x => x.LABEL_ID == input.LabelVars[0].LABEL_ID).ExecuteCommand(); |
| | | var z = db.Storageable(input.LabelVars) |
| | | .WhereColumns(t => new { t.LABEL_ID, t.VAR_NAME, t.GHOST_ROW }) |
| | | .ToStorage(); |
| | | z.AsInsertable.ExecuteCommand(); |
| | | z.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | | } |
| | | if (input.LabelVarWos != null && input.LabelVarWos.Count > 0) |
| | | { |
| | | db.Deleteable<BAS_LABEL_VAR_WO>(false).Where(x => x.LABEL_ID == input.LabelVarWos[0].LABEL_ID).ExecuteCommand(); |
| | | var o = db.Storageable(input.LabelVarWos) |
| | | .WhereColumns(t => new { t.LABEL_ID, t.WORK_ORDER, t.VAR_NAME, t.GHOST_ROW }) |
| | | .ToStorage(); |
| | | o.AsInsertable.ExecuteCommand(); |
| | | o.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | | } |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"保存标签变量异常!"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, "保存标签变量异常"); |
| | | } |
| | | return await Task.FromResult(result); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据分隔符生成Code名 |
| | | /// </summary> |
| | | /// <param name="data"></param> |