|
|
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年05月07日
|
|
|
* 创建者: 李跃升
|
|
|
* Copy Right: 北京科技大学设计研究院有限公司
|
|
|
********************************************************/
|
|
|
namespace ibk.IPD.Controller.IPD_MR.HotRoll
|
|
|
{
|
|
|
[RoutePrefix("ipd/ipdMr")]
|
|
|
public class AngleRlolWidthRatioController : ApiController
|
|
|
{
|
|
|
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 参数校验
|
|
|
/// </summary>
|
|
|
/// <param name="cncs"></param>
|
|
|
/// /// <param name="result"></param>
|
|
|
/// <returns>是否通过参数校验</returns>
|
|
|
public bool ParameterCalibration(ANGLE_RLOL_WIDTH_RATIO cncs, RequestEntity result)
|
|
|
{
|
|
|
#region 参数判断
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.SLAB_WIDTH))
|
|
|
if (!CommonUtils.IsNumber(cncs.SLAB_WIDTH) || cncs.SLAB_WIDTH.Length > 6)
|
|
|
{
|
|
|
result.msg = "坯料宽度是长度不可超过6的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.SALB_LEN))
|
|
|
if (!CommonUtils.IsNumber(cncs.SALB_LEN) || cncs.SALB_LEN.Length > 6)
|
|
|
{
|
|
|
result.msg = "坯料长度是长度不可超过6的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.ROLLED_WIDTH_MAX))
|
|
|
if (!CommonUtils.IsNumber(cncs.ROLLED_WIDTH_MAX) || cncs.ROLLED_WIDTH_MAX.Length > 6)
|
|
|
{
|
|
|
result.msg = "轧件最大宽度是长度不可超过6的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.BROAD_MAX))
|
|
|
if (!CommonUtils.IsNumber(cncs.BROAD_MAX) || cncs.BROAD_MAX.Length > 4)
|
|
|
{
|
|
|
result.msg = "最大展宽量是长度不可超过6的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.BROAD_RATIO))
|
|
|
if (!CommonUtils.IsNumber(cncs.BROAD_RATIO) || cncs.BROAD_RATIO.Length > 4)
|
|
|
{
|
|
|
result.msg = "展宽比是长度不可超过4的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.SINGLE_WEI_260))
|
|
|
if (!CommonUtils.IsNumber(cncs.SINGLE_WEI_260) || cncs.SINGLE_WEI_260.Length > 5)
|
|
|
{
|
|
|
result.msg = "采用260mm坯料单重是长度不可超过5的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cncs.SINGLE_WEI_320))
|
|
|
if (!CommonUtils.IsNumber(cncs.SINGLE_WEI_320) || cncs.SINGLE_WEI_320.Length > 5)
|
|
|
{
|
|
|
result.msg = "采用320mm坯料单重是长度不可超过5的数字!";
|
|
|
result.code = "0";
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取主键的条件
|
|
|
/// </summary>
|
|
|
/// <param name="primaryKeyEntity"></param>
|
|
|
/// <returns>AND 开头的 主键条件字符串</returns>
|
|
|
public string GetPrimaryKeyString(ANGLE_RLOL_WIDTH_RATIO primaryKeyEntity)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
//if (!string.IsNullOrWhiteSpace(primaryKeyEntity.APLY_ITEM))
|
|
|
//因为主键是自增主键, 所以将判断主键重复换成重复数据判断
|
|
|
|
|
|
strSql.AppendLine(" AND SLAB_WIDTH = '" + primaryKeyEntity.SLAB_WIDTH + "'");
|
|
|
strSql.AppendLine(" AND SALB_LEN = '" + primaryKeyEntity.SALB_LEN + "'");
|
|
|
strSql.AppendLine(" AND ROLLED_WIDTH_MAX = '" + primaryKeyEntity.ROLLED_WIDTH_MAX + "'");
|
|
|
strSql.AppendLine(" AND BROAD_MAX = '" + primaryKeyEntity.BROAD_MAX + "'");
|
|
|
strSql.AppendLine(" AND BROAD_RATIO = '" + primaryKeyEntity.BROAD_RATIO + "'");
|
|
|
strSql.AppendLine(" AND SINGLE_WEI_260 = '" + primaryKeyEntity.SINGLE_WEI_260 + "'");
|
|
|
strSql.AppendLine(" AND SINGLE_WEI_320 = '" + primaryKeyEntity.SINGLE_WEI_320 + "'");
|
|
|
|
|
|
return strSql.ToString();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取主键查询的sql
|
|
|
/// </summary>
|
|
|
/// <param name="checkEntity"></param>
|
|
|
/// <returns>主键查询sql</returns>
|
|
|
public string GetCheckString(ANGLE_RLOL_WIDTH_RATIO checkEntity)
|
|
|
{
|
|
|
string strSql = "SELECT * FROM ANGLE_RLOL_WIDTH_RATIO WHERE 1=1 " + GetPrimaryKeyString(checkEntity);
|
|
|
return strSql;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询接口
|
|
|
/// </summary>
|
|
|
/// <param name="queryArgs"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("hotRoll/getAngleRlolWidthRatio")]
|
|
|
public RequestEntity GetAngleRlolWidthRatio(AngleRlolWidthRatioQueryArgs queryArgs)
|
|
|
{
|
|
|
RequestEntity result = new RequestEntity(); //声明返回参数实体类
|
|
|
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
|
|
|
DataTable dtCheck = new DataTable();
|
|
|
|
|
|
//查询sql
|
|
|
//PK , SLAB_WIDTH , SALB_LEN , ROLLED_WIDTH_MAX , BROAD_MAX , BROAD_RATIO , SINGLE_WEI_260 , SINGLE_WEI_320
|
|
|
strSql.AppendLine("SELECT PK , SLAB_WIDTH , SALB_LEN , ROLLED_WIDTH_MAX , BROAD_MAX , BROAD_RATIO , SINGLE_WEI_260 , SINGLE_WEI_320 ,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 ANGLE_RLOL_WIDTH_RATIO WHERE 1 = 1 ");
|
|
|
if (queryArgs != null)
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_SLAB_WIDTH) && CommonUtils.IsNumber(queryArgs.START_SLAB_WIDTH)) strSql.AppendLine(" AND SLAB_WIDTH >=" + queryArgs.START_SLAB_WIDTH);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_SLAB_WIDTH) && CommonUtils.IsNumber(queryArgs.END_SLAB_WIDTH)) strSql.AppendLine(" AND SLAB_WIDTH <=" + queryArgs.END_SLAB_WIDTH);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_SALB_LEN) && CommonUtils.IsNumber(queryArgs.START_SALB_LEN)) strSql.AppendLine(" AND SALB_LEN >=" + queryArgs.START_SALB_LEN);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_SALB_LEN) && CommonUtils.IsNumber(queryArgs.END_SALB_LEN)) strSql.AppendLine(" AND SALB_LEN <=" + queryArgs.END_SALB_LEN);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_ROLLED_WIDTH_MAX) && CommonUtils.IsNumber(queryArgs.START_ROLLED_WIDTH_MAX)) strSql.AppendLine(" AND ROLLED_WIDTH_MAX >=" + queryArgs.START_ROLLED_WIDTH_MAX);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_ROLLED_WIDTH_MAX) && CommonUtils.IsNumber(queryArgs.END_ROLLED_WIDTH_MAX)) strSql.AppendLine(" AND ROLLED_WIDTH_MAX <=" + queryArgs.END_ROLLED_WIDTH_MAX);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_BROAD_MAX) && CommonUtils.IsNumber(queryArgs.START_BROAD_MAX)) strSql.AppendLine(" AND BROAD_MAX >=" + queryArgs.START_BROAD_MAX);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_BROAD_MAX) && CommonUtils.IsNumber(queryArgs.END_BROAD_MAX)) strSql.AppendLine(" AND BROAD_MAX <=" + queryArgs.END_BROAD_MAX);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_BROAD_RATIO) && CommonUtils.IsNumber(queryArgs.START_BROAD_RATIO)) strSql.AppendLine(" AND BROAD_RATIO >=" + queryArgs.START_BROAD_RATIO);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_BROAD_RATIO) && CommonUtils.IsNumber(queryArgs.END_BROAD_RATIO)) strSql.AppendLine(" AND BROAD_RATIO <=" + queryArgs.END_BROAD_RATIO);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_SINGLE_WEI_260) && CommonUtils.IsNumber(queryArgs.START_SINGLE_WEI_260)) strSql.AppendLine(" AND SINGLE_WEI_260 >=" + queryArgs.START_SINGLE_WEI_260);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_SINGLE_WEI_260) && CommonUtils.IsNumber(queryArgs.END_SINGLE_WEI_260)) strSql.AppendLine(" AND SINGLE_WEI_260 <=" + queryArgs.END_SINGLE_WEI_260);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.START_SINGLE_WEI_320) && CommonUtils.IsNumber(queryArgs.START_SINGLE_WEI_320)) strSql.AppendLine(" AND SINGLE_WEI_320 >=" + queryArgs.START_SINGLE_WEI_320);
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.END_SINGLE_WEI_320) && CommonUtils.IsNumber(queryArgs.END_SINGLE_WEI_320)) strSql.AppendLine(" AND SINGLE_WEI_320 <=" + queryArgs.END_SINGLE_WEI_320);
|
|
|
|
|
|
|
|
|
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 INS_DATE DESC ");
|
|
|
dtCheck = db.Query(strSql.ToString());
|
|
|
result.data = db.Query<ANGLE_RLOL_WIDTH_RATIO>(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("GetAngleRlolWidthRatio 报错", ex);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加接口
|
|
|
/// </summary>
|
|
|
/// <param name="insertModel"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("hotRoll/addAngleRlolWidthRatio")]
|
|
|
public RequestEntity AddAngleRlolWidthRatio(ANGLE_RLOL_WIDTH_RATIO insertModel)
|
|
|
{
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
try
|
|
|
{
|
|
|
#region 参数判断
|
|
|
if (!ParameterCalibration(insertModel, result))
|
|
|
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<ANGLE_RLOL_WIDTH_RATIO>(insertModel) > 0)
|
|
|
{
|
|
|
result.msg = "操作成功";
|
|
|
result.code = "1";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.msg = "数据库错误!";
|
|
|
result.code = "0";
|
|
|
logger.Error("AddAngleRlolWidthRatio 报错 : ", ex);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新接口
|
|
|
/// </summary>
|
|
|
/// <param name="requestData"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("hotRoll/updAngleRlolWidthRatio")]
|
|
|
public RequestEntity UpdAngleRlolWidthRatio(IList<ANGLE_RLOL_WIDTH_RATIO> 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 参数判断
|
|
|
if (!ParameterCalibration(requestData[1], result))
|
|
|
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
|
|
|
{
|
|
|
//更新哪些字段
|
|
|
// SLAB_WIDTH , SALB_LEN , ROLLED_WIDTH_MAX , BROAD_MAX , BROAD_RATIO , SINGLE_WEI_260 , SINGLE_WEI_320
|
|
|
if (db.Execute("UPDATE ANGLE_RLOL_WIDTH_RATIO SET " + string.Format(" SLAB_WIDTH = '{0}' , SALB_LEN = '{1}' , ROLLED_WIDTH_MAX = '{2}' ,BROAD_MAX = '{3}' ,BROAD_RATIO = '{4}' ,SINGLE_WEI_260 = '{5}' ,SINGLE_WEI_320 = '{6}' , UPD_DATE = '{7}' , UPD_TIME='{8}',UPD_EMP = '{9}' WHERE 1 = 1 ",
|
|
|
requestData[1].SLAB_WIDTH, requestData[1].SALB_LEN, requestData[1].ROLLED_WIDTH_MAX, requestData[1].BROAD_MAX, requestData[1].BROAD_RATIO, requestData[1].SINGLE_WEI_260, requestData[1].SINGLE_WEI_320, requestData[1].UPD_DATE, requestData[1].UPD_TIME, requestData[1].UPD_EMP) +
|
|
|
//根据主键字段可以确定唯一数据即要修改的数据
|
|
|
string.Format(" AND PK = {0}", requestData[0].PK)) > 0)
|
|
|
{
|
|
|
result.msg = "操作成功";
|
|
|
result.code = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.msg = "数据未发生改变,请确认后重试!";
|
|
|
result.code = "0";
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
result.msg = "数据库错误!";
|
|
|
result.code = "0";
|
|
|
logger.Error("UpdAngleRlolWidthRatio 报错", ex);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除接口
|
|
|
/// </summary>
|
|
|
/// <param name="delModel"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost, Route("hotRoll/delAngleRlolWidthRatio")]
|
|
|
public RequestEntity DelAngleRlolWidthRatio(ANGLE_RLOL_WIDTH_RATIO delModel)
|
|
|
{
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
strSql.AppendLine("DELETE FROM ANGLE_RLOL_WIDTH_RATIO WHERE 1=1 AND");
|
|
|
strSql.AppendLine(string.Format("PK = {0}", delModel.PK));
|
|
|
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("DelAngleRlolWidthRatio 报错", ex);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|