using HanHe.Utility.Data; using HH.WMS.Common; using HH.WMS.DAL; using HH.WMS.Entitys.Algorithm; using HH.WMS.Entitys.Basic; using HH.WMS.Entitys.Common; using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HH.WMS.DAL.CoreServer { public class BasicDataDAL : DapperBaseDAL { public DataTable GetInventoryData() { string sql = @" select top 50 * from Inventory where bIsRead_WMS=0 "; DbCommand cmd = DataAccess.GetSqlStringCommand(sql); DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd); return dt; } public DataTable GetWarehouseData() { string sql = @" select top 50 * from Warehouse where bIsRead_WMS=0 "; DbCommand cmd = DataAccess.GetSqlStringCommand(sql); DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd); return dt; } public DataTable GetCustomerData() { string sql = @"select top 50 * from Customer where bIsRead_WMS=0 "; DbCommand cmd = DataAccess.GetSqlStringCommand(sql); DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd); return dt; } public DataTable GetVendnrData() { string sql = @"select top 50 * from Vendor where bIsRead_WMS=0 "; DbCommand cmd = DataAccess.GetSqlStringCommand(sql); DataTable dt = DataAccessExtensive.ExecuteDataTable(this.DataAccess, cmd); return dt; } public SqlExecuteResult UpdateInventoryCheckState(List itemEntityList) { List cmdlist = new List(); foreach (PLM_itemEntity entity in itemEntityList) { string strSql = @"update Inventory set bIsRead_WMS=1,cReader_WMS=:cReader_WMS,dReadDate_WMS=getdate() WHERE cInvCode=:cInvCode "; DbCommand cmd = DataAccess.GetSqlStringCommand(strSql); DataAccess.AddInParameter(cmd, "cReader_WMS", ComDbType.STRING, "汉和信息"); DataAccess.AddInParameter(cmd, "cInvCode", ComDbType.STRING, entity.CODE); cmdlist.Add(cmd); } return ExecuteCommands(cmdlist, null); } public List GetStockData() { List u8RebackData = new List(); string u8_zhangtaoDB = System.Configuration.ConfigurationManager.AppSettings["U8_zhangtaoDB"].ToString(); string u8_stockCode = System.Configuration.ConfigurationManager.AppSettings["U8_stockCode"].ToString(); if (string.IsNullOrEmpty(u8_zhangtaoDB)||string.IsNullOrEmpty(u8_stockCode)) { Log.Info("u8_zhangtaoDB或者u8_stockCode未设置", ""); return u8RebackData; } string sql = @"select * from " + u8_zhangtaoDB + ".dbo.v_SSYY_CurrentStock where cWhCode in(" + u8_stockCode + ") and iQuantity!=0"; DbCommand cmd = DataAccess.GetSqlStringCommand(sql); u8RebackData = DataAccessExtensive.ExecuteListEntity(this.DataAccess, cmd, SetEntity); return u8RebackData; } private void SetEntity(U8RebackData entity, IDataReader reader) { SetEntityUti(entity, "cWhCode", "cWhCode", reader); SetEntityUti(entity, "cWhName", "cWhName", reader); SetEntityUti(entity, "cInvStd", "cInvStd", reader); SetEntityUti(entity, "cInvCode", "cInvCode", reader); SetEntityUti(entity, "cInvName", "cInvName", reader); SetEntityUti(entity, "cComUnitCode", "cComUnitCode", reader); SetEntityUti(entity, "cComUnitName", "cComUnitName", reader); SetEntityUti(entity, "cBatch", "cBatch", reader); SetEntityUti(entity, "iQuantity", "iQuantity", reader); } public SqlExecuteResult UpdateWarehouseCheckState(List stockEntityList) { List cmdlist = new List(); foreach (TN_AB_STOCKEntity entity in stockEntityList) { string strSql = @"update Warehouse set bIsRead_WMS=1,cReader_WMS=:cReader_WMS,dReadDate_WMS=getdate() WHERE cWhCode=:cWhCode "; DbCommand cmd = DataAccess.GetSqlStringCommand(strSql); DataAccess.AddInParameter(cmd, "cReader_WMS", ComDbType.STRING, "汉和信息"); DataAccess.AddInParameter(cmd, "cWhCode", ComDbType.STRING, entity.CN_S_STOCK_CODE); cmdlist.Add(cmd); } return ExecuteCommands(cmdlist, null); } public SqlExecuteResult UpdateCustomerCheckState(List customEntityList) { List cmdlist = new List(); foreach (PLM_CusEntity entity in customEntityList) { string strSql = @"update Customer set bIsRead_WMS=1,cReader_WMS=:cReader_WMS,dReadDate_WMS=getdate() WHERE cCusCode=:cCusCode "; DbCommand cmd = DataAccess.GetSqlStringCommand(strSql); DataAccess.AddInParameter(cmd, "cReader_WMS", ComDbType.STRING, "汉和信息"); DataAccess.AddInParameter(cmd, "cCusCode", ComDbType.STRING, entity.COUSTOMER_CODE); cmdlist.Add(cmd); } return ExecuteCommands(cmdlist, null); } public SqlExecuteResult UpdateVendnrCheckState(List vendnrEntityList) { List cmdlist = new List(); foreach (PLM_VenEntity entity in vendnrEntityList) { string strSql = @"update Vendor set bIsRead_WMS=1,cReader_WMS=:cReader_WMS,dReadDate_WMS=getdate() WHERE cVenCode=:cVenCode "; DbCommand cmd = DataAccess.GetSqlStringCommand(strSql); DataAccess.AddInParameter(cmd, "cReader_WMS", ComDbType.STRING, "汉和信息"); DataAccess.AddInParameter(cmd, "cVenCode", ComDbType.STRING, entity.VENDOR_CODE); cmdlist.Add(cmd); } return ExecuteCommands(cmdlist, null); } } }