|
|
|
|
using ibk.IPD.Common;
|
|
|
|
|
using ibk.IPD.Entity;
|
|
|
|
|
using ibk.IPD.Entity.IPD_PS.QueryArgs;
|
|
|
|
|
using ibk.IPD.Entity.IPD_MR.EquipmentMgt.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;
|
|
|
|
|
using ibk.IPD.Entity.IPD_PS;
|
|
|
|
|
/********************************************************
|
|
|
|
|
* 简 介:设备能力及工序时间维护
|
|
|
|
|
* 探伤标准后端接口
|
|
|
|
|
* 版本号:V1.0
|
|
|
|
|
* 日 期:2022年06月29日
|
|
|
|
|
* 创建者: SunH
|
|
|
|
|
* Copy Right: 北京科技大学设计研究院有限公司
|
|
|
|
|
********************************************************/
|
|
|
|
|
namespace ibk.IPD.Controller.IPD_MR.EquipmentMgt
|
|
|
|
|
{
|
|
|
|
|
[RoutePrefix("ipd/ipdMr")]
|
|
|
|
|
public class TbUstFlController : 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(TB_UST_FL cncs, RequestEntity result)
|
|
|
|
|
{
|
|
|
|
|
#region 参数判断
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(cncs.FL_KND) || CommonUtils.GetLength(cncs.FL_KND) >100)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "探伤种类不可为空且长度不可超过100!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(cncs.FL_CD) || CommonUtils.GetLength(cncs.FL_CD) > 100)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "探伤标准不可为空且长度不可超过100!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(cncs.FL_LEV) || CommonUtils.GetLength(cncs.FL_LEV) > 100)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "探伤等级不可为空且长度不可超过100!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(cncs.FL_CON) || CommonUtils.GetLength(cncs.FL_CON) > 2000)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "备注不可为空且长度不可超过2000!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="queryArgs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("getTbUstFl")]
|
|
|
|
|
public RequestEntity GetTbUstFl(TbUstFlQueryArgs queryArgs)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity(); //声明返回参数实体类
|
|
|
|
|
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
|
|
|
|
|
DataTable dtCheck = new DataTable();
|
|
|
|
|
|
|
|
|
|
//查询
|
|
|
|
|
//PK , PLT , PLATE_THK_MIN , PLATE_THK_MAX , COILING_TIME
|
|
|
|
|
strSql.AppendLine("SELECT FL_KND, FL_CD, FL_LEV, FL_CON, ID,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_UST_FL WHERE 1 = 1 ");
|
|
|
|
|
if (queryArgs != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.FL_KND)) strSql.AppendLine(" AND FL_KND LIKE '%" + queryArgs.FL_KND + "%'");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.FL_CD)) strSql.AppendLine(" AND FL_CD LIKE '%" + queryArgs.FL_CD + "%'");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryArgs.FL_LEV)) strSql.AppendLine(" AND FL_LEV LIKE '%" + queryArgs.FL_LEV + "%'");
|
|
|
|
|
|
|
|
|
|
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 || INS_TIME ,'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 || INS_TIME ,'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<TB_UST_FL>(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("addTbUstFl")]
|
|
|
|
|
public RequestEntity AddTbUstFl(TB_UST_FL 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"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (db.Insert<TB_UST_FL>(insertModel) > 0)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "操作成功";
|
|
|
|
|
result.code = "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据库错误!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
logger.Error("AddTbUstFl 报错 : ", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="requestData"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("updTbUstFl")]
|
|
|
|
|
public RequestEntity UpdTbUstFl(IList<TB_UST_FL> 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"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//更新哪些字段
|
|
|
|
|
//PLT , PLATE_THK_MIN , PLATE_THK_MAX , COILING_TIME
|
|
|
|
|
if (db.Execute("UPDATE TB_UST_FL SET " + string.Format(" FL_KND = '{0}' , FL_CD = '{1}' , FL_LEV = '{2}' ,FL_CON = '{3}' , UPD_DATE = '{4}' , UPD_TIME='{5}',UPD_EMP = '{6}' WHERE 1 = 1 ",
|
|
|
|
|
requestData[1].FL_KND, requestData[1].FL_CD, requestData[1].FL_LEV, requestData[1].FL_CON, requestData[1].UPD_DATE, requestData[1].UPD_TIME, requestData[1].UPD_EMP) +
|
|
|
|
|
//根据主键字段可以确定唯一数据即要修改的数据
|
|
|
|
|
string.Format(" AND ID = {0}", requestData[0].ID)) > 0)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "操作成功";
|
|
|
|
|
result.code = "1";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据未发生改变,请确认后重试!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "数据库错误!";
|
|
|
|
|
result.code = "0";
|
|
|
|
|
logger.Error("UpdTbUstFl 报错", ex);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="delModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("delTbUstFl")]
|
|
|
|
|
public RequestEntity DelTbUstFl(TB_UST_FL delModel)
|
|
|
|
|
{
|
|
|
|
|
RequestEntity result = new RequestEntity();
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
strSql.AppendLine("DELETE FROM TB_UST_FL WHERE 1=1 AND");
|
|
|
|
|
strSql.AppendLine(string.Format("ID = {0}", delModel.ID));
|
|
|
|
|
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("DelTbUstFl 报错", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|