You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1582 lines
66 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using ibk.IPD.Common;
using ibk.IPD.Entity.IPD_PS;
using ibk.IPD.Entity;
using log4net.Repository.Hierarchy;
using SOA.Objects;
using SOA.Persistent;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using log4net;
using System.Reflection;
using ibk.IPD.Service.IPD_SS;
namespace ibk.IPD.Controller.IPD_PS
{
[RoutePrefix("ipd/ipdMr")]
public class TbSlabSpeController : ApiController
{
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//设置一个加锁对象
private static readonly object LOCK = new object();
/// <summary>
/// 参数校验
/// </summary>
/// <param name="cncs"></param>
/// /// <param name="result"></param>
/// <returns>是否通过参数校验</returns>
public bool ParameterCalibration(TB_SLAB_ORD_SPE cncs, RequestEntity result)
{
#region 参数判断
if (CommonUtils.GetLength(cncs.ORD_ITEM) > 100)
{
result.msg = "订单探项次号不可超过100";
result.code = "0";
return false;
}
if (CommonUtils.GetLength(cncs.ORD_NO) > 100)
{
result.msg = "订单长度不可超过100";
result.code = "0";
return false;
}
return true;
#endregion
}
#region 特殊钢种成材率管控
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbYieldControl")]
public RequestEntity GetTbYieldControl(TB_YIELD_CONTROL query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//查询
strSql.AppendLine("SELECT ID,PLT, STLGRD, REMLEN,REMLEN_MIN, YIELD,to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss') as INS_DATE ,INS_TIME,INS_EMP , to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss') as UPD_DATE, UPD_TIME,UPD_EMP FROM TB_YIELD_CONTROL WHERE 1 = 1 ");
if (!string.IsNullOrEmpty(query.PLT))
{
strSql.AppendLine("and PLT='" + query.PLT + "'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
strSql.AppendLine("Order By INS_DATE DESC ");
dtCheck = db.Query(strSql.ToString());
result.data = db.Query<TB_YIELD_CONTROL>(strSql.ToString());
if (dtCheck.Rows.Count > 0)
{
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTbUstFl 报错", ex);
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbYieldControl")]
public RequestEntity AddTbYieldControl(TB_YIELD_CONTROL model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
#region 参数判断
if (string.IsNullOrEmpty(model.PLT) || string.IsNullOrEmpty(model.STLGRD))
{
db.Rollback();
return result;
}
#endregion
model.ID = "";
model.PLT = model.PLT.Trim();
model.STLGRD = model.STLGRD.Trim();
model.REMLEN = model.REMLEN;
model.REMLEN_MIN = model.REMLEN_MIN;
model.YIELD = model.YIELD;
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_YIELD_CONTROL>(model) > 0)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbYieldControl")]
public RequestEntity UpdateTbYieldControl(IList<TB_YIELD_CONTROL> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_YIELD_CONTROL ");
strSql.AppendLine(string.Format("set REMLEN='{2}',REMLEN_MIN='{5}', YIELD='{3}',PLT = '{0}',STLGRD = '{1}' where ID = '{4}'", model[1].PLT, model[1].STLGRD, model[1].REMLEN, model[1].YIELD, model[1].ID, model[1].REMLEN_MIN));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录修改失败: " + model.ToString());
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbYieldControl")]
public RequestEntity DelTbYieldControl(IList<TB_YIELD_CONTROL> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM TB_YIELD_CONTROL WHERE 1=1 ");
strSql.AppendLine(string.Format("AND ID= '{0}'", model.ID));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录删除失败: " + delModel.ToString());
}
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTbOrdSpe 报错", ex);
}
return result;
}
#endregion
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbSlabOrdSpe")]
public RequestEntity GetTbSlabOrdSpe(TB_SLAB_ORD_SPE query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
String strSql2 = string.Empty; //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList<TB_SLAB_ORD_SPE> tB_SLAB_ORD_SPEs = new List<TB_SLAB_ORD_SPE>();
IList<TB_APPOINT_ORDER_INFO> ltResult = new List<TB_APPOINT_ORDER_INFO>();
//查询
strSql.AppendLine("SELECT ORD_NO, ORD_ITEM, ORD_CON, PK,to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss') as INS_DATE ,INS_TIME,INS_EMP , to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss') as UPD_DATE, UPD_TIME,UPD_EMP FROM TB_SLAB_ORD_SPE WHERE 1 = 1 ");
if (query != null)
{
if (!string.IsNullOrWhiteSpace(query.ORD_NO))
strSql.AppendLine(" AND ORD_NO LIKE '%" + query.ORD_NO + "%'");
if (!string.IsNullOrWhiteSpace(query.ORD_ITEM))
strSql.AppendLine(" AND ORD_ITEM LIKE '%" + query.ORD_ITEM + "%'");
}
strSql.AppendLine("Order By INS_DATE DESC ");
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
tB_SLAB_ORD_SPEs = db.Query<TB_SLAB_ORD_SPE>(strSql.ToString());
}
foreach (TB_SLAB_ORD_SPE order in tB_SLAB_ORD_SPEs)
{
strSql2 += string.Format(" or (boi.ORD_NO = '{0}' and boi.ORD_ITEM = '{1}')", order.ORD_NO, order.ORD_ITEM);
}
ltResult = getAPPOINTOrderInfo(strSql2);
foreach (TB_SLAB_ORD_SPE order in tB_SLAB_ORD_SPEs)
{
if(ltResult.Where(p=>p.ORD_NO== order.ORD_NO && p.ORD_ITEM == order.ORD_ITEM).Count() == 0)
{
TB_APPOINT_ORDER_INFO tB_APPOINT_ORDER_INFO = new TB_APPOINT_ORDER_INFO();
tB_APPOINT_ORDER_INFO.ORD_NO = order.ORD_NO;
tB_APPOINT_ORDER_INFO.ORD_ITEM = order.ORD_ITEM;
tB_APPOINT_ORDER_INFO.COLOR_STROKE = "未找到订单信息";
ltResult.Add(tB_APPOINT_ORDER_INFO);
}
}
if (ltResult.Count > 0)
{
result.code = "1";
result.data = ltResult;
}
return result;
}
public IList<TB_APPOINT_ORDER_INFO> getAPPOINTOrderInfo(string BOI)
{
StringBuilder strSql = new StringBuilder();//声明拼接Sql语句变量
IList<TB_APPOINT_ORDER_INFO> ltBOI = new List<TB_APPOINT_ORDER_INFO>();
strSql.AppendLine("SELECT DISTINCT ");
strSql.AppendLine(" BOI.ord_no,BOI.ord_item,BOI.ORD_STS,BOI.STDSPEC,BOI.STLGRD,BOI.ORD_THK,BOI.ORD_WID,BOI.ORD_LEN,ROUND(BOI.ORD_THK/1000*BOI.ORD_WID/1000*BOI.ORD_LEN/1000*7.85,3) AS ORD_WGT ,BOI.SIZE_KND,BOI.DEL_TO_DATE,CPP.ORD_WGT as PROD_WGT ");
strSql.AppendLine(",NVL(CPP.ORD_REM_WGT, 0) DEL_TOL_MAX, NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100 DEL_TOL_MIN ");
strSql.AppendLine(" ,NVL(C.SMS_TOT_WGT, 0) SMS_TOT_WGT-- - 炼钢 ");
strSql.AppendLine(", NVL(C.CCM_TOT_WGT, 0) CCM_TOT_WGT--连铸 ");
strSql.AppendLine(",NVL(C.MILL_TOT_WGT, 0) ");
strSql.AppendLine(" - DECODE(BOI.IS_JC, ");
strSql.AppendLine(" 'Y', ");
strSql.AppendLine(" (SELECT NVL(SUM(WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB ");
strSql.AppendLine(" WHERE REC_STS = '2' ");
strSql.AppendLine(" AND ORD_FL = '1' ");
strSql.AppendLine(" AND PROC_CD IN('CAA', 'CAD') ");
strSql.AppendLine(" AND ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND INGOT_FL = 'A'), ");
strSql.AppendLine(" 0) ZGDD--轧钢等待 ");
strSql.AppendLine(",(SELECT NVL(SUM(E.WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB F, NISCO.FP_SLAB_DES E ");
strSql.AppendLine(" WHERE E.ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND E.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND E.BLOCK_SEQ > '00' ");
strSql.AppendLine(" AND E.SEQ > '00' ");
strSql.AppendLine(" AND E.REC_STS = '2' ");
strSql.AppendLine(" AND F.SLAB_NO = E.SLAB_NO ");
strSql.AppendLine(" AND F.ORD_FL = '1' ");
strSql.AppendLine(" AND E.PROC_CD = 'CAD') CADPL--CAD ");
strSql.AppendLine(",BOI.CFM_MILL_PLT,BOI.COLOR_STROKE,BOI.CUST_CD ");
strSql.AppendLine("FROM NISCO.cp_prc CPP ");
strSql.AppendLine("INNER JOIN ");
strSql.AppendLine("NISCO.BP_ORDER_ITEM boi ");
strSql.AppendLine("ON BOI.ORD_NO = CPP.ORD_NO ");
strSql.AppendLine("AND BOI.ORD_ITEM = CPP.ORD_ITEM ");
strSql.AppendLine("AND BOI.ORD_WID <> 0 ");
strSql.AppendLine("AND BOI.ORD_LEN <> 0 ");
strSql.AppendLine("AND BOI.ORD_THK <> 0 ");
strSql.AppendLine("LEFT JOIN(SELECT CPD.ORD_NO, CPD.ORD_ITEM, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BC', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BD', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BE', CPD.TOT_WGT, 0)) AS SMS_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BF', CPD.TOT_WGT, 0)) AS CCM_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'CA', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'CB', CPD.TOT_WGT, 0)) AS MILL_TOT_WGT ");
strSql.AppendLine(" FROM NISCO.CP_PRC_DET CPD ");
strSql.AppendLine(" GROUP BY CPD.ORD_NO, CPD.ORD_ITEM) C ");
strSql.AppendLine(" ON C.ORD_NO = BOI.ORD_NO AND C.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine("WHERE 1!=1 ");
strSql.AppendLine(BOI);
// P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
ltBOI = db.Query<TB_APPOINT_ORDER_INFO>(strSql.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetBOIInfo 报错", ex);
}
return ltBOI;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbSlabOrdSpe")]
public RequestEntity AddTbSlabOrdSpe(IList<TB_SLAB_ORD_SPE> insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
foreach (TB_SLAB_ORD_SPE model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM))
{
continue;
}
if (!ParameterCalibration(model, result))
{
db.Rollback();
return result;
}
#endregion
model.PK = "";
model.ORD_NO = model.ORD_NO.Trim();
model.ORD_ITEM = model.ORD_ITEM.Trim();
model.ORD_ITEM = model.ORD_ITEM.ToString().PadLeft(3, '0');
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_SLAB_ORD_SPE>(model) == 0)
{
b = false;
break;
}
}
if (b)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbSlabOrdSpeOne")]
public RequestEntity AddTbSlabOrdSpeOne(TB_SLAB_ORD_SPE model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
#region 参数判断
if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM))
{
db.Rollback();
return result;
}
if (!ParameterCalibration(model, result))
{
db.Rollback();
return result;
}
#endregion
if(model.ORD_ITEM.Trim()=="000"|| model.ORD_ITEM.Trim() == "")
model.PK = "";
model.ORD_NO = model.ORD_NO.Trim();
model.ORD_ITEM = model.ORD_ITEM.Trim();
model.ORD_ITEM = model.ORD_ITEM.ToString().PadLeft(3, '0');
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_SLAB_ORD_SPE>(model) > 0)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbSlabOrdSpe")]
public RequestEntity UpdateTbSlabOrdSpeOne(IList<TB_SLAB_ORD_SPE> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_SLAB_ORD_SPE ");
strSql.AppendLine(string.Format("set 1=1 where ORD_NO = '{0}' and ORD_ITEM = '{1}' ", model[1].ORD_NO, model[1].ORD_ITEM));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录修改失败: " + model.ToString());
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbSlabOrdSpe")]
public RequestEntity DelTbSlabOrdSpe(IList<TB_SLAB_ORD_SPE> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM TB_SLAB_ORD_SPE WHERE 1=1 ");
strSql.AppendLine(string.Format("AND ORD_NO = '{0}' AND ORD_ITEM = '{1}' ", model.ORD_NO, model.ORD_ITEM));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录删除失败: " + delModel.ToString());
}
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTbOrdSpe 报错", ex);
}
return result;
}
#region 选择板坯转工厂
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbPltSpe")]
public RequestEntity GetTbPltSpe(TB_PLT_SPE query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
string strSql2 = string.Empty; //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList<TB_PLT_SPE> TB_HEAT_SPEs = new List<TB_PLT_SPE>();
IList<TB_SlabOrdFl> TB_HEAT_SPEs2 = new List<TB_SlabOrdFl>();
//IList<TB_APPOINT_ORDER_INFO> ltResult = new List<TB_APPOINT_ORDER_INFO>();
//查询
strSql.AppendLine("SELECT '' ord_fl ,t.* FROM TB_PLT_SPE t WHERE 1 = 1 ");
if (query != null)
{
if (!string.IsNullOrWhiteSpace(query.SLAB_NO))
strSql.AppendLine(" AND SLAB_NO LIKE '%" + query.SLAB_NO + "%'");
}
strSql.AppendLine("Order By INS_DATE DESC ");
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
TB_HEAT_SPEs = db.Query<TB_PLT_SPE>(strSql.ToString());
}
strSql2=string.Join("','", TB_HEAT_SPEs.Select(p=>p.SLAB_NO));
strSql2 = string.Format("Select slab_no,ord_fl from nisco.fp_slab where slab_no in ('{0}')", strSql2);
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
TB_HEAT_SPEs2 = db.Query<TB_SlabOrdFl>(strSql2.ToString());
}
foreach (TB_PLT_SPE tb in TB_HEAT_SPEs)
{
if(TB_HEAT_SPEs2.Where(p => p.SLAB_NO == tb.SLAB_NO).Count() > 0)
{
tb.ORD_FL = TB_HEAT_SPEs2.Where(p => p.SLAB_NO == tb.SLAB_NO).FirstOrDefault().ORD_FL;
tb.ORD_FL = tb.ORD_FL == "2" ? "未替代" : "已替代";
}
else
{
tb.ORD_FL = "已替代";
}
}
//foreach (TB_HEAT_SPE order in TB_HEAT_SPEs)
//{
// strSql2 += string.Format(" or (boi.ORD_NO = '{0}' and boi.ORD_ITEM = '{1}')", order.ORD_NO, order.ORD_ITEM);
//}
//ltResult = TB_HEAT_SPEs;// getAPPOINTOrderInfo(strSql2);
//foreach (TB_HEAT_SPE order in TB_HEAT_SPEs)
//{
//if (ltResult.Where(p => p.ORD_NO == order.ORD_NO && p.ORD_ITEM == order.ORD_ITEM).Count() == 0)
//{
// TB_APPOINT_ORDER_INFO tB_APPOINT_ORDER_INFO = new TB_APPOINT_ORDER_INFO();
// tB_APPOINT_ORDER_INFO.ORD_NO = order.ORD_NO;
// tB_APPOINT_ORDER_INFO.ORD_ITEM = order.ORD_ITEM;
// tB_APPOINT_ORDER_INFO.COLOR_STROKE = "未找到订单信息";
// ltResult.Add(tB_APPOINT_ORDER_INFO);
//}
//}
if (TB_HEAT_SPEs.Count > 0)
{
result.code = "1";
result.data = TB_HEAT_SPEs;
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbPltSpe")]
public RequestEntity AddTbPltSpe(IList<TB_PLT_SPE> insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
IList<TB_PLT_SPE> TB_HEAT_SPEs = new List<TB_PLT_SPE>();
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
//查询
strSql.AppendLine("SELECT '' ord_fl ,t.* FROM TB_PLT_SPE t WHERE 1 = 1 ");
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
TB_HEAT_SPEs = db.Query<TB_PLT_SPE>(strSql.ToString());
foreach (TB_PLT_SPE model in insertModel)
{
#region 参数判断
if(TB_HEAT_SPEs.Where(p=>p.SLAB_NO== model.SLAB_NO.Trim()).Count() > 0)
{
continue;
}
if (string.IsNullOrEmpty(model.SLAB_NO) )
{
result.msg = "板坯号不能为空!";
continue;
}
if (string.IsNullOrEmpty(model.REMARK))
{
result.msg = "备注不能为空!";
continue;
}
if (string.IsNullOrEmpty(model.PLT))
{
result.msg = "工厂不能为空!";
continue;
}
if(model.PLT != "C1" && model.PLT != "C2" && model.PLT != "C3")
{
result.msg = "工厂错误!";
continue;
}
//if (!ParameterCalibration(model, result))
//{
// db.Rollback();
// return result;
//}
#endregion
model.PK = "";
model.SLAB_NO = model.SLAB_NO.Trim();
model.REMARK = model.REMARK.Trim();
model.PLT = model.PLT.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
model.STATUS = "0";
if (db.Insert<TB_PLT_SPE>(model) == 0)
{
b = false;
break;
}
}
if (b)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbPltSpeOne")]
public RequestEntity AddTbPltSpeOne(TB_PLT_SPE model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
IList<TB_PLT_SPE> TB_HEAT_SPEs = new List<TB_PLT_SPE>();
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
//查询
strSql.AppendLine("SELECT '' ord_fl ,t.* FROM TB_PLT_SPE t WHERE 1 = 1 ");
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
TB_HEAT_SPEs = db.Query<TB_PLT_SPE>(strSql.ToString());
if (TB_HEAT_SPEs.Where(p => p.SLAB_NO == model.SLAB_NO.Trim()).Count() > 0)
{
db.Rollback();
result.msg = "不能重复插入!";
return result;
}
#region 参数判断
if (string.IsNullOrEmpty(model.SLAB_NO) )
{
db.Rollback();
result.msg = "板坯号不能为空!";
return result;
}
if (string.IsNullOrEmpty(model.REMARK))
{
db.Rollback();
result.msg = "备注不能为空!";
return result;
}
//if (!ParameterCalibration(model, result))
//{
// db.Rollback();
// return result;
//}
#endregion
model.PK = "";
model.SLAB_NO = model.SLAB_NO.Trim();
model.REMARK = model.REMARK.Trim();
model.REMARK = model.REMARK.Trim();
model.PLT = model.PLT.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
model.STATUS = "0";
if (db.Insert<TB_PLT_SPE>(model) > 0)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbPltSpe")]
public RequestEntity UpdateTbPltSpeOne(IList<TB_PLT_SPE> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_PLT_SPE ");
strSql.AppendLine(string.Format("set 1=1 where SLAB_NO = '{0}' and REMARK = '{1}' ", model[1].SLAB_NO, model[1].REMARK));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录修改失败: " + model.ToString());
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbPltSpe")]
public RequestEntity DelTbPltSpe(IList<TB_PLT_SPE> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM tb_PLT_spe WHERE 1=1 ");
strSql.AppendLine(string.Format("AND Slab_NO = '{0}' AND REMARK = '{1}' ", model.SLAB_NO, model.REMARK));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录删除失败: " + delModel.ToString());
}
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTbOrdSpe 报错", ex);
}
return result;
}
#endregion
#region 不可替代垛位
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbYardSpe")]
public RequestEntity GetTbYardSpe(TB_YARD_SPE query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
String strSql2 = string.Empty; //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList<TB_YARD_SPE> TB_HEAT_SPEs = new List<TB_YARD_SPE>();
//IList<TB_APPOINT_ORDER_INFO> ltResult = new List<TB_APPOINT_ORDER_INFO>();
//查询
strSql.AppendLine("SELECT * FROM TB_YARD_SPE WHERE 1 = 1 ");
if (query != null)
{
if (!string.IsNullOrWhiteSpace(query.LOC))
strSql.AppendLine(" AND LOC LIKE '%" + query.LOC + "%'");
}
strSql.AppendLine("Order By INS_DATE DESC ");
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
TB_HEAT_SPEs = db.Query<TB_YARD_SPE>(strSql.ToString());
}
//foreach (TB_HEAT_SPE order in TB_HEAT_SPEs)
//{
// strSql2 += string.Format(" or (boi.ORD_NO = '{0}' and boi.ORD_ITEM = '{1}')", order.ORD_NO, order.ORD_ITEM);
//}
//ltResult = TB_HEAT_SPEs;// getAPPOINTOrderInfo(strSql2);
//foreach (TB_HEAT_SPE order in TB_HEAT_SPEs)
//{
//if (ltResult.Where(p => p.ORD_NO == order.ORD_NO && p.ORD_ITEM == order.ORD_ITEM).Count() == 0)
//{
// TB_APPOINT_ORDER_INFO tB_APPOINT_ORDER_INFO = new TB_APPOINT_ORDER_INFO();
// tB_APPOINT_ORDER_INFO.ORD_NO = order.ORD_NO;
// tB_APPOINT_ORDER_INFO.ORD_ITEM = order.ORD_ITEM;
// tB_APPOINT_ORDER_INFO.COLOR_STROKE = "未找到订单信息";
// ltResult.Add(tB_APPOINT_ORDER_INFO);
//}
//}
if (TB_HEAT_SPEs.Count > 0)
{
result.code = "1";
result.data = TB_HEAT_SPEs;
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbYardSpe")]
public RequestEntity AddTbYardSpe(IList<TB_YARD_SPE> insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
foreach (TB_YARD_SPE model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.LOC))
{
continue;
}
if (string.IsNullOrEmpty(model.REMARK))
{
continue;
}
//if (!ParameterCalibration(model, result))
//{
// db.Rollback();
// return result;
//}
#endregion
model.PK = "";
model.LOC = model.LOC.Trim();
model.REMARK = model.REMARK.Trim();
model.PLT = model.PLT.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_YARD_SPE>(model) == 0)
{
b = false;
break;
}
}
if (b)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbYardSpeOne")]
public RequestEntity AddTbYardSpeOne(TB_YARD_SPE model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
#region 参数判断
if (string.IsNullOrEmpty(model.LOC))
{
db.Rollback();
result.msg = "垛位不能为空!";
return result;
}
if (string.IsNullOrEmpty(model.REMARK))
{
db.Rollback();
result.msg = "备注不能为空!";
return result;
}
if (string.IsNullOrEmpty(model.PLT))
{
db.Rollback();
result.msg = "工厂不能为空!";
return result;
}
//if (!ParameterCalibration(model, result))
//{
// db.Rollback();
// return result;
//}
#endregion
model.PK = "";
model.LOC = model.LOC.Trim();
model.REMARK = model.REMARK.Trim();
model.REMARK = model.REMARK.Trim();
model.PLT = model.PLT.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_YARD_SPE>(model) > 0)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbYARDSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbYardSpe")]
public RequestEntity UpdateTbYardSpeOne(IList<TB_YARD_SPE> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_YARD_SPE ");
strSql.AppendLine(string.Format("set 1=1 where LOC = '{0}' and REMARK = '{1}' ", model[1].LOC, model[1].REMARK));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录修改失败: " + model.ToString());
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbYardSpe")]
public RequestEntity DelTbYardSpe(IList<TB_YARD_SPE> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM tb_Yard_spe WHERE 1=1 ");
strSql.AppendLine(string.Format("AND LOC = '{0}' AND REMARK = '{1}' ", model.LOC, model.REMARK));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录删除失败: " + delModel.ToString());
}
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTbYARDSpe 报错", ex);
}
return result;
}
#endregion
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbSlabSpe")]
public RequestEntity GetTbSlabSpe(TB_SLAB_SPE query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//查询
strSql.AppendLine("SELECT SLAB_NO, SLAB_FLG,PLT, SLAB_CON, PK,to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss') as INS_DATE ,INS_TIME,INS_EMP , to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss') as UPD_DATE, UPD_TIME,UPD_EMP FROM TB_SLAB_SPE WHERE 1 = 1 ");
if (query != null)
{
if (!string.IsNullOrWhiteSpace(query.SLAB_NO))
strSql.AppendLine(" AND SLAB_NO LIKE '%" + query.SLAB_NO + "%'");
if (!string.IsNullOrWhiteSpace(query.PLT))
strSql.AppendLine(" AND PLT LIKE '%" + query.PLT + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
strSql.AppendLine("Order By SLAB_CON ");
dtCheck = db.Query(strSql.ToString());
result.data = db.Query<TB_SLAB_SPE>(strSql.ToString());
if (dtCheck.Rows.Count > 0)
{
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTbUstFl 报错", ex);
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbSlabSpe")]
public RequestEntity AddTbSlabSpe(IList<TB_SLAB_SPE> insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
foreach (TB_SLAB_SPE model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.SLAB_NO))
{
continue;
}
if (CommonUtils.GetLength(model.SLAB_NO) > 20)
{
db.Rollback();
return result;
}
#endregion
model.PK = "";
model.SLAB_NO = model.SLAB_NO.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_SLAB_SPE>(model) == 0)
{
b = false;
break;
}
}
if (b)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbSlabSpeOne")]
public RequestEntity AddTbSlabSpeOne(TB_SLAB_SPE model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
#region 参数判断
if (string.IsNullOrEmpty(model.SLAB_NO))
{
db.Rollback();
return result;
}
if (CommonUtils.GetLength(model.SLAB_NO) > 20)
{
db.Rollback();
return result;
}
#endregion
model.PK = "";
model.SLAB_NO = model.SLAB_NO.Trim();
model.PLT = model.PLT.Trim();
model.INS_DATE = dtNow.ToString("yyyyMMdd");
model.INS_TIME = dtNow.ToString("HHmmss");
model.UPD_DATE = dtNow.ToString("yyyyMMdd");
model.UPD_TIME = dtNow.ToString("HHmmss");
if (db.Insert<TB_SLAB_SPE>(model) > 0)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddTbOrdSpe 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbSlabSpe")]
public RequestEntity UpdateTbSlabSpeOne(IList<TB_SLAB_SPE> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_SLAB_SPE ");
strSql.AppendLine(string.Format("set PLT='{0}' where SLAB_NO = '{1}' ", model[1].PLT, model[1].SLAB_NO));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录修改失败: " + model.ToString());
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbSlabSpe")]
public RequestEntity DelTbSlabOrdSpe(IList<TB_SLAB_SPE> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM TB_SLAB_SPE WHERE 1=1 ");
strSql.AppendLine(string.Format("AND SLAB_NO = '{0}' ", model.SLAB_NO));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
strSql.Length = 0;
}
catch
{
logger.Error("该条记录删除失败: " + delModel.ToString());
}
}
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTbOrdSpe 报错", ex);
}
return result;
}
}
}