Beispiel #1
0
        // build scrap dictionary
        public void BuildScrapDictionary()
        {
            string   query          = "select oejob#, oeseq#, oecdat, oectim from cmsdat.rprp order by oecdat, oectim";
            ExcoODBC odbcConnection = ExcoODBC.Instance;

            odbcConnection.Open(database);
            OdbcDataReader reader = odbcConnection.RunQuery(query);

            while (reader.Read())
            {
                Scrap scrap = new Scrap();
                scrap.wo   = reader[0].ToString().Trim();
                scrap.seq  = Convert.ToInt32(reader[1]);
                scrap.time = Convert.ToDateTime(Convert.ToDateTime(reader[2]).ToShortDateString() + " " + reader[3].ToString().Trim());
                if (!scrapMap.ContainsKey(scrap.wo))
                {
                    scrapMap.Add(scrap.wo, scrap);
                }
            }
            reader.Close();
        }
Beispiel #2
0
        // get piece's info
        public void GetInfo(Database database, Dictionary <string, Dictionary <int, SeqTemplate> > seqTemplateMap, Dictionary <string, Scrap> scrapMap, Dictionary <int, List <Task> > sparkMap, Dictionary <int, List <Task> > wireMap, DateTime date)
        {
            if (!seqTemplateMap.ContainsKey(wo))
            {
                return;
            }
            Dictionary <int, SeqTemplate> seqMap = seqTemplateMap[wo];

            foreach (SeqTemplate seqTemplate in seqMap.Values)
            {
                Seq seq = new Seq(seqTemplate.seqNum, seqTemplate.runtime, type, part, wo, so);
                // get description based on sequence number
                seq.GetSeqInfo(database, sparkMap, wireMap, date);
                seq.runtimeList[0].seqNum  = seq.seqNum;
                seq.runtimeList[0].part    = part;
                seq.runtimeList[0].woNum   = wo;
                seq.runtimeList[0].soNum   = so;
                seq.runtimeList[0].type    = type;
                seq.runtimeList[0].stdTime = seq.stdTime;
                seqList.Add(seq);
            }
            // check scrap
            if (scrapMap.ContainsKey(wo))
            {
                Scrap scrap = scrapMap[wo];
                foreach (Seq seq in seqList)
                {
                    if (seq.seqNum <= scrap.seq)
                    {
                        RunTime runtime = seq.runtimeList[seq.runtimeList.Count - 1].DeepCopy();
                        runtime.taskList.Clear();
                        seq.runtimeList.Add(runtime);
                    }
                }
            }
            // get solarsoft time
            ExcoODBC odbcConnection = ExcoODBC.Instance;

            odbcConnection.Open(database);
            foreach (Seq seq in seqList)
            {
                if (seq.seqNum != 320 && seq.seqNum != 320 && seq.seqNum != 330 && seq.seqNum != 340 && seq.seqNum != 350 && seq.seqNum != 360)
                {
                    string         query  = "select fwdept, fwresc, fwtime, fwdate, fwqtyc from cmsdat.jcsta where fwjobn='" + wo + "' and fwoseq=" + seq.seqNum.ToString() + " order by fwdate";
                    OdbcDataReader reader = odbcConnection.RunQuery(query);
                    int            i      = 0;
                    while (reader.Read())
                    {
                        seq.runtimeList[i].quantity        += Convert.ToInt32(reader["fwqtyc"]);
                        seq.runtimeList[i].seqNum           = seq.seqNum;
                        seq.runtimeList[i].part             = part;
                        seq.runtimeList[i].woNum            = wo;
                        seq.runtimeList[i].empNum           = 99999;
                        seq.runtimeList[i].depCode          = reader["fwdept"].ToString().Trim().Replace("001", "");;
                        seq.runtimeList[i].resCode          = reader["fwresc"].ToString().Trim();;
                        seq.runtimeList[i].soNum            = so;
                        seq.runtimeList[i].stdTime          = seq.stdTime;
                        seq.runtimeList[i].slsTime         += Convert.ToDouble(reader["fwtime"]);
                        seq.runtimeList[i].slsDate          = Convert.ToDateTime(reader["fwdate"].ToString().Trim());
                        seq.runtimeList[i].hasSolarsoftTime = true;
                        if (seq.runtimeList.Count > i + 1)
                        {
                            i++;
                        }
                    }
                    reader.Close();
                    // adjust quantity when meets scrap
                    if (seq.runtimeList.Count > 1)
                    {
                        if (seq.runtimeList.Count > 1 && seq.runtimeList[0].quantity > 1)
                        {
                            if (seq.runtimeList[1].quantity < 1)
                            {
                                seq.runtimeList[0].quantity = 1;
                                seq.runtimeList[1].quantity = 1;
                            }
                        }
                    }
                }
                else
                {
                    if (!seqTemplateMap[seq.woNum].ContainsKey(seq.seqNum))
                    {
                        throw new Exception("failed to find sequence number " + seq.seqNum.ToString() + " in sequence template " + wo);
                    }
                    seq.runtimeList[0].quantity = seqTemplateMap[seq.woNum][seq.seqNum].compQuant;
                    seq.runtimeList[0].seqNum   = seq.seqNum;
                    seq.runtimeList[0].part     = part;
                    seq.runtimeList[0].woNum    = wo;
                    seq.runtimeList[0].soNum    = so;
                    seq.runtimeList[0].stdTime  = seq.stdTime;
                    if (seq.runtimeList[0].quantity > 0)
                    {
                        seq.runtimeList[0].slsTime          = seq.runtimeList[0].stdTime;
                        seq.runtimeList[0].hasSolarsoftTime = true;
                    }
                }
            }
        }