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.

451 lines
27 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;
using ibk.IPD.Entity.IPD_MR.HotRoll;
using ibk.IPD.Entity.IPD_MR.HotRoll.QueryArgs;
using log4net;
using SOA.Objects;
using SOA.Persistent;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
/********************************************************
* 简 介:南钢热轧制造规范管理
* 头尾放尺规范维护后端接口
* 版本号V1.0
* 日 期2022年04月07日
* 创建者: 李跃升
* Copy Right: 北京科技大学设计研究院有限公司
********************************************************/
namespace ibk.IPD.Controller.IPD_MR.HotRoll
{
[RoutePrefix("ipd/ipdMr")]
public class TopEndRulerController : ApiController
{
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// 查询接口
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("hotRoll/getHeadAndTailRuler")]
public RequestEntity GetHeadAndTailRuler(EpStdCropLenQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//查询语句日期时间拼接起来格式化成yyyy-mm-dd hh24:mi:ss
//PLT , STLGRD , THK_MIN , THK_MAX , ASROLL_LEN_MIN , ASROLL_LEN_MAX , BASIC_LEN , UNIT_LEN , UNIT_RATIO , SIZE_FL , ASROLL_WID_MIN , ASROLL_WID_MAX , WID_RATIO_MIN , WID_RATIO_MAX , SLAB_THK
//strSql.AppendLine("SELECT PLT , STLGRD ,THK_MIN , THK_MAX , ASROLL_LEN_MIN , ASROLL_LEN_MAX , BASIC_LEN , UNIT_LEN , UNIT_RATIO , SIZE_FL , ASROLL_WID_MIN , ASROLL_WID_MAX , WID_RATIO_MIN , WID_RATIO_MAX , SLAB_THK , to_date(UPD_DATE || UPD_TIME,'yyyy-mm-dd hh24:mi:ss') as UPD_DATE,UPD_TIME,UPD_EMP,to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss') as INS_DATE,INS_TIME,INS_EMP FROM EP_STD_CROP_LEN WHERE 1 = 1 ");
strSql.AppendLine("SELECT PLT , STLGRD ,THK_MIN , THK_MAX , ASROLL_LEN_MIN , ASROLL_LEN_MAX , BASIC_LEN , UNIT_LEN , UNIT_RATIO , SIZE_FL , ASROLL_WID_MIN , " +
"ASROLL_WID_MAX , WID_RATIO_MIN , WID_RATIO_MAX , SLAB_THK , UPD_DATE,UPD_TIME,UPD_EMP,INS_DATE,INS_TIME,INS_EMP FROM EP_STD_CROP_LEN WHERE 1 = 1 ");
if (queryArgs != null)
{
if (!string.IsNullOrWhiteSpace(queryArgs.PLT)) strSql.AppendLine(" AND PLT LIKE '%" + queryArgs.PLT + "%'");
if (!string.IsNullOrWhiteSpace(queryArgs.STLGRD)) strSql.AppendLine(" AND STLGRD LIKE '%" + queryArgs.STLGRD + "%'");
if (!string.IsNullOrWhiteSpace(queryArgs.THK_MIN) && CommonUtils.IsNumber(queryArgs.THK_MIN)) strSql.AppendLine(" AND THK_MIN >=" + queryArgs.THK_MIN);
if (!string.IsNullOrWhiteSpace(queryArgs.THK_MAX) && CommonUtils.IsNumber(queryArgs.THK_MAX)) strSql.AppendLine(" AND THK_MAX <=" + queryArgs.THK_MAX);
if (!string.IsNullOrWhiteSpace(queryArgs.ASROLL_LEN_MIN) && CommonUtils.IsNumber(queryArgs.ASROLL_LEN_MIN)) strSql.AppendLine(" AND ASROLL_LEN_MIN >=" + queryArgs.ASROLL_LEN_MIN);
if (!string.IsNullOrWhiteSpace(queryArgs.ASROLL_LEN_MAX) && CommonUtils.IsNumber(queryArgs.ASROLL_LEN_MAX)) strSql.AppendLine(" AND ASROLL_LEN_MAX <=" + queryArgs.ASROLL_LEN_MAX);
//坯料厚度
if (!string.IsNullOrWhiteSpace(queryArgs.SLAB_THK) && CommonUtils.IsNumber(queryArgs.SLAB_THK)) strSql.AppendLine(" AND SLAB_THK =" + queryArgs.SLAB_THK);
if (!string.IsNullOrWhiteSpace(queryArgs.ASROLL_WID_MIN) && CommonUtils.IsNumber(queryArgs.ASROLL_WID_MIN)) strSql.AppendLine(" AND ASROLL_WID_MIN >=" + queryArgs.ASROLL_WID_MIN);
if (!string.IsNullOrWhiteSpace(queryArgs.ASROLL_WID_MAX) && CommonUtils.IsNumber(queryArgs.ASROLL_WID_MAX)) strSql.AppendLine(" AND ASROLL_WID_MAX <=" + queryArgs.ASROLL_WID_MAX);
if (!string.IsNullOrWhiteSpace(queryArgs.SIZE_FL)) strSql.AppendLine(" AND SIZE_FL LIKE '%" + queryArgs.SIZE_FL + "%'");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.START_TIME)) && CommonUtils.ObjectToStr(queryArgs.START_TIME) != "0001/1/1 0:00:00") strSql.AppendLine(" AND to_date(INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00") strSql.AppendLine(" AND to_date(INS_DATE ,'yyyy-mm-dd hh24:mi:ss') <= to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
strSql.AppendLine("Order By PLT DESC");
dtCheck = db.Query(strSql.ToString());
//result.data = db.Query<EP_STD_CROP_LEN>(strSql.ToString());
if (dtCheck.Rows.Count > 0)
{
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHeadAndTailRuler 报错", ex);
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("hotRoll/addHeadAndTailRuler")]
public RequestEntity AddHeadAndTailRuler(EP_STD_CROP_LEN insertModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
DateTime dtNow = DateTime.Now;
try
{
#region 参数判断
//非空参数
if (string.IsNullOrEmpty(insertModel.PLT) || insertModel.PLT.Length > 2)
{
result.msg = "工厂不可为空且长度不可超过2";
result.code = "0";
return result;
}
if (string.IsNullOrEmpty(insertModel.STLGRD) || insertModel.STLGRD.Length > 40)
{
result.msg = "钢种不可为空且长度不可超过40";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.THK_MIN))
if ( insertModel.THK_MIN.Length > 6 || !CommonUtils.IsNumber(insertModel.THK_MIN))
{
result.msg = "轧件厚度下限是长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.THK_MAX))
if (insertModel.THK_MAX.Length > 6 || !CommonUtils.IsNumber(insertModel.THK_MAX))
{
result.msg = "轧件厚度上限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.ASROLL_LEN_MIN))
if (insertModel.ASROLL_LEN_MIN.Length > 8 || !CommonUtils.IsNumber(insertModel.ASROLL_LEN_MIN))
{
result.msg = "轧件长度下限长度不可超过8的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.ASROLL_LEN_MAX))
if (insertModel.ASROLL_LEN_MAX.Length > 8 || !CommonUtils.IsNumber(insertModel.ASROLL_LEN_MAX))
{
result.msg = "轧件长度上限长度不可超过8的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.ASROLL_WID_MIN))
if (insertModel.ASROLL_WID_MIN.Length > 6 || !CommonUtils.IsNumber(insertModel.ASROLL_WID_MIN))
{
result.msg = "轧件宽度下限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.ASROLL_WID_MAX))
if (insertModel.ASROLL_WID_MAX.Length > 6 || !CommonUtils.IsNumber(insertModel.ASROLL_WID_MAX))
{
result.msg = "轧件宽度上限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(insertModel.SIZE_FL))
if (insertModel.SIZE_FL.Length > 2 || !CommonUtils.IsNumber(insertModel.SIZE_FL))
{
result.msg = "定尺 单定尺 毛边长度不可超过2的数字";
result.code = "0";
return result;
}
#endregion
// 拼接重复check查询语句
//EP_STD_CROP_LEN 表 没有主键
strSql.AppendLine("SELECT * FROM EP_STD_CROP_LEN WHERE 1=1 ");
if (!string.IsNullOrWhiteSpace(insertModel.PLT)) strSql.AppendLine(" AND PLT = '" + insertModel.PLT + "'");
if (!string.IsNullOrWhiteSpace(insertModel.STLGRD)) strSql.AppendLine(" AND STLGRD = '" + insertModel.STLGRD + "'");
if (!string.IsNullOrWhiteSpace(insertModel.THK_MIN)) strSql.AppendLine(" AND THK_MIN = '" + insertModel.THK_MIN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.THK_MAX)) strSql.AppendLine(" AND THK_MAX = '" + insertModel.THK_MAX + "'");
if (!string.IsNullOrWhiteSpace(insertModel.ASROLL_LEN_MIN)) strSql.AppendLine(" AND ASROLL_LEN_MIN = '" + insertModel.ASROLL_LEN_MIN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.ASROLL_LEN_MAX)) strSql.AppendLine(" AND ASROLL_LEN_MAX = '" + insertModel.ASROLL_LEN_MAX + "'");
if (!string.IsNullOrWhiteSpace(insertModel.BASIC_LEN)) strSql.AppendLine(" AND BASIC_LEN = '" + insertModel.BASIC_LEN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.UNIT_LEN)) strSql.AppendLine(" AND UNIT_LEN = '" + insertModel.UNIT_LEN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.UNIT_RATIO)) strSql.AppendLine(" AND UNIT_RATIO = '" + insertModel.UNIT_RATIO + "'");
if (!string.IsNullOrWhiteSpace(insertModel.SIZE_FL)) strSql.AppendLine(" AND SIZE_FL = '" + insertModel.SIZE_FL + "'");
if (!string.IsNullOrWhiteSpace(insertModel.ASROLL_WID_MIN)) strSql.AppendLine(" AND ASROLL_WID_MIN = '" + insertModel.ASROLL_WID_MIN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.ASROLL_WID_MAX)) strSql.AppendLine(" AND ASROLL_WID_MAX = '" + insertModel.ASROLL_WID_MAX + "'");
if (!string.IsNullOrWhiteSpace(insertModel.WID_RATIO_MIN)) strSql.AppendLine(" AND WID_RATIO_MIN = '" + insertModel.WID_RATIO_MIN + "'");
if (!string.IsNullOrWhiteSpace(insertModel.WID_RATIO_MAX)) strSql.AppendLine(" AND WID_RATIO_MAX = '" + insertModel.WID_RATIO_MAX + "'");
if (!string.IsNullOrWhiteSpace(insertModel.SLAB_THK)) strSql.AppendLine(" AND SLAB_THK = '" + insertModel.SLAB_THK + "'");
insertModel.INS_DATE = dtNow.ToString("yyyyMMdd");
insertModel.INS_TIME = dtNow.ToString("HHmmss");
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
// 执行主键重复查询
DataTable dtCheck = db.Query(strSql.ToString());
if (dtCheck.Rows.Count > 0) // 若数据库中存在则返回错误码0并msg提示用户
{
result.msg = "数据已存在,请确认后重试!";
result.code = "0";
return result;
}
if (db.Insert<EP_STD_CROP_LEN>(insertModel) > 0)
{
result.msg = "操作成功";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddHeadAndTailRuler 报错 : ", ex);
}
return result;
}
/// <summary>
/// 更新接口
/// </summary>
/// <param name="requestData"></param>
/// <returns></returns>
[HttpPost, Route("hotRoll/updHeadAndTailRuler")]
public RequestEntity UpdHeadAndTailRuler(IList<EP_STD_CROP_LEN> requestData)
{
RequestEntity result = new RequestEntity();
DataTable dtCheck = new DataTable();
StringBuilder strSql = new StringBuilder();
StringBuilder strSqlUpd = new StringBuilder();
DateTime dtNow = DateTime.Now;
requestData[1].UPD_DATE = dtNow.ToString("yyyyMMdd");
requestData[1].UPD_TIME = dtNow.ToString("HHmmss");
#region 参数判断
//非空参数
if (string.IsNullOrEmpty(requestData[1].PLT) || requestData[1].PLT.Length > 2)
{
result.msg = "工厂不可为空且长度不可超过2";
result.code = "0";
return result;
}
if (string.IsNullOrEmpty(requestData[1].STLGRD) || requestData[1].STLGRD.Length > 40)
{
result.msg = "钢种不可为空且长度不可超过40";
result.code = "0";
return result;
}
//可空参数
if (!string.IsNullOrEmpty(requestData[1].THK_MIN))
if (requestData[1].THK_MIN.Length > 6 || !CommonUtils.IsNumber(requestData[1].THK_MIN))
{
result.msg = "轧件厚度下限是长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].THK_MAX))
if (requestData[1].THK_MAX.Length > 6 || !CommonUtils.IsNumber(requestData[1].THK_MAX))
{
result.msg = "轧件厚度上限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].ASROLL_LEN_MIN))
if (requestData[1].ASROLL_LEN_MIN.Length > 8 || !CommonUtils.IsNumber(requestData[1].ASROLL_LEN_MIN))
{
result.msg = "轧件长度下限长度不可超过8的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].ASROLL_LEN_MAX))
if (requestData[1].ASROLL_LEN_MAX.Length > 8 || !CommonUtils.IsNumber(requestData[1].ASROLL_LEN_MAX))
{
result.msg = "轧件长度上限长度不可超过8的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].ASROLL_WID_MIN))
if (requestData[1].ASROLL_WID_MIN.Length > 6 || !CommonUtils.IsNumber(requestData[1].ASROLL_WID_MIN))
{
result.msg = "轧件宽度下限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].ASROLL_WID_MAX))
if (requestData[1].ASROLL_WID_MAX.Length > 6 || !CommonUtils.IsNumber(requestData[1].ASROLL_WID_MAX))
{
result.msg = "轧件宽度上限长度不可超过6的数字";
result.code = "0";
return result;
}
if (!string.IsNullOrEmpty(requestData[1].SIZE_FL))
if (requestData[1].SIZE_FL.Length > 2 || !CommonUtils.IsNumber(requestData[1].SIZE_FL))
{
result.msg = "定尺 单定尺 毛边长度不可超过2的数字";
result.code = "0";
return result;
}
#endregion
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
// 拼接重复check查询语句
//EP_STD_CROP_LEN 表 没有主键
strSql.AppendLine("SELECT * FROM EP_STD_CROP_LEN WHERE 1=1 ");
if (!string.IsNullOrWhiteSpace(requestData[1].PLT)) strSql.AppendLine(" AND PLT = '" + requestData[1].PLT + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].STLGRD)) strSql.AppendLine(" AND STLGRD = '" + requestData[1].STLGRD + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].THK_MIN)) strSql.AppendLine(" AND THK_MIN = '" + requestData[1].THK_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].THK_MAX)) strSql.AppendLine(" AND THK_MAX = '" + requestData[1].THK_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].ASROLL_LEN_MIN)) strSql.AppendLine(" AND ASROLL_LEN_MIN = '" + requestData[1].ASROLL_LEN_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].ASROLL_LEN_MAX)) strSql.AppendLine(" AND ASROLL_LEN_MAX = '" + requestData[1].ASROLL_LEN_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].BASIC_LEN)) strSql.AppendLine(" AND BASIC_LEN = '" + requestData[1].BASIC_LEN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].UNIT_LEN)) strSql.AppendLine(" AND UNIT_LEN = '" + requestData[1].UNIT_LEN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].UNIT_RATIO)) strSql.AppendLine(" AND UNIT_RATIO = '" + requestData[1].UNIT_RATIO + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].SIZE_FL)) strSql.AppendLine(" AND SIZE_FL = '" + requestData[1].SIZE_FL + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].ASROLL_WID_MIN)) strSql.AppendLine(" AND ASROLL_WID_MIN = '" + requestData[1].ASROLL_WID_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].ASROLL_WID_MAX)) strSql.AppendLine(" AND ASROLL_WID_MAX = '" + requestData[1].ASROLL_WID_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].WID_RATIO_MIN)) strSql.AppendLine(" AND WID_RATIO_MIN = '" + requestData[1].WID_RATIO_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].WID_RATIO_MAX)) strSql.AppendLine(" AND WID_RATIO_MAX = '" + requestData[1].WID_RATIO_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[1].SLAB_THK)) strSql.AppendLine(" AND SLAB_THK = '" + requestData[1].SLAB_THK + "'");
// 执行重复查询
dtCheck = db.Query(strSql.ToString());
if (dtCheck.Rows.Count > 0) // 若数据库中存在则返回错误码0并msg提示用户
{
result.msg = "数据已存在,请确认后重试!";
result.code = "0";
}
else
{
strSqlUpd.AppendLine("UPDATE EP_STD_CROP_LEN SET ");
strSqlUpd.AppendLine ( string.Format(" PLT = '{0}' , STLGRD = '{1}' , THK_MIN = '{2}' , THK_MAX = '{3}' , ASROLL_LEN_MIN = '{4}' , ASROLL_LEN_MAX = '{5}' , BASIC_LEN = '{6}' , UNIT_LEN = '{7}' , UNIT_RATIO = '{8}' , SIZE_FL = '{9}' , ASROLL_WID_MIN = '{10}' , ASROLL_WID_MAX = '{11}' , WID_RATIO_MIN = '{12}' , WID_RATIO_MAX = '{13}' , SLAB_THK = '{14}' , UPD_DATE = '{15}',UPD_TIME='{16}',UPD_EMP = '{17}' ",
requestData[1].PLT, requestData[1].STLGRD, requestData[1].THK_MIN, requestData[1].THK_MAX, requestData[1].ASROLL_LEN_MIN, requestData[1].ASROLL_LEN_MAX, requestData[1].BASIC_LEN, requestData[1].UNIT_LEN, requestData[1].UNIT_RATIO, requestData[1].SIZE_FL, requestData[1].ASROLL_WID_MIN, requestData[1].ASROLL_WID_MAX, requestData[1].WID_RATIO_MIN, requestData[1].WID_RATIO_MAX, requestData[1].SLAB_THK, requestData[1].UPD_DATE, requestData[1].UPD_TIME, requestData[1].UPD_EMP));
strSqlUpd.AppendLine("WHERE 1 = 1 ");
if (!string.IsNullOrWhiteSpace(requestData[0].PLT)) strSqlUpd.AppendLine(" AND PLT = '" + requestData[0].PLT + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].STLGRD)) strSqlUpd.AppendLine(" AND STLGRD = '" + requestData[0].STLGRD + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].THK_MIN)) strSqlUpd.AppendLine(" AND THK_MIN = '" + requestData[0].THK_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].THK_MAX)) strSqlUpd.AppendLine(" AND THK_MAX = '" + requestData[0].THK_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].ASROLL_LEN_MIN)) strSqlUpd.AppendLine(" AND ASROLL_LEN_MIN = '" + requestData[0].ASROLL_LEN_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].ASROLL_LEN_MAX)) strSqlUpd.AppendLine(" AND ASROLL_LEN_MAX = '" + requestData[0].ASROLL_LEN_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].BASIC_LEN)) strSqlUpd.AppendLine(" AND BASIC_LEN = '" + requestData[0].BASIC_LEN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].UNIT_LEN)) strSqlUpd.AppendLine(" AND UNIT_LEN = '" + requestData[0].UNIT_LEN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].UNIT_RATIO)) strSqlUpd.AppendLine(" AND UNIT_RATIO = '" + requestData[0].UNIT_RATIO + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].SIZE_FL)) strSqlUpd.AppendLine(" AND SIZE_FL = '" + requestData[0].SIZE_FL + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].ASROLL_WID_MIN)) strSqlUpd.AppendLine(" AND ASROLL_WID_MIN = '" + requestData[0].ASROLL_WID_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].ASROLL_WID_MAX)) strSqlUpd.AppendLine(" AND ASROLL_WID_MAX = '" + requestData[0].ASROLL_WID_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].WID_RATIO_MIN)) strSqlUpd.AppendLine(" AND WID_RATIO_MIN = '" + requestData[0].WID_RATIO_MIN + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].WID_RATIO_MAX)) strSqlUpd.AppendLine(" AND WID_RATIO_MAX = '" + requestData[0].WID_RATIO_MAX + "'");
if (!string.IsNullOrWhiteSpace(requestData[0].SLAB_THK)) strSqlUpd.AppendLine(" AND SLAB_THK = '" + requestData[0].SLAB_THK + "'");
if (db.Execute(strSqlUpd.ToString()) > 0)
{
result.msg = "操作成功";
result.code = "1";
}
else
{
result.msg = "数据未发生改变,请确认后重试!";
result.code = "0";
}
}
return result;
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("UpdHeadAndTailRuler 报错", ex);
return result;
}
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("hotRoll/delHeadAndTailRuler")]
public RequestEntity DelHeadAndTailRuler(EP_STD_CROP_LEN delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
strSql.AppendLine("DELETE FROM EP_STD_CROP_LEN WHERE 1=1 ");
if (!string.IsNullOrWhiteSpace(delModel.PLT)) strSql.AppendLine(" AND PLT = '" + delModel.PLT + "'");
if (!string.IsNullOrWhiteSpace(delModel.STLGRD)) strSql.AppendLine(" AND STLGRD = '" + delModel.STLGRD + "'");
if (!string.IsNullOrWhiteSpace(delModel.THK_MIN)) strSql.AppendLine(" AND THK_MIN = '" + delModel.THK_MIN + "'");
if (!string.IsNullOrWhiteSpace(delModel.THK_MAX)) strSql.AppendLine(" AND THK_MAX = '" + delModel.THK_MAX + "'");
if (!string.IsNullOrWhiteSpace(delModel.ASROLL_LEN_MIN)) strSql.AppendLine(" AND ASROLL_LEN_MIN = '" + delModel.ASROLL_LEN_MIN + "'");
if (!string.IsNullOrWhiteSpace(delModel.ASROLL_LEN_MAX)) strSql.AppendLine(" AND ASROLL_LEN_MAX = '" + delModel.ASROLL_LEN_MAX + "'");
if (!string.IsNullOrWhiteSpace(delModel.BASIC_LEN)) strSql.AppendLine(" AND BASIC_LEN = '" + delModel.BASIC_LEN + "'");
if (!string.IsNullOrWhiteSpace(delModel.UNIT_LEN)) strSql.AppendLine(" AND UNIT_LEN = '" + delModel.UNIT_LEN + "'");
if (!string.IsNullOrWhiteSpace(delModel.UNIT_RATIO)) strSql.AppendLine(" AND UNIT_RATIO = '" + delModel.UNIT_RATIO + "'");
if (!string.IsNullOrWhiteSpace(delModel.SIZE_FL)) strSql.AppendLine(" AND SIZE_FL = '" + delModel.SIZE_FL + "'");
if (!string.IsNullOrWhiteSpace(delModel.ASROLL_WID_MIN)) strSql.AppendLine(" AND ASROLL_WID_MIN = '" + delModel.ASROLL_WID_MIN + "'");
if (!string.IsNullOrWhiteSpace(delModel.ASROLL_WID_MAX)) strSql.AppendLine(" AND ASROLL_WID_MAX = '" + delModel.ASROLL_WID_MAX + "'");
if (!string.IsNullOrWhiteSpace(delModel.WID_RATIO_MIN)) strSql.AppendLine(" AND WID_RATIO_MIN = '" + delModel.WID_RATIO_MIN + "'");
if (!string.IsNullOrWhiteSpace(delModel.WID_RATIO_MAX)) strSql.AppendLine(" AND WID_RATIO_MAX = '" + delModel.WID_RATIO_MAX + "'");
if (!string.IsNullOrWhiteSpace(delModel.SLAB_THK)) strSql.AppendLine(" AND SLAB_THK = '" + delModel.SLAB_THK + "'");
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.Execute(strSql.ToString()); // 执行删除数据操作
result.msg = "操作成功";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelHeadAndTailRuler 报错", ex);
}
return result;
}
}
}