天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.1 KiB

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;
namespace EQUIPINTERFACETEST
{
public class InsertCastingParameter
{
public void Insert()
{
string sql = @"select * from T_AW_MAINOPERATION t
where t.PROCESSTYPE='9' and t.OPERATEDDATE>'2016-05-26 00:00:00'
and t.OPERATESTATE='1' and not exists (select 1 from T_AW_CASTINGPARAMETER c where c.MOID=t.pid)";
string sql2 = @"
select * from T_AW_CASTINGPARAMETER t where t.createdate>'2016-06-20 14:39:39.160'
and t.createdate<'2016-06-20 16:39:39.160'";
List<CastingParameter> list2 = new List<CastingParameter>();
List<MainOperation> molist = new List<MainOperation>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
molist = session.GetList<MainOperation>(sql, new List<DataParameter>().ToArray()).ToList<MainOperation>();
list2 = session.GetList<CastingParameter>(sql2, new List<DataParameter>().ToArray()).ToList<CastingParameter>();
}
int index = 0;
List<CastingParameter> cplist = new List<CastingParameter>();
foreach (var mo in molist)
{
if (index == list2.Count - 1)
index = 0;
CastingParameter a = list2[index];
CastingParameter c = new CastingParameter();
c.PID = Guid.NewGuid().ToString();
c.PDID = mo.PDID;
c.PRODUCTCODE = mo.PRODUCTCODE;
c.MOID = mo.PID;
c.PRODUCTTYPE = "8";
c.MACHINENAME = "AUDIB9浇注设备";
c.MACHINECODDE = "1A-FB0004";
c.CREATEDATE = mo.UPDATEDATE;
if (mo.MOLDNUMBER.ToString() == "5")
{
c.MOULDNUMBER = 1;
}
else if (mo.MOLDNUMBER.ToString() == "1")
{
c.MOULDNUMBER = 2;
}
else
{
c.MOULDNUMBER = 4;
}
c.MAINCODE = "2";
//decimal flowValue = new Random().Next(3943, 3954);
c.FLOW = a.FLOW;
//decimal stressPercentValue = 6;
c.STRESSPERCENT = a.STRESSPERCENT;
//decimal mt1 = new Random().Next(271, 289);
c.METARIALTEMPRATURE = a.METARIALTEMPRATURE;
//decimal mt2 = new Random().Next(284, 293);
c.METARIALTEMPRATURETWO = a.METARIALTEMPRATURETWO;
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.Insert<CastingParameter>(c);
Console.WriteLine("Insert Complete");
}
index++;
}
}
}
}