using System; using System.Collections.Generic; using System.Linq; using System.Web; using Warehouse.Models.mesModel; using Warehouse.Models.mesMysqlModel; namespace Warehouse.DAL.WarehouseReport { public class LCLreportDal { //拼柜 public List LCL(string StartDateTime, string EndDateTime, string powergrade, string palletno, string state,string containerno) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; //if (!string.IsNullOrEmpty(StartDateTime)) //{ // strWhere += " and a.wks_visit_date >= '" + StartDateTime + "' "; //} //if (!string.IsNullOrEmpty(EndDateTime)) //{ // strWhere += " and a.wks_visit_date <= '" + EndDateTime + "' "; //} if (!string.IsNullOrEmpty(containerno)) { strWhere += "and LCLing.containerno = '" + containerno + "' "; } if (!string.IsNullOrEmpty(powergrade)) { strWhere += "and LCLing.powergrade = '" + powergrade + "' "; } if (!string.IsNullOrEmpty(palletno)) { strWhere += "and LCLingLotid.palletno = '" + palletno + "' "; } if (!string.IsNullOrEmpty(state)) { strWhere += " and LCLing.state = '" + state + "' "; } sql = @"SELECT LCLing.containerno,LCLing.state,LCLing.powergrade,LCLing.count,LCLingLotid.palletno FROM [wh].[dbo].[tcontainer] LCLing left join [wh].[dbo].[tcontainerpallet] LCLingLotid on LCLing.containerno = LCLingLotid.containerno WHERE 1=1" +strWhere ; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } public List Tobeputinstorage(string StartDateTime, string EndDateTime, string locationname, string type, string pallet, string name,string containerno) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; //if (!string.IsNullOrEmpty(StartDateTime)) //{ // strWhere += " and a.wks_visit_date >= '" + StartDateTime + "' "; //} //if (!string.IsNullOrEmpty(EndDateTime)) //{ // strWhere += " and a.wks_visit_date <= '" + EndDateTime + "' "; //} if (!string.IsNullOrEmpty(locationname)) { strWhere += "and kw.locationname = '" + locationname + "' "; } if (!string.IsNullOrEmpty(name)) { strWhere += "and ck.name = '" + name + "' "; } if (!string.IsNullOrEmpty(type)) { strWhere += "and ck.type = '" + type + "' "; } if (!string.IsNullOrEmpty(pallet)) { strWhere += " and lot.pallet = '" + pallet + "' "; } if (!string.IsNullOrEmpty(containerno)) { strWhere += " and LCL.containerno = '" + containerno + "' "; } sql = @"/****** Script for SelectTopNRows command from SSMS ******/ SELECT kw.locationname,ck.name,ck.type,lot.pallet,LCL.containerno,LCL.createuser,LCL.status FROM [wh].[dbo].[tstoragelocation] KW left join [wh].[dbo].[tstock] CK on kw.stockid =ck.id left join [wh].[dbo].[treturnstocklog] lot on kw.id =lot.storagelocationid left join [wh].[dbo].[tcontainerpallet] LCL on lot.id =LCL.id WHERE 1=1" + strWhere; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } //待拼柜 public List Tospellark(string StartDateTime, string EndDateTime, string workorder, string power_grade, string pallet_nbr, string product_code, string final_grade,string current_grade) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; if (!string.IsNullOrEmpty(StartDateTime)) { strWhere += " and a.pack_date >= '" + StartDateTime + "' "; } if (!string.IsNullOrEmpty(EndDateTime)) { strWhere += " and a.pack_date <= '" + EndDateTime + "' "; } if (!string.IsNullOrEmpty(workorder)) { strWhere += "and a.workorder in (" + workorder + ") "; } if (!string.IsNullOrEmpty(product_code)) { strWhere += "and a.product_code = '" + product_code + "' "; } if (!string.IsNullOrEmpty(power_grade)) { strWhere += "and a.power_grade = '" + power_grade + "' "; } if (!string.IsNullOrEmpty(pallet_nbr)) { strWhere += " and a.pallet_nbr in (" + pallet_nbr + ") "; } if (!string.IsNullOrEmpty(final_grade)) { strWhere += " and a.final_grade = '" + final_grade + "' "; } if (!string.IsNullOrEmpty(current_grade)) { strWhere += " and a.current_grade = '" + current_grade + "' "; } sql = @"select a.pallet_nbr,a.pack_date,a.product_code,a.workorder,a.power_grade,a.final_grade,current_grade from mes_main.dbo.pack_pallets a left join wh.dbo.tcontainerpallet b on a.pallet_nbr = b.palletno left join wh.dbo.tcontainer c on b.containerno = c.containerno where c.containerno is null" + strWhere; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } //移库记录 public List tmovestocklog(string StartDateTime, string EndDateTime, string oldstoragelocationid, string newstoragelocationid,string pallet) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; if (!string.IsNullOrEmpty(StartDateTime)) { strWhere += " and a.createtime >= '" + StartDateTime + "' "; } if (!string.IsNullOrEmpty(EndDateTime)) { strWhere += " and a.createtime <= '" + EndDateTime + "' "; } //if (!string.IsNullOrEmpty(workorder)) //{ // strWhere += "and a.workorder = '" + workorder + "' "; //} if (!string.IsNullOrEmpty(oldstoragelocationid)) { strWhere += "and b.locationname = '" + oldstoragelocationid + "' "; } if (!string.IsNullOrEmpty(newstoragelocationid)) { strWhere += "and b.locationname = '" + newstoragelocationid + "' "; } if (!string.IsNullOrEmpty(pallet)) { strWhere += " and a.pallet in (" + pallet + ") "; } //if (!string.IsNullOrEmpty(final_grade)) //{ // strWhere += " and a.final_grade = '" + final_grade + "' "; //} //if (!string.IsNullOrEmpty(current_grade)) //{ // strWhere += " and a.current_grade = '" + current_grade + "' "; //} sql = @"SELECT a.pallet,b.locationname,c.locationname,d.Username,a.createtime FROM wh.dbo.tmovestocklog a left join wh.dbo.tstoragelocation b on a.oldstoragelocationid = b.id left join wh.dbo.tstoragelocation c on a.newstoragelocationid = c.id left join wh.dbo.tusers d on a.createuser =d.UserId where 1=1 " + strWhere; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } //删柜记录 public List delcontainerlog(string StartDateTime, string EndDateTime, string container, string pallet) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; if (!string.IsNullOrEmpty(StartDateTime)) { strWhere += " and a.createtime >= '" + StartDateTime + "' "; } if (!string.IsNullOrEmpty(EndDateTime)) { strWhere += " and a.createtime <= '" + EndDateTime + "' "; } //if (!string.IsNullOrEmpty(workorder)) //{ // strWhere += "and a.workorder = '" + workorder + "' "; //} //if (!string.IsNullOrEmpty(oldstoragelocationid)) //{ // strWhere += "and b.locationname = '" + oldstoragelocationid + "' "; //} if (!string.IsNullOrEmpty(container)) { strWhere += "a.container in (" + container + ") "; } if (!string.IsNullOrEmpty(pallet)) { strWhere += " and a.pallet in (" + pallet + ") "; } //if (!string.IsNullOrEmpty(final_grade)) //{ // strWhere += " and a.final_grade = '" + final_grade + "' "; //} //if (!string.IsNullOrEmpty(current_grade)) //{ // strWhere += " and a.current_grade = '" + current_grade + "' "; //} sql = @"SELECT a.pallet,a.container,a.createuser,a.createtime,remark FROM [wh].[dbo].[tdelcontainerlog] a where 1=1 " + strWhere; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } //退库记录 public List returnstocklog(string StartDateTime, string EndDateTime, string pallet) { using (var context = new mesModel()) { string sql = string.Empty; string strWhere = string.Empty; if (!string.IsNullOrEmpty(StartDateTime)) { strWhere += " and a.createtime >= '" + StartDateTime + "' "; } if (!string.IsNullOrEmpty(EndDateTime)) { strWhere += " and a.createtime <= '" + EndDateTime + "' "; } //if (!string.IsNullOrEmpty(workorder)) //{ // strWhere += "and a.workorder = '" + workorder + "' "; //} //if (!string.IsNullOrEmpty(oldstoragelocationid)) //{ // strWhere += "and b.locationname = '" + oldstoragelocationid + "' "; //} //if (!string.IsNullOrEmpty(container)) //{ // strWhere += "a.container in (" + container + ") "; //} if (!string.IsNullOrEmpty(pallet)) { strWhere += " and a.pallet in (" + pallet + ") "; } //if (!string.IsNullOrEmpty(final_grade)) //{ // strWhere += " and a.final_grade = '" + final_grade + "' "; //} //if (!string.IsNullOrEmpty(current_grade)) //{ // strWhere += " and a.current_grade = '" + current_grade + "' "; //} sql = @"SELECT a.pallet,a.storagelocationid,a.createuser,a.createtime FROM [wh].[dbo].[treturnstocklog] a where 1=1 " + strWhere; var res = context.DynamicListFromSql(sql, null); return res.ToList(); } } } }