using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.FJC.Entity.Operation; using QMFrameWork.Data; using QMAPP.FJC.Entity.ProcessParameter; using QMAPP.FJC.Entity.Injection; namespace EQUIPINTERFACETEST { public class InsertScorekinParameterClass { public void Insert() { string sql = @"select * from t_aw_product t where t.PRODUCTTYPE='0' and t.CREATEDATE>'2016-06-1 00:50:19.237' and t.CURRENTPROCESS>'6' and not exists (select 1 from t_aw_mainoperation mo where mo.PROCESSTYPE='6' and t.pid=mo.pdid)"; string sqlparameter = @"select top 40 * from T_AW_BURNPARAMETER b where b.createdate<'2016-06-14 12:24:21.671' order by b.createdate desc"; List productList = new List(); List burnList = new List(); using (IDataSession session = AppDataFactory.CreateMainSession()) { productList = session.GetList(sql, new List().ToArray()).ToList(); burnList = session.GetList(sqlparameter, new List().ToArray()).ToList(); } List moList = new List(); List addBurnList = new List(); int index = 0; foreach (var p in productList) { string pid = Guid.NewGuid().ToString(); if (index == 39) index = 0; MainOperation mo = new MainOperation(); mo.PID = Guid.NewGuid().ToString(); mo.PDID = p.PID; mo.PRODUCTCODE = p.PRODUCTCODE; mo.PROCESSTYPE = "6"; mo.PRODUCTTYPE = "0"; mo.MACHINENAME = "AUDIB9冷刀切割设备"; mo.MACHINECODDE = "1A-CC0002"; mo.STATUS = "0"; mo.OPERATESTATE = "1"; mo.OPERATEDDATE = p.CREATEDATE.AddDays(1).AddHours(2); mo.CURRENTPROCESS = "6"; mo.PRODUCELINE = "B9"; mo.CREATEUSER = "c361d78c-91ed-4b1f-9777-8ff0aefa6cc6"; mo.CREATEDATE = p.CREATEDATE.AddDays(1).AddHours(2); mo.UPDATEUSER = "c361d78c-91ed-4b1f-9777-8ff0aefa6cc6"; mo.PRODUCESHIFTTCODE = "1"; BurnParameter burnPara = burnList[index]; burnPara.PID = pid; burnPara.PDID = p.PID; burnPara.PRODUCTCODE = p.PRODUCTCODE; burnPara.MOID = mo.PID; burnPara.CREATEDATE = mo.CREATEDATE.AddSeconds(70); burnPara.WORKTIME = mo.CREATEDATE.AddMinutes(5).ToString("HH:mm"); burnPara.RELEASE = "1"; index++; using (IDataSession session = AppDataFactory.CreateMainSession()) { session.Insert(mo); Console.WriteLine(burnPara.PRODUCTCODE); session.Insert(burnPara); } } } public void InsertInjection() { string sql = @"SELECT * FROM T_AW_PRODUCT T WHERE T.CREATEDATE>'2016-04-05 18:59:09' AND T.PRODUCTCODE LIKE 'B9B%' AND NOT exists (select 1 from T_AW_PRODUCTINJECTIOn p where p.MPPID=t.pid) ORDER BY T.CREATEDATE ASC"; List productList = new List(); InjectionRecorder re = new InjectionRecorder(); InjectionRecorder re2 = new InjectionRecorder(); using (IDataSession session = AppDataFactory.CreateMainSession()) { productList = session.GetList(sql, new List().ToArray()).ToList(); re = session.Get(new InjectionRecorder() { PID = "9b9856cb-928a-479e-a9e8-59602663c001" }); re2 = session.Get(new InjectionRecorder() { PID = "3316acd7-a9d2-438d-ac95-14939963e881" }); } foreach (var p in productList) { ProductInjection pi = new ProductInjection(); pi.PID = Guid.NewGuid().ToString(); pi.IPID = re.PID; pi.MPPID = p.PID; pi.MATERIALNAME = re.MATERIALNAME; pi.MATERIALCODE = re.MATERIALCODE; pi.MATERIALTYPE = "1"; pi.MATERIALBATCH = re.MATERIALBATCH; pi.INJECTIONINDEX = re.INJECTIONINDEX; pi.INJECTIONTERMINAL = re.INJECTIONTERMINAL; pi.CREATEDATE = p.CREATEDATE; pi.UPDATEDATE = p.CREATEDATE; pi.PROCESSTYPE = "."; //pi.USEDWEIGHT = Convert.ToDecimal(0.66); //re.USEDWEIGHTSUM += Convert.ToDecimal(0.66); ProductInjection pi2 = new ProductInjection(); pi2.PID = Guid.NewGuid().ToString(); pi2.IPID = re2.PID; pi2.MPPID = p.PID; pi2.MATERIALNAME = re2.MATERIALNAME; pi2.MATERIALCODE = re2.MATERIALCODE; pi2.MATERIALTYPE = "1"; pi2.MATERIALBATCH = re2.MATERIALBATCH; pi2.INJECTIONINDEX = re2.INJECTIONINDEX; pi2.INJECTIONTERMINAL = re2.INJECTIONTERMINAL; pi2.CREATEDATE = p.CREATEDATE; pi2.UPDATEDATE = p.CREATEDATE; pi2.PROCESSTYPE = "."; Console.WriteLine(p.PRODUCTCODE); using (IDataSession session = AppDataFactory.CreateMainSession()) { session.Insert(pi); session.Insert(pi2); } } } } }