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 { private static object Lock = new object(); private PlanViewService() : base(PlanViewDao.GetInstance()) { } private static PlanViewService Instance = null; /// /// 获取单例的方法 /// /// 角色服务的单例实体 public static PlanViewService GetInstance() { if (Instance == null) { lock (Lock) { if (Instance == null) { Instance = new PlanViewService(); } } } return Instance; } /// /// 盘点计划明细 /// /// /// /// public List GetPlaceMaterialByPlanNo(string planno, out string msg) { using(var DbModel = new DbModelCore()){ try { msg = ""; List plans = new List(); 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; } } } /// /// 根据盘点单号 /// public List GetPlan(string plannl) { using (DbModelCore context = new DbModelCore()) { try { string sql = "select distinct planno,begintime,endtime,updatetime,quantity,planstatus from CheckPlanView"; List data = context.Database.SqlQuery(sql).ToList(); return data; } catch (Exception ex) { LogTextHelper.WriteLine("InOutService", "GetInMaterial", ex.ToString()); return null; } } } /// /// /// /// /// /// 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; } } } } }