using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using HH.WMS.Entitys;
|
using HH.WMS.Common;
|
using System.Data.Common;
|
|
namespace HH.WMS.DAL.SysMgr
|
{
|
public class TN_WM_TASKDAL : DapperBaseDAL
|
{
|
#region GET
|
|
public DataTable GetList(int pageIndex, int pageSize, out long total, string where = "", string orderBy = "")
|
{
|
string sql = @" (SELECT * FROM TN_WM_TASK " + where + ") a ";
|
return ExecutePagingData(sql, pageIndex, pageSize, out total, "", "");
|
}
|
|
#endregion
|
|
|
/// <summary>
|
/// 获取正在执行中或者未执行的任务
|
/// </summary>
|
/// <param name="trayCode"></param>
|
/// <returns></returns>
|
public List<TN_WM_TASKEntity> GetTaskByTray(string trayCode)
|
{
|
string sql = @" SELECT * FROM TN_WM_TASK where CN_S_TRAY_CODE ='" + trayCode + "' AND CN_S_STATE IN('" + Constants.TaskState_NoExecuted + "','" + Constants.TaskState_Executing + "') ";
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
/// <summary>
|
/// 获取正在执行中或者未执行的任务
|
/// </summary>
|
/// <param name="trayCode"></param>
|
/// <returns></returns>
|
public List<TN_WM_TASKEntity> GetTaskByEndLocation(string locationCode)
|
{
|
string sql = @" SELECT * FROM TN_WM_TASK where CN_S_END_BIT ='" + locationCode + "' AND CN_S_STATE IN('" + Constants.TaskState_NoExecuted + "','" + Constants.TaskState_Executing + "') ";
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
|
/// <summary>
|
/// 获取任务根据任务号
|
/// </summary>
|
/// <param name="taskNo"></param>
|
/// <returns></returns>
|
public List<TN_WM_TASKEntity> GetTaskByTaskNo(string taskNo)
|
{
|
string sql = " SELECT * FROM TN_WM_TASK WHERE CN_S_TASK_NO='" + taskNo + "' ";
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
|
public List<TN_WM_TASKEntity> GetTask(string sqlWhere)
|
{
|
string sql = " SELECT * FROM TN_WM_TASK WHERE 1=1 " + sqlWhere;
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
|
public List<TN_WM_TASKEntity> GetTaskByAreaCode(string areaCode)
|
{
|
string sql = string.Format(@" SELECT * FROM TN_WM_TASK WHERE (CN_S_START_AREA='{0}' OR CN_S_END_AREA='{0}') AND CN_S_STATE IN ('未执行','执行中','开始取货','取货完成','开始卸货','卸货完成') ", areaCode);
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
public List<TN_WM_TASKEntity> GetTaskByAreaCodeJX(string areaCode)
|
{
|
string sql = string.Format(@" SELECT * FROM TN_WM_TASK WHERE CN_S_END_AREA='{0}' AND CN_S_STATE IN ('未执行','执行中','开始取货','取货完成','开始卸货','卸货完成') ", areaCode);
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
public List<TN_WM_TASKEntity> GetTaskByAreaCodeList(string areaCode)
|
{
|
string sql = string.Format(@" SELECT * FROM TN_WM_TASK WHERE (CN_S_START_AREA IN '{0}' OR CN_S_END_AREA IN '{0}') AND CN_S_STATE IN ('未执行','执行中') ", areaCode);
|
return ExecuteQuery<TN_WM_TASKEntity>(sql, null);
|
}
|
public OperateResult UpdateState(string locationCode, string afterLocationSate, string useState, string beforeLocationState, IDbTransaction trans)
|
{
|
string sql = string.Format(@"UPDATE tn_wm_b_location_ext SET CN_S_LOCATION_STATE='{0}',CN_S_USE_STATE='{1}'
|
WHERE CN_S_LOCATION_CODE='{2}' AND CN_S_LOCATION_STATE='{3}' ", afterLocationSate, useState, locationCode, beforeLocationState);
|
return ExecuteTranSql(sql, null, trans);
|
}
|
#region 计算该库区中的出入任务总和
|
/// <summary>
|
/// 查找该库区中即将要存放该物料的货位
|
/// </summary>
|
/// <param name="stockCode"></param>
|
/// <param name="locationCodes"></param>
|
/// <param name="opType"></param>
|
/// <returns></returns>
|
public long CalTaskCountByAreaCode(string areaCode)
|
{
|
StringBuilder strSql = new StringBuilder();
|
strSql.AppendLine(" SELECT * FROM TN_WM_TASK ");
|
strSql.AppendLine(" WHERE CN_S_STATE IN ('未执行','执行中') ");
|
if (!string.IsNullOrEmpty(areaCode))
|
{
|
strSql.AppendLine(" AND CN_S_END_AREA = '" + areaCode + "' ");
|
}
|
Log.AlgorInfo("CalTaskCountByAreaCode", "sql语句为:" + strSql.ToString());
|
long result = ExecuteCountSql(strSql.ToString());
|
return result;
|
}
|
#endregion
|
|
}
|
}
|