using Confluent.Kafka; using log4net; using MES.Interface; using Oracle.ManagedDataAccess.Client; using SlabHandle.Enity; using SOA.Objects; using SOA.Persistent; using Swashbuckle.Swagger; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using System.Text.RegularExpressions; namespace SlabHandle { public class SlabCoilService { private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); #region 获取数据 /// ///查询板卷板坯信息 /// /// 所有符合条件的板坯 public IList GetMediumSlab(string strWHere) { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList ltSlab = new List(); strSql.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, 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 "); strSql.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 or CSDD.SLAB_NO=substr(A.MOTHER_SLAB,1,10))) > 0 THEN '1'"); strSql.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 "); strSql.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' "); strSql.AppendLine(" ELSE '0' END ) XY_FLG "); strSql.AppendLine(",(SELECT COM FROM(SELECT CSDD_C.EST_CD || '_' || CSDD_C.EST_COMMENT COM FROM NISCO.CP_SLAB_DELI_DET CSDD_C"); strSql.AppendLine(" WHERE CSDD_C.SLAB_NO = A.SLAB_NO ORDER BY CSDD_C.EST_DATE DESC) T_COM WHERE ROWNUM = 1) EST_COMMENT "); strSql.AppendLine(" , (case when (select substr(MOTHER_SLAB,1,10) from nisco.fp_slab where slab_no=substr(A.MOTHER_SLAB,1,10)) is not null then (select mother_slab from nisco.fp_slab where slab_no=substr(A.MOTHER_SLAB,1,10)) else '' end) Gmother_slab "); //低倍标记 0为低倍不合 strSql.AppendLine(" , case when (SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') >0 THEN 1 ELSE 0 END FLG_LOWPOWER"); strSql.AppendLine("FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); //TODO: 测试数据2320047205 // strSql.AppendLine(" AND A.SLAB_NO in (" + //"'2330680931'" + //",'2330680932'" + // ",'2330713002'" + // ",'2330314731'" + //",'2330316103'" + // ",'2310553603'" + //")"); // strSql.AppendLine(" AND A.SLAB_NO like ('2430210031%')"); strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.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 )"); //strSql.AppendLine(" AND A.SLAB_NO!='2320297902' "); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); //strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND A.WID > 1600 "); strSql.AppendLine(" AND A.LEN > 3900 "); strSql.AppendLine(" AND A.THK < 260 "); strSql.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.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') ) "); strSql.AppendLine(" AND not ((substr(A.LOC,1,7) in ('S7I1701','S7I1702','S7I1703','S7I1801','S7I1802','S7I1803') or substr(A.LOC,1,5) in ('S3E04','S3E05','S3E06') ) and CUR_INV='00') "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); //3.11.5.4.9 订单有低倍要求并且物料低倍等级不合格的板坯,不允许替代。 //strSql.AppendLine(" AND ( ( (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower Q WHERE Q.ORD_NO =A.ORD_NO AND Q.ORD_ITEM=A.ORD_ITEM) >= 1) AND A.QUALITY_GRD = '4' AND ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') < 1 ))"); strSql.AppendLine(" AND (select COUNT(*) from nisco.fp_slab_C3 WHERE SLAB_NO=A.SLAB_NO AND FL='True')<1"); strSql.AppendLine(" AND (select COUNT(*) from nisco.fp_slab_C2 WHERE SLAB_NO=A.SLAB_NO AND FL='1')<1"); //strSql.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 ) ");// strSql.AppendLine(" ORDER BY A.LOC DESC, A.SLAB_NO ASC "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltSlab = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetMediumSlab 报错", ex); } return ltSlab; } public DataTable GetSlab(string strSlabNo) { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtReturn = new DataTable(); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { strSql.AppendLine("SELECT * FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); strSql.AppendLine("AND A.SLAB_NO = '" + strSlabNo + "'"); dtReturn = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetSlab 报错", ex); } return dtReturn; } /// /// 获取订单物理属性QP_QLTY_MATR /// /// public IList GetQP_QLTY_MATR(string strWhere) { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltQP_QLTY_MATR = new List(); strSql.AppendLine(" SELECT* FROM(SELECT QQM.*,"); strSql.AppendLine(" rank() over(partition by QQM.ord_no, QQM.ord_item order by knd desc) rk"); strSql.AppendLine(" from NISCO.QP_QLTY_MATR QQM "); strSql.AppendLine(" where(QQM.ORD_NO, QQM.ORD_ITEM) IN( "); strSql.AppendLine(" SELECT "); strSql.AppendLine(" TO_CHAR(BOI.ORD_NO), TO_CHAR(BOI.ORD_ITEM) "); 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(" 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') + (NVL(CPP.ORD_REM_WGT, 0) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) / (((BOI.ORD_WID / 1000) * (BOI.ORD_LEN / 1000) * (BOI.ORD_THK / 1000)) * 7.85) >= 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' AND (SELECT COUNT(*) FROM NISCO.BP_ODER_XY BOXY WHERE BOXY.ORDER_NO=BOI.ORD_NO AND BOXY.ORDER_ITEM=BOI.ORD_ITEM )>0)) "); strSql.AppendLine("AND (boi.CUST_DEL_TO_DATE>= to_char(sysdate-183,'YYYYMMDD') OR BOI.ORD_NO LIKE 'OMA%' )"); strSql.AppendLine("AND boi.CFM_MILL_PLT='C1' "); strSql.AppendLine(" )"); strSql.AppendLine(") T WHERE T.RK = 1"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltQP_QLTY_MATR = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("QP_QLTY_MATR 报错 : ", ex); } return ltQP_QLTY_MATR; } /// /// 可用订单选择 /// 订单欠量字段 ORD_REM_CNT /// /// 所有符合条件的订单 集合 public IList GetOrder(string strWHereOrd) { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 StringBuilder strRemSql = new StringBuilder(); //声明订单欠量sql IList gpPlates = null; strSql.AppendLine("SELECT DISTINCT "); strSql.AppendLine(" BOI.ORD_NO, BOI.ORD_ITEM, 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, BOI.STLGRD, BOI.PAYMENT_COND, BOI.DEL_COND, BOI.DEL_TOL_UNIT, BOI.DEL_TOL_MAX, BOI.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(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(" , '0' as FIRST_FLG "); strSql.AppendLine(",CASE WHEN BOI.CUST_DEL_TO_DATE > TO_CHAR(SYSDATE + 7, 'YYYYMMdd') THEN 0 ELSE 1 END DEL_FLG"); //成品成分 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' WHEN BOI.STDSPEC LIKE 'NMXY%' 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(" ,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((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) - CPP.ORD_WGT * (CPP.DEL_TOL_MAX + ABS(CPP.DEL_TOL_MIN)) / 100) AS WGT_MIN "); //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') +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(", ( 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') +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 LACK_NUM"); //低倍标记 1为有低倍要求 strSql.AppendLine(" , case when (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower where ord_no=boi.ord_no and ord_item=boi.ord_item)<1 THEN 0 ELSE 1 END FLG_LOWPOWER"); // 高表标记 1是高表 strSql.AppendLine(", CASE WHEN BOI.STD_DET_CLASS_LVL IN('G1','G2') and (SELECT STEEL_GRD_DETAIL FROM NISCO.QP_NISCO_CHMC WHERE STLGRD = BOI.STLGRD) not in ('Q550-QT-1','Q550-QT-2','Q906-1','Q960-2','Q960-3','Q890-1','Q890-2') THEN 1 ELSE 0 END FLG_GB"); 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("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') + 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.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' AND (SELECT COUNT(*) FROM NISCO.BP_ODER_XY BOXY WHERE BOXY.ORDER_NO=BOI.ORD_NO AND BOXY.ORDER_ITEM=BOI.ORD_ITEM )>0)) "); strSql.AppendLine("AND (boi.CUST_DEL_TO_DATE>= to_char(sysdate-183,'YYYYMMDD') OR BOI.ORD_NO LIKE 'OMA%' )"); strSql.AppendLine("AND boi.CFM_MILL_PLT='C1' "); //strSql.AppendLine(" AND boi.ORD_NO || '-' || boi.ORD_ITEM in ('EM523100005-001')"); // strSql.AppendLine(" AND boi.ORD_NO in ('OMA23060029')"); //OMI23030002-035 try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { gpPlates = db.Query(strSql.ToString()); //logger.Info("订单SQL:" + strSql.ToString()); // logger.Info(gpPlates.Count.ToString()); //gpPlates = CommonUtils.DataTableToList(a); // logger.Info("gpPlates :" + a.Rows.Count); } } catch (Exception ex) { logger.Error("GetOrder 报错", ex); } return gpPlates; } /// /// 根据订单号找到对应的订单要求化学成分 /// /// 对应的化学成分集合 /// 方法如果被static修饰, 则在接口中无法被发现(原因不详) public IList GetOrderChemistry() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList orderChemistrys = new List(); strSql.AppendLine("SELECT T.*FROM("); strSql.AppendLine("SELECT QQC.*, rank() over(partition by QQC.ord_no, QQC.ord_item order by knd desc) rk from NISCO.QP_QLTY_CHEM QQC where (QQC.ORD_NO, QQC.ORD_ITEM) IN("); strSql.AppendLine("SELECT"); strSql.AppendLine("TO_CHAR(BOI.ORD_NO), TO_CHAR(BOI.ORD_ITEM)"); 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(" 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') + 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.95 "); strSql.AppendLine("AND boi.PROD_CD = 'PP'"); strSql.AppendLine("AND boi.REC_STS = '2' "); strSql.AppendLine("and boi.ORD_STS IN('E', 'D') "); strSql.AppendLine(" AND (boi.ord_knd ='A' OR (boi.ord_knd ='T' AND (SELECT COUNT(*) FROM NISCO.BP_ODER_XY BOXY WHERE BOXY.ORDER_NO=BOI.ORD_NO AND BOXY.ORDER_ITEM=BOI.ORD_ITEM )>0)) "); // strSql.AppendLine(" AND boi.ORD_NO || '-' || boi.ORD_ITEM in ('OMC22110048-001')"); strSql.AppendLine(") "); strSql.AppendLine(" AND QQC.KND IN ('1','2') ) T WHERE T.rk = 1 "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { orderChemistrys = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetOrderChemistry 报错 : ", ex); } return orderChemistrys; } /// /// 获取订单生产规范设计结果主表的信息 /// /// 订单的条件 /// public IList GetEP_STD_CROP_LEN() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_STD_CROP_LEN = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_STD_CROP_LEN"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_STD_CROP_LEN = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_STD_CROP_LEN 报错 : ", ex); } return ltEP_STD_CROP_LEN; } /// /// 轧件长度余量标准 /// /// public IList GetEP_PLATELEN_M() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_PLATELEN_M = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_PLATELEN_M"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_PLATELEN_M = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_PLATELEN_M 报错 : ", ex); } return ltEP_PLATELEN_M; } /// /// 宽厚上下限 /// /// public IList GetEP_PLATEWID_STD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_PLATEWID_STD = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_PLATEWID_STD"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_PLATEWID_STD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_PLATEWID_STD 报错 : ", ex); } return ltEP_PLATEWID_STD; } /// /// 宽厚上下限 /// /// public IList GetQP_STD_HEAD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltQP_STD_HEAD = new List(); strSql.AppendLine("SELECT * FROM NISCO.QP_STD_HEAD"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltQP_STD_HEAD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetQP_STD_HEAD 报错 : ", ex); } return ltQP_STD_HEAD; } /// /// /// /// public IList GetQP_PROD_RATIO() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltQP_PROD_RATIO = new List(); strSql.AppendLine("SELECT * FROM NISCO.QP_PROD_RATIO"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltQP_PROD_RATIO = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetQP_PROD_RATIO 报错 : ", ex); } return ltQP_PROD_RATIO; } /// /// 板坯设计标准 /// /// public IList GetEP_SLABDESIGN() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_SLABDESIGN = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_SLABDESIGN"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_SLABDESIGN = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_SLABDESIGN 报错 : ", ex); } return ltEP_SLABDESIGN; } /// /// 获取轧件长度限制标准信息 /// /// public IList getEP_ASROLL_LEN_STD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_ASROLL_LEN_STD = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_ASROLL_LEN_STD"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_ASROLL_LEN_STD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_ASROLL_LEN_STD 报错 : ", ex); } return ltEP_ASROLL_LEN_STD; } /// /// 获取钢种组信息 /// /// public IList getEP_GRD_GROUP() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_GRD_GROUP = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_GRD_GROUP"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_GRD_GROUP = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_GRD_GROUP 报错 : ", ex); } return ltEP_GRD_GROUP; } /// /// 厚度附加值标准数据表 /// /// public IList getGP_THK_ADD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltGP_THK_ADD = new List(); strSql.AppendLine("SELECT * FROM NISCO.GP_THK_ADD"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltGP_THK_ADD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("getGP_THK_ADD 报错 : ", ex); } return ltGP_THK_ADD; } /// /// 获取加热炉信息 /// /// public IList getEP_FUR_SIZE_STD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_FUR_SIZE_STD = new List(); strSql.AppendLine("SELECT * FROM NISCO.EP_FUR_SIZE_STD"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_FUR_SIZE_STD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_FUR_SIZE_STD 报错 : ", ex); } return ltEP_FUR_SIZE_STD; } public IList getFP_SLAB_DES() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltFP_SLAB_DES = new List(); strSql.AppendLine("SELECT fsd_1.*,'C1' PLT,'' ID ,'' HAN_RSL ,'' HAN_CON, '' HAN_DATE" + ",'' THK_RATIO" + ",'' WID_RATIO" + ",'' HEAD_LEN" + ",'' TAIL_LEN" + ",'' WID_MRGIN" + ",'' SAMP_LEN" + ",'' CUT_LOSS" + ",'' ORG_LEN" + ",'' ORG_WGT" + ",'' ORG_THK" + ",'' ORG_WID" + ",'' REM_LEN" + ",'' REM_WGT" + ",'' REQ_SEQ_NO" + ",'' SUB_KIND" + " FROM NISCO.FP_SLAB_DES FSD_1 "); strSql.AppendLine("LEFT JOIN NISCO.FP_SLAB fs "); strSql.AppendLine("ON fs.SLAB_NO = fsd_1.SLAB_NO "); strSql.AppendLine("WHERE FSD_1.SLAB_NO IN( "); strSql.AppendLine("SELECT fsd.SLAB_NO FROM NISCO.FP_SLAB_DES fsd WHERE fsd.SLAB_NO IN ( "); strSql.AppendLine(" SELECT A.SLAB_NO "); strSql.AppendLine(" FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.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 )"); strSql.AppendLine(" AND A.PROC_CD!='CAD' "); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); //strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND A.WID > 1600 "); strSql.AppendLine(" AND A.LEN > 3900 "); strSql.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.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') ) "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); //3.11.5.4.9 订单有低倍要求并且物料低倍等级不合格的板坯,不允许替代。 //strSql.AppendLine(" AND ( ( (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower Q WHERE Q.ORD_NO =A.ORD_NO AND Q.ORD_ITEM=A.ORD_ITEM) >= 1) AND A.QUALITY_GRD = '4' AND ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') < 1 ))"); //strSql.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 )) ");// strSql.AppendLine(" )GROUP BY fsd.SLAB_NO "); strSql.AppendLine(" HAVING(COUNT(fsd.SLAB_NO) > 3) "); strSql.AppendLine(" ) "); strSql.AppendLine(" AND fsd_1.ORD_CNT > 0 "); strSql.AppendLine(" ORDER BY fsd_1.SLAB_NO DESC, fsd_1.BLOCK_SEQ,fsd_1.seq "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltFP_SLAB_DES = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetFP_SLAB_DES 报错 : ", ex); } return ltFP_SLAB_DES; } /// /// 炼钢缓冲区主表 /// /// public IList getEP_REQ_SLAB() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_REQ_SLAB = new List(); strSql.AppendLine("SELECT round(to_number(slab_wgt))*10000+rownum ROW_NUM,rownum,T.*FROM( "); strSql.AppendLine("SELECT ERS.* FROM NISCO.EP_REQ_SLAB ERS "); strSql.AppendLine("WHERE ERS.REC_STS = '1' AND ERS.REQ_PLT = 'C1' "); strSql.AppendLine("AND (select count(*) from NISCO.EP_REQ_SLAB_D ERSD where ERSD.REQ_SEQ_NO=ERS.REQ_SEQ_NO)>=3 "); strSql.AppendLine("ORDER BY ERS.SLAB_LEN) T "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_REQ_SLAB = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_REQ_SLAB 报错 : ", ex); } return ltEP_REQ_SLAB; } /// /// 炼钢缓冲区 详细设计表 /// /// public IList getEP_REQ_SLAB_D() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltEP_REQ_SLAB_D = new List(); //strSql.AppendLine("SELECT * FROM NISCO.EP_REQ_SLAB_D"); strSql.AppendLine("SELECT ERSD.* ,'' USE_FLG FROM NISCO.EP_REQ_SLAB_D ERSD WHERE ERSD.REQ_SEQ_NO IN("); strSql.AppendLine("SELECT ERS.REQ_SEQ_NO FROM NISCO.EP_REQ_SLAB ERS"); strSql.AppendLine("WHERE ERS.REC_STS = '1' AND ERS.REQ_PLT = 'C1'"); strSql.AppendLine("AND (select count(*) from NISCO.EP_REQ_SLAB_D ERSD where ERSD.REQ_SEQ_NO=ERS.REQ_SEQ_NO)>=3) "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltEP_REQ_SLAB_D = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_REQ_SLAB_D 报错 : ", ex); } return ltEP_REQ_SLAB_D; } /// /// 替代厚度限制 /// /// public IList getSUBS_THICK_LIMIT() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltSUBS_THICK_LIMIT = new List(); strSql.AppendLine("SELECT * FROM SUBS_THICK_LIMIT"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { ltSUBS_THICK_LIMIT = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetSUBS_THICK_LIMIT 报错 : ", ex); } return ltSUBS_THICK_LIMIT; } /// /// 钢种说明 /// /// public IList getQP_NISCO_CHMC() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltQP_NISCO_CHMC = new List(); strSql.AppendLine("SELECT * FROM NISCO.QP_NISCO_CHMC "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltQP_NISCO_CHMC = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetQP_NISCO_CHMC 报错 : ", ex); } return ltQP_NISCO_CHMC; } /// /// 一坯多钢种信息 /// /// public IList getCP_NISCO_CHMC_SL() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltCP_NISCO_CHMC_SL = new List(); strSql.AppendLine("SELECT * FROM NISCO.CP_NISCO_CHMC_SL"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltCP_NISCO_CHMC_SL = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetCP_NISCO_CHMC_SL 报错 : ", ex); } return ltCP_NISCO_CHMC_SL; } /// /// 获取配置信息 /// /// public IList getTB_SLAB_CONF() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltTB_SLAB_CONF = new List(); strSql.AppendLine("SELECT * FROM TB_SLAB_CONF"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { ltTB_SLAB_CONF = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetTB_SLAB_CONF 报错 : ", ex); } return ltTB_SLAB_CONF; } /// /// 异钢种替代工艺 /// /// public IList getQP_QLTY_TECH_REPLACE() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltQP_QLTY_TECH_REPLACE = new List(); strSql.AppendLine("SELECT * FROM NISCO.QP_QLTY_TECH_REPLACE"); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltQP_QLTY_TECH_REPLACE = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetQP_QLTY_TECH_REPLACE 报错 : ", ex); } return ltQP_QLTY_TECH_REPLACE; } /// /// 根据钢板板坯号找到对应炉号,根据炉号找到对应化学成分 /// /// 对应的化学成分集合 public IList GetChemistry() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList chemistrys = new List(); strSql.AppendLine("SELECT * FROM NISCO.QP_CHEM_RSLT WHERE HEAT_NO IN ( "); strSql.AppendLine("SELECT "); strSql.AppendLine("A.HEAT_NO "); strSql.AppendLine("FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); //strSql.AppendLine(" AND A.SLAB_NO = '2310167902' "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.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 )"); //strSql.AppendLine(" AND A.SLAB_NO!='2320297902' "); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); //strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND A.WID > 1600 "); strSql.AppendLine(" AND A.LEN > 3900 "); strSql.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.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') ) "); strSql.AppendLine(" AND not (substr(A.LOC,1,7) in ('S7I1701','S7I1702','S7I1703','S7I1801','S7I1802','S7I1803') and CUR_INV='00') "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); //3.11.5.4.9 订单有低倍要求并且物料低倍等级不合格的板坯,不允许替代。 //strSql.AppendLine(" AND ( ( (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower Q WHERE Q.ORD_NO =A.ORD_NO AND Q.ORD_ITEM=A.ORD_ITEM) >= 1) AND A.QUALITY_GRD = '4' AND ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') < 1 ))"); //strSql.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 ) ");// strSql.AppendLine(") "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { chemistrys = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetChemistry 报错 : ", ex); } return chemistrys; } public IList GetGPTHKADD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gGPTHKADD = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM NISCO.GP_THK_ADD"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { gGPTHKADD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetGPTHKADD 报错", ex); } return gGPTHKADD; } public IList GetEP_SLABLEN_STD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList getEP_SLABLEN_STD = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM NISCO.EP_SLABLEN_STD"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { getEP_SLABLEN_STD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetEP_SLABLEN_STD 报错", ex); } return getEP_SLABLEN_STD; } public static string GetSlabNo(FP_SLAB_DES FSD) { string strSlabNo = string.Empty; DataTable dtReturn = new DataTable(); StringBuilder strSql = new StringBuilder(); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { strSql.AppendLine(" SELECT 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 "); 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' "); strSql.AppendFormat(" AND A.ORD_NO = '{0}' ", FSD.ORD_NO); strSql.AppendFormat(" AND A.ORD_ITEM = '{0}' ", FSD.ORD_ITEM); dtReturn = db.Query(strSql.ToString()); if (dtReturn.Rows.Count > 0) { strSlabNo = dtReturn.Rows[0]["REQ_SEQ_NO"].ToString(); } } } catch (Exception) { } return strSlabNo; } public IList GetFP_CAD_INF() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltFP_CAD_INF = new List(); strSql.AppendLine("SELECT * FROM NISCO.FP_CAD_INF "); strSql.AppendLine("WHERE substr (SLAB_NO,1,8) IN ( "); strSql.AppendLine("SELECT "); strSql.AppendLine("substr(A.SLAB_NO,1,8) "); strSql.AppendLine("FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.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 )"); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); //strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND A.WID > 1600 "); strSql.AppendLine(" AND A.LEN > 3900 "); strSql.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.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') ) "); strSql.AppendLine(" AND not (substr(A.LOC,1,7) in ('S7I1701','S7I1702','S7I1703','S7I1801','S7I1802','S7I1803') and CUR_INV='00') "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); //3.11.5.4.9 订单有低倍要求并且物料低倍等级不合格的板坯,不允许替代。 //strSql.AppendLine(" AND ( ( (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower Q WHERE Q.ORD_NO =A.ORD_NO AND Q.ORD_ITEM=A.ORD_ITEM) >= 1) AND A.QUALITY_GRD = '4' AND ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') < 1 ))"); //strSql.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.FB_SLAB_001 R WHERE R.SLAB_NO = A.SLAB_NO) < 1 ) )");// strSql.AppendLine(") "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltFP_CAD_INF = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetFP_CAD_INF 报错 : ", ex); } return ltFP_CAD_INF; } /// /// 获取炼钢板坯设计信息 /// /// public IList getEP_SLAB_DES() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltFP_SLAB_DES = new List(); strSql.AppendLine("SELECT " + "fsd_1.ACT_SLAB_NO SLAB_NO,"+ "fsd_1.*,'C1' PLT,'' ID ,'' HAN_RSL ,'' HAN_CON, '' HAN_DATE" + ",'' THK_RATIO" + ",'' WID_RATIO" + ",'' HEAD_LEN" + ",'' TAIL_LEN" + ",'' WID_MRGIN" + ",'' SAMP_LEN" + ",'' CUT_LOSS" + ",'' ORG_LEN" + ",'' ORG_WGT" + ",'' ORG_THK" + ",'' ORG_WID" + ",'' REM_LEN" + ",'' REM_WGT" + ",'' REQ_SEQ_NO" + ",'' SUB_KIND" + ",'' POSITION_TYPE" + ",'' POSITION_X" + ",'' POSITION_Y" + ",'' FL" + " FROM NISCO.EP_SLAB_DES FSD_1 "); strSql.AppendLine("LEFT JOIN NISCO.FP_SLAB fs "); strSql.AppendLine("ON fs.SLAB_NO = fsd_1.ACT_SLAB_NO "); strSql.AppendLine("WHERE FSD_1.ACT_SLAB_NO IN( "); strSql.AppendLine("SELECT fsd.ACT_SLAB_NO FROM NISCO.EP_SLAB_DES fsd WHERE fsd.ACT_SLAB_NO IN ( "); strSql.AppendLine(" SELECT A.SLAB_NO "); strSql.AppendLine(" FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.AppendLine(" AND((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD IN ('9010','0002','0003','2010')) < 1 )"); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND SUBSTR(A.SLAB_NO,3,1) <> 'F' "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD, 'N') NOT IN('N','E') "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); strSql.AppendLine(" AND NVL(A.PLAN_SLAB_MERGE_FL,'N') = 'N' ) "); strSql.AppendLine(" GROUP BY fsd.ACT_SLAB_NO "); strSql.AppendLine(" HAVING(COUNT(fsd.ACT_SLAB_NO) > 3) "); strSql.AppendLine(" ) "); strSql.AppendLine(" ORDER BY fsd_1.SLAB_NO DESC, fsd_1.BLOCK_SEQ,fsd_1.seq "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltFP_SLAB_DES = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetFP_SLAB_DES 报错 : ", ex); } return ltFP_SLAB_DES; } /// /// 镍系钢种 修磨表 /// /// public IList GetSPECIAL_VARIETIES() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gGPTHKADD = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM NISCO.SPECIAL_VARIETIES"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { gGPTHKADD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetSPECIAL_VARIETIES 报错", ex); } return gGPTHKADD; } /// /// 获取预留钢种 /// /// public IList GetTB_STLGRD_CHMC() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLTB_STLGRD_CHMC = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM tb_stlgrd_chmc WHERE plt='C1'"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { gLTB_STLGRD_CHMC = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("gLTB_APPOINT_ORDER 报错", ex); } return gLTB_STLGRD_CHMC; } /// /// 镍系钢种 修磨表 /// /// public IList GetTB_APPOINT_ORDER() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gTB_APPOINT_ORDER = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM TB_APPOINT_ORDER"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { gTB_APPOINT_ORDER = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetTB_APPOINT_ORDER 报错", ex); } return gTB_APPOINT_ORDER; } /// /// 镍系钢种 修磨表 /// /// public IList GetFB_SLAB_001() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLFB_SLAB_001 = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM NISCO.FB_SLAB_001"); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { gLFB_SLAB_001 = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetFB_SLAB_001 报错", ex); } return gLFB_SLAB_001; } public TB_CNF_C1 getTB_CNF_C1() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLTB_CNF_C1 = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM TB_CNF_C1 "); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { gLTB_CNF_C1 = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("gLTB_CNF_C1 报错", ex); } return gLTB_CNF_C1.FirstOrDefault(); } public IList getFP_SLAB_ADD() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLFP_SLAB_ADD = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM Nisco.FP_SLAB_ADD where slab_type in ('CZC1''CZC2','CZC3') "); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { gLFP_SLAB_ADD = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("getFP_SLAB_ADD 报错", ex); } return gLFP_SLAB_ADD; } //不可替代订单 public IList getTB_SLAB_ORD_SPE() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLTB_SLAB_ORD_SPE = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT ORD_NO,ORD_ITEM FROM TB_SLAB_ORD_SPE "); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { gLTB_SLAB_ORD_SPE = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("getFP_SLAB_ADD 报错", ex); } return gLTB_SLAB_ORD_SPE; } public IList getTB_YARD_SPE() { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 IList gLTB_YARD_SPE = null; //查询可用订单以及常用字段 try { strSql.AppendLine("SELECT * FROM TB_YARD_SPE "); //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db")) { gLTB_YARD_SPE = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("getTB_ONLY_TYPE 报错", ex); } return gLTB_YARD_SPE; } /// /// 在途的仓库 /// /// public IList GetCPMOVESLT(string strWHere) { StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量 DataTable dtCheck = new DataTable(); IList ltCP_MOVE_SLT = new List(); strSql.AppendLine("SELECT * FROM( "); strSql.AppendLine("SELECT "); strSql.AppendLine("rank() over(partition BY CMS.MAT_NO order by CMS.SND_TIME desc) rk ,CMS.* "); strSql.AppendLine("FROM NISCO.CP_MOVE_SLT CMS "); strSql.AppendLine(" WHERE CMS.MAT_NO IN ( "); strSql.AppendLine(" SELECT DISTINCT A.SLAB_NO "); strSql.AppendLine("FROM NISCO.FP_SLAB A "); strSql.AppendLine("WHERE 1 = 1 "); strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND(A.PROC_CD = 'CAC' OR "); strSql.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)"); strSql.AppendLine(" AND A.PROC_CD='CAD' ) "); strSql.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 )"); //strSql.AppendLine(" AND A.SLAB_NO!='2320297902' "); strSql.AppendLine(" AND A.CUR_INV in ('00','C7','52','ZZ','HC') "); //strSql.AppendLine(" AND A.PROC_CD = 'CAC' "); strSql.AppendLine(" AND A.ORD_FL = '2' "); strSql.AppendLine(" AND A.REC_STS = '2' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.AppendLine(" AND NVL(A.PLAN_SLAB_CUT_FL,'N') = 'N' "); strSql.AppendLine(" AND A.WGT > 0 "); strSql.AppendLine(" AND A.WID > 1600 "); strSql.AppendLine(" AND A.LEN > 3900 "); strSql.AppendLine(" AND NVL(A.PLT,'99') IN ('B1','BZ') "); strSql.AppendLine(" AND NVL(A.QUALITY_UPD_GRD,'N') <> 'N' "); strSql.AppendLine(" AND NVL(A.OUT_PLT_CD,'9') <> '0' "); strSql.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') ) "); strSql.AppendLine(" AND not ((substr(A.LOC,1,7) in ('S7I1701','S7I1702','S7I1703','S7I1801','S7I1802','S7I1803') or substr(A.LOC,1,5) in ('S3E04','S3E05','S3E06') ) and CUR_INV='00') "); strSql.AppendLine(" AND NVL(A.PLAN_MILL_PLT , ' ') LIKE '%C1' || '%' "); //3.11.5.4.9 订单有低倍要求并且物料低倍等级不合格的板坯,不允许替代。 //strSql.AppendLine(" AND ( ( (SELECT COUNT(*) FROM NISCO.qp_qlty_slab_lowpower Q WHERE Q.ORD_NO =A.ORD_NO AND Q.ORD_ITEM=A.ORD_ITEM) >= 1) AND A.QUALITY_GRD = '4' AND ((SELECT COUNT(*) FROM NISCO.CP_SLAB_DELI_DET C WHERE C.SLAB_NO = A.SLAB_NO AND C.EST_CD = '0001' AND C.REASON_CD = '3010' AND C.REASON_COMMENT = '低倍不符合要求') < 1 ))"); strSql.AppendLine(" AND (select COUNT(*) from nisco.fp_slab_C3 WHERE SLAB_NO=A.SLAB_NO AND FL='True')<1"); strSql.AppendLine(" AND (select COUNT(*) from nisco.fp_slab_C2 WHERE SLAB_NO=A.SLAB_NO AND FL='1')<1"); //P_SLAB_DELI_DET表中字段EST_CD是5或者6开头是协议板。 //strSql.AppendLine(" ORDER BY A.LOC DESC, A.SLAB_NO ASC "); //strSql.AppendLine(strWHerePlate); strSql.AppendLine(") "); strSql.AppendLine(" ) WHERE rk = 1 "); try { //开启数据库连接查询数据 using (IDbContext db = ObjectContainer.GetObject("db_sur")) { ltCP_MOVE_SLT = db.Query(strSql.ToString()); } } catch (Exception ex) { logger.Error("GetCPMOVESLT 报错 : ", ex); } return ltCP_MOVE_SLT; } #endregion #region 存储数据 public static void SaveStat(IList ltFSD) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C2' AND HAN_RSL IS NULL"); db.Insert(ltFSD); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("存储错误!信息:{0}", ex.ToString()); } } } public static void SaveFSD(IList ltFSD) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 if (ltFSD.Count() > 0) { db.BeginTransaction(); db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C1' AND SLAB_NO = '" + ltFSD.FirstOrDefault().SLAB_NO + "'"); int intDB = db.Insert(ltFSD); db.Commit(); #region PDO db.BeginTransaction(); FP_SLAB_DES supData = new FP_SLAB_DES(); supData = db.Query("SELECT * FROM FP_SLAB_DES " + "WHERE PLT='C1' " + " AND SLAB_NO = '" + ltFSD.FirstOrDefault().SLAB_NO + "'" + " AND BLOCK_SEQ = '00' AND SEQ = '00' AND SLAB_CUT_SEQ ='01'").FirstOrDefault(); if (supData != null) { TBDIPDO InsertPDO = GetTBDIBKDPDO(supData); db.Insert(InsertPDO); DateTime date = DateTime.Now; List ltFSD2 = db.Query("SELECT * FROM FP_SLAB_DES " + "WHERE PLT='C1' " + " AND SLAB_NO = '" + ltFSD.FirstOrDefault().SLAB_NO + "'").ToList(); foreach (FP_SLAB_DES item in ltFSD2) { FP_SLAB_DES_HIS fP_SLAB_DES_HIS = new FP_SLAB_DES_HIS(); fP_SLAB_DES_HIS = CopyToModel(item); fP_SLAB_DES_HIS.SUB_TIME = date.ToString(); db.Insert(fP_SLAB_DES_HIS); } } db.Commit(); #endregion } } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("存储错误!信息:{0}", ex.ToString()); } } } public static FP_SLAB_DES_HIS CopyToModel(FP_SLAB_DES source) { FP_SLAB_DES_HIS model = default(FP_SLAB_DES_HIS); PropertyInfo[] pi = typeof(FP_SLAB_DES_HIS).GetProperties(); PropertyInfo[] pi1 = typeof(FP_SLAB_DES).GetProperties(); model = Activator.CreateInstance(); for (int i = 0; i < pi.Length; i++) { for (int k = 0; k < pi1.Length; k++) { if (pi[i].Name == pi1[k].Name) { pi[i].SetValue(model, pi1[k].GetValue(source, null), null); break; } } } return model; } /// /// 删除数据 /// /// public static void DeleteSlab(string DeleteSlab) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); db.Execute("DELETE FROM FP_SLAB_DES WHERE slab_no='"+ DeleteSlab+"'"); //挂回原订单数据删除 //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL AND SUB_KIND='1'"); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("删除错误!信息:{0}", ex.ToString()); } } } /// /// 删除数据 /// /// public static void DeleteFSD() { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C1' AND HAN_RSL IS NULL "); //挂回原订单数据删除 //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL AND SUB_KIND='1'"); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("删除错误!信息:{0}", ex.ToString()); } } } /// /// 删除数据挂回原订单 /// /// public static void DeleteFSDBackOrder() { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL "); //挂回原订单数据删除 db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C1' AND HAN_RSL IS NULL AND SUB_KIND='1'"); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("删除错误!信息:{0}", ex.ToString()); } } } /// /// 删除数据炼钢缓冲区 /// /// public static void DeleteFSDBuffer() { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL "); //挂回原订单数据删除 db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C1' AND HAN_RSL IS NULL AND SUB_KIND='2'"); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("删除错误!信息:{0}", ex.ToString()); } } } /// /// 删除数据自动匹配 /// /// public static void DeleteFSDAuto() { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL "); //挂回原订单数据删除 db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C3' AND HAN_RSL IS NULL AND SUB_KIND='3'"); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("删除错误!信息:{0}", ex.ToString()); } } } public static void SaveORDER(IList ltFSD) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); //db.Execute("DELETE FROM FP_SLAB_DES WHERE PLT='C2' AND HAN_RSL IS NULL"); db.Execute("DELETE from BP_ORDER_C1 where TO_CHAR(TO_DATE(ins_time, 'yyyy-MM-dd HH24:mi:ss'), 'yyyyMMdd') <= TO_CHAR(trunc(sysdate-6), 'yyyyMMdd')"); db.Insert(ltFSD); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("存储错误!信息:{0}", ex.ToString()); } } } public static void SaveFSD_TEST(IList ltFSD) { using (IDbContext db = ObjectContainer.GetObject("db")) { try { //因为是同时操作两个表, 所以开启事务 db.BeginTransaction(); db.Insert(ltFSD); db.Commit(); } catch (Exception ex) { //数据如果发生错误则回滚 db.Rollback(); logger.ErrorFormat("存储错误!信息:{0}", ex.ToString()); } } } #endregion #region 方法 /// /// 整理 PDO 实体类数据 /// /// 钢板数据 /// 订单数据库 /// public static TBDIPDO GetTBDIBKDPDO(FP_SLAB_DES prSlabDes) { TBDIPDO Result = new TBDIPDO(); //Data字段:数值型、字符型都是后补空格 Result.TIMESTAMP = GetTimeStamp(); //TIMESTAMP: 1970.1.1 8:00:00 至当前时间的毫秒数 Result.SERIALNO = "0";//Serialno :默认0,对于TIMESTAMP: 重复时的区分号 Result.QUEUEID = "BKDMES000";//:主键,BKDYC0001 ,有时序先后顺序的必须用同一个QUEUEID Result.HEADER = "";// 未使用 //Result.DATA = "";// 前10位记录FORMID(例如:BKD001 / BKD002) Result.STATUS = "N";// 发送方写入N,读取成功后变0,异常变1 Result.PROCESSTIME = DateTime.Now.ToString("yyyyMMddHHmmss");//:读取时间 Result.DESCRIPTION = "";//:读取异常备注 StringBuilder strData = new StringBuilder(); strData.Append(("BKDMES011").PadRight(10));// FORMID:10位 ,BKDMES011 固定 strData.Append(prSlabDes.ID.PadRight(12));// 业务ID号 NUMBER(12) 流水号,需要在应答中带回 strData.Append(prSlabDes.PLT.PadRight(2));// 工厂代码:VARCHAR2(2), C1 / C2 / C3 strData.Append(prSlabDes.SLAB_NO.PadRight(10));// 板坯号: VARCHAR2(10) Result.DATA = strData.ToString(); return Result; } /// /// 获取时间戳 /// /// public static string GetTimeStamp() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 8, 0, 0, 0); return Convert.ToInt64(ts.TotalMilliseconds).ToString(); } #endregion } }