jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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<PLM_itemEntity> itemEntityList)
        {
            List<DbCommand> cmdlist = new List<DbCommand>();
            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<U8RebackData> GetStockData()
        {
            List<U8RebackData> u8RebackData = new List<U8RebackData>();
            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<U8RebackData>(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<TN_AB_STOCKEntity> stockEntityList)
        {
            List<DbCommand> cmdlist = new List<DbCommand>();
            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<PLM_CusEntity> customEntityList)
        {
            List<DbCommand> cmdlist = new List<DbCommand>();
            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<PLM_VenEntity> vendnrEntityList)
        {
            List<DbCommand> cmdlist = new List<DbCommand>();
            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);
        }
    }
}