| | |
| | | using yunneiWCS.Common; |
| | | using yunneiWCS.SystemInteraction.tianyong; |
| | | using yunneiWCS.Models; |
| | | using iWareCommon.Utils; |
| | | |
| | | namespace yunneiWCS.wcf |
| | | { |
| | | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“yunneiWcf”。 |
| | |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary>查找出入库记录给MES [EditBy shaocx,2025-09-01] |
| | | /// |
| | | /// </summary> |
| | | /// <param name="page">分页</param> |
| | | /// <returns></returns> |
| | | public resMsg<Wms_outInStockRecord_V2_Mes> findOutInStockRecord_V2_Mes(paging page, Wms_outInStockRecord_V2_Mes value) |
| | | { |
| | | resMsg<Wms_outInStockRecord_V2_Mes> msg = new resMsg<Wms_outInStockRecord_V2_Mes>(); |
| | | msg.status = 400; |
| | | try |
| | | { |
| | | using (dbmodel mod = new dbmodel()) |
| | | { |
| | | string sql = "SELECT * FROM [LA20025].[dbo].[Wms_outInStockRecord_V2_Mes] "; |
| | | sql = sql + " WHERE 1=1 "; |
| | | if (!string.IsNullOrEmpty(value.sourcePlace))//起点 |
| | | { |
| | | sql = sql + " and sourcePlace='" + value.sourcePlace + "' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.toPlace))//目标点 |
| | | { |
| | | sql = sql + " and toPlace='" + value.toPlace + "' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.containerCode))//托盘号 |
| | | { |
| | | sql = sql + " and containerCode like'%" + value.containerCode + "%' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.materialCode))//物料编号 |
| | | { |
| | | sql = sql + " and materialCode like '%" + value.materialCode + "%'"; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.materialName))//物料名称 |
| | | { |
| | | sql = sql + " and materialName like '%" + value.materialName + "%' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.version))//机型 |
| | | { |
| | | sql = sql + " and version like '%" + value.version + "%' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.supplier))//供应商 |
| | | { |
| | | sql = sql + " and supplier like '%" + value.supplier + "%'"; |
| | | } |
| | | if (value.isSendToMes != null) |
| | | { |
| | | sql = sql + " and isSendToMes = '" + value.isSendToMes + "' "; |
| | | } |
| | | //if (value.positionType == (byte)positionType.余料回库)//是否查询余料 |
| | | //{ |
| | | // sql = sql + " and positionType =" + value.positionType; |
| | | //} |
| | | if (page.startDateTime != DateTime.Parse("1900-01-01 0:00:00") && page.startDateTime != DateTime.Parse("0001-01-01 0:00:00"))//起始时间 |
| | | { |
| | | sql = sql + " and CreateTime >'" + page.startDateTime + "'"; |
| | | } |
| | | if (page.endDateTime != DateTime.Parse("1900-01-01 0:00:00") && page.endDateTime != DateTime.Parse("0001-01-01 0:00:00"))//截止时间 |
| | | { |
| | | sql = sql + " and CreateTime <'" + page.endDateTime + "'"; |
| | | } |
| | | |
| | | sql = sql + " order by CreateTime desc"; |
| | | List<Wms_outInStockRecord_V2_Mes> dataList = mod.Database.SqlQuery<Wms_outInStockRecord_V2_Mes>(sql).ToList(); |
| | | |
| | | if (dataList.Count > 0) |
| | | { |
| | | //msg.quantity = (int)dataList.Sum(x => x.quantity); |
| | | msg.totalNum = dataList.Count; |
| | | msg.dateAll = dataList; |
| | | //分页计算 |
| | | List<Wms_outInStockRecord_V2_Mes> fenyeRerult = new List<Wms_outInStockRecord_V2_Mes>(); |
| | | msg.status = 200; |
| | | |
| | | //假如每页数量 大于盘点数据 |
| | | if (page.pagesize > dataList.Count) |
| | | { |
| | | msg.date = dataList; |
| | | msg.total = 1; |
| | | } |
| | | else |
| | | { |
| | | #region 分页计算 |
| | | int a = page.pagesize; |
| | | int b = page.pagenum; |
| | | int c = (int)Math.Ceiling((double)dataList.Count / a); |
| | | msg.total = c; |
| | | int d = dataList.Count % a; |
| | | int e = 0; |
| | | int f = a * (b - 1); |
| | | if (d != 0 && b == c) |
| | | { |
| | | e = d + f; |
| | | } |
| | | else |
| | | { |
| | | e = a + f; |
| | | } |
| | | for (int i = f; i < e; i++) |
| | | { |
| | | fenyeRerult.Add(dataList[i]); |
| | | } |
| | | |
| | | msg.date = fenyeRerult; |
| | | #endregion |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | msg.status = 200; |
| | | msg.msg = "查找数据为0,请更换查询条件"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg.msg = "查询失败"; |
| | | WZ.Useful.Commons.LogTextHelper.WriteLine("IyunneiWcf", "findOutInStockRecord_V2_Mes", ex.ToString()); |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary>查找出入库记录明细给MES [EditBy shaocx,2025-09-01] |
| | | /// |
| | | /// </summary> |
| | | /// <param name="page">分页</param> |
| | | /// <returns></returns> |
| | | public resMsg<Wms_outInStockRecord_Details_V2_Mes> findOutInStockRecord_Details_V2_Mes_Page(paging page, Wms_outInStockRecord_Details_V2_Mes value) |
| | | { |
| | | resMsg<Wms_outInStockRecord_Details_V2_Mes> msg = new resMsg<Wms_outInStockRecord_Details_V2_Mes>(); |
| | | msg.status = 400; |
| | | try |
| | | { |
| | | using (dbmodel mod = new dbmodel()) |
| | | { |
| | | string sql = "SELECT * FROM [LA20025].[dbo].[Wms_outInStockRecord_Details_V2_Mes] "; |
| | | sql = sql + " WHERE 1=1 "; |
| | | |
| | | if (!string.IsNullOrEmpty(value.containerCode))//托盘号 |
| | | { |
| | | sql = sql + " and containerCode like '%" + value.containerCode + "%'"; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.productCode))//物料编号 |
| | | { |
| | | sql = sql + " and productCode like '%" + value.productCode + "%'"; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.productName))//物料名称 |
| | | { |
| | | sql = sql + " and productName like '%" + value.productName + "%' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(value.serialNumber))//流水号 |
| | | { |
| | | sql = sql + " and serialNumber like '%" + value.serialNumber + "%' "; |
| | | } |
| | | |
| | | if (page.startDateTime != DateTime.Parse("1900-01-01 0:00:00") && page.startDateTime != DateTime.Parse("0001-01-01 0:00:00"))//起始时间 |
| | | { |
| | | sql = sql + " and CreateTime >'" + page.startDateTime + "'"; |
| | | } |
| | | if (page.endDateTime != DateTime.Parse("1900-01-01 0:00:00") && page.endDateTime != DateTime.Parse("0001-01-01 0:00:00"))//截止时间 |
| | | { |
| | | sql = sql + " and CreateTime <'" + page.endDateTime + "'"; |
| | | } |
| | | |
| | | sql = sql + " order by CreateTime desc"; |
| | | List<Wms_outInStockRecord_Details_V2_Mes> dataList = mod.Database.SqlQuery<Wms_outInStockRecord_Details_V2_Mes>(sql).ToList(); |
| | | |
| | | if (dataList.Count > 0) |
| | | { |
| | | //msg.quantity = (int)dataList.Sum(x => x.quantity); |
| | | msg.totalNum = dataList.Count; |
| | | msg.dateAll = dataList; |
| | | //分页计算 |
| | | List<Wms_outInStockRecord_Details_V2_Mes> fenyeRerult = new List<Wms_outInStockRecord_Details_V2_Mes>(); |
| | | msg.status = 200; |
| | | |
| | | //假如每页数量 大于盘点数据 |
| | | if (page.pagesize > dataList.Count) |
| | | { |
| | | msg.date = dataList; |
| | | msg.total = 1; |
| | | } |
| | | else |
| | | { |
| | | #region 分页计算 |
| | | int a = page.pagesize; |
| | | int b = page.pagenum; |
| | | int c = (int)Math.Ceiling((double)dataList.Count / a); |
| | | msg.total = c; |
| | | int d = dataList.Count % a; |
| | | int e = 0; |
| | | int f = a * (b - 1); |
| | | if (d != 0 && b == c) |
| | | { |
| | | e = d + f; |
| | | } |
| | | else |
| | | { |
| | | e = a + f; |
| | | } |
| | | for (int i = f; i < e; i++) |
| | | { |
| | | fenyeRerult.Add(dataList[i]); |
| | | } |
| | | |
| | | msg.date = fenyeRerult; |
| | | #endregion |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | msg.status = 200; |
| | | msg.msg = "查找数据为0,请更换查询条件"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg.msg = "查询失败"; |
| | | WZ.Useful.Commons.LogTextHelper.WriteLine("IyunneiWcf", "Wms_outInStockRecord_Details_V2_Mes", ex.ToString()); |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | /// <summary>查找入库单流水号 |
| | | /// |
| | | /// </summary> |
| | |
| | | { |
| | | res.msg = "查不入库单"; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | res.msg = "查询异常"; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | |
| | | /// <summary>查找出入库记录推行mes详情 |
| | | /// |
| | | /// </summary> |
| | | /// <param name="inStockCode"></param> |
| | | /// <returns></returns> |
| | | public resMsg<Wms_outInStockRecord_Details_V2_Mes> findOutInStockRecord_Details_V2_Mes(long mainId) |
| | | { |
| | | resMsg<Wms_outInStockRecord_Details_V2_Mes> res = new resMsg<Wms_outInStockRecord_Details_V2_Mes>(); |
| | | res.status = 400; |
| | | try |
| | | { |
| | | using (dbmodel mod = new dbmodel()) |
| | | { |
| | | |
| | | List<Wms_outInStockRecord_Details_V2_Mes> instockList = mod.Wms_outInStockRecord_Details_V2_Mes.Where(x => x.mainId == mainId).ToList(); |
| | | if (instockList.Count > 0) |
| | | { |
| | | res.status = 200; |
| | | res.date = instockList; |
| | | } |
| | | else |
| | | { |
| | | res.msg = "查不到明细"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception) |
| | |
| | | msg.msg = "至少留一个明细"; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | catch (Exception ex) |
| | | { |
| | | msg.msg = "执行错误"; |
| | | msg.msg = "执行错误:" + ex.Message; |
| | | Log4NetHelper.WriteErrorLog(LogType.OtherInfo, "modfiyInStockList:" + msg.msg, ex); |
| | | } |
| | | return msg; |
| | | } |
| | |
| | | mod.productStockList.Add(newList); |
| | | |
| | | } |
| | | |
| | | List<productStockList> record_delteList = new List<productStockList>(); |
| | | var realDeleteList = all_serialNumberList.Where(x => !now_serialNumberList.Contains(x)).ToList(); |
| | | foreach (var item in deleteList) |
| | | { |
| | | if (realDeleteList.Contains(item.serialNumber)) |
| | | { |
| | | record_delteList.Add(item); |
| | | //记录日志 [EditBy shaocx,2022-03-16] |
| | | StockClearLog _StockClearLog = new StockClearLog() |
| | | { |
| | |
| | | mod.StockClearLog.Add(_StockClearLog); |
| | | } |
| | | } |
| | | |
| | | var preLog = "普通删除"; |
| | | if (taskId > 0) |
| | | {//说明是 出库分拣 【Editby shaocx,2022-03-02】 |
| | | var task = mod.task.Where(x => x.taskId == taskId).FirstOrDefault(); |
| | |
| | | return msg; |
| | | } |
| | | task.taskStatus = (int)taskStatus.分拣完成; |
| | | preLog = "人工分拣"; |
| | | } |
| | | |
| | | if (record_delteList?.Count > 0) |
| | | { |
| | | OutInStockRecord_V2_MesHandler.AddRecordForPersonDelete(mod, OutInFlag.出库, "人工删除库存:" + preLog, |
| | | record_delteList, modfiyStock, (currentStock != null ? currentStock.positionName : ""));//堆垛机任务完成后的出库 |
| | | } |
| | | |
| | | |
| | | int res = mod.SaveChanges(); |
| | | if (res > 0) |
| | |
| | | msg.msg = "至少留一个明细"; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | catch (Exception ex) |
| | | { |
| | | msg.msg = "执行错误"; |
| | | msg.msg = "报错了:" + ex.Message; |
| | | Log4NetHelper.WriteErrorLog(LogType.OtherInfo, "modfiyStockList:" + msg.msg, ex); |
| | | } |
| | | return msg; |
| | | } |
| | |
| | | { |
| | | using (dbmodel mod = new dbmodel()) |
| | | { |
| | | var b_result = MyExtend.deleteProduct(true, user, mod, positionName, null, ref res); |
| | | var b_result = MyExtend.deleteProduct(true, user, mod, positionName, null, ref res, "人工直接删除库存"); |
| | | if (b_result == false) |
| | | { |
| | | return FunctionReturnEntity<bool>.Fail("删除失败:" + res); |