예제 #1
0
        /// <summary>
        ///  根据工种统计出工情况
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <WorkTypeCount> GetToWorkByType(WorkCount model)
        {
            sb?.Clear();
            sb.Append(string.Format(@"SELECT A22.E0386,B22.numCount,(C22.allCount-B22.numCount) AS unCount FROM
                (
	                SELECT ISNULL(code1.E0386,'其他') AS E0386,A2.gong FROM
	                (SELECT DISTINCT ISNULL(E0386,'00') AS gong FROM dbo.A01 WHERE UnitID=@UnitID) A2 LEFT JOIN
	                (SELECT CodeItemID,CodeItemName AS E0386 FROM dbo.SM_CodeItems WHERE CodeID='JA') code1 
	                ON A2.gong=code1.CodeItemID
                ) A22 INNER JOIN
                (
	                SELECT gong,COUNT(A11.gong) AS numCount FROM 
	                (
		                SELECT ISNULL(A1.E0386,'00') AS gong FROM 
		                (SELECT A0177,UnitID,E0386 FROM dbo.A01) A1 INNER JOIN
		                (SELECT DISTINCT A0177,UnitID FROM dbo.View_A02 WHERE UnitID=@UnitID AND CONVERT(varchar(100), A0201, 23)=@dateStart) B
		                ON A1.A0177 = B.A0177 WHERE A1.UnitID=B.UnitID
	                ) A11 GROUP BY A11.gong
                )B22 ON A22.gong = B22.gong INNER JOIN
                (
					SELECT gong,COUNT(gong) AS allCount FROM 
					(SELECT ISNULL(E0386,'00') AS gong FROM dbo.A01 WHERE UnitID=@UnitID)C11 GROUP BY C11.gong
                )C22 ON B22.gong=C22.gong;"));
            _param?.Clear();
            _param.Add("@UnitID", model.orgid);
            _param.Add("@dateStart", model.work_date);
            DataTable dt = SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, SqlHelper.GetParameters(_param));

            return(HCQ2_Common.Data.DataTableHelper.DataTableToIList <WorkTypeCount>(dt));
        }
예제 #2
0
        public ActionResult Create(int id, WorkCountViewModel collection)
        {
            try
            {
                using (OnlineShopDbContext db = new OnlineShopDbContext())
                {
                    WorkCountViewModel model = new WorkCountViewModel();
                    model.Thiet_Bi   = db.Thiet_Bis.OrderBy(m => m.ID).ToList();
                    model.ProjectAll = new List <SelectListItem>();

                    var items = new List <SelectListItem>();
                    foreach (var project in model.Thiet_Bi)
                    {
                        items.Add(new SelectListItem()
                        {
                            Value = project.Ten_Thiet_Bi,
                            Text  = project.Ten_Thiet_Bi,
                        });
                    }

                    model.ProjectAll = items;

                    var Check = model.Thiet_Bi[0].Ten_Thiet_Bi;

                    model.Catelory_Project = db.Catelories.Where(i => i.Prj_Name == Check).ToList();

                    model.Number_Team_2   = model.Catelory_Project.Count();
                    model.SelectedProject = null;
                    int j = 0;

                    model.WorkCount = db.WorkCounts.Where(i => i.CreateDate == collection.SelectedWorkCount.CreateDate).ToList();

                    if (model.WorkCount.Count() != 0)
                    {
                        return(View("Index", model));
                    }

                    foreach (var item in collection.Count_Number)
                    {
                        WorkCount obj = new WorkCount();

                        model.WorkCount = db.WorkCounts.Where(i => i.CreateDate == collection.SelectedWorkCount.CreateDate).ToList();

                        obj.Ten_Thiet_Bi = Check;
                        obj.Unit_Name    = model.Catelory_Project[j].Unit_Name;
                        obj.CreateDate   = collection.SelectedWorkCount.CreateDate;
                        obj.Unit_Number  = item;

                        db.WorkCounts.Add(obj);
                        db.SaveChanges();
                        j = j + 1;
                    }
                    return(View("Index", model));
                }
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
 /// <summary>
 ///  根据工种统计出工情况
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <WorkTypeCount> GetToWorkByType(WorkCount model)
 {
     if (null == model)
     {
         return(null);
     }
     return(DBSession.IView_A02DAL.GetToWorkByType(model));
 }
예제 #4
0
 /// <summary>
 ///  获取未出工人数
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int GetonWorkPersonCount(WorkCount model)
 {
     if (null == model)
     {
         return(0);
     }
     return(DBSession.IView_A02DAL.GetonWorkPersonCount(model));
 }
예제 #5
0
 /// <summary>
 ///  获取未出工情况
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <string> GetonWorkPersonList(WorkCount model)
 {
     if (null == model)
     {
         return(null);
     }
     return(DBSession.IView_A02DAL.GetonWorkPersonList(model));
 }
예제 #6
0
        /// <summary>
        ///  获取未出工人数
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int GetonWorkPersonCount(WorkCount model)
        {
            sb?.Clear();
            sb.Append(string.Format(@"SELECT COUNT(A0101) FROM dbo.A01 WHERE UnitID=@UnitID AND ISNULL(retire_time,'')='' AND PersonID NOT IN(
	            SELECT DISTINCT PersonID FROM dbo.View_A02 WHERE UnitID=@UnitID AND CONVERT(varchar(100), A0201, 23)=@dateStart
            )"));
            _param?.Clear();
            _param.Add("@UnitID", model.orgid);
            _param.Add("@dateStart", model.work_date);
            return(Helper.ToInt(SqlHelper.ExecuteScalar(sb.ToString(), CommandType.Text, SqlHelper.GetParameters(_param))));
        }
예제 #7
0
        public object GetWorkTypeByUnit(WorkCount model)
        {
            if (!ModelState.IsValid)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.参数异常.ToString(), null));
            }
            List <WorkTypeCount>        cList = operateContext.bllSession.View_A02.GetToWorkByType(model);
            Dictionary <string, object> obj   = new Dictionary <string, object>();

            obj.Add("allCount", operateContext.bllSession.View_A02.GetWorkPersonCount(model));
            obj.Add("personList", cList);
            return(operateContext.RedirectWebApi(WebResultCode.Ok, GlobalConstant.数据获取成功.ToString(), obj));
        }
예제 #8
0
        /// <summary>
        ///  获取未出工情况
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <string> GetonWorkPersonList(WorkCount model)
        {
            sb?.Clear();
            sb.Append(string.Format(@"SELECT A0101 FROM dbo.A01 WHERE UnitID=@UnitID AND ISNULL(retire_time,'')='' AND PersonID NOT IN(
	            SELECT DISTINCT PersonID FROM dbo.View_A02 WHERE UnitID=@UnitID AND CONVERT(varchar(100), A0201, 23)=@dateStart
            ); "));
            _param?.Clear();
            _param.Add("@UnitID", model.orgid);
            _param.Add("@dateStart", model.work_date);
            DataTable             dt   = SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text, SqlHelper.GetParameters(_param));
            List <WorkParamModel> list = HCQ2_Common.Data.DataTableHelper.DataTableToIList <WorkParamModel>(dt);

            if (null == list)
            {
                return(null);
            }
            return(list.Select(s => s.A0101).ToList());
        }
예제 #9
0
        public object GetPersonWorkByUnit(WorkCount model)
        {
            if (!ModelState.IsValid)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.参数异常.ToString(), null));
            }
            HCQ2_IBLL.IView_A02BLL View02 = operateContext.bllSession.View_A02;
            int toWork = View02.GetWorkPersonCount(model);
            int onWork = View02.GetonWorkPersonCount(model);
            ToWorkResultModel rModel = new ToWorkResultModel
            {
                allCount   = toWork + onWork,
                toWork     = toWork,
                onWork     = onWork,
                toWorkList = operateContext.bllSession.View_A02.GetWorkPersonList(model),
                onWorkList = operateContext.bllSession.View_A02.GetonWorkPersonList(model)
            };

            if (null == rModel)
            {
                return(operateContext.RedirectWebApi(WebResultCode.Exception, GlobalConstant.数据获取失败.ToString(), null));
            }
            return(operateContext.RedirectWebApi(WebResultCode.Ok, GlobalConstant.操作成功.ToString(), rModel));
        }