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.
131 lines
5.4 KiB
131 lines
5.4 KiB
4 years ago
|
using System;
|
||
|
using System.ServiceProcess;
|
||
|
using QMAPP.FJC.BLL.FIS;
|
||
|
using QMAPP.FJC.BLL.MesB9;
|
||
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
||
|
using QMAPP.FJC.Entity.FIS;
|
||
|
|
||
|
namespace DbMesB4Service
|
||
|
{
|
||
|
partial class AutoDbCopyService : ServiceBase
|
||
|
{
|
||
|
|
||
|
private int timerIntno = 60000;
|
||
|
|
||
|
public AutoDbCopyService()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
timer.Interval = timerIntno;
|
||
|
timer.Enabled = true;
|
||
|
}
|
||
|
|
||
|
protected override void OnStart(string[] args)
|
||
|
{
|
||
|
// TODO: 在此处添加代码以启动服务。
|
||
|
|
||
|
}
|
||
|
|
||
|
protected override void OnStop()
|
||
|
{
|
||
|
// TODO: 在此处添加代码以执行停止服务所需的关闭操作。
|
||
|
|
||
|
QMFrameWork.Log.LogManager.LogHelper.Info(
|
||
|
new QMFrameWork.Log.LogInfo { ClientIP = "localhost", UserName = "admin", Info = "DbMesB4Service服务停止" });
|
||
|
|
||
|
}
|
||
|
|
||
|
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
lock (this)
|
||
|
{
|
||
|
// TODO: 在此处添加代码以启动服务。
|
||
|
timer.Enabled = false;
|
||
|
//获取Mes_B4表数据
|
||
|
MesB4BLL mesB4Bll = new MesB4BLL();
|
||
|
var MesB4BLLList = mesB4Bll.GetAllList();
|
||
|
if (MesB4BLLList != null)
|
||
|
foreach (var item in MesB4BLLList)
|
||
|
{
|
||
|
FISOrderBLL fisOrderBll = new FISOrderBLL();
|
||
|
FISOrder fisOrder = new FISOrder();
|
||
|
|
||
|
fisOrder.PID = Guid.NewGuid().ToString();
|
||
|
fisOrder.VWSEQ = item.seq;
|
||
|
fisOrder.KIN = item.kin;
|
||
|
fisOrder.VIN = item.vin;
|
||
|
fisOrder.ORDER_NO = item.m100dtm;
|
||
|
var ds = item.m100dtm + "00";
|
||
|
fisOrder.M100_ONLINEDATE =
|
||
|
DateTime.Parse(ds.Substring(0, 4) + "-" + ds.Substring(4, 2) + "-" + ds.Substring(6, 2) + " " +
|
||
|
ds.Substring(8, 2) + ":" + ds.Substring(10, 2) + ":00");
|
||
|
fisOrder.LINENO = item.assemblyline;
|
||
|
fisOrder.CREATETIME=DateTime.Now;
|
||
|
fisOrder.SCANSTATE = "0";
|
||
|
|
||
|
//插入T_PP_FISORDER表(因为Mes_B4表里有4个ProdNo,所以要插入4条记录)
|
||
|
fisOrder.PRODNO = item.ProdNo1;
|
||
|
fisOrderBll.Insert(fisOrder);
|
||
|
|
||
|
fisOrder.PID = Guid.NewGuid().ToString();
|
||
|
fisOrder.PRODNO = item.ProdNo2;
|
||
|
fisOrderBll.Insert(fisOrder);
|
||
|
|
||
|
fisOrder.PID = Guid.NewGuid().ToString();
|
||
|
fisOrder.PRODNO = item.ProdNo3;
|
||
|
fisOrderBll.Insert(fisOrder);
|
||
|
|
||
|
fisOrder.PID = Guid.NewGuid().ToString();
|
||
|
fisOrder.PRODNO = item.ProdNo4;
|
||
|
fisOrderBll.Insert(fisOrder);
|
||
|
|
||
|
OrderPlanBLL orderPlanBll = new OrderPlanBLL();
|
||
|
OrderPlan orderPlan = new OrderPlan();
|
||
|
|
||
|
orderPlan.PID = Guid.NewGuid().ToString();
|
||
|
orderPlan.PLAN_NO = fisOrder.ORDER_NO;
|
||
|
orderPlan.PLAN_SEQ = fisOrder.VWSEQ;
|
||
|
orderPlan.PLAN_STATE = "0";
|
||
|
orderPlan.QTY = 1;
|
||
|
orderPlan.COMPLETE_QTY = 0;
|
||
|
orderPlan.PLAN_DATE=DateTime.Now;
|
||
|
orderPlan.PLANSOURCE = "0";
|
||
|
orderPlan.PRODUCEREQUIRE = "1";
|
||
|
|
||
|
//插入T_PP_ORDERPLAN表,T_PP_WORKORDER表.(因为Mes_B4表里有4个ProdNo,所以要插入4条记录)
|
||
|
orderPlan.MATERIAL_CODE = item.ProdNo1;
|
||
|
orderPlanBll.InsertOrderPlanAndWorkOrder(orderPlan,null);
|
||
|
|
||
|
orderPlan.PID = Guid.NewGuid().ToString();
|
||
|
orderPlan.MATERIAL_CODE = item.ProdNo2;
|
||
|
orderPlanBll.InsertOrderPlanAndWorkOrder(orderPlan,null);
|
||
|
|
||
|
orderPlan.PID = Guid.NewGuid().ToString();
|
||
|
orderPlan.MATERIAL_CODE = item.ProdNo3;
|
||
|
orderPlanBll.InsertOrderPlanAndWorkOrder(orderPlan,null);
|
||
|
|
||
|
orderPlan.PID = Guid.NewGuid().ToString();
|
||
|
orderPlan.MATERIAL_CODE = item.ProdNo4;
|
||
|
orderPlanBll.InsertOrderPlanAndWorkOrder(orderPlan,null);
|
||
|
|
||
|
//跟新Mes_B9表
|
||
|
item.ReadFlag = 1;
|
||
|
mesB4Bll.Update(item);
|
||
|
}
|
||
|
|
||
|
timer.Enabled = true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
timer.Enabled = true;
|
||
|
QMFrameWork.Log.LogManager.LogHelper.Error(
|
||
|
new QMFrameWork.Log.LogInfo { ClientIP = "localhost", UserName = "admin", Info = "DbMesB4Service服务失败:", ErrorInfo = ex });
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|