You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

383 lines
25 KiB
C#

10 months ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.Areas.OA.Models.RptVwWmsStocktakeEntity;
using DSWeb.Areas.CommMng.Models;
using DSWeb.TruckMng.Helper;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using System.IO;
namespace DSWeb.Areas.OA.Controllers
{
/// <summary>
/// 应收应付明细
/// </summary>
public class RptWmsController : Controller
{
//
// GET: /Import/RptImportFeedetail/
// 库存分段盘点
public ActionResult RptVwWmsStocktakeIndex()
{
return View();
}
public ActionResult RptVwWmsStocktakeEdit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition, string condition2, string condition3, string condition4)
{
var dataList = GetDataList(condition, condition2, condition3, condition4, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
private static List<RptVwWmsStocktakeEntity> GetDataList(string strCondition, string strCondition2, string strCondition3, string strCondition4, string sort)
{
//原仓储查询语句
//strSql.Append(" SELECT NID,CUSTOMERNAME,STORAGENAME,WMSDATE,BLNO,CONTRACTNO,CUSTOMNO,GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSSLICE"
//+ ",hj_GOODSPACK,hj_GOODSPACKACTUAL,hj_GOODSPACKPFSL,hj_GOODSPACKSTOCK"
//+ ",hj_GOODSRKSL,hj_GOODSRKSLACTUAL,hj_GOODSPFSL_OUT,hj_GOODSSTOCK"
//+ ",CHARGEUNIT FROM VW_WMS_STOCKTAKE ");
////WHERE 1=1 " + ViewState["hid_sel"].ToString().Trim()
////+ " ORDER BY CUSTOMERNAME,STORAGENAME,WMSDATE,BLNO,GOODSNAME,GOODSMODEL ");
//原程序
//var strSql = new StringBuilder();
//strSql.Append(" select * from vw_wms_stocktake");
//if (!string.IsNullOrEmpty(strCondition))
//{
// strSql.Append(" where " + strCondition);
//}
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = " and " + strCondition;
}
if (!string.IsNullOrEmpty(strCondition2))
{
strCondition2 = " and " + strCondition2;
}
if (!string.IsNullOrEmpty(strCondition3))
{
strCondition3 = " and " + strCondition3;
}
if (!string.IsNullOrEmpty(strCondition4))
{
strCondition4 = " and " + strCondition4;
}
String strSql = "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, (SELECT CONTRACTNO FROM op_seai WHERE BSNO = A.ASSOCIATEDNO) CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
+ " from ("
+ "SELECT GID, CONVERT(char(10), WMSDATE, 120) AS WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSSTANDARD, '' AS REMARK, '' as GOODSGRADE, 0 as GOODSSLICE"
+ ", GOODSRKSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPFSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
+ ", GOODSPACK"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
+ ", GOODSPACKACTUAL, GOODSRKSLACTUAL, CORPID "
+ " FROM wms WHERE CHARGEUNIT <> 'CBM' AND ISDELETE = 0 " + strCondition
+ ") as A where 1=1 " + strCondition3
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE"
+ " UNION ALL "
+ "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
+ " from ("
+ "SELECT i.GID, CONVERT(char(10), w.WMSDATE, 120) AS WMSDATE"
+ ", w.CUSTOMERNAME, w.BLNO, w.STORAGENAME, w.AREANAME, w.GOODSNAME, i.GOODSMODEL, w.ASSOCIATEDNO, w.CONTRACTNO, w.CHARGEUNIT, w.CUSTOMNO, i.GOODSGRADE, i.GOODSSLICE, i.GOODSSTANDARD, '' as REMARK"
+ ", i.GOODSRKSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPFSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
+ ", i.GOODSPACK"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
+ ", i.GOODSPACKACTUAL, i.GOODSRKSLACTUAL, w.CORPID "
+ " FROM wms_in AS i LEFT OUTER JOIN wms AS w ON i.ASSOCIATEDNO = w.GID WHERE i.CHARGEUNIT = 'CBM' AND i.ISDELETE = 0 " + strCondition
+ ") as A where 1=1 " + strCondition3
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE";
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql += " order by " + sortstring;
}
else
{
strSql += " order by CUSTOMERNAME,STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, WMSDATE, BLNO";
}
return SetData(strSql);
}
private static List<RptVwWmsStocktakeEntity> SetData(String strSql)
{
var headList = new List<RptVwWmsStocktakeEntity>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
var data = new RptVwWmsStocktakeEntity();
#region Set DB data to Object
data.WMSDATE = Convert.ToString(reader["WMSDATE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.BLNO = Convert.ToString(reader["BLNO"]);
data.STORAGENAME = Convert.ToString(reader["STORAGENAME"]);
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
data.GOODSMODEL = Convert.ToString(reader["GOODSMODEL"]);
data.hj_GOODSRKSL = Convert.ToString(reader["hj_GOODSRKSL"]);
data.hj_GOODSPFSL_OUT = Convert.ToString(reader["hj_GOODSPFSL_OUT"]);
data.hj_GOODSPFSL_MONTH = Convert.ToString(reader["hj_GOODSPFSL_MONTH"]);
data.hj_GOODSSTOCK = Convert.ToString(reader["hj_GOODSSTOCK"]);
data.hj_GOODSPACK = Convert.ToString(reader["hj_GOODSPACK"]);
data.hj_GOODSPACKPFSL = Convert.ToString(reader["hj_GOODSPACKPFSL"]);
data.hj_GOODSPACKPFSL_MONTH = Convert.ToString(reader["hj_GOODSPACKPFSL_MONTH"]);
data.hj_GOODSPACKSTOCK = Convert.ToString(reader["hj_GOODSPACKSTOCK"]);
data.GID = Convert.ToString(reader["GID"]);
data.ASSOCIATEDNO = Convert.ToString(reader["ASSOCIATEDNO"]);
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
data.CHARGEUNIT = Convert.ToString(reader["CHARGEUNIT"]);
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
data.GOODSGRADE = Convert.ToString(reader["GOODSGRADE"]);
data.GOODSSLICE = Convert.ToString(reader["GOODSSLICE"]);
data.GOODSSTANDARD = Convert.ToString(reader["GOODSSTANDARD"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.hj_GOODSPACKACTUAL = Convert.ToString(reader["hj_GOODSPACKACTUAL"]);
data.hj_GOODSRKSLACTUAL = Convert.ToString(reader["hj_GOODSRKSLACTUAL"]);
data.AREANAME = Convert.ToString(reader["AREANAME"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public ContentResult GetVwWmsDetailDataList(string condition, string sort)
{
var dataList = GetVwWmsDetailDataList2(condition, sort);
var list = dataList.Skip(0).Take(20);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
private static List<WMSDetailmb> GetVwWmsDetailDataList2(string strCondition, string sort)
{
var strSql = new StringBuilder();
strSql.Append(" SELECT NID,BLNO,CUSTOMNO,CUSTOMERNAME,STORAGENAME,GOODSNAME,GOODSSTANDARD,GOODSMODEL,WMSNO,OUTBSNO_OUT,BSNO_OUT,WMSDATE,DODATE_OUT,GOODSRKSL,GOODSRKSLACTUAL,GOODSPFSL_OUT,GOODSSTOCK,CHARGEUNIT,GOODSOUTFEE_OUT, GOODSOUTFEEAP_OUT,ARFEE, APFEE,ARFEE_OUT,APFEE_OUT,FREESTORAGEPERIOD,CONTRACTNO,GOODSPACK,TRUCKNO_OUT,REMARK_OUT,MODIFIEDUSER,MODIFIEDTIME,CREATEUSER_OUT,CREATETIME_OUT FROM VW_WMS_DETAIL ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetDetailData(strSql);
}
private static List<WMSDetailmb> SetDetailData(StringBuilder strSql)
{
var headList = new List<WMSDetailmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new WMSDetailmb();
#region Set DB data to Object
data.NID = Convert.ToString(reader["NID"]);
data.BLNO = Convert.ToString(reader["BLNO"]);
data.CUSTOMNO = Convert.ToString(reader["CUSTOMNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.STORAGENAME = Convert.ToString(reader["STORAGENAME"]);
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
data.GOODSSTANDARD = Convert.ToString(reader["GOODSSTANDARD"]);
data.GOODSMODEL = Convert.ToString(reader["GOODSMODEL"]);
data.WMSNO = Convert.ToString(reader["WMSNO"]);
data.OUTBSNO_OUT = Convert.ToString(reader["OUTBSNO_OUT"]);
data.BSNO_OUT = Convert.ToString(reader["BSNO_OUT"]);
data.WMSDATE = Convert.ToString(reader["WMSDATE"]);
data.DODATE_OUT = Convert.ToString(reader["DODATE_OUT"]);
data.GOODSRKSL = Convert.ToString(reader["GOODSRKSL"]);
data.GOODSRKSLACTUAL = Convert.ToString(reader["GOODSRKSLACTUAL"]);
data.GOODSPFSL_OUT = Convert.ToString(reader["GOODSPFSL_OUT"]);
data.GOODSSTOCK = Convert.ToString(reader["GOODSSTOCK"]);
data.CHARGEUNIT = Convert.ToString(reader["CHARGEUNIT"]);
data.GOODSOUTFEE_OUT = Convert.ToString(reader["GOODSOUTFEE_OUT"]);
data.GOODSOUTFEEAP_OUT = Convert.ToString(reader["GOODSOUTFEEAP_OUT"]);
data.ARFEE = Convert.ToString(reader["ARFEE"]);
data.APFEE = Convert.ToString(reader["APFEE"]);
data.ARFEE_OUT = Convert.ToString(reader["ARFEE_OUT"]);
data.APFEE_OUT = Convert.ToString(reader["APFEE_OUT"]);
data.FREESTORAGEPERIOD = Convert.ToString(reader["FREESTORAGEPERIOD"]);
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
data.GOODSPACK = Convert.ToString(reader["GOODSPACK"]);
data.TRUCKNO_OUT = Convert.ToString(reader["TRUCKNO_OUT"]);
data.REMARK_OUT = Convert.ToString(reader["REMARK_OUT"]);
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
data.CREATEUSER_OUT = Convert.ToString(reader["CREATEUSER_OUT"]);
data.CREATETIME_OUT = Convert.ToString(reader["CREATETIME_OUT"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 获取List合计数
public ContentResult GetDataListSum(int start, int limit, string sort, string condition, string condition2, string condition3, string condition4)
{
var dataList = GetDataListSum(condition, condition2, condition3, condition4, sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
private static List<RptVwWmsStocktakeEntity> GetDataListSum(string strCondition, string strCondition2, string strCondition3, string strCondition4, string sort)
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = " and " + strCondition;
}
if (!string.IsNullOrEmpty(strCondition2))
{
strCondition2 = " and " + strCondition2;
}
if (!string.IsNullOrEmpty(strCondition3))
{
strCondition3 = " and " + strCondition3;
}
if (!string.IsNullOrEmpty(strCondition4))
{
strCondition4 = " and " + strCondition4;
}
String strSql = "select newid() as GID"
+ ", ISNULL(sum(hj_GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
+ ", ISNULL(SUM(hj_GOODSPFSL_OUT), 0) AS hj_GOODSPFSL_OUT"//出库量
+ ", ISNULL(SUM(hj_GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
+ ", ISNULL(sum(hj_GOODSSTOCK), 0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
+ ", ISNULL(sum(hj_GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
+ ", ISNULL(SUM(hj_GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
+ ", ISNULL(SUM(hj_GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
+ ", ISNULL(SUM(hj_GOODSPACKSTOCK), 0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
+ ", ISNULL(sum(hj_GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
+ ", ISNULL(sum(hj_GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
+ " from (select newid() as GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
+ " from ("
+ "SELECT GID, CONVERT(char(10), WMSDATE, 120) AS WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSSTANDARD, '' AS REMARK, '' as GOODSGRADE, 0 as GOODSSLICE"
+ ", GOODSRKSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPFSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
+ ", GOODSPACK"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
+ ", GOODSPACKACTUAL, GOODSRKSLACTUAL, CORPID "
+ " FROM wms WHERE CHARGEUNIT <> 'CBM' AND ISDELETE = 0 " + strCondition
+ ") as A where 1=1 " + strCondition3
+ " GROUP BY CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE"
+ " UNION ALL "
+ "select newid() as GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
+ " from ("
+ "SELECT i.GID, CONVERT(char(10), w.WMSDATE, 120) AS WMSDATE"
+ ", w.CUSTOMERNAME, w.BLNO, w.STORAGENAME, w.AREANAME, w.GOODSNAME, i.GOODSMODEL, w.ASSOCIATEDNO, w.CONTRACTNO, w.CHARGEUNIT, w.CUSTOMNO, i.GOODSGRADE, i.GOODSSLICE, i.GOODSSTANDARD, '' as REMARK"
+ ", i.GOODSRKSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPFSL"
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
+ ", i.GOODSPACK"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
+ ", i.GOODSPACKACTUAL, i.GOODSRKSLACTUAL, w.CORPID "
+ " FROM wms_in AS i LEFT OUTER JOIN wms AS w ON i.ASSOCIATEDNO = w.GID WHERE i.CHARGEUNIT = 'CBM' AND i.ISDELETE = 0 " + strCondition
+ ") as A where 1=1 " + strCondition3
+ " GROUP BY CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE) as B";
return SetDataSum(strSql);
}
private static List<RptVwWmsStocktakeEntity> SetDataSum(String strSql)
{
var headList = new List<RptVwWmsStocktakeEntity>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
var data = new RptVwWmsStocktakeEntity();
#region Set DB data to Object
data.hj_GOODSRKSL = Convert.ToString(reader["hj_GOODSRKSL"]);
data.hj_GOODSRKSLACTUAL = Convert.ToString(reader["hj_GOODSRKSLACTUAL"]);
data.hj_GOODSPFSL_OUT = Convert.ToString(reader["hj_GOODSPFSL_OUT"]);
data.hj_GOODSPFSL_MONTH = Convert.ToString(reader["hj_GOODSPFSL_MONTH"]);
data.hj_GOODSSTOCK = Convert.ToString(reader["hj_GOODSSTOCK"]);
data.hj_GOODSPACK = Convert.ToString(reader["hj_GOODSPACK"]);
data.hj_GOODSPACKACTUAL = Convert.ToString(reader["hj_GOODSPACKACTUAL"]);
data.hj_GOODSPACKPFSL = Convert.ToString(reader["hj_GOODSPACKPFSL"]);
data.hj_GOODSPACKPFSL_MONTH = Convert.ToString(reader["hj_GOODSPACKPFSL_MONTH"]);
data.hj_GOODSPACKSTOCK = Convert.ToString(reader["hj_GOODSPACKSTOCK"]);
data.GID = Convert.ToString(reader["GID"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
//
}
}