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.
561 lines
18 KiB
561 lines
18 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMAPP.FJC.Entity.Equipment;
|
||
|
using QMAPP.Entity;
|
||
|
using QMFrameWork.Log;
|
||
|
using QMAPP.FJC.DAL.Equipment;
|
||
|
using QMAPP.FJC.Entity;
|
||
|
using QMAPP.BLL;
|
||
|
using QMFrameWork.Data;
|
||
|
using System.Data;
|
||
|
using QMAPP.FJC.BLL.Dict;
|
||
|
using QMAPP.FJC.DAL.Basic;
|
||
|
using QMAPP.FJC.Entity.Basic;
|
||
|
using QMAPP.FJC.Entity.MaximoDataDB;
|
||
|
using QMAPP.MD.Entity;
|
||
|
|
||
|
namespace QMAPP.FJC.BLL.Equipment
|
||
|
{
|
||
|
public class MouldBLL : BaseBLL
|
||
|
{
|
||
|
#region 获取信息
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public DataResult<Mould> Get(Mould model)
|
||
|
{
|
||
|
DataResult<Mould> result = new DataResult<Mould>();
|
||
|
try
|
||
|
{
|
||
|
result.Result = new MouldDAL().Get(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "模具信息逻辑层-获取信息!"
|
||
|
});
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
throw ex;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataResult<DataPage> GetList(Mould condition, DataPage page)
|
||
|
{
|
||
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
||
|
try
|
||
|
{
|
||
|
//获取模具信息列表
|
||
|
DataPage dataPage = new MouldDAL().GetList(condition, page);
|
||
|
List<Mould> list = page.Result as List<Mould>;
|
||
|
#region 显示类型
|
||
|
//处理字典信息
|
||
|
DictManageBLL dictMOULD_STATE = new DictManageBLL(DictKind.MOULD_STATE);
|
||
|
foreach (var info in list)
|
||
|
{
|
||
|
info.MOULD_STATE = dictMOULD_STATE.GetDictValue(info.MOULD_STATE);
|
||
|
}
|
||
|
#endregion
|
||
|
result.Result = dataPage;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "模具信息逻辑层-获取列表!"
|
||
|
});
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
throw ex;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <returns>全部集合</returns>
|
||
|
public List<Mould> GetAllList(Mould condition)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<Mould> list = new MouldDAL().GetAllList(condition);
|
||
|
return list;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
public List<Mould> GetMoulds()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<Mould> list = new MouldDAL().GetMoulds();
|
||
|
return list;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 信息是否重复
|
||
|
/// <summary>
|
||
|
/// 判断模具号是否存在
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public bool ExistsPlant(Mould model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new MouldDAL().ExistsMould(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 插入信息
|
||
|
/// <summary>
|
||
|
/// 插入信息(单表)
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public DataResult<int> Insert(Mould model)
|
||
|
{
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
//基本信息
|
||
|
model.PID = Guid.NewGuid().ToString();
|
||
|
model.CREATEUSER = this.LoginUser.UserID;
|
||
|
model.CREATEDATE = DateTime.Now;
|
||
|
model.UPDATEUSER = model.CREATEUSER;
|
||
|
model.UPDATEDATE = model.CREATEDATE;
|
||
|
MouldDAL cmdDAL = new MouldDAL();
|
||
|
try
|
||
|
{
|
||
|
if (ExistsPlant(model) == true)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.MaterielCodeIsHave;
|
||
|
return result;
|
||
|
}
|
||
|
result.Result = new MouldDAL().Insert(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "模具信息逻辑层-插入信息!"
|
||
|
});
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
throw ex;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 更新信息
|
||
|
/// <summary>
|
||
|
/// 更新信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>更新行数</returns>
|
||
|
public DataResult<int> Update(Mould model)
|
||
|
{
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
model.UPDATEUSER = this.LoginUser.UserID;
|
||
|
try
|
||
|
{
|
||
|
if (ExistsPlant(model) == true)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.MaterielCodeIsHave;
|
||
|
return result;
|
||
|
}
|
||
|
result.Result = new MouldDAL().Update(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "模具信息逻辑层-更新信息!"
|
||
|
});
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
throw ex;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 删除
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
public DataResult<int> Delete(string strs)
|
||
|
{
|
||
|
int count = 0;
|
||
|
string[] list = strs.Split(":".ToCharArray());
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
try
|
||
|
{
|
||
|
foreach (string str in list)
|
||
|
{
|
||
|
count += this.DeletePlant(new Mould { PID = str });
|
||
|
}
|
||
|
if (count == 0)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
return result;
|
||
|
}
|
||
|
result.Result = count;
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
public int DeletePlant(Mould model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
count = new MouldDAL().Delete(model);
|
||
|
return count;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取模具资料维护(分页)
|
||
|
/// <summary>
|
||
|
/// 获取模具资料维护列表(分页)
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataResult<DataPage> GetMouldData(MouldData condition, DataPage page)
|
||
|
{
|
||
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
||
|
try
|
||
|
{
|
||
|
|
||
|
DataPage dataPage = new MouldDAL().GetMouldData(condition, page);
|
||
|
|
||
|
result.Result = dataPage;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
return result;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 信息是否重复
|
||
|
/// <summary>
|
||
|
/// 判断模具资料是否存在
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public bool ExistsdataPlant(MouldData model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new MouldDAL().ExistsMouldData(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 判断模具资料名称是否存在
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public bool ExistsdatanamePlant(MouldData model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new MouldDAL().ExistsMouldnameData(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 模具资料维护保存
|
||
|
/// <summary>
|
||
|
/// 信息保存
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataResult<int> MouldDataSave(MouldData model)
|
||
|
{
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
MouldDAL mouldDal = new MouldDAL();
|
||
|
|
||
|
model.PID = Guid.NewGuid().ToString();
|
||
|
model.CREATEDATE = System.DateTime.Now;
|
||
|
model.CREATEUSER = this.LoginUser.UserID;
|
||
|
model.UPDATEUSER = this.LoginUser.UserID;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
//int i = mouldDal.InsertMouldData(model);
|
||
|
if (ExistsdataPlant(model) == true)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.MaterielCodeIsHave;
|
||
|
return result;
|
||
|
}
|
||
|
if (ExistsdatanamePlant(model) == true)
|
||
|
{
|
||
|
result.IsSuccess = true;
|
||
|
result.Msg = Resource.MaterielCodeIsHave;
|
||
|
return result;
|
||
|
}
|
||
|
//result.Result = new MouldDAL().InsertMouldData(model);
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
session.OpenCon();
|
||
|
int moulddatacount = mouldDal.InsertMouldData(model);
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
return result;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 模具资料维护删除
|
||
|
/// <summary>
|
||
|
/// 模具资料维护删除
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
public DataResult<int> MouldDataDelete(string selectKey, string MOULD_ID)
|
||
|
{
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
int deleteDataCount = 0;
|
||
|
MouldDAL mouldDAL = new MouldDAL();
|
||
|
string[] list = selectKey.Split(":".ToCharArray());
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
session.OpenTs();
|
||
|
mouldDAL.BaseSession = session;
|
||
|
foreach (string str in list)
|
||
|
{
|
||
|
deleteDataCount += mouldDAL.DeleteMouldData(new MouldData { PID = str, MOULD_ID = MOULD_ID });
|
||
|
}
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
session.RollbackTs();
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
return result;
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
|
||
|
#region 事物--设备合模次数同步到[MaximoDataDB].[dbo].[T_QT_MOULDCOUNTER]
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <returns>信息</returns>
|
||
|
public void selectMesMouldIntoMaximoMouldCounter()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//获取公司代码组织机构代码
|
||
|
var corp = new QMAPP.MD.DAL.CorpDAL().Get();
|
||
|
//获取所有模具
|
||
|
var moulds = new MouldDAL().GetMoulds();
|
||
|
//报告人
|
||
|
string INSPECTOR = System.Configuration.ConfigurationManager.AppSettings["INSPECTOR"];
|
||
|
//仪表编号
|
||
|
string METERNAME = System.Configuration.ConfigurationManager.AppSettings["METERNAME"];
|
||
|
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateSession("maindbMaximo"))
|
||
|
{
|
||
|
foreach (var mould in moulds)
|
||
|
{
|
||
|
var mc = new MounldCounter
|
||
|
{
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
Siteid = corp.Siteid,
|
||
|
Orgid = corp.Orgid,
|
||
|
ASSETNUM = mould.MOULD_CODE,
|
||
|
INSPECTOR = INSPECTOR,
|
||
|
METERNAME = METERNAME,
|
||
|
NEWREADING = mould.USAGECOUNT.ToString(),
|
||
|
NEWREADINGDATE = DateTime.Now
|
||
|
};
|
||
|
new MouldDAL().InsertMouldCounter(mc, session);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 事物--查询中间表T_QT_EQUIPMENTINFO 然后根据1 模具 ,0 设备比对Mould Machine两个表插入。
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <returns>信息</returns>
|
||
|
public void SelectEquipmentInfoInsertMouldMachine()
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
// 开始事务
|
||
|
session.OpenTs();
|
||
|
//获取中间表equipmentType=0 设备
|
||
|
var machines = new MouldDAL().GetSelectEquipmentInfo("0");
|
||
|
//全部设备
|
||
|
var machineList = new MachineInfoDAL().GetMachineInfos();
|
||
|
//获取中间表equipmentType=1 模具
|
||
|
var moulds = new MouldDAL().GetSelectEquipmentInfo("1");
|
||
|
//全部模具
|
||
|
var mouldList = new MouldDAL().GetMoulds();
|
||
|
//比对设备
|
||
|
var expMachines = machines.Where(a => !machineList.Exists(t => a.ASSETNUM.Contains(t.MACHINECODDE))).ToList();
|
||
|
if (expMachines != null && expMachines.Count > 0)
|
||
|
{
|
||
|
foreach (var equipmentInfo in expMachines)
|
||
|
{
|
||
|
var machine = new MachineInfo
|
||
|
{
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
CREATEUSER = this.LoginUser.UserID,
|
||
|
CREATEDATE = DateTime.Now,
|
||
|
UPDATEUSER = this.LoginUser.UserID,
|
||
|
UPDATEDATE = DateTime.Now,
|
||
|
MACHINECODDE = equipmentInfo.ASSETNUM,
|
||
|
MACHINENAME = equipmentInfo.ASSETNUM,
|
||
|
//MACHINENUM = "0",
|
||
|
//PROCESSTYPE = "0",
|
||
|
ISCONTROL = "0",
|
||
|
STATUS = "0"
|
||
|
};
|
||
|
session.Insert(machine);
|
||
|
}
|
||
|
}
|
||
|
//比对模具
|
||
|
var expMoulds = moulds.Where(a => !mouldList.Exists(t => a.ASSETNUM.Contains(t.MOULD_CODE))).ToList();
|
||
|
if (expMoulds != null && expMoulds.Count > 0)
|
||
|
{
|
||
|
foreach (var equipmentInfo in expMoulds)
|
||
|
{
|
||
|
var mould = new Mould
|
||
|
{
|
||
|
PID = Guid.NewGuid().ToString(),
|
||
|
CREATEUSER = this.LoginUser.UserID,
|
||
|
CREATEDATE = DateTime.Now,
|
||
|
UPDATEUSER = this.LoginUser.UserID,
|
||
|
UPDATEDATE = DateTime.Now,
|
||
|
SYNC_DATE = DateTime.Now,
|
||
|
MOULD_CODE = equipmentInfo.ASSETNUM,
|
||
|
MOULD_NAME = equipmentInfo.ASSETNUM,
|
||
|
MOULD_TYPE = "注塑模具",
|
||
|
WORKCENTER_CODE = "INJECT",
|
||
|
FACTORY_CODE = "CFAAQD",
|
||
|
MOULD_STATE = "0"
|
||
|
};
|
||
|
session.Insert(mould);
|
||
|
}
|
||
|
}
|
||
|
// 事务提交
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
session.RollbackTs();
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|