|
|
|
|
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月11日
|
|
|
|
|
* 创建者: 李跃升
|
|
|
|
|
* Copy Right: 北京科技大学设计研究院有限公司
|
|
|
|
|
********************************************************/
|
|
|
|
|
namespace ibk.IPD.Controller.IPD_MR.HotRoll
|
|
|
|
|
{
|
|
|
|
|
[RoutePrefix("ipd/ipdMr")]
|
|
|
|
|
public class PlateWidController : ApiController
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryArgs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("hotRoll/getPlateWid")]
|
|
|
|
|
public RequestEntity GetPlateWid(EpPlatewidStdQueryArgs queryArgs)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity(); //声明返回参数实体类
|
|
|
|
|
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
|
|
|
|
|
DataTable dtCheck = new DataTable();
|
|
|
|
|
|
|
|
|
|
//查询语句日期时间拼接起来格式化成yyyy-mm-dd hh24:mi:ss
|
|
|
|
|
//PLT , PROD_CD , TRIM_FL , THK_MIN , THK_MAX , WID_MIN , WID_MAX , WID_MARGIN , WID_MARGIN_2 , WID_MARGIN_3 , STLGRD , SFKP
|
|
|
|
|
strSql.AppendLine("SELECT t.PLT ,t. PROD_CD ,t.TRIM_FL , t.THK_MIN , t.THK_MAX , t.WID_MIN , t.WID_MAX , t.WID_MARGIN , t.WID_MARGIN_2 , t.WID_MARGIN_3, t.STLGRD , t.SFKP , to_date(t.UPD_DATE || t.UPD_TIME ,'yyyy-mm-dd hh24:mi:ss') as UPD_DATE, t.UPD_TIME,t.UPD_EMP,to_date(t.INS_DATE || t.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') as INS_DATE,t.INS_TIME,t.INS_EMP,qnc.steel_grd_detail FROM EP_PLATEWID_STD t left join qp_nisco_chmc qnc on t.stlgrd=qnc.stlgrd WHERE 1 = 1 ");
|
|
|
|
|
if (queryArgs != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.PLT)) strSql.AppendLine(" AND PLT LIKE '%" + queryArgs.PLT + "%'");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.PROD_CD)) strSql.AppendLine(" AND PROD_CD LIKE '%" + queryArgs.PROD_CD + "%'");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.TRIM_FL)) strSql.AppendLine(" AND TRIM_FL LIKE '%" + queryArgs.TRIM_FL + "%'");
|
|
|
|
|
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.WID_MIN) && CommonUtils.IsNumber(queryArgs.WID_MIN)) strSql.AppendLine(" AND WID_MIN >=" + queryArgs.WID_MIN);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.WID_MAX) && CommonUtils.IsNumber(queryArgs.WID_MAX)) strSql.AppendLine(" AND WID_MAX <=" + queryArgs.WID_MAX);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID_MARGIN) && CommonUtils.IsNumber(queryArgs.START_WID_MARGIN)) strSql.AppendLine(" AND WID_MARGIN >=" + queryArgs.START_WID_MARGIN);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID_MARGIN) && CommonUtils.IsNumber(queryArgs.END_WID_MARGIN)) strSql.AppendLine(" AND WID_MARGIN <=" + queryArgs.END_WID_MARGIN);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID_MARGIN_2) && CommonUtils.IsNumber(queryArgs.START_WID_MARGIN_2)) strSql.AppendLine(" AND WID_MARGIN_2 >=" + queryArgs.START_WID_MARGIN_2);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID_MARGIN_2) && CommonUtils.IsNumber(queryArgs.END_WID_MARGIN_2)) strSql.AppendLine(" AND WID_MARGIN_2 <=" + queryArgs.END_WID_MARGIN_2);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID_MARGIN_3) && CommonUtils.IsNumber(queryArgs.START_WID_MARGIN_3)) strSql.AppendLine(" AND WID_MARGIN_3 >=" + queryArgs.START_WID_MARGIN_3);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID_MARGIN_3) && CommonUtils.IsNumber(queryArgs.END_WID_MARGIN_3)) strSql.AppendLine(" AND WID_MARGIN_3 <=" + queryArgs.END_WID_MARGIN_3);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.STLGRD)) strSql.AppendLine(" AND STLGRD LIKE '%" + queryArgs.STLGRD + "%'");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.SFKP)) strSql.AppendLine(" AND SFKP LIKE '%" + queryArgs.SFKP + "%'");
|
|
|
|
|
|
|
|
|
|
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 ");
|
|
|
|
|
dtCheck = db.Query(strSql.ToString());
|
|
|
|
|
result.data = db.Query<EP_PLATEWID_STD>(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("GetPlateWid 报错", ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="insertModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("hotRoll/addPlateWid")]
|
|
|
|
|
public RequestEntity AddPlateWid(EP_PLATEWID_STD insertModel)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 参数判断
|
|
|
|
|
//非空参数
|
|
|
|
|
//主键
|
|
|
|
|
//PLT , PROD_CD , TRIM_FL , THK_MIN , THK_MAX , WID_MIN , WID_MAX ,STLGRD
|
|
|
|
|
//非主键
|
|
|
|
|
//WID_MARGIN , WID_MARGIN_2 , WID_MARGIN_3 ,SFKP
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.PLT) || insertModel.PLT.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "轧钢工厂不可为空且长度不可超过2!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.PROD_CD) || insertModel.PROD_CD.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "产品形态不可为空且长度不可超过2!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.TRIM_FL) || insertModel.TRIM_FL.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "切边方式不可为空且长度不可超过1!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.THK_MIN) || !CommonUtils.IsNumber(insertModel.THK_MIN) || insertModel.THK_MIN.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "厚度下限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.THK_MAX) || !CommonUtils.IsNumber(insertModel.THK_MAX) || insertModel.THK_MAX.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "厚度上限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.WID_MIN) || !CommonUtils.IsNumber(insertModel.WID_MIN) || insertModel.WID_MIN.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "宽度下限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.WID_MAX) || !CommonUtils.IsNumber(insertModel.WID_MAX) || insertModel.WID_MAX.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "宽度上限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(insertModel.WID_MARGIN))
|
|
|
|
|
if (!CommonUtils.IsNumber(insertModel.WID_MARGIN) || insertModel.WID_MARGIN.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "单排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(insertModel.WID_MARGIN_2))
|
|
|
|
|
if (!CommonUtils.IsNumber(insertModel.WID_MARGIN_2) || insertModel.WID_MARGIN_2.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "双排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(insertModel.WID_MARGIN_3))
|
|
|
|
|
if (!CommonUtils.IsNumber(insertModel.WID_MARGIN_3) || insertModel.WID_MARGIN_3.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "三排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(insertModel.STLGRD) || insertModel.STLGRD.Length > 11)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "钢种不可为空且长度不可超过11!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(insertModel.SFKP))
|
|
|
|
|
if ((!"Y".Equals(insertModel.SFKP) && !"N".Equals(insertModel.SFKP)))
|
|
|
|
|
{
|
|
|
|
|
result.msg = "是否开坯只能是 Y 或 N!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
insertModel.INS_DATE = dtNow.ToString("yyyyMMdd");
|
|
|
|
|
insertModel.INS_TIME = dtNow.ToString("HHmmss");
|
|
|
|
|
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
// 执行主键重复查询
|
|
|
|
|
DataTable dtCheck = db.Query(GetCheckString(insertModel));
|
|
|
|
|
|
|
|
|
|
if (dtCheck.Rows.Count > 0) // 若数据库中存在则返回错误码0并msg提示用户
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据已存在,请确认后重试!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (db.Insert<EP_PLATEWID_STD>(insertModel) > 0)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "操作成功";
|
|
|
|
|
result.code = "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据库错误!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
logger.Error("AddPlateWid 报错 : ", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestData"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("hotRoll/updPlateWid")]
|
|
|
|
|
public RequestEntity UpdPlateWid(IList<EP_PLATEWID_STD> requestData)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
|
|
DataTable dtCheck = new DataTable();
|
|
|
|
|
DataTable dtCheckSelf = new DataTable();
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
StringBuilder strSqlSelf = new StringBuilder();
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
requestData[1].UPD_DATE = dtNow.ToString("yyyyMMdd");
|
|
|
|
|
requestData[1].UPD_TIME = dtNow.ToString("HHmmss");
|
|
|
|
|
|
|
|
|
|
#region 参数判断
|
|
|
|
|
//非空参数
|
|
|
|
|
//主键
|
|
|
|
|
//PLT , PROD_CD , TRIM_FL , THK_MIN , THK_MAX , WID_MIN , WID_MAX ,STLGRD
|
|
|
|
|
//非主键
|
|
|
|
|
//WID_MARGIN , WID_MARGIN_2 , WID_MARGIN_3 ,SFKP
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].PLT) || requestData[1].PLT.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "轧钢工厂不可为空且长度不可超过2!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].PROD_CD) || requestData[1].PROD_CD.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "产品形态不可为空且长度不可超过2!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].TRIM_FL) || requestData[1].TRIM_FL.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "切边方式不可为空且长度不可超过1!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].THK_MIN) || !CommonUtils.IsNumber(requestData[1].THK_MIN) || requestData[1].THK_MIN.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "厚度下限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].THK_MAX) || !CommonUtils.IsNumber(requestData[1].THK_MAX) || requestData[1].THK_MAX.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "厚度上限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].WID_MIN) || !CommonUtils.IsNumber(requestData[1].WID_MIN) || requestData[1].WID_MIN.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "宽度下限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].WID_MAX) || !CommonUtils.IsNumber(requestData[1].WID_MAX) || requestData[1].WID_MAX.Length > 6)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "宽度上限是不可为空且长度不可超过6的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(requestData[1].WID_MARGIN))
|
|
|
|
|
if (!CommonUtils.IsNumber(requestData[1].WID_MARGIN) || requestData[1].WID_MARGIN.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "单排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(requestData[1].WID_MARGIN_2))
|
|
|
|
|
if (!CommonUtils.IsNumber(requestData[1].WID_MARGIN_2) || requestData[1].WID_MARGIN_2.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "双排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(requestData[1].WID_MARGIN_3))
|
|
|
|
|
if (!CommonUtils.IsNumber(requestData[1].WID_MARGIN_3) || requestData[1].WID_MARGIN_3.Length > 8)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "三排列宽度余量是长度不可超过8的数字!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(requestData[1].STLGRD) || requestData[1].STLGRD.Length > 11)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "钢种不可为空且长度不可超过11!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(requestData[1].SFKP))
|
|
|
|
|
if ((!"Y".Equals(requestData[1].SFKP) && !"N".Equals(requestData[1].SFKP)))
|
|
|
|
|
{
|
|
|
|
|
result.msg = "是否开坯只能是 Y 或 N!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 执行主键重复查询
|
|
|
|
|
dtCheck = db.Query(GetCheckString(requestData[1]));
|
|
|
|
|
dtCheckSelf = db.Query(GetCheckString(requestData[0]));
|
|
|
|
|
|
|
|
|
|
if (dtCheck.Rows.Count > 0 && !CommonUtils.CompareDataTable(dtCheck, dtCheckSelf)) // 若数据库中存在则返回错误码0并msg提示用户
|
|
|
|
|
{
|
|
|
|
|
result.msg = "主键数据已存在,请确认后重试!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//更新哪些字段
|
|
|
|
|
//PLT , PROD_CD , TRIM_FL , THK_MIN , THK_MAX , WID_MIN , WID_MAX ,STLGRD
|
|
|
|
|
//WID_MARGIN , WID_MARGIN_2 , WID_MARGIN_3 ,SFKP
|
|
|
|
|
if (db.Execute("UPDATE EP_PLATEWID_STD SET " + string.Format(" PLT = '{0}' , PROD_CD = '{1}' , TRIM_FL = '{2}' , THK_MIN = '{3}' , THK_MAX = '{4}',WID_MIN = '{5}' ,WID_MAX = '{6}' , STLGRD = '{7}' , WID_MARGIN = '{8}' , WID_MARGIN_2 = '{9}' , WID_MARGIN_3 = '{10}' , SFKP = '{11}',UPD_DATE = '{12}',UPD_TIME='{13}',UPD_EMP = '{14}' WHERE 1 = 1 ",
|
|
|
|
|
requestData[1].PLT, requestData[1].PROD_CD, requestData[1].TRIM_FL, requestData[1].THK_MIN, requestData[1].THK_MAX, requestData[1].WID_MIN, requestData[1].WID_MAX, requestData[1].STLGRD, requestData[1].WID_MARGIN, requestData[1].WID_MARGIN_2, requestData[1].WID_MARGIN_3, requestData[1].SFKP, requestData[1].UPD_DATE, requestData[1].UPD_TIME, requestData[1].UPD_EMP) +
|
|
|
|
|
//根据主键字段可以确定唯一数据即要修改的数据
|
|
|
|
|
GetPrimaryKeyString(requestData[0])) > 0)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "操作成功";
|
|
|
|
|
result.code = "1";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据未发生改变,请确认后重试!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据库错误!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
logger.Error("UpdPlateWid 报错", ex);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="delModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("hotRoll/delPlateWid")]
|
|
|
|
|
public RequestEntity DelPlateWid(EP_PLATEWID_STD delModel)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//PLT , PROD_CD , TRIM_FL , THK_MIN , THK_MAX , WID_MIN , WID_MAX ,STLGRD
|
|
|
|
|
strSql.AppendLine("DELETE FROM EP_PLATEWID_STD WHERE 1=1 ");
|
|
|
|
|
strSql.AppendLine(GetPrimaryKeyString(delModel));
|
|
|
|
|
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("DelPlateWid 报错", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取主键的条件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="primaryKeyEntity"></param>
|
|
|
|
|
/// <returns>AND 开头的 主键条件字符串</returns>
|
|
|
|
|
public string GetPrimaryKeyString(EP_PLATEWID_STD primaryKeyEntity)
|
|
|
|
|
{
|
|
|
|
|
return string.Format("AND PLT = '{0}' AND PROD_CD = '{1}' AND TRIM_FL = '{2}' AND THK_MIN = '{3}' AND THK_MAX = '{4}' AND WID_MIN = '{5}' AND WID_MAX = '{6}'AND STLGRD = '{7}'",
|
|
|
|
|
primaryKeyEntity.PLT, primaryKeyEntity.PROD_CD, primaryKeyEntity.TRIM_FL, primaryKeyEntity.THK_MIN, primaryKeyEntity.THK_MAX, primaryKeyEntity.WID_MIN, primaryKeyEntity.WID_MAX, primaryKeyEntity.STLGRD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取主键查询的sql
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="checkEntity"></param>
|
|
|
|
|
/// <returns>主键查询sql</returns>
|
|
|
|
|
public string GetCheckString(EP_PLATEWID_STD checkEntity)
|
|
|
|
|
{
|
|
|
|
|
string strSql = "SELECT PLT FROM EP_PLATEWID_STD WHERE 1=1 " + GetPrimaryKeyString(checkEntity);
|
|
|
|
|
return strSql;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|