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 { /// /// 获取列表 /// /// 全部数据 public List GetAllList() { try { return new MesB9DAL().GetList(); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取Mes_B9表错误!" }); throw; } } /// /// 更新信息 /// /// /// 更新行数 public DataResult Update(MesB9Entity model) { DataResult result = new DataResult { 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; } } } } } } }