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年07月8日 * 创建者: LiZhuo * Copy Right: 北京科技大学设计研究院有限公司 ********************************************************/ namespace ibk.IPD.Controller.IPD_MR.EquipmentMgt { [RoutePrefix("ipd/ipdMr")] public class TbOrdSpeController : ApiController { private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// 参数校验 /// /// /// /// /// 是否通过参数校验 public bool ParameterCalibration(TB_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 不替代订单 /// /// 查询接口 /// /// /// [HttpPost, Route("getTbOrdSpe")] public RequestEntity GetTbOrdSpe(TB_ORD_SPE query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT ORD_NO, ORD_ITEM, ORD_FLG, 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,IS_FULL,IS_PART FROM TB_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 + "%'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = db.Query(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; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbOrdSpe")] public RequestEntity AddTbOrdSpe(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (TB_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.IS_FULL = model.IS_FULL.Trim(); model.IS_PART = model.IS_PART.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(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; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbOrdSpeOne")] public RequestEntity AddTbOrdSpeOne(TB_ORD_SPE model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("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 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.IS_FULL = model.IS_FULL.Trim(); model.IS_PART = model.IS_PART.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(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; } /// /// 修改接口 /// /// /// [HttpPost, Route("UpdateTbOrdSpeOne")] public RequestEntity UpdateTbOrdSpeOne(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("Update TB_ORD_SPE "); //strSql.AppendLine(string.Format("set IS_FULL = '{0}',IS_PART = '{1}' where ORD_NO = '{2}' and ORD_ITEM = '{3}' ", model[1].IS_FULL, model[1].IS_PART, model[1].ORD_NO, model[1].ORD_ITEM)); strSql.AppendLine(string.Format("set IS_FULL = '{0}',IS_PART = '{1}',ORD_NO='{4}',ORD_ITEM='{5}',ORD_CON='{6}' where ORD_NO = '{2}' and ORD_ITEM = '{3}' ", model[1].IS_FULL, model[1].IS_PART, model[1].ORD_NO, model[1].ORD_ITEM, model[1].ORD_NO, model[1].ORD_ITEM, model[1].ORD_CON)); 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; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelTbOrdSpe")] public RequestEntity DelTbOrdSpe(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM TB_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; } #endregion #region 特殊S订单 /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbSpecialOrd")] public RequestEntity AddTbSpecialOrd(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (TB_SPECIAL_ORD 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.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"); model.IS_FULL = model.IS_FULL.Trim(); model.IS_PART = model.IS_PART.Trim(); if (db.Insert(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("AddTbSpecialOrd 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbSpecialOrdOne")] public RequestEntity AddTbSpecialOrdOne(TB_SPECIAL_ORD model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); #region 参数判断 if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM)) { db.Rollback(); return result; } #endregion model.ORD_NO = model.ORD_NO.Trim(); model.ORD_ITEM = model.ORD_ITEM.Trim(); //model.ORD_FLG = model.ORD_FLG.Trim(); if (!string.IsNullOrEmpty(model.ORD_CON)) { model.ORD_CON = model.ORD_CON.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.IS_FULL = model.IS_FULL.Trim(); model.IS_PART = model.IS_PART.Trim(); if (db.Insert(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("AddTbSpecialOrdOne 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelTbSpecialOrd")] public RequestEntity DelTbSpecialOrd(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM TB_SPECIAL_ORD 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("DelTbSpecialOrd 报错", ex); } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("UpdateTbSpecialOrd")] public RequestEntity UpdateTbSpecialOrd(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("Update TB_SPECIAL_ORD "); strSql.AppendLine(string.Format("set ORD_FLG = '{0}',IS_FULL='{3}',IS_PART='{4}',ORD_CON='{5}' where ORD_NO = '{1}' and ORD_ITEM = '{2}' ", model[1].ORD_FLG, model[1].ORD_NO, model[1].ORD_ITEM, model[1].IS_FULL, model[1].IS_PART, model[1].ORD_CON)); 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("UpdateTbSpecialOrd 报错", ex); } return result; } /// /// 查询接口 /// /// /// [HttpPost, Route("GetTbSpecialOrd")] public RequestEntity GetTbSpecialOrd(TB_SPECIAL_ORD query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT IS_FULL,IS_PART,ORD_NO, ORD_ITEM, ORD_FLG, ORD_CON, TO_CHAR( to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as INS_DATE ,INS_TIME,INS_EMP , TO_CHAR( to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as UPD_DATE, UPD_TIME,UPD_EMP FROM TB_SPECIAL_ORD 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 + "%'"); if (!string.IsNullOrWhiteSpace(query.ORD_FLG)) strSql.AppendLine(" AND ORD_FLG = '" + query.ORD_FLG + "'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = dtCheck; 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("GetTbSpecialOrd 报错", ex); } return result; } #endregion #region 特殊订单 /// /// 添加接口 /// /// /// [HttpPost, Route("AddSpecialOrd")] public RequestEntity AddSpecialOrd(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (SPECIAL_ORD 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.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(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("AddTbSpecialOrd 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddSpecialOrdOne")] public RequestEntity AddSpecialOrdOne(SPECIAL_ORD model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); #region 参数判断 if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM)) { db.Rollback(); return result; } #endregion model.ORD_NO = model.ORD_NO.Trim(); model.ORD_ITEM = model.ORD_ITEM.Trim(); //model.ORD_FLG = model.ORD_FLG.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(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("AddSpecialOrdOne 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelSpecialOrd")] public RequestEntity DelSpecialOrd(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM SPECIAL_ORD 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("DelTbSpecialOrd 报错", ex); } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("UpdateSpecialOrd")] public RequestEntity UpdateSpecialOrd(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("Update SPECIAL_ORD "); strSql.AppendLine(string.Format("set ORD_NO = '{0}', ORD_ITEM= '{1}',ORD_CON='{2}' where ORD_NO = '{3}' and ORD_ITEM = '{4}' ", model[1].ORD_NO, model[1].ORD_ITEM, model[1].ORD_CON, model[0].ORD_NO, model[0].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("UpdateTbSpecialOrd 报错", ex); } return result; } /// /// 查询接口 /// /// /// [HttpPost, Route("GetSpecialOrd")] public RequestEntity GetSpecialOrd(SPECIAL_ORD query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT ORD_NO, ORD_ITEM, ORD_CON, TO_CHAR( to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as INS_DATE ,INS_TIME,INS_EMP , TO_CHAR( to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as UPD_DATE, UPD_TIME,UPD_EMP FROM SPECIAL_ORD 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 + "%'"); //if (!string.IsNullOrWhiteSpace(query.ORD_FLG)) // strSql.AppendLine(" AND ORD_FLG = '" + query.ORD_FLG + "'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = dtCheck; 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("GetSpecialOrd 报错", ex); } return result; } #endregion #region 特殊订单——标准号 /// /// 添加接口 /// /// /// [HttpPost, Route("AddSpecialstdspec")] public RequestEntity AddSpecialstdspec(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (SPECIAL_STDSPEC 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.STDSPEC = model.STDSPEC.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(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("AddSpecialstdspec 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddSpecialstdspecOne")] public RequestEntity AddSpecialstdspecOne(SPECIAL_STDSPEC model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); #region 参数判断 //if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM)) //{ // db.Rollback(); // return result; //} #endregion model.STDSPEC = model.STDSPEC.Trim(); //model.ORD_ITEM = model.ORD_ITEM.Trim(); //model.ORD_FLG = model.ORD_FLG.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(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("AddSpecialstdspecOne 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelSpecialstdspec")] public RequestEntity DelSpecialstdspec(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM SPECIAL_STDSPEC WHERE 1=1 "); strSql.AppendLine(string.Format("AND STDSPEC = '{0}' ", model.STDSPEC)); 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("DelTbSpecialOrd 报错", ex); } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("UpdateSpecialstdspec")] public RequestEntity UpdateSpecialstdspec(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("Update SPECIAL_STDSPEC "); strSql.AppendLine(string.Format("set STDSPEC = '{0}',ORD_CON='{1}' where STDSPEC = '{2}' ", model[1].STDSPEC, model[1].ORD_CON, model[0].STDSPEC)); 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("UpdateSpecialstdspec 报错", ex); } return result; } /// /// 查询接口 /// /// /// [HttpPost, Route("GetSpecialstdspec")] public RequestEntity GetSpecialstdspec(SPECIAL_STDSPEC query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT STDSPEC, ORD_CON, TO_CHAR( to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as INS_DATE ,INS_TIME,INS_EMP , TO_CHAR( to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as UPD_DATE, UPD_TIME,UPD_EMP FROM SPECIAL_STDSPEC WHERE 1 = 1 "); if (query != null) { if (!string.IsNullOrWhiteSpace(query.STDSPEC)) strSql.AppendLine(" AND STDSPEC LIKE '%" + query.STDSPEC + "%'"); //if (!string.IsNullOrWhiteSpace(query.ORD_ITEM)) // strSql.AppendLine(" AND ORD_ITEM LIKE '%" + query.ORD_ITEM + "%'"); //if (!string.IsNullOrWhiteSpace(query.ORD_FLG)) // strSql.AppendLine(" AND ORD_FLG = '" + query.ORD_FLG + "'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = dtCheck; 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("GetSpecialsedspec 报错", ex); } return result; } #endregion #region 牌号价格 /// /// 添加接口 /// /// /// [HttpPost, Route("AddBrandPrice")] public RequestEntity AddBrandPrice(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (TB_BRAND_PRICE 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.STDSPEC = model.STDSPEC.Trim(); model.PRICE = model.PRICE.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(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("AddBrandPrice 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddBrandPriceOne")] public RequestEntity AddBrandPriceOne(TB_BRAND_PRICE model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); #region 参数判断 //if (string.IsNullOrEmpty(model.ORD_NO) || string.IsNullOrEmpty(model.ORD_ITEM)) //{ // db.Rollback(); // return result; //} #endregion model.STDSPEC = model.STDSPEC.Trim(); model.PRICE = model.PRICE.Trim(); //model.ORD_FLG = model.ORD_FLG.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(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("AddBrandPriceOne 报错 : ", ex); if (ex.ToString().Contains("00001")) { result.msg = "重复插入!"; } } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelBrandPrice")] public RequestEntity DelBrandPrice(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM TB_BRAND_PRICE WHERE 1=1 "); strSql.AppendLine(string.Format("AND STDSPEC = '{0}' ", model.STDSPEC)); 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("DelBrandPrice 报错", ex); } return result; } /// /// 删除接口 /// /// /// [HttpPost, Route("UpdateBrandPrice")] public RequestEntity UpdateBrandPrice(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("Update TB_BRAND_PRICE "); strSql.AppendLine(string.Format("set ORD_CON = '{0}' ,PRICE = '{1}' where STDSPEC = '{2}' ", model[1].ORD_CON, model[1].PRICE, model[1].STDSPEC)); 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("UpdateSpecialstdspec 报错", ex); } return result; } /// /// 查询接口 /// /// /// [HttpPost, Route("GetBrandPrice")] public RequestEntity GetBrandPrice(TB_BRAND_PRICE query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT STDSPEC, ORD_CON,PRICE, TO_CHAR( to_date(INS_DATE || INS_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as INS_DATE ,INS_TIME,INS_EMP , TO_CHAR( to_date(UPD_DATE || UPD_TIME ,'yyyy-mm-dd hh24:mi:ss'), 'mm-dd HH24:mi') as UPD_DATE, UPD_TIME,UPD_EMP FROM TB_BRAND_PRICE WHERE 1 = 1 "); if (query != null) { if (!string.IsNullOrWhiteSpace(query.STDSPEC)) strSql.AppendLine(" AND STDSPEC LIKE '%" + query.STDSPEC + "%'"); //if (!string.IsNullOrWhiteSpace(query.ORD_ITEM)) // strSql.AppendLine(" AND ORD_ITEM LIKE '%" + query.ORD_ITEM + "%'"); //if (!string.IsNullOrWhiteSpace(query.ORD_FLG)) // strSql.AppendLine(" AND ORD_FLG = '" + query.ORD_FLG + "'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = dtCheck; 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("GetBrandPrice 报错", ex); } return result; } #endregion //新增 #region 不可替代特殊订单 /// /// 查询接口 /// /// /// [HttpPost, Route("getTbOrdNospe")] public RequestEntity GetTbOrdNospe(TB_ORD_NOSPE query) { RequestEntity result = new RequestEntity(); //声明返回参数实体类 StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); //查询 strSql.AppendLine("SELECT PK,ORD_CUST_CD,STDSPEC,ORD_CAUSE,ORD_CON,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,IS_FULL,IS_PART FROM TB_ORD_NOSPE WHERE 1 = 1 "); if (query != null) { //订单客户代码 if (!string.IsNullOrWhiteSpace(query.ORD_CUST_CD)) strSql.AppendLine(" AND ORD_CUST_CD LIKE '%" + query.ORD_CUST_CD + "%'"); //标准号 if (!string.IsNullOrWhiteSpace(query.STDSPEC)) strSql.AppendLine(" AND STDSPEC LIKE '%" + query.STDSPEC + "%'"); } try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { strSql.AppendLine("Order By INS_DATE DESC "); dtCheck = db.Query(strSql.ToString()); result.data = db.Query(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("GetTbUstFl 报错", ex); } return result; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbOrdNospe")] public RequestEntity AddTbOrdNospe(IList insertModel) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { bool b = true; using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); foreach (TB_ORD_NOSPE model in insertModel) { model.PK = ""; if (model.ORD_CON != null) { model.ORD_CON = model.ORD_CON.Trim(); //备注 } if (model.INS_EMP != null) { model.INS_EMP = model.INS_EMP.Trim(); //录入人员 } if (model.UPD_EMP != null) { model.UPD_EMP = model.UPD_EMP.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.IS_FULL = model.IS_FULL.Trim(); //是否完全替代 model.IS_PART = model.IS_PART.Trim(); //是否部分替代 if (model.ORD_CUST_CD != null) { model.ORD_CUST_CD = model.ORD_CUST_CD.Trim(); //订单客户代码 } model.STDSPEC = model.STDSPEC.Trim(); //标准号 if (model.ORD_CAUSE != null) { model.ORD_CAUSE = model.ORD_CAUSE.Trim(); //原因 } if (db.Insert(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; } /// /// 添加接口 /// /// /// [HttpPost, Route("AddTbOrdNospeOne")] public RequestEntity AddTbOrdNospeOne(TB_ORD_NOSPE model) { RequestEntity result = new RequestEntity(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { db.BeginTransaction(); model.PK = ""; if (model.ORD_CON != null) { model.ORD_CON = model.ORD_CON.Trim(); //备注 } if (model.INS_EMP != null) { model.INS_EMP = model.INS_EMP.Trim(); //录入人员 } if (model.UPD_EMP != null) { model.UPD_EMP = model.UPD_EMP.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.IS_FULL = model.IS_FULL.Trim(); //是否完全替代 model.IS_PART = model.IS_PART.Trim(); //是否部分替代 if (model.ORD_CUST_CD != null) { model.ORD_CUST_CD = model.ORD_CUST_CD.Trim(); //订单客户代码 } model.STDSPEC = model.STDSPEC.Trim(); //标准号 if (model.ORD_CAUSE != null) { model.ORD_CAUSE = model.ORD_CAUSE.Trim(); //原因 } if (db.Insert(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; } /// /// 修改接口 /// /// /// [HttpPost, Route("UpdateTbOrdNospeOne")] public RequestEntity UpdateTbOrdNospeOne(IList model) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); DateTime dtNow = DateTime.Now; try { using (IDbContext db = ObjectContainer.GetObject("db")) { try { strSql.AppendLine("Update TB_ORD_NOSPE "); strSql.AppendLine(string.Format("set IS_FULL = '{0}',IS_PART = '{1}', UPD_DATE='{2}', UPD_TIME='{3}',ORD_CUST_CD='{4}',STDSPEC='{5}',ORD_CON='{6}', ORD_CAUSE = '{7}' where PK = '{8}' ", model[1].IS_FULL, model[1].IS_PART, dtNow.ToString("yyyyMMdd"), dtNow.ToString("HHmmss"), model[1].ORD_CUST_CD, model[1].STDSPEC, model[1].ORD_CON, model[1].ORD_CAUSE, model[1].PK)); 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; } /// /// 删除接口 /// /// /// [HttpPost, Route("DelTbOrdNospe")] public RequestEntity DelTbOrdNospe(IList delModel) { RequestEntity result = new RequestEntity(); StringBuilder strSql = new StringBuilder(); try { using (IDbContext db = ObjectContainer.GetObject("db")) { foreach (var model in delModel) { try { //ORD_NO, ORD_ITEM strSql.AppendLine("DELETE FROM TB_ORD_NOSPE WHERE 1=1 "); strSql.AppendLine(string.Format("AND PK='{0}' ", model.PK)); 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 } }