using iWareCommon.Common.Service;
|
using iWareCommon.Utils;
|
using iWareDataCore.BASE.Entity;
|
using iWareDataCore.Check.Dao;
|
using iWareDataCore.Check.Entity;
|
using iWareDataCore.ORM;
|
using iWareDataCore.Properties;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace iWareDataCore.Check.Service
|
{
|
public class PlanViewService: CommonService<PlanViewEntity, CheckPlanView, DbModelCore>
|
{
|
|
private static object Lock = new object();
|
|
private PlanViewService() : base(PlanViewDao.GetInstance()) { }
|
|
private static PlanViewService Instance = null;
|
|
/// <summary>
|
/// 获取单例的方法
|
/// </summary>
|
/// <returns>角色服务的单例实体</returns>
|
public static PlanViewService GetInstance()
|
{
|
|
if (Instance == null)
|
{
|
lock (Lock)
|
{
|
if (Instance == null)
|
{
|
Instance = new PlanViewService();
|
}
|
}
|
}
|
return Instance;
|
}
|
|
/// <summary>
|
/// 盘点计划明细
|
/// </summary>
|
/// <param name="id"></param>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
public List<PlanViewEntity> GetPlaceMaterialByPlanNo(string planno, out string msg)
|
{
|
using(var DbModel = new DbModelCore()){
|
try
|
{
|
msg = "";
|
List<PlanViewEntity> plans = new List<PlanViewEntity>();
|
var planView = DbModel.CheckPlanViews.Where(x => x.planno == planno).ToList();
|
planView.ForEach(x => plans.Add(new PlanViewEntity(x)));
|
|
return plans;
|
}
|
catch (Exception ex)
|
{
|
msg = ex.Message;
|
return null;
|
}
|
}
|
|
}
|
|
/// <summary>
|
/// 根据盘点单号
|
/// </summary>
|
public List<PlanViewEntity> GetPlan(string plannl)
|
{
|
using (DbModelCore context = new DbModelCore())
|
{
|
try
|
{
|
string sql = "select distinct planno,begintime,endtime,updatetime,quantity,planstatus from CheckPlanView";
|
List<PlanViewEntity> data = context.Database.SqlQuery<PlanViewEntity>(sql).ToList();
|
return data;
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLine("InOutService", "GetInMaterial", ex.ToString());
|
return null;
|
}
|
}
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="id"></param>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
public int UpdateByPlanNo(string planno)
|
{
|
using (var DbModel = new DbModelCore())
|
{
|
try
|
{
|
string sql = "update CheckPlan set status = 2 where planno = ";
|
sql += planno;
|
int count = DbModel.Database.ExecuteSqlCommand(sql);
|
return count;
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "UpdateByPlanNo", ex.Message);
|
return -1;
|
}
|
}
|
|
}
|
|
}
|
}
|