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

175 lines
6.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
using QMFrameWork.Data;
using QMFrameWork.Common.Util;
using QMAPP.FJC.Entity.ProcessParameter;
namespace EQUIPINTERFACETEST.Deal
{
public class WeldDeal
{
public void InsertParameter()
{
List<Main> mainList = new List<Main>();
string mainSql = @"select top 400 * from T_AW_MAIN m where CREATEDATE>'2017-01-1 13:42:12.047' and COMPLETEFLAG='1'
and not exists (select 1 from T_AW_MAINOPERATION mo where
mo.createdate>'2017-01-1 13:42:12.047' and mo.PDID=m.PID and PROCESSTYPE='15')";
List<Product> b9bList = new List<Product>();
string b9bSql = @"select * from T_AW_PRODUCT t where
t.CREATEDATE>'2017-01-1 13:42:12.047' and t.CREATEDATE<'2017-01-9 13:42:12.047'
and t.USINGSTATE='0'
--and t.CURRENTPROCESS='15'
and t.PRODUCTTYPE='4' ";
List<Product> fjcList = new List<Product>();
string fjcSql = @"select * from T_AW_PRODUCT t where
t.CREATEDATE>'2016-12-1 13:42:12.047' and t.CREATEDATE<'2017-01-1 00:42:12.047'
and t.USINGSTATE='0'
--and t.CURRENTPROCESS='15'
and t.PRODUCTTYPE='2' ";
List<HotweldParameter> wildList = new List<HotweldParameter>();
string parameter = "select * from T_AW_HOTWELDPARAMETERSAMPLE";
MainOperation mo = new MainOperation() { PID = "0153ebac-98ed-44fc-8663-248844a50ab4" };
using (IDataSession session = AppDataFactory.CreateMainSession())
{
mainList = session.GetList<Main>(mainSql, new List<DataParameter>().ToArray()).ToList<Main>();
b9bList = session.GetList<Product>(b9bSql, new List<DataParameter>().ToArray()).ToList<Product>();
fjcList = session.GetList<Product>(fjcSql, new List<DataParameter>().ToArray()).ToList<Product>();
mo = session.Get<MainOperation>(mo);
wildList = session.GetList<HotweldParameter>(parameter, new List<DataParameter>().ToArray()).ToList<HotweldParameter>();
}
List<MainProduct> mpList = new List<MainProduct>();
List<MainOperation> molist = new List<MainOperation>();
List<Product> productList = new List<Product>();
List<HotweldParameter> intwildList = new List<HotweldParameter>();
int f = 0;
for (int n = 0; n < mainList.Count;n++ )
{
f++;
if (f == 6)
{
f = 0;
}
HotweldParameter hp = wildList[f];
Main m = mainList[n];
Product fjc = fjcList[n];
fjc.USINGCOUNT = 1;
fjc.USINGSTATE = "2";
fjc.CURRENTPROCESS = "15";
fjc.UPDATEDATE = m.UPDATEDATE.AddSeconds(-20);
productList.Add(fjc);
Product b9b = b9bList[n];
b9b.USINGCOUNT = 1;
b9b.USINGSTATE = "2";
b9b.CURRENTPROCESS = "15";
b9b.UPDATEDATE = m.UPDATEDATE.AddSeconds(-20);
productList.Add(b9b);
MainOperation mi = BindHelper.CopyToModel<MainOperation, MainOperation>(mo, false);
mi.PID = Guid.NewGuid().ToString();
mi.PDID = m.PID;
mi.PRODUCTCODE = m.EPIDERMISCODE;
mi.OPERATEDDATE = m.UPDATEDATE;
mi.CREATEDATE = m.UPDATEDATE.AddSeconds(-80);
mi.UPDATEDATE = m.UPDATEDATE.AddSeconds(-20);
mi.PRODUCTCODESTR = fjc.PRODUCTCODE + ":" + b9b.PRODUCTCODE + ".";
molist.Add(mi);
MainProduct mp = new MainProduct();
mp.PID = Guid.NewGuid().ToString();
mp.MID = m.PID;
mp.PDID = fjc.PID;
mp.COUNT = 1;
mp.MOID = mi.PID;
mp.CREATEUSER = "471c7578-3474-4804-92b2-34673516bf2b";
mp.CREATEDATE = m.UPDATEDATE.AddSeconds(-80);
mp.UPDATEDATE = m.UPDATEDATE.AddSeconds(-80);
mpList.Add(mp);
MainProduct mp2 = new MainProduct();
mp2.PID = Guid.NewGuid().ToString();
mp2.MID = m.PID;
mp2.PDID = b9b.PID;
mp2.COUNT = 1;
mp2.MOID = mi.PID;
mp2.CREATEUSER = "471c7578-3474-4804-92b2-34673516bf2b";
mp2.CREATEDATE = m.UPDATEDATE.AddSeconds(-80);
mp2.UPDATEDATE = m.UPDATEDATE.AddSeconds(-80);
mpList.Add(mp2);
HotweldParameter htp = BindHelper.CopyToModel<HotweldParameter, HotweldParameter>(hp, false);
htp.PID = Guid.NewGuid().ToString();
htp.PDID = mi.PDID;
htp.MOID = mi.PID;
htp.PRODUCTCODE = mi.PRODUCTCODE;
htp.CREATEDATE = mi.OPERATEDDATE;
htp.OPERATETIME = mi.OPERATEDDATE.AddSeconds(-71).ToString("HH:mm");
intwildList.Add(htp);
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
int a = 0;
foreach (var pc in productList)
{
a++;
session.Update<Product>(pc);
Console.WriteLine(pc.PRODUCTCODE + " - " + a.ToString());
WriteLog.Write(pc.PRODUCTCODE + " - " + a.ToString());
}
int b = 0;
foreach (var mi in intwildList)
{
b++;
session.Insert<HotweldParameter>(mi);
Console.WriteLine(mi.MAINCODE + " - " + b.ToString());
WriteLog.Write(mi.MAINCODE + " - " + b.ToString());
}
int c = 0;
foreach (var mp in molist)
{
c++;
session.Insert<MainOperation>(mp);
Console.WriteLine(mp.PRODUCTCODE + " - " + c.ToString());
WriteLog.Write(mp.PRODUCTCODE + " - " + c.ToString());
}
int d = 0;
foreach (var mp in mpList)
{
d++;
Console.WriteLine(d.ToString());
WriteLog.Write(d.ToString());
session.Insert<MainProduct>(mp);
}
}
}
}
}