You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
5.9 KiB
165 lines
5.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using QMAPP.DAL;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.FJC.Entity.ProduceManage;
|
|
using QMFrameWork.Data;
|
|
using System.Text;
|
|
|
|
namespace QMAPP.FJC.DAL.Package
|
|
{
|
|
/// <summary>
|
|
/// 作 用:线边库存大屏显示
|
|
/// 作 者:周晓东
|
|
/// 编写日期:20180530
|
|
///</summary>
|
|
public class PackageDAL : BaseDAL
|
|
{
|
|
|
|
|
|
|
|
#region 更新信息
|
|
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新行数</returns>
|
|
public int Update(Entity.Operation.Package model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//更新基本信息
|
|
if (model.CREATEDATE==DateTime.MinValue)
|
|
{
|
|
model.CREATEDATE = model.UPDATEDATE;
|
|
}
|
|
count = session.Update(model);
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 线边库存大屏显示
|
|
|
|
public Entity.Operation.Package Get(Entity.Operation.Package model)
|
|
{
|
|
try
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//获取信息
|
|
model = session.Get<Entity.Operation.Package>(model);
|
|
}
|
|
return model;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public List<Entity.Package.PackageSummary> GetList()
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
//var sql =
|
|
// "SELECT t.MATERIAL_CODE ,(sum(CAPACITY)-sum(USINGCOUNT)) as CAPACITY_USINGCOUNT,(select MATERIAL_NAME from T_MD_MATERIAL where MATERIAL_CODE=t.MATERIAL_CODE) as MATERIAL_NAME ,(select CAPACITY from T_MD_PACKAGESET where MATERIAL_CODE=t.MATERIAL_CODE) as CAPACITY_SET FROM T_AW_PACKAGE t group by MATERIAL_CODE";
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.AppendLine("SELECT M.MATERIAL_CODE ");
|
|
sql.AppendLine(" ,M.MATERIAL_NAME ");
|
|
sql.AppendLine(" ,M.MATERIAL_SHORT ");
|
|
sql.AppendLine(" ,ISNULL(P.CAPACITY,0) AS CAPACITY ");
|
|
sql.AppendLine(" ,ISNULL(P.USINGCOUNT,0) AS USINGCOUNT ");
|
|
sql.AppendLine(" ,ISNULL(P.PACKAGECOUNT,0) AS PACKAGECOUNT ");
|
|
sql.AppendLine(" ,M.CAPACITY AS PACKAGECAPACITY ");
|
|
sql.AppendLine(" ,MC.MATERIAL_TYPE_CODE ");
|
|
sql.AppendLine(" ,MC.MATERIAL_TYPE_NAME ");
|
|
sql.AppendLine(" ,W.WORKCELL_CODE ");
|
|
sql.AppendLine(" ,W.WORKCELL_NAME ");
|
|
sql.AppendLine(" ,C.WORKCENTER_CODE ");
|
|
sql.AppendLine(" ,C.WORKCENTER_NAME ");
|
|
sql.AppendLine(" FROM T_MD_MATERIAL AS M ");
|
|
sql.AppendLine(" LEFT JOIN T_MD_MATERIAL_CLASS AS MC ");
|
|
sql.AppendLine(" ON MC.MATERIAL_TYPE_CODE=m.MATERIAL_TYPE_CODE ");
|
|
sql.AppendLine(" LEFT JOIN (SELECT MATERIAL_CODE ");
|
|
sql.AppendLine(" ,GMP ");
|
|
sql.AppendLine(" FROM T_MD_PBOM_ITEM ");
|
|
sql.AppendLine(" WHERE GMP IS NOT NULL ");
|
|
sql.AppendLine(" GROUP BY MATERIAL_CODE,GMP) AS B ");
|
|
sql.AppendLine(" ON M.MATERIAL_CODE=B.MATERIAL_CODE ");
|
|
sql.AppendLine(" LEFT JOIN (SELECT MATERIAL_CODE ");
|
|
sql.AppendLine(" ,SUM(CAPACITY) AS CAPACITY ");
|
|
sql.AppendLine(" ,SUM(USINGCOUNT) AS USINGCOUNT ");
|
|
sql.AppendLine(" ,COUNT(1) AS PACKAGECOUNT ");
|
|
sql.AppendLine(" FROM T_AW_PACKAGE ");
|
|
sql.AppendLine(" WHERE USINGSTATE <> '2' ");
|
|
sql.AppendLine(" GROUP BY MATERIAL_CODE ) AS P ");
|
|
sql.AppendLine(" ON P.MATERIAL_CODE=M.MATERIAL_CODE ");
|
|
sql.AppendLine(" LEFT JOIN T_MD_WORKCELL AS W ");
|
|
sql.AppendLine(" ON W.WORKCELL_CODE=B.GMP ");
|
|
sql.AppendLine(" LEFT JOIN T_MD_WORKCENTER AS C ");
|
|
sql.AppendLine(" ON W.WORKCENTER_CODE=C.WORKCENTER_CODE ");
|
|
sql.AppendLine(" WHERE MC.MATERIAL_ATTRIBUTE = '1' ");
|
|
sql.AppendLine(" AND B.GMP IS NOT NULL ");
|
|
sql.AppendLine(" AND M.CAPACITY > 1 ");
|
|
sql.AppendLine(" ORDER BY WORKCENTER_CODE,W.WORKCELL_CODE,MATERIAL_CODE ");
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<Entity.Package.PackageSummary>(sql.ToString(), parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
public List<Entity.Operation.Package> GetMaterialCodeList(string materialCode)
|
|
{
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
var sql =
|
|
"SELECT PID,PACKAGECODE,MATERIAL_CODE,CAPACITY,USINGCOUNT FROM T_AW_PACKAGE where MATERIAL_CODE='" + materialCode + "'";
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<Entity.Operation.Package>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|