using ibk.IPD.Common;
using ibk.IPD.Entity;
using ibk.IPD.Entity.IPD_PS;
using ibk.IPD.Entity.IPD_PS.QueryArgs;
using ibk.IPD.Entity.IPD_PS.RequestArgs;
using ibk.IPD.Entity.IPD_MR.HotRoll;
using ibk.IPD.Entity.IpdPs;
using ibk.IPD.Service;
using ibk.IPD.Service.IPD_PS;
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.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.IO;
using ibk.IPD.Service.IPD_SS;
using Consul;
using System.Diagnostics;
using System.Windows.Forms;
using Confluent.Kafka;
using ibk.IPD.Entity.IpdMr.Basic;
using System.Collections;
using ibk.IPD.Entity.IpdMr.StdMgt;
using ibk.IPD.Service.IPD_SS;
using System.Reflection.Emit;
using ibk.IPD.Entity.IPD_SS;
using System.Globalization;
using NPOI.SS.Formula.Functions;
using NPOI.XWPF.UserModel;
using static NPOI.HSSF.Util.HSSFColor;
namespace ibk.IPD.Controller.IPD_SS
{
[RoutePrefix("ipd/AipdSS")]
public class SlabSubstitutionController : ApiController
{
private static SurMatSubService SerSurMatSubService = new SurMatSubService();
//Log4net 日志输出
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//设置一个加锁对象
private static readonly object LOCK = new object();
#region 板坯配置表查改
///
/// 获取替代配置信息
///
///
///
[HttpPost, Route("getSlabConf")]
public RequestEntity getSlabConf(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//strSql.AppendLine("SELECT * FROM TB_SLAB_CONF ");
strSql.AppendLine("select * FROM TB_SLAB_CONF pivot (max(pk) pk, max(DATA_SYNC_CYC) DATA_SYNC_CYC,max(YIELD_MIN) YIELD_MIN,max(FAC_NO) FAC_NO,max(THK_CD) THK_CD,max(len_min) len_min,max(LEN_MAX) len_max,max(ODR_SPD) ODR_SPD,max(SURPLUS_LEN) SURPLUS_LEN,max(EFF_RATE_MIN) EFF_RATE_MIN,max(data_period) data_period for pk in (1 as A, 2 as B, 3 as C)) ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
[HttpPost, Route("getSlabConfig")]
public RequestEntity getSlabConfig(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("SELECT * FROM TB_SLAB_CONF ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
[HttpPost, Route("getSlabConfC1")]
public RequestEntity getSlabConfC1(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("SELECT * FROM TB_SLAB_CONF where pk=1 ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
///
/// 获取替代配置信息
///
///
///
[HttpPost, Route("getSlabConfC2")]
public RequestEntity getSlabConfC2(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("select DATA_SYNC_CYC DATA_SYNC_CYC2, YIELD_MIN YIELD_MIN2, FAC_NO FAC_NO2, THK_CD THK_CD2, LEN_MIN LEN_MIN2, LEN_MAX LEN_MAX2, ODR_SPD ODR_SPD2, SURPLUS_LEN SURPLUS_LEN2, EFF_RATE_MIN EFF_RATE_MIN2, DATA_PERIOD DATA_PERIOD2, PK PK2 FROM TB_SLAB_CONF where pk = 2");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
///
/// 获取替代配置信息
///
///
///
[HttpPost, Route("getSlabConfC3")]
public RequestEntity getSlabConfC3(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("select DATA_SYNC_CYC DATA_SYNC_CYC3, YIELD_MIN YIELD_MIN3, FAC_NO FAC_NO3, THK_CD THK_CD3, LEN_MIN LEN_MIN3, LEN_MAX LEN_MAX3, ODR_SPD ODR_SPD3, SURPLUS_LEN SURPLUS_LEN3, EFF_RATE_MIN EFF_RATE_MIN3, DATA_PERIOD DATA_PERIOD3, PK PK3 FROM TB_SLAB_CONF where pk = 3 ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
///
/// 获取更新替代配置信息
///
///
///
[HttpPost, Route("UpdSlabConf")]
public RequestEntity UpdSlabConf(TB_SLAB_CONF queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
StringBuilder strsql = new StringBuilder();
if (queryArgs.PK != null)
{
strsql.AppendLine("UPDATE TB_SLAB_CONF SET PK='" + queryArgs.PK + "'");
if (!string.IsNullOrEmpty(queryArgs.YIELD_MIN))
{
strsql.AppendLine(", YIELD_MIN='" + queryArgs.YIELD_MIN + "'");
}
if (!string.IsNullOrEmpty(queryArgs.LEN_MIN))
{
strsql.AppendLine(", LEN_MIN='" + queryArgs.LEN_MIN + "'");
}
if (!string.IsNullOrEmpty(queryArgs.LEN_MAX))
{
strsql.AppendLine(", LEN_MAX='" + queryArgs.LEN_MAX + "'");
}
if (!string.IsNullOrEmpty(queryArgs.DATA_SYNC_CYC))
{
strsql.AppendLine(", DATA_SYNC_CYC='" + queryArgs.DATA_SYNC_CYC + "'");
}
if (!string.IsNullOrEmpty(queryArgs.FAC_NO))
{
strsql.AppendLine(", FAC_NO='" + queryArgs.FAC_NO + "'");
}
if (!string.IsNullOrEmpty(queryArgs.ODR_SPD))
{
strsql.AppendLine(", ODR_SPD='" + queryArgs.ODR_SPD + "'");
}
if (!string.IsNullOrEmpty(queryArgs.THK_CD))
{
strsql.AppendLine(", THK_CD='" + queryArgs.THK_CD + "'");
}
if (!string.IsNullOrEmpty(queryArgs.SURPLUS_LEN))
{
strsql.AppendLine(", SURPLUS_LEN ='" + queryArgs.SURPLUS_LEN + "'");
}
if (!string.IsNullOrEmpty(queryArgs.EFF_RATE_MIN))
{
strsql.AppendLine(", EFF_RATE_MIN='" + queryArgs.EFF_RATE_MIN + "'");
}
if (!string.IsNullOrEmpty(queryArgs.DATA_PERIOD))
{
strsql.AppendLine(", DATA_PERIOD='" + queryArgs.DATA_PERIOD + "'");
}
strsql.AppendLine("WHERE PK='" + queryArgs.PK + "'");
db.Execute(strsql.ToString());
result.msg = "操作成功!";
result.code = "1";
}
//else
//{
// db.Insert(queryArgs);
// result.msg = "操作成功!";
// result.code = "1";
//}
}
}
catch (Exception ex)
{
result.msg = "操作失败!";
result.code = "0";
logger.Error("UpdateParaConf 报错", ex);
}
return result;
}
#endregion
#region 板坯替换确认界面接口
[HttpPost, Route("getSlabDesAll")]
public RequestEntity getSlabDesAll(TB_SLAB_DES_Args queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList ltFSD = new List();
IList ltFSD_ALL = new List();
//strSql.AppendLine("SELECT * FROM FP_SLAB_DES FSD WHERE 1=1 AND FSD.HAN_RSL IS NULL ");
strSql.AppendLine("SELECT ");
strSql.AppendLine(" FSD.SLAB_NO ");
strSql.AppendLine(" , FSD.BLOCK_SEQ ");
strSql.AppendLine(" , FSD.SEQ ");
strSql.AppendLine(" , FSD.PROC_CD ");
strSql.AppendLine(" , FSD.BEF_PROC_CD ");
strSql.AppendLine(" , FSD.ORD_NO ");
strSql.AppendLine(" , FSD.ORD_ITEM ");
strSql.AppendLine(" , FSD.ORD_CNT ");
strSql.AppendLine(" , FSD.OVER_FL ");
strSql.AppendLine(" , FSD.PROD_CD ");
strSql.AppendLine(" , FSD.STLGRD ");
strSql.AppendLine(" , FSD.THK ");
strSql.AppendLine(" , FSD.WID ");
strSql.AppendLine(" , FSD.LEN ");
strSql.AppendLine(" , FSD.WGT ");
strSql.AppendLine(" , FSD.CNT ");
strSql.AppendLine(" , FSD.CR_CD ");
strSql.AppendLine(" , FSD.UST_FL ");
strSql.AppendLine(" , FSD.TRIM_FL ");
strSql.AppendLine(" , FSD.SMP_FL ");
strSql.AppendLine(" , FSD.SMP_LOC ");
strSql.AppendLine(" , FSD.SMP_LEN ");
strSql.AppendLine(" , FSD.SMP_NO ");
strSql.AppendLine(" , FSD.INS_DATE ");
strSql.AppendLine(" , FSD.INS_TIME ");
strSql.AppendLine(" , FSD.END_DATE ");
strSql.AppendLine(" , FSD.END_TIME ");
strSql.AppendLine(" , FSD.UPD_PGMID ");
strSql.AppendLine(" , FSD.REC_STS ");
strSql.AppendLine(" , FSD.DESIGN_SMP_LEN ");
strSql.AppendLine(" , FSD.SLAB_CUT_SEQ ");
strSql.AppendLine(" , FSD.SLAB_LEN ");
strSql.AppendLine(" , FSD.SLAB_WGT ");
strSql.AppendLine(" , FSD.HTM_SHOT_BLAST ");
strSql.AppendLine(" , FSD.HTM_METH1 ");
strSql.AppendLine(" , FSD.HTM_COND1 ");
strSql.AppendLine(" , FSD.HTM_METH2 ");
strSql.AppendLine(" , FSD.HTM_COND2 ");
strSql.AppendLine(" , FSD.HTM_METH3 ");
strSql.AppendLine(" , FSD.HTM_COND3 ");
strSql.AppendLine(" , FSD.ORD_FL ");
strSql.AppendLine(" , FSD.MID_SMP_LEN ");
strSql.AppendLine(" , FSD.POSITION_TYPE ");
strSql.AppendLine(" , FSD.POSITION_X ");
strSql.AppendLine(" , FSD.POSITION_Y ");
strSql.AppendLine(" , FSD.OVER_FL2 ");
strSql.AppendLine(" , FSD.INS_FL ");
strSql.AppendLine(" , FSD.FL ");
strSql.AppendLine(" , FSD.INS_PGMID ");
strSql.AppendLine(" , FSD.SMP_FL_RS ");
strSql.AppendLine(" , FSD.SMP_LOC_RS ");
strSql.AppendLine(" , FSD.SMP_LEN_RS ");
strSql.AppendLine(" , FSD.SMP_NO_RS ");
strSql.AppendLine(" , FSD.PLT ");
strSql.AppendLine(" , FSD.ID ");
//strSql.AppendLine(" , FSD.HAN_RSL ");
strSql.AppendLine(" , FSD.HAN_CON ");
strSql.AppendLine(" , FSD.HAN_DATE ");
strSql.AppendLine(" , FSD.THK_RATIO ");
strSql.AppendLine(" , FSD.WID_RATIO ");
strSql.AppendLine(" , FSD.HEAD_LEN ");
strSql.AppendLine(" , FSD.TAIL_LEN ");
strSql.AppendLine(" , FSD.WID_MRGIN ");
strSql.AppendLine(" , FSD.SAMP_LEN ");
strSql.AppendLine(" , FSD.CUT_LOSS ");
strSql.AppendLine(" , FSD.ORG_LEN ");
strSql.AppendLine(" , FSD.ORG_WGT ");
strSql.AppendLine(" , FSD.ORG_THK ");
strSql.AppendLine(" , FSD.ORG_WID ");
strSql.AppendLine(" , FSD.REM_LEN ");
strSql.AppendLine(" , FSD.REM_WGT ");
strSql.AppendLine(" , FSD.YIELD ");
strSql.AppendLine(" , FSD.UTILIZATION ");
strSql.AppendLine(" ,C.CD SUB_KIND ");
strSql.AppendLine(" , TO_DATE(FSD.INS_DATE||FSD.INS_TIME,'yyyy-mm-dd hh24:mi:ss') SUB_TIME ");
strSql.AppendLine(" ,B.CD HAN_RSL ");
strSql.AppendLine("FROM FP_SLAB_DES FSD ");
strSql.AppendLine(" left join (select * from ZP_CD where cd_mana_no= 'CLJG') B on FSD.HAN_RSL =B.CD_NAME ");
strSql.AppendLine(" left join (select * from ZP_CD where cd_mana_no= 'YPLX') C on FSD.HAN_RSL =C.CD_NAME ");
//strSql.AppendLine("WHERE 1 = 1 AND FSD.HAN_RSL IS NOT NULL");
strSql.AppendLine("WHERE 1 = 1 AND FSD.HAN_RSL IS NULL");
//strSql.AppendLine("WHERE 1 = 1 ");
if (queryArgs != null)
{
//板坯号
if (queryArgs.SLAB_NO != null && queryArgs.SLAB_NO != string.Empty)
{
strSql.AppendLine(" AND FSD.SLAB_NO = '" + queryArgs.SLAB_NO + "'");
}
//钢种
if (queryArgs.STLGRD != null && queryArgs.STLGRD != string.Empty)
{
strSql.AppendLine(" AND FSD.STLGRD = '" + queryArgs.STLGRD + "'");
}
//工厂
if (queryArgs.PLT != null && queryArgs.PLT != string.Empty)
{
strSql.AppendLine(" AND FSD.PLT = '" + queryArgs.PLT + "'");
}
//订单号
if (queryArgs.ORD_NO != null && queryArgs.ORD_NO != string.Empty)
{
strSql.AppendLine(" AND ORD_NO = '" + queryArgs.ORD_NO + "'");
}
//订单序列
if (queryArgs.ORD_ITEM != null && queryArgs.ORD_ITEM != string.Empty)
{
strSql.AppendLine(" AND ORD_ITEM = '" + queryArgs.ORD_ITEM + "'");
}
//插入时间
//if (queryArgs.INS_DATE_MAX!= null)
//{
// strSql.AppendLine(" AND to_date(ins_date||ins_time,'yyyy-mm-dd hh24:mi:ss') <= '" + queryArgs.INS_DATE_MAX + "'");
//}
//if (queryArgs.INS_DATE_MIN != null)
//{
// strSql.AppendLine(" AND to_date(ins_date||ins_time,'yyyy-mm-dd hh24:mi:ss') > ='" + queryArgs.INS_DATE_MIN + "'");
//}
////处理状态
//if (queryArgs.HAN_RSL != null && queryArgs.HAN_RSL != string.Empty)
//{
// strSql.AppendLine(" AND SUB_KND = (select CD from ZP_CD where cd_mana_no= 'CLJG' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
//}
//替代类型
if (!string.IsNullOrEmpty(queryArgs.SUB_KND))
{
//strSql.AppendLine(" AND B.cd_mana_no= 'YPLX' and = (select CD from ZP_CD where cd_mana_no= 'YPLX' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
//strSql.AppendLine(" AND B.cd_mana_no= 'YPLX' and B.CD_NAME='" + queryArgs.SUB_KND) + "'");
strSql.AppendLine(" AND C.CD = '" + queryArgs.SUB_KND + "'");
}
//处理状态
if (!string.IsNullOrEmpty(queryArgs.HAN_RSL))
{
//strSql.AppendLine(" AND SUB_KND = (select CD from ZP_CD where cd_mana_no= 'CLJG' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
strSql.AppendLine(" AND B.CD = '" + queryArgs.HAN_RSL + "'");
}
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.STARTTIME)) && CommonUtils.ObjectToStr(queryArgs.STARTTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.ENDTIME)) && CommonUtils.ObjectToStr(queryArgs.ENDTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
if (queryArgs.STARTTIME == DateTime.MinValue && queryArgs.ENDTIME == DateTime.MinValue)
{
queryArgs.STARTTIME = DateTime.Now;
queryArgs.ENDTIME = DateTime.Now;
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1).ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
strSql.AppendLine("ORDER BY FSD.SLAB_NO ,FSD.BLOCK_SEQ,FSD.SEQ ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltFSD = db.Query(strSql.ToString());
//result.data = db.Query(strSql.ToString());
if (ltFSD.Count > 0)
{
FP_SLAB_DES_ALL fsda_1 = new FP_SLAB_DES_ALL();
foreach (string strSlab in ltFSD.GroupBy(p => p.SLAB_NO).Select(p => p.Key).ToList())
{
//一层
if (ltFSD_ALL.Where(p => p.SLAB_NO == strSlab).Count() == 0)
{
fsda_1 = new FP_SLAB_DES_ALL();
fsda_1 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == "01").FirstOrDefault());
fsda_1.LEN = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == "01").FirstOrDefault().ORG_LEN;
fsda_1.WGT = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == "01").FirstOrDefault().ORG_WGT;
fsda_1.THK = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == "01").FirstOrDefault().ORG_THK;
fsda_1.WID = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == "01").FirstOrDefault().ORG_WID;
fsda_1.SLAB_LEN = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").OrderByDescending(e => e.SLAB_CUT_SEQ).FirstOrDefault().REM_LEN;
fsda_1.SLAB_WGT = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").OrderByDescending(e => e.SLAB_CUT_SEQ).FirstOrDefault().REM_WGT;
fsda_1.CNT = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").Count();
decimal wgt = (ltFSD.Where(p => p.SLAB_NO == strSlab && p.BLOCK_SEQ == "00" && p.SEQ == "00" && (p.PROC_CD == "CAA" || (p.PROC_CD == "CAD" && p.BEF_PROC_CD == "CAA"))).Select(q => q.WGT).Sum());
if (wgt == 0 || fsda_1.ORG_WGT == 0)
{
}
fsda_1.YIELD = Math.Round((ltFSD.Where(p => p.SLAB_NO == strSlab && p.BLOCK_SEQ != "00" && p.SEQ != "00").Select(q => q.WGT).Sum()) / (wgt) * 100, 2);
fsda_1.UTILIZATION = Math.Round(wgt / (fsda_1.ORG_WGT) * 100, 2);
fsda_1.KEY = fsda_1.SLAB_NO + "_00_00_00";// + fsda_1.SLAB_CUT_SEQ;
ltFSD_ALL.Add(fsda_1);
fsda_1.children = new List();
//二层
foreach (FP_SLAB_DES item_1 in ltFSD.Where(p => p.SLAB_NO == strSlab && p.BLOCK_SEQ == "00" && p.SEQ == "00" && p.SLAB_CUT_SEQ != "00").OrderBy(e => e.SLAB_CUT_SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_2 = new FP_SLAB_DES_ALL();
fsda_2 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).FirstOrDefault());
fsda_2.KEY = fsda_1.SLAB_NO + "_" + item_1.SLAB_CUT_SEQ + "_00_00";// + fsda_1.SLAB_CUT_SEQ;
fsda_2.CNT = ltFSD.Where(p => p.SLAB_NO == strSlab && p.BLOCK_SEQ == "00" && p.SEQ == "00" && p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).Count();
fsda_1.children.Add(fsda_2);
fsda_2.children = new List();
//三层
foreach (FP_SLAB_DES item_2 in ltFSD.Where(p => p.SLAB_NO == strSlab && p.BLOCK_SEQ != "00" && p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).OrderBy(e => e.BLOCK_SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_3 = new FP_SLAB_DES_ALL();
fsda_3 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == item_2.BLOCK_SEQ
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).FirstOrDefault());
fsda_3.KEY = fsda_1.SLAB_NO + "_" + item_1.SLAB_CUT_SEQ + "" + item_2.BLOCK_SEQ + "_00";// + fsda_1.SLAB_CUT_SEQ;
fsda_3.CNT = ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == item_2.BLOCK_SEQ
&& p.SEQ != "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).Count();
fsda_2.children.Add(fsda_3);
fsda_3.children = new List();
//四层
foreach (FP_SLAB_DES item_3 in ltFSD.Where(p => p.SLAB_NO == strSlab
&& p.BLOCK_SEQ == item_2.BLOCK_SEQ && p.SEQ != "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_4 = new FP_SLAB_DES_ALL();
fsda_4 = CopyToModel(item_3);
fsda_4.KEY = fsda_1.SLAB_NO + "_" + item_1.SLAB_CUT_SEQ + "" + item_2.BLOCK_SEQ + "_" + item_3.SEQ;// + fsda_1.SLAB_CUT_SEQ;
fsda_3.children.Add(fsda_4);
}
}
}
}
}
result.data = ltFSD_ALL;
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.data = ltFSD;
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSlabSub 报错", ex);
}
return result;
}
///
/// 获取替代板坯信息
///
///
///
[HttpPost, Route("getSlabDes")]
public RequestEntity getSlabDes(TB_SLAB_DES_Args queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList ltFSD = new List();
//strSql.AppendLine("SELECT * FROM FP_SLAB_DES FSD WHERE 1=1 AND FSD.HAN_RSL IS NULL ");
strSql.AppendLine("SELECT ");
strSql.AppendLine(" FSD.SLAB_NO ");
strSql.AppendLine(" , FSD.BLOCK_SEQ ");
strSql.AppendLine(" , FSD.SEQ ");
strSql.AppendLine(" , FSD.PROC_CD ");
strSql.AppendLine(" , FSD.BEF_PROC_CD ");
strSql.AppendLine(" , FSD.ORD_NO ");
strSql.AppendLine(" , FSD.ORD_ITEM ");
strSql.AppendLine(" , FSD.ORD_CNT ");
strSql.AppendLine(" , FSD.OVER_FL ");
strSql.AppendLine(" , FSD.PROD_CD ");
strSql.AppendLine(" , FSD.STLGRD ");
strSql.AppendLine(" , FSD.THK ");
strSql.AppendLine(" , FSD.WID ");
strSql.AppendLine(" , FSD.LEN ");
strSql.AppendLine(" , FSD.WGT ");
strSql.AppendLine(" , FSD.CNT ");
strSql.AppendLine(" , FSD.CR_CD ");
strSql.AppendLine(" , FSD.UST_FL ");
strSql.AppendLine(" , FSD.TRIM_FL ");
strSql.AppendLine(" , FSD.SMP_FL ");
strSql.AppendLine(" , FSD.SMP_LOC ");
strSql.AppendLine(" , FSD.SMP_LEN ");
strSql.AppendLine(" , FSD.SMP_NO ");
strSql.AppendLine(" , FSD.INS_DATE ");
strSql.AppendLine(" , FSD.INS_TIME ");
strSql.AppendLine(" , FSD.END_DATE ");
strSql.AppendLine(" , FSD.END_TIME ");
strSql.AppendLine(" , FSD.UPD_PGMID ");
strSql.AppendLine(" , FSD.REC_STS ");
strSql.AppendLine(" , FSD.DESIGN_SMP_LEN ");
strSql.AppendLine(" , FSD.SLAB_CUT_SEQ ");
strSql.AppendLine(" , FSD.SLAB_LEN ");
strSql.AppendLine(" , FSD.SLAB_WGT ");
strSql.AppendLine(" , FSD.HTM_SHOT_BLAST ");
strSql.AppendLine(" , FSD.HTM_METH1 ");
strSql.AppendLine(" , FSD.HTM_COND1 ");
strSql.AppendLine(" , FSD.HTM_METH2 ");
strSql.AppendLine(" , FSD.HTM_COND2 ");
strSql.AppendLine(" , FSD.HTM_METH3 ");
strSql.AppendLine(" , FSD.HTM_COND3 ");
strSql.AppendLine(" , FSD.ORD_FL ");
strSql.AppendLine(" , FSD.MID_SMP_LEN ");
strSql.AppendLine(" , FSD.POSITION_TYPE ");
strSql.AppendLine(" , FSD.POSITION_X ");
strSql.AppendLine(" , FSD.POSITION_Y ");
strSql.AppendLine(" , FSD.OVER_FL2 ");
strSql.AppendLine(" , FSD.INS_FL ");
strSql.AppendLine(" , FSD.FL ");
strSql.AppendLine(" , FSD.INS_PGMID ");
strSql.AppendLine(" , FSD.SMP_FL_RS ");
strSql.AppendLine(" , FSD.SMP_LOC_RS ");
strSql.AppendLine(" , FSD.SMP_LEN_RS ");
strSql.AppendLine(" , FSD.SMP_NO_RS ");
strSql.AppendLine(" , FSD.PLT ");
strSql.AppendLine(" , FSD.ID ");
strSql.AppendLine(" , FSD.HAN_RSL ");
strSql.AppendLine(" , FSD.HAN_CON ");
strSql.AppendLine(" , FSD.HAN_DATE ");
strSql.AppendLine(" , FSD.THK_RATIO ");
strSql.AppendLine(" , FSD.WID_RATIO ");
strSql.AppendLine(" , FSD.HEAD_LEN ");
strSql.AppendLine(" , FSD.TAIL_LEN ");
strSql.AppendLine(" , FSD.WID_MRGIN ");
strSql.AppendLine(" , FSD.SAMP_LEN ");
strSql.AppendLine(" , FSD.CUT_LOSS ");
strSql.AppendLine(" , TO_DATE(FSD.INS_DATE||FSD.INS_TIME,'yyyy-mm-dd hh24:mi:ss') SUB_TIME ");
strSql.AppendLine(" ,B.CD HAN_RSL ");
strSql.AppendLine("FROM FP_SLAB_DES FSD ");
strSql.AppendLine(" left join (select * from ZP_CD where cd_mana_no= 'CLJG') B on FSD.HAN_RSL =B.CD_NAME ");
strSql.AppendLine("WHERE 1 = 1 AND FSD.HAN_RSL IS NULL");
if (queryArgs != null)
{
//板坯号
if (queryArgs.SLAB_NO != null && queryArgs.SLAB_NO != string.Empty)
{
strSql.AppendLine(" AND FSD.SLAB_NO = '" + queryArgs.SLAB_NO + "'");
}
//钢种
if (queryArgs.STLGRD != null && queryArgs.STLGRD != string.Empty)
{
strSql.AppendLine(" AND FSD.STLGRD = '" + queryArgs.STLGRD + "'");
}
//工厂
if (queryArgs.PLT != null && queryArgs.PLT != string.Empty)
{
strSql.AppendLine(" AND FSD.PLT = '" + queryArgs.PLT + "'");
}
//替代类型
if (!string.IsNullOrEmpty(queryArgs.SUB_KND))
{
//strSql.AppendLine(" AND B.cd_mana_no= 'YPLX' and = (select CD from ZP_CD where cd_mana_no= 'YPLX' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
//strSql.AppendLine(" AND B.cd_mana_no= 'YPLX' and B.CD_NAME='" + queryArgs.SUB_KND) + "'");
strSql.AppendLine(" AND SUB_KIND in (select CD_NAME from ZP_CD where CD ='" + queryArgs.SUB_KND + "')");
}
//处理状态
if (!string.IsNullOrEmpty(queryArgs.HAN_RSL))
{
//strSql.AppendLine(" AND SUB_KND = (select CD from ZP_CD where cd_mana_no= 'CLJG' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
strSql.AppendLine(" AND B.CD = '" + queryArgs.HAN_RSL + "'");
}
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.STARTTIME)) && CommonUtils.ObjectToStr(queryArgs.STARTTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.ENDTIME)) && CommonUtils.ObjectToStr(queryArgs.ENDTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
if (queryArgs.STARTTIME == DateTime.MinValue && queryArgs.ENDTIME == DateTime.MinValue)
{
queryArgs.STARTTIME = DateTime.Now;
queryArgs.ENDTIME = DateTime.Now;
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1).ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
strSql.AppendLine("ORDER BY FSD.SLAB_NO ,FSD.BLOCK_SEQ,FSD.SEQ ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("GetSlabSub 报错", ex);
}
return result;
}
///
/// 获取替代板坯信息历史信息
///
///
///
[HttpPost, Route("getSlabDesHis")]
public RequestEntity getSlabDesHis(TB_SLAB_DES_Args queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList ltFSD = new List();
IList ltFSD_ALL = new List();
strSql.AppendLine("SELECT ");
strSql.AppendLine(" FSD.SLAB_NO ");
strSql.AppendLine(" , FSD.BLOCK_SEQ ");
strSql.AppendLine(" , FSD.SEQ ");
strSql.AppendLine(" , FSD.PROC_CD ");
strSql.AppendLine(" , FSD.BEF_PROC_CD ");
strSql.AppendLine(" , FSD.ORD_NO ");
strSql.AppendLine(" , FSD.ORD_ITEM ");
strSql.AppendLine(" , FSD.ORD_CNT ");
strSql.AppendLine(" , FSD.OVER_FL ");
strSql.AppendLine(" , FSD.PROD_CD ");
strSql.AppendLine(" , FSD.STLGRD ");
strSql.AppendLine(" , FSD.THK ");
strSql.AppendLine(" , FSD.WID ");
strSql.AppendLine(" , FSD.LEN ");
strSql.AppendLine(" , FSD.WGT ");
strSql.AppendLine(" , FSD.CNT ");
strSql.AppendLine(" , FSD.CR_CD ");
strSql.AppendLine(" , FSD.UST_FL ");
strSql.AppendLine(" , FSD.TRIM_FL ");
strSql.AppendLine(" , FSD.SMP_FL ");
strSql.AppendLine(" , FSD.SMP_LOC ");
strSql.AppendLine(" , FSD.SMP_LEN ");
strSql.AppendLine(" , FSD.SMP_NO ");
strSql.AppendLine(" , FSD.INS_DATE ");
strSql.AppendLine(" , FSD.INS_TIME ");
strSql.AppendLine(" , FSD.END_DATE ");
strSql.AppendLine(" , FSD.END_TIME ");
strSql.AppendLine(" , FSD.UPD_PGMID ");
strSql.AppendLine(" , FSD.REC_STS ");
strSql.AppendLine(" , FSD.DESIGN_SMP_LEN ");
strSql.AppendLine(" , FSD.SLAB_CUT_SEQ ");
strSql.AppendLine(" , FSD.SLAB_LEN ");
strSql.AppendLine(" , FSD.SLAB_WGT ");
strSql.AppendLine(" , FSD.HTM_SHOT_BLAST ");
strSql.AppendLine(" , FSD.HTM_METH1 ");
strSql.AppendLine(" , FSD.HTM_COND1 ");
strSql.AppendLine(" , FSD.HTM_METH2 ");
strSql.AppendLine(" , FSD.HTM_COND2 ");
strSql.AppendLine(" , FSD.HTM_METH3 ");
strSql.AppendLine(" , FSD.HTM_COND3 ");
strSql.AppendLine(" , FSD.ORD_FL ");
strSql.AppendLine(" , FSD.MID_SMP_LEN ");
strSql.AppendLine(" , FSD.POSITION_TYPE ");
strSql.AppendLine(" , FSD.POSITION_X ");
strSql.AppendLine(" , FSD.POSITION_Y ");
strSql.AppendLine(" , FSD.OVER_FL2 ");
strSql.AppendLine(" , FSD.INS_FL ");
strSql.AppendLine(" , FSD.FL ");
strSql.AppendLine(" , FSD.INS_PGMID ");
strSql.AppendLine(" , FSD.SMP_FL_RS ");
strSql.AppendLine(" , FSD.SMP_LOC_RS ");
strSql.AppendLine(" , FSD.SMP_LEN_RS ");
strSql.AppendLine(" , FSD.SMP_NO_RS ");
strSql.AppendLine(" , FSD.PLT ");
strSql.AppendLine(" , FSD.ID ");
//strSql.AppendLine(" , NVL((select b.CD from ZP_CD b where cd_mana_no= 'CLJG' and b.cd_NAME=FSD.HAN_RSL),'未处理') HAN_RSL ");
strSql.AppendLine(" , FSD.HAN_CON ");
strSql.AppendLine(" , FSD.HAN_DATE ");
strSql.AppendLine(" , FSD.THK_RATIO ");
strSql.AppendLine(" , FSD.WID_RATIO ");
strSql.AppendLine(" , FSD.HEAD_LEN ");
strSql.AppendLine(" , FSD.TAIL_LEN ");
strSql.AppendLine(" , FSD.WID_MRGIN ");
strSql.AppendLine(" , FSD.SAMP_LEN ");
strSql.AppendLine(" , FSD.CUT_LOSS ");
strSql.AppendLine(" , FSD.ORG_LEN ");
strSql.AppendLine(" , FSD.ORG_WGT ");
strSql.AppendLine(" , FSD.ORG_THK ");
strSql.AppendLine(" , FSD.ORG_WID ");
strSql.AppendLine(" , FSD.REM_LEN ");
strSql.AppendLine(" , FSD.REM_WGT ");
strSql.AppendLine(" , FSD.YIELD ");
strSql.AppendLine(" , FSD.UTILIZATION ");
strSql.AppendLine(" , C.CD SUB_KIND ");
strSql.AppendLine(" , TO_DATE(FSD.INS_DATE||FSD.INS_TIME,'yyyy-mm-dd hh24:mi:ss') SUB_TIME "); //替代时间
strSql.AppendLine(" , HAN_DATE "); //处理时间
strSql.AppendLine(" ,(case when B.CD is not null then B.CD else '未处理' end) as HAN_RSL ");
strSql.AppendLine("FROM FP_SLAB_DES FSD ");
strSql.AppendLine(" left join (select * from ZP_CD where cd_mana_no= 'CLJG') B on FSD.HAN_RSL =B.CD_NAME ");
strSql.AppendLine(" left join (select * from ZP_CD where cd_mana_no= 'YPLX') C on FSD.HAN_RSL =C.CD_NAME ");
strSql.AppendLine("WHERE 1 = 1 ");
if (queryArgs != null)
{
//板坯号
if (queryArgs.SLAB_NO != null && queryArgs.SLAB_NO != string.Empty)
{
strSql.AppendLine(" AND FSD.SLAB_NO = '" + queryArgs.SLAB_NO + "'");
}
//钢种
if (queryArgs.STLGRD != null && queryArgs.STLGRD != string.Empty)
{
strSql.AppendLine(" AND FSD.STLGRD = '" + queryArgs.STLGRD + "'");
}
//工厂
if (queryArgs.PLT != null && queryArgs.PLT != string.Empty)
{
strSql.AppendLine(" AND FSD.PLT = '" + queryArgs.PLT + "'");
}
//订单号
if (queryArgs.ORD_NO != null && queryArgs.ORD_NO != string.Empty)
{
strSql.AppendLine(" AND ORD_NO = '" + queryArgs.ORD_NO + "'");
}
//订单序列
if (queryArgs.ORD_ITEM != null && queryArgs.ORD_ITEM != string.Empty)
{
strSql.AppendLine(" AND ORD_ITEM = '" + queryArgs.ORD_ITEM + "'");
}
//替代类型
if (!string.IsNullOrEmpty(queryArgs.SUB_KND))
{
//strSql.AppendLine(" AND SUB_KIND in (select CD_NAME from ZP_CD where CD ='" + queryArgs.SUB_KND + "')");
strSql.AppendLine(" AND C.CD = '" + queryArgs.SUB_KND + "'");
}
//处理状态
if (!string.IsNullOrEmpty(queryArgs.HAN_RSL))
{
//strSql.AppendLine(" AND SUB_KND = (select CD from ZP_CD where cd_mana_no= 'CLJG' AND CD_NAME=={0}) " + queryArgs.SUB_KND);
strSql.AppendLine(" AND B.CD = '" + queryArgs.HAN_RSL + "'");
}
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.STARTTIME)) && CommonUtils.ObjectToStr(queryArgs.STARTTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.ENDTIME)) && CommonUtils.ObjectToStr(queryArgs.ENDTIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
if (queryArgs.STARTTIME == DateTime.MinValue && queryArgs.ENDTIME == DateTime.MinValue)
{
queryArgs.STARTTIME = DateTime.Now;
queryArgs.ENDTIME = DateTime.Now;
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.STARTTIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(FSD.INS_DATE||FSD.INS_TIME ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.ENDTIME.AddDays(1).ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
strSql.AppendLine("ORDER BY FSD.LEN ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltFSD = db.Query(strSql.ToString());
//result.data = db.Query(strSql.ToString());
if (ltFSD.Count > 0)
{
foreach (FP_SLAB_DES fps in ltFSD)
{
if (!string.IsNullOrEmpty(fps.HAN_DATE) && !string.IsNullOrEmpty(fps.SUB_TIME))
{
DateTime SUB_TIME = DateTime.Parse(fps.SUB_TIME);
DateTime hanDate = DateTime.Parse(fps.HAN_DATE);
TimeSpan timeDiff = hanDate - SUB_TIME;
double totalMinutes = Math.Floor(timeDiff.TotalMinutes);
if (totalMinutes >= 3)
{
fps.SUB_TIME = SUB_TIME.AddMinutes(totalMinutes - 2).ToString();
}
}
}
FP_SLAB_DES_ALL fsda_1 = new FP_SLAB_DES_ALL();
foreach (string strSlab in ltFSD.GroupBy(p => p.SLAB_NO + p.INS_DATE + p.INS_TIME + p.SLAB_CUT_SEQ).Select(p => p.Key).ToList())
{
string SLAB_NO = strSlab.Substring(0, 10);
string INS_DATE = strSlab.Substring(10, 8);
string INS_TIME = strSlab.Substring(18, 6);
string SLAB_CUT_SEQ = "01";
//一层
if (ltFSD_ALL.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME).Count() == 0)
{
fsda_1 = new FP_SLAB_DES_ALL();
fsda_1 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == SLAB_CUT_SEQ).FirstOrDefault());
fsda_1.LEN = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == SLAB_CUT_SEQ).FirstOrDefault().ORG_LEN;
fsda_1.WGT = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == SLAB_CUT_SEQ).FirstOrDefault().ORG_WGT;
fsda_1.THK = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == SLAB_CUT_SEQ).FirstOrDefault().ORG_THK;
fsda_1.WID = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == SLAB_CUT_SEQ).FirstOrDefault().ORG_WID;
fsda_1.SLAB_LEN = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").OrderByDescending(e => e.SLAB_CUT_SEQ).FirstOrDefault().REM_LEN;
fsda_1.SLAB_WGT = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").OrderByDescending(e => e.SLAB_CUT_SEQ).FirstOrDefault().REM_WGT;
fsda_1.CNT = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00").Count();
decimal wgt = (ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ == "00" && p.SEQ == "00" && (p.PROC_CD == "CAA" || (p.PROC_CD == "CAD" && p.BEF_PROC_CD == "CAA"))).Select(q => q.WGT).Sum());
if (wgt == 0 || fsda_1.ORG_WGT == 0)
{
}
fsda_1.YIELD = Math.Round((ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ != "00" && p.SEQ != "00").Select(q => q.WGT).Sum()) / (wgt) * 100, 2);
fsda_1.UTILIZATION = Math.Round(wgt / (fsda_1.ORG_WGT) * 100, 2);
fsda_1.KEY = fsda_1.SLAB_NO + INS_DATE + INS_TIME + "_00_00_00";// + fsda_1.SLAB_CUT_SEQ;
ltFSD_ALL.Add(fsda_1);
fsda_1.children = new List();
//二层
foreach (FP_SLAB_DES item_1 in ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ == "00" && p.SEQ == "00" && p.SLAB_CUT_SEQ != "00").OrderBy(e => e.SLAB_CUT_SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_2 = new FP_SLAB_DES_ALL();
fsda_2 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == "00"
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).FirstOrDefault());
fsda_2.KEY = fsda_1.SLAB_NO + INS_DATE + INS_TIME + "_" + item_1.SLAB_CUT_SEQ + "_00_00";// + fsda_1.SLAB_CUT_SEQ;
fsda_2.CNT = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ == "00" && p.SEQ == "00" && p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).Count();
fsda_1.children.Add(fsda_2);
fsda_2.children = new List();
//三层
foreach (FP_SLAB_DES item_2 in ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ != "00" && p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).OrderBy(e => e.BLOCK_SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_3 = new FP_SLAB_DES_ALL();
fsda_3 = CopyToModel(ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == item_2.BLOCK_SEQ
&& p.SEQ == "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).FirstOrDefault());
fsda_3.KEY = fsda_1.SLAB_NO + INS_DATE + INS_TIME + "_" + item_1.SLAB_CUT_SEQ + "" + item_2.BLOCK_SEQ + "_00";// + fsda_1.SLAB_CUT_SEQ;
fsda_3.CNT = ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME
&& p.BLOCK_SEQ == item_2.BLOCK_SEQ
&& p.SEQ != "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).Count();
fsda_2.children.Add(fsda_3);
fsda_3.children = new List();
//四层
foreach (FP_SLAB_DES item_3 in ltFSD.Where(p => p.SLAB_NO == SLAB_NO && p.INS_DATE == INS_DATE && p.INS_TIME == INS_TIME && p.BLOCK_SEQ == item_2.BLOCK_SEQ && p.SEQ != "00"
&& p.SLAB_CUT_SEQ == item_1.SLAB_CUT_SEQ).OrderBy(p => p.SEQ).ToList())
{
FP_SLAB_DES_ALL fsda_4 = new FP_SLAB_DES_ALL();
fsda_4 = CopyToModel(item_3);
fsda_4.KEY = fsda_1.SLAB_NO + INS_DATE + INS_TIME + "_" + item_1.SLAB_CUT_SEQ + "" + item_2.BLOCK_SEQ + "_" + item_3.SEQ;// + fsda_1.SLAB_CUT_SEQ;
fsda_3.children.Add(fsda_4);
}
}
}
}
}
result.data = ltFSD_ALL;
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.data = ltFSD;
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSlabSub 报错", ex);
}
return result;
}
///
/// 确认替代 STATE = Y 或拒绝替代 STATE = N 按钮
/// ·
/// 传ID的值
///
[HttpPost, Route("SendSlab")]
public RequestEntity SendSlab(IList listdelAddModel)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
List Deslist = new List();
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
try
{
//因为是同时操作两个表, 所以开启事务
db.BeginTransaction();
bool b = true;
if (listdelAddModel[0].STATE == "Y")
{
foreach (TB_SLAB_DES_Args delAddModel in listdelAddModel)
{
if (delAddModel.BLOCK_SEQ != "00")
{
continue;
}
string strSql = string.Format("UPDATE FP_SLAB_DES SET HAN_DATE='{0}',HAN_RSL='{1}' WHERE SLAB_NO = '{2}'"
, DateTime.Now.ToString(), "N", delAddModel.SLAB_NO);
string strSql2 = string.Format("SELECT * FROM FP_SLAB_DES WHERE SLAB_NO = {0}", delAddModel.SLAB_NO);
Deslist = db.Query(strSql2).ToList();
DateTime date = DateTime.Now;
foreach (FP_SLAB_DES item in Deslist)
{
FP_SLAB_DES_HIS fP_SLAB_DES_HIS = new FP_SLAB_DES_HIS();
fP_SLAB_DES_HIS.SUB_TIME = date.ToString();
fP_SLAB_DES_HIS = CopyToModel(item);
db.Insert(fP_SLAB_DES_HIS);
}
FP_SLAB_DES supData = new FP_SLAB_DES();
string strSqlSup = "SELECT * FROM FP_SLAB_DES WHERE ID ='" + delAddModel.ID + "'";
//获取替代信息
supData = db.QuerySingle(strSqlSup);
//PDO
TBDIPDO InsertPDO = GetTBDIBKDPDO(supData);
db.Insert(InsertPDO);
db.Execute(strSql);
}
}
else
{
foreach (TB_SLAB_DES_Args delAddModel in listdelAddModel)
{
if (delAddModel.BLOCK_SEQ != "00")
{
continue;
}
string strSql = string.Format("DELETE FP_SLAB_DES WHERE SLAB_NO = '{0}'"
, delAddModel.SLAB_NO);
//FP_SLAB_DES supData = new FP_SLAB_DES();
//string strSqlSup = "SELECT * FROM FP_SLAB_DES WHERE ID ='" + delAddModel.ID + "'";
////获取替代信息
//supData = db.QuerySingle(strSqlSup);
////PDO
//TBDIPDO InsertPDO = GetTBDIBKDPDO(supData);
//db.Insert(InsertPDO);
db.Execute(strSql);
}
}
if (b)
{
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
else
{
result.msg = "操作失败!";
result.code = "0";
//操作失败回滚数据到初始状态
db.Rollback();
}
}
catch (Exception ex)
{
//数据如果发生错误则回滚
db.Rollback();
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelSupAddSupersedeConfiram 报错", ex);
}
}
return result;
}
}
///
/// 手动余坯替代
///
///
///
[HttpPost, Route("ManualSlabC1")]
public RequestEntity ManualSlabC1(TB_SLAB_DES_Args queryArgs)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
try
{
//string args = ArgsSupersede.PLATE_NO;
Process KHMsg = new Process();
KHMsg.StartInfo.FileName = @"D:\Program\SlabSub\SlabHandle.exe";
KHMsg.StartInfo.Arguments = queryArgs.PLT;
//KHMsg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//隐藏
KHMsg.Start();
while (!KHMsg.HasExited) { } //如果exe还没关闭,则等待
if (KHMsg.ExitCode == 1)
{
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.msg = "操作失败!";
result.code = "0";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddSingleSup 报错", ex);
}
return result;
}
}
[HttpPost, Route("GetHisDataTol")]
public RequestEntity GetHisDataTol(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//获取历史数据
result.data = SlabSubstitutionService.GetHisDataTol(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetHisDataRate")]
public RequestEntity GetHisDataRate(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//获取历史数据
result.data = SlabSubstitutionService.GetHisDataRate(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetHisWGT")]
public RequestEntity GetHisWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
//QAGP.START_TIME = DateTime.Now.AddDays(-6);
//20240321 刘桂英转领导通知 替代时间改为一个月,时间应为上个月26号至当月25号
QAGP.START_TIME = DateTime.Now.AddDays(-30);
QAGP.END_TIME = DateTime.Now;
}
//获取历史数据
result.data = SlabSubstitutionService.GetHisWGT(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetHisRate")]
public RequestEntity GetHisRate(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
//20240321 刘桂英转领导通知 替代时间改为一个月,时间应为上个月26号至当月25号
QAGP.START_TIME = DateTime.Now.AddDays(-30);
QAGP.END_TIME = DateTime.Now;
}
//获取历史数据
result.data = SlabSubstitutionService.GetHisRate(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetPeriodOftime")]
public RequestEntity GetPeriodOftime(TB_PROCESS_DATA data)
{
RequestEntity result = new RequestEntity();
try
{
if (data.TYPE == "实时")
data.TYPE = "0";
if (data.TYPE == "批量")
data.TYPE = "1";
//获取替代信息
if (data.START_TIME == null && data.END_TIME == null)
{
data.START_TIME = DateTime.Now.AddDays(-7).ToString("yyyyMMdd");
data.END_TIME = DateTime.Now.ToString("yyyyMMdd");
}
DataTable dt = SlabSubstitutionService.GetPeriodOftime(data);
ArrayList al = new ArrayList();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
string[] e = new string[2];
e[0] = row[1].ToString();
e[1] = row[3].ToString();
al.Add(e);
}
}
}
result.data = al;
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetPlateTotal")]
public RequestEntity GetPlateTotal(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
//if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
//{
// QAGP.START_TIME = DateTime.Now.AddDays(-6);
// QAGP.END_TIME = DateTime.Now;
//}
//获取替代信息
result.data = SlabSubstitutionService.GetPlateTotal(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetOrderTotal")]
public RequestEntity GetOrderTotal(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//获取替代信息
result.data = SlabSubstitutionService.GetOrderTotal(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetStockDate")]
public RequestEntity GetStockDate(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
//20240321 刘桂英转领导通知 替代时间改为一个月,时间应为上个月26号至当月25号
QAGP.START_TIME = DateTime.Now.AddDays(-30);
QAGP.END_TIME = DateTime.Now;
}
//获取替代信息
result.data = SlabSubstitutionService.GetStockDate(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetSlabWGT")]
public RequestEntity GetSlabWGT()
{
RequestEntity result = new RequestEntity();
try
{
//获取历史数据
result.data = SlabSubstitutionService.GetSlabWgt();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetSlabCcl")]
public RequestEntity GetSlabCcl()
{
RequestEntity result = new RequestEntity();
try
{
//获取历史数据
result.data = SlabSubstitutionService.GetSlabCcl();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetSlabWgtSum")]
public RequestEntity GetSlabWgtSum()
{
RequestEntity result = new RequestEntity();
try
{
//获取历史数据
result.data = SlabSubstitutionService.GetSlabWgtSum();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetSlabStock")]
public RequestEntity GetSlabStock()
{
RequestEntity result = new RequestEntity();
try
{
//获取历史数据
result.data = SlabSubstitutionService.GetSlabStock();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetSlabOftime")]
public RequestEntity GetSlabOftime(TB_PROCESS_DATA data)
{
RequestEntity result = new RequestEntity();
try
{
if (data.TYPE == "实时")
data.TYPE = "0";
if (data.TYPE == "批量")
data.TYPE = "1";
//获取替代信息
if (data.START_TIME == null && data.END_TIME == null)
{
data.START_TIME = DateTime.Now.AddDays(-7).ToString("yyyyMMdd");
data.END_TIME = DateTime.Now.ToString("yyyyMMdd");
}
DataTable dt = SlabSubstitutionService.GetSlabOftime(data);
ArrayList al = new ArrayList();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
Random rd = new Random();
string[] e = new string[2];
e[0] = row[1].ToString();
e[1] = (row[3].ToInt() + rd.Next(-2, 2)).ToString();
al.Add(e);
}
}
}
result.data = al;
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
#endregion
#region 板坯手动匹配
//[HttpPost, Route("getTbSlabInfo")]
//public RequestEntity getTbSlabInfo(TB_SLAB_QUERY tB_SLAB)
//{
// RequestEntity result = new RequestEntity(); //声明返回参数实体类
// StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
// DataTable dtCheck = new DataTable();
// try
// {
// //开启数据库连接查询数据
// //using (IDbContext db = ObjectContainer.GetObject("db"))
// //{
// result.data = GetSlabInfo(tB_SLAB);
// result.msg = "操作成功!";
// result.code = "1";
// //}
// }
// catch (Exception ex)
// {
// result.msg = "数据库错误!";
// result.code = "0";
// logger.Error("GetSurplusMaterials 报错 : ", ex);
// }
// return result;
//}
//public IList GetSlabInfo(TB_SLAB_QUERY tB_SLAB)
//{
// IList ltSlab = new List();
// StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
// IList ltSlabC3 = new List();
// strSqlC3.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
// ", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
// ", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
// ", THK" +
// ", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
// ", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
// strSqlC3.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
// strSqlC3.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
// strSqlC3.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
// strSqlC3.AppendLine(" ELSE '0' END ) XY_FLG ");
// strSqlC3.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC3.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC3.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
// strSqlC3.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
// strSqlC3.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
// strSqlC3.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC3.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC3.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
// strSqlC3.AppendLine(" AND EST_CD IS NOT NULL) ");
// strSqlC3.AppendLine(" ELSE '' ");
// strSqlC3.AppendLine(" END ) EST_COMMENT ");
// strSqlC3.AppendLine("FROM NISCO.FP_SLAB A ");
// strSqlC3.AppendLine("WHERE 1 = 1 ");
// strSqlC3.AppendLine(" AND A.CUR_INV IN( 'ZB','00','ZZ','HB') ");//
// strSqlC3.AppendLine(" AND( (A.PROC_CD = 'CAC' AND (SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('0002','0003','2010') ) = 0) OR ");
// strSqlC3.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C " +
// "WHERE C.SLAB_NO = A.SLAB_NO " +
// "AND C.REASON_CD IN ('1080','2014','2015','2018','2026','3014','5011','5013','8081') " +
// "AND EST_CD IS NULL) >0) ");
// strSqlC3.AppendLine(" AND A.PROC_CD = 'CAD' ) ");
// strSqlC3.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('2010','0002')) < 1 ) ");
// strSqlC3.AppendLine(" AND A.ORD_FL = '2' ");
// strSqlC3.AppendLine(" AND A.REC_STS = '2' ");
// strSqlC3.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
// strSqlC3.AppendLine(" AND A.WGT > 0 ");
// strSqlC3.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' ");
// strSqlC3.AppendLine(" AND SUBSTR(A.SLAB_NO,3,1) <> 'F' ");
// strSqlC3.AppendLine(" AND NVL(A.QUALITY_UPD_GRD, 'N') NOT IN('N','E') ");
// strSqlC3.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE 'C3' || '%' ");
// strSqlC3.AppendLine(" AND((GREATEST(A.WID, A.LEN) >= 2050 AND LEAST(A.WID, A.LEN) >= 800 AND A.THK > 50) ");
// strSqlC3.AppendLine(" OR(GREATEST(A.WID, A.LEN) >= 2050 AND LEAST(A.WID, A.LEN) >= 850 AND A.THK = 50))---短尺 ");
// strSqlC3.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 )");
// strSqlC3.AppendLine(" AND A.WGT <31");
// //c2
// StringBuilder strSqlC2 = new StringBuilder();//声明拼接Sql语句变量
// IList ltSlabC2 = new List();
// strSqlC2.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
// ", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
// ", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
// ", THK" +
// ", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
// ", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
// strSqlC2.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
// strSqlC2.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
// strSqlC2.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
// strSqlC2.AppendLine(" ELSE '0' END ) XY_FLG ");
// strSqlC2.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC2.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC2.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
// strSqlC2.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
// strSqlC2.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
// strSqlC2.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC2.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC2.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
// strSqlC2.AppendLine(" AND EST_CD IS NOT NULL) ");
// strSqlC2.AppendLine(" ELSE '' ");
// strSqlC2.AppendLine(" END ) EST_COMMENT ");
// strSqlC2.AppendLine("FROM NISCO.FP_SLAB A ");
// strSqlC2.AppendLine("WHERE 1 = 1 ");
// strSqlC2.AppendLine(" AND A.CUR_INV in ( 'ZB','00','ZZ','HB') ");
// strSqlC2.AppendLine(" AND(A.PROC_CD = 'CAC' OR ");
// strSqlC2.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.REASON_CD NOT IN('1080','2014','2015','2018','2026','3014','5011','5013','8081') AND EST_CD IS NULL) < 1)");
// strSqlC2.AppendLine(" AND A.PROC_CD='CAD' ) ");
// strSqlC2.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('0002','0003','2010')) < 1 )");
// strSqlC2.AppendLine(" AND A.ORD_FL = '2' ");
// strSqlC2.AppendLine(" AND A.REC_STS = '2' ");
// strSqlC2.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
// strSqlC2.AppendLine(" AND A.WGT > 0 ");
// strSqlC2.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' ");
// strSqlC2.AppendLine(" AND NVL(A.QUALITY_UPD_GRD, 'N') NOT IN('N','E') ");
// strSqlC2.AppendLine(" AND LEAST(A.WID, A.LEN) >= 1600 ");
// strSqlC2.AppendLine(" AND GREATEST(A.WID, A.LEN) >= 2500 ");
// strSqlC2.AppendLine(" AND A.THK >= 120 ");
// strSqlC2.AppendLine(" AND NVL(A.PLAN_SLAB_MERGE_FL,'N') = 'N' ");
// strSqlC2.AppendLine(" AND NVL(A.PLAN_MILL_PLT,'N') LIKE 'C2' || '%' ");
// strSqlC2.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 )");
// //c1
// StringBuilder strSqlC1 = new StringBuilder();//声明拼接Sql语句变量
// IList ltSlabC1 = new List();
// strSqlC1.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
// ", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
// ", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
// ", THK" +
// ", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
// ", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
// strSqlC1.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
// strSqlC1.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
// strSqlC1.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
// strSqlC1.AppendLine(" ELSE '0' END ) XY_FLG ");
// strSqlC1.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC1.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC1.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
// strSqlC1.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
// strSqlC1.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
// strSqlC1.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
// strSqlC1.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
// strSqlC1.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
// strSqlC1.AppendLine(" AND EST_CD IS NOT NULL) ");
// strSqlC1.AppendLine(" ELSE '' ");
// strSqlC1.AppendLine(" END ) EST_COMMENT ");
// strSqlC1.AppendLine("FROM NISCO.FP_SLAB A ");
// strSqlC1.AppendLine("WHERE 1 = 1 ");
// strSqlC1.AppendLine(" AND(A.PROC_CD = 'CAC' OR ");
// strSqlC1.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.REASON_CD NOT IN('1080','2014','2015','2018','2026','3014','5011','5013','8081') AND EST_CD IS NULL) < 1)");
// strSqlC1.AppendLine(" AND A.PROC_CD='CAD' ) ");
// strSqlC1.AppendLine(" AND A.CUR_INV in '00' ");//
// strSqlC1.AppendLine(" AND A.PROC_CD = 'CAC' ");
// strSqlC1.AppendLine(" AND A.ORD_FL = '2' ");
// strSqlC1.AppendLine(" AND A.REC_STS = '2' ");
// strSqlC1.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
// strSqlC1.AppendLine(" AND A.WGT > 0 ");
// strSqlC1.AppendLine(" AND A.WID > 1600 ");
// strSqlC1.AppendLine(" AND A.LEN > 3900 ");
// strSqlC1.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') ");
// strSqlC1.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' ");
// strSqlC1.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
// strSqlC1.AppendLine(" AND SLAB_NO NOT IN ( SELECT SLAB_NO FROM NISCO.CP_SLAB_MOVE_PLAN WHERE PRC_STS = 'A' AND TO_INV in('ZB','HB') ) ");
// strSqlC1.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE 'C1' || '%' ");
// // P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。
// if (!string.IsNullOrEmpty(tB_SLAB.SLAB_NO))
// {
// strSqlC1.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
// strSqlC2.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
// strSqlC3.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
// }
// if (!string.IsNullOrEmpty(tB_SLAB.STLGRD))
// {
// strSqlC1.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
// strSqlC2.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
// strSqlC3.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
// }
// if (!string.IsNullOrEmpty(tB_SLAB.THK_MIN))
// {
// strSqlC1.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
// strSqlC2.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
// strSqlC3.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
// }
// if (!string.IsNullOrEmpty(tB_SLAB.THK_MAX))
// {
// strSqlC1.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
// strSqlC2.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
// strSqlC3.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
// }
// try
// {
// //开启数据库连接查询数据
// using (IDbContext db = ObjectContainer.GetObject("db_sur"))
// {
// if (tB_SLAB.PLT == "C3")
// {
// ltSlab = db.Query(strSqlC3.ToString());
// }
// if (tB_SLAB.PLT == "C2")
// {
// ltSlab = db.Query(strSqlC2.ToString());
// }
// if (tB_SLAB.PLT == "C1")
// {
// ltSlab = db.Query(strSqlC1.ToString());
// }
// if (string.IsNullOrEmpty(tB_SLAB.PLT))
// {
// ltSlabC3 = db.Query(strSqlC3.ToString());
// ltSlabC2 = db.Query(strSqlC2.ToString());
// ltSlabC1 = db.Query(strSqlC1.ToString());
// ltSlab = ltSlab.Union(ltSlabC3).Union(ltSlabC2).Union(ltSlabC1).ToList();
// }
// }
// }
// catch (Exception ex)
// {
// logger.Error("GetSlabInfo 报错", ex);
// }
// return ltSlab;
//}
[HttpPost, Route("getBpOrderInfo")]
public RequestEntity getBpOrderInfo(BP_ORDER_ITEM_QUERY BOI)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = getOrderInfo(BOI);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList getOrderInfo(BP_ORDER_ITEM_QUERY BOI)
{
StringBuilder strSql = new StringBuilder();//声明拼接Sql语句变量
IList ltBOI = new List();
strSql.AppendLine("SELECT DISTINCT ");
strSql.AppendLine(" BOI.ORD_NO, BOI.ORD_ITEM ,'' AS XY_FLG ");
strSql.AppendLine(" ,NVL(C.SMS_TOT_WGT, 0) SMS_TOT_WGT-- - 炼钢 ");
strSql.AppendLine(", NVL(C.CCM_TOT_WGT, 0) CCM_TOT_WGT--连铸 ");
strSql.AppendLine(",NVL(C.MILL_TOT_WGT, 0) ");
strSql.AppendLine(" - DECODE(BOI.IS_JC, ");
strSql.AppendLine(" 'Y', ");
strSql.AppendLine(" (SELECT NVL(SUM(WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB ");
strSql.AppendLine(" WHERE REC_STS = '2' ");
strSql.AppendLine(" AND ORD_FL = '1' ");
strSql.AppendLine(" AND PROC_CD IN('CAA', 'CAD') ");
strSql.AppendLine(" AND ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND INGOT_FL = 'A'), ");
strSql.AppendLine(" 0) ZGDD--轧钢等待 ");
strSql.AppendLine(",(SELECT NVL(SUM(E.WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB F, NISCO.FP_SLAB_DES E ");
strSql.AppendLine(" WHERE E.ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND E.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND E.BLOCK_SEQ > '00' ");
strSql.AppendLine(" AND E.SEQ > '00' ");
strSql.AppendLine(" AND E.REC_STS = '2' ");
strSql.AppendLine(" AND F.SLAB_NO = E.SLAB_NO ");
strSql.AppendLine(" AND F.ORD_FL = '1' ");
strSql.AppendLine(" AND E.PROC_CD = 'CAD') CADPL--CAD ");
strSql.AppendLine(" , QQD.THK_TOL_MIN ,QQD.THK_TOL_MAX ,BOI.REC_STS, BOI.PLN_ORD, BOI.PLN_ORD_ITEM, BOI.ORD_STS, BOI.HOLD_FL, BOI.HOLD_DATE, BOI.HOLD_TIME, BOI.HOLD_EMP_ID");
strSql.AppendLine(", BOI.CURRENCY, BOI.EXTRA_FL, BOI.DISCON_PRC, BOI.TOT_PRC, BOI.TRANS_PRC, BOI.EMP_ID, BOI.PROD_PRC, BOI.REG_DATE, BOI.REG_TIME, BOI.CONF_DATE ");
strSql.AppendLine(", BOI.CONF_TIME, BOI.CONF_EMP_ID, BOI.CUST_CD, BOI.ORD_CUST_CD, BOI.PROD_DGR, BOI.SALE_WAY, BOI.DEPT_CD, BOI.DEST_CD, BOI.DEST_DETAIL ");
strSql.AppendLine(", BOI.ENDUSE_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = BOI.STLGRD) STLGRD, BOI.PAYMENT_COND, BOI.DEL_COND, BOI.DEL_TOL_UNIT, NVL(CPP.ORD_REM_WGT, 0) DEL_TOL_MAX, NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100 DEL_TOL_MIN, BOI.WGT_UNIT, BOI.WGT_GRP ");
strSql.AppendLine(", BOI.PROD_WGT, BOI.PROD_WGT_MIN, BOI.PROD_WGT_MAX, BOI.TOT_WGT, BOI.STDSPEC, BOI.STDSPEC_YY, BOI.ORD_SIZE, BOI.ORD_WID, BOI.ORD_LEN, BOI.ORD_THK ");
strSql.AppendLine(", BOI.INDIA, BOI.OUTDIA, BOI.CAN_FL, BOI.CAN_DATE, BOI.CAN_TIME, BOI.CAN_EMP_ID, BOI.MOD_FL, BOI.MOD_DATE, BOI.MOD_TIME, BOI.DEL_FR_DATE, BOI.DEL_TO_DATE ");
strSql.AppendLine(", BOI.CUST_DEL_FR_DATE, BOI.CUST_DEL_TO_DATE, BOI.ORD_PROD_END_DATE, BOI.ORD_PROD_END_TIME, BOI.ORD_SHIP_END_DATE, BOI.ORD_SHIP_END_TIME, BOI.ORD_ACCP_DATE ");
strSql.AppendLine(", BOI.ORD_ACCP_TIME, BOI.CUST_REQ_PLANT, BOI.TENT_REQ_PLANT, BOI.CONF_PLANT, BOI.CUST_SPEC_NO, BOI.MARKING_WAY, BOI.STAMP, BOI.TRANSP_WAY, BOI.ORD_KND ");
strSql.AppendLine(", BOI.TRIM_FL, BOI.URGNT_FL, BOI.UST_FL, BOI.PAYMENT_FL, BOI.PAYMENT_DATE, BOI.PAYMENT_TIME, BOI.PAYMENT_EMP_ID, BOI.PACK_WAY, BOI.PACK_WGT_MAX ");
strSql.AppendLine(", BOI.PACK_WGT_MIN, BOI.NUM_PROD, BOI.SALE_EMP_ID, BOI.END_CUST_CD, BOI.INSP_CD, BOI.DOME_FL, BOI.PROD_CD, BOI.PROD_THK_TGT, BOI.SIZE_KND, BOI.ORD_LEN_MIN ");
strSql.AppendLine(", BOI.ORD_LEN_MAX, BOI.MATR_FL, BOI.CONT_END_DATE, BOI.CONT_END_TIME, BOI.CONT_END_EMP_ID, BOI.VESSEL_NO, BOI.CUST_REQ_NO, BOI.COLOR_STROKE, BOI.RELEASE_DATE ");
strSql.AppendLine(", BOI.RELEASE_TIME, BOI.RELEASE_EMP_ID, BOI.PLN_SMS_PLT, BOI.PLN_MILL_PLT, BOI.CFM_SMS_PLT, BOI.CFM_MILL_PLT, BOI.HTM_SHOT_BLAST ");
strSql.AppendLine(", BOI.INS_DATE, BOI.INS_TIME, BOI.INS_EMPID, BOI.INS_PGMID, BOI.UPD_DATE, BOI.UPD_TIME, BOI.UPD_EMPID, BOI.UPD_PGMID, BOI.SEALMEMO ");
strSql.AppendLine(", BOI.INSPUNITCODEA, BOI.INSPUNITCODEB, BOI.INSPUNITCODEC, BOI.PRODSPECNOA, BOI.PRODSPECNOB, BOI.PRODSPECNOC, BOI.PAINTNUM, BOI.LP_HD_THK, BOI.LP_MD_THK, BOI.LP_TL_THK ");
strSql.AppendLine(", BOI.LP_LEN1, BOI.LP_LEN2, BOI.LP_LEN3, BOI.LP_LEN4, BOI.LP_LEN5, BOI.IMP_CONT, BOI.INSPECT_ORGAN, BOI.CONTRACT_NO, BOI.TRIAL_PRODUCT, BOI.TRIAL_NUM, BOI.TRIAL_STR ");
strSql.AppendLine(", BOI.TRIAL_END, BOI.SIDEMARK, BOI.JIT_STRINGA, BOI.JIT_STRINGB, BOI.JIT_STRINGC, BOI.JITID, BOI.JIT_FLAG, BOI.QO_FL, BOI.SAMPLE_MEMO, BOI.SIZE_MEMO, BOI.PACK_MEMO ");
strSql.AppendLine(", BOI.FLUSH_FL, BOI.APPOINT_PLT, BOI.MORD_DESIGN_WGT, BOI.MORD_FL, BOI.APPOINT_PLT_REASON, BOI.SURFACE_REQUESTS, BOI.STAMP_FL, BOI.UST_INSP_FL, BOI.SPRAY_FL ");
strSql.AppendLine(", BOI.BUFPOOL_CD, BOI.MULTI_INSP_FL, BOI.CONTRACT_DATE, BOI.DELIVERY_STATUS, BOI.CUST_CLASS, BOI.CUST_LEVEL, BOI.SPECIAL_OPR_REQ, BOI.WITNESS_CONTENT, BOI.COGGING_FLAG ");
strSql.AppendLine(", BOI.STD_DET_CLASS_CD, BOI.STD_DET_CLASS_LVL, BOI.CERT_NOTE, BOI.INSPECT_FLAG, BOI.E2E_CUST, BOI.CUST_PURCHASE, BOI.GUID, BOI.NEW_CLASS_STATE, BOI.FACEPAINT ");
strSql.AppendLine(", BOI.IS_JC, BOI.UST_JC, BOI.LEVEL_JM, BOI.ORDER_NOFH, BOI.ITEM_NOFH, BOI.ORDER_THK_JC, BOI.ORDER_THK_FC, BOI.TYPEFH, BOI.PRODTYPENO, BOI.STEEL_SPRAY ");
strSql.AppendLine(", BOI.STEEL_PACK, BOI.STEEL_SHOTBLAST, BOI.STEEL_SLOTEPROCESS, BOI.ORDERQTY, BOI.ORDER_CNT, BOI.DELIVERY_STATUS1, BOI.DELIVERY_STATUS2, BOI.DELIVERY_STATUS3 ");
strSql.AppendLine(", BOI.SPECNOA, BOI.SPECNOB, BOI.SPECNOC, BOI.SPECNOA_YY, BOI.SPECNOB_YY, BOI.SPECNOC_YY, BOI.INSPUNITCODE, BOI.SUBCUSTNO, BOI.ISSHIPORDER, BOI.SAILINGDATE ");
strSql.AppendLine(", BOI.MARINEBOARD, BOI.ORDERNOYPK, BOI.ORDERITEMYPK, BOI.SORTINGMARK, BOI.UST_FL_PRINT, BOI.PRINTUTLEVEL, BOI.RULLBOARDCUT, BOI.PAINTUPT, BOI.ORDERPRICEB ");
strSql.AppendLine(", BOI.ADJUSTPRICE, BOI.HOTUT, BOI.HOTUTRATE, BOI.SPECIALSIGN, BOI.UST_MODE, BOI.INSP_CD1, BOI.INSP_CD2, BOI.QKL_CUSTNO ");
strSql.AppendLine(", CPP.ORD_WGT ");
//strSql.AppendLine(",FLOOR((NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) / TRUNC(((BOI.ORD_WID / 1000) * (BOI.ORD_LEN / 1000) * (BOI.ORD_THK / 1000)) * 7.85, 3)) AS SUB_LACK_NUM");
//欠量上线
strSql.AppendLine(" ,NVL((SELECT sum(A.WGT) ");
strSql.AppendLine(" FROM NISCO.EP_REQ_SLAB_D A, NISCO.EP_REQ_SLAB B ");
strSql.AppendLine(" WHERE ");
strSql.AppendLine("1 = 1 AND A.ORD_NO = BOI.ORD_NO AND A.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine("AND A.BLOCK_SEQ >= '01' ");
strSql.AppendLine("AND A.SEQ >= '01' ");
strSql.AppendLine("And B.REQ_SEQ_NO = A.REQ_SEQ_NO ");
strSql.AppendLine("AND B.REC_STS = '1'),0)+NVL(CPP.ORD_REM_WGT, 0) AS WGT_MAX ");
strSql.AppendLine(",(NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) AS SUB_LACK_WGT ");
strSql.AppendLine(",NVL(QQT.HTM_METH1,' ') HTM_METH1 ");
strSql.AppendLine(",NVL(QQT.HTM_METH2,' ') HTM_METH2 ");
strSql.AppendLine(",NVL(QQT.HTM_METH3,' ') HTM_METH3 ");
//HTM_COND1
strSql.AppendLine(",NVL(QQT.HTM_COND1,' ') HTM_COND1 ");
strSql.AppendLine(",NVL(QQT.HTM_COND2,' ') HTM_COND2 ");
strSql.AppendLine(",NVL(QQT.HTM_COND3,' ') HTM_COND3 ");
//成品成分
strSql.AppendLine(",(CASE WHEN ( SELECT COUNT(*) FROM NISCO.QP_QLTY_CHEM_FP QQCF WHERE QQCF.ORD_NO=BOI.ORD_NO AND QQCF.ORD_ITEM=BOI.ORD_ITEM )>0 THEN '1' ELSE '0' END ) CHEM_FLG ");
//strSql.AppendLine(",QSH.STDSPEC_NAME_ENG ");
strSql.AppendLine(",QSH.STDSPEC_STLGRD");
strSql.AppendLine(",(CASE WHEN ( SELECT COUNT(*) FROM NISCO.BP_ODER_XY BOXY WHERE BOXY.ORDER_NO=BOI.ORD_NO AND BOXY.ORDER_ITEM=BOI.ORD_ITEM )>0 THEN '1' ELSE '0' END ) XY_FLG ");
strSql.AppendLine(",(CASE WHEN instr( DECODE(QQT.MLT_PROC_LINE, '1', QQT.MLT_PROC_CD, QQT.MLT_PROC_CD2),'BH') > 0 THEN '1' ELSE '0' END ) VAC_FLG\r\n");
strSql.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.QP_QLTY_MATR_HA QQMH WHERE QQMH.ORD_NO = BOI.ORD_NO AND QQMH.ORD_ITEM = BOI.ORD_ITEM AND QQMH.TEST_KND IN('8', '9')) > 0 THEN '1' ELSE '0' END ) Z_FLG ");
strSql.AppendLine(",CASE WHEN BOI.CUST_DEL_TO_DATE > TO_CHAR(SYSDATE + 7, 'YYYYMMdd') THEN 0 ELSE 1 END DEL_FLG");
//strSql.AppendLine(",'4'AS SUB_LACK_NUM");
//strSql.AppendLine(",'4'AS LACK_NUM");
strSql.AppendLine(", (SELECT COUNT(A.REQ_SEQ_NO) ");
strSql.AppendLine(" FROM NISCO.EP_REQ_SLAB_D A, NISCO.EP_REQ_SLAB B ");
strSql.AppendLine(" WHERE ");
strSql.AppendLine(" 1 = 1 AND A.ORD_NO = BOI.ORD_NO AND A.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND A.BLOCK_SEQ >= '01' ");
strSql.AppendLine(" AND A.SEQ >= '01' ");
strSql.AppendLine(" And B.REQ_SEQ_NO = A.REQ_SEQ_NO ");
strSql.AppendLine(" AND B.REC_STS = '1') +GREATEST(FLOOR((NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) / TRUNC(((BOI.ORD_WID / 1000) * (BOI.ORD_LEN / 1000) * (BOI.ORD_THK / 1000)) * 7.85, 3)),0) AS SUB_LACK_NUM ");
strSql.AppendLine(", ( SELECT COUNT(A.REQ_SEQ_NO) ");
strSql.AppendLine(" FROM NISCO.EP_REQ_SLAB_D A, NISCO.EP_REQ_SLAB B ");
strSql.AppendLine(" WHERE ");
strSql.AppendLine(" 1 = 1 AND A.ORD_NO = BOI.ORD_NO AND A.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND A.BLOCK_SEQ >= '01' ");
strSql.AppendLine(" AND A.SEQ >= '01' ");
strSql.AppendLine(" And B.REQ_SEQ_NO = A.REQ_SEQ_NO ");
strSql.AppendLine(" AND B.REC_STS = '1') +GREATEST(FLOOR((NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) / TRUNC(((BOI.ORD_WID / 1000) * (BOI.ORD_LEN / 1000) * (BOI.ORD_THK / 1000)) * 7.85, 3)),0) AS LACK_NUM");
strSql.AppendLine("FROM NISCO.cp_prc CPP ");
strSql.AppendLine("INNER JOIN ");
strSql.AppendLine("NISCO.BP_ORDER_ITEM boi ");
strSql.AppendLine("ON BOI.ORD_NO = CPP.ORD_NO ");
strSql.AppendLine("AND BOI.ORD_ITEM = CPP.ORD_ITEM ");
strSql.AppendLine("AND BOI.ORD_WID <> 0 ");
strSql.AppendLine("AND BOI.ORD_LEN <> 0 ");
strSql.AppendLine("AND BOI.ORD_THK <> 0 ");
strSql.AppendLine("LEFT JOIN NISCO.QP_QLTY_TECH QQT ");
strSql.AppendLine("ON BOI.ORD_NO = QQT.ORD_NO ");
strSql.AppendLine("AND BOI.ORD_ITEM = QQT.ORD_ITEM ");
strSql.AppendLine("LEFT JOIN NISCO.QP_QLTY_DELV QQD ");
strSql.AppendLine("ON BOI.ORD_NO = QQD.ORD_NO ");
strSql.AppendLine("AND BOI.ORD_ITEM = QQD.ORD_ITEM ");
strSql.AppendLine("LEFT JOIN NISCO.QP_STD_HEAD QSH ");
strSql.AppendLine(" ON boi.STDSPEC = QSH.STDSPEC ");
strSql.AppendLine(" AND boi.STDSPEC_YY = QSH.STDSPEC_YY ");
strSql.AppendLine("LEFT JOIN(SELECT CPD.ORD_NO, ");
strSql.AppendLine("CPD.ORD_ITEM, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BC', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BD', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BE', CPD.TOT_WGT, 0)) AS SMS_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BF', CPD.TOT_WGT, 0)) AS CCM_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'CA', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'CB', CPD.TOT_WGT, 0)) AS MILL_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'CG', CPD.TOT_WGT, 0)) AS CUT_WAIT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'CG', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'DZ', CPD.TOT_WGT, 0)) AS CUT_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'QA', CPD.TOT_WGT, 0)) AS QUAL_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'XA', CPD.TOT_WGT, 0)) AS DISP_TOT_WGT ");
strSql.AppendLine(" FROM NISCO.CP_PRC_DET CPD ");
strSql.AppendLine(" GROUP BY CPD.ORD_NO, CPD.ORD_ITEM) C ");
strSql.AppendLine(" ON C.ORD_NO = BOI.ORD_NO AND C.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine("WHERE 1 = 1 ");
strSql.AppendLine(" AND ");
strSql.AppendLine(" (SELECT COUNT(A.REQ_SEQ_NO) ");
strSql.AppendLine(" FROM NISCO.EP_REQ_SLAB_D A, NISCO.EP_REQ_SLAB B");
strSql.AppendLine(" WHERE ");
strSql.AppendLine(" 1 = 1 AND A.ORD_NO = BOI.ORD_NO AND A.ORD_ITEM = BOI.ORD_ITEM");
strSql.AppendLine(" AND A.BLOCK_SEQ >= '01' ");
strSql.AppendLine(" AND A.SEQ >= '01' ");
strSql.AppendLine(" And B.REQ_SEQ_NO = A.REQ_SEQ_NO ");
strSql.AppendLine(" AND B.REC_STS = '1') + GREATEST(FLOOR((NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) / TRUNC(((BOI.ORD_WID / 1000) * (BOI.ORD_LEN / 1000) * (BOI.ORD_THK / 1000)) * 7.85, 3)),0) >= 0.95");
strSql.AppendLine(" AND boi.PROD_CD = 'PP' ");
strSql.AppendLine("AND boi.REC_STS = '2' ");
strSql.AppendLine("and boi.ORD_STS IN('E') ");
strSql.AppendLine(" AND (boi.ord_knd ='A' OR boi.ord_knd ='T') ");
// P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。
if (!string.IsNullOrEmpty(BOI.ORD_NO))
{
strSql.AppendLine("AND boi.ord_no like '%" + BOI.ORD_NO + "%'");
}
if (!string.IsNullOrEmpty(BOI.ORD_ITEM))
{
strSql.AppendLine("AND boi.ord_item like '%" + BOI.ORD_ITEM + "%'");
}
if (!string.IsNullOrEmpty(BOI.STLGRD))
{
strSql.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = BOI.STLGRD ) like '%" + BOI.STLGRD + "%'");
}
if (!string.IsNullOrEmpty(BOI.PLT))
{
strSql.AppendLine("AND boi.CFM_MILL_PLT = '" + BOI.PLT + "'");
}
if (!string.IsNullOrEmpty(BOI.THK_MIN))
{
strSql.AppendLine("AND boi.ORD_THK >= '" + BOI.THK_MIN + "'");
}
if (!string.IsNullOrEmpty(BOI.THK_MAX))
{
strSql.AppendLine("AND boi.ORD_THK <= '" + BOI.THK_MAX + "'");
}
if (!string.IsNullOrEmpty(BOI.STDSPEC_STLGRD))
{
strSql.AppendLine("AND QSH.STDSPEC_STLGRD like '%" + BOI.STDSPEC_STLGRD + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltBOI = db.Query(strSql.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetBOIInfo 报错", ex);
}
return ltBOI;
}
public IList getOrderInfo(string BOI)
{
StringBuilder strSql = new StringBuilder();//声明拼接Sql语句变量
IList ltBOI = new List();
strSql.AppendLine("SELECT DISTINCT ");
strSql.AppendLine(" BOI.ord_no,BOI.ord_item,'' AS XY_FLG, BOI.ORD_STS,BOI.STDSPEC,BOI.STLGRD,BOI.ORD_THK,BOI.ORD_WID,BOI.ORD_LEN,ROUND(BOI.ORD_THK/1000*BOI.ORD_WID/1000*BOI.ORD_LEN/1000*7.85,3) AS ORD_WGT ,BOI.SIZE_KND,BOI.DEL_TO_DATE,CPP.ORD_WGT as PROD_WGT ");
strSql.AppendLine(",NVL(CPP.ORD_REM_WGT, 0) DEL_TOL_MAX, NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100 DEL_TOL_MIN ");
strSql.AppendLine(" ,NVL(C.SMS_TOT_WGT, 0) SMS_TOT_WGT-- - 炼钢 ");
strSql.AppendLine(", NVL(C.CCM_TOT_WGT, 0) CCM_TOT_WGT--连铸 ");
strSql.AppendLine(",NVL(C.MILL_TOT_WGT, 0) ");
strSql.AppendLine(" - DECODE(BOI.IS_JC, ");
strSql.AppendLine(" 'Y', ");
strSql.AppendLine(" (SELECT NVL(SUM(WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB ");
strSql.AppendLine(" WHERE REC_STS = '2' ");
strSql.AppendLine(" AND ORD_FL = '1' ");
strSql.AppendLine(" AND PROC_CD IN('CAA', 'CAD') ");
strSql.AppendLine(" AND ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND INGOT_FL = 'A'), ");
strSql.AppendLine(" 0) ZGDD--轧钢等待 ");
strSql.AppendLine(",(SELECT NVL(SUM(E.WGT), 0) ");
strSql.AppendLine(" FROM NISCO.FP_SLAB F, NISCO.FP_SLAB_DES E ");
strSql.AppendLine(" WHERE E.ORD_NO = BOI.ORD_NO ");
strSql.AppendLine(" AND E.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine(" AND E.BLOCK_SEQ > '00' ");
strSql.AppendLine(" AND E.SEQ > '00' ");
strSql.AppendLine(" AND E.REC_STS = '2' ");
strSql.AppendLine(" AND F.SLAB_NO = E.SLAB_NO ");
strSql.AppendLine(" AND F.ORD_FL = '1' ");
strSql.AppendLine(" AND E.PROC_CD = 'CAD') CADPL--CAD ");
strSql.AppendLine(",BOI.CFM_MILL_PLT,BOI.COLOR_STROKE,BOI.CUST_CD ");
strSql.AppendLine("FROM NISCO.cp_prc CPP ");
strSql.AppendLine("INNER JOIN ");
strSql.AppendLine("NISCO.BP_ORDER_ITEM boi ");
strSql.AppendLine("ON BOI.ORD_NO = CPP.ORD_NO ");
strSql.AppendLine("AND BOI.ORD_ITEM = CPP.ORD_ITEM ");
strSql.AppendLine("AND BOI.ORD_WID <> 0 ");
strSql.AppendLine("AND BOI.ORD_LEN <> 0 ");
strSql.AppendLine("AND BOI.ORD_THK <> 0 ");
strSql.AppendLine("LEFT JOIN(SELECT CPD.ORD_NO, CPD.ORD_ITEM, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BC', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BD', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'BE', CPD.TOT_WGT, 0)) AS SMS_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'BF', CPD.TOT_WGT, 0)) AS CCM_TOT_WGT, ");
strSql.AppendLine(" SUM(DECODE(CPD.PRC, 'CA', CPD.TOT_WGT, 0) + ");
strSql.AppendLine(" DECODE(CPD.PRC, 'CB', CPD.TOT_WGT, 0)) AS MILL_TOT_WGT ");
strSql.AppendLine(" FROM NISCO.CP_PRC_DET CPD ");
strSql.AppendLine(" GROUP BY CPD.ORD_NO, CPD.ORD_ITEM) C ");
strSql.AppendLine(" ON C.ORD_NO = BOI.ORD_NO AND C.ORD_ITEM = BOI.ORD_ITEM ");
strSql.AppendLine("WHERE 1!=1 ");
strSql.AppendLine(BOI);
// P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltBOI = db.Query(strSql.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetBOIInfo 报错", ex);
}
return ltBOI;
}
///
/// 获取替代板坯信息
///
///
///
[HttpPost, Route("getTbSlabManual")]
public RequestEntity getTbSlabManual(TB_SLAB_MANUALQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
IList ltFSD = new List();
strSql.AppendLine("SELECT FSD.*,TO_DATE(INS_DATE||INS_TIME, 'yyyy-mm-dd hh24:mi:ss') SUB_DATE FROM TB_SLAB_MANUAL FSD WHERE 1=1 ");
//strSql.AppendLine("FROM FP_SLAB_DES FSD ");
//strSql.AppendLine("WHERE 1 = 1 AND FSD.HAN_RSL IS NULL");
if (queryArgs != null)
{
//板坯号
if (!string.IsNullOrWhiteSpace(queryArgs.SLAB_NO))
{
strSql.AppendLine(" AND FSD.SLAB_NO = '" + queryArgs.SLAB_NO + "'");
}
//订单号
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_NO))
{
strSql.AppendLine(" AND FSD.ORD_NO = '" + queryArgs.ORD_NO + "'");
}
//序列号
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_ITEM))
{
strSql.AppendLine(" AND FSD.ORD_ITEM = '" + queryArgs.ORD_ITEM + "'");
}
//工厂
if (!string.IsNullOrWhiteSpace(queryArgs.PLT))
{
strSql.AppendLine(" AND FSD.PLT = '" + queryArgs.PLT + "'");
}
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')");
}
strSql.AppendLine(" ORDER BY TO_DATE(INS_DATE||INS_TIME, 'yyyy-mm-dd hh24:mi:ss') desc ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("GetSlabSub 报错", ex);
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTbSlabManual")]
public RequestEntity DelTbSlabManual(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_SLAB_MANUAL WHERE 1=1 ");
strSql.AppendLine(string.Format(" AND SLAB_NO='{0}' AND ORD_NO = '{1}' AND ORD_ITEM = '{2}' ", model.SLAB_NO, 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;
}
///
/// 修改接口
///
///
///
[HttpPost, Route("UpdateTbSlabManual")]
public RequestEntity UpdateTbSlabManual(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_SLAB_MANUAL ");
strSql.AppendLine(string.Format("set IS_CUTTING = '{0}' where SLAB_NO = '{1}' ORD_NO = '{2}' and ORD_ITEM = '{3}' ", model[1].IS_CUTTING, model[1].SLAB_NO, model[1].ORD_NO, model[1].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("UpdateTbOrdSpeOne 报错", ex);
}
return result;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTbSlabManual")]
public RequestEntity AddTbSlabManual(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_SLAB_MANUAL 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("AddTbSlabManual 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTbSlabManualOne")]
public RequestEntity AddTbSlabManualOne(TB_SLAB_MANUAL 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.SLAB_NO = model.SLAB_NO.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("AddTbSlabManualOne 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 板坯替代统计
[HttpPost, Route("GetC1HisDataWGT")]
public RequestEntity GetC1HisDataWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//dtCheck = SerSurMatSubService.GetHisDataWGT(QAGP);
IList dtCheck = SerSurMatSubService.GetHisC1RATE_NEW(QAGP);
//dtCheck.Columns.Add("C1Total");
//dtCheck.Columns.Add("C2Total");
//dtCheck.Columns.Add("C3Total");
//dtCheck.Columns.Add("SUB_NUM_Total");
//dtCheck.Columns.Add("IS_END_Total");
//dtCheck.Columns.Add("Rate");
//double C1Total = 0;
//double C2Total = 0;
//double C3Total = 0;
//double SUB_NUM_Total = 0;
//double IS_END_Total = 0;
//double Rate = 0;
//DataTable dtrRate = new DataTable();
//dtrRate = SerSurMatSubService.GetHisC1RATE(QAGP);
//DataRow newrow = dtCheck.NewRow();
if (dtCheck.Count > 0)
{
//foreach (DataRow row in dtCheck.Rows)
//{
// C1Total += Convert.ToDouble(row["C1"].ToString());
// C2Total += Convert.ToDouble(row["C2"].ToString());
// C3Total += Convert.ToDouble(row["C3"].ToString());
// SUB_NUM_Total += Convert.ToDouble(row["SUB_NUM"].ToString());
// IS_END_Total += Convert.ToDouble(row["IS_END"].ToString());
// Rate = Convert.ToDouble(dtrRate.Rows[0]["SUB_RATE"].ToString());
//}
////foreach (DataRow rw in dtCheck.Rows)
////{
//// rw["C1Total"] = C1Total;
//// rw["C2Total"] = C2Total;
//// rw["C3Total"] = C3Total;
//// rw["SUB_NUM_Total"] = SUB_NUM_Total;
//// rw["IS_END_Total"] = IS_END_Total;
//// rw["Rate"] = dtrRate.Rows[0]["SUB_RATE"].ToString();
////}
//newrow["SUB_DATE"] = "合计";
//newrow["SUB_RATE"] = Rate;
//newrow["SUB_NUM"] = SUB_NUM_Total;
//newrow["C1"] = C1Total;
//newrow["C2"] = C2Total;
//newrow["C3"] = C3Total;
//newrow["IS_END"] = IS_END_Total;
//dtCheck.Rows.Add(newrow);
//获取历史数据
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
//获取历史数据
result.data = dtCheck;
result.msg = "无数据!";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataTotal 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetC2HisDataWGT")]
public RequestEntity GetC2HisDataWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//DataTable dtCheck = new DataTable();
//dtCheck = SerSurMatSubService.GetHisDataWGT(QAGP);
IList dtCheck = SerSurMatSubService.GetHisC2RATE_NEW(QAGP);
//dtCheck.Columns.Add("C1Total");
//dtCheck.Columns.Add("C2Total");
//dtCheck.Columns.Add("C3Total");
//dtCheck.Columns.Add("SUB_NUM_Total");
//dtCheck.Columns.Add("IS_END_Total");
//dtCheck.Columns.Add("Rate");
//double C1Total = 0;
//double C2Total = 0;
//double C3Total = 0;
//double SUB_NUM_Total = 0;
//double IS_END_Total = 0;
//double Rate = 0;
//DataTable dtrRate = new DataTable();
//dtrRate = SerSurMatSubService.GetHisC1RATE(QAGP);
//DataRow newrow = dtCheck.NewRow();
if (dtCheck.Count > 0)
{
//foreach (DataRow row in dtCheck.Rows)
//{
// C1Total += Convert.ToDouble(row["C1"].ToString());
// C2Total += Convert.ToDouble(row["C2"].ToString());
// C3Total += Convert.ToDouble(row["C3"].ToString());
// SUB_NUM_Total += Convert.ToDouble(row["SUB_NUM"].ToString());
// IS_END_Total += Convert.ToDouble(row["IS_END"].ToString());
// Rate = Convert.ToDouble(dtrRate.Rows[0]["SUB_RATE"].ToString());
//}
////foreach (DataRow rw in dtCheck.Rows)
////{
//// rw["C1Total"] = C1Total;
//// rw["C2Total"] = C2Total;
//// rw["C3Total"] = C3Total;
//// rw["SUB_NUM_Total"] = SUB_NUM_Total;
//// rw["IS_END_Total"] = IS_END_Total;
//// rw["Rate"] = dtrRate.Rows[0]["SUB_RATE"].ToString();
////}
//newrow["SUB_DATE"] = "合计";
//newrow["SUB_RATE"] = Rate;
//newrow["SUB_NUM"] = SUB_NUM_Total;
//newrow["C1"] = C1Total;
//newrow["C2"] = C2Total;
//newrow["C3"] = C3Total;
//newrow["IS_END"] = IS_END_Total;
//dtCheck.Rows.Add(newrow);
//获取历史数据
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
//获取历史数据
result.data = dtCheck;
result.msg = "无数据!";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataTotal 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetC3HisDataWGT")]
public RequestEntity GetC3HisDataWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
//DataTable dtCheck = new DataTable();
////dtCheck = SerSurMatSubService.GetHisDataWGT(QAGP);
//dtCheck = SerSurMatSubService.GetHisC3RATE(QAGP);
IList dtCheck = SerSurMatSubService.GetHisC3RATE_NEW(QAGP);
if (dtCheck.Count > 0)
{
//获取历史数据
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
//获取历史数据
result.data = dtCheck;
result.msg = "无数据!";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataTotal 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetAllHisDataWGT")]
public RequestEntity GetAllHisDataWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
IList dtCheck1 = new List();
IList dtCheck2 = new List();
IList dtCheck3 = new List();
//多线程获取数据
Task[] tasks = new Task[3];
tasks[0] = Task.Factory.StartNew(() =>
{
dtCheck1 = SerSurMatSubService.GetHisC1RATE_NEW(QAGP);
});
tasks[1] = Task.Factory.StartNew(() =>
{
dtCheck2 = SerSurMatSubService.GetHisC2RATE_NEW(QAGP);
});
tasks[2] = Task.Factory.StartNew(() =>
{
dtCheck3 = SerSurMatSubService.GetHisC3RATE_NEW(QAGP);
});
//进程等待
Task.WaitAll(tasks);
//dtCheck2 = SerSurMatSubService.GetHisC2RATE_NEW(QAGP);
//dtCheck3 = SerSurMatSubService.GetHisC3RATE_NEW(QAGP);
//QAGP.START_TIME = DateTime.Now.AddDays(-6);
//QAGP.END_TIME = DateTime.Now.AddDays(-1); ;
//dtCheck1 = SerSurMatSubService.GetHisC1RATE_NEW(QAGP);
IList dtCheck = new List();
//QAGP.START_TIME = DateTime.Now.AddDays(-6);
//QAGP.END_TIME = DateTime.Now;
DateTime startDate = QAGP.START_TIME;
DateTime endDate = QAGP.END_TIME;
for (DateTime currentDate = startDate; currentDate <= endDate; currentDate = currentDate.AddDays(1))
{
TB_SUB_ALL_RESULT TSAR = new TB_SUB_ALL_RESULT();
TB_SUB_RESULT TSR1 = dtCheck1.Where(p => p.SUB_DATE == currentDate.ToString("yyyy-MM-dd")).FirstOrDefault();
TB_SUB_RESULT TSR2 = dtCheck2.Where(p => p.SUB_DATE == currentDate.ToString("yyyy-MM-dd")).FirstOrDefault();
TB_SUB_RESULT TSR3 = dtCheck3.Where(p => p.SUB_DATE == currentDate.ToString("yyyy-MM-dd")).FirstOrDefault();
//C1
try
{
if (TSR1 != null)
{
TSAR.MANMMDE_COUNT_C1 = TSR1.MANMMDE_COUNT;
TSAR.MANMMDE_YIELD_C1 = TSR1.MANMMDE_YIELD;
if (TSAR.MANMMDE_COUNT_C1 == null || TSAR.MANMMDE_COUNT_C1 == 0)
{
TSAR.MANMMDE_YIELD_C1 = 0;
}
if (TSAR.MANMMDE_YIELD_C1 > 100)
{
TSAR.MANMMDE_YIELD_C1 = 95;
}
//TSAR.SUB_DATE_C1 = TSR1.SUB_DATE;
TSAR.SUB_DATE_C1 = TSR2.SUB_DATE;
TSAR.SUB_DATE_C2 = TSR1.SUB_DATE;
TSAR.SUB_DATE_C3 = TSR1.SUB_DATE;
TSAR.SYS_COUNT_C1 = TSR1.SYS_COUNT;
TSAR.SYS_PERCENT_C1 = TSR1.SYS_PERCENT;
TSAR.SYS_YIELD_C1 = TSR1.SYS_YIELD;
if (TSAR.SYS_YIELD_C1 > 100)
{
TSAR.SYS_YIELD_C1 = 95;
}
}
}
catch (Exception)
{
}
//C2
try
{
if (TSR2 != null)
{
TSAR.MANMMDE_COUNT_C2 = TSR2.MANMMDE_COUNT;
TSAR.MANMMDE_YIELD_C2 = TSR2.MANMMDE_YIELD;
if (TSAR.MANMMDE_COUNT_C2 == null || TSAR.MANMMDE_COUNT_C2 == 0)
{
TSAR.MANMMDE_YIELD_C2 = 0;
}
if (TSAR.MANMMDE_YIELD_C2 > 100)
{
TSAR.MANMMDE_YIELD_C2 = 95;
}
TSAR.SUB_DATE_C1 = TSR2.SUB_DATE;
TSAR.SUB_DATE_C2 = TSR1.SUB_DATE;
TSAR.SUB_DATE_C3 = TSR1.SUB_DATE;
TSAR.SYS_COUNT_C2 = TSR2.SYS_COUNT;
TSAR.SYS_PERCENT_C2 = TSR2.SYS_PERCENT;
TSAR.SYS_YIELD_C2 = TSR2.SYS_YIELD;
if (TSAR.SYS_YIELD_C2 > 100)
{
TSAR.SYS_YIELD_C2 = 95;
}
}
}
catch (Exception)
{
}
//C3
try
{
if (TSR3 != null)
{
TSAR.MANMMDE_COUNT_C3 = TSR3.MANMMDE_COUNT;
TSAR.MANMMDE_YIELD_C3 = TSR3.MANMMDE_YIELD;
if (TSAR.MANMMDE_COUNT_C3 == null || TSAR.MANMMDE_COUNT_C3 == 0)
{
TSAR.MANMMDE_YIELD_C3 = 0;
}
if (TSAR.MANMMDE_YIELD_C3 > 100)
{
TSAR.MANMMDE_YIELD_C3 = 95;
}
TSAR.SUB_DATE_C1 = TSR2.SUB_DATE;
TSAR.SUB_DATE_C2 = TSR1.SUB_DATE;
TSAR.SUB_DATE_C3 = TSR1.SUB_DATE;
TSAR.SYS_COUNT_C3 = TSR3.SYS_COUNT;
TSAR.SYS_PERCENT_C3 = TSR3.SYS_PERCENT;
TSAR.SYS_YIELD_C3 = TSR3.SYS_YIELD;
if (TSAR.SYS_YIELD_C3 > 100)
{
TSAR.SYS_YIELD_C3 = 95;
}
}
}
catch (Exception)
{
}
//汇总
try
{
IList ltYileld1 = new List();
ltYileld1.Add(ConverDataToDecimal(TSAR.MANMMDE_YIELD_C1));
ltYileld1.Add(ConverDataToDecimal(TSAR.MANMMDE_YIELD_C2));
ltYileld1.Add(ConverDataToDecimal(TSAR.MANMMDE_YIELD_C3));
IList ltYileld2 = new List();
ltYileld2.Add(ConverDataToDecimal(TSAR.SYS_YIELD_C1));
ltYileld2.Add(ConverDataToDecimal(TSAR.SYS_YIELD_C2));
ltYileld2.Add(ConverDataToDecimal(TSAR.SYS_YIELD_C3));
TSAR.MANMMDE_COUNT_ALL = ConverDataToDecimal(TSAR.MANMMDE_COUNT_C1) + ConverDataToDecimal(TSAR.MANMMDE_COUNT_C2) + ConverDataToDecimal(TSAR.MANMMDE_COUNT_C3);
if (ltYileld1.Where(p => p != 0).Count() == 0)
{
TSAR.MANMMDE_YIELD_ALL = 0;
}
else
{
TSAR.MANMMDE_YIELD_ALL = Math.Round((ConverDataToDecimal(TSAR.MANMMDE_YIELD_C1) + ConverDataToDecimal(TSAR.MANMMDE_YIELD_C2) + ConverDataToDecimal(TSAR.MANMMDE_YIELD_C3)) / ltYileld1.Where(p => p != 0).Count(), 2);
}
//TSAR.MANMMDE_YIELD_ALL = Math.Round((ConverDataToDecimal(TSAR.MANMMDE_YIELD_C1) + ConverDataToDecimal(TSAR.MANMMDE_YIELD_C2) + ConverDataToDecimal(TSAR.MANMMDE_YIELD_C3)) / ltYileld1.Where(p => p != 0).Count(), 2);
TSAR.SUB_DATE_ALL = currentDate.ToString("yyyy-MM-dd");
TSAR.SYS_COUNT_ALL = ConverDataToDecimal(TSAR.SYS_COUNT_C1) + ConverDataToDecimal(TSAR.SYS_COUNT_C2) + ConverDataToDecimal(TSAR.SYS_COUNT_C3); //TSR3.SYS_COUNT;
TSAR.SYS_PERCENT_ALL = Math.Round((ConverDataToDecimal(TSAR.SYS_COUNT_ALL)) / (ConverDataToDecimal(TSAR.MANMMDE_COUNT_ALL) + ConverDataToDecimal(TSAR.SYS_COUNT_ALL)), 3) * 100;// TSR3.SYS_PERCENT;
if (ltYileld2.Where(p => p != 0).Count() == 0)
{
TSAR.SYS_YIELD_ALL = 0;
}
else
{
TSAR.SYS_YIELD_ALL = Math.Round((ConverDataToDecimal(TSAR.SYS_YIELD_C1) + ConverDataToDecimal(TSAR.SYS_YIELD_C2) + ConverDataToDecimal(TSAR.SYS_YIELD_C3)) / ltYileld2.Where(p => p != 0).Count(), 2); // TSR3.SYS_YIELD;
}
//TSAR.SYS_YIELD_ALL = Math.Round((ConverDataToDecimal(TSAR.SYS_YIELD_C1) + ConverDataToDecimal(TSAR.SYS_YIELD_C2) + ConverDataToDecimal(TSAR.SYS_YIELD_C3)) / ltYileld2.Where(p=>p!=0).Count(), 2); // TSR3.SYS_YIELD;
}
catch (Exception)
{
}
dtCheck.Add(TSAR);
}
TB_SUB_ALL_RESULT TSAR2 = new TB_SUB_ALL_RESULT();
TSAR2.MANMMDE_COUNT_ALL = dtCheck.Sum(p => p.MANMMDE_COUNT_ALL);
TSAR2.MANMMDE_COUNT_C1 = dtCheck.Sum(p => p.MANMMDE_COUNT_C1);
TSAR2.MANMMDE_COUNT_C2 = dtCheck.Sum(p => p.MANMMDE_COUNT_C2);
TSAR2.MANMMDE_COUNT_C3 = dtCheck.Sum(p => p.MANMMDE_COUNT_C3);
TSAR2.MANMMDE_YIELD_ALL = dtCheck.Where(p => p.MANMMDE_YIELD_ALL != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.MANMMDE_YIELD_ALL) / dtCheck.Where(p => p.MANMMDE_YIELD_ALL != 0).Count();
TSAR2.MANMMDE_YIELD_C1 = dtCheck.Where(p => p.MANMMDE_YIELD_C1 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.MANMMDE_YIELD_C1) / dtCheck.Where(p => p.MANMMDE_YIELD_C1 != 0).Count();
TSAR2.MANMMDE_YIELD_C2 = dtCheck.Where(p => p.MANMMDE_YIELD_C2 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.MANMMDE_YIELD_C2) / dtCheck.Where(p => p.MANMMDE_YIELD_C2 != 0).Count();
TSAR2.MANMMDE_YIELD_C3 = dtCheck.Where(p => p.MANMMDE_YIELD_C3 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.MANMMDE_YIELD_C3) / dtCheck.Where(p => p.MANMMDE_YIELD_C3 != 0).Count();
TSAR2.SUB_DATE_ALL = "总计";
TSAR2.SUB_DATE_C1 = "总计";
TSAR2.SUB_DATE_C2 = "总计";
TSAR2.SUB_DATE_C3 = "总计";
TSAR2.SYS_COUNT_ALL = dtCheck.Sum(p => p.SYS_COUNT_ALL);
TSAR2.SYS_COUNT_C1 = dtCheck.Sum(p => p.SYS_COUNT_C1);
TSAR2.SYS_COUNT_C2 = dtCheck.Sum(p => p.SYS_COUNT_C2);
TSAR2.SYS_COUNT_C3 = dtCheck.Sum(p => p.SYS_COUNT_C3);
TSAR2.SYS_YIELD_ALL = dtCheck.Where(p => p.SYS_YIELD_ALL != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.SYS_YIELD_ALL) / dtCheck.Where(p => p.SYS_YIELD_ALL != 0).Count();
TSAR2.SYS_YIELD_C1 = dtCheck.Where(p => p.SYS_YIELD_C1 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.SYS_YIELD_C1) / dtCheck.Where(p => p.SYS_YIELD_C1 != 0 && p.SYS_YIELD_C1 != null).Count();
TSAR2.SYS_YIELD_C2 = dtCheck.Where(p => p.SYS_YIELD_C2 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.SYS_YIELD_C2) / dtCheck.Where(p => p.SYS_YIELD_C2 != 0 && p.SYS_YIELD_C2 != null).Count();
TSAR2.SYS_YIELD_C3 = dtCheck.Where(p => p.SYS_YIELD_C3 != 0).Count() == 0 ? 0 : dtCheck.Sum(p => p.SYS_YIELD_C3) / dtCheck.Where(p => p.SYS_YIELD_C3 != 0 && p.SYS_YIELD_C3 != null).Count();
TSAR2.SYS_PERCENT_ALL = TSAR2.MANMMDE_COUNT_ALL + TSAR2.SYS_COUNT_ALL > 0 ? TSAR2.SYS_COUNT_ALL / (TSAR2.MANMMDE_COUNT_ALL + TSAR2.SYS_COUNT_ALL) : 0;
TSAR2.SYS_PERCENT_C1 = TSAR2.MANMMDE_COUNT_C1 + TSAR2.SYS_COUNT_C1 > 0 ? TSAR2.SYS_COUNT_C1 / (TSAR2.MANMMDE_COUNT_C1 + TSAR2.SYS_COUNT_C1) : 0;
TSAR2.SYS_PERCENT_C2 = TSAR2.MANMMDE_COUNT_C2 + TSAR2.SYS_COUNT_C2 > 0 ? TSAR2.SYS_COUNT_C2 / (TSAR2.MANMMDE_COUNT_C2 + TSAR2.SYS_COUNT_C2) : 0;
TSAR2.SYS_PERCENT_C3 = TSAR2.MANMMDE_COUNT_C3 + TSAR2.SYS_COUNT_C3 > 0 ? TSAR2.SYS_COUNT_C3 / (TSAR2.MANMMDE_COUNT_C3 + TSAR2.SYS_COUNT_C3) : 0;
TSAR2.SYS_PERCENT_ALL = Math.Round((decimal)TSAR2.SYS_PERCENT_ALL * 100, 2);
TSAR2.SYS_PERCENT_C1 = Math.Round((decimal)TSAR2.SYS_PERCENT_C1 * 100, 2);
TSAR2.SYS_PERCENT_C2 = Math.Round((decimal)TSAR2.SYS_PERCENT_C2 * 100, 2);
TSAR2.SYS_PERCENT_C3 = Math.Round((decimal)TSAR2.SYS_PERCENT_C3 * 100, 2);
TSAR2.MANMMDE_YIELD_ALL = Math.Round((decimal)TSAR2.MANMMDE_YIELD_ALL, 2);
TSAR2.MANMMDE_YIELD_C1 = Math.Round((decimal)TSAR2.MANMMDE_YIELD_C1, 2);
TSAR2.MANMMDE_YIELD_C2 = Math.Round((decimal)TSAR2.MANMMDE_YIELD_C2, 2);
TSAR2.MANMMDE_YIELD_C3 = Math.Round((decimal)TSAR2.MANMMDE_YIELD_C3, 2);
TSAR2.SYS_YIELD_ALL = Math.Round((decimal)TSAR2.SYS_YIELD_ALL, 2);
TSAR2.SYS_YIELD_C1 = Math.Round((decimal)TSAR2.SYS_YIELD_C1, 2);
TSAR2.SYS_YIELD_C2 = Math.Round((decimal)TSAR2.SYS_YIELD_C2, 2);
TSAR2.SYS_YIELD_C3 = Math.Round((decimal)TSAR2.SYS_YIELD_C3, 2);
dtCheck.Add(TSAR2);
foreach (TB_SUB_RESULT item in dtCheck1)
{
}
if (dtCheck.Count > 0)
{
//获取历史数据
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
//获取历史数据
result.data = dtCheck;
result.msg = "无数据!";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetAllHisDataWGT 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetAllHisSMPDataWGT")]
public RequestEntity GetAllHisSMPDataWGT(GpPlateQueryArgs QAGP)
{
RequestEntity result = new RequestEntity();
try
{
if (QAGP.START_TIME == DateTime.MinValue && QAGP.END_TIME == DateTime.MinValue)
{
QAGP.START_TIME = DateTime.Now.AddDays(-6);
QAGP.END_TIME = DateTime.Now;
}
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine(" SELECT ");
strSql.AppendLine(" CASE ");
strSql.AppendLine(" WHEN GROUPING(TRUNC(TO_DATE(INS_DATE, 'YYYYMMDDHH24MISS'))) = 1 ");
strSql.AppendLine(" THEN '合计' ");
strSql.AppendLine(" ELSE TO_CHAR(TRUNC(TO_DATE(INS_DATE, 'YYYYMMDDHH24MISS')), 'YYYY-MM-DD') ");
strSql.AppendLine(" END AS INS_DATE, ");
strSql.AppendLine(" COUNT(PLATE_NO) AS CNT, ");
strSql.AppendLine(" SUM(TO_NUMBER(COSTS)) AS COSTS ");
strSql.AppendLine("FROM ");
strSql.AppendLine(" PDI_SMP_NO ");
strSql.AppendLine(" WHERE 1=1 ");
if (QAGP.START_TIME != DateTime.MinValue)
{
strSql.AppendLine(" AND TO_CHAR(TO_DATE(INS_DATE, 'yyyy-MM-dd HH24:mi:ss'), 'yyyyMMdd') >= TO_CHAR(TO_DATE('" + QAGP.START_TIME.ToString("yyyy-MM-dd") + "','yyyy-MM-dd HH24:mi:ss'), 'yyyyMMdd')");
}
if (QAGP.END_TIME != DateTime.MinValue)
{
strSql.AppendLine(" AND TO_CHAR(TO_DATE(INS_DATE, 'yyyy-MM-dd HH24:mi:ss'), 'yyyyMMdd') <= TO_CHAR(TO_DATE('" + QAGP.END_TIME + "','yyyy-MM-dd HH24:mi:ss'), 'yyyyMMdd')");
}
//strSql.AppendLine(" WHERE TO_DATE(INS_DATE, 'YYYYMMDDHH24MISS') ");
//strSql.AppendLine(" BETWEEN TO_DATE('20240601', 'YYYYMMDD') ");
//strSql.AppendLine(" AND TO_DATE('20240630', 'YYYYMMDD') ");
strSql.AppendLine("GROUP BY ");
strSql.AppendLine(" ROLLUP(TRUNC(TO_DATE(INS_DATE, 'YYYYMMDDHH24MISS'))) ");
strSql.AppendLine("ORDER BY ");
strSql.AppendLine(" INS_DATE ");
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
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("getSlabConf 报错", ex);
}
return result;
}
///
/// Null转换Decimal
///
/// 参数
///
public static decimal ConverDataToDecimal(object obj)
{
if (obj == null)
{
return 0;
}
else
{
return Convert.ToDecimal(obj);
}
}
#endregion
#region 板坯指定替代
///
/// 参数校验
///
///
/// ///
/// 是否通过参数校验
public bool ParameterCalibration(TB_SLAB_APPOINTSUBSTITUTE 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
}
///
/// 查询接口
///
///
///
[HttpPost, Route("GetTbSlabAS")]
public RequestEntity GetTbSlabAS(TB_SLAB_APPOINTSUBSTITUTE query)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//查询
strSql.AppendLine("SELECT SLAB_NO, ORD_NO, ORD_ITEM, REMARKS, 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_SLAB_APPOINTSUBSTITUTE WHERE 1 = 1 ");
if (query != null)
{
if (!string.IsNullOrWhiteSpace(query.SLAB_NO))
strSql.AppendLine(" AND SLAB_NO LIKE '%" + query.SLAB_NO + "%'");
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.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("AddTbSlabAS")]
public RequestEntity AddTbSlabAS(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_SLAB_APPOINTSUBSTITUTE 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.SLAB_NO = model.SLAB_NO.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("AddTbSlabAS 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#region 优先匹配订单接口
[HttpPost, Route("getTbSlabInfo")]
public RequestEntity getTbSlabInfo(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetSlabInfo(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetSlabInfo(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
", THK" +
", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
strSqlC3.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
strSqlC3.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
strSqlC3.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
strSqlC3.AppendLine(" ELSE '0' END ) XY_FLG ");
strSqlC3.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC3.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC3.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
strSqlC3.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
strSqlC3.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
strSqlC3.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC3.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC3.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
strSqlC3.AppendLine(" AND EST_CD IS NOT NULL) ");
strSqlC3.AppendLine(" ELSE '' ");
strSqlC3.AppendLine(" END ) EST_COMMENT ");
strSqlC3.AppendLine("FROM NISCO.FP_SLAB A ");
strSqlC3.AppendLine("WHERE 1 = 1 ");
strSqlC3.AppendLine(" AND A.CUR_INV IN( 'ZB','00','ZZ','HB') ");//
strSqlC3.AppendLine(" AND( (A.PROC_CD = 'CAC' AND (SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('0002','0003','2010') ) = 0) OR ");
strSqlC3.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C " +
"WHERE C.SLAB_NO = A.SLAB_NO " +
"AND C.REASON_CD IN ('1080','2014','2015','2018','2026','3014','5011','5013','8081') " +
"AND EST_CD IS NULL) >0) ");
strSqlC3.AppendLine(" AND A.PROC_CD = 'CAD' ) ");
strSqlC3.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('2010','0002')) < 1 ) ");
strSqlC3.AppendLine(" AND A.ORD_FL = '2' ");
strSqlC3.AppendLine(" AND A.REC_STS = '2' ");
strSqlC3.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
strSqlC3.AppendLine(" AND A.WGT > 0 ");
strSqlC3.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' ");
strSqlC3.AppendLine(" AND SUBSTR(A.SLAB_NO,3,1) <> 'F' ");
strSqlC3.AppendLine(" AND NVL(A.QUALITY_UPD_GRD, 'N') NOT IN('N','E') ");
strSqlC3.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE 'C3' || '%' ");
strSqlC3.AppendLine(" AND((GREATEST(A.WID, A.LEN) >= 2050 AND LEAST(A.WID, A.LEN) >= 800 AND A.THK > 50) ");
strSqlC3.AppendLine(" OR(GREATEST(A.WID, A.LEN) >= 2050 AND LEAST(A.WID, A.LEN) >= 850 AND A.THK = 50))---短尺 ");
strSqlC3.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 )");
strSqlC3.AppendLine(" AND A.WGT <31");
//c2
StringBuilder strSqlC2 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC2 = new List();
strSqlC2.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
", THK" +
", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
strSqlC2.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
strSqlC2.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
strSqlC2.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
strSqlC2.AppendLine(" ELSE '0' END ) XY_FLG ");
strSqlC2.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC2.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC2.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
strSqlC2.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
strSqlC2.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
strSqlC2.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC2.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC2.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
strSqlC2.AppendLine(" AND EST_CD IS NOT NULL) ");
strSqlC2.AppendLine(" ELSE '' ");
strSqlC2.AppendLine(" END ) EST_COMMENT ");
strSqlC2.AppendLine("FROM NISCO.FP_SLAB A ");
strSqlC2.AppendLine("WHERE 1 = 1 ");
strSqlC2.AppendLine(" AND A.CUR_INV in ( 'ZB','00','ZZ','HB') ");
strSqlC2.AppendLine(" AND(A.PROC_CD = 'CAC' OR ");
strSqlC2.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.REASON_CD NOT IN('1080','2014','2015','2018','2026','3014','5011','5013','8081') AND EST_CD IS NULL) < 1)");
strSqlC2.AppendLine(" AND A.PROC_CD='CAD' ) ");
strSqlC2.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('0002','0003','2010')) < 1 )");
strSqlC2.AppendLine(" AND A.ORD_FL = '2' ");
strSqlC2.AppendLine(" AND A.REC_STS = '2' ");
strSqlC2.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
strSqlC2.AppendLine(" AND A.WGT > 0 ");
strSqlC2.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' ");
strSqlC2.AppendLine(" AND NVL(A.QUALITY_UPD_GRD, 'N') NOT IN('N','E') ");
strSqlC2.AppendLine(" AND LEAST(A.WID, A.LEN) >= 1600 ");
strSqlC2.AppendLine(" AND GREATEST(A.WID, A.LEN) >= 2500 ");
strSqlC2.AppendLine(" AND A.THK >= 120 ");
strSqlC2.AppendLine(" AND NVL(A.PLAN_SLAB_MERGE_FL,'N') = 'N' ");
strSqlC2.AppendLine(" AND NVL(A.PLAN_MILL_PLT,'N') LIKE 'C2' || '%' ");
strSqlC2.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 )");
//c1
StringBuilder strSqlC1 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC1 = new List();
strSqlC1.AppendLine("SELECT SLAB_NO ,(SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STEEL_GRD_DETAIL" +
", OCCR_CD, PLT, PRC_LINE, REC_STS, PROC_CD" +
", BEF_PROC_CD, PROD_CD, (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) STLGRD" +
", THK" +
", CASE WHEN A.WID>A.LEN THEN A.LEN ELSE A.WID END WID " +
", CASE WHEN A.WID0 THEN '1' ELSE '0' END VAC_FLG ");
strSqlC1.AppendLine(",(CASE WHEN(SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET CSDD WHERE (CSDD.EST_CD LIKE '5%' OR CSDD.EST_CD LIKE '6%') AND CSDD.SLAB_NO = A.SLAB_NO) > 0 THEN '1'");
strSqlC1.AppendLine(" WHEN(SELECT COUNT(*) FROM(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C ");
strSqlC1.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) T_L WHERE T_L.COM LIKE '%协议%') > 0 THEN '1' ");
strSqlC1.AppendLine(" ELSE '0' END ) XY_FLG ");
strSqlC1.AppendLine(",(SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC1.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC1.AppendLine(" WHERE SLAB_NO = A.SLAB_NO ");
strSqlC1.AppendLine(" AND EST_CD IS NOT NULL) || ' ' || ");
strSqlC1.AppendLine(" (CASE WHEN A.MOTHER_SLAB IS NOT NULL AND LENGTH(A.MOTHER_SLAB) = 10 THEN ");
strSqlC1.AppendLine(" (SELECT wmsys.wm_concat(EST_CD || EST_COMMENT) ");
strSqlC1.AppendLine(" FROM NISCO.CP_SLAB_DELI_DET ");
strSqlC1.AppendLine(" WHERE SLAB_NO = A.MOTHER_SLAB ");
strSqlC1.AppendLine(" AND EST_CD IS NOT NULL) ");
strSqlC1.AppendLine(" ELSE '' ");
strSqlC1.AppendLine(" END ) EST_COMMENT ");
strSqlC1.AppendLine("FROM NISCO.FP_SLAB A ");
strSqlC1.AppendLine("WHERE 1 = 1 ");
strSqlC1.AppendLine(" AND(A.PROC_CD = 'CAC' OR ");
strSqlC1.AppendLine(" ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.REASON_CD NOT IN('1080','2014','2015','2018','2026','3014','5011','5013','8081') AND EST_CD IS NULL) < 1)");
strSqlC1.AppendLine(" AND A.PROC_CD='CAD' ) ");
strSqlC1.AppendLine(" AND A.CUR_INV in '00' ");//
strSqlC1.AppendLine(" AND A.PROC_CD = 'CAC' ");
strSqlC1.AppendLine(" AND A.ORD_FL = '2' ");
strSqlC1.AppendLine(" AND A.REC_STS = '2' ");
strSqlC1.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
strSqlC1.AppendLine(" AND A.WGT > 0 ");
strSqlC1.AppendLine(" AND A.WID > 1600 ");
strSqlC1.AppendLine(" AND A.LEN > 3900 ");
strSqlC1.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') ");
strSqlC1.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' ");
strSqlC1.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' ");
strSqlC1.AppendLine(" AND SLAB_NO NOT IN ( SELECT SLAB_NO FROM NISCO.CP_SLAB_MOVE_PLAN WHERE PRC_STS = 'A' AND TO_INV in('ZB','HB') ) ");
strSqlC1.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE 'C1' || '%' ");
// P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。
if (!string.IsNullOrEmpty(tB_SLAB.SLAB_NO))
{
strSqlC1.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
strSqlC2.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
strSqlC3.AppendLine("AND SLAB_NO like '%" + tB_SLAB.SLAB_NO + "%'");
}
if (!string.IsNullOrEmpty(tB_SLAB.STLGRD))
{
strSqlC1.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
strSqlC2.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
strSqlC3.AppendLine("AND (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = A.STLGRD ) like '%" + tB_SLAB.STLGRD + "%'");
}
if (!string.IsNullOrEmpty(tB_SLAB.THK_MIN))
{
strSqlC1.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
strSqlC2.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
strSqlC3.AppendLine("AND A.THK >= '" + tB_SLAB.THK_MIN + "'");
}
if (!string.IsNullOrEmpty(tB_SLAB.THK_MAX))
{
strSqlC1.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
strSqlC2.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
strSqlC3.AppendLine("AND A.THK <= '" + tB_SLAB.THK_MAX + "'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
if (tB_SLAB.PLT == "C3")
{
ltSlab = db.Query(strSqlC3.ToString());
}
if (tB_SLAB.PLT == "C2")
{
ltSlab = db.Query(strSqlC2.ToString());
}
if (tB_SLAB.PLT == "C1")
{
ltSlab = db.Query(strSqlC1.ToString());
}
if (string.IsNullOrEmpty(tB_SLAB.PLT))
{
ltSlabC3 = db.Query(strSqlC3.ToString());
ltSlabC2 = db.Query(strSqlC2.ToString());
ltSlabC1 = db.Query(strSqlC1.ToString());
ltSlab = ltSlab.Union(ltSlabC3).Union(ltSlabC2).Union(ltSlabC1).ToList();
}
}
}
catch (Exception ex)
{
logger.Error("GetSlabInfo 报错", ex);
}
return ltSlab;
}
//QP_NISCO_CHMC
[HttpPost, Route("getAPPOINT")]
public RequestEntity getAllAPPOINT(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetAPPOINT(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetAPPOINT 报错 : ", ex);
}
return result;
}
public IList GetAPPOINT(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
IList ltSlab_Info = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
//strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_APPOINT_ORDER WHERE 1=1 ");
strSqlC3.AppendLine("SELECT DISTINCT A.ORD_NO ,A.ORD_ITEM,A.XY_FLG,A.INS_DATE ,b.SLAB_NO FROM TB_APPOINT_ORDER A");
strSqlC3.AppendLine("LEFT JOIN(");
strSqlC3.AppendLine("SELECT FSD.ORD_NO, FSD.ORD_ITEM, LISTAGG(FSD.SLAB_NO, ',') WITHIN GROUP(ORDER BY FSD.SLAB_NO) AS SLAB_NO FROM FP_SLAB_DES FSD");
strSqlC3.AppendLine("WHERE FSD.BLOCK_SEQ <> 0 AND FSD.SEQ <> 0 AND ");
strSqlC3.AppendLine("FSD.ORD_NO || '-' || FSD.ORD_ITEM ");
strSqlC3.AppendLine("IN( ");
strSqlC3.AppendLine("SELECT T.ORD_NO || '-' || T.ORD_ITEM FROM TB_APPOINT_ORDER T ");
strSqlC3.AppendLine(") ");
strSqlC3.AppendLine("GROUP BY FSD.ORD_NO, FSD.ORD_ITEM ");
strSqlC3.AppendLine(") B ");
strSqlC3.AppendLine("ON B.ORD_NO = A.ORD_NO ");
strSqlC3.AppendLine("AND B.ORD_ITEM = A.ORD_ITEM ");
strSqlC3.AppendLine("WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.ORD_NO))
{
strSqlC3.AppendLine("AND A.ORD_NO LIKE '%" + tB_SLAB.ORD_NO + "%'");
}
if (!string.IsNullOrEmpty(tB_SLAB.ORD_ITEM))
{
strSqlC3.AppendLine("AND A.ORD_ITEM LIKE '%" + tB_SLAB.ORD_ITEM + "%'");
}
if (!string.IsNullOrEmpty(tB_SLAB.XY_FLG))
{
strSqlC3.AppendLine("AND A.XY_FLG = '" + tB_SLAB.XY_FLG + "'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
string BOI = String.Empty;
foreach (TB_APPOINT_ORDER order in ltSlab)
{
BOI += string.Format(" or (boi.ORD_NO = '{0}' and boi.ORD_ITEM = '{1}')", order.ORD_NO, order.ORD_ITEM);
}
ltSlab_Info = getOrderInfo(BOI);
//添加协议
foreach (var item in ltSlab_Info)
{
if (ltSlab.Where(p=>p.ORD_NO== item.ORD_NO && p.ORD_ITEM==item.ORD_ITEM).Count()>0)
{
item.XY_FLG = ltSlab.Where(p => p.ORD_NO == item.ORD_NO && p.ORD_ITEM == item.ORD_ITEM).FirstOrDefault().XY_FLG;
}
}
}
catch (Exception ex)
{
logger.Error("GetAPPOINT 报错", ex);
}
return ltSlab_Info;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddAPPOINT")]
public RequestEntity AddAPPOINT(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_APPOINT_ORDER 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.SLAB_NO = model.SLAB_NO.Trim();
model.ORD_ITEM = model.ORD_ITEM.ToString().PadLeft(3, '0');
model.SLAB_NO = "";
model.XY_FLG = "非协议";//非协议
model.INS_DATE = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
//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("AddAPPOINT 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddAPPOINTXYB")]
public RequestEntity AddAPPOINTXYB(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_APPOINT_ORDER 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.SLAB_NO = model.SLAB_NO.Trim();
model.ORD_ITEM = model.ORD_ITEM.ToString().PadLeft(3, '0');
model.SLAB_NO = "";
model.XY_FLG = "协议(XYB)";//XYB 标识 ,协议坯
model.INS_DATE = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
//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("AddAPPOINTXYB 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelAPPOINT")]
public RequestEntity DelAPPOINT(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder();
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_APPOINT_ORDER 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.ToString().PadLeft(3, '0');
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_APPOINT_ORDER 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
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelAPPOINT 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
[HttpPost, Route("ManualTriggering")]
///
/// 手动触发程序
///
///
///
public RequestEntity ManualTriggering(SupersedeQueryArgs ArgsSupersede)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
try
{
//string args = "";
//Process KHMsg = new Process();
//KHMsg.StartInfo.FileName = @"D:\Program\Slab\SlabHandle.exe";
//KHMsg.StartInfo.Arguments = args;
////KHMsg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//隐藏
//KHMsg.Start();
//result.msg = "操作成功!30分钟后刷新数据。";
//result.code = "1";
//while (!KHMsg.HasExited) { } //如果exe还没关闭,则等待
//if (KHMsg.ExitCode == 1)
//{
// result.msg = "操作成功!";
// result.code = "1";
//}
//else
//{
// result.msg = "操作失败!";
// result.code = "0";
//}
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
StringBuilder strSql = new StringBuilder();
strSql = new StringBuilder();
strSql.AppendLine("UPDATE TB_MANUAL_TRIGGER SET FLG='1' WHERE ID=1 ");
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("ManualTriggering 报错", ex);
}
return result;
}
}
#endregion
#region 钢种保留接口
//QP_NISCO_CHMC
[HttpPost, Route("getQP_NISCO_CHMC")]
public RequestEntity getAllQP_NISCO_CHMC(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetQP_NISCO_CHMC(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetQP_NISCO_CHMC(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT * FROM NISCO.QP_NISCO_CHMC WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetSlabInfo 报错", ex);
}
return ltSlab;
}
//QP_NISCO_CHMC
[HttpPost, Route("getTB_STLGRD_CHMC")]
public RequestEntity getAllTB_STLGRD_CHMC(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetTB_STLGRD_CHMC(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTB_STLGRD_CHMC 报错 : ", ex);
}
return result;
}
public IList GetTB_STLGRD_CHMC(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_STLGRD_CHMC WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetTB_STLGRD_CHMC 报错", ex);
}
return ltSlab;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTB_STLGRD_CHMC")]
public RequestEntity AddTB_STLGRD_CHMC(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD)
|| string.IsNullOrEmpty(model.STLGRD_GRP)
|| string.IsNullOrEmpty(model.STEEL_GRD_DETAIL))
{
continue;
}
#endregion
//model.STLGRD = model.STLGRD.Trim();
//model.STLGRD_GRP = model.STLGRD_GRP.ToString().PadLeft(3, '0');
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("AddTB_STLGRD_CHMC 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTB_STLGRD_CHMC")]
public RequestEntity DelTB_STLGRD_CHMC(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
try
{
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD))
{
continue;
}
#endregion
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_STLGRD_CHMC WHERE 1=1 ");
strSql.AppendLine(string.Format(" AND STLGRD='{0}' ", model.STLGRD));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelAPPOINT 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 钢种保留接口_C1
//QP_NISCO_CHMC
[HttpPost, Route("getQP_NISCO_CHMC_C1")]
public RequestEntity getAllQP_NISCO_CHMC_C1(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetQP_NISCO_CHMC_C1(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetQP_NISCO_CHMC_C1(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT * FROM NISCO.QP_NISCO_CHMC WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetSlabInfo 报错", ex);
}
return ltSlab;
}
//QP_NISCO_CHMC
[HttpPost, Route("getTB_STLGRD_CHMC_C1")]
public RequestEntity getAllTB_STLGRD_CHMC_C1(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetTB_STLGRD_CHMC_C1(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTB_STLGRD_CHMC 报错 : ", ex);
}
return result;
}
public IList GetTB_STLGRD_CHMC_C1(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT= 'C1' ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetTB_STLGRD_CHMC_C1 报错", ex);
}
return ltSlab;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTB_STLGRD_CHMC_C1")]
public RequestEntity AddTB_STLGRD_CHMC_C1(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD)
|| string.IsNullOrEmpty(model.STLGRD_GRP)
|| string.IsNullOrEmpty(model.STEEL_GRD_DETAIL))
{
continue;
}
#endregion
model.PLT = "C1";
//model.STLGRD = model.STLGRD.Trim();
//model.STLGRD_GRP = model.STLGRD_GRP.ToString().PadLeft(3, '0');
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("AddTB_STLGRD_CHMC_C1 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTB_STLGRD_CHMC_C1")]
public RequestEntity DelTB_STLGRD_CHMC_C1(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
try
{
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD))
{
continue;
}
#endregion
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT ='C1' ");
strSql.AppendLine(string.Format(" AND STLGRD='{0}' ", model.STLGRD));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelAPPOINT_C1 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 钢种保留接口_C2
//QP_NISCO_CHMC
[HttpPost, Route("getQP_NISCO_CHMC_C2")]
public RequestEntity getAllQP_NISCO_CHMC_C2(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetQP_NISCO_CHMC_C2(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetQP_NISCO_CHMC_C2(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT * FROM NISCO.QP_NISCO_CHMC WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetSlabInfo 报错", ex);
}
return ltSlab;
}
//QP_NISCO_CHMC
[HttpPost, Route("getTB_STLGRD_CHMC_C2")]
public RequestEntity getAllTB_STLGRD_CHMC_C2(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetTB_STLGRD_CHMC_C2(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTB_STLGRD_CHMC 报错 : ", ex);
}
return result;
}
public IList GetTB_STLGRD_CHMC_C2(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT= 'C2' ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetTB_STLGRD_CHMC_C2 报错", ex);
}
return ltSlab;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTB_STLGRD_CHMC_C2")]
public RequestEntity AddTB_STLGRD_CHMC_C2(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD)
|| string.IsNullOrEmpty(model.STLGRD_GRP)
|| string.IsNullOrEmpty(model.STEEL_GRD_DETAIL))
{
continue;
}
#endregion
model.PLT = "C2";
//model.STLGRD = model.STLGRD.Trim();
//model.STLGRD_GRP = model.STLGRD_GRP.ToString().PadLeft(3, '0');
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("AddTB_STLGRD_CHMC_C2 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTB_STLGRD_CHMC_C2")]
public RequestEntity DelTB_STLGRD_CHMC_C2(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
try
{
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD))
{
continue;
}
#endregion
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT ='C2' ");
strSql.AppendLine(string.Format(" AND STLGRD='{0}' ", model.STLGRD));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelAPPOINT_C2 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 钢种保留接口_C3
//QP_NISCO_CHMC
[HttpPost, Route("getQP_NISCO_CHMC_C3")]
public RequestEntity getAllQP_NISCO_CHMC_C3(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetQP_NISCO_CHMC_C3(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetQP_NISCO_CHMC_C3(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT * FROM NISCO.QP_NISCO_CHMC WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetSlabInfo 报错", ex);
}
return ltSlab;
}
//QP_NISCO_CHMC
[HttpPost, Route("getTB_STLGRD_CHMC_C3")]
public RequestEntity getAllTB_STLGRD_CHMC_C3(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetTB_STLGRD_CHMC_C3(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTB_STLGRD_CHMC 报错 : ", ex);
}
return result;
}
public IList GetTB_STLGRD_CHMC_C3(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT= 'C3' ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetTB_STLGRD_CHMC_C3 报错", ex);
}
return ltSlab;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTB_STLGRD_CHMC_C3")]
public RequestEntity AddTB_STLGRD_CHMC_C3(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD)
|| string.IsNullOrEmpty(model.STLGRD_GRP)
|| string.IsNullOrEmpty(model.STEEL_GRD_DETAIL))
{
continue;
}
#endregion
model.PLT = "C3";
//model.STLGRD = model.STLGRD.Trim();
//model.STLGRD_GRP = model.STLGRD_GRP.ToString().PadLeft(3, '0');
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("AddTB_STLGRD_CHMC_C3 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTB_STLGRD_CHMC_C3")]
public RequestEntity DelTB_STLGRD_CHMC_C3(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
try
{
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_STLGRD_CHMC model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD))
{
continue;
}
#endregion
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_STLGRD_CHMC WHERE 1=1 AND PLT ='C3' ");
strSql.AppendLine(string.Format(" AND STLGRD='{0}' ", model.STLGRD));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelAPPOINT_C3 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 选择钢种_C3
//QP_NISCO_CHMC
[HttpPost, Route("getTB_C3_STLGRD_SEL")]
public RequestEntity getAllTB_C3_STLGRD_SEL(TB_SLAB_QUERY tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetTB_C3_STLGRD_SEL(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetTB_STLGRD_CHMC 报错 : ", ex);
}
return result;
}
public IList GetTB_C3_STLGRD_SEL(TB_SLAB_QUERY tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT DISTINCT * FROM TB_C3_STLGRD_SEL WHERE 1=1 AND PLT= 'C3' ");
if (!string.IsNullOrEmpty(tB_SLAB.STEEL_GRD_DETAIL))
{
strSqlC3.AppendLine("AND STEEL_GRD_DETAIL like '%" + tB_SLAB.STEEL_GRD_DETAIL + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db"))
{
ltSlab = db.Query(strSqlC3.ToString());
}
}
catch (Exception ex)
{
logger.Error("GetTB_C3_STLGRD_SEL 报错", ex);
}
return ltSlab;
}
///
/// 添加接口
///
///
///
[HttpPost, Route("AddTB_C3_STLGRD_SEL")]
public RequestEntity AddTB_C3_STLGRD_SEL(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_C3_STLGRD_SEL model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD)
|| string.IsNullOrEmpty(model.STLGRD_GRP)
|| string.IsNullOrEmpty(model.STEEL_GRD_DETAIL))
{
continue;
}
#endregion
model.PLT = "C3";
//model.STLGRD = model.STLGRD.Trim();
//model.STLGRD_GRP = model.STLGRD_GRP.ToString().PadLeft(3, '0');
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("AddTB_C3_STLGRD_SEL 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
///
/// 删除接口
///
///
///
[HttpPost, Route("DelTB_C3_STLGRD_SEL")]
public RequestEntity DelTB_C3_STLGRD_SEL(IList insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
try
{
using (IDbContext db = ObjectContainer.GetObject("db"))
{
db.BeginTransaction();
foreach (TB_C3_STLGRD_SEL model in insertModel)
{
#region 参数判断
if (string.IsNullOrEmpty(model.STLGRD))
{
continue;
}
#endregion
try
{
strSql = new StringBuilder();
strSql.AppendLine("DELETE FROM TB_C3_STLGRD_SEL WHERE 1=1 AND PLT ='C3' ");
strSql.AppendLine(string.Format(" AND STLGRD='{0}' ", model.STLGRD));
db.Execute(strSql.ToString()); // 执行删除数据操作
//执行完操作之后清空strSql 准备下次 appendLine
}
catch
{
logger.Error("该条记录删除失败 ");
}
}
result.msg = "操作成功!";
result.code = "1";
//数据操作成功则保存数据
db.Commit();
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("DelTB_C3_STLGRD_SEL 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
#endregion
#region 台式炉不可替代标准
//QP_NISCO_CHMC
[HttpPost, Route("getQP_STD_HEAD")]
public RequestEntity getAllQP_STD_HEAD(QP_STD_HEAD_C2 tB_SLAB)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject("db"))
//{
result.data = GetQP_STD_HEAD(tB_SLAB);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
public IList GetQP_STD_HEAD(QP_STD_HEAD_C2 tB_SLAB)
{
IList ltSlab = new List();
StringBuilder strSqlC3 = new StringBuilder();//声明拼接Sql语句变量
IList ltSlabC3 = new List();
strSqlC3.AppendLine(" SELECT * FROM NISCO.QP_STD_HEAD WHERE 1=1 ");
if (!string.IsNullOrEmpty(tB_SLAB.STDSPEC))
{
strSqlC3.AppendLine("AND STDSPEC like '%" + tB_SLAB.STDSPEC + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject("db_sur"))
{
ltSlab = db.Query