using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMFrameWork.Data; using QMAPP.FJC.Entity.ProcessParameter; using QMAPP.FJC.Entity.Operation; using QMFrameWork.Common.Util; namespace EQUIPINTERFACETEST.Deal { public class SkinCutDeal { //放行的补充加工参数 public void InsertParameter() { List sampleListParameter = new List(); string sampleParameterSql = "select * from t_aw_burnparametersample"; List insertListParameter = new List(); string mosql = @"select * from T_AW_MAINOPERATION mo where mo.createdate>'2016-9-1 00:00:00' and mo.createdate<'2016-10-1 00:00:00' and mo.PRODUCTCODESTR='.' and not exists(select 1 from T_AW_BURNPARAMETER t where t.MOID=mo.PID)"; List molist = new List(); using (IDataSession session = AppDataFactory.CreateMainSession()) { sampleListParameter = session.GetList(sampleParameterSql, new List().ToArray()).ToList(); molist = session.GetList(mosql, new List().ToArray()).ToList(); } int index = 0; foreach (var mo in molist) { index++; if (index == 8) { index = 0; } BurnParameter bpindex = sampleListParameter[index]; //mo.OPERATESTATE = "1"; //mo.PRODUCTCODESTR = "."; BurnParameter bp = new BurnParameter(); bp = BindHelper.CopyToModel(bpindex, false); bp.PID = Guid.NewGuid().ToString(); bp.PDID = mo.PDID; bp.MOID = mo.PID; bp.PRODUCTCODE = mo.PRODUCTCODE; bp.CREATEDATE = mo.OPERATEDDATE; bp.WORKTIME = mo.OPERATEDDATE.AddMinutes(-3).ToString("HH:mm"); bp.INDENTITYCODE = "."; insertListParameter.Add(bp); } using (IDataSession session = AppDataFactory.CreateMainSession()) { int i = 0; foreach (var bp in insertListParameter) { i++; session.Insert(bp); Console.WriteLine(bp.PRODUCTCODE + " - " + i.ToString()); WriteLog.Write(bp.PRODUCTCODE + " - " + i.ToString()); } } } //跳序的补充加工参数 public void InsertProcessParameter() { List sampleListParameter = new List(); string sampleParameterSql = "select * from t_aw_burnparametersample"; List insertListParameter = new List(); List productList = new List(); string sql = @"select * from t_aw_product t where 1=1 and not exists(select 1 from T_AW_MAINOPERATION b where b.processtype='6' and b.pdid=t.pid) and t.PRODUCTTYPE='0' and t.USINGSTATE='2' --and t.currentprocess='9' and t.createdate>'2016-12-1 00:00:00' and t.createdate<'2017-1-1 00:00:00' order by t.createdate asc "; List molist = new List(); MainOperation mosample = new MainOperation(); mosample.PID = "0b602d6c-3d56-4b01-91fc-5c420f6d591c"; using (IDataSession session = AppDataFactory.CreateMainSession()) { sampleListParameter = session.GetList(sampleParameterSql, new List().ToArray()).ToList(); productList = session.GetList(sql, new List().ToArray()).ToList(); mosample = session.Get(mosample); } foreach (var p in productList) { MainOperation mo = new MainOperation(); mo = BindHelper.CopyToModel(mosample, false); mo.PID = Guid.NewGuid().ToString(); mo.PDID = p.PID; mo.PRODUCTCODE = p.PRODUCTCODE; mo.OPERATEDDATE = p.CREATEDATE.AddMinutes(30); mo.CREATEDATE = mo.OPERATEDDATE.AddSeconds(-55); mo.UPDATEDATE = mo.OPERATEDDATE; mo.PRODUCTCODESTR = "."; molist.Add(mo); BurnParameter bp = new BurnParameter(); int index = new Random().Next(1,8); BurnParameter bpindex = sampleListParameter[index]; bp = BindHelper.CopyToModel(bpindex, false); bp.PID = Guid.NewGuid().ToString(); bp.PDID = mo.PDID; bp.MOID = mo.PID; bp.PRODUCTCODE = mo.PRODUCTCODE; bp.CREATEDATE = mo.OPERATEDDATE; bp.WORKTIME = mo.OPERATEDDATE.AddMinutes(-3).ToString("HH:mm"); bp.INDENTITYCODE = "."; insertListParameter.Add(bp); } using (IDataSession session = AppDataFactory.CreateMainSession()) { int i = 0; foreach (var mo in molist) { i++; session.Insert(mo); Console.WriteLine(mo.PRODUCTCODE + " - " + i.ToString()); WriteLog.Write(mo.PRODUCTCODE + " - " + i.ToString()); } int j = 0; foreach (var bp in insertListParameter) { j++; session.Insert(bp); Console.WriteLine(j.ToString()); } } } } }