天津投入产出系统后端
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.
 
 
 
 
 
 

156 lines
5.9 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;
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<Product> productList = new List<Product>();
List<BurnParameter> burnList = new List<BurnParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
productList = session.GetList<Product>(sql, new List<DataParameter>().ToArray()).ToList<Product>();
burnList = session.GetList<BurnParameter>(sqlparameter, new List<DataParameter>().ToArray()).ToList<BurnParameter>();
}
List<MainOperation> moList = new List<MainOperation>();
List<BurnParameter> addBurnList = new List<BurnParameter>();
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<MainOperation>(mo);
Console.WriteLine(burnPara.PRODUCTCODE);
session.Insert<BurnParameter>(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<Product> productList = new List<Product>();
InjectionRecorder re = new InjectionRecorder();
InjectionRecorder re2 = new InjectionRecorder();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
productList = session.GetList<Product>(sql, new List<DataParameter>().ToArray()).ToList<Product>();
re = session.Get<InjectionRecorder>(new InjectionRecorder() {
PID = "9b9856cb-928a-479e-a9e8-59602663c001"
});
re2 = session.Get<InjectionRecorder>(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<ProductInjection>(pi);
session.Insert<ProductInjection>(pi2);
}
}
}
}
}