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.
94 lines
2.8 KiB
94 lines
2.8 KiB
4 years ago
|
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 QMFrameWork.Common.Util;
|
||
|
|
||
|
namespace EQUIPINTERFACETEST.Deal
|
||
|
{
|
||
|
public class CastDeal
|
||
|
{
|
||
|
|
||
|
public void InsertParameter()
|
||
|
{
|
||
|
string mosql = @"select * from T_AW_MAINOPERATION mo where
|
||
|
mo.createdate>'2016-7-23 00:00:00'
|
||
|
and mo.createdate<'2016-7-24 00:00:00'
|
||
|
and mo.PROCESSTYPE='9'
|
||
|
and mo.OPERATESTATE='2'
|
||
|
";
|
||
|
|
||
|
|
||
|
List<CastingParameter> sampleListParameter = new List<CastingParameter>();
|
||
|
string sampleParameterSql = "select top 100 * from T_AW_CASTINGPARAMETERSAMPLE";
|
||
|
|
||
|
List<MainOperation> molist = new List<MainOperation>();
|
||
|
|
||
|
List<CastingParameter> insertListParameter = new List<CastingParameter>();
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
sampleListParameter = session.GetList<CastingParameter>(sampleParameterSql, new List<DataParameter>().ToArray()).ToList<CastingParameter>();
|
||
|
|
||
|
molist = session.GetList<MainOperation>(mosql, new List<DataParameter>().ToArray()).ToList<MainOperation>();
|
||
|
|
||
|
}
|
||
|
int index = 0;
|
||
|
foreach (var mo in molist)
|
||
|
{
|
||
|
mo.OPERATESTATE = "1";
|
||
|
mo.PRODUCTCODESTR += ".";
|
||
|
|
||
|
index++;
|
||
|
|
||
|
if (index == 8)
|
||
|
{
|
||
|
index = 0;
|
||
|
}
|
||
|
|
||
|
CastingParameter bpindex = sampleListParameter[index];
|
||
|
|
||
|
CastingParameter bp = new CastingParameter();
|
||
|
|
||
|
bp = BindHelper.CopyToModel<CastingParameter, CastingParameter>(bpindex, false);
|
||
|
|
||
|
bp.PID = Guid.NewGuid().ToString();
|
||
|
bp.PDID = mo.PDID;
|
||
|
bp.MOID = mo.PID;
|
||
|
bp.PRODUCTCODE = mo.PRODUCTCODE;
|
||
|
bp.CREATEDATE = mo.OPERATEDDATE;
|
||
|
|
||
|
insertListParameter.Add(bp);
|
||
|
|
||
|
}
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
|
||
|
int j = 0;
|
||
|
foreach (var mo in molist)
|
||
|
{
|
||
|
j++;
|
||
|
session.Update<MainOperation>(mo);
|
||
|
Console.WriteLine(mo.PRODUCTCODE + " - " + j.ToString());
|
||
|
WriteLog.Write(mo.PRODUCTCODE + " - " + j.ToString());
|
||
|
}
|
||
|
|
||
|
int i = 0;
|
||
|
foreach (var bp in insertListParameter)
|
||
|
{
|
||
|
i++;
|
||
|
session.Insert<CastingParameter>(bp);
|
||
|
Console.WriteLine(bp.PRODUCTCODE + " - " + i.ToString());
|
||
|
WriteLog.Write(bp.PRODUCTCODE + " - " + i.ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|