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

161 lines
5.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
using QMFrameWork.Data;
using System.Data;
using QMFrameWork.Common.Util;
namespace EQUIPINTERFACETEST.Deal
{
public class ZczpDeal
{
public void InsertParameter()
{
string sql = @"select top 400 * from T_AW_PRINTCODE p
where 1=1
and PRODUCTCODE LIKE '17%'
and iscomplete='0'
AND CREATETIME>'2017-01-10 00:00:00'";
List<PrintCode> pcList = new List<PrintCode>();
Product leftPro = new Product();
string left = @"select * from t_aw_product where productcode='B9H1201701056PS010'";
Product rightPro = new Product();
string right = @"select * from t_aw_product where productcode='B9I1201701066PS001'";
List<Main> mainList = new List<Main>();
string mainSql = @"select * from t_aw_main where
exists(select 1 from T_AW_PRINTCODE p
where 1=1
and EPIDERMISCODE=p.PRODUCTCODE
and PRODUCTCODE LIKE '17%'
and iscomplete='0'
AND CREATETIME>'2017-01-10 00:00:00')";
List<MainOperation> molist = new List<MainOperation>();
MainOperation mo = new MainOperation() { PID = "c99a5036-e36f-488a-a5d8-80833083c343" };
DataTable dt = new DataTable();
List<MainProduct> mpList = new List<MainProduct>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
pcList = session.GetList<PrintCode>(sql, new List<DataParameter>().ToArray()).ToList<PrintCode>();
leftPro = session.Get<Product>(left, new List<DataParameter>().ToArray());
rightPro = session.Get<Product>(right, new List<DataParameter>().ToArray());
mainList = session.GetList<Main>(mainSql, new List<DataParameter>().ToArray()).ToList<Main>();
mo = session.Get<MainOperation>(mo);
}
List<Main> updateList = new List<Main>();
foreach (PrintCode pc in pcList)
{
if (updateList.Count(o => o.EPIDERMISCODE == pc.PRODUCTCODE) > 0)
{
continue;
}
if (mainList.Count(o => o.EPIDERMISCODE == pc.PRODUCTCODE) == 0)
{
continue;
}
pc.ISCOMPLETE = 1;
Main m = mainList.First(o => o.EPIDERMISCODE == pc.PRODUCTCODE);
m.MAINCODE = pc.MAINCODE;
m.PROCESSSTATE = "2";
m.CURRENTPROCESS = "16";
m.COMPLETEFLAG = "1";
m.COMPLETETIME = pc.CREATETIME;
m.UPDATEDATE = m.COMPLETETIME;
updateList.Add(m);
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;
mi.UPDATEDATE = m.UPDATEDATE;
mi.PRODUCTCODESTR = "B9H1201701056PS010:B9I1201701066PS001.";
molist.Add(mi);
MainProduct mp = new MainProduct();
mp.PID = Guid.NewGuid().ToString();
mp.MID = m.PID;
mp.PDID = leftPro.PID;
mp.COUNT = 1;
mp.MOID = mi.PID;
mp.CREATEUSER = "471c7578-3474-4804-92b2-34673516bf2b";
mp.CREATEDATE = mi.CREATEDATE;
mp.UPDATEDATE = mi.CREATEDATE;
mpList.Add(mp);
MainProduct mp2 = new MainProduct();
mp2.PID = Guid.NewGuid().ToString();
mp2.MID = m.PID;
mp2.PDID = rightPro.PID;
mp2.COUNT = 1;
mp2.MOID = mi.PID;
mp2.CREATEUSER = "471c7578-3474-4804-92b2-34673516bf2b";
mp2.CREATEDATE = mi.CREATEDATE;
mp2.UPDATEDATE = mi.CREATEDATE;
mpList.Add(mp2);
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
int a = 0;
foreach (PrintCode pc in pcList)
{
a++;
session.Update<PrintCode>(pc);
Console.WriteLine(pc.PRODUCTCODE + " - " + a.ToString());
WriteLog.Write(pc.PRODUCTCODE + " - " + a.ToString());
}
int b = 0;
foreach (var mi in updateList)
{
b++;
session.Update<Main>(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);
}
}
}
}
}