Esempio n. 1
0
 public async Task <ConstructionPlanMonthDetails> ListPage(ConstructionPlanMonthDetailParm parm)
 {
     return(await WithConnection(async c =>
     {
         ConstructionPlanMonthDetails ret = new ConstructionPlanMonthDetails();
         string sql = "SELECT c.*,ot.name as team_name,d.name,dt.name as pm_type_name " +
                      " FROM construction_plan_month_detail c " +
                      " left join org_tree ot on ot.id=c.team " +
                      " left join dictionary_tree d on d.id=c.work_type " +
                      " left join dictionary_tree dt on dt.id=c.pm_type ";
         string sqlwhere = "";
         if (parm.Query != null)
         {
             sqlwhere = " where c.query=" + parm.Query + " and c.month=" + parm.Month;
         }
         else if (parm.Year != null && parm.Line != null && parm.Company != null && parm.Department != null)
         {
             string tmpSql = "(select id from construction_plan_import_common where year=" + parm.Year
                             + " and department=" + parm.Department
                             + " and company=" + parm.Company
                             + " and line=" + parm.Line + ")";
             sqlwhere = " where c.query=" + tmpSql + " and c.month=" + parm.Month + " and c.is_assigned=0 ";
         }
         if (parm.Team != null)
         {
             sqlwhere += " and c.team=" + parm.Team;
         }
         if (parm.Location != null && parm.LocationBy != null)
         {
             sqlwhere += " and c.location=" + parm.Location + " and c.location_by=" + parm.LocationBy;
         }
         if (!string.IsNullOrWhiteSpace(parm.PlanDate))
         {
             string[] tmpDate = parm.PlanDate.Split('.');
             string lastDay = MSS.Platform.Workflow.WebApi.Model.Common.GetLastDay(Convert.ToInt32(tmpDate[1]), Convert.ToInt32(tmpDate[0]));
             string myDate = tmpDate[0] + "." + tmpDate[1] + ".01-" + tmpDate[0] + "." + tmpDate[1] + "." + lastDay;
             sqlwhere += " and (c.plan_date='" + parm.PlanDate + "' or c.plan_date='" + myDate + "') ";
         }
         sql = sql + sqlwhere + " order by plan_date limit " + (parm.page - 1) * parm.rows + "," + parm.rows;
         var tmp = await c.QueryAsync <ConstructionPlanMonthDetail>(sql);
         if (tmp.Count() > 0)
         {
             sql = "select count(*) FROM construction_plan_month_detail c " + sqlwhere;
             ret.total = await c.QueryFirstOrDefaultAsync <int>(sql);
             ret.rows = tmp.ToList();
         }
         else
         {
             ret.rows = new List <ConstructionPlanMonthDetail>();
             ret.total = 0;
         }
         return ret;
     }));
 }
Esempio n. 2
0
 public async Task <List <ConstructionPlanMonthDetail> > GetByIDs(List <int> ids)
 {
     return(await WithConnection(async c =>
     {
         ConstructionPlanMonthDetails ret = new ConstructionPlanMonthDetails();
         string sql = "SELECT *,ot.name as team_name,d.name,dt.name as pm_type_name " +
                      " FROM construction_plan_month_detail c " +
                      " left join org_tree ot on ot.id=c.team " +
                      " left join dictionary_tree d on d.id=c.work_type " +
                      " left join dictionary_tree dt on dt.id=c.pm_type where c.id in @ids";
         return (await c.QueryAsync <ConstructionPlanMonthDetail>(sql, new { ids })).ToList();
     }));
 }
Esempio n. 3
0
 public async Task <ConstructionPlanMonthDetail> GetByID(int id)
 {
     return(await WithConnection(async c =>
     {
         ConstructionPlanMonthDetails ret = new ConstructionPlanMonthDetails();
         string sql = "SELECT *,ot.name as team_name,d.name,dt.name as pm_type_name " +
                      " FROM construction_plan_month_detail c " +
                      " left join org_tree ot on ot.id=c.team " +
                      " left join dictionary_tree d on d.id=c.work_type " +
                      " left join dictionary_tree dt on dt.id=c.pm_type where c.id=@id";
         return await c.QueryFirstOrDefaultAsync <ConstructionPlanMonthDetail>(sql, new { id });
     }));
 }
        public async Task <ApiResult> ListPage(ConstructionPlanMonthDetailParm parm)
        {
            ApiResult ret = new ApiResult();

            try
            {
                ConstructionPlanMonthDetails c = await _repo.ListPage(parm);

                var locations = await _importRepo.ListAllLocations();

                foreach (var item in c.rows)
                {
                    item.LocationName = locations.Where(a => a.LocationBy == item.LocationBy && a.ID == item.Location)
                                        .FirstOrDefault().Name;
                }
                ret.data = c;
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
            }
            return(ret);
        }