|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
|
|
|
|
|
{
|
|
|
|
|
public class DownToDatabase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public DownToDatabase() { }
|
|
|
|
|
|
|
|
|
|
public DownToDatabase(int id)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计划Id
|
|
|
|
|
LjPlanningEntity ljPlanningEntity = FreeSqlUnit.Instance.Select<LjPlanningEntity>().
|
|
|
|
|
Where(x => x.Id == id).ToOne();
|
|
|
|
|
|
|
|
|
|
// 配方
|
|
|
|
|
LjFormulaEntity ljFormulaEntity = FreeSqlUnit.Instance.Select<LjFormulaEntity>().Where(x => x.Id ==
|
|
|
|
|
ljPlanningEntity.FormulaId).ToOne();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//配方详情
|
|
|
|
|
|
|
|
|
|
List<LjFormulaDetailEntity> ljFormulaDetailEntity =
|
|
|
|
|
FreeSqlUnit.Instance.Select<LjFormulaDetailEntity>().
|
|
|
|
|
Where(x => x.FormulaId == ljFormulaEntity.Id).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Delete<LjFormulaDownEntity>().
|
|
|
|
|
Where(x => x.PlanId == ljPlanningEntity.Id
|
|
|
|
|
&& x.FormulaId == ljFormulaEntity.Id).ExecuteDeleted();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Delete<LjFormulaDetailDownEntity>()
|
|
|
|
|
.Where(x => x.PlanId == ljPlanningEntity.Id
|
|
|
|
|
&& x.FormulaId == ljFormulaEntity.Id).ExecuteDeleted();
|
|
|
|
|
|
|
|
|
|
LjFormulaDownEntity ljFormulaDownEntity = new LjFormulaDownEntity()
|
|
|
|
|
{
|
|
|
|
|
CbSiloC = ljFormulaEntity.CbSiloC,
|
|
|
|
|
CbSiloH = ljFormulaEntity.CbSiloH,
|
|
|
|
|
CbWeterH = ljFormulaEntity.CbWeterH,
|
|
|
|
|
CreateTime = ljFormulaEntity.CreateTime,
|
|
|
|
|
FormulaId = ljFormulaEntity.Id,
|
|
|
|
|
FormulaName = ljFormulaEntity.FormulaName,
|
|
|
|
|
FormulaNo = ljFormulaEntity.FormulaNo,
|
|
|
|
|
FormulaVersion = ljFormulaEntity.FormulaVersion,
|
|
|
|
|
IsEnable = ljFormulaEntity.IsEnable,
|
|
|
|
|
PlanId = ljPlanningEntity.Id,
|
|
|
|
|
RecipeTypeId = ljFormulaEntity.RecipeTypeId,
|
|
|
|
|
RecipeTypeName = ljFormulaEntity.RecipeTypeName,
|
|
|
|
|
Status = ljFormulaEntity.Status,
|
|
|
|
|
Unit = ljFormulaEntity.Unit,
|
|
|
|
|
UpdateTime = ljFormulaEntity.UpdateTime
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(ljFormulaDownEntity).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
List<LjFormulaDetailDownEntity> ljFormulaDetailDownEntity = new List<LjFormulaDetailDownEntity>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (LjFormulaDetailEntity Entity in ljFormulaDetailEntity)
|
|
|
|
|
{
|
|
|
|
|
LjFormulaDetailDownEntity singleEntity = new LjFormulaDetailDownEntity()
|
|
|
|
|
{
|
|
|
|
|
ActionCode = Entity.ActionCode,
|
|
|
|
|
ActionId = Entity.ActionId,
|
|
|
|
|
ActionName = Entity.ActionName,
|
|
|
|
|
BinNo = Entity.BinNo,
|
|
|
|
|
CbCopyC = Entity.CbCopyC,
|
|
|
|
|
CbCopyH = Entity.CbCopyH,
|
|
|
|
|
CpSiloH = Entity.CpSiloH,
|
|
|
|
|
|
|
|
|
|
FormulaId = Entity.FormulaId,
|
|
|
|
|
PlanId = ljPlanningEntity.Id,
|
|
|
|
|
|
|
|
|
|
FormulaType = Entity.FormulaType,
|
|
|
|
|
Machine = Entity.Machine,
|
|
|
|
|
MachineType = Entity.MachineType,
|
|
|
|
|
MId = Entity.MId,
|
|
|
|
|
MName = Entity.MName,
|
|
|
|
|
SetTolerance = Entity.SetTolerance,
|
|
|
|
|
SetValue = Entity.SetValue,
|
|
|
|
|
Speed = Entity.Speed,
|
|
|
|
|
StockMaterialId = Entity.StockMaterialId,
|
|
|
|
|
Temp = Entity.Temp,
|
|
|
|
|
TimeInfo = Entity.TimeInfo,
|
|
|
|
|
Tolerance = Entity.Tolerance,
|
|
|
|
|
Weight = Entity.Weight
|
|
|
|
|
};
|
|
|
|
|
ljFormulaDetailDownEntity.Add(singleEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(ljFormulaDetailDownEntity).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|