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.
221 lines
5.7 KiB
221 lines
5.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.BLL;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.DAL.Basic;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.KB.Entity;
|
|
using QMAPP.FJC.Entity;
|
|
|
|
namespace QMAPP.FJC.BLL.Basic
|
|
{
|
|
/// <summary>
|
|
/// 单色搪塑操作类
|
|
/// 2016-6-15 闫永刚
|
|
///
|
|
/// </summary>
|
|
public class MoldConfigBLL : BaseBLL
|
|
{
|
|
/// <summary>
|
|
/// 获取所有的配置信息
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public DataPage GetList(MoldConfig condition)
|
|
{
|
|
try
|
|
{
|
|
DataPage page = new DataPage();
|
|
//获取物料信息列表
|
|
List<MoldConfig> list = new MoldConfigDAL().GetList(condition);
|
|
page.Result = list;
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取最大的模架号和模腔号
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public MoldConfig GetMaxMold()
|
|
{
|
|
try
|
|
{
|
|
//获取物料信息列表
|
|
MoldConfig mold = new MoldConfigDAL().GetMaxMold();
|
|
return mold;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取单个实体
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public DataResult<MoldConfig> Get(MoldConfig condition)
|
|
{
|
|
DataResult<MoldConfig> result=new DataResult<MoldConfig>();
|
|
|
|
condition = new MoldConfigDAL().Get(condition);
|
|
|
|
result.Result = condition;
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
public DataResult Delete(MoldConfig condition)
|
|
{
|
|
DataResult result = new DataResult();
|
|
|
|
try
|
|
{
|
|
new MoldConfigDAL().Delete(condition);
|
|
result.IsSuccess = true;
|
|
result.Msg = "删除成功!";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = "删除失败!";
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增模腔号配置信息
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
public DataResult Insert(MoldConfig entity)
|
|
{
|
|
|
|
DataResult result = new DataResult();
|
|
|
|
entity.PID = Guid.NewGuid().ToString();
|
|
|
|
MoldConfigDAL dal = new MoldConfigDAL();
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dal.BaseSession = session;
|
|
|
|
session.OpenTs();
|
|
|
|
dal.Insert(entity);
|
|
|
|
if (entity.USED == 1)
|
|
{
|
|
dal.UpdateOtherUsed(entity);
|
|
}
|
|
|
|
|
|
session.CommitTs();
|
|
}
|
|
|
|
result.Msg = "保存成功!";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改模腔号配置信息
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
public DataResult Update(MoldConfig entity)
|
|
{
|
|
DataResult result = new DataResult();
|
|
|
|
MoldConfigDAL dal = new MoldConfigDAL();
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dal.BaseSession = session;
|
|
|
|
session.OpenTs();
|
|
|
|
dal.Update(entity);
|
|
|
|
if (entity.USED == 1)
|
|
{
|
|
dal.UpdateOtherUsed(entity);
|
|
}
|
|
|
|
session.CommitTs();
|
|
}
|
|
result.Msg = "保存成功!";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
|
|
public DataResult UpdateNextUsed(MoldConfig entity)
|
|
{
|
|
DataResult result = new DataResult();
|
|
|
|
MoldConfigDAL dal = new MoldConfigDAL();
|
|
|
|
List<MoldConfig> list = new MoldConfigDAL().GetList(new MoldConfig() { STATUS=1 });
|
|
|
|
|
|
MoldConfig original = new MoldConfig();
|
|
MoldConfig nextEntity = new MoldConfig();
|
|
if (list.Count(o => o.MOLDSTATION == entity.MOLDSTATION) > 0)
|
|
{
|
|
original = list.First(o => o.MOLDSTATION == entity.MOLDSTATION);
|
|
|
|
//original.USED = 0;
|
|
|
|
List<MoldConfig> restList = list.Where(o => o.INDEXVALUE > original.INDEXVALUE)
|
|
.OrderBy(o => o.INDEXVALUE).ToList<MoldConfig>();
|
|
|
|
if (restList.Count > 0)
|
|
{
|
|
nextEntity = restList[0];
|
|
}
|
|
else
|
|
{
|
|
nextEntity = list[0];
|
|
}
|
|
|
|
nextEntity.USED = 1;
|
|
}
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dal.BaseSession = session;
|
|
|
|
session.OpenTs();
|
|
|
|
|
|
if (string.IsNullOrEmpty(nextEntity.PID) == false)
|
|
{
|
|
dal.Update(nextEntity);
|
|
}
|
|
|
|
dal.UpdateOtherUsed(nextEntity);
|
|
|
|
session.CommitTs();
|
|
}
|
|
result.Msg = "保存成功!";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|