|
@@ -1,630 +0,0 @@
|
|
|
-using SCADA.CommonLib;
|
|
|
-using SCADA.CommonLib.Data.DIL;
|
|
|
-using SCADA.CommonLib.Helper;
|
|
|
-using SCADA_DAQ.Customer.Models;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using DBModel;
|
|
|
-using DBNames;
|
|
|
-using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
|
|
|
-using static SCADA_DAQ.Customer.CustomerEnv;
|
|
|
-using Mysqlx;
|
|
|
-using SCADA_DAQ.Customer.Utils;
|
|
|
-using IdGen;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
-
|
|
|
-namespace SCADA_DAQ.Customer.Service
|
|
|
-{
|
|
|
- public partial class WcsService
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// 前端手动合并上架任务,更新已合并字段
|
|
|
- /// </summary>
|
|
|
- /// <param name="wmsItemUpList"></param>
|
|
|
- /// <returns></returns>
|
|
|
- //public RpcResponse<object> MergeItemUpList(List<AppBCItemTaskModel> wmsItemUpList)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var billNOList = wmsItemUpList.ToLookup(t => t.BillNo);
|
|
|
- // var itemUpList = new List<AppBCItemUpModel>();
|
|
|
- // var updateItemUpList = new List<AppBCItemTaskModel>();
|
|
|
- // foreach (var item in billNOList)
|
|
|
- // {
|
|
|
- // foreach (var itemm in item)
|
|
|
- // {
|
|
|
- // if (!itemUpList.Any(t => t.BillNo == itemm.BillNo && t.ItemCode == itemm.ItemCode && t.WarehouseCode == itemm.WarehouseCode))
|
|
|
- // {
|
|
|
- // itemUpList.Add(new AppBCItemUpModel()
|
|
|
- // {
|
|
|
- // ItemNo = itemm.TaskNo,
|
|
|
- // BillNo = itemm.BillNo,
|
|
|
- // ItemCode = itemm.ItemCode,
|
|
|
- // ItemName = itemm.ItemName,
|
|
|
- // OnhandState = itemm.OnhandState,
|
|
|
- // PlannedTotalQty = itemm.PlannedQty,
|
|
|
- // ActualTotalQty = itemm.PlannedQty,
|
|
|
- // UnitCode = itemm.UnitCode,
|
|
|
- // IsSynced = false,
|
|
|
- // SourceLocations = "",
|
|
|
- // LocationItemsNum = "",
|
|
|
- // LocationNum = 0,
|
|
|
- // WarehouseCode = itemm.WarehouseCode,
|
|
|
- // CreateTime = DateTime.Now.ToString()
|
|
|
- // });
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // var itemCode = itemUpList.Where(j => j.BillNo == itemm.BillNo && j.ItemCode == itemm.ItemCode).ToList();
|
|
|
- // itemCode[0].ItemNo += $"/{itemm.TaskNo}";
|
|
|
- // itemCode[0].PlannedTotalQty += itemm.PlannedQty;
|
|
|
- // itemCode[0].ActualTotalQty += itemm.PlannedQty;
|
|
|
- // }
|
|
|
- // updateItemUpList.Add(new AppBCItemTaskModel()
|
|
|
- // {
|
|
|
- // TaskNo = itemm.TaskNo,
|
|
|
- // IsMerged = true
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //CustomerEnv.WMSItemUpList.AddRange(itemUpList);
|
|
|
- // var dbRes = Env.DAL.BatchUpdateOrInsert(
|
|
|
- // updateItemUpList,
|
|
|
- // t => new { t.TaskNo }, //更新条件
|
|
|
- // null,
|
|
|
- // t => new { t.IsMerged } //更新字段
|
|
|
- // ); //批量更新
|
|
|
- // var dbResult = Env.DAL.Insert(itemUpList);
|
|
|
- // // 更新父任务表库位
|
|
|
- // for (int i = 0; i < itemUpList.Count; i++)
|
|
|
- // {
|
|
|
- // var isOK = QueryWMSItemUpListSourceLocations(itemUpList[i]);
|
|
|
- // }
|
|
|
- // if (dbResult.IsSucceed == true && dbRes)
|
|
|
- // {
|
|
|
- // res.Message = $"上架任务合并成功";
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // res.IsSucceed = false;
|
|
|
- // res.Message = $"上架任务合并失败";
|
|
|
- // return res;
|
|
|
- //}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 前端手动合并下架任务,更新已合并字段
|
|
|
- /// </summary>
|
|
|
- /// <param name="wmsItemLowList"></param>
|
|
|
- /// <returns></returns>
|
|
|
- //public RpcResponse<object> MergeItemLowList(List<AppBCItemTaskModel> wmsItemLowList)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var billNOList = wmsItemLowList.ToLookup(t => t.BillNo);
|
|
|
- // var itemLowList = new List<AppBCItemLowModel>();
|
|
|
- // var updateItemLowList = new List<AppBCItemTaskModel>();
|
|
|
- // foreach (var item in billNOList)
|
|
|
- // {
|
|
|
- // foreach (var itemm in item)
|
|
|
- // {
|
|
|
- // if (!itemLowList.Any(t => t.BillNo == itemm.BillNo && t.ItemCode == itemm.ItemCode && t.WarehouseCode == itemm.WarehouseCode))
|
|
|
- // {
|
|
|
- // itemLowList.Add(new AppBCItemLowModel()
|
|
|
- // {
|
|
|
- // ItemNo = itemm.TaskNo,
|
|
|
- // BillNo = itemm.BillNo,
|
|
|
- // ItemCode = itemm.ItemCode,
|
|
|
- // ItemName = itemm.ItemName,
|
|
|
- // OnhandState = itemm.OnhandState,
|
|
|
- // PlannedTotalQty = itemm.PlannedQty,
|
|
|
- // ActualTotalQty = itemm.PlannedQty,
|
|
|
- // UnitCode = itemm.UnitCode,
|
|
|
- // IsSynced = false,
|
|
|
- // SourceLocations = "",
|
|
|
- // LocationItemsNum = "",
|
|
|
- // LocationNum = 0,
|
|
|
- // WarehouseCode = itemm.WarehouseCode,
|
|
|
- // SourceLocationTag = itemm.SourceLocationTag,
|
|
|
- // CreateTime = DateTime.Now.ToString()
|
|
|
- // });
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // var itemCode = itemLowList.Where(j => j.BillNo == itemm.BillNo && j.ItemCode == itemm.ItemCode).ToList();
|
|
|
- // itemCode[0].ItemNo += $"/{itemm.TaskNo}";
|
|
|
- // itemCode[0].PlannedTotalQty += itemm.PlannedQty;
|
|
|
- // itemCode[0].ActualTotalQty += itemm.PlannedQty;
|
|
|
- // }
|
|
|
- // updateItemLowList.Add(new AppBCItemTaskModel()
|
|
|
- // {
|
|
|
- // TaskNo = itemm.TaskNo,
|
|
|
- // IsMerged = true
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // //CustomerEnv.WMSItemLowList.AddRange(itemLowList);
|
|
|
- // var dbRes = Env.DAL.BatchUpdateOrInsert(
|
|
|
- // updateItemLowList,
|
|
|
- // t => new { t.TaskNo }, //更新条件
|
|
|
- // null,
|
|
|
- // t => new { t.IsMerged } //更新字段
|
|
|
- // ); //批量更新
|
|
|
- // var dbResult = Env.DAL.Insert(itemLowList);
|
|
|
- // // 更新父任务表库位
|
|
|
- // for (int i = 0; i < itemLowList.Count; i++)
|
|
|
- // {
|
|
|
- // var isOK = QueryWMSItemLowListSourceLocations(itemLowList[i]);
|
|
|
- // }
|
|
|
- // if (dbResult.IsSucceed == true && dbRes)
|
|
|
- // {
|
|
|
- // res.Message = $"下架任务合并成功";
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // res.IsSucceed = false;
|
|
|
- // res.Message = $"下架任务合并失败";
|
|
|
- // return res;
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- // 获取任务表 上架
|
|
|
- //public RpcResponse<object> GetItemUpTaskTable(PageBo page, AppBCItemTaskVo item, int show, int taskState)
|
|
|
- //{
|
|
|
- // var taskNoSql = item.TaskNo.Split(',');
|
|
|
- // var taskNoinFiler = "";
|
|
|
- // for (var i = 0; i < taskNoSql.Length; i++)
|
|
|
- // {
|
|
|
- // if (taskNoinFiler == "")
|
|
|
- // {
|
|
|
- // taskNoinFiler = $"'{taskNoSql[i]}'";
|
|
|
- // }
|
|
|
- // else taskNoinFiler += $",'{taskNoSql[i]}'";
|
|
|
- // }
|
|
|
- // var taskNoFilterStr = $" TaskNo_Str in ({taskNoinFiler})";
|
|
|
- // var woNoSql = item.WoNo.Split(',');
|
|
|
- // var woNoinFiler = "";
|
|
|
- // for (var i = 0; i < woNoSql.Length; i++)
|
|
|
- // {
|
|
|
- // if (woNoinFiler == "")
|
|
|
- // {
|
|
|
- // woNoinFiler = $"'{woNoSql[i]}'";
|
|
|
- // }
|
|
|
- // else woNoinFiler += $",'{woNoSql[i]}'";
|
|
|
- // }
|
|
|
- // var woNoFilterStr = $" WoNo_Str in ({woNoinFiler})";
|
|
|
- // var woNoFilter = item.WoNo == null ? "1=1" : item.WoNo == "" ? "1=1" : $"{woNoFilterStr}";
|
|
|
- // var taskNoFilter = item.TaskNo == null ? "1=1" : item.TaskNo == "" ? "1=1" : $"{taskNoFilterStr}";
|
|
|
- // var typefilter = $"TaskType_Bit = 1";
|
|
|
- // var billNoFilter = item.BillNo == null ? "1=1" : item.BillNo == "" ? "1=1" : $"BillNo_Str='{item.BillNo}'";
|
|
|
- // var itemCodeFilter = item.ItemCode == null ? "1=1" : item.ItemCode == "" ? "1=1" : $"ItemCode_Str='{item.ItemCode}'";
|
|
|
- // var sourceLocationGroupFilter = item.SourceLocationGroup == null ? "1=1" : item.SourceLocationGroup == "" ? "1=1" : $"SourceLocationGroup_Str='{item.SourceLocationGroup}'";
|
|
|
- // var mergedFilter = show == 1 ? "IsMerged_Bit='1'" : show == 0 ? "IsMerged_Bit='0'" : $"1=1";
|
|
|
- // var taskStateFilter = taskState == 10 ? "1=1" : $"State_Int='{taskState}'";
|
|
|
- // var filterStr = $"{typefilter} and {billNoFilter} and {taskNoFilter} and {itemCodeFilter} and {woNoFilter} and {mergedFilter} and {sourceLocationGroupFilter} and {taskStateFilter}";
|
|
|
- // var sqlStr = GetTableSql("App_BC_ItemTask", filterStr, page);
|
|
|
- // var taskTable = Env.DAL.ReadDataTable(sqlStr).DtToList<AppBCItemTaskVo>();
|
|
|
- // return new RpcResponse<object>()
|
|
|
- // {
|
|
|
- // Data = taskTable
|
|
|
- // };
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- //下架合并 工单号合并
|
|
|
- //public RpcResponse<object> MergeItemLowList(string workNos, string sourceLocationGroup)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var itemWorkNo = workNos;
|
|
|
- // var WorkSql = workNos.Split(',');
|
|
|
- // var inFiler = "";
|
|
|
- // for (var i = 0; i < WorkSql.Length; i++)
|
|
|
- // {
|
|
|
- // if (inFiler == "")
|
|
|
- // {
|
|
|
- // inFiler = $"'{WorkSql[i]}'";
|
|
|
- // }
|
|
|
- // else inFiler += $",'{WorkSql[i]}'";
|
|
|
- // }
|
|
|
- // var mergedList = Env.DAL.App_BC_ItemTask.GetData<App_BC_ItemTask>($"WoNo_Str in ({inFiler}) and IsMerged_Bit = 1 and State_Int = 0 and SourceLocationGroup_Str = '{sourceLocationGroup}'");
|
|
|
- // if (mergedList.Count > 0)
|
|
|
- // {
|
|
|
- // var mergedWoNos = mergedList.GroupBy(t => t.WoNo_Str).Select(t => t.First().WoNo_Str).ToList<string>();
|
|
|
- // res.Message = $"存在合并过的工单号{string.Join(",",mergedWoNos)}货架{sourceLocationGroup}创建任务, 请先删除";
|
|
|
- // res.IsSucceed = false;
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // var taskFilter = $"WoNo_Str in ({inFiler}) and TaskType_Bit = 0 and State_Int = 0 and SourceLocationGroup_Str = '{sourceLocationGroup}'";
|
|
|
- // var taskItemList = Env.DAL.App_BC_ItemTask.GetData<App_BC_ItemTask>(taskFilter);
|
|
|
- // if (taskItemList.Count == 0)
|
|
|
- // {
|
|
|
- // res.Message = $"找不到需要合并的工单号{workNos}创建任务";
|
|
|
- // res.IsSucceed = false;
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // taskItemList = taskItemList.OrderBy(x => x.TaskNo_Str).ToList();
|
|
|
- // var billNoIL = taskItemList.ToLookup(t => new { t.BillNo_Str, t.WorkCenter_Str });
|
|
|
- // var itemLowList = new List<App_BC_ItemLow>();
|
|
|
- // var updateItemTaskList = new List<App_BC_ItemTask>();
|
|
|
- // foreach (var billNoItem in billNoIL)
|
|
|
- // {
|
|
|
- // foreach (var billNoChildItem in billNoItem)
|
|
|
- // {
|
|
|
- // if (!itemLowList.Any(t => t.BillNo_Str == billNoChildItem.BillNo_Str && t.ItemCode_Str == billNoChildItem.ItemCode_Str && t.WarehouseCode_Str == billNoChildItem.WarehouseCode_Str && t.WorkCenter_Str == billNoChildItem.WorkCenter_Str))
|
|
|
- // {
|
|
|
- // itemLowList.Add(new App_BC_ItemLow()
|
|
|
- // {
|
|
|
- // ItemNo_Str = billNoChildItem.TaskNo_Str,
|
|
|
- // BillNo_Str = billNoChildItem.BillNo_Str,
|
|
|
- // ItemCode_Str = billNoChildItem.ItemCode_Str,
|
|
|
- // ItemName_Str = billNoChildItem.ItemName_Str,
|
|
|
- // OnhandState_Int = billNoChildItem.OnhandState_Int,
|
|
|
- // PlannedTotalQty_Dec = billNoChildItem.PlannedQty_Dec,
|
|
|
- // ActualTotalQty_Dec = billNoChildItem.PlannedQty_Dec,
|
|
|
- // UnitCode_Str = billNoChildItem.UnitCode_Str,
|
|
|
- // SourceLocations_Str = "",
|
|
|
- // LocationItemsNum_Str = "",
|
|
|
- // LocationNum_Int = 0,
|
|
|
- // WarehouseCode_Str = billNoChildItem.WarehouseCode_Str,
|
|
|
- // SourceLocationTag_Str = billNoChildItem.SourceLocationTag_Str,
|
|
|
- // ItemWorkNo_Str = itemWorkNo,
|
|
|
- // WoNos_Str = billNoChildItem.WoNo_Str,
|
|
|
- // WorkCenter_Str = billNoChildItem.WorkCenter_Str,
|
|
|
- // CreateTime_Str = DateTime.Now.ToString()
|
|
|
- // });
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // var list = itemLowList.Where(j => j.BillNo_Str == billNoChildItem.BillNo_Str && j.ItemCode_Str == billNoChildItem.ItemCode_Str).ToList();
|
|
|
- // list[0].ItemNo_Str += $"/{billNoChildItem.TaskNo_Str}";
|
|
|
- // list[0].WoNos_Str += $"/{billNoChildItem.WoNo_Str}";
|
|
|
- // list[0].PlannedTotalQty_Dec += billNoChildItem.PlannedQty_Dec;
|
|
|
- // list[0].ActualTotalQty_Dec += billNoChildItem.PlannedQty_Dec;
|
|
|
- // }
|
|
|
- // updateItemTaskList.Add(new App_BC_ItemTask()
|
|
|
- // {
|
|
|
- // TaskNo_Str = billNoChildItem.TaskNo_Str,
|
|
|
- // ItemWorkNo_Str = itemWorkNo,
|
|
|
- // IsMerged_Bit = true
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // itemLowList.OrderBy(t => t.SourceLocationTag_Str).ToList();
|
|
|
-
|
|
|
- // Env.DAL.App_BC_ItemLow.Insert(itemLowList,
|
|
|
- // t => new
|
|
|
- // {
|
|
|
- // t.ItemNo_Str,
|
|
|
- // t.BillNo_Str,
|
|
|
- // t.ItemCode_Str,
|
|
|
- // t.ItemName_Str,
|
|
|
- // t.OnhandState_Int,
|
|
|
- // t.PlannedTotalQty_Dec,
|
|
|
- // t.ActualTotalQty_Dec,
|
|
|
- // t.UnitCode_Str,
|
|
|
- // t.SourceLocations_Str,
|
|
|
- // t.LocationItemsNum_Str,
|
|
|
- // t.LocationNum_Int,
|
|
|
- // t.WarehouseCode_Str,
|
|
|
- // t.SourceLocationTag_Str,
|
|
|
- // t.ItemWorkNo_Str,
|
|
|
- // t.WoNos_Str,
|
|
|
- // t.WorkCenter_Str,
|
|
|
- // t.CreateTime_Str
|
|
|
- // });
|
|
|
-
|
|
|
-
|
|
|
- // Env.DAL.ExecuteNonQuery($" Update App_BC_ItemTask Set IsMerged_Bit= 1, ItemWorkNo_Str = '{workNos}' where {taskFilter}");
|
|
|
-
|
|
|
- // #region
|
|
|
- // //// 父表批量插入值拼接
|
|
|
- // //var itemLowColValues = "";
|
|
|
- // //for (int i = 0; i < itemLowList.Count; i++)
|
|
|
- // //{
|
|
|
- // // if (i == 0)
|
|
|
- // // {
|
|
|
- // // itemLowColValues = $@"
|
|
|
- // // (
|
|
|
- // // '{itemLowList[0].ItemNo_Str}', '{itemLowList[0].BillNo_Str}','{itemLowList[0].ItemCode_Str}', '{itemLowList[0].ItemName_Str}',
|
|
|
- // // '{itemLowList[0].OnhandState_Int}','{itemLowList[0].PlannedTotalQty_Dec}','{itemLowList[0].ActualTotalQty_Dec}','{itemLowList[0].UnitCode_Str}',
|
|
|
- // // '{itemLowList[0].SourceLocations_Str}', '{itemLowList[0].LocationItemsNum_Str}','{itemLowList[0].LocationNum_Int}', '{itemLowList[0].WarehouseCode_Str}',
|
|
|
- // // '{itemLowList[0].SourceLocationTag_Str}', '{itemLowList[0].ItemWorkNo_Str}','{itemLowList[0].WoNos_Str}', '{itemLowList[0].WorkCenter_Str}', '{DateTime.Now.ToString()}'
|
|
|
- // // )";
|
|
|
- // // }
|
|
|
- // // else
|
|
|
- // // {
|
|
|
- // // itemLowColValues = $@"{itemLowColValues},
|
|
|
- // // (
|
|
|
- // // '{itemLowList[i].ItemNo_Str}', '{itemLowList[i].BillNo_Str}','{itemLowList[i].ItemCode_Str}', '{itemLowList[i].ItemName_Str}',
|
|
|
- // // '{itemLowList[i].OnhandState_Int}','{itemLowList[i].PlannedTotalQty_Dec}','{itemLowList[i].ActualTotalQty_Dec}','{itemLowList[i].UnitCode_Str}',
|
|
|
- // // '{itemLowList[i].SourceLocations_Str}', '{itemLowList[i].LocationItemsNum_Str}','{itemLowList[i].LocationNum_Int}', '{itemLowList[i].WarehouseCode_Str}',
|
|
|
- // // '{itemLowList[i].SourceLocationTag_Str}', '{itemLowList[i].ItemWorkNo_Str}','{itemLowList[i].WoNos_Str}', '{itemLowList[i].WorkCenter_Str}', '{DateTime.Now.ToString()}'
|
|
|
- // // )
|
|
|
- // // ";
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //var insertSql = "";
|
|
|
- // //if (itemLowColValues != "")
|
|
|
- // //{
|
|
|
- // // insertSql = $@"
|
|
|
- // // Insert Into
|
|
|
- // // {nameof(App_BC_ItemLow)}(
|
|
|
- // // ItemNo_Str, BillNo_Str, ItemCode_Str, ItemName_Str,
|
|
|
- // // OnhandState_Int, PlannedTotalQty_Dec, ActualTotalQty_Dec, UnitCode_Str,
|
|
|
- // // SourceLocations_Str, LocationItemsNum_Str, LocationNum_Int, WarehouseCode_Str,
|
|
|
- // // SourceLocationTag_Str, ItemWorkNo_Str, WoNos_Str, WorkCenter_Str, CreateTime_Str
|
|
|
- // // )
|
|
|
- // // Values {itemLowColValues};";
|
|
|
- // //}
|
|
|
- // //// 子表拼接sql更新语句
|
|
|
- // //var updateItemTaskSql = "";
|
|
|
- // //for (int i = 0; i < updateItemTaskList.Count; i++)
|
|
|
- // //{
|
|
|
- // // updateItemTaskSql = $"{updateItemTaskSql} Update {nameof(App_BC_ItemTask)} Set IsMerged_Bit= 1, ItemWorkNo_Str = '{updateItemTaskList[i].ItemWorkNo_Str}' Where TaskNo_Str = '{updateItemTaskList[i].TaskNo_Str}';";
|
|
|
- // //}
|
|
|
- // #endregion
|
|
|
-
|
|
|
- // // 更新 父表任务库位
|
|
|
- // var updateItemLowInventory = $@"
|
|
|
- // UPDATE App_BC_ItemLow
|
|
|
- // SET SourceLocations_Str = COALESCE((
|
|
|
- // SELECT GROUP_CONCAT(b.SourceLocation_Str, '/')
|
|
|
- // FROM (
|
|
|
- // SELECT App_BC_Inventory.Qty_Dec, App_BC_Inventory.SourceLocation_Str FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemLow.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemLow.WarehouseCode_Str
|
|
|
- // ORDER BY App_BC_Inventory.Qty_Dec DESC
|
|
|
- // ) b
|
|
|
- // ), null),
|
|
|
- // LocationItemsNum_Str = COALESCE((
|
|
|
- // SELECT GROUP_CONCAT(b.Qty_Dec, '/')
|
|
|
- // FROM (
|
|
|
- // SELECT App_BC_Inventory.Qty_Dec, App_BC_Inventory.SourceLocation_Str FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemLow.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemLow.WarehouseCode_Str
|
|
|
- // ORDER BY App_BC_Inventory.Qty_Dec DESC
|
|
|
- // ) b
|
|
|
- // ), null)
|
|
|
- // WHERE EXISTS (
|
|
|
- // SELECT 1
|
|
|
- // FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemLow.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemLow.WarehouseCode_Str
|
|
|
- // ) AND (App_BC_ItemLow.SourceLocations_Str is null or App_BC_ItemLow.SourceLocations_Str = '');";
|
|
|
-
|
|
|
- // //{ insertSql}
|
|
|
- // //{ updateItemTaskSql}
|
|
|
- // var sqlStr = $@"
|
|
|
- // {updateItemLowInventory}
|
|
|
- // ";
|
|
|
- // Env.DAL.ReadDataTable(sqlStr);
|
|
|
- // res.Message = "合并成功";
|
|
|
- // return res;
|
|
|
- //}
|
|
|
-
|
|
|
- //// 上架合并 工单号合并
|
|
|
- //public RpcResponse<object> MergeItemUpList(string workNos, string sourceLocationGroup)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var itemWorkNo = workNos;
|
|
|
- // var WorkSql = workNos.Split(',');
|
|
|
- // var inFiler = "";
|
|
|
- // for (var i = 0; i < WorkSql.Length; i++)
|
|
|
- // {
|
|
|
- // if (inFiler == "")
|
|
|
- // {
|
|
|
- // inFiler = $"'{WorkSql[i]}'";
|
|
|
- // }
|
|
|
- // else inFiler += $",'{WorkSql[i]}'";
|
|
|
- // }
|
|
|
- // var mergedList = Env.DAL.App_BC_ItemTask.GetData<App_BC_ItemTask>($"WoNo_Str in ({inFiler}) and IsMerged_Bit = 1 and State_Int = 0");
|
|
|
- // if (mergedList.Count > 0)
|
|
|
- // {
|
|
|
- // var mergedWoNos = mergedList.GroupBy(t => t.WoNo_Str).Select(t => t.First().WoNo_Str).ToList<string>();
|
|
|
- // res.Message = $"存在合并过的工单号{string.Join(",", mergedWoNos)}创建任务, 请先删除";
|
|
|
- // res.IsSucceed = false;
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // var taskFilter = $"WoNo_Str in ({inFiler}) and TaskType_Bit = 1 and State_Int = 0";
|
|
|
- // var taskItemList = Env.DAL.App_BC_ItemTask.GetData<App_BC_ItemTask>(taskFilter);
|
|
|
- // if (taskItemList.Count == 0)
|
|
|
- // {
|
|
|
- // res.Message = $"找不到需要合并的工单号{workNos}创建任务";
|
|
|
- // res.IsSucceed = false;
|
|
|
- // return res;
|
|
|
- // }
|
|
|
- // taskItemList = taskItemList.OrderBy(x => x.TaskNo_Str).ToList();
|
|
|
- // var billNoIL = taskItemList.ToLookup(t => new { t.BillNo_Str, t.WorkCenter_Str });
|
|
|
- // var itemUpList = new List<App_BC_ItemUp>();
|
|
|
- // var updateItemTaskList = new List<App_BC_ItemTask>();
|
|
|
- // foreach (var billNoItem in billNoIL)
|
|
|
- // {
|
|
|
- // foreach (var billNoChildItem in billNoItem)
|
|
|
- // {
|
|
|
- // if (!itemUpList.Any(t => t.BillNo_Str == billNoChildItem.BillNo_Str && t.ItemCode_Str == billNoChildItem.ItemCode_Str && t.WarehouseCode_Str == billNoChildItem.WarehouseCode_Str && t.WorkCenter_Str == billNoChildItem.WorkCenter_Str))
|
|
|
- // {
|
|
|
- // itemUpList.Add(new App_BC_ItemUp()
|
|
|
- // {
|
|
|
- // ItemNo_Str = billNoChildItem.TaskNo_Str,
|
|
|
- // BillNo_Str = billNoChildItem.BillNo_Str,
|
|
|
- // ItemCode_Str = billNoChildItem.ItemCode_Str,
|
|
|
- // ItemName_Str = billNoChildItem.ItemName_Str,
|
|
|
- // OnhandState_Int = billNoChildItem.OnhandState_Int,
|
|
|
- // PlannedTotalQty_Dec = billNoChildItem.PlannedQty_Dec,
|
|
|
- // ActualTotalQty_Dec = billNoChildItem.PlannedQty_Dec,
|
|
|
- // UnitCode_Str = billNoChildItem.UnitCode_Str,
|
|
|
- // SourceLocations_Str = "",
|
|
|
- // LocationItemsNum_Str = "",
|
|
|
- // LocationNum_Int = 0,
|
|
|
- // WarehouseCode_Str = billNoChildItem.WarehouseCode_Str,
|
|
|
- // SourceLocationTag_Str = billNoChildItem.SourceLocationTag_Str,
|
|
|
- // ItemWorkNo_Str = itemWorkNo,
|
|
|
- // WoNos_Str = billNoChildItem.WoNo_Str,
|
|
|
- // WorkCenter_Str = billNoChildItem.WorkCenter_Str,
|
|
|
- // CreateTime_Str = DateTime.Now.ToString()
|
|
|
- // });
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // var list = itemUpList.Where(j => j.BillNo_Str == billNoChildItem.BillNo_Str && j.ItemCode_Str == billNoChildItem.ItemCode_Str).ToList();
|
|
|
- // list[0].ItemNo_Str += $"/{billNoChildItem.TaskNo_Str}";
|
|
|
- // list[0].WoNos_Str += $"/{billNoChildItem.WoNo_Str}";
|
|
|
- // list[0].PlannedTotalQty_Dec += billNoChildItem.PlannedQty_Dec;
|
|
|
- // list[0].ActualTotalQty_Dec += billNoChildItem.PlannedQty_Dec;
|
|
|
- // }
|
|
|
- // updateItemTaskList.Add(new App_BC_ItemTask()
|
|
|
- // {
|
|
|
- // TaskNo_Str = billNoChildItem.TaskNo_Str,
|
|
|
- // ItemWorkNo_Str = itemWorkNo,
|
|
|
- // IsMerged_Bit = true
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // itemUpList.OrderBy(t => t.SourceLocationTag_Str);
|
|
|
- // Env.DAL.App_BC_ItemUp.Insert(itemUpList,
|
|
|
- // t => new
|
|
|
- // {
|
|
|
- // t.ItemNo_Str,
|
|
|
- // t.BillNo_Str,
|
|
|
- // t.ItemCode_Str,
|
|
|
- // t.ItemName_Str,
|
|
|
- // t.OnhandState_Int,
|
|
|
- // t.PlannedTotalQty_Dec,
|
|
|
- // t.ActualTotalQty_Dec,
|
|
|
- // t.UnitCode_Str,
|
|
|
- // t.SourceLocations_Str,
|
|
|
- // t.LocationItemsNum_Str,
|
|
|
- // t.LocationNum_Int,
|
|
|
- // t.WarehouseCode_Str,
|
|
|
- // t.SourceLocationTag_Str,
|
|
|
- // t.ItemWorkNo_Str,
|
|
|
- // t.WoNos_Str,
|
|
|
- // t.WorkCenter_Str,
|
|
|
- // t.CreateTime_Str
|
|
|
- // });
|
|
|
- // #region
|
|
|
- // // 父表批量插入值拼接
|
|
|
- // //var itemUpColValues = "";
|
|
|
- // //for (int i = 0; i < itemUpList.Count; i++)
|
|
|
- // //{
|
|
|
- // // if (i == 0)
|
|
|
- // // {
|
|
|
- // // itemUpColValues = $@"
|
|
|
- // // (
|
|
|
- // // '{itemUpList[0].ItemNo_Str}', '{itemUpList[0].BillNo_Str}','{itemUpList[0].ItemCode_Str}', '{itemUpList[0].ItemName_Str}',
|
|
|
- // // '{itemUpList[0].OnhandState_Int}','{itemUpList[0].PlannedTotalQty_Dec}','{itemUpList[0].ActualTotalQty_Dec}','{itemUpList[0].UnitCode_Str}',
|
|
|
- // // '{itemUpList[0].SourceLocations_Str}', '{itemUpList[0].LocationItemsNum_Str}','{itemUpList[0].LocationNum_Int}', '{itemUpList[0].WarehouseCode_Str}',
|
|
|
- // // '{itemUpList[0].SourceLocationTag_Str}', '{itemUpList[0].ItemWorkNo_Str}','{itemUpList[0].WoNos_Str}', '{itemUpList[0].WorkCenter_Str}', '{DateTime.Now.ToString()}'
|
|
|
- // // )";
|
|
|
- // // }
|
|
|
- // // else
|
|
|
- // // {
|
|
|
- // // itemUpColValues = $@"{itemUpColValues},
|
|
|
- // // (
|
|
|
- // // '{itemUpList[i].ItemNo_Str}', '{itemUpList[i].BillNo_Str}','{itemUpList[i].ItemCode_Str}', '{itemUpList[i].ItemName_Str}',
|
|
|
- // // '{itemUpList[i].OnhandState_Int}','{itemUpList[i].PlannedTotalQty_Dec}','{itemUpList[i].ActualTotalQty_Dec}','{itemUpList[i].UnitCode_Str}',
|
|
|
- // // '{itemUpList[i].SourceLocations_Str}', '{itemUpList[i].LocationItemsNum_Str}','{itemUpList[i].LocationNum_Int}', '{itemUpList[i].WarehouseCode_Str}',
|
|
|
- // // '{itemUpList[i].SourceLocationTag_Str}', '{itemUpList[i].ItemWorkNo_Str}','{itemUpList[i].WoNos_Str}', '{itemUpList[i].WorkCenter_Str}', '{DateTime.Now.ToString()}'
|
|
|
- // // )
|
|
|
- // // ";
|
|
|
- // // }
|
|
|
- // //}
|
|
|
- // //var insertSql = "";
|
|
|
- // //if (itemUpColValues != "")
|
|
|
- // //{
|
|
|
- // // insertSql = $@"
|
|
|
- // // Insert Into
|
|
|
- // // {nameof(App_BC_ItemUp)}(
|
|
|
- // // ItemNo_Str, BillNo_Str, ItemCode_Str, ItemName_Str,
|
|
|
- // // OnhandState_Int, PlannedTotalQty_Dec, ActualTotalQty_Dec, UnitCode_Str,
|
|
|
- // // SourceLocations_Str, LocationItemsNum_Str, LocationNum_Int, WarehouseCode_Str,
|
|
|
- // // SourceLocationTag_Str, ItemWorkNo_Str, WoNos_Str, WorkCenter_Str, CreateTime_Str
|
|
|
- // // )
|
|
|
- // // Values {itemUpColValues};";
|
|
|
- // //}
|
|
|
- // // 子表拼接sql更新语句
|
|
|
- // //var updateItemTaskSql = "";
|
|
|
- // //for (int i = 0; i < updateItemTaskList.Count; i++)
|
|
|
- // //{
|
|
|
- // // updateItemTaskSql = $"{updateItemTaskSql} Update {nameof(App_BC_ItemTask)} Set IsMerged_Bit= 1, ItemWorkNo_Str = '{updateItemTaskList[i].ItemWorkNo_Str}' Where TaskNo_Str = '{updateItemTaskList[i].TaskNo_Str}';";
|
|
|
- // //}
|
|
|
- // #endregion
|
|
|
-
|
|
|
-
|
|
|
- // Env.DAL.ExecuteNonQuery($" Update App_BC_ItemTask Set IsMerged_Bit= 1, ItemWorkNo_Str = '{workNos}' where {taskFilter}");
|
|
|
- // // 更新 父表任务库位
|
|
|
- // var updateItemUpInventory = $@"
|
|
|
- // UPDATE App_BC_ItemUp
|
|
|
- // SET SourceLocations_Str = COALESCE((
|
|
|
- // SELECT GROUP_CONCAT(b.SourceLocation_Str, '/')
|
|
|
- // FROM (
|
|
|
- // SELECT App_BC_Inventory.Qty_Dec, App_BC_Inventory.SourceLocation_Str FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemUp.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemUp.WarehouseCode_Str
|
|
|
- // ORDER BY App_BC_Inventory.Qty_Dec DESC
|
|
|
- // ) b
|
|
|
- // ), null),
|
|
|
- // LocationItemsNum_Str = COALESCE((
|
|
|
- // SELECT GROUP_CONCAT(b.Qty_Dec, '/')
|
|
|
- // FROM (
|
|
|
- // SELECT App_BC_Inventory.Qty_Dec, App_BC_Inventory.SourceLocation_Str FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemUp.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemUp.WarehouseCode_Str
|
|
|
- // ORDER BY App_BC_Inventory.Qty_Dec DESC
|
|
|
- // ) b
|
|
|
- // ), null)
|
|
|
- // WHERE EXISTS (
|
|
|
- // SELECT 1
|
|
|
- // FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemUp.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemUp.WarehouseCode_Str
|
|
|
- // ) AND (App_BC_ItemUp.SourceLocations_Str is null or App_BC_ItemUp.SourceLocations_Str = '');";
|
|
|
-
|
|
|
- // //{ insertSql}
|
|
|
- // //{ updateItemTaskSql}
|
|
|
- // var sqlStr = $@"
|
|
|
- // {updateItemUpInventory}
|
|
|
- // ";
|
|
|
- // Env.DAL.ReadDataTable(sqlStr);
|
|
|
- // res.Message = "合并成功";
|
|
|
- // return res;
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- //public RpcResponse<object> DelItemLowItemWorkNo(string itemWorkNo, string tag)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var ok = Env.DAL.ReadDataTable($"DELETE FROM App_BC_ItemLow WHERE ItemWorkNo_Str = '{itemWorkNo}' and IsSynced_Bit = 0 and SourceLocationTag_Str like '%{tag}%'");
|
|
|
- // var result = Env.DAL.ReadDataTable($"UPDATE App_BC_ItemTask Set IsMerged_Bit= 0, ItemWorkNo_Str = null WHERE ItemWorkNo_Str = '{itemWorkNo}' and State_Int = 0");
|
|
|
- // res.Message = "删除成功";
|
|
|
- // return res;
|
|
|
- // return new RpcResponse<object>();
|
|
|
- //}
|
|
|
-
|
|
|
- //public RpcResponse<object> DelItemUpItemWorkNo(string itemWorkNo, string tag)
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var ok = Env.DAL.ReadDataTable($"DELETE FROM App_BC_ItemUp WHERE ItemWorkNo_Str = '{itemWorkNo}' and IsSynced_Bit = 0");
|
|
|
- // var result = Env.DAL.ReadDataTable($"UPDATE App_BC_ItemTask Set IsMerged_Bit= 0, ItemWorkNo_Str = null WHERE ItemWorkNo_Str = '{itemWorkNo}' and State_Int = 0");
|
|
|
- // res.Message = "删除成功";
|
|
|
- // return res;
|
|
|
- // return new RpcResponse<object>();
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //public RpcResponse<object> UpdateItemTaskSourceLocation1()
|
|
|
- //{
|
|
|
- // var res = new RpcResponse<object>();
|
|
|
- // var ok = Env.DAL.ReadDataTable($@" UPDATE App_BC_ItemTask
|
|
|
- // SET SourceLocation_Str = COALESCE((
|
|
|
- // SELECT b.SourceLocation_Str
|
|
|
- // FROM (
|
|
|
- // SELECT App_BC_Inventory.Qty_Dec, App_BC_Inventory.SourceLocation_Str FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemTask.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemTask.WarehouseCode_Str
|
|
|
- // ORDER BY App_BC_Inventory.Qty_Dec DESC
|
|
|
- // ) b
|
|
|
- // ), null)
|
|
|
- // WHERE EXISTS (
|
|
|
- // SELECT 1
|
|
|
- // FROM App_BC_Inventory
|
|
|
- // WHERE App_BC_Inventory.ItemCode_Str = App_BC_ItemTask.ItemCode_Str AND App_BC_Inventory.WarehouseCode_Str = App_BC_ItemTask.WarehouseCode_Str
|
|
|
- // AND App_BC_ItemTask.State_Int = 0
|
|
|
- // ) AND (App_BC_ItemTask.SourceLocation_Str is null or App_BC_ItemTask.SourceLocation_Str = '') And TaskType_Bit = 0 ");
|
|
|
- // res.Message = "更新库位成功";
|
|
|
- // return res;
|
|
|
- //}
|
|
|
- }
|
|
|
-}
|