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.
224 lines
8.4 KiB
224 lines
8.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using QMAPP.BLL;
|
|
using QMAPP.Entity;
|
|
using QMAPP.FJC.BLL.FIS;
|
|
using QMAPP.FJC.DAL.FIS;
|
|
using QMAPP.FJC.DAL.MesB9;
|
|
using QMAPP.FJC.Entity;
|
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
|
using QMAPP.FJC.Entity.FIS;
|
|
using QMAPP.FJC.Entity.MesB9;
|
|
using QMFrameWork.Data;
|
|
using QMFrameWork.Log;
|
|
|
|
namespace QMAPP.FJC.BLL.MesB9
|
|
{
|
|
public class MesB9BLL : BaseBLL
|
|
{
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <returns>全部数据</returns>
|
|
public List<MesB9Entity> GetAllList()
|
|
{
|
|
try
|
|
{
|
|
return new MesB9DAL().GetList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取Mes_B9表错误!" });
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns>更新行数</returns>
|
|
public DataResult<int> Update(MesB9Entity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>
|
|
{
|
|
IsSuccess = true,
|
|
Msg = Resource.MsgSuccess
|
|
};
|
|
try
|
|
{
|
|
result.Result = new MesB9DAL().Update(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "更新Mes_B9表异常!" });
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
//执行task程序
|
|
public void SelectMesInsertPPtable()
|
|
{
|
|
//获取Mes_B9表数据
|
|
var mesB9BllList = new MesB9DAL().GetList();
|
|
//获取Mes_B9表数据
|
|
var mesB9M110BllList = new MesB9M110DAL().GetList();
|
|
|
|
if (mesB9BllList != null && mesB9BllList.Count>0)
|
|
{
|
|
foreach (var item in mesB9BllList)
|
|
{
|
|
using (
|
|
IDataSession session = AppDataFactory.CreateMainSession(),
|
|
sessionSelect = AppDataFactory.CreateSession("maindbSelect"))
|
|
{
|
|
try
|
|
{
|
|
//FISOrderDAL fisOrderDal = new FISOrderDAL {BaseSession = session};
|
|
//MesB9DAL mesB9Dal = new MesB9DAL {BaseSession = sessionSelect};
|
|
var ds = item.m100dtm + "00";
|
|
FISOrder fisOrder = new FISOrder
|
|
{
|
|
PID = Guid.NewGuid().ToString(),
|
|
VWSEQ = item.seq,
|
|
KIN = item.kin,
|
|
VIN = item.vin,
|
|
ORDER_NO = "IPFIS" + item.m100dtm + item.seq.Substring(item.seq.Length-4),
|
|
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"),
|
|
PRODNO = item.ProdNo,
|
|
LINENO = item.assemblyline,
|
|
CREATETIME = DateTime.Now,
|
|
SCANSTATE = "0"
|
|
};
|
|
//查询是否存在数据
|
|
var fisOrderNew = new FISOrderDAL().FISOrderIsNull(fisOrder);
|
|
// 开始事务
|
|
session.OpenTs();
|
|
sessionSelect.OpenTs();
|
|
if (fisOrderNew != null)
|
|
{
|
|
//更新之前m110存进来的数据
|
|
fisOrderNew[0].M100_ONLINEDATE = fisOrder.M100_ONLINEDATE;
|
|
session.Update(fisOrderNew);
|
|
}
|
|
else
|
|
{
|
|
//插入T_PP_FISORDER表
|
|
fisOrder.M110_ONLINEDATE = fisOrder.M100_ONLINEDATE;
|
|
session.Insert(fisOrder);
|
|
}
|
|
|
|
//更新Mes_B9表
|
|
item.ReadFlag = 1;
|
|
sessionSelect.Update(item);
|
|
|
|
// 事务提交
|
|
session.CommitTs();
|
|
sessionSelect.CommitTs();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
session.RollbackTs();
|
|
sessionSelect.RollbackTs();
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (mesB9M110BllList != null && mesB9M110BllList.Count > 0)
|
|
{
|
|
foreach (var item in mesB9M110BllList)
|
|
{
|
|
using (
|
|
IDataSession session = AppDataFactory.CreateMainSession(),
|
|
sessionSelect = AppDataFactory.CreateSession("maindbSelect"))
|
|
{
|
|
try
|
|
{
|
|
//FISOrderDAL fisOrderDal = new FISOrderDAL {BaseSession = session};
|
|
//MesB9DAL mesB9Dal = new MesB9DAL {BaseSession = sessionSelect};
|
|
var ds = item.m110dtm + "00";
|
|
FISOrder fisOrder = new FISOrder
|
|
{
|
|
PID = Guid.NewGuid().ToString(),
|
|
VWSEQ = item.seq,
|
|
KIN = item.kin,
|
|
VIN = item.vin,
|
|
ORDER_NO = "IPFIS" + item.m110dtm + item.seq.Substring(item.seq.Length - 4),
|
|
M110_ONLINEDATE =
|
|
DateTime.Parse(ds.Substring(0, 4) + "-" + ds.Substring(4, 2) + "-" +
|
|
ds.Substring(6, 2) +
|
|
" " +
|
|
ds.Substring(8, 2) + ":" + ds.Substring(10, 2) + ":00"),
|
|
PRODNO = item.ProdNo,
|
|
LINENO = item.assemblyline,
|
|
CREATETIME = DateTime.Now,
|
|
SCANSTATE = "0"
|
|
};
|
|
//查询是否存在数据
|
|
var fisOrderNew = new FISOrderDAL().FISOrderIsNull(fisOrder);
|
|
// 开始事务
|
|
session.OpenTs();
|
|
sessionSelect.OpenTs();
|
|
if (fisOrderNew != null)
|
|
{
|
|
//更新之前m110存进来的数据
|
|
fisOrderNew[0].M110_ONLINEDATE = fisOrder.M110_ONLINEDATE;
|
|
session.Update(fisOrderNew);
|
|
}
|
|
else
|
|
{
|
|
//插入T_PP_FISORDER表
|
|
fisOrder.M100_ONLINEDATE = fisOrder.M110_ONLINEDATE;
|
|
session.Insert(fisOrder);
|
|
}
|
|
|
|
//更新Mes_B9表
|
|
item.ReadFlag = 1;
|
|
sessionSelect.Update(item);
|
|
|
|
// 事务提交
|
|
session.CommitTs();
|
|
sessionSelect.CommitTs();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
session.RollbackTs();
|
|
sessionSelect.RollbackTs();
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|