コード例 #1
0
        public DataTable AlAssmblingDetail_getDayList(AlAssmblingDetailQryModel qm)
        {
            DateTime dteTmp   = DateTime.Today;
            DateTime dteDateS = DateTime.MinValue;
            DateTime dteDateE = DateTime.Today;

            HryDataService.Instance.getOneDayForAssemblingDetail(qm.Q_Date, ref dteDateS, ref dteDateE);

            var qry = new NsDbQuery();

            qry.setSelect(s =>
            {
                var t1 = s.from <AL_Assmbling>();
                var t2 = s.leftJoin <AL_AssmblingDetail>().on(t => t.ALAD_MCID == t1.ALA_MCID);
                s.select(t1.ALA_MCID, t1.ALA_MCCode, t1.ALA_MCName, t2.ALAD_DATE, t2.ALAD_ITEM, t2.ALAD_QTY);
                s.Where = t1.ALA_MCCode.contains(qm.Q_MCCode.toConstOpt1())
                          & t2.ALAD_DATE >= dteDateS
                          & t2.ALAD_DATE <= dteDateE;
                s.groupBy(t1.ALA_MCID, t1.ALA_MCCode, t1.ALA_MCName, t2.ALAD_DATE, t2.ALAD_ITEM, t2.ALAD_QTY);
                s.orderBy(new[] { t1.ALA_MCName.Asc, t2.ALAD_DATE.Asc });
            });

            var dt = qry.queryData();

            return(dt);
        }
コード例 #2
0
        /// <summary>
        /// 取得此項目的資料
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public String GetAssemblingDetailByDate(string code, string date)
        {
            AlAssmblingDetailQryModel qm = new AlAssmblingDetailQryModel();

            qm.Q_MCCode = code;
            qm.Q_Date   = date;
            var dt = AlDataService.Instance.AlAssmblingDetail_getDayList(qm);


            List <PrdClass> data     = new List <PrdClass>();
            PrdClass        dataList = null;

            if (dt != null && dt.Rows.Count > 0)
            {
                string        codeIdxPast = null, codexPast = null;
                String[]      arrTimeWork = null;
                var           listLine = HryDataService.Instance.getArrayForAssemblingDetail(ref arrTimeWork);
                Int32         sumMorning = 0, sumNighting = 0, index = 0;;
                PrdEditDetail itemLine = null;
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    var    row     = dt.Rows[i];
                    string codeIdx = Convert.ToString(row[AppDataName.ALA_MCID]);
                    string codex   = Convert.ToString(row[AppDataName.ALA_MCName]);
                    var    hh      = Convert.ToDateTime(row[AppDataName.ALAD_DATE]).Hour.ToString();
                    hh    = (hh.Length == 1) ? String.Concat("0", hh) : hh;
                    index = -1;

                    #region 第一筆
                    if (codeIdxPast.isNullOrEmpty())
                    {
                        index = Array.IndexOf(arrTimeWork, hh);
                        if (index >= 0)
                        {
                            itemLine        = listLine[index];
                            itemLine.item   = Convert.ToString(row[AppDataName.ALAD_ITEM]).Replace("\0", string.Empty);
                            itemLine.qty    = Convert.ToString(row[AppDataName.ALAD_QTY]);
                            listLine[index] = itemLine;

                            if (Convert.ToInt32(hh) >= 7 && Convert.ToInt32(hh) <= 18)
                            {
                                sumMorning += Convert.ToInt32(itemLine.qty);
                            }
                            if ((Convert.ToInt32(hh) >= 19 && Convert.ToInt32(hh) <= 23) || (Convert.ToInt32(hh) >= 0 && Convert.ToInt32(hh) <= 6))
                            {
                                sumNighting += Convert.ToInt32(itemLine.qty);
                            }
                        }
                        codeIdxPast = codeIdx;
                        codexPast   = codex;
                        continue;
                    }
                    #endregion

                    #region  一條LINE
                    if (!codeIdxPast.equalIgnoreCase(codeIdx))
                    {
                        //早班
                        index           = Array.IndexOf(arrTimeWork, "Morning小計");
                        itemLine        = listLine[index];
                        itemLine.qty    = Convert.ToString(sumMorning);
                        listLine[index] = itemLine;
                        //晚班
                        index           = Array.IndexOf(arrTimeWork, "Night小計");
                        itemLine        = listLine[index];
                        itemLine.qty    = Convert.ToString(sumNighting);
                        listLine[index] = itemLine;
                        //整天
                        index           = Array.IndexOf(arrTimeWork, "Day合計");
                        itemLine        = listLine[index];
                        itemLine.qty    = Convert.ToString(sumMorning + sumNighting);
                        listLine[index] = itemLine;

                        dataList = new PrdClass(codexPast, listLine);
                        data.Add(dataList);
                        sumMorning  = 0;
                        sumNighting = 0;
                        codeIdxPast = codeIdx;
                        codexPast   = codex;
                        listLine    = HryDataService.Instance.getArrayForAssemblingDetail(ref arrTimeWork);
                    }
                    #endregion

                    #region  一筆
                    index = Array.IndexOf(arrTimeWork, hh);
                    if (index >= 0)
                    {
                        itemLine        = listLine[index];
                        itemLine.item   = Convert.ToString(row[AppDataName.ALAD_ITEM]).Replace("\0", string.Empty);
                        itemLine.qty    = Convert.ToString(row[AppDataName.ALAD_QTY]);
                        listLine[index] = itemLine;

                        if (Convert.ToInt32(hh) >= 7 && Convert.ToInt32(hh) <= 18)
                        {
                            sumMorning += Convert.ToInt32(itemLine.qty);
                        }
                        if ((Convert.ToInt32(hh) >= 19 && Convert.ToInt32(hh) <= 23) || (Convert.ToInt32(hh) >= 0 && Convert.ToInt32(hh) <= 6))
                        {
                            sumNighting += Convert.ToInt32(itemLine.qty);
                        }
                    }
                    #endregion
                }

                //早班
                index           = Array.IndexOf(arrTimeWork, "Morning小計");
                itemLine        = listLine[index];
                itemLine.qty    = Convert.ToString(sumMorning);
                listLine[index] = itemLine;
                //晚班
                index           = Array.IndexOf(arrTimeWork, "Night小計");
                itemLine        = listLine[index];
                itemLine.qty    = Convert.ToString(sumNighting);
                listLine[index] = itemLine;
                //整天
                index           = Array.IndexOf(arrTimeWork, "Day合計");
                itemLine        = listLine[index];
                itemLine.qty    = Convert.ToString(sumMorning + sumNighting);
                listLine[index] = itemLine;
                dataList        = new PrdClass(codexPast, listLine);
                data.Add(dataList);
            }
            return(JsonConvert.SerializeObject(data));

            //return "value";
        }