You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7070 lines
308 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 QP_STD_HEAD = ibk.IPD.Entity.IPD_PS.QP_STD_HEAD;
using System.Diagnostics;
using ibk.IPD.Service.IPD_SS;
using Confluent.Kafka;
using NPOI.SS.Formula.Functions;
using static NPOI.HSSF.Util.HSSFColor;
namespace ibk.IPD.Controller.IPD_PS
{
[RoutePrefix("ipd/AipdPs")]
public class SurMatSubController : ApiController
{
#region 变量常量
//Log4net 日志输出
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//后端 Service
private static SurMatSubService SerSurMatSubService = new SurMatSubService();
//排除已经替代
private static IList<SUPERSEDE> gltUnConSur = new List<SUPERSEDE>();
private static int intLOOP_CYC = 2;
private static int intORD_DAYS_DIFF = 200;
private static int intPLATE_DAYS_DIFF = 200;
private static decimal DecSUB_RATE = ConverDataToDecimal(0.85);
private static decimal DecEFF_WID = 200;
private static decimal DecEFF_LEN = 200;
private static decimal SPLITTING_LEN = 5000;
//厚度(计算钢板单重用)
private static IList<GP_THK_ADD> gltGPTHKADD = new List<GP_THK_ADD>();
//标准(计算钢板单重用)
private static IList<QP_STD_HEAD> gltQPSTDHEAD = new List<QP_STD_HEAD>();
//替代规则配置参数
private static IList<TB_PS_CONFIG> gltTBSubRules = new List<TB_PS_CONFIG>();
//替代仓库参数配置
private static IList<REMA_PLA_SUBSI_WAREH_MANAGE> gltWarDiffDays = new List<REMA_PLA_SUBSI_WAREH_MANAGE>();
//设置一个加锁对象
private static readonly object LOCK = new object();
//可用订单集合
private static IList<BP_ORDER_ITEM> orderEntities = new List<BP_ORDER_ITEM>();
//可用余材集合
private static IList<GP_PLATE> gP_PLATEs = new List<GP_PLATE>();
//全部标准信息集合
private static IList<CP_NISCO_CHMC_SL> gCP_NISCO_CHMC_SLs = new List<CP_NISCO_CHMC_SL>();
//可用订单化学成分表
private static IList<QP_QLTY_CHEM> gQP_QLTY_CHEM = new List<QP_QLTY_CHEM>();
//可用钢材化学成分表
private static IList<QP_CHEM_RSLT> gQP_CHEM_RSLT = new List<QP_CHEM_RSLT>();
//可用钢材炉号
private static IList<FP_SLAB> gFP_SLAB = new List<FP_SLAB>();
//对比数据
private static IList<COM_DATA> gCOM_DATA = new List<COM_DATA>();
//临时表数据
private static IList<TEMP_DATA> gTEMP_DATA = new List<TEMP_DATA>();
//待确认数据
private static IList<SUPERSEDE> gSUPERSEDE = new List<SUPERSEDE>();
//记录所有钢板号
private static List<string> ltPlateNo = new List<string>();
#region 物理特性
//订单物理特性HA
private static IList<QP_QLTY_MATR_HA> gQP_QLTY_MATR_HA = new List<QP_QLTY_MATR_HA>();
//订单物理特性HB
private static IList<QP_QLTY_MATR_HB> gQP_QLTY_MATR_HB = new List<QP_QLTY_MATR_HB>();
//订单物理特性HC
private static IList<QP_QLTY_MATR_HC> gQP_QLTY_MATR_HC = new List<QP_QLTY_MATR_HC>();
//订单物理特性HD
private static IList<QP_QLTY_MATR_HD> gQP_QLTY_MATR_HD = new List<QP_QLTY_MATR_HD>();
//订单物理特性HE
private static IList<QP_QLTY_MATR_HE> gQP_QLTY_MATR_HE = new List<QP_QLTY_MATR_HE>();
//订单物理特性HF
private static IList<QP_QLTY_MATR_HF> gQP_QLTY_MATR_HF = new List<QP_QLTY_MATR_HF>();
//订单物理特性HJ
private static IList<QP_QLTY_MATR_HJ> gQP_QLTY_MATR_HJ = new List<QP_QLTY_MATR_HJ>();
//订单物理特性HK
private static IList<QP_QLTY_MATR_HK> gQP_QLTY_MATR_HK = new List<QP_QLTY_MATR_HK>();
//订单物理特性HM
private static IList<QP_QLTY_MATR_HM> gQP_QLTY_MATR_HM = new List<QP_QLTY_MATR_HM>();
//订单物理特性HN
private static IList<QP_QLTY_MATR_HN> gQP_QLTY_MATR_HN = new List<QP_QLTY_MATR_HN>();
//订单物理特性HR
private static IList<QP_QLTY_MATR_HR> gQP_QLTY_MATR_HR = new List<QP_QLTY_MATR_HR>();
//订单物理特性HZ
private static IList<QP_QLTY_MATR_HZ> gQP_QLTY_MATR_HZ = new List<QP_QLTY_MATR_HZ>();
//钢板物理特性
private static IList<QP_TEST_RSLT> gQP_TEST_RSLT = new List<QP_TEST_RSLT>();
//钢板物理特性HA
private static IList<QP_TEST_RSLT_HA> gQP_TEST_RSLT_HA = new List<QP_TEST_RSLT_HA>();
//钢板物理特性HB
private static IList<QP_TEST_RSLT_HB> gQP_TEST_RSLT_HB = new List<QP_TEST_RSLT_HB>();
//钢板物理特性HC
private static IList<QP_TEST_RSLT_HC> gQP_TEST_RSLT_HC = new List<QP_TEST_RSLT_HC>();
//钢板物理特性HD
private static IList<QP_TEST_RSLT_HD> gQP_TEST_RSLT_HD = new List<QP_TEST_RSLT_HD>();
//钢板物理特性HE
private static IList<QP_TEST_RSLT_HE> gQP_TEST_RSLT_HE = new List<QP_TEST_RSLT_HE>();
//钢板物理特性HF
private static IList<QP_TEST_RSLT_HF> gQP_TEST_RSLT_HF = new List<QP_TEST_RSLT_HF>();
//钢板物理特性HJ
private static IList<QP_TEST_RSLT_HJ> gQP_TEST_RSLT_HJ = new List<QP_TEST_RSLT_HJ>();
//钢板物理特性HK
private static IList<QP_TEST_RSLT_HK> gQP_TEST_RSLT_HK = new List<QP_TEST_RSLT_HK>();
//钢板物理特性HM
private static IList<QP_TEST_RSLT_HM> gQP_TEST_RSLT_HM = new List<QP_TEST_RSLT_HM>();
//钢板物理特性HN
private static IList<QP_TEST_RSLT_HN> gQP_TEST_RSLT_HN = new List<QP_TEST_RSLT_HN>();
//钢板物理特性HR
private static IList<QP_TEST_RSLT_HR> gQP_TEST_RSLT_HR = new List<QP_TEST_RSLT_HR>();
//钢板物理特性HZ
private static IList<QP_TEST_RSLT_HZ> gQP_TEST_RSLT_HZ = new List<QP_TEST_RSLT_HZ>();
#endregion
#endregion
#region 接口
/// <summary>
/// 查询所有原始可用余材(前端需求接口)
/// </summary>
/// <returns></returns>
[HttpPost, Route("getSurplusMaterials")]
public RequestEntity GetSurplusMaterials(string strWHerePlate)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
//{
result.data = SerSurMatSubService.GetAllMat(strWHerePlate);
result.msg = "操作成功!";
result.code = "1";
//}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSurplusMaterials 报错 : ", ex);
}
return result;
}
/// <summary>
/// 查询按钮
/// 查询(SUPERSEDE 表)
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getSupersede")]
public RequestEntity GetSupersede(SupersedeQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//strSql.AppendLine("SELECT ");
//strSql.AppendLine(" sur.PLATE_NO ");//--物料号
//strSql.AppendLine(",gp.SUB_DATE ");//--替代时间
//strSql.AppendLine(",sur.SUB_RATE ");//--替代率
//strSql.AppendLine(",gp.THK gp_THK ");//--替代前物料信息厚度
//strSql.AppendLine(",gp.WID gp_WID ");//--替代前物料信息宽度
//strSql.AppendLine(",gp.LEN gp_LEN ");//--替代前物料信息长度
//strSql.AppendLine(",gp.WGT gp_WGT ");//--替代前物料信息重量
//strSql.AppendLine(",gp.APLY_STDSPEC gp_APLY_STDSPEC ");//--替代前物料信息标准
//strSql.AppendLine(",gp.ORD_FL gp_ORD_FL ");//--替代前物料信息余材代码
//strSql.AppendLine(",gp.SURF_GRD gp_SURF_GRD ");//--替代前物料信息表面等级
//strSql.AppendLine(",boi.ORD_NO boi_ORD_NO ");//--替代后订单订单号
//strSql.AppendLine(",boi.ORD_ITEM boi_ORD_ITEM ");//--替代后订单序列
//strSql.AppendLine(",boi.STDSPEC boi_STDSPEC ");//--替代后订单订单标准
//strSql.AppendLine(",boi.ORD_THK boi_ORD_THK ");//--替代后订单厚度
//strSql.AppendLine(",boi.ORD_WID boi_ORD_WID ");//--替代后订单宽度
//strSql.AppendLine(",boi.ORD_LEN boi_ORD_LEN ");//--替代后订单长度
//strSql.AppendLine(",boi.WGT_UNIT boi_WGT_UNIT ");//--替代后订单重量
//strSql.AppendLine(",boi.CUST_CD boi_CUST_CD ");//--替代后订单客户名称
//strSql.AppendLine(",boi.ENDUSE_CD boi_ENDUSE_CD ");//--替代后订单订单用途
//strSql.AppendLine(",boi.ORD_KND boi_ORD_KND ");//--替代后订单订单种类
//strSql.AppendLine(",bob.ORD_NO bob_ORD_NO ");//--替代前订单订单号
//strSql.AppendLine(",bob.ORD_ITEM bob_ORD_ITEM ");//--替代前订单序列
//strSql.AppendLine(",bob.STDSPEC bob_STDSPEC ");//--替代前订单订单标准
//strSql.AppendLine(",bob.ORD_THK bob_ORD_THK ");//--替代前订单厚度
//strSql.AppendLine(",bob.ORD_WID bob_ORD_WID ");//--替代前订单宽度
//strSql.AppendLine(",bob.ORD_LEN bob_ORD_LEN ");//--替代前订单长度
//strSql.AppendLine(",bob.WGT_UNIT bob_WGT_UNIT ");//--替代前订单重量
//strSql.AppendLine(",bob.CUST_CD bob_CUST_CD ");//--替代前订单客户名称
//strSql.AppendLine(",bob.ENDUSE_CD bob_ENDUSE_CD ");//--替代前订单订单用途
//strSql.AppendLine(",bob.ORD_KND bob_ORD_KND ");//--替代前订单订单种类
//strSql.AppendLine(",boo.ORD_NO boo_ORD_NO ");//--原始订单订单号
//strSql.AppendLine(",boo.ORD_ITEM boo_ORD_ITEM ");//--原始订单序列
//strSql.AppendLine(",boo.STDSPEC boo_STDSPEC ");//--原始订单订单标准
//strSql.AppendLine(",boo.ORD_THK boo_ORD_THK ");//--原始订单厚度
//strSql.AppendLine(",boo.ORD_WID boo_ORD_WID ");//--原始订单宽度
//strSql.AppendLine(",boo.ORD_LEN boo_ORD_LEN ");//--原始订单长度
//strSql.AppendLine(",boo.WGT_UNIT boo_WGT_UNIT ");//--原始订单重量
//strSql.AppendLine(",boo.CUST_CD BOO_CUST_CD ");//--原始订单客户名称
//strSql.AppendLine(",gp.SUB_USER ");//--替代人员
//strSql.AppendLine(",'产品备注' SUR_PRO_REM ");//--产品备注
//strSql.AppendLine(",gp.PLT gp_PLT ");//--轧制工厂
//strSql.AppendLine(",gp.PROD_TIME gp_PROD_TIME ");//--轧制时间
//strSql.AppendLine(",'首次降级时间' SUR_FIR_TIM ");//--首次降级时间
//strSql.AppendLine(",gp.WOO_RSN gp_WOO_RSN ");//--余材原因
//strSql.AppendLine(",'责任单位' SUR_COM ");//--责任单位
//strSql.AppendLine(",gp.SUB_NUM ");//--替代块数
//strSql.AppendLine(",gp.SUB_DIR ");//--排列方向
//strSql.AppendLine(",gp.SUB_US_WID ");//--剩余可用宽度
//strSql.AppendLine(",gp.SUB_US_LEN ");//--剩余可用长度
//strSql.AppendLine(",gp.SUB_CUT_X ");//--切割点X坐标
//strSql.AppendLine(",gp.SUB_CUT_Y ");//--切割点Y坐标
//strSql.AppendLine(",gp.SUB_LOS_WGT ");//--替代损失重量
//strSql.AppendLine(",'是否强制替代(N)' SUB_FOR ");//--是否强制替代
//strSql.AppendLine(",'替代备注' SUB_REM ");//--替代备注
//strSql.AppendLine(",gp.CUR_INV GP_CUR_INV ");//--替代时仓库
//strSql.AppendLine(",'备注原因' SUR_REM_REA ");//--备注原因
//strSql.AppendLine(",gp.TRIM_FL gp_TRIM_FL ");//--切边
//strSql.AppendLine(",gp.SIZE_KND gp_SIZE_KND ");//--定尺
//strSql.AppendLine(",'订单备注' ORD_REM ");//--订单备注
//strSql.AppendLine(",gp.UST_RLT_CD gp_UST_RLT_CD ");//--探伤
//strSql.AppendLine(",gp.GAS_FL gp_GAS_FL ");//--切割
//strSql.AppendLine(",gp.CL_FL gp_CL_FL ");//--矫直
//strSql.AppendLine(",gp.HTM_CNT gp_HTM_CNT ");//--热处理
//strSql.AppendLine(",gp.APLY_STDSPEC gp_APLY_STDSPEC ");//--标识标准
//strSql.AppendLine(",gp.STLGRD gp_STLGRD ");//--标识钢种
//strSql.AppendLine(",boi.SURFACE_REQUESTS boi_SURFACE_REQUESTS");//--客户表面要求
//strSql.AppendLine(",boi.VESSEL_NO boi_VESSEL_NO ");//--加喷内容
//strSql.AppendLine(",boi.SIDEMARK boi_SIDEMARK ");//--侧喷加喷
//strSql.AppendLine(",boi.FACEPAINT boi_FACEPAINT ");//--表喷次数
//strSql.AppendLine(",boi.SEALMEMO boi_SEALMEMO ");//--是否钢印
//strSql.AppendLine(",boi.SEALMEMO boi_SEALMEMO ");//--钢印加冲
//strSql.AppendLine(",boi.ORD_PROD_END_TIME boi_ORD_PROD_END_TIME");//--综判时间
//strSql.AppendLine(",boi.PROD_CD boi_PROD_CD ");//--产品
//strSql.AppendLine(",boi.DOME_FL boi_DOME_FL ");//--替代分类
//strSql.AppendLine(",boi.DEL_FR_DATE boi_DEL_FR_DATE ");//--用户交货期
//strSql.AppendLine("FROM SUPERSEDE sur ");//
//strSql.AppendLine("LEFT JOIN GP_PLATE gp ON gp.PLATE_NO = sur.PLATE_NO");//
//strSql.AppendLine("LEFT JOIN BP_ORDER_ITEM boi ON sur.ORD_NO = boi.ORD_NO AND sur.ORD_ITEM = boi.ORD_ITEM ");//
//strSql.AppendLine("LEFT JOIN BP_ORDER_ITEM bob ON gp.ORD_NO = bob.ORD_NO AND gp.ORD_ITEM = bob.ORD_ITEM ");//
//strSql.AppendLine("LEFT JOIN BP_ORDER_ITEM boo ON gp.ORG_ORD_NO = boo.ORD_NO AND gp.ORG_ORD_ITEM = boo.ORD_ITEM ");//
strSql.AppendLine("select DISTINCT PROC_CD|| DECODE(PRICE_GRD,'2','现货',''),ALTERNATIVE_PRICE,GENUINE_PRICE, CASE SUB_FULL when 'C' then '完全替代' when 'P' then '部分替代' else '' end IS_FULL,sur.*, SUB_DATE as data_time, CD_NAME, TO_CHAR((BOI_ORD_LEN * BOI_ORD_WID * BOI_ORD_THK * 7.85 / 1000000000), 'FM9999999990.000') as BOB_WGT from SUPERSEDE_BACKUPS sur ");
strSql.AppendLine("left join (select * from ZP_CD where cd_mana_no='G0099') b on sur.GP_WOO_RSN=b.CD WHERE 1=1 ");
if (queryArgs != null)
{
if (!string.IsNullOrWhiteSpace(queryArgs.IS_FULL))
{
if (queryArgs.IS_FULL == "完全替代")
{
strSql.AppendLine(" AND sur.SUB_FULL = '" + "C" + "'");
}
if (queryArgs.IS_FULL == "部分替代")
{
strSql.AppendLine(" AND sur.SUB_FULL = '" + "P" + "'");
}
}
if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD))
{
strSql.AppendLine(" AND sur.id in (select id from SUPERSEDE where 1=1 ");
string PROC_CD = queryArgs.PROC_CD;
PROC_CD = PROC_CD.Replace(",", "','");
strSql.AppendLine(" AND sur.PROC_CD in ('" + PROC_CD + "')");
if (queryArgs.PROC_CD.Contains("XAC现货"))
{
strSql.AppendLine(" or sur.PROC_CD = 'XAC' AND sur.PRICE_GRD = '2'");
}
strSql.AppendLine(")");
}
//替代时仓库
if (!string.IsNullOrWhiteSpace(queryArgs.GP_CUR_INV))
{
string GP_CUR_INV = queryArgs.GP_CUR_INV;
GP_CUR_INV = GP_CUR_INV.Replace(",", "','");
strSql.AppendLine(" AND sur.GP_CUR_INV in ('" + GP_CUR_INV + "')");
}
//if (!string.IsNullOrWhiteSpace(queryArgs.GP_CUR_INV)) strSql.AppendLine(" AND sur.GP_CUR_INV = '" + queryArgs.GP_CUR_INV + "'");
//欠量
if (!string.IsNullOrWhiteSpace(queryArgs.SUB_LACK_NUM)) strSql.AppendLine(" AND sur.SUB_LACK_NUM = '" + queryArgs.SUB_LACK_NUM + "'");
//状态
// if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD)) strSql.AppendLine(" AND sur.PROC_CD = '" + queryArgs.PROC_CD + "'");
//标准
if (!string.IsNullOrWhiteSpace(queryArgs.APLY_STDSPEC)) strSql.AppendLine(" AND sur.APLY_STDSPEC LIKE '%" + queryArgs.APLY_STDSPEC + "%'");
//厚度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_THK) && CommonUtils.IsNumber(queryArgs.START_THK)) strSql.AppendLine(" AND sur.THK >=" + queryArgs.START_THK);
if (!string.IsNullOrWhiteSpace(queryArgs.END_THK) && CommonUtils.IsNumber(queryArgs.END_THK)) strSql.AppendLine(" AND sur.THK <=" + queryArgs.END_THK);
//长度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_LEN) && CommonUtils.IsNumber(queryArgs.START_LEN)) strSql.AppendLine(" AND sur.LEN >=" + queryArgs.START_LEN);
if (!string.IsNullOrWhiteSpace(queryArgs.END_LEN) && CommonUtils.IsNumber(queryArgs.END_LEN)) strSql.AppendLine(" AND sur.LEN <=" + queryArgs.END_LEN);
//宽度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID) && CommonUtils.IsNumber(queryArgs.START_WID)) strSql.AppendLine(" AND sur.WID >=" + queryArgs.START_WID);
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID) && CommonUtils.IsNumber(queryArgs.END_WID)) strSql.AppendLine(" AND sur.WID <=" + queryArgs.END_WID);
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND sur.PLATE_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
//钢种
if (!string.IsNullOrWhiteSpace(queryArgs.STLGRD)) strSql.AppendLine(" AND sur.STLGRD LIKE '%" + queryArgs.STLGRD + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
strSql.AppendLine("Order By SUB_RATE DESC ");
dtCheck = db.Query(strSql.ToString());
//result.data = 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("GetSupersede 报错", ex);
}
return result;
}
/// <summary>
/// 炼钢,轧钢等待可替代余材
/// 查询(SUPERSEDE_BACKUPS_copy2 表)
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("GetSUPERSEDE_BACKUPS_copy2")]
public RequestEntity GetSUPERSEDE_BACKUPS_copy2(SupersedeQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("select DISTINCT PROC_CD|| DECODE(PRICE_GRD,'2','现货',''),ALTERNATIVE_PRICE,GENUINE_PRICE, CASE SUB_FULL when 'C' then '完全替代' when 'P' then '部分替代' else '' end IS_FULL,sur.*, SUB_DATE as data_time, CD_NAME, TO_CHAR((BOI_ORD_LEN * BOI_ORD_WID * BOI_ORD_THK * 7.85 / 1000000000), 'FM9999999990.000') as BOB_WGT from SUPERSEDE_BACKUPS_copy2 sur ");
strSql.AppendLine("left join (select * from ZP_CD where cd_mana_no='G0099') b on sur.GP_WOO_RSN=b.CD WHERE 1=1 ");
if (queryArgs != null)
{
//生产厂
if (!string.IsNullOrWhiteSpace(queryArgs.PLT))
{
strSql.AppendLine(" AND sur.GP_PLT = '" + queryArgs.PLT + "'");
}
//不能有完全替代的钢板,余材替代应该全部替代
strSql.AppendLine(" AND sur.SUB_FULL = '" + "P" + "'");
//strSql.AppendLine(" AND sur.EEF_RATE <100");
if (!string.IsNullOrWhiteSpace(queryArgs.IS_FULL))
{
if (queryArgs.IS_FULL == "完全替代")
{
strSql.AppendLine(" AND sur.SUB_FULL = '" + "C" + "'");
}
if (queryArgs.IS_FULL == "部分替代")
{
strSql.AppendLine(" AND sur.SUB_FULL = '" + "P" + "'");
}
}
if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD))
{
strSql.AppendLine(" AND sur.id in (select id from SUPERSEDE where 1=1 ");
string PROC_CD = queryArgs.PROC_CD;
PROC_CD = PROC_CD.Replace(",", "','");
strSql.AppendLine(" AND sur.PROC_CD in ('" + PROC_CD + "')");
if (queryArgs.PROC_CD.Contains("XAC现货"))
{
strSql.AppendLine(" or sur.PROC_CD = 'XAC' AND sur.PRICE_GRD = '2'");
}
strSql.AppendLine(")");
}
//替代时仓库
if (!string.IsNullOrWhiteSpace(queryArgs.GP_CUR_INV))
{
string GP_CUR_INV = queryArgs.GP_CUR_INV;
GP_CUR_INV = GP_CUR_INV.Replace(",", "','");
strSql.AppendLine(" AND sur.GP_CUR_INV in ('" + GP_CUR_INV + "')");
}
//if (!string.IsNullOrWhiteSpace(queryArgs.GP_CUR_INV)) strSql.AppendLine(" AND sur.GP_CUR_INV = '" + queryArgs.GP_CUR_INV + "'");
//欠量
if (!string.IsNullOrWhiteSpace(queryArgs.SUB_LACK_NUM)) strSql.AppendLine(" AND sur.SUB_LACK_NUM = '" + queryArgs.SUB_LACK_NUM + "'");
//状态
// if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD)) strSql.AppendLine(" AND sur.PROC_CD = '" + queryArgs.PROC_CD + "'");
//标准
if (!string.IsNullOrWhiteSpace(queryArgs.APLY_STDSPEC)) strSql.AppendLine(" AND sur.APLY_STDSPEC LIKE '%" + queryArgs.APLY_STDSPEC + "%'");
//厚度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_THK) && CommonUtils.IsNumber(queryArgs.START_THK)) strSql.AppendLine(" AND sur.THK >=" + queryArgs.START_THK);
if (!string.IsNullOrWhiteSpace(queryArgs.END_THK) && CommonUtils.IsNumber(queryArgs.END_THK)) strSql.AppendLine(" AND sur.THK <=" + queryArgs.END_THK);
//长度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_LEN) && CommonUtils.IsNumber(queryArgs.START_LEN)) strSql.AppendLine(" AND sur.LEN >=" + queryArgs.START_LEN);
if (!string.IsNullOrWhiteSpace(queryArgs.END_LEN) && CommonUtils.IsNumber(queryArgs.END_LEN)) strSql.AppendLine(" AND sur.LEN <=" + queryArgs.END_LEN);
//宽度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID) && CommonUtils.IsNumber(queryArgs.START_WID)) strSql.AppendLine(" AND sur.WID >=" + queryArgs.START_WID);
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID) && CommonUtils.IsNumber(queryArgs.END_WID)) strSql.AppendLine(" AND sur.WID <=" + queryArgs.END_WID);
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND sur.PLATE_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
//钢种
if (!string.IsNullOrWhiteSpace(queryArgs.STLGRD)) strSql.AppendLine(" AND sur.STLGRD LIKE '%" + queryArgs.STLGRD + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
strSql.AppendLine("Order By SUB_RATE DESC ");
dtCheck = db.Query(strSql.ToString());
//result.data = db.Query(strSql.ToString());
result.data = dtCheck;
StringBuilder strPlateNo = new StringBuilder();
for (int i = 0; i <= dtCheck.Rows.Count - 1; i++)
{
if (i==0)
{
strPlateNo.AppendLine("'" + dtCheck.Rows[i]["PLATE_NO"] + "'");
}
else
{
strPlateNo.AppendLine(",'" + dtCheck.Rows[i]["PLATE_NO"] + "'");
}
}
//剔除掉非余材的信息
if (strPlateNo.ToString().Length!=0)
{
StringBuilder strPlate = new StringBuilder();
strPlate.AppendLine(" SELECT* FROM NISCO.GP_PLATE gp WHERE 1=1");
strPlate.AppendLine("AND gp.ORD_FL = '1'");
strPlate.AppendLine(" AND gp.PLATE_NO IN( ");
strPlate.AppendLine(strPlateNo.ToString());
strPlate.AppendLine(") ");
using (IDbContext db_sur = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
var dtPlate = db_sur.Query(strPlate.ToString());
foreach (DataRow row in dtCheck.Rows)
{
//24304312010201
if (row["PLATE_NO"].ToString() == "24303644030324")
{
}
var filteredRows = dtPlate.AsEnumerable().Where(p => p.Field<string>("PLATE_NO") == row["PLATE_NO"].ToString());
//var query = from DataRow row2 in dtPlate.Rows
// where row2["PLATE_NO"] == row["PLATE_NO"].ToString()
// select row2;
//if (query.Count()>0)
//{
// row.Delete();
//}
if (filteredRows.Count()>0)
{
row.Delete();
}
}
}
}
dtCheck.AcceptChanges();
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("GetSupersede 报错", ex);
}
return result;
}
[HttpPost, Route("GetCnt")]
//查询替代块数
public RequestEntity GetCnt(SupersedeQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("select count(1) cnt from SUPERSEDE sur WHERE 1=1 ");
if (queryArgs != null)
{
//标准号
if (!string.IsNullOrWhiteSpace(queryArgs.APLY_STDSPEC)) strSql.AppendLine(" AND sur.APLY_STDSPEC LIKE '%" + queryArgs.APLY_STDSPEC + "%'");
//厚度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_THK) && CommonUtils.IsNumber(queryArgs.START_THK)) strSql.AppendLine(" AND sur.THK >=" + queryArgs.START_THK);
if (!string.IsNullOrWhiteSpace(queryArgs.END_THK) && CommonUtils.IsNumber(queryArgs.END_THK)) strSql.AppendLine(" AND sur.THK <=" + queryArgs.END_THK);
//长度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_LEN) && CommonUtils.IsNumber(queryArgs.START_LEN)) strSql.AppendLine(" AND sur.LEN >=" + queryArgs.START_LEN);
if (!string.IsNullOrWhiteSpace(queryArgs.END_LEN) && CommonUtils.IsNumber(queryArgs.END_LEN)) strSql.AppendLine(" AND sur.LEN <=" + queryArgs.END_LEN);
//宽度上下限
if (!string.IsNullOrWhiteSpace(queryArgs.START_WID) && CommonUtils.IsNumber(queryArgs.START_WID)) strSql.AppendLine(" AND sur.WID >=" + queryArgs.START_WID);
if (!string.IsNullOrWhiteSpace(queryArgs.END_WID) && CommonUtils.IsNumber(queryArgs.END_WID)) strSql.AppendLine(" AND sur.WID <=" + queryArgs.END_WID);
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND sur.PLATE_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
//钢种
if (!string.IsNullOrWhiteSpace(queryArgs.STLGRD)) strSql.AppendLine(" AND sur.STLGRD LIKE '%" + queryArgs.STLGRD + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
dtCheck = db.Query(strSql.ToString());
//result.data = 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("GetSupersede 报错", ex);
}
return result;
}
///// <summary>
///// 查询余材订单
///// </summary>
///// <returns></returns>
///// 方法如果被static修饰, 则在接口中无法被发现(原因不详)
[HttpPost, Route("GetSupersedeOrder")]
public RequestEntity GetSupersedeOrder(SUPERSEDE_ORDER queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine(" SELECT DISTINCT b.PLATE_NO,b.ORD_NO,b.ORD_ITEM,b.STDSPEC,b.ORD_THK,b.ORD_WID,b.ORD_LEN,b.ORD_WGT,b.CUST_CD,b.ENDUSE_CD,b.ORD_KND,b.x,b.y,b.wid,b.heigth FROM SUPERSEDE t ");
strSql.AppendLine(" Left join SUPERSEDE_ORDER b on t.PLATE_NO=b.PLATE_NO ");
strSql.AppendLine(" where 1=1 ");
if (queryArgs != null)
{
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND b.PLATE_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
//strSql.AppendLine("Order By INS_DATE DESC ");
dtCheck = db.Query(strSql.ToString());
result.data = db.Query<SUPERSEDE_ORDER>(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("GetSupersedeOrder 报错", ex);
}
return result;
}
/// <summary>
/// 确认替代 STATE = Y 或拒绝替代 STATE = N 按钮
/// 点击确认或拒绝按钮则删除supersede表中确认记录,添加到SUPERSEDE_CONFIRAM表
/// </summary>·
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("delSupAddSupersedeConfiram")]
public RequestEntity DelSupAddSupersedeConfiram(IList<SupersedeRequestArgs> listdelAddModel)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//因为是同时操作两个表, 所以开启事务
db.BeginTransaction();
bool b = true;
foreach (SupersedeRequestArgs delAddModel in listdelAddModel)
{
string strSql = string.Format("DELETE FROM SUPERSEDE WHERE PLATE_NO = '{0}' AND APLY_STDSPEC = '{1}' AND ORD_NO = '{2}' AND ORD_ITEM = '{3}'", delAddModel.PLATE_NO, delAddModel.APLY_STDSPEC, delAddModel.ORD_NO, delAddModel.ORD_ITEM);
//将匹配表的记录信息复制给历史记录表
SUPERSEDE_CONFIRAM sc = new SUPERSEDE_CONFIRAM
{
PLATE_NO = delAddModel.PLATE_NO,
PROC_CD = delAddModel.PROC_CD,
ORD_NO = delAddModel.ORD_NO,
ORD_ITEM = delAddModel.ORD_ITEM,
INS_DATE = DateTime.Now.ToString("yyyyMMdd"),
INS_TIME = DateTime.Now.ToString("HHmmss"),
//替代状态
STATE = delAddModel.STATE
};
SUPERSEDE supData = new SUPERSEDE();
string strSqlSup = "SELECT * FROM SUPERSEDE WHERE ID ='" + delAddModel.ID + "'";
//获取替代信息
supData = db.QuerySingle<SUPERSEDE>(strSqlSup);
//替代履历
SUPERSEDE_HISTORY supHis = GetSupHis(supData, delAddModel);
//PDO
TBDIPDO InsertPDO = GetTBDIBKDPDO(supData);
db.Insert<TBDIPDO>(InsertPDO);
if (db.Execute(strSql) == 0)
{
b = false;
break;
}
if (db.Insert<SUPERSEDE_HISTORY>(supHis) == 0)
{
b = false;
break;
}
}
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("AddSingleSup")]
/// <summary>
/// 单个钢板手动替代
/// </summary>
/// <param name="ArgsSupersede"></param>
/// <returns></returns>
public RequestEntity AddSingleSup(SupersedeQueryArgs ArgsSupersede)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
try
{
string args = ArgsSupersede.PLATE_NO+"01";
Process KHMsg = new Process();
KHMsg.StartInfo.FileName = @"D:\Program\SurplusMaterial\SinglePlateHandle.exe";
KHMsg.StartInfo.Arguments = args;
//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;
}
}
/// <summary>
/// 历史信息查询按钮
/// 查询(SUPERSEDE_CONFIRAM 表)
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getSupersedeConfiram")]
public RequestEntity GetSupersedeConfiram(SupersedeConfiramQueryArgs queryArgs)
{
int querynum = 0;
foreach (PropertyInfo info in queryArgs.GetType().GetProperties())
{
object ob= queryArgs.GetType().GetProperty(info.Name).GetValue(queryArgs, null);
if(ob!=null)
{
if(!string.IsNullOrWhiteSpace(ob.ToString()))
querynum++;
}
}
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
DataTable dtPlate = new DataTable();
//DataTable dtOrd = new DataTable();
//PLATE_NO , PROC_CD , THK , WID , LEN , SURPLUS_THK , SURPLUS_WID , SURPLUS_LEN , SURPLUS_PER , ORD_NO , ORD_ITEM , STATE
strSql.AppendLine("select DISTINCT CASE SPLITTING when '1' then '是' when '2' then '是' else '否' end DIVISION , CASE HAN_RSL when 'S' then '成功' when 'F' then '失败' else '未处理' end HAN_STATE, TO_CHAR(TO_date(CON_DATE, 'yyyy-mm-dd HH24:mi:ss'), 'mm-dd HH24:mi') con_time, PROC_CD || DECODE(PRICE_GRD, '2', '现货', '') PROC_STATE, CASE SUB_FULL when 'C' then '完全替代' when 'P' then '部分替代' else '' end IS_FULL, a.*, SUB_DATE as data_time, CD_NAME, TO_CHAR((BOI_ORD_LEN * BOI_ORD_WID * BOI_ORD_THK * 7.85 / 1000000000), 'FM9999999990.000') as BOB_WGT from SUPERSEDE_HISTORY a ");
strSql.AppendLine("left join (select * from ZP_CD where cd_mana_no='G0099') b on a.GP_WOO_RSN=b.CD WHERE 1=1 ");
if (queryArgs != null)
{
//是否接收替代
if (!string.IsNullOrWhiteSpace(queryArgs.STATE)) strSql.AppendLine(" AND a.STATE = '" + queryArgs.STATE + "'");
//钢板号
//if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND a.PLATE_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND TRIM(REPLACE(a.PLATE_NO,' ','')) LIKE TRIM(REPLACE('%" + queryArgs.PLATE_NO + "%',' ',''))");
if (!string.IsNullOrWhiteSpace(queryArgs.IS_FULL))
{
if (queryArgs.IS_FULL == "完全替代")
{
strSql.AppendLine(" AND a.SUB_FULL = '" + "C" + "'");
}
if (queryArgs.IS_FULL == "部分替代")
{
strSql.AppendLine(" AND a.SUB_FULL = '" + "P" + "'");
}
}
//替代时仓库
if (!string.IsNullOrWhiteSpace(queryArgs.GP_CUR_INV))
{
string GP_CUR_INV = queryArgs.GP_CUR_INV;
GP_CUR_INV = GP_CUR_INV.Replace(",", "','");
strSql.AppendLine(" AND a.GP_CUR_INV in ('" + GP_CUR_INV + "')");
}
if (!string.IsNullOrWhiteSpace(queryArgs.DIVISION))
{
if (queryArgs.DIVISION == "是")
{
strSql.AppendLine(" AND a.SPLITTING in ('1','2')");
}
else
{
strSql.AppendLine(" AND a.SPLITTING is null ");
}
}
//进程号
if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD))
{
//if (queryArgs.PROC_CD == "XAC现货")
//{
// strSql.AppendLine(" AND a.PROC_CD = 'XAC'");
// strSql.AppendLine(" AND a.PRICE_GRD = '2' ");
//}
//else
//{
// strSql.AppendLine(" AND a.PROC_CD = '" + queryArgs.PROC_CD + "'");
//}
//string PROC_CD = queryArgs.PROC_CD;
//PROC_CD = PROC_CD.Replace(",", "','");
//strSql.AppendLine(" AND a.PROC_CD in ('" + PROC_CD + "')");
//if (queryArgs.PROC_CD.Contains("XAC现货"))
//{
// strSql.AppendLine(" or a.PROC_CD = 'XAC'");
// strSql.AppendLine(" AND a.PRICE_GRD = '2' ");
//}
strSql.AppendLine(" AND a.id in (select id from SUPERSEDE_HISTORY where 1=1 ");
string PROC_CD = queryArgs.PROC_CD;
PROC_CD = PROC_CD.Replace(",", "','");
strSql.AppendLine(" AND a.PROC_CD in ('" + PROC_CD + "')");
if (queryArgs.PROC_CD.Contains("XAC现货"))
{
strSql.AppendLine(" or a.PROC_CD = 'XAC' AND a.PRICE_GRD = '2'");
}
strSql.AppendLine(")");
}
if (!string.IsNullOrEmpty(queryArgs.HAN_STATE))
{
if (queryArgs.HAN_STATE == "未处理")
{
strSql.AppendLine(" AND a.HAN_RSL is null ");
}
if (queryArgs.HAN_STATE == "成功")
{
strSql.AppendLine(" AND a.HAN_RSL = 'S'");
}
if (queryArgs.HAN_STATE == "失败")
{
strSql.AppendLine(" AND a.HAN_RSL = 'F'");
}
}
//是否终结订单
if (!string.IsNullOrWhiteSpace(queryArgs.IS_END)) strSql.AppendLine(" AND a.IS_END = '" + queryArgs.IS_END + "'");
//处理内容
if (!string.IsNullOrWhiteSpace(queryArgs.HAN_CON)) strSql.AppendLine(" AND a.HAN_CON LIKE '%" + queryArgs.HAN_CON + "%'");
//if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD)) strSql.AppendLine(" AND a.PROC_CD LIKE '%" + queryArgs.PROC_CD + "%'");
//订单号
//if (!string.IsNullOrWhiteSpace(queryArgs.ORD_NO)) strSql.AppendLine(" AND a.BOI_ORD_NO LIKE '%" + queryArgs.ORD_NO + "%'");
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_NO)) strSql.AppendLine(" AND TRIM(REPLACE(a.BOI_ORD_NO,' ','')) LIKE TRIM(REPLACE('%" + queryArgs.ORD_NO + "% ',' ',''))");
//if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND TRIM(REPLACE(a.BOI_ORD_NO,' ','')) LIKE TRIM(REPLACE('% + queryArgs.BOI_ORD_NO + %',' ',''))");
//订单序列号
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_ITEM)) strSql.AppendLine(" AND a.BOI_ORD_ITEM LIKE '%" + queryArgs.ORD_ITEM + "%'");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.START_TIME)) && CommonUtils.ObjectToStr(queryArgs.START_TIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(a.SUB_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
strSql.AppendLine(" AND to_date(a.SUB_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
//日期空间传值有问题为了演示先处理掉2023-05-11
if (queryArgs.START_TIME == DateTime.MinValue && queryArgs.END_TIME == DateTime.MinValue && querynum == 2)
{
queryArgs.START_TIME = DateTime.Now.AddDays(-2);
queryArgs.END_TIME = DateTime.Now;
strSql.AppendLine(" AND to_date(a.SUB_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(a.SUB_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
//strSql.AppendLine("Order By INS_DATE DESC ");
strSql.AppendLine(" Order By TO_date(CON_DATE, 'yyyy-mm-dd HH24:mi:ss') DESC ");
dtCheck = db.Query(strSql.ToString());
dtCheck.Columns.Add("PROC_CD_NOW");
dtCheck.Columns.Add("ORD_FL");
dtCheck.Columns.Add("CURRENT_CUR_INV");
dtCheck.Columns.Add("CURRENT_LOC");
string plate_no = " select PLATE_NO,PROC_CD,ORD_FL,CUR_INV,LOC from NISCO.GP_PLATE where PLATE_NO in ('";
//string ord_no = " select ORD_NO,ORD_ITEM,ORD_KND from NISCO.BP_ORDER_ITEM where 1=1 ";
if (dtCheck.Rows.Count > 0)
{
int n = 0;
foreach (DataRow row in dtCheck.Rows)
{
if(n==0)
{
plate_no += row["PLATE_NO"].ToString();
}
else
{
plate_no +="','" +row["PLATE_NO"].ToString();
}
//多条1000会报错 截取城 多列sql 查询
if(n>900)
{
n = n - 900;
plate_no += "') or PLATE_NO in ('" + row["PLATE_NO"].ToString();
}
//ord_no += " or ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'";
n++;
}
plate_no += "')";
using (IDbContext db_sur = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
dtPlate = db_sur.Query(plate_no.ToString());
//dtOrd = db_sur.Query(ord_no.ToString());
}
if(dtPlate.Rows.Count>0)
{
foreach(DataRow row in dtCheck.Rows)
{
DataRow[] rw = dtPlate.Select(" PLATE_NO='" + row["PLATE_NO"].ToString() + "'");
if(rw.Length>0)
{
string PROC_CD_NOW = rw[0]["PROC_CD"].ToString();
string ORD_FL = rw[0]["ORD_FL"].ToString();
string CURRENT_CUR_INV = rw[0]["CUR_INV"].ToString();
string CURRENT_LOC = rw[0]["LOC"].ToString();
row["PROC_CD_NOW"] = PROC_CD_NOW;
//string ORD_KND = dtOrd.Select(" ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'")[0].ToString();
if (ORD_FL == "2")
{
row["ORD_FL"] = "2";
}
else if (ORD_FL == "1")
{
row["ORD_FL"] = "1";
}
row["CURRENT_CUR_INV"] = CURRENT_CUR_INV;
row["CURRENT_LOC"] = CURRENT_LOC;
string HAN_DATE = row["HAN_DATE"].ToString();//处理时间不变
string DATA_TIME = row["DATA_TIME"].ToString();//替代时间
if (!string.IsNullOrEmpty(HAN_DATE) && !string.IsNullOrEmpty(DATA_TIME))
{
DateTime HAN_DATE1 = DateTime.Parse(HAN_DATE);
DateTime DATA_TIME1 = DateTime.Parse(DATA_TIME);
TimeSpan timeDiff = HAN_DATE1 - DATA_TIME1;
double totalMinutes = Math.Floor(timeDiff.TotalMinutes);
if (totalMinutes >= 3)
{
string a = DATA_TIME1.AddMinutes(totalMinutes - 2).ToString();
row["DATA_TIME"] = a;
}
}
}
}
}
}
//余材/订单材
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_FL))
{
DataRow[] rows = dtCheck.Select(" ORD_FL='" + queryArgs.ORD_FL + "'");
if (rows.Length > 0)
{
dtCheck = rows.CopyToDataTable();
}
else
{
//result.msg = "未找到查询所需数据!";
//result.code = "1";
dtCheck = new DataTable();
//return result;
}
}
if (!string.IsNullOrWhiteSpace(queryArgs.PROC_CD_NOW))
{
DataRow[] rows = dtCheck.Select(" PROC_CD_NOW='" + queryArgs.PROC_CD_NOW + "'");
if (rows.Length > 0)
{
dtCheck = rows.CopyToDataTable();
}
else
{
//result.msg = "未找到查询所需数据!";
//result.code = "1";
dtCheck = new DataTable();
//return result;
}
//dtCheck = dtCheck.Select(" PROC_CD_NOW='" + queryArgs.PROC_CD_NOW + "'").CopyToDataTable();
}
if (dtCheck.Rows.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("GetSupersedeConfiram 报错", ex);
}
return result;
}
/// <summary>
/// 对所有余材订单信息做匹配并存入SUPERSEDE表中
/// 且排除SUPERSEDE_CONFIRAM表中已经完成操作的数据
/// </summary>
/// 因为定时器方法必须有一个object类型的参数, 所以随意添加一个参数 , 方法内部并未用到
/// 因为定时器方法必须是静态的所以添加static
/// /// <param name="stateInfo"></param>
/// <returns></returns>
/// 方法如果被static修饰, 则在接口中无法被发现(原因不详)
[HttpPost, Route("addSupersede")]
public static void AddSupersede(GP_PLATE gP_PLATE)
{
try
{
gSUPERSEDE.Clear();
gTEMP_DATA.Clear();
ltPlateNo.Clear();
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//获取厚度
gltGPTHKADD = GetGPTHKADD();
//获取标准
gltQPSTDHEAD = GetQPSTDHEAD();
//获取设置参数
gltTBSubRules = GetTBPSRules();
//获取仓库偏移参数
gltWarDiffDays = GetWarDiffDays();
if (gltTBSubRules.Count > 0)
{
intLOOP_CYC = ConverDataToInt(gltTBSubRules[0].LOOP_CYC);
logger.Info("【周期】:" + intLOOP_CYC);
intORD_DAYS_DIFF = ConverDataToInt(gltTBSubRules[0].ORD_DAYS_DIFF);
logger.Info("【订单日期偏移量】:" + intORD_DAYS_DIFF);
intPLATE_DAYS_DIFF = ConverDataToInt(gltTBSubRules[0].PLATE_DAYS_DIFF);
logger.Info("【钢板日期偏移量】:" + intPLATE_DAYS_DIFF);
DecSUB_RATE = ConverDataToDecimal(gltTBSubRules[0].SUB_RATE);
logger.Info("【替代率】:" + DecSUB_RATE);
DecEFF_WID = ConverDataToDecimal(gltTBSubRules[0].EFF_WID);
logger.Info("【剩余最小宽】:" + DecEFF_WID);
DecEFF_LEN = ConverDataToDecimal(gltTBSubRules[0].EFF_LEN);
logger.Info("【剩余最小长】:" + DecEFF_LEN);
SPLITTING_LEN = ConverDataToDecimal(gltTBSubRules[0].SPLITTING_LEN);
logger.Info("【分板长度】:" + SPLITTING_LEN);
}
string strWHereOrd = string.Empty;
string strWHerePlate = string.Empty;
if (!string.IsNullOrEmpty(gP_PLATE.PLATE_NO))
{
if (gP_PLATE.PLATE_NO.Length > 7)
{
strWHerePlate += " AND GP.PLATE_NO ='" + gP_PLATE.PLATE_NO + "'";
}
}
if (intPLATE_DAYS_DIFF != 0)
{
strWHerePlate += " AND GP.PROD_DATE > TO_CHAR(SYSdate + '" + intPLATE_DAYS_DIFF.ToString() + "' ,'yyyyMMdd')";
}
if (intORD_DAYS_DIFF != 0)
{
strWHereOrd += " AND boi.DEL_TO_DATE > TO_CHAR(SYSdate + '" + intORD_DAYS_DIFF.ToString() + "' ,'yyyyMMdd')";
}
//获取所有待确认数据
gltUnConSur = GetUnConSUPERSEDE();
logger.Info("【待确认数据】:" + gltUnConSur.Count);
////TODO:测试,不排除待确认数据*************
//gltUnConSur.Clear();
//获取所有可用余材
gP_PLATEs = GetSurplusMaterial(strWHerePlate);
logger.Info("【余材信息】:" + gP_PLATEs.Count);
//获取所有可用订单
orderEntities = GetOrders(strWHereOrd);
logger.Info("【订单信息】:" + orderEntities.Count);
//获取全部标准信息
gCP_NISCO_CHMC_SLs = GetStandGroup();
logger.Info("【全部标准信息】:" + gCP_NISCO_CHMC_SLs.Count);
//获取所有可用订单化学成分
gQP_QLTY_CHEM = GetOrderChemistry(strWHereOrd);
logger.Info("【余材化学成分】:" + gQP_QLTY_CHEM.Count);
//获取所有可用余材化学成分
gQP_CHEM_RSLT = GetChemistry(strWHerePlate);
logger.Info("【订单化学成分】:" + gQP_CHEM_RSLT.Count);
//获取炉号
gFP_SLAB = GetHeat(strWHerePlate);
logger.Info("【炉号】:" + gFP_SLAB.Count);
#region 物理特性
//订单物理特性
gQP_QLTY_MATR_HA = GetQP_QLTY_MATR_HA(strWHereOrd);
logger.Info("【订单HA】" + gQP_QLTY_MATR_HA.Count);
gQP_QLTY_MATR_HB = GetQP_QLTY_MATR_HB(strWHereOrd);
logger.Info("【订单HB】" + gQP_QLTY_MATR_HB.Count);
gQP_QLTY_MATR_HC = GetQP_QLTY_MATR_HC(strWHereOrd);
logger.Info("【订单HC】" + gQP_QLTY_MATR_HC.Count);
gQP_QLTY_MATR_HD = GetQP_QLTY_MATR_HD(strWHereOrd);
logger.Info("【订单HD】" + gQP_QLTY_MATR_HD.Count);
gQP_QLTY_MATR_HE = GetQP_QLTY_MATR_HE(strWHereOrd);
logger.Info("【订单HE】" + gQP_QLTY_MATR_HE.Count);
gQP_QLTY_MATR_HF = GetQP_QLTY_MATR_HF(strWHereOrd);
logger.Info("【订单HF】" + gQP_QLTY_MATR_HF.Count);
gQP_QLTY_MATR_HJ = GetQP_QLTY_MATR_HJ(strWHereOrd);
logger.Info("【订单HJ】" + gQP_QLTY_MATR_HJ.Count);
gQP_QLTY_MATR_HK = GetQP_QLTY_MATR_HK(strWHereOrd);
logger.Info("【订单HK】" + gQP_QLTY_MATR_HK.Count);
gQP_QLTY_MATR_HM = GetQP_QLTY_MATR_HM(strWHereOrd);
logger.Info("【订单HM】" + gQP_QLTY_MATR_HM.Count);
gQP_QLTY_MATR_HN = GetQP_QLTY_MATR_HN(strWHereOrd);
logger.Info("【订单HN】" + gQP_QLTY_MATR_HN.Count);
gQP_QLTY_MATR_HR = GetQP_QLTY_MATR_HR(strWHereOrd);
logger.Info("【订单HR】" + gQP_QLTY_MATR_HR.Count);
gQP_QLTY_MATR_HZ = GetQP_QLTY_MATR_HZ(strWHereOrd);
logger.Info("【订单HZ】" + gQP_QLTY_MATR_HZ.Count);
//钢板物理特性
gQP_TEST_RSLT_HA = GetQP_TEST_RSLT_HA(strWHerePlate);
logger.Info("【钢板HA】" + gQP_TEST_RSLT_HA.Count);
gQP_TEST_RSLT_HB = GetQP_TEST_RSLT_HB(strWHerePlate);
logger.Info("【钢板HB】" + gQP_TEST_RSLT_HB.Count);
gQP_TEST_RSLT_HC = GetQP_TEST_RSLT_HC(strWHerePlate);
logger.Info("【钢板HC】" + gQP_TEST_RSLT_HC.Count);
gQP_TEST_RSLT_HD = GetQP_TEST_RSLT_HD(strWHerePlate);
logger.Info("【钢板HD】" + gQP_TEST_RSLT_HD.Count);
gQP_TEST_RSLT_HE = GetQP_TEST_RSLT_HE(strWHerePlate);
logger.Info("【钢板HE】" + gQP_TEST_RSLT_HE.Count);
gQP_TEST_RSLT_HF = GetQP_TEST_RSLT_HF(strWHerePlate);
logger.Info("【钢板HF】" + gQP_TEST_RSLT_HF.Count);
gQP_TEST_RSLT_HJ = GetQP_TEST_RSLT_HJ(strWHerePlate);
logger.Info("【钢板HJ】" + gQP_TEST_RSLT_HJ.Count);
gQP_TEST_RSLT_HK = GetQP_TEST_RSLT_HK(strWHerePlate);
logger.Info("【钢板HK】" + gQP_TEST_RSLT_HK.Count);
gQP_TEST_RSLT_HM = GetQP_TEST_RSLT_HM(strWHerePlate);
logger.Info("【钢板HM】" + gQP_TEST_RSLT_HM.Count);
gQP_TEST_RSLT_HN = GetQP_TEST_RSLT_HN(strWHerePlate);
logger.Info("【钢板HN】" + gQP_TEST_RSLT_HN.Count);
gQP_TEST_RSLT_HR = GetQP_TEST_RSLT_HR(strWHerePlate);
logger.Info("【钢板HR】" + gQP_TEST_RSLT_HR.Count);
gQP_TEST_RSLT_HZ = GetQP_TEST_RSLT_HZ(strWHerePlate);
logger.Info("【钢板HZ】" + gQP_TEST_RSLT_HZ.Count);
#endregion
//声明匹配后数据集
IList<SUPERSEDE> supersedes = new List<SUPERSEDE>();
//定义需要删除的数据集
IList<SUPERSEDE> delsupersedes = new List<SUPERSEDE>();
foreach (BP_ORDER_ITEM order in orderEntities)
{
logger.InfoFormat("*******开始匹配 订单号:【{0}-{1}】. *******", order.ORD_NO, order.ORD_ITEM);
int intLackNum = Convert.ToInt32(order.SUB_LACK_NUM);//欠量
intLackNum = SetSubNum(order);
intLackNum -= GetSubNum(order);//减掉待确认数据=实际欠量
#region 完全匹配
//根据订单条件筛选钢材信息 初步筛选
List<GP_PLATE> ltGP_PLATE_Full = gP_PLATEs.Where(p =>
p.LEN == order.ORD_LEN //长
&& p.WID == order.ORD_WID //宽
&& p.THK == order.ORD_THK //厚
//&& ConverDataToString(p.SUB_PRO_STA) != "1" //
).ToList();
if (ltGP_PLATE_Full.Count == 0)
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = "";
CD.ORD_NO = order.ORD_NO;
CD.ORD_ITEM = order.ORD_ITEM;
CD.NULL_FULL = "1"; //完全替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
}
//二次判断
foreach (GP_PLATE itemGP_PLATE in ltGP_PLATE_Full)
{
if (intLackNum <= 0)
{
break;
}
//排除待确认的
if (gltUnConSur.Where(p => p.PLATE_NO == itemGP_PLATE.PLATE_NO).ToList().Count > 0)
{
continue;
}
////排除已经被确认的钢板号
//if (ltPlateNo.Contains(itemGP_PLATE.PLATE_NO))
//{
// continue;
//}
switch (itemGP_PLATE.PROC_CD)
{
case "XAC":
#region 完全 XAC
//切割判断与计算切割位置
if (!ChkCalCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//切边状态
if (!ChkCutCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
break;
}
//itemGP_PLATE.SUB_PRO_STA = "1";//标记被替代
//替换成功,更新数据
//SaveData2(itemGP_PLATE, order, ref intLackNum);//intLackNum 是缺少的数量 每次替换之后要减一。
AddTempData(itemGP_PLATE, order, intLackNum, 1, "C");
break;
#endregion
case "QAB":
#region 完全 QAB
//切割判断与计算切割位置
if (!ChkCalCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//切边状态
if (!ChkCutCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
itemGP_PLATE.SUB_PRO_STA = "1";//标记被替代
//替换成功,更新数据
//SaveData(itemGP_PLATE, order, ref intLackNum);//intLackNum 是缺少的数量 每次替换之后要减一。
AddTempData(itemGP_PLATE, order, intLackNum, 1, "P");
break;
#endregion
case "DZB":
#region 完全 QZB
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//切边状态
if (!ChkCutCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
itemGP_PLATE.SUB_PRO_STA = "1";
//替换成功,更新数据
//SaveData(itemGP_PLATE, order, ref intLackNum);//intLackNum 是缺少的数量 每次替换之后要减一。
AddTempData(itemGP_PLATE, order, intLackNum, 1, "P");
break;
#endregion
default:
break;
}
}
#endregion
#region 多块匹配
if (intLackNum >= 2)
{
//根据订单条件筛选钢材信息 初步筛选 钢板的长宽大于2倍的订单长宽
List<GP_PLATE> ltGP_PLATE_Double = gP_PLATEs.Where(p => (
Convert.ToDecimal(p.LEN) >= Convert.ToDecimal(order.ORD_LEN) * 2
&& p.WID == order.ORD_WID && Convert.ToDecimal(p.THK) == Convert.ToDecimal(order.ORD_THK)
&& ConverDataToString(p.SUB_PRO_STA) != "1")
|| (p.LEN == order.ORD_LEN && Convert.ToDecimal(p.THK) == Convert.ToDecimal(order.ORD_THK)
&& ConverDataToString(p.SUB_PRO_STA) != "1"
&& Convert.ToDecimal(p.WID) >= Convert.ToDecimal(order.ORD_WID) * 2)
).ToList();
foreach (GP_PLATE itemGP_PLATE in ltGP_PLATE_Double)
{
if (intLackNum <= 0)
{
break;
}
//排除待确认的
if (gltUnConSur.Where(p => p.PLATE_NO == itemGP_PLATE.PLATE_NO).ToList().Count > 0)
{
continue;
}
switch (itemGP_PLATE.PROC_CD)
{
case "XAC":
#region 多块 XAC
//切割判断与计算切割位置
if (!ChkCalDoubleCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//itemGP_PLATE.SUB_PRO_STA = "1";
//添加到临时数据中,二次优化
//SaveData2(itemGP_PLATE, order, ref intLackNum);
AddTempData(itemGP_PLATE, order, intLackNum, 2, "P");
break;
#endregion
case "QAB":
#region 多块 QAB
//切割判断与计算切割位置
if (!ChkCalDoubleCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//itemGP_PLATE.SUB_PRO_STA = "1";
////添加到临时数据中,二次优化
//SaveData2(itemGP_PLATE, order, ref intLackNum);
AddTempData(itemGP_PLATE, order, intLackNum, 2, "P");
break;
#endregion
case "DZB":
#region 多块 DZB
//切割判断与计算切割位置
if (!ChkCalDoubleCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//itemGP_PLATE.SUB_PRO_STA = "1";
////添加到临时数据中,二次优化
//SaveData2(itemGP_PLATE, order, ref intLackNum);
AddTempData(itemGP_PLATE, order, intLackNum, 2, "P");
break;
#endregion
default:
break;
}
}
}
#endregion
#region 部分匹配
//根据订单条件筛选钢材信息 初步筛选
List<GP_PLATE> ltGP_PLATE_Part = gP_PLATEs.Where(p =>
(Convert.ToDecimal(p.LEN) >= Convert.ToDecimal(order.ORD_LEN) //长
&& Convert.ToDecimal(p.WID) >= Convert.ToDecimal(order.ORD_WID)) //宽
&& p.THK == order.ORD_THK //厚
&& ConverDataToString(p.SUB_PRO_STA) != "1"
).OrderByDescending(p => p.ORD_LEN).OrderByDescending(p => p.ORD_WID).ToList();
if (ltGP_PLATE_Full.Count == 0)
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = "";
CD.ORD_NO = order.ORD_NO;
CD.ORD_ITEM = order.ORD_ITEM;
CD.NULL_PART = "1"; //部分替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
}
//二次判断
foreach (GP_PLATE itemGP_PLATE in ltGP_PLATE_Part)
{
if (intLackNum <= 0)
{
break;
}
//排除待确认的
if (gltUnConSur.Where(p => p.PLATE_NO == itemGP_PLATE.PLATE_NO).ToList().Count > 0)
{
continue;
}
switch (itemGP_PLATE.PROC_CD)
{
case "XAC":
#region 部分 XAC
//切割判断与计算切割位置
if (!ChkCalCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//添加到临时数据中,二次优化
AddTempData(itemGP_PLATE, order, intLackNum, 1, "P");
break;
#endregion
case "QAB":
#region 部分 QAB
//切割判断与计算切割位置
if (!ChkCalCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//添加到临时数据中,二次优化
AddTempData(itemGP_PLATE, order, intLackNum, 1, "P");
break;
#endregion
case "DZB":
#region 部分 DZB
//切割判断与计算切割位置
if (!ChkCalCut(itemGP_PLATE, order))
{
continue;
}
//标准
if (!ChkStandGroup(itemGP_PLATE, order))
{
continue;
}
//厚度公差
if (!ChkTHKTol(itemGP_PLATE, order))
{
continue;
}
//探伤结果
if (!ChkFlawCom(itemGP_PLATE, order))
{
continue;
}
//热处理结果
if (!ChkHeatCom(itemGP_PLATE, order))
{
continue;
}
//实际化学成分
if (!ChkChemCom(itemGP_PLATE, order))
{
continue;
}
//物理属性
if (!ChkPhyCom(itemGP_PLATE, order))
{
continue;
}
////标准
//if (!ChkStandGroup(itemGP_PLATE, order))
//{
// continue;
//}
//添加到临时数据中,二次优化
AddTempData(itemGP_PLATE, order, intLackNum, 1, "P");
break;
#endregion
default:
break;
}
}
#endregion
logger.InfoFormat("*******结束匹配 订单号:【{0}-{1}】.*******", order.ORD_NO, order.ORD_ITEM);
}
#region 二次优化的部分替代
logger.InfoFormat("*******开始二次优化*******");
logger.InfoFormat("*优化前的数量:" + gTEMP_DATA.Count);
foreach (TEMP_DATA TD in gTEMP_DATA)
{
//筛选钢板号替代率最高的数据
TEMP_DATA Fir_TD = gTEMP_DATA.Where(p => p.PLATE_NO == TD.PLATE_NO && p.USE_FLG != "1").OrderByDescending(p => p.SUB_RATE).OrderByDescending(p => p.SUB_NUM).FirstOrDefault();
if (Fir_TD != null)
{
if (Fir_TD.DEF_NUM != 0)
{
logger.InfoFormat("*二次优化(替代率【{3}】)*---订单号【{0}-{1}】==>>钢板号【{2}】"
, Fir_TD.ORD_NO, Fir_TD.ORD_ITEM, Fir_TD.PLATE_NO, Fir_TD.SUB_RATE);
Fir_TD.CON_FLG = "1";
//循环当前所有钢板,标记被使用
foreach (TEMP_DATA TD_PLATE in gTEMP_DATA.Where(p => p.PLATE_NO == TD.PLATE_NO).ToList())
{
TD_PLATE.USE_FLG = "1";//标记已被使用
}
//循环所有被替代的订单,欠量减一
foreach (TEMP_DATA TD_ORDER in gTEMP_DATA.Where(p => p.ORD_NO == TD.ORD_NO && p.ORD_ITEM == TD.ORD_ITEM).ToList())
{
TD_ORDER.DEF_NUM = TD_ORDER.DEF_NUM - TD_ORDER.SUB_NUM;//欠量减替代块数
}
}
}
}
logger.Info("完全替代数量:" + gSUPERSEDE.Count);
//二次优化后存储数据
foreach (TEMP_DATA TD in gTEMP_DATA)
{
if (TD.CON_FLG != "1")//筛选后的数据
{
continue;
}
GP_PLATE GP_save = gP_PLATEs.Where(p => p.PLATE_NO == TD.PLATE_NO).FirstOrDefault();//确认的钢板信息
BP_ORDER_ITEM ORD_save = orderEntities.Where(p => p.ORD_NO == TD.ORD_NO && p.ORD_ITEM == TD.ORD_ITEM).FirstOrDefault();//确认的订单信息
//int int_NUM = 1;
GP_save.SUB_FULL = "0";//部分替代一定是不完全替代=0
//保存数据
SaveData(GP_save, ORD_save, TD);
}
#endregion
logger.InfoFormat("*******结束二次优化*******");
//存储待确认数据
if (gSUPERSEDE.Count > 0)
{
logger.Info("替代总数量:" + gSUPERSEDE.Count);
SerSurMatSubService.SaveSupersede(gSUPERSEDE);
}
if (gCOM_DATA.Count > 0)
{
ExportDataGridToCSV(gCOM_DATA, DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
}
}
catch (Exception ex)
{
logger.Error("AddSupersede 报错 : ", ex);
}
}
/// <summary>
/// 新增余材(外部需要调用的接口)
/// 外部无需调用,改为Kafka发送消息
/// </summary>
/// <param name="gP_PLATE"></param>
/// <returns></returns>
[HttpPost, Route("addSurplusMaterial")]
public RequestEntity AddSurplusMaterial(GP_PLATE gP_PLATE)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
//try
//{
// //不管该余材是否可用都需要添加到表中
// db.Insert<GP_PLATE>(gP_PLATE);
//}
//catch
//{
// logger.Info("余材插入失败了: " + gP_PLATE.ToString());
//}
//判断新增的余材是不是可用余材
//if (gP_PLATE.CUR_INV == "HB")
// if (gP_PLATE.PROD_CD == "PP")
// if (gP_PLATE.REC_STS == "2")
// if (gP_PLATE.PROC_CD == "QAB")
// if (gP_PLATE.SURF_GRD == "1")
// {
// //给该操作加锁
// lock (LOCK)
// {
// //调用所有数据匹配, 因为出现新余材, 所以重新匹配
// //AddSupersede(null);
// }
// }
AddSupersede(gP_PLATE);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddSurplusMaterial 报错 : ", ex);
}
return result;
}
[HttpPost, Route("addSurplusMaterialReset")]
public RequestEntity AddSurplusMaterialReset(GP_PLATE gP_PLATE)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
ResetData();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddSurplusMaterial 报错 : ", ex);
}
return result;
}
/// <summary>
/// 新增订单(外部需要调用的接口)
/// 外部无需调用,改为Kafka发送消息
/// </summary>
/// <param name="gP_PLATE"></param>
/// <returns></returns>
[HttpPost, Route("addOrder")]
public RequestEntity AddOrder(BP_ORDER_ITEM boi)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//不管该订单是否可用都需要添加到表中
db.Insert<BP_ORDER_ITEM>(boi);
}
catch
{
logger.Info("订单插入失败了: " + boi.ToString());
}
//判断新增的订单是不是可用订单
if (boi.PROD_CD == "PP")
if (boi.REC_STS == "2")
if (boi.ORD_STS == "E" || boi.ORD_STS == "D")
if (boi.ORD_KND == "A")
{
lock (LOCK)
{
//调用所有数据匹配, 因为出现新余材, 所以重新匹配
//AddSupersede(null);
}
}
result.msg = "操作成功!";
result.code = "1";
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("AddOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 根据余材查询第一个可用订单
/// </summary>
/// <param name="gP_PLATE"></param>
/// <returns></returns>
[HttpPost, Route("getOrder")]
public RequestEntity GetOrder(GP_PLATE gP_PLATE)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
//因为前端如果返回状态码 1 则需要data有值, 不能为null , 所以给个初始值
result.data = new List<BP_ORDER_ITEM>();
//查询所有可用订单以及常用字段
strSql.AppendLine("SELECT T.* from BP_ORDER_ITEM T " +
// " LEFT JOIN CP_PRC F ON T.ORD_NO = F.ORD_NO" +
// " LEFT JOIN QP_QLTY_DELV C ON T.ORD_NO = C.ORD_NO" +
" WHERE 1=1");
strSql.AppendLine(" AND T.PROD_CD = 'PP'");
strSql.AppendLine(" AND T.REC_STS = '2'");
//订单状态
strSql.AppendLine(" AND T.ORD_STS IN('E', 'D') ");
//订单种类
strSql.AppendLine(" AND T.ORD_KND = 'A' ");
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
//查询所有可用订单
//SurplusMaterialSubstitutionController.orderEntities = db.Query<BP_ORDER_ITEM>(strSql.ToString());
IList<BP_ORDER_ITEM> bpOrderItems = db.Query<BP_ORDER_ITEM>(strSql.ToString());
foreach (BP_ORDER_ITEM item in bpOrderItems)
{
if (gP_PLATE.THK == (item.ORD_THK))
{
if (gP_PLATE.WID == (item.ORD_WID))
{
if (gP_PLATE.LEN == (item.ORD_LEN))
{
//符合条件的订单号
strSql.AppendLine(" AND T.ORD_NO = '" + item.ORD_NO + "' ");
//符合条件的订单序列号
strSql.AppendLine(" AND T.ORD_ITEM = '" + item.ORD_ITEM + "' ");
result.data = db.Query<BP_ORDER_ITEM>(strSql.ToString());
break;
}
}
}
}
if (result.data == null)
{
result.msg = "操作成功未找到符合条件的数据!";
result.code = "1";
}
else
{
result.msg = "操作成功!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 根据余材查询第一个可用订单
/// </summary>
/// <param name="gP_PLATE"></param>
/// <returns></returns>
[HttpPost, Route("AddSurTest")]
public RequestEntity AddSurTest()
{
RequestEntity result = new RequestEntity();
try
{
//获取所有可用余材
gP_PLATEs = GetSurplusMaterial(null);
logger.Info("【余材信息】:" + gP_PLATEs.Count);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 接口测试
/// </summary>
/// <param name="gP_PLATE"></param>
/// <returns></returns>
[HttpPost, Route("AddPDO")]
public RequestEntity AddPDO(SupersedeRequestArgs delAddModel)
{
RequestEntity result = new RequestEntity();
try
{
SUPERSEDE supData = new SUPERSEDE();
string strSqlSup = "SELECT * FROM SUPERSEDE WHERE ID ='" + delAddModel.ID + "'";
IDbContext db = ObjectContainer.GetObject<IDbContext>("db");
//获取替代信息
supData = db.QuerySingle<SUPERSEDE>(strSqlSup);
//PDO
TBDIPDO InsertPDO = GetTBDIBKDPDO(supData);
db.Insert<TBDIPDO>(InsertPDO);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 获取配置参数
/// </summary>
/// <returns></returns>
[HttpPost, Route("GetTBPSConf")]
public RequestEntity GetTBPSConf()
{
RequestEntity result = new RequestEntity();
try
{
//获取替代信息
result.data = SerSurMatSubService.GetTBPSRules();
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 获取配置参数
/// </summary>
/// <returns></returns>
[HttpPost, Route("GetTB_PROCESS_DATA")]
public RequestEntity GetTB_PROCESS_DATA(TB_PROCESS_DATA data)
{
RequestEntity result = new RequestEntity();
try
{
if (data.TYPE == "实时")
data.TYPE = "0";
if(data.TYPE == "批量")
data.TYPE = "1";
//获取替代信息
result.data = SerSurMatSubService.GetTB_PROCESS_DATA(data);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", ex);
}
return result;
}
/// <summary>
/// 更新配置参数
/// </summary>
/// <param name="prTBSubRules">配置参数</param>
/// <returns></returns>
[HttpPost, Route("UpdateTBPSConf")]
public RequestEntity UpdateTBPSConf(TB_PS_CONFIG prTBSubRules)
{
RequestEntity result = new RequestEntity();
try
{
IList<TB_PS_CONFIG> ilist = SerSurMatSubService.GetTBPSRules(prTBSubRules);
if (ilist[0].ID == prTBSubRules.ID
&& ilist[0].LOOP_CYC == prTBSubRules.LOOP_CYC
&& ilist[0].ORD_DAYS_DIFF == prTBSubRules.ORD_DAYS_DIFF
&& ilist[0].PLATE_DAYS_DIFF == prTBSubRules.PLATE_DAYS_DIFF
&& ilist[0].SUB_RATE == prTBSubRules.SUB_RATE
&& ilist[0].SPLITTING_LEN == prTBSubRules.SPLITTING_LEN
&& ilist[0].SUB_RATE_SPEC == prTBSubRules.SUB_RATE_SPEC
&& ilist[0].GENUINE_PRICE == prTBSubRules.GENUINE_PRICE
&& ilist[0].SCRAP_PRICE == prTBSubRules.SCRAP_PRICE
&& ilist[0].CUTTING_COSTS == prTBSubRules.CUTTING_COSTS
&& ilist[0].TRANSPORT_COSTS == prTBSubRules.TRANSPORT_COSTS
&& ilist[0].INSPECT_COSTS == prTBSubRules.INSPECT_COSTS
&& ilist[0].NI_CUTTING_COSTS == prTBSubRules.NI_CUTTING_COSTS
&& ilist[0].HOISTING_WAREHOUSE == prTBSubRules.HOISTING_WAREHOUSE
&& ilist[0].HOISTING_COSTS == prTBSubRules.HOISTING_COSTS
&& ilist[0].NI_STEEL_SCRAP_COSTS_5 == prTBSubRules.NI_STEEL_SCRAP_COSTS_5
&& ilist[0].NI_STEEL_SCRAP_COSTS_9 == prTBSubRules.NI_STEEL_SCRAP_COSTS_9
&& ilist[0].MINIMUM_PROFIT == prTBSubRules.MINIMUM_PROFIT)
{
SerSurMatSubService.UpdateTbPSConf(prTBSubRules);
result.msg = "数据未变更无需确认";
result.code = "2";
return result;
}
SerSurMatSubService.UpdateTbPSConf(prTBSubRules);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetOrder 报错 : ", 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 = SerSurMatSubService.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 = SerSurMatSubService.GetHisDataRate(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataRate 报错 : ", ex);
}
return result;
}
[HttpPost, Route("GetHisDataTotal")]
public RequestEntity GetHisDataTotal(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 = SerSurMatSubService.GetHisDataTotal(QAGP);
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataTotal 报错 : ", ex);
}
return result;
}
//[HttpPost, Route("GetHisDataWGT")]
//public RequestEntity GetHisDataWGT(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.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;
// double TOTAL_PROFIT = 0;
// DataTable dtrRate = new DataTable();
// dtrRate = SerSurMatSubService.GetHisRATE(QAGP);//日期内替代总计
// DataRow newrow = dtCheck.NewRow();
// if (dtCheck.Rows.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());
// TOTAL_PROFIT += Math.Round(Convert.ToDouble(row["PROFIT"].ToString()), 2);
// }
// //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;
// newrow["PROFIT"] = TOTAL_PROFIT;
// 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("GetHisDataWGT")]
public RequestEntity GetHisDataWGT(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 = SerSurMatSubService.GetHisDataWGT(QAGP); // 替代信息
DataTable dtRepCheck = SerSurMatSubService.GetREPHisData(QAGP); // MES替代信息
DataTable dtrRate = SerSurMatSubService.GetHisRATE(QAGP); // 日期内替代总计
double SUB_NUM_Total = 0;
double IS_END_Total = 0;
double SYSTEM_COUNT_Total = 0; // 系统替代块数合计
double SYSTEM_WGT_Total = 0; // 系统替代重量合计
double ART_COUNT_Total = 0; // 人工替代块数合计
double ART_WGT_Total = 0; // 人工替代重量合计
double SYSTEM_PROP_PERCENT_Total = 0; // 系统替代百分比合计
double C1Total = 0;
double C2Total = 0;
double C3Total = 0;
double TOTAL_PROFIT = 0;
DataTable dataTable = new DataTable();
dataTable.Columns.Add("SUB_DATE", typeof(string)); // 替代日期
dataTable.Columns.Add("SUB_RATE", typeof(double)); // 替代率
dataTable.Columns.Add("SYSTEM_COUNT", typeof(double)); // 系统替代块数
dataTable.Columns.Add("SYSTEM_WGT", typeof(double)); // 系统替代重量
dataTable.Columns.Add("ART_COUNT", typeof(double)); // 人工替代块数
dataTable.Columns.Add("ART_WGT", typeof(double)); // 人工替代重量
dataTable.Columns.Add("SYSTEM_PROP_PERCENT", typeof(double)); // 系统替代百分比
dataTable.Columns.Add("C1", typeof(double));
dataTable.Columns.Add("C2", typeof(double));
dataTable.Columns.Add("C3", typeof(double));
dataTable.Columns.Add("SUB_NUM", typeof(double)); // 当日合计吨
dataTable.Columns.Add("PROFIT", typeof(double)); // 增效/元
dataTable.Columns.Add("IS_END", typeof(double)); // 终结订单次数
foreach (DataRow row in dtCheck.Rows)
{
double SYSTEM_COUNT = 0; // 系统替代块数
double SYSTEM_WGT = 0; // 系统替代重量
double ART_COUNT = 0; // 人工替代块数
double ART_WGT = 0; // 人工替代重量
double SYSTEM_PROP_PERCENT = 0; // 系统替代百分比
foreach (DataRow repRow in dtRepCheck.Rows)
{
if (repRow["INS_DATE_DAY"].ToString() == row["SUB_DATE"].ToString())
{
if (!string.IsNullOrEmpty(repRow["SYSTEM_COUNT"].ToString()))
{
SYSTEM_COUNT += Convert.ToDouble(repRow["SYSTEM_COUNT"]);
SYSTEM_COUNT_Total += Convert.ToDouble(repRow["SYSTEM_COUNT"]);
}
if (!string.IsNullOrEmpty(repRow["SYSTEM_WGT"].ToString()))
{
SYSTEM_WGT += Convert.ToDouble(repRow["SYSTEM_WGT"]);
SYSTEM_WGT_Total += Convert.ToDouble(repRow["SYSTEM_WGT"]);
}
if (!string.IsNullOrEmpty(repRow["ART_COUNT"].ToString()))
{
ART_COUNT += Convert.ToDouble(repRow["ART_COUNT"]);
ART_COUNT_Total += Convert.ToDouble(repRow["ART_COUNT"]);
}
if (!string.IsNullOrEmpty(repRow["ART_WGT"].ToString()))
{
ART_WGT += Convert.ToDouble(repRow["ART_WGT"]);
ART_WGT_Total += Convert.ToDouble(repRow["ART_WGT"]);
}
if (!string.IsNullOrEmpty(repRow["SYSTEM_PROP_PERCENT"].ToString()))
{
SYSTEM_PROP_PERCENT += Convert.ToDouble(repRow["SYSTEM_PROP_PERCENT"]);
SYSTEM_PROP_PERCENT_Total += Convert.ToDouble(repRow["SYSTEM_PROP_PERCENT"]);
}
}
}
double C1 = Convert.ToDouble(row["C1"].ToString());
double C2 = Convert.ToDouble(row["C2"].ToString());
double C3 = Convert.ToDouble(row["C3"].ToString());
double SUB_NUM = Convert.ToDouble(row["SUB_NUM"].ToString());
double IS_END = Convert.ToDouble(row["IS_END"].ToString());
double RATE = Convert.ToDouble(row["SUB_RATE"].ToString());
double PROFIT = Math.Round(Convert.ToDouble(row["PROFIT"].ToString()), 2);
TOTAL_PROFIT += PROFIT;
DataRow newrow = dataTable.NewRow();
newrow["SUB_DATE"] = row["SUB_DATE"];
newrow["SUB_RATE"] = RATE;
newrow["SYSTEM_COUNT"] = SYSTEM_COUNT;
newrow["SYSTEM_WGT"] = SYSTEM_WGT;
newrow["ART_COUNT"] = ART_COUNT;
newrow["ART_WGT"] = ART_WGT;
newrow["SYSTEM_PROP_PERCENT"] = SYSTEM_PROP_PERCENT;
newrow["C1"] = C1;
newrow["C2"] = C2;
newrow["C3"] = C3;
newrow["SUB_NUM"] = SUB_NUM;
newrow["PROFIT"] = PROFIT;
newrow["IS_END"] = IS_END;
dataTable.Rows.Add(newrow);
SUB_NUM_Total += SUB_NUM;
IS_END_Total += IS_END;
C1Total += C1;
C2Total += C2;
C3Total += C3;
}
// 添加合计行
DataRow newTotalRow = dataTable.NewRow();
newTotalRow["SUB_DATE"] = "合计";
newTotalRow["SUB_RATE"] = Convert.ToDouble(dtrRate.Rows[0]["SUB_RATE"].ToString());
newTotalRow["SYSTEM_COUNT"] = SYSTEM_COUNT_Total;
//newTotalRow["SYSTEM_WGT"] = SYSTEM_WGT_Total;
newTotalRow["SYSTEM_WGT"] = Math.Round(SYSTEM_WGT_Total, 2);//系统重量和
newTotalRow["ART_COUNT"] = ART_COUNT_Total;
newTotalRow["ART_WGT"] = ART_WGT_Total;
//double avg_SYSTEM_PROP_PERCENT = Math.Round(SYSTEM_PROP_PERCENT_Total / dtCheck.Rows.Count, 2); // 计算平均值并四舍五入
//newTotalRow["SYSTEM_PROP_PERCENT"] = avg_SYSTEM_PROP_PERCENT;
newTotalRow["SYSTEM_PROP_PERCENT"] = Math.Round((SYSTEM_COUNT_Total / (SYSTEM_COUNT_Total + ART_COUNT_Total)) * 100, 2);
newTotalRow["C1"] = Math.Round(C1Total, 2);
newTotalRow["C2"] = Math.Round(C2Total, 2);
newTotalRow["C3"] = Math.Round(C3Total, 2);
newTotalRow["SUB_NUM"] = Math.Round(SUB_NUM_Total, 2);
newTotalRow["PROFIT"] = Math.Round(TOTAL_PROFIT, 2);
newTotalRow["IS_END"] = IS_END_Total;
dataTable.Rows.Add(newTotalRow);
// 获取历史数据
result.data = dataTable;
result.msg = "操作成功!";
result.code = "1";
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetHisDataTotal 报错 : ", ex);
}
return result;
}
#endregion
#region 获取数据
/// <summary>
/// 厚度 (计算单重用)
/// </summary>
/// <returns></returns>
public static IList<GP_THK_ADD> GetGPTHKADD()
{
IList<GP_THK_ADD> reListGPTHKADD = new List<GP_THK_ADD>();
try
{
////开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
//{
reListGPTHKADD = SerSurMatSubService.GetGPTHKADD();
//}
}
catch (Exception ex)
{
logger.Error("GetTBPSRules 报错 : ", ex);
}
return reListGPTHKADD;
}
/// <summary>
/// 标准(计算单重用)
/// </summary>
/// <returns></returns>
public static IList<QP_STD_HEAD> GetQPSTDHEAD()
{
IList<QP_STD_HEAD> reListQPSTDHEAD = new List<QP_STD_HEAD>();
try
{
////开启数据库连接查询数据
//using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
//{
reListQPSTDHEAD = SerSurMatSubService.GetQPSTDHEAD();
//}
}
catch (Exception ex)
{
logger.Error("GetTBPSRules 报错 : ", ex);
}
return reListQPSTDHEAD;
}
/// <summary>
/// 获取配置参数
/// </summary>
/// <returns></returns>
public static IList<TB_PS_CONFIG> GetTBPSRules()
{
IList<TB_PS_CONFIG> reListTBSubRules = new List<TB_PS_CONFIG>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListTBSubRules = SerSurMatSubService.GetTBPSRules();
}
}
catch (Exception ex)
{
logger.Error("GetTBPSRules 报错 : ", ex);
}
return reListTBSubRules;
}
public static IList<REMA_PLA_SUBSI_WAREH_MANAGE> GetWarDiffDays()
{
IList<REMA_PLA_SUBSI_WAREH_MANAGE> reListTBSubRules = new List<REMA_PLA_SUBSI_WAREH_MANAGE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListTBSubRules = SerSurMatSubService.GetWarDiffDays();
}
}
catch (Exception ex)
{
logger.Error("GetTBPSRules 报错 : ", ex);
}
return reListTBSubRules;
}
/// <summary>
/// 获取所有待确认数据
/// </summary>
/// <returns></returns>
public static IList<SUPERSEDE> GetUnConSUPERSEDE()
{
IList<SUPERSEDE> reListSUPERSEDE = new List<SUPERSEDE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListSUPERSEDE = SerSurMatSubService.GetUnConSUPERSEDE();
}
}
catch (Exception ex)
{
logger.Error("GetSurplusMaterial 报错 : ", ex);
}
return reListSUPERSEDE;
}
/// <summary>
/// 查询所有原始可用余材(后台获取接口)
/// </summary>
/// <returns></returns>
/// 方法如果被static修饰, 则在接口中无法被发现(原因不详)
public static IList<GP_PLATE> GetSurplusMaterial(string strWHerePlate)
{
IList<GP_PLATE> reListGP_PLATE = new List<GP_PLATE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListGP_PLATE = SerSurMatSubService.GetAllMat(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetSurplusMaterial 报错 : ", ex);
}
return reListGP_PLATE;
}
/// <summary>
/// 查询所有原始可用订单
/// </summary>
/// <returns></returns>
/// 方法如果被static修饰, 则在接口中无法被发现(原因不详)
public static IList<BP_ORDER_ITEM> GetOrders(string strWHereOrd)
{
IList<BP_ORDER_ITEM> reListBP_ORDER_ITEM = new List<BP_ORDER_ITEM>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListBP_ORDER_ITEM = SerSurMatSubService.GetOrder(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetSurplusMaterial 报错 : ", ex);
}
return reListBP_ORDER_ITEM;
}
/// <summary>
/// 获取标准集合
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
public static IList<CP_NISCO_CHMC_SL> GetStandGroup()
{
IList<CP_NISCO_CHMC_SL> reListCP_NISCO_CHMC_SL = new List<CP_NISCO_CHMC_SL>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListCP_NISCO_CHMC_SL = SerSurMatSubService.GetStandGroup();
}
}
catch (Exception ex)
{
logger.Error("GetStandGroup 报错 : ", ex);
}
return reListCP_NISCO_CHMC_SL;
}
/// <summary>
/// 根据钢板板坯号找到对应炉号,根据炉号找到对应化学成分
/// </summary>
/// <returns>对应的化学成分集合</returns>
/// 方法如果被static修饰, 则在接口中无法被发现(原因不详)
public static IList<QP_CHEM_RSLT> GetChemistry(string strWHereOrd)
{
IList<QP_CHEM_RSLT> reListQP_CHEM_RSLT = new List<QP_CHEM_RSLT>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_CHEM_RSLT = SerSurMatSubService.GetChemistry(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetChemistry 报错 : ", ex);
}
return reListQP_CHEM_RSLT;
}
/// <summary>
/// 获取钢板的炉号
/// </summary>
/// <param name="plate"></param>
/// <returns></returns>
public static IList<FP_SLAB> GetHeat(string strWHerePlate)
{
IList<FP_SLAB> reListFP_SLAB = new List<FP_SLAB>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListFP_SLAB = SerSurMatSubService.GetHeat(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetChemistry 报错 : ", ex);
}
return reListFP_SLAB;
}
//[HttpPost, Route("GetCP_REP_HIS")]
////查询替代块数
//public RequestEntity GetCP_REP_HIS(CP_REP_HISQueryArgs queryArgs)
//{
// int querynum = 0;
// foreach (PropertyInfo info in queryArgs.GetType().GetProperties())
// {
// object ob = queryArgs.GetType().GetProperty(info.Name).GetValue(queryArgs, null);
// if (ob != null)
// {
// if (!string.IsNullOrWhiteSpace(ob.ToString()))
// querynum++;
// }
// }
// RequestEntity result = new RequestEntity(); //声明返回参数实体类
// StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
// DataTable dtCheck = new DataTable();
// DataTable dtPlate = new DataTable();
// strSql.AppendLine("SELECT distinct boi.ORD_KND,CP.MAT_NO PLATE_NO,CP.UPD_AFT_ORD ORD_NO,CP.UPD_AFT_ORD_ITEM ORD_ITEM,GP.PLT,GP.CUR_INV,pr.REPLACE_TYPE,to_char( to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi') INS_DATE FROM NISCO.CP_REP_HIS cp ");
// strSql.AppendLine(" INNER JOIN NISCO.BP_ORDER_ITEM boi ON BOI.ORD_NO = cp.UPD_AFT_ORD AND BOI.ORD_ITEM = cp.UPD_AFT_ORD_ITEM");
// strSql.AppendLine(" INNER JOIN NISCO.GP_PLATE GP ON GP.PLATE_NO = cp.MAT_NO ");
// strSql.AppendLine(" INNER JOIN NISCO.PLATE_REPLACE pr ON GP.PLATE_NO = pr.PLATE_NO ");
// strSql.AppendLine(" where 1=1 AND cp.REP_TYP='2' AND cp.PROD_CD='PP' and cp.INS_EMP not in('BKD','DI') AND pr.REPLACE_TYPE IN (2,3) ");
// if (queryArgs != null)
// {
// if (!string.IsNullOrWhiteSpace(queryArgs.ORD_KND)) strSql.AppendLine(" AND boi.ORD_KND = '" + queryArgs.ORD_KND + "'");
// //钢板号
// if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) strSql.AppendLine(" AND CP.MAT_NO LIKE '%" + queryArgs.PLATE_NO + "%'");
// //订单号
// if (!string.IsNullOrWhiteSpace(queryArgs.ORD_NO)) strSql.AppendLine(" AND CP.UPD_AFT_ORD LIKE '%" + queryArgs.ORD_NO + "%'");
// //订单序列号
// if (!string.IsNullOrWhiteSpace(queryArgs.ORD_ITEM)) strSql.AppendLine(" AND CP.UPD_AFT_ORD_ITEM LIKE '%" + queryArgs.ORD_ITEM + "%'");
// //仓库
// if (!string.IsNullOrWhiteSpace(queryArgs.CUR_INV)) strSql.AppendLine(" AND GP.CUR_INV LIKE '%" + queryArgs.CUR_INV + "%'");
// //工厂
// if (!string.IsNullOrWhiteSpace(queryArgs.PLT)) strSql.AppendLine(" AND GP.PLT LIKE '%" + 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(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
// //if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
// // strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
// if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.START_TIME)) && CommonUtils.ObjectToStr(queryArgs.START_TIME) != "0001/1/1 0:00:00")
// strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
// if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
// strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
// if (queryArgs.START_TIME == DateTime.MinValue && queryArgs.END_TIME == DateTime.MinValue)
// {
// queryArgs.START_TIME = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
// queryArgs.END_TIME = DateTime.Now;
// strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
// strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
// }
// }
// try
// {
// //开启数据库连接查询数据
// using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
// {
// strSql.AppendLine("Order By to_date(INS_DATE ,'yyyy-mm-dd hh24:mi:ss') DESC ");
// dtCheck = db.Query(strSql.ToString());
// dtCheck.Columns.Add("TYPE");
// dtCheck.Columns.Add("REASON");
// //result.data = db.Query(strSql.ToString());
// string plate_no = " select distinct PLATE_NO ,ORD_NO,ORD_ITEM ,REASON,case TYPE when 'OK' then '可以成功' when 'gUnS_SUPERSEDE_HISTORY' then '历史失败' ";
// plate_no += " when 'gltTBPlateSpe' then '不可替代钢板'";
// plate_no += " when 'gltGpPlateReplace' then '锁定钢板' ";
// plate_no += " when 'gltGP_ZZP_YJ' then '保留钢板' ";
// plate_no += " when 'CK' then 'ZB/WG 不可替代仓库' ";
// plate_no += " when 'ACC' then '改判原因是卷轧头尾的不替代' ";
// plate_no += " when 'ChkStandGroup' then '标准不在范围' ";
// plate_no += " when 'ChkTHKTol' then '厚度公差' ";
// plate_no += " when 'ChkFlawCom' then '探伤' ";
// plate_no += " when 'ChkHeatCom' then '热处理' ";
// plate_no += " when 'ChkCutCom' then '切边' ";
// plate_no += " when 'ChkChemCom' then '实际化学成分' ";
// plate_no += " when 'ChkPhyCom' then '物理属性' ";
// plate_no += " when 'ChkSMPLen' then '取样后长度判断' ";
// plate_no += " when 'ChkG1' then 'G1特种钢判断' ";
// plate_no += " when 'ChkWar' then '仓库期限' ";
// plate_no += " when 'LOC' then '仓位' ";
// plate_no += " when 'FBDC' then '分板短尺' ";
// plate_no += " when 'FBTDL' then '分板替代率' ";
// plate_no += " when 'TDL' then '替代率' ";
// plate_no += " when 'null' then '钢板订单不匹配' ";
// plate_no += " when '-NJ' then '余材-NJ标准不替代' ";
// plate_no += " when 'ordernull' then '订单不在余材中' ";
// plate_no += " when 'platenull' then '钢板不在余材中' ";
// plate_no += " else type end type ";
// plate_no += " from TB_BATCH_TEST ";
// plate_no += " where status='0' and PLATE_NO in ('";
// //string ord_no = " select ORD_NO,ORD_ITEM,ORD_KND from NISCO.BP_ORDER_ITEM where 1=1 ";
// if (dtCheck.Rows.Count > 0)
// {
// int n = 0;
// foreach (DataRow row in dtCheck.Rows)
// {
// if (n == 0)
// {
// plate_no += row["PLATE_NO"].ToString();
// }
// else
// {
// plate_no += "','" + row["PLATE_NO"].ToString();
// }
// //多条1000会报错 截取城 多列sql 查询
// if (n > 900)
// {
// n = n - 900;
// plate_no += "') or PLATE_NO in ('" + row["PLATE_NO"].ToString();
// }
// //ord_no += " or ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'";
// n++;
// }
// plate_no += "')";
// using (IDbContext db_sur = ObjectContainer.GetObject<IDbContext>("db"))
// {
// dtPlate = db_sur.Query(plate_no.ToString());
// //dtOrd = db_sur.Query(ord_no.ToString());
// }
// if (dtPlate.Rows.Count > 0)
// {
// foreach (DataRow row in dtCheck.Rows)
// {
// DataRow[] rw = dtPlate.Select(" PLATE_NO='" + row["PLATE_NO"].ToString() + "'");
// if (rw.Length > 0)
// {
// string TYPE = rw[0]["TYPE"].ToString();
// row["TYPE"] = TYPE;
// }
// if (rw.Length > 0)
// {
// string REASON = rw[0]["REASON"].ToString();
// row["REASON"] = REASON;
// }
// }
// }
// result.data = dtCheck;
// result.msg = "操作成功!";
// result.code = "1";
// }
// else
// {
// result.msg = "未找到查询所需数据!";
// result.code = "1";
// }
// }
// }
// catch (Exception ex)
// {
// result.msg = "数据库错误!";
// result.code = "0";
// logger.Error("GetSupersede 报错", ex);
// }
// return result;
//}
[HttpPost, Route("GetCP_REP_HIS")]
//查询替代块数
public RequestEntity GetCP_REP_HIS(CP_REP_HISQueryArgs queryArgs)
{
int querynum = 0;
foreach (PropertyInfo info in queryArgs.GetType().GetProperties())
{
object ob = queryArgs.GetType().GetProperty(info.Name).GetValue(queryArgs, null);
if (ob != null)
{
if (!string.IsNullOrWhiteSpace(ob.ToString()))
querynum++;
}
}
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
DataTable dtPlate = new DataTable();
string PLATE_NO = string.Empty;
string starttime = string.Empty;
string endtime = string.Empty;
string ORD_KND = string.Empty;
//strSql.AppendLine("SELECT distinct boi.ORD_KND,CP.MAT_NO PLATE_NO,CP.UPD_AFT_ORD ORD_NO,CP.UPD_AFT_ORD_ITEM ORD_ITEM,GP.PLT,GP.CUR_INV,pr.REPLACE_TYPE,to_char( to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi') INS_DATE FROM NISCO.CP_REP_HIS cp ");
//strSql.AppendLine(" INNER JOIN NISCO.BP_ORDER_ITEM boi ON BOI.ORD_NO = cp.UPD_AFT_ORD AND BOI.ORD_ITEM = cp.UPD_AFT_ORD_ITEM");
//strSql.AppendLine(" INNER JOIN NISCO.GP_PLATE GP ON GP.PLATE_NO = cp.MAT_NO ");
//strSql.AppendLine(" INNER JOIN NISCO.PLATE_REPLACE pr ON GP.PLATE_NO = pr.PLATE_NO ");
//strSql.AppendLine(" where 1=1 AND cp.REP_TYP='2' AND cp.PROD_CD='PP' and cp.INS_EMP not in('BKD','DI') AND pr.REPLACE_TYPE IN (2,3) ");
if (queryArgs != null)
{
//if (!string.IsNullOrWhiteSpace(queryArgs.ORD_KND)) strSql.AppendLine(" AND boi.ORD_KND = '" + queryArgs.ORD_KND + "'");
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_KND)) ORD_KND = queryArgs.ORD_KND;
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) PLATE_NO = queryArgs.PLATE_NO;
////订单号
//if (!string.IsNullOrWhiteSpace(queryArgs.ORD_NO)) strSql.AppendLine(" AND CP.UPD_AFT_ORD LIKE '%" + queryArgs.ORD_NO + "%'");
////订单序列号
//if (!string.IsNullOrWhiteSpace(queryArgs.ORD_ITEM)) strSql.AppendLine(" AND CP.UPD_AFT_ORD_ITEM LIKE '%" + queryArgs.ORD_ITEM + "%'");
////仓库
//if (!string.IsNullOrWhiteSpace(queryArgs.CUR_INV)) strSql.AppendLine(" AND GP.CUR_INV LIKE '%" + queryArgs.CUR_INV + "%'");
////工厂
//if (!string.IsNullOrWhiteSpace(queryArgs.PLT)) strSql.AppendLine(" AND GP.PLT LIKE '%" + 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(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
//if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
// strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.START_TIME)) && CommonUtils.ObjectToStr(queryArgs.START_TIME) != "0001/1/1 0:00:00")
{
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
starttime = queryArgs.START_TIME.ToString("yyyyMMdd");
}
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
{
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
endtime = queryArgs.END_TIME.ToString("yyyyMMdd");
}
if (queryArgs.START_TIME == DateTime.MinValue && queryArgs.END_TIME == DateTime.MinValue)
{
queryArgs.START_TIME = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
queryArgs.END_TIME = DateTime.Now;
starttime = DateTime.Now.ToString("yyyyMMdd");
endtime = DateTime.Now.AddDays(1).ToString("yyyymmdd");
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
strSql.AppendLine("Order By to_date(INS_DATE ,'yyyy-mm-dd hh24:mi:ss') DESC ");
//dtCheck = db.Query(strSql.ToString());
dtCheck = SerSurMatSubService.GetMES(PLATE_NO, starttime, endtime, ORD_KND);
dtCheck.Columns.Add("TYPE");
dtCheck.Columns.Add("REASON");
dtCheck.Columns.Add("PER");
//DataTable dt = SerSurMatSubService.GetMES(PLATE_NO, starttime, endtime, ORD_KND);
//result.data = db.Query(strSql.ToString());
string plate_no = " select distinct PLATE_NO ,ORD_NO,ORD_ITEM ,REASON,case TYPE when 'OK' then '可以成功' when 'gUnS_SUPERSEDE_HISTORY' then '历史失败' ";
plate_no += " when 'gltTBPlateSpe' then '不可替代钢板'";
plate_no += " when 'gltGpPlateReplace' then '锁定钢板' ";
plate_no += " when 'gltGP_ZZP_YJ' then '保留钢板' ";
plate_no += " when 'CK' then 'ZB/WG 不可替代仓库' ";
plate_no += " when 'ACC' then '改判原因是卷轧头尾的不替代' ";
plate_no += " when 'ChkStandGroup' then '标准不在范围' ";
plate_no += " when 'ChkTHKTol' then '厚度公差' ";
plate_no += " when 'ChkFlawCom' then '探伤' ";
plate_no += " when 'ChkHeatCom' then '热处理' ";
plate_no += " when 'ChkCutCom' then '切边' ";
plate_no += " when 'ChkChemCom' then '实际化学成分' ";
plate_no += " when 'ChkPhyCom' then '物理属性' ";
plate_no += " when 'ChkSMPLen' then '取样后长度判断' ";
plate_no += " when 'ChkG1' then 'G1特种钢判断' ";
plate_no += " when 'ChkWar' then '仓库期限' ";
plate_no += " when 'LOC' then '仓位' ";
plate_no += " when 'FBDC' then '分板短尺' ";
plate_no += " when 'FBTDL' then '分板替代率' ";
plate_no += " when 'TDL' then '替代率' ";
plate_no += " when 'null' then '钢板订单不匹配' ";
plate_no += " when '-NJ' then '余材-NJ标准不替代' ";
plate_no += " when 'ordernull' then '订单不在余材中' ";
plate_no += " when 'platenull' then '钢板不在余材中' ";
plate_no += " else type end type ";
plate_no += " from TB_BATCH_TEST ";
plate_no += " where status='0' and PLATE_NO in ('";
//string ord_no = " select ORD_NO,ORD_ITEM,ORD_KND from NISCO.BP_ORDER_ITEM where 1=1 ";
if (dtCheck.Rows.Count > 0)
{
int n = 0;
foreach (DataRow row in dtCheck.Rows)
{
if (n == 0)
{
plate_no += row["PLATE_NO"].ToString();
}
else
{
plate_no += "','" + row["PLATE_NO"].ToString();
}
//多条1000会报错 截取城 多列sql 查询
if (n > 900)
{
n = n - 900;
plate_no += "') or PLATE_NO in ('" + row["PLATE_NO"].ToString();
}
//string per= Math.Round((Convert.ToDecimal(row["WGT_H"].ToString())/ Convert.ToDecimal(row["WGT_H"].ToString()) * 100), 2).ToString();
//ord_no += " or ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'";
n++;
}
plate_no += "')";
using (IDbContext db_sur = ObjectContainer.GetObject<IDbContext>("db"))
{
dtPlate = db_sur.Query(plate_no.ToString());
//dtOrd = db_sur.Query(ord_no.ToString());
}
if (dtPlate.Rows.Count > 0)
{
foreach (DataRow row in dtCheck.Rows)
{
string per = Math.Round((Convert.ToDecimal(row["WGT_H"].ToString()) / Convert.ToDecimal(row["WGT_Q"].ToString()) * 100), 2).ToString();
row["PER"] = per;
DataRow[] rw = dtPlate.Select(" PLATE_NO='" + row["PLATE_NO"].ToString() + "'");
if (rw.Length > 0)
{
string TYPE = rw[0]["TYPE"].ToString();
string REASON = rw[0]["REASON"].ToString();
row["REASON"] = REASON;
row["TYPE"] = TYPE;
}
//if (rw.Length > 0)
//{
// string REASON = rw[0]["REASON"].ToString();
//}
}
}
result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.data = new DataTable();
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSupersede 报错", ex);
}
return result;
}
[HttpPost, Route("GetREP_HIS")]
//查询替代块数
public RequestEntity GetREP_HIS(CP_REP_HISQueryArgs queryArgs)
{
int querynum = 0;
foreach (PropertyInfo info in queryArgs.GetType().GetProperties())
{
object ob = queryArgs.GetType().GetProperty(info.Name).GetValue(queryArgs, null);
if (ob != null)
{
if (!string.IsNullOrWhiteSpace(ob.ToString()))
querynum++;
}
}
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
DataTable dtPlate = new DataTable();
string PLATE_NO = string.Empty;
string starttime = string.Empty;
string endtime = string.Empty;
string ORD_KND = string.Empty;
if (queryArgs != null)
{
if (!string.IsNullOrWhiteSpace(queryArgs.ORD_KND)) ORD_KND = queryArgs.ORD_KND;
//钢板号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO)) PLATE_NO = queryArgs.PLATE_NO;
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.START_TIME)) && CommonUtils.ObjectToStr(queryArgs.START_TIME) != "0001/1/1 0:00:00")
{
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME) + "','yyyy-mm-dd hh24:mi:ss')");
starttime = queryArgs.START_TIME.ToString("yyyyMMdd");
}
if (!string.IsNullOrWhiteSpace(CommonUtils.ObjectToStr(queryArgs.END_TIME)) && CommonUtils.ObjectToStr(queryArgs.END_TIME) != "0001/1/1 0:00:00")
{
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
endtime = queryArgs.END_TIME.ToString("yyyyMMdd");
}
if (queryArgs.START_TIME == DateTime.MinValue && queryArgs.END_TIME == DateTime.MinValue)
{
queryArgs.START_TIME = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
queryArgs.END_TIME = DateTime.Now;
starttime = DateTime.Now.ToString("yyyyMMdd");
endtime = DateTime.Now.AddDays(1).ToString("yyyymmdd");
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') >= to_date('" + CommonUtils.ObjectToStr(queryArgs.START_TIME.ToString("yyyy-MM-dd")) + "','yyyy-mm-dd hh24:mi:ss')");
strSql.AppendLine(" AND to_date(cp.INS_DATE ,'yyyy-mm-dd hh24:mi:ss') < to_date('" + CommonUtils.ObjectToStr(queryArgs.END_TIME.AddDays(1)) + "','yyyy-mm-dd hh24:mi:ss')");
}
}
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
strSql.AppendLine("Order By to_date(INS_DATE ,'yyyy-mm-dd hh24:mi:ss') DESC ");
//dtCheck = db.Query(strSql.ToString());
//dtCheck = SerSurMatSubService.GetREP_HIS(PLATE_NO, starttime, endtime, ORD_KND);
//dtCheck.Columns.Add("TYPE");
//dtCheck.Columns.Add("REASON");
//dtCheck.Columns.Add("PER");
DataTable dt = SerSurMatSubService.GetREP_HIS(PLATE_NO, starttime, endtime, ORD_KND);
DataRow[] rows = dt.Select(" TYPE not in ('转单')");
if (rows.Length > 0)
{
dt = rows.CopyToDataTable();
}
////result.data = db.Query(strSql.ToString());
//string plate_no = " select distinct PLATE_NO ,ORD_NO,ORD_ITEM ,REASON,case TYPE when 'OK' then '可以成功' when 'gUnS_SUPERSEDE_HISTORY' then '历史失败' ";
//plate_no += " when 'gltTBPlateSpe' then '不可替代钢板'";
//plate_no += " when 'gltGpPlateReplace' then '锁定钢板' ";
//plate_no += " when 'gltGP_ZZP_YJ' then '保留钢板' ";
//plate_no += " when 'CK' then 'ZB/WG 不可替代仓库' ";
//plate_no += " when 'ACC' then '改判原因是卷轧头尾的不替代' ";
//plate_no += " when 'ChkStandGroup' then '标准不在范围' ";
//plate_no += " when 'ChkTHKTol' then '厚度公差' ";
//plate_no += " when 'ChkFlawCom' then '探伤' ";
//plate_no += " when 'ChkHeatCom' then '热处理' ";
//plate_no += " when 'ChkCutCom' then '切边' ";
//plate_no += " when 'ChkChemCom' then '实际化学成分' ";
//plate_no += " when 'ChkPhyCom' then '物理属性' ";
//plate_no += " when 'ChkSMPLen' then '取样后长度判断' ";
//plate_no += " when 'ChkG1' then 'G1特种钢判断' ";
//plate_no += " when 'ChkWar' then '仓库期限' ";
//plate_no += " when 'LOC' then '仓位' ";
//plate_no += " when 'FBDC' then '分板短尺' ";
//plate_no += " when 'FBTDL' then '分板替代率' ";
//plate_no += " when 'TDL' then '替代率' ";
//plate_no += " when 'null' then '钢板订单不匹配' ";
//plate_no += " when '-NJ' then '余材-NJ标准不替代' ";
//plate_no += " when 'ordernull' then '订单不在余材中' ";
//plate_no += " when 'platenull' then '钢板不在余材中' ";
//plate_no += " else type end type ";
//plate_no += " from TB_BATCH_TEST ";
//plate_no += " where status='0' and PLATE_NO in ('";
//string ord_no = " select ORD_NO,ORD_ITEM,ORD_KND from NISCO.BP_ORDER_ITEM where 1=1 ";
if (dt.Rows.Count > 0)
{
int n = 0;
//foreach (DataRow row in dtCheck.Rows)
//{
// if (n == 0)
// {
// plate_no += row["PLATE_NO"].ToString();
// }
// else
// {
// plate_no += "','" + row["PLATE_NO"].ToString();
// }
// //多条1000会报错 截取城 多列sql 查询
// if (n > 900)
// {
// n = n - 900;
// plate_no += "') or PLATE_NO in ('" + row["PLATE_NO"].ToString();
// }
// //string per= Math.Round((Convert.ToDecimal(row["WGT_H"].ToString())/ Convert.ToDecimal(row["WGT_H"].ToString()) * 100), 2).ToString();
// //ord_no += " or ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'";
// n++;
//}
//plate_no += "')";
//using (IDbContext db_sur = ObjectContainer.GetObject<IDbContext>("db"))
//{
// dtPlate = db_sur.Query(plate_no.ToString());
// //dtOrd = db_sur.Query(ord_no.ToString());
//}
//if (dtPlate.Rows.Count > 0)
//{
// foreach (DataRow row in dtCheck.Rows)
// {
// string per = Math.Round((Convert.ToDecimal(row["WGT_H"].ToString()) / Convert.ToDecimal(row["WGT_Q"].ToString()) * 100), 2).ToString();
// row["PER"] = per;
// DataRow[] rw = dtPlate.Select(" PLATE_NO='" + row["PLATE_NO"].ToString() + "'");
// if (rw.Length > 0)
// {
// string TYPE = rw[0]["TYPE"].ToString();
// string REASON = rw[0]["REASON"].ToString();
// row["REASON"] = REASON;
// row["TYPE"] = TYPE;
// }
// //if (rw.Length > 0)
// //{
// // string REASON = rw[0]["REASON"].ToString();
// //}
// }
//}
result.data = dt;
//result.data = dtCheck;
result.msg = "操作成功!";
result.code = "1";
}
else
{
result.data = new DataTable();
result.msg = "未找到查询所需数据!";
result.code = "1";
}
}
}
catch (Exception ex)
{
result.msg = "数据库错误!";
result.code = "0";
logger.Error("GetSupersede 报错", ex);
}
return result;
}
///// <summary>
///// 获取钢板物理特性
///// </summary>
///// <returns></returns>
//public static IList<QP_TEST_RSLT> GetQP_TEST_RSLT()
//{
// IList<QP_TEST_RSLT> reListQP_TEST_RSLT = new List<QP_TEST_RSLT>();
// try
// {
// //开启数据库连接查询数据
// using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
// {
// reListQP_TEST_RSLT = SerSurMatSubService.GetQP_TEST_RSLT();
// }
// }
// catch (Exception ex)
// {
// logger.Error("GetQP_QLTY_MATR 报错 : ", ex);
// }
// return reListQP_TEST_RSLT;
//}
/// <summary>
/// 根据订单号找到对应的订单要求化学成分
/// </summary>
/// <returns>对应的化学成分集合</returns>
public static IList<QP_QLTY_CHEM> GetOrderChemistry(string strWHereOrd)
{
//订单化学成分
IList<QP_QLTY_CHEM> reListQP_QLTY_CHEM = new List<QP_QLTY_CHEM>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
//获取订单化学成分
reListQP_QLTY_CHEM = SerSurMatSubService.GetOrderChemistry(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetStandGroup 报错 : ", ex);
}
return reListQP_QLTY_CHEM;
}
#region 订单物理特性
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HA
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HA> GetQP_QLTY_MATR_HA(string strWHereOrd)
{
IList<QP_QLTY_MATR_HA> reListQP_QLTY_MATR_HA = new List<QP_QLTY_MATR_HA>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HA = SerSurMatSubService.GetQP_QLTY_MATR_HA(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HA 报错 : ", ex);
}
return reListQP_QLTY_MATR_HA;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HB
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HB> GetQP_QLTY_MATR_HB(string strWHereOrd)
{
IList<QP_QLTY_MATR_HB> reListQP_QLTY_MATR_HB = new List<QP_QLTY_MATR_HB>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HB = SerSurMatSubService.GetQP_QLTY_MATR_HB(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HB 报错 : ", ex);
}
return reListQP_QLTY_MATR_HB;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HC
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HC> GetQP_QLTY_MATR_HC(string strWHereOrd)
{
IList<QP_QLTY_MATR_HC> reListQP_QLTY_MATR_HC = new List<QP_QLTY_MATR_HC>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HC = SerSurMatSubService.GetQP_QLTY_MATR_HC(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HC 报错 : ", ex);
}
return reListQP_QLTY_MATR_HC;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HD
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HD> GetQP_QLTY_MATR_HD(string strWHereOrd)
{
IList<QP_QLTY_MATR_HD> reListQP_QLTY_MATR_HD = new List<QP_QLTY_MATR_HD>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HD = SerSurMatSubService.GetQP_QLTY_MATR_HD(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HD 报错 : ", ex);
}
return reListQP_QLTY_MATR_HD;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HE
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HE> GetQP_QLTY_MATR_HE(string strWHereOrd)
{
IList<QP_QLTY_MATR_HE> reListQP_QLTY_MATR_HE = new List<QP_QLTY_MATR_HE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HE = SerSurMatSubService.GetQP_QLTY_MATR_HE(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HE 报错 : ", ex);
}
return reListQP_QLTY_MATR_HE;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HF
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HF> GetQP_QLTY_MATR_HF(string strWHereOrd)
{
IList<QP_QLTY_MATR_HF> reListQP_QLTY_MATR_HF = new List<QP_QLTY_MATR_HF>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HF = SerSurMatSubService.GetQP_QLTY_MATR_HF(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HF 报错 : ", ex);
}
return reListQP_QLTY_MATR_HF;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HJ
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HJ> GetQP_QLTY_MATR_HJ(string strWHereOrd)
{
IList<QP_QLTY_MATR_HJ> reListQP_QLTY_MATR_HJ = new List<QP_QLTY_MATR_HJ>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HJ = SerSurMatSubService.GetQP_QLTY_MATR_HJ(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HJ 报错 : ", ex);
}
return reListQP_QLTY_MATR_HJ;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HK
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HK> GetQP_QLTY_MATR_HK(string strWHereOrd)
{
IList<QP_QLTY_MATR_HK> reListQP_QLTY_MATR_HK = new List<QP_QLTY_MATR_HK>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HK = SerSurMatSubService.GetQP_QLTY_MATR_HK(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HK 报错 : ", ex);
}
return reListQP_QLTY_MATR_HK;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HM
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HM> GetQP_QLTY_MATR_HM(string strWHereOrd)
{
IList<QP_QLTY_MATR_HM> reListQP_QLTY_MATR_HM = new List<QP_QLTY_MATR_HM>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HM = SerSurMatSubService.GetQP_QLTY_MATR_HM(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HM 报错 : ", ex);
}
return reListQP_QLTY_MATR_HM;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HN
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HN> GetQP_QLTY_MATR_HN(string strWHereOrd)
{
IList<QP_QLTY_MATR_HN> reListQP_QLTY_MATR_HN = new List<QP_QLTY_MATR_HN>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HN = SerSurMatSubService.GetQP_QLTY_MATR_HN(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HN 报错 : ", ex);
}
return reListQP_QLTY_MATR_HN;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HR
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HR> GetQP_QLTY_MATR_HR(string strWHereOrd)
{
IList<QP_QLTY_MATR_HR> reListQP_QLTY_MATR_HR = new List<QP_QLTY_MATR_HR>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HR = SerSurMatSubService.GetQP_QLTY_MATR_HR(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HR 报错 : ", ex);
}
return reListQP_QLTY_MATR_HR;
}
/// <summary>
/// 获取订单物理属性QP_QLTY_MATR_HZ
/// </summary>
/// <returns></returns>
public static IList<QP_QLTY_MATR_HZ> GetQP_QLTY_MATR_HZ(string strWHereOrd)
{
IList<QP_QLTY_MATR_HZ> reListQP_QLTY_MATR_HZ = new List<QP_QLTY_MATR_HZ>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_QLTY_MATR_HZ = SerSurMatSubService.GetQP_QLTY_MATR_HZ(strWHereOrd);
}
}
catch (Exception ex)
{
logger.Error("GetQP_QLTY_MATR_HZ 报错 : ", ex);
}
return reListQP_QLTY_MATR_HZ;
}
#endregion
#region 钢板物理特性
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HA
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HA> GetQP_TEST_RSLT_HA(string strWHerePlate)
{
IList<QP_TEST_RSLT_HA> reListQP_TEST_RSLT_HA = new List<QP_TEST_RSLT_HA>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HA = SerSurMatSubService.GetQP_TEST_RSLT_HA(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HA 报错 : ", ex);
}
return reListQP_TEST_RSLT_HA;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HB
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HB> GetQP_TEST_RSLT_HB(string strWHerePlate)
{
IList<QP_TEST_RSLT_HB> reListQP_TEST_RSLT_HB = new List<QP_TEST_RSLT_HB>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HB = SerSurMatSubService.GetQP_TEST_RSLT_HB(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HB 报错 : ", ex);
}
return reListQP_TEST_RSLT_HB;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HC
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HC> GetQP_TEST_RSLT_HC(string strWHerePlate)
{
IList<QP_TEST_RSLT_HC> reListQP_TEST_RSLT_HC = new List<QP_TEST_RSLT_HC>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HC = SerSurMatSubService.GetQP_TEST_RSLT_HC(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HC 报错 : ", ex);
}
return reListQP_TEST_RSLT_HC;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HD
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HD> GetQP_TEST_RSLT_HD(string strWHerePlate)
{
IList<QP_TEST_RSLT_HD> reListQP_TEST_RSLT_HD = new List<QP_TEST_RSLT_HD>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HD = SerSurMatSubService.GetQP_TEST_RSLT_HD(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HD 报错 : ", ex);
}
return reListQP_TEST_RSLT_HD;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HE
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HE> GetQP_TEST_RSLT_HE(string strWHerePlate)
{
IList<QP_TEST_RSLT_HE> reListQP_TEST_RSLT_HE = new List<QP_TEST_RSLT_HE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HE = SerSurMatSubService.GetQP_TEST_RSLT_HE(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HE 报错 : ", ex);
}
return reListQP_TEST_RSLT_HE;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HF
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HF> GetQP_TEST_RSLT_HF(string strWHerePlate)
{
IList<QP_TEST_RSLT_HF> reListQP_TEST_RSLT_HF = new List<QP_TEST_RSLT_HF>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HF = SerSurMatSubService.GetQP_TEST_RSLT_HF(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HF 报错 : ", ex);
}
return reListQP_TEST_RSLT_HF;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HJ
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HJ> GetQP_TEST_RSLT_HJ(string strWHerePlate)
{
IList<QP_TEST_RSLT_HJ> reListQP_TEST_RSLT_HJ = new List<QP_TEST_RSLT_HJ>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HJ = SerSurMatSubService.GetQP_TEST_RSLT_HJ(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HJ 报错 : ", ex);
}
return reListQP_TEST_RSLT_HJ;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HK
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HK> GetQP_TEST_RSLT_HK(string strWHerePlate)
{
IList<QP_TEST_RSLT_HK> reListQP_TEST_RSLT_HK = new List<QP_TEST_RSLT_HK>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HK = SerSurMatSubService.GetQP_TEST_RSLT_HK(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HK 报错 : ", ex);
}
return reListQP_TEST_RSLT_HK;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HM
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HM> GetQP_TEST_RSLT_HM(string strWHerePlate)
{
IList<QP_TEST_RSLT_HM> reListQP_TEST_RSLT_HM = new List<QP_TEST_RSLT_HM>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HM = SerSurMatSubService.GetQP_TEST_RSLT_HM(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HM 报错 : ", ex);
}
return reListQP_TEST_RSLT_HM;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HN
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HN> GetQP_TEST_RSLT_HN(string strWHerePlate)
{
IList<QP_TEST_RSLT_HN> reListQP_TEST_RSLT_HN = new List<QP_TEST_RSLT_HN>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HN = SerSurMatSubService.GetQP_TEST_RSLT_HN(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HN 报错 : ", ex);
}
return reListQP_TEST_RSLT_HN;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HR
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HR> GetQP_TEST_RSLT_HR(string strWHerePlate)
{
IList<QP_TEST_RSLT_HR> reListQP_TEST_RSLT_HR = new List<QP_TEST_RSLT_HR>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HR = SerSurMatSubService.GetQP_TEST_RSLT_HR(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HR 报错 : ", ex);
}
return reListQP_TEST_RSLT_HR;
}
/// <summary>
/// 获取钢板物理属性QP_TEST_RSLT_HZ
/// </summary>
/// <returns></returns>
public static IList<QP_TEST_RSLT_HZ> GetQP_TEST_RSLT_HZ(string strWHerePlate)
{
IList<QP_TEST_RSLT_HZ> reListQP_TEST_RSLT_HZ = new List<QP_TEST_RSLT_HZ>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListQP_TEST_RSLT_HZ = SerSurMatSubService.GetQP_TEST_RSLT_HZ(strWHerePlate);
}
}
catch (Exception ex)
{
logger.Error("GetQP_TEST_RSLT_HZ 报错 : ", ex);
}
return reListQP_TEST_RSLT_HZ;
}
#endregion
#endregion
#region 检测数据
/// <summary>
/// 化学成分对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkChemCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorde)
{
//gQP_CHEM_RSLT
//gQP_QLTY_CHEM
//获取订单的化学成分
List<QP_QLTY_CHEM> ltQPQltyChem = gQP_QLTY_CHEM.Where(p => p.ORD_NO == prorde.ORD_NO && p.ORD_ITEM == prorde.ORD_ITEM).ToList();
//获取炉号
string strHeatNo = gFP_SLAB.Where(p => p.SLAB_NO == prP_PLATE.SLAB_NO).ToList().Count > 0 ? gFP_SLAB.Where(p => p.SLAB_NO == prP_PLATE.SLAB_NO).ToList().First<FP_SLAB>().HEAT_NO : "";
//获取钢板炉号的化学成分
List<QP_CHEM_RSLT> ltQPChemRslt = gQP_CHEM_RSLT.Where(p => p.HEAT_NO == strHeatNo).ToList();
if (ltQPChemRslt.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/化学成分";
}
if (ltQPQltyChem.Count > 0)
{
foreach (QP_QLTY_CHEM itemQP_QLTY_CHEM in ltQPQltyChem)
{
try
{
//筛选每个元素的量,是否满足订单
List<QP_CHEM_RSLT> ltCheck = ltQPChemRslt.Where
(p => Convert.ToDecimal(itemQP_QLTY_CHEM.CHEM_COMP_MIN) <= Convert.ToDecimal(p.CHEM_RSLT)
&& Convert.ToDecimal(itemQP_QLTY_CHEM.CHEM_COMP_MAX) >= Convert.ToDecimal(p.CHEM_RSLT)
&& itemQP_QLTY_CHEM.CHEM_COMP_CD == p.CHEM_COMP_CD).ToList();
if (ltCheck.Count == 0)
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Chem = "1"; //化学特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
//不满足返回false
return false;
}
}
catch (Exception)
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Chem = "1"; //化学特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
}
//满足条件返回True
return true;
}
/// <summary>
/// 物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorde)
{
//TODO:物理属性
//获取订单的物理特性
//List<QP_QLTY_MATR> ltQPQltyChem = gQP_QLTY_MATR.Where(p => p.ORD_NO == prorde.ORD_NO && p.ORD_ITEM == prorde.ORD_ITEM).ToList();
//获取钢板的物理特性
//List<QP_TEST_RSLT> ltQPChemRslt = gQP_TEST_RSLT.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//foreach (QP_QLTY_MATR itemQP_QLTY_MATR in ltQPQltyChem)
//{
// if (ltQPChemRslt.Where(p => p.YP_RST >= itemQP_QLTY_MATR.YP_MIN
// && p.YP_RST <= itemQP_QLTY_MATR.YP_MAX
// && p.TS_RST >= itemQP_QLTY_MATR.TS_MIN
// && p.TS_RST <= itemQP_QLTY_MATR.TS_MAX).ToList().Count > 0)//YP屈服 TS拉伸
// {
// return true;
// }
//}
if (!ChkPhyHA(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "A"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
//if (!ChkPhyHB(prP_PLATE, prorde))
//{
// COM_DATA CD = new COM_DATA();
// CD.PLATE_NO = prP_PLATE.PLATE_NO;
// CD.ORD_NO = prorde.ORD_NO;
// CD.ORD_ITEM = prorde.ORD_ITEM;
// CD.Phy = "B"; //化学特性
// gCOM_DATA.Add(CD);//全局变量添加对不结果数据
// return false;
//}
if (!ChkPhyHC(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "C"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (!ChkPhyHD(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "D"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (!ChkPhyHE(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "E"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (!ChkPhyHF(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "F"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (!ChkPhyHJ(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "J"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (!ChkPhyHM(prP_PLATE, prorde))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Phy = "M"; //物理特性
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
return true;
}
/// <summary>
/// 标准集合对比
/// </summary>
/// <param name="prP_PLATE">钢板信息</param>
/// <param name="prorde">订单信息</param>
/// <returns></returns>
public static bool ChkStandGroup(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorde)
{
if (prorde.STDSPEC == prP_PLATE.APLY_STDSPEC)
{
return true;
}
//获取订单的钢种标准集合
List<CP_NISCO_CHMC_SL> ltOrdStand =
gCP_NISCO_CHMC_SLs.Where(p => p.STLGRD == prorde.STLGRD
&& ConverDataToDecimal(prorde.ORD_THK) >= ConverDataToDecimal(p.THK_MIN)
&& ConverDataToDecimal(prorde.ORD_THK) <= ConverDataToDecimal(p.THK_MAX)).ToList();
//集合是否为空
if (ltOrdStand.Count == 0)
{
////空的时候直接对比标准号
//if (prorde.STDSPEC == prP_PLATE.APLY_STDSPEC)
//{
// return true;
//}
//else
//{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.STDSPEC = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
//}
}
else
{ //非空的时候看集合收到包含钢板的标准
//查询订单厚度范围内的钢种标准集合
// List<CP_NISCO_CHMC_SL> ltOrdStandGroup = gCP_NISCO_CHMC_SLs.Where(p => p.STLGRD == ltOrdStand[0].STLGRD
//&& Convert.ToDecimal(prorde.ORD_THK) >= Convert.ToDecimal(p.THK_MIN)
//&& Convert.ToDecimal(prorde.ORD_THK) <= Convert.ToDecimal(p.THK_MAX)).ToList();
if (ltOrdStand.Where(p => p.STDSPEC == prP_PLATE.APLY_STDSPEC).ToList().Count > 0)
{
return true;
}
else
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.STDSPEC = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
}
/// <summary>
/// 厚度公差对比
/// </summary>
/// <param name="prP_PLATE">钢板数据</param>
/// <param name="prorde">订单数据</param>
/// <returns></returns>
public static bool ChkTHKTol(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorde)
{
//TODO:厚度公差
if (ConverDataToDecimal(prP_PLATE.THK_TOL_MIN) < ConverDataToDecimal(prorde.THK_TOL_MIN))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Thk = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
if (ConverDataToDecimal(prP_PLATE.THK_TOL_MAX) > ConverDataToDecimal(prorde.THK_TOL_MAX))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.Thk = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
return true;
}
/// <summary>
/// 仓库与订单期限对比
/// </summary>
/// <param name="prP_PLATE">钢板数据</param>
/// <param name="prorde">订单数据</param>
/// <returns></returns>
public static bool ChkWar(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorde)
{
// 完全替代配置:
//WX WJ WN WQ WT LG W7 KH 00 HB ;最早交货期偏移量: -30天 最晚交货期偏移量:180天
//退判替代配置
//00 HB YT 最早交货期偏移量: 7天 最晚交货期偏移量: 180天
//01 WX WJ WN WQ WT LG W7 KH最早交货期偏移量:15天 最晚交货期偏移量: 180天
List<REMA_PLA_SUBSI_WAREH_MANAGE> ltWarDiffDays =
gltWarDiffDays.Where(p => p.SUB_KND == prP_PLATE.SUB_FULL
&& p.WAREH_MANAGE_CLASS.ToString().Contains(prP_PLATE.CUR_INV) //TODO:钢板仓库还没确定。
&& ConverDataToDecimal(prorde.DEL_TO_DATE) >=
ConverDataToDecimal(DateTime.Now.AddDays(Convert.ToDouble(p.BEF_DEL_DIFF)).ToString("yyyyMMdd"))
&& ConverDataToDecimal(prorde.DEL_TO_DATE) <=
ConverDataToDecimal(DateTime.Now.AddDays(Convert.ToDouble(p.AFT_DEL_DIFF)).ToString("yyyyMMdd"))).ToList();
if (ltWarDiffDays.Count == 0)
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorde.ORD_NO;
CD.ORD_ITEM = prorde.ORD_ITEM;
CD.War = "1"; //仓库
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
return true;
}
///// <summary>
///// 探伤结果
///// </summary>
///// <returns>满足True;不满足False</returns>
//public static bool ChkFlawCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
//{
// //探伤标准可高代低
// //钢板探伤信息:是否探伤,探伤结果,探伤次数,超声波探伤代码
// //订单信息:客户要求探伤标准 (varchar(4))
// if (!string.IsNullOrEmpty(prorder.UST_FL))//客户要求探伤标准
// {
// if (prorder.UST_FL=="X")
// {
// return true;
// }
// if (!string.IsNullOrEmpty(prP_PLATE.UST_FL))//钢材结果
// {
// return true;
// }
// else
// {
// if (string.IsNullOrEmpty(prP_PLATE.UST_STATUS))
// {
// prP_PLATE.SUB_FULL = "P";
// prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/探伤";
// return true;
// }
// else
// {
// COM_DATA CD = new COM_DATA();
// CD.PLATE_NO = prP_PLATE.PLATE_NO;
// CD.ORD_NO = prorder.ORD_NO;
// CD.ORD_ITEM = prorder.ORD_ITEM;
// CD.Flaw = "1"; //添加探伤要求
// gCOM_DATA.Add(CD);//全局变量添加对不结果数据
// return false;
// }
// }
// }
// return true;
//}
/// <summary>
/// 探伤结果
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkFlawCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//探伤标准可高代低
//钢板探伤信息:是否探伤,探伤结果,探伤次数,超声波探伤代码
//订单信息:客户要求探伤标准 (varchar(4))
if (!string.IsNullOrEmpty(prorder.UST_FL))//客户要求探伤标准
{
if (ConverDataToString(prorder.UST_FL) == "X")
{
return true;
}
if (!string.IsNullOrEmpty(prP_PLATE.UST_FL))//钢材结果
{
if (ConverDataToString(prorder.UST_FL) == ConverDataToString(prP_PLATE.UST_FL))
{
return true;
}
else
{
if (ConverDataToString(prorder.UST_FL).Length == 4 && ConverDataToString(prP_PLATE.UST_FL).Length == 4)
{
if (ConverDataToString(prorder.UST_FL).Substring(0, 2) == "AA" || ConverDataToString(prorder.UST_FL).Substring(0, 2) == "NN")
{
if (ConverDataToString(prP_PLATE.UST_FL).Substring(0, 2) == "AA" || ConverDataToString(prP_PLATE.UST_FL).Substring(0, 2) == "NN")
{
if (CheckNUM(ConverDataToString(prorder.UST_FL).Substring(2, 1))
&& CheckNUM(ConverDataToString(prorder.UST_FL).Substring(3, 1))
&& CheckNUM(ConverDataToString(prP_PLATE.UST_FL).Substring(2, 1))
&& CheckNUM(ConverDataToString(prP_PLATE.UST_FL).Substring(3, 1)))
{
if (ConverDataToDecimal(ConverDataToString(prorder.UST_FL).Substring(2, 1))
>= ConverDataToDecimal(ConverDataToString(prP_PLATE.UST_FL).Substring(2, 1))
|| ConverDataToDecimal(ConverDataToString(prorder.UST_FL).Substring(3, 1))
>= ConverDataToDecimal(ConverDataToString(prP_PLATE.UST_FL).Substring(3, 1)))
{
return true;
}
else
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Flaw = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
}
}
else
{
if (ConverDataToString(prP_PLATE.UST_FL).Substring(0, 2) == ConverDataToString(prP_PLATE.UST_FL).Substring(0, 2))
{
if (CheckNUM(ConverDataToString(prorder.UST_FL).Substring(2, 1))
&& CheckNUM(ConverDataToString(prorder.UST_FL).Substring(3, 1))
&& CheckNUM(ConverDataToString(prP_PLATE.UST_FL).Substring(2, 1))
&& CheckNUM(ConverDataToString(prP_PLATE.UST_FL).Substring(3, 1)))
{
if (ConverDataToDecimal(ConverDataToString(prorder.UST_FL).Substring(2, 1))
>= ConverDataToDecimal(ConverDataToString(prP_PLATE.UST_FL).Substring(2, 1))
|| ConverDataToDecimal(ConverDataToString(prorder.UST_FL).Substring(3, 1))
>= ConverDataToDecimal(ConverDataToString(prP_PLATE.UST_FL).Substring(3, 1)))
{
return true;
}
else
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Flaw = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
}
else
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Flaw = "1"; //标准替代没有信息
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
}
}
}
else
{
if (string.IsNullOrEmpty(prP_PLATE.UST_FL) || ConverDataToString(prP_PLATE.UST_FL) == "X")
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/探伤";
return true;
}
}
}
return true;
}
public static bool CheckNUM(string str)
{
if (str == string.Empty || str == null)
return false;
try
{
decimal.Parse(str);
}
catch
{
return false;
}
return true;
}
/// <summary>
/// 热处理结果
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkHeatCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//热处理结果 = 热处理要求
//钢板信息:热处理方法和热处理代码
//订单信息:热处理方法 1 2 3
if (!string.IsNullOrEmpty(prorder.HTM_METH1)) //订单热处理方法
{
if (!string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH1))//订单处理方法和结果数据是一样的
{
if (string.IsNullOrEmpty(prorder.HTM_METH1) != string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH1))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Heat = string.Format("order.HTM_METH1={0};P_PLATE.HTM_RLT_METH1={1}", string.IsNullOrEmpty(prorder.HTM_METH1), string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH1)); //添加探伤要求
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
else
{
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/热处理1";
prP_PLATE.SUB_FULL = "P";
}
}
if (!string.IsNullOrEmpty(prorder.HTM_METH2)) //订单热处理方法
{
if (!string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH2))//订单处理方法和结果数据是一样的
{
if (string.IsNullOrEmpty(prorder.HTM_METH2) != string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH2))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Heat = string.Format("order.HTM_METH2={0};P_PLATE.HTM_RLT_METH2={1}", string.IsNullOrEmpty(prorder.HTM_METH2), string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH2)); //添加探伤要求
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
else
{
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/热处理2";
prP_PLATE.SUB_FULL = "P";
}
}
if (!string.IsNullOrEmpty(prorder.HTM_METH3)) //订单热处理方法
{
if (!string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH3))//订单处理方法和结果数据是一样的
{
if (string.IsNullOrEmpty(prorder.HTM_METH3) != string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH3))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Heat = string.Format("order.HTM_METH3={0};P_PLATE.HTM_RLT_METH3={1}", string.IsNullOrEmpty(prorder.HTM_METH3), string.IsNullOrEmpty(prP_PLATE.HTM_RLT_METH3)); //添加探伤要求
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
else
{
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/热处理3";
prP_PLATE.SUB_FULL = "P";
}
}
return true;
}
/// <summary>
/// 喷涂结果
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPlatCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//订单信息:喷涂标记 SPRAY_FL
return true;
}
/// <summary>
/// 打包结果
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPackCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//订单信息:包装方式 PACK_WAY
return true;
}
/// <summary>
/// 用途
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkUseCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//订单信息:订单用途 ENDUSE_CD
//钢板信息:订单用途 ENDUSE_CD
return true;
}
/// <summary>
/// 切边
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkCutCom(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//订单信息:切边代码 TRIM_FL
//钢板信息:
if (!string.IsNullOrEmpty(prorder.TRIM_FL))//订单需要切边
{
if (!string.IsNullOrEmpty(prP_PLATE.TRIM_FL))
{
if (prorder.TRIM_FL == prP_PLATE.TRIM_FL)//订单切边与钢板切边相等
{
return true;
}
else
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Cut = "1"; //添加切边要求
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
}
else
{
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/切边";
prP_PLATE.SUB_FULL = "P";
return true;
}
}
return true;
}
/// <summary>
/// 切割处理Check 切割结果,计算切割位置)
/// </summary>
/// <param name="prP_PLATE">钢板信息</param>
/// <param name="prorder">订单信息</param>
/// <returns></returns>
public static bool ChkCalCut(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//订单信息:
//钢板信息:
//使用率小于85%返回false
if (((Convert.ToDecimal(prorder.ORD_WID) * Convert.ToDecimal(prorder.ORD_LEN))
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN)))
< Convert.ToDecimal(0.85))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Rate = "1"; //切割百分率
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
prP_PLATE.SUB_CUT_POS_1 = prorder.ORD_LEN;//切割位置1=订单的长度
prP_PLATE.SUB_CUT_POS_2 = prorder.ORD_WID;//切割位置2=订单宽度
prP_PLATE.SUB_SUR_LEN_1 = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prorder.ORD_LEN));
prP_PLATE.SUB_SUR_WID_1 = Convert.ToString(prP_PLATE.WID);
prP_PLATE.SUB_SUR_STA_1 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_SUR_LEN_2 = Convert.ToString(prorder.ORD_LEN);
prP_PLATE.SUB_SUR_WID_2 = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prorder.ORD_WID));
prP_PLATE.SUB_SUR_STA_2 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_DATE = DateTime.Now.ToString();//替代时间
prP_PLATE.SUB_NUM = "1"; //替代块数*先都算作一块
prP_PLATE.SUB_DIR = "H"; //排列方向
prP_PLATE.SUB_US_WID = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prorder.ORD_WID));//剩余宽度
prP_PLATE.SUB_US_LEN = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prorder.ORD_LEN));//剩余长度
prP_PLATE.SUB_CUT_X = Convert.ToString(prorder.ORD_LEN);//替代切割点X
prP_PLATE.SUB_CUT_Y = Convert.ToString(prP_PLATE.WID);//替代切割点Y
prP_PLATE.SUB_LOS_WGT = "0";//替代损失重量
return true;
}
/// <summary>
/// 切割处理Check 切割结果,计算切割位置)
/// </summary>
/// <param name="prP_PLATE">钢板信息</param>
/// <param name="prorder">订单信息</param>
/// <returns></returns>
public static bool ChkCalDoubleCut(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
if (Convert.ToDecimal(prP_PLATE.LEN) >= Convert.ToDecimal(prorder.ORD_LEN))//
{
//使用率小于85%返回false
if (((Convert.ToDecimal(prorder.ORD_WID) * Convert.ToDecimal(prorder.ORD_LEN) * 2)
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN)))
< Convert.ToDecimal(0.85))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Rate = "2"; //切割百分率
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
prP_PLATE.SUB_CUT_POS_1 = prorder.ORD_LEN;//切割位置1=订单的长度
prP_PLATE.SUB_CUT_POS_2 = prorder.ORD_WID;//切割位置2=订单宽度
prP_PLATE.SUB_SUR_LEN_1 = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prorder.ORD_LEN));
prP_PLATE.SUB_SUR_WID_1 = Convert.ToString(prP_PLATE.WID);
prP_PLATE.SUB_SUR_STA_1 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_SUR_LEN_2 = Convert.ToString(prorder.ORD_LEN);
prP_PLATE.SUB_SUR_WID_2 = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prorder.ORD_WID));
prP_PLATE.SUB_SUR_STA_2 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_DATE = DateTime.Now.ToString();//替代时间
prP_PLATE.SUB_NUM = "2"; //替代块数*先都算作一块
prP_PLATE.SUB_DIR = "H"; //排列方向
prP_PLATE.SUB_US_WID = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prorder.ORD_WID));//剩余宽度
prP_PLATE.SUB_US_LEN = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - 2 * Convert.ToDecimal(prorder.ORD_LEN));//剩余长度
prP_PLATE.SUB_CUT_X = Convert.ToString(Convert.ToDecimal(prorder.ORD_LEN) * 2);//替代切割点X
prP_PLATE.SUB_CUT_Y = Convert.ToString(prP_PLATE.WID);//替代切割点Y
prP_PLATE.SUB_LOS_WGT = "0";//替代损失重量
}
else
{
if (((Convert.ToDecimal(prorder.ORD_WID) * 2 * Convert.ToDecimal(prorder.ORD_LEN))
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN)))
< Convert.ToDecimal(0.85))
{
COM_DATA CD = new COM_DATA();
CD.PLATE_NO = prP_PLATE.PLATE_NO;
CD.ORD_NO = prorder.ORD_NO;
CD.ORD_ITEM = prorder.ORD_ITEM;
CD.Rate = "2"; //切割百分率
gCOM_DATA.Add(CD);//全局变量添加对不结果数据
return false;
}
prP_PLATE.SUB_CUT_POS_1 = prorder.ORD_LEN;//切割位置1=订单的长度
prP_PLATE.SUB_CUT_POS_2 = prorder.ORD_WID;//切割位置2=订单宽度
prP_PLATE.SUB_SUR_LEN_1 = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prorder.ORD_LEN));
prP_PLATE.SUB_SUR_WID_1 = Convert.ToString(prP_PLATE.WID);
prP_PLATE.SUB_SUR_STA_1 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_SUR_LEN_2 = Convert.ToString(prorder.ORD_LEN);
prP_PLATE.SUB_SUR_WID_2 = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prorder.ORD_WID));
prP_PLATE.SUB_SUR_STA_2 = "1";//判废=1 ,剩余=0
prP_PLATE.SUB_DATE = DateTime.Now.ToString();//替代时间
prP_PLATE.SUB_NUM = "2"; //替代块数*先都算作一块
prP_PLATE.SUB_DIR = "V"; //排列方向
prP_PLATE.SUB_US_WID = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) - 2 * Convert.ToDecimal(prorder.ORD_WID));//剩余宽度
prP_PLATE.SUB_US_LEN = Convert.ToString(Convert.ToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prorder.ORD_LEN));//剩余长度
prP_PLATE.SUB_CUT_X = Convert.ToString(Convert.ToDecimal(prorder.ORD_LEN));//替代切割点X
prP_PLATE.SUB_CUT_Y = Convert.ToString(Convert.ToDecimal(prP_PLATE.WID) * 2);//替代切割点Y
prP_PLATE.SUB_LOS_WGT = "0";//替代损失重量
}
return true;
}
#region 物理特性对比
/// <summary>
/// HA物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHA(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HA> ltQPQltyMatrHA = gQP_QLTY_MATR_HA.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HA> ltQPTestRsltHA = gQP_TEST_RSLT_HA.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHA.Count == 0)
{
return true;
}
if (ltQPTestRsltHA.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HA";
return true;
}
//屈服点实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].YP_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].YP_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].YP_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].YP_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].YP_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].YP_MAX))
{
return false;//大于最大值
}
//拉伸强度实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].TS_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].TS_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].TS_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].TS_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].TS_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].TS_MAX))
{
return false;//大于最大值
}
//面缩率实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].RA_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].RA_RST_AVE) < ConverDataToDecimal(ltQPQltyMatrHA[0].RA_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].RA_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].RA_RST_AVE) > ConverDataToDecimal(ltQPQltyMatrHA[0].RA_MAX))
{
return false;//大于最大值
}
//断面伸长率实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].EL_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].EL_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].EL_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].EL_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].EL_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].EL_MAX))
{
return false;//大于最大值
}
//规定非比例伸长应力实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SNPP_EL_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SNPP_EL_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].SNPP_EL_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SNPP_EL_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SNPP_EL_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].SNPP_EL_MAX))
{
return false;//大于最大值
}
//规定总伸长应力实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SG_EL_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SG_EL_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].SG_EL_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SG_EL_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SG_EL_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].SG_EL_MAX))
{
return false;//大于最大值
}
//规定残余伸长应力实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SP_EL_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SP_EL_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].SP_EL_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].SP_EL_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].SP_EL_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].SP_EL_MAX))
{
return false;//大于最大值
}
//屈强比实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].YR_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].YR_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].YR_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].YR_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].YR_RST) > ConverDataToDecimal(ltQPQltyMatrHA[0].YR_MAX))
{
return false;//大于最大值
}
//厚度方向面缩率均值实绩
if (ConverDataToDecimal(ltQPQltyMatrHA[0].ZRA_AVE_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].ZRA_RST_AVE) < ConverDataToDecimal(ltQPQltyMatrHA[0].ZRA_AVE_MIN))
{
return false;//小于最小值
}
//均匀变形伸长率
if (ConverDataToDecimal(ltQPQltyMatrHA[0].UEL_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].UEL_VAL) < ConverDataToDecimal(ltQPQltyMatrHA[0].UEL_MIN))
{
return false;//小于最小值
}
if (ConverDataToDecimal(ltQPQltyMatrHA[0].UEL_MAX) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].UEL_VAL) > ConverDataToDecimal(ltQPQltyMatrHA[0].UEL_MAX))
{
return false;//大于最大值
}
//强延积(抗拉*延伸)
if (ConverDataToDecimal(ltQPQltyMatrHA[0].RMA_MIN) != 0
&& ConverDataToDecimal(ltQPTestRsltHA[0].RMA_RST) < ConverDataToDecimal(ltQPQltyMatrHA[0].RMA_MIN))
{
return false;//小于最小值
}
return true;
}
/// <summary>
/// HC物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHC(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HC> ltQPQltyMatrHC = gQP_QLTY_MATR_HC.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HC> ltQPTestRsltHC = gQP_TEST_RSLT_HC.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHC.Count == 0)
{
return true;
}
if (ltQPTestRsltHC.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HC";
return true;
}
//冲击试验
if (ConverDataToString(ltQPQltyMatrHC[0].IMPACT_DIR) != string.Empty)
{
if (ConverDataToString(ltQPTestRsltHC[0].IMPACT_DIR) == ConverDataToString(ltQPQltyMatrHC[0].IMPACT_DIR))//方向相同
{
if (ConverDataToDecimal(ltQPTestRsltHC[0].IMPACT_TMP) <= ConverDataToDecimal(ltQPQltyMatrHC[0].IMPACT_TMP))//钢板温度小于小于等于订单温度
{
//冲击试验实绩平均
if (ConverDataToDecimal(ltQPTestRsltHC[0].IMPACT_RST_AVE)
< ConverDataToDecimal(ltQPQltyMatrHC[0].IMPACT_MIN_MIN))//冲击试验实绩平均小于订单冲击最小值
{
return false;
}
//冲击试验断面纤维率实绩
if (ConverDataToDecimal(ltQPTestRsltHC[0].IMPACT_RATE_RST)
< ConverDataToDecimal(ltQPQltyMatrHC[0].IMPACT_RATE_MIN)
|| ConverDataToDecimal(ltQPTestRsltHC[0].IMPACT_RATE_RST)
> ConverDataToDecimal(ltQPQltyMatrHC[0].IMPACT_RATE_MAX))//冲击试验断面纤维率实绩小于最小值大于最大值
{
return false;
}
//冲击试验实绩平均
if (ConverDataToDecimal(ltQPTestRsltHC[0].IMPACT_RST_AVE)
< ConverDataToDecimal(ltQPQltyMatrHC[0].IMPACT_MIN_MIN))//冲击试验实绩平均小于订单冲击最小值
{
return false;
}
}
}
}
//时效冲击试验
if (ConverDataToString(ltQPQltyMatrHC[0].TIM_IMPACT_DIR) != string.Empty)
{
if (ConverDataToString(ltQPTestRsltHC[0].TIM_IMPACT_DIR) == ConverDataToString(ltQPQltyMatrHC[0].TIM_IMPACT_DIR))//方向相同
{
if (ConverDataToDecimal(ltQPTestRsltHC[0].TIM_IMPACT_DIR) <= ConverDataToDecimal(ltQPQltyMatrHC[0].TIM_IMPACT_DIR))//钢板温度小于小于等于订单温度
{
//时效冲击试验实绩平均
if (ConverDataToDecimal(ltQPTestRsltHC[0].TIM_IMPACT_RST_AVE)
< ConverDataToDecimal(ltQPQltyMatrHC[0].TIM_IMPACT_MIN_MIN))//冲击试验实绩平均小于订单冲击最小值
{
return false;
}
//时效冲击试验断面纤维率实绩
if (ConverDataToDecimal(ltQPTestRsltHC[0].TIM_IMPACT_RATE_RST)
< ConverDataToDecimal(ltQPQltyMatrHC[0].TIM_IMPACT_RATE_MIN)
|| ConverDataToDecimal(ltQPTestRsltHC[0].TIM_IMPACT_RATE_RST)
> ConverDataToDecimal(ltQPQltyMatrHC[0].TIM_IMPACT_RATE_MAX))//冲击试验断面纤维率实绩小于最小值大于最大值
{
return false;
}
//时效冲击试验实绩平均
if (ConverDataToDecimal(ltQPTestRsltHC[0].TIM_IMPACT_RST_AVE)
< ConverDataToDecimal(ltQPQltyMatrHC[0].TIM_IMPACT_MIN_MIN))//冲击试验实绩平均小于订单冲击最小值
{
return false;
}
}
}
}
return true;
}
/// <summary>
/// HD物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHD(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HD> ltQPQltyMatrHD = gQP_QLTY_MATR_HD.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HD> ltQPTestRsltHD = gQP_TEST_RSLT_HD.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHD.Count == 0)
{
return true;
}
if (ltQPTestRsltHD.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HD";
return true;
}
//硬度小于最小值
if (ConverDataToDecimal(ltQPTestRsltHD[0].HARD_RST) < ConverDataToDecimal(ltQPQltyMatrHD[0].HARD_MIN))
{
return false;
}
//硬度最大值不为空,且大于最大值
if (ConverDataToDecimal(ltQPQltyMatrHD[0].HARD_MAX) != 0 &&
ConverDataToDecimal(ltQPTestRsltHD[0].HARD_RST) > ConverDataToDecimal(ltQPQltyMatrHD[0].HARD_MAX))
{
return false;
}
return true;
}
/// <summary>
/// HE物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHE(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HE> ltQPQltyMatrHE = gQP_QLTY_MATR_HE.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HE> ltQPTestRsltHE = gQP_TEST_RSLT_HE.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHE.Count == 0)
{
return true;
}
if (ltQPTestRsltHE.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HE";
return true;
}
//晶粒度级别
if (ConverDataToDecimal(ltQPTestRsltHE[0].GRAIN_SIZE_RST)
< ConverDataToDecimal(ltQPQltyMatrHE[0].GRAIN_SIZE_MIN))//晶粒度级别小于最小值
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHE[0].GRAIN_SIZE_MAX) != 0)//晶粒度级别最大值不为空
{
if (ConverDataToDecimal(ltQPTestRsltHE[0].GRAIN_SIZE_RST)
> ConverDataToDecimal(ltQPQltyMatrHE[0].GRAIN_SIZE_MAX))//晶粒度级别大于最大
{
return false;
}
}
//奥氏体(本质)晶粒度
if (ConverDataToDecimal(ltQPTestRsltHE[0].OST_GRAIN_SIZE_RST)
< ConverDataToDecimal(ltQPQltyMatrHE[0].OST_GRAIN_SIZE_MIN))//奥氏体(本质)晶粒度小于最小值
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHE[0].OST_GRAIN_SIZE_MAX) != 0)//奥氏体(本质)晶粒度最大值不为空
{
if (ConverDataToDecimal(ltQPTestRsltHE[0].OST_GRAIN_SIZE_RST)
> ConverDataToDecimal(ltQPQltyMatrHE[0].OST_GRAIN_SIZE_MAX))//奥氏体(本质)晶粒度大于最大
{
return false;
}
}
//脱碳层
if (ConverDataToDecimal(ltQPQltyMatrHE[0].RMV_CAR_MAX) != 0)//脱碳层最大值不为空
{
if (ConverDataToDecimal(ltQPTestRsltHE[0].RMV_CAR_RST)
> ConverDataToDecimal(ltQPQltyMatrHE[0].RMV_CAR_MAX))//脱碳层大于最大
{
return false;
}
}
//带形试验级别
if (ConverDataToDecimal(ltQPQltyMatrHE[0].BELT_STR_GRD) != 0)//带形试验级别不为空
{
if (ConverDataToDecimal(ltQPTestRsltHE[0].BELT_STR_GRD_RST)
< ConverDataToDecimal(ltQPQltyMatrHE[0].BELT_STR_GRD))//带形试验级别小于要求
{
return false;
}
}
return true;
}
/// <summary>
/// HF物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHF(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HF> ltQPQltyMatrHF = gQP_QLTY_MATR_HF.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HF> ltQPTestRsltHF = gQP_TEST_RSLT_HF.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHF.Count == 0)
{
return true;
}
//钢板缺少物理属性
if (ltQPTestRsltHF.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HF";
return true;
}
//重力撕裂试试验温度
if (ConverDataToDecimal(ltQPTestRsltHF[0].DWTT_TMP) <= ConverDataToDecimal(ltQPQltyMatrHF[0].DWTT_TMP))
{
//重力撕裂试验柔性破面率实绩平均
if (ConverDataToDecimal(ltQPTestRsltHF[0].DWTT_YP_RST_AVE) < ConverDataToDecimal(ltQPQltyMatrHF[0].DWTT_YP_MIN))
{
return false;
}
}
return true;
}
/// <summary>
/// HJ物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHJ(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HJ> ltQPQltyMatrHJ = gQP_QLTY_MATR_HJ.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HJ> ltQPTestRsltHJ = gQP_TEST_RSLT_HJ.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHJ.Count == 0)
{
return true;
}
//钢板缺少物理属性
if (ltQPTestRsltHJ.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HJ";
return true;
}
//非金属夹杂粗系等级 数值越小等级越大 A 1-4 A-D
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD1) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_ARST1) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD1))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD2) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_ARST2) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD2))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD3) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_ARST3) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD3))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD4) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_ARST4) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_AGRD4))
{
return false;
}
//非金属夹杂粗系等级 数值越小等级越大 B 1-4 A-D
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD1) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_BRST1) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD1))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD2) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_BRST2) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD2))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD3) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_BRST3) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD3))
{
return false;
}
if (ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD4) != 0 &&
ConverDataToDecimal(ltQPTestRsltHJ[0].NON_METAL_BRST4) > ConverDataToDecimal(ltQPQltyMatrHJ[0].NON_METAL_BGRD4))
{
return false;
}
return true;
}
/// <summary>
/// HK物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHK(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HK> ltQPQltyMatrHK = gQP_QLTY_MATR_HK.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HK> ltQPTestRsltHK = gQP_TEST_RSLT_HK.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHK.Count == 0)
{
return true;
}
//钢板缺少物理属性
if (ltQPTestRsltHK.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HK";
return true;
}
//纤维率 纤维率小于要求false
if (ConverDataToDecimal(ltQPQltyMatrHK[0].CRYSTALLINITY_MIN) != 0 &&
ConverDataToDecimal(ltQPTestRsltHK[0].CRYSTALLINITY_RSLT) < ConverDataToDecimal(ltQPQltyMatrHK[0].CRYSTALLINITY_MIN))
{
return false;
}
return true;
}
/// <summary>
/// HM物理性能对比
/// </summary>
/// <returns>满足True;不满足False</returns>
public static bool ChkPhyHM(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder)
{
//获取订单的物理特性
List<QP_QLTY_MATR_HM> ltQPQltyMatrHM = gQP_QLTY_MATR_HM.Where(p => p.ORD_NO == prorder.ORD_NO && p.ORD_ITEM == prorder.ORD_ITEM).ToList();
//获取钢板的物理特性
List<QP_TEST_RSLT_HM> ltQPTestRsltHM = gQP_TEST_RSLT_HM.Where(p => p.SMP_NO == prP_PLATE.SMP_NO).ToList();
//订单没有物理特性要求返回True
if (ltQPQltyMatrHM.Count == 0)
{
return true;
}
//钢板缺少物理属性
if (ltQPTestRsltHM.Count == 0)
{
prP_PLATE.SUB_FULL = "P";
prP_PLATE.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON + "/物理性能HM";
return true;
}
//剩磁 大于要求false
if (ConverDataToDecimal(ltQPQltyMatrHM[0].BR_MAX) != 0 &&
ConverDataToDecimal(ltQPTestRsltHM[0].BR_RST) > ConverDataToDecimal(ltQPQltyMatrHM[0].BR_MAX))
{
return false;
}
return true;
}
#endregion
#endregion
#region 钢板手动匹配
/// <summary>
/// 获取替代板坯信息
/// </summary>
/// <param name="queryArgs"></param>
/// <returns></returns>
[HttpPost, Route("getTbPLATEManual")]
public RequestEntity getTbPLATEManual(TB_PLATE_MANUALQueryArgs queryArgs)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
StringBuilder strSql = new StringBuilder(); //声明拼接Sql语句变量
DataTable dtCheck = new DataTable();
strSql.AppendLine("SELECT FSD.*,TO_DATE(INS_DATE||INS_TIME, 'yyyy-mm-dd hh24:mi:ss') SUB_DATE FROM TB_PLATE_MANUAL FSD WHERE 1=1 ");
//strSql.AppendLine("FROM FP_PLATE_DES FSD ");
//strSql.AppendLine("WHERE 1 = 1 AND FSD.HAN_RSL IS NULL");
if (queryArgs != null)
{
//板坯号
if (!string.IsNullOrWhiteSpace(queryArgs.PLATE_NO))
{
strSql.AppendLine(" AND FSD.PLATE_NO = '" + queryArgs.PLATE_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<IDbContext>("db"))
{
dtCheck = db.Query(strSql.ToString());
string plate_no = " OR GP.PLATE_NO in ('";
string plate_no1 = " where PLATE_NO in ('";
//strSpecialOrd += string.Format(" or (boi.ORD_NO = '{0}' and boi.ORD_ITEM = '{1}')", order.ORD_NO, order.ORD_ITEM);
string ord_no = " OR (boi.ORD_NO = '";
string ord_no1 = " where (ORD_NO = '";
dtCheck.Columns.Add("LEN");
dtCheck.Columns.Add("WID");
dtCheck.Columns.Add("THK");
dtCheck.Columns.Add("APLY_STDSPEC");
dtCheck.Columns.Add("ORD_LEN");
dtCheck.Columns.Add("ORD_WID");
dtCheck.Columns.Add("ORD_THK");
dtCheck.Columns.Add("STDSPEC");
dtCheck.Columns.Add("SUB_LACK_NUM");
if (dtCheck.Rows.Count > 0)
{
int n = 0;
int m = 0;
foreach (DataRow row in dtCheck.Rows)
{
if (n == 0)
{
plate_no += row["PLATE_NO"].ToString();
plate_no1 += row["PLATE_NO"].ToString();
}
else
{
plate_no += "','" + row["PLATE_NO"].ToString();
plate_no1 += "','" + row["PLATE_NO"].ToString();
}
//多条1000会报错 截取城 多列sql 查询
if (n > 900)
{
n = n - 900;
plate_no += "') or GP.PLATE_NO in ('" + row["PLATE_NO"].ToString();
plate_no1 += "') or GP.PLATE_NO in ('" + row["PLATE_NO"].ToString();
}
if (m == 0)
{
ord_no += row["ORD_NO"].ToString() + "' and boi.ORD_ITEM = '" + row["ORD_ITEM"].ToString();
ord_no1 += row["ORD_NO"].ToString() + "' and ORD_ITEM = '" + row["ORD_ITEM"].ToString();
}
else
{
ord_no += "') or (boi.ORD_NO ='" + row["ORD_NO"].ToString() + "' and boi.ORD_ITEM = '" + row["ORD_ITEM"].ToString();
ord_no1 += "') or (ORD_NO ='" + row["ORD_NO"].ToString() + "' and ORD_ITEM = '" + row["ORD_ITEM"].ToString();
}
//ord_no += " or ORD_NO='" + row["BOI_ORD_NO"].ToString() + "' and ORD_ITEM='" + row["BOI_ORD_ITEM"].ToString() + "'";
n++;
m++;
}
plate_no += "')";
plate_no1 += "')";
ord_no += "')";
ord_no1 += "')";
IList<GP_PLATE> gP_PLATEs = GetSurplusMaterial(plate_no, plate_no1);
IList<BP_ORDER_ITEM> oRDER_ITEMs = GetOrders(ord_no, ord_no1);
if (gP_PLATEs.Count > 0)
{
foreach (DataRow row in dtCheck.Rows)
{
GP_PLATE P_PLATE = gP_PLATEs.Where(p => p.PLATE_NO == row["PLATE_NO"].ToString()).ToList().Count > 0 ? gP_PLATEs.Where(p => p.PLATE_NO == row["PLATE_NO"].ToString()).FirstOrDefault() : null;
if (P_PLATE != null)
{
row["LEN"] = P_PLATE.LEN;
row["WID"] = P_PLATE.WID;
row["THK"] = P_PLATE.THK;
row["APLY_STDSPEC"] = P_PLATE.APLY_STDSPEC;
}
BP_ORDER_ITEM ORDER_ITEM = oRDER_ITEMs.Where(p => p.ORD_NO == row["ORD_NO"].ToString() && p.ORD_ITEM == row["ORD_ITEM"].ToString()).ToList().Count > 0 ? oRDER_ITEMs.Where(p => p.ORD_NO == row["ORD_NO"].ToString() && p.ORD_ITEM == row["ORD_ITEM"].ToString()).FirstOrDefault() : null;
if (ORDER_ITEM != null)
{
row["ORD_LEN"] = ORDER_ITEM.ORD_LEN;
row["ORD_WID"] = ORDER_ITEM.ORD_WID;
row["ORD_THK"] = ORDER_ITEM.ORD_THK;
row["STDSPEC"] = ORDER_ITEM.STDSPEC;
row["SUB_LACK_NUM"] = ORDER_ITEM.SUB_LACK_NUM;
}
//if (rw.Length > 0)
//{
// string REASON = rw[0]["REASON"].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("GetPLATESub 报错", ex);
}
return result;
}
[HttpPost, Route("AddSingleSup1")]
/// <summary>
/// 单个钢板手动替代
/// </summary>
/// <param name="ArgsSupersede"></param>
/// <returns></returns>
public RequestEntity AddSingleSup1(IList<TB_PLATE_MANUAL> insertModel)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
try
{
//int cnt = insertModel.Count;
//string[] str = new string[cnt];
string args = string.Empty;
for (int i = 0; i < insertModel.Count; i++)
{
if (i == 0)
{
args += "'"+ insertModel[i].PLATE_NO.ToString()+"'";
}
else
{
args += "," + "'" + insertModel[i].PLATE_NO.ToString() + "'";
}
}
//string args = ArgsSupersede.PLATE_NO + "01";
Process KHMsg = new Process();
KHMsg.StartInfo.FileName = @"D:\Program\SurplusMaterial\SinglePlateHandle.exe";
KHMsg.StartInfo.Arguments = args;
//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;
}
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("DelTbPLATEManual")]
public RequestEntity DelTbPLATEManual(IList<TB_PLATE_MANUAL> delModel)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
foreach (var model in delModel)
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("DELETE FROM TB_PLATE_MANUAL WHERE 1=1 ");
strSql.AppendLine(string.Format(" AND PLATE_NO='{0}' AND ORD_NO = '{1}' AND ORD_ITEM = '{2}' ", model.PLATE_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;
}
/// <summary>
/// 修改接口
/// </summary>
/// <param name="delModel"></param>
/// <returns></returns>
[HttpPost, Route("UpdateTbPLATEManual")]
public RequestEntity UpdateTbPLATEManual(IList<TB_PLATE_MANUAL> model)
{
RequestEntity result = new RequestEntity();
StringBuilder strSql = new StringBuilder();
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
//ORD_NO, ORD_ITEM
strSql.AppendLine("Update TB_PLATE_MANUAL ");
strSql.AppendLine(string.Format("set IS_CUTTING = '{0}' where PLATE_NO = '{1}' ORD_NO = '{2}' and ORD_ITEM = '{3}' ", model[1].IS_CUTTING, model[1].PLATE_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("UpdateTbPLATEManual 报错", ex);
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbPLATEManual")]
public RequestEntity AddTbPLATEManual(IList<TB_PLATE_MANUAL> insertModel)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
bool b = true;
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
db.BeginTransaction();
foreach (TB_PLATE_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.PLATE_NO = model.PLATE_NO.Trim();
model.ORD_NO = model.ORD_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<TB_PLATE_MANUAL>(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("AddTbPLATEManual 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("AddTbPLATEManualOne")]
public RequestEntity AddTbPLATEManualOne(TB_PLATE_MANUAL model)
{
RequestEntity result = new RequestEntity();
DateTime dtNow = DateTime.Now;
try
{
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("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.PLATE_NO = model.PLATE_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<TB_PLATE_MANUAL>(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("AddTbPLATEManualOne 报错 : ", ex);
if (ex.ToString().Contains("00001"))
{
result.msg = "重复插入!";
}
}
return result;
}
public static IList<GP_PLATE> GetSurplusMaterial(string strWHerePlate, string strplate)
{
IList<GP_PLATE> reListGP_PLATE = new List<GP_PLATE>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListGP_PLATE = SerSurMatSubService.GetAllMat(strWHerePlate, strplate);
}
}
catch (Exception ex)
{
logger.Error("GetSurplusMaterial 报错 : ", ex);
}
return reListGP_PLATE;
}
public static IList<BP_ORDER_ITEM> GetOrders(string strWHereOrd, string strord)
{
IList<BP_ORDER_ITEM> reListBP_ORDER_ITEM = new List<BP_ORDER_ITEM>();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
reListBP_ORDER_ITEM = SerSurMatSubService.GetOrder(strWHereOrd, strord);
}
}
catch (Exception ex)
{
logger.Error("GetSurplusMaterial 报错 : ", ex);
}
return reListBP_ORDER_ITEM;
}
/// <summary>
/// 添加接口
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost, Route("TB_PLATE_MANUALVerification")]
public RequestEntity TB_PLATE_MANUALVerification(IList<TB_PLATE_MANUAL> ltmanual)
{
lock (LOCK)
{
RequestEntity result = new RequestEntity(); //声明返回参数实体类
DataTable dtCheck = new DataTable();
//开启数据库连接查询数据
try
{
string args = string.Empty;
for (int i = 0; i < ltmanual.Count; i++)
{
if (i == 0)
{
args += "'"+ ltmanual[i].PLATE_NO;
}
else
{
args += "','" + ltmanual[i].PLATE_NO;
}
if(i== ltmanual.Count-1)
{
args += "'" ;
}
}
//string args = string.Empty;
//if(ArgsSupersede.Count>)
//foreach(var a in ArgsSupersede)
//string args = ArgsSupersede;
Process KHMsg = new Process();
KHMsg.StartInfo.FileName = @"D:\Program\SurplusMaterial\SinglePlateHandle.exe";
//KHMsg.StartInfo.FileName = @"D:\南钢项目\ipd-file\ipd-file67\ipd-file\SinglePlateHandle\SinglePlateHandle\bin\Debug\SinglePlateHandle.exe";
KHMsg.StartInfo.Arguments = args;
//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 = ex.Message;
result.code = "0";
logger.Error("AddSingleSup 报错", ex);
}
return result;
}
}
#endregion
#region 方法
/// <summary>
/// 替换成功存储数据
/// </summary>
public static void SaveData(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder, TEMP_DATA prTempData)
{
//声明匹配实体类
SUPERSEDE supersede = new SUPERSEDE();
//记录被替代的号
ltPlateNo.Add(prP_PLATE.PLATE_NO);
//不需要切边
//替代率
//supersede.SUB_RATE = prTempData.SUB_RATE.ToString();
supersede.SUB_RATE = Math.Round((((Convert.ToDecimal(prorder.ORD_WID) * Convert.ToDecimal(prorder.ORD_LEN) * Convert.ToDecimal(prTempData.SUB_NUM))
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN))) * 100), 2).ToString();
if (supersede.SUB_RATE == "100")
{
supersede.TRIMMING = "1";
}
else
{
supersede.TRIMMING = "2";
}
if (Convert.ToDecimal(prTempData.SUB_NUM) == 1)
{
supersede.SUB_US_WID = (ConverDataToDecimal(prP_PLATE.WID) - ConverDataToDecimal(prorder.ORD_WID)).ToString();
supersede.SUB_US_LEN = (ConverDataToDecimal(prP_PLATE.LEN) - ConverDataToDecimal(prorder.ORD_LEN)).ToString();
supersede.SUB_CUT_X = ConverDataToDecimal(prorder.ORD_LEN).ToString();
supersede.SUB_CUT_Y = ConverDataToDecimal(prorder.ORD_WID).ToString();
}
else
{
if (ConverDataToDecimal(prP_PLATE.LEN) >= Convert.ToDecimal(prTempData.SUB_NUM) * ConverDataToDecimal(prorder.ORD_LEN))
{
supersede.SUB_US_WID = (ConverDataToDecimal(prP_PLATE.WID) - ConverDataToDecimal(prorder.ORD_WID)).ToString();
supersede.SUB_US_LEN = (ConverDataToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prTempData.SUB_NUM) * ConverDataToDecimal(prorder.ORD_LEN)).ToString();
supersede.SUB_CUT_X = (ConverDataToDecimal(prP_PLATE.LEN) - Convert.ToDecimal(prTempData.SUB_NUM) * ConverDataToDecimal(prorder.ORD_LEN)).ToString();
supersede.SUB_CUT_Y = ConverDataToDecimal(prorder.ORD_WID).ToString();
}
else
{
supersede.SUB_US_LEN = (ConverDataToDecimal(prP_PLATE.LEN) - ConverDataToDecimal(prorder.ORD_LEN)).ToString();
supersede.SUB_US_WID = (ConverDataToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prTempData.SUB_NUM) * ConverDataToDecimal(prorder.ORD_WID)).ToString();
supersede.SUB_CUT_X = (ConverDataToDecimal(prP_PLATE.WID) - Convert.ToDecimal(prTempData.SUB_NUM) * ConverDataToDecimal(prorder.ORD_WID)).ToString();
supersede.SUB_CUT_Y = ConverDataToDecimal(prorder.ORD_LEN).ToString();
}
}
//钢种
supersede.STLGRD = prP_PLATE.STLGRD;
//钢板号
supersede.PLATE_NO = prP_PLATE.PLATE_NO;
supersede.APLY_STDSPEC = prP_PLATE.APLY_STDSPEC;
supersede.PROC_CD = prP_PLATE.PROC_CD;
supersede.THK = prorder.ORD_THK;
supersede.WID = prorder.ORD_WID;
supersede.LEN = prorder.ORD_LEN;
supersede.PLATE_SIZE = prP_PLATE.THK + "*" + prP_PLATE.WID + "*" + prP_PLATE.LEN;
supersede.ORD_NO = prorder.ORD_NO;
supersede.ORD_ITEM = prorder.ORD_ITEM;
supersede.TRIMMING_WID = "0";
supersede.TRIMMING_LEN = "0";
supersede.SURPLUS_WID = "0";
supersede.SURPLUS_LEN = "0";
supersede.WGT = "0";
supersede.REDO_HOT = "";
supersede.SIZE_KND = "";
supersede.SUB_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
supersede.GP_THK = ConverDataToDecimal(prP_PLATE.THK).ToString();
supersede.GP_WID = ConverDataToDecimal(prP_PLATE.WID).ToString();
supersede.GP_LEN = ConverDataToDecimal(prP_PLATE.LEN).ToString();
supersede.GP_WGT = ConverDataToDecimal(prP_PLATE.WGT).ToString();
supersede.GP_APLY_STDSPEC = prP_PLATE.APLY_STDSPEC;
supersede.GP_ORD_FL = prP_PLATE.ORD_FL;
supersede.GP_SURF_GRD = prP_PLATE.SURF_GRD;
supersede.BOI_ORD_NO = prorder.ORD_NO;
supersede.BOI_ORD_ITEM = prorder.ORD_ITEM;
supersede.BOI_STDSPEC = prorder.STDSPEC;
supersede.BOI_ORD_THK = ConverDataToDecimal(prorder.ORD_THK).ToString();
supersede.BOI_ORD_WID = ConverDataToDecimal(prorder.ORD_WID).ToString();
supersede.BOI_ORD_LEN = ConverDataToDecimal(prorder.ORD_LEN).ToString();
supersede.BOI_WGT_UNIT = prorder.ORD_WGT;
supersede.BOI_CUST_CD = prorder.CUST_CD;
supersede.BOI_ENDUSE_CD = prorder.ENDUSE_CD;
supersede.BOI_ORD_KND = prorder.ORD_KND;
supersede.BOB_ORD_NO = prP_PLATE.BOB_ORD_NO;
supersede.BOB_ORD_ITEM = prP_PLATE.BOB_ORD_ITEM;
supersede.BOB_STDSPEC = prP_PLATE.BOB_STDSPEC;
supersede.BOB_ORD_THK = ConverDataToDecimal(prP_PLATE.BOB_ORD_THK).ToString();
supersede.BOB_ORD_WID = ConverDataToDecimal(prP_PLATE.BOB_ORD_WID).ToString();
supersede.BOB_ORD_LEN = ConverDataToDecimal(prP_PLATE.BOB_ORD_LEN).ToString();
supersede.BOB_WGT_UNIT = prP_PLATE.BOB_WGT_UNIT;
supersede.BOB_CUST_CD = prP_PLATE.BOB_CUST_CD;
supersede.BOB_ENDUSE_CD = prP_PLATE.BOB_ENDUSE_CD;
supersede.BOB_ORD_KND = prP_PLATE.BOB_ORD_KND;
supersede.BOO_ORD_NO = prP_PLATE.BOO_ORD_NO;
supersede.BOO_ORD_ITEM = prP_PLATE.BOO_ORD_ITEM;
supersede.BOO_STDSPEC = prP_PLATE.BOO_STDSPEC;
supersede.BOO_ORD_THK = ConverDataToDecimal(prP_PLATE.BOO_ORD_THK).ToString();
supersede.BOO_ORD_WID = ConverDataToDecimal(prP_PLATE.BOO_ORD_WID).ToString();
supersede.BOO_ORD_LEN = ConverDataToDecimal(prP_PLATE.BOO_ORD_LEN).ToString();
supersede.BOO_WGT_UNIT = prP_PLATE.BOO_WGT_UNIT;
supersede.BOO_CUST_CD = prP_PLATE.BOO_CUST_CD;
supersede.SUB_USER = "替代人员";
supersede.SUR_PRO_REM = "产品备注";
supersede.GP_PLT = prP_PLATE.PLT;
supersede.GP_PROD_TIME = prP_PLATE.PROD_TIME;
supersede.SUR_FIR_TIM = "首次降级时间";//prP_PLATE.SUR_FIR_TIM;
supersede.GP_WOO_RSN = prP_PLATE.WOO_RSN;
supersede.SUR_COM = "责任单位";
supersede.SUB_NUM = "1";
supersede.SUB_DIR = "H";
supersede.SUB_LOS_WGT = "0";
supersede.SUB_FOR = "Y";
supersede.SUB_REM = "替代备注";
supersede.GP_CUR_INV = prP_PLATE.CUR_INV;
supersede.GP_TRIM_FL = prP_PLATE.TRIM_FL;
supersede.GP_SIZE_KND = prP_PLATE.SIZE_KND;
supersede.ORD_REM = "订单备注";
supersede.GP_UST_RLT_CD = prP_PLATE.UST_RLT_CD;
supersede.GP_GAS_FL = prP_PLATE.GAS_FL;
supersede.GP_CL_FL = prP_PLATE.CL_FL;
supersede.GP_HTM_CNT = prP_PLATE.HTM_CNT;
supersede.GP_STLGRD = prP_PLATE.STLGRD;
supersede.BOI_SURFACE_REQUESTS = prorder.SURFACE_REQUESTS;
supersede.BOI_VESSEL_NO = prorder.VESSEL_NO;
supersede.BOI_SIDEMARK = prorder.SIDEMARK;
supersede.BOI_FACEPAINT = prorder.FACEPAINT;
supersede.BOI_SEALMEMO = prorder.SEALMEMO;
supersede.BOI_ORD_PROD_END_TIME = prorder.ORD_PROD_END_TIME;
supersede.BOI_PROD_CD = prorder.PROD_CD;
supersede.BOI_DOME_FL = prorder.DOME_FL;
supersede.BOI_DEL_TO_DATE = prorder.DEL_TO_DATE;
supersede.SUB_FULL = prTempData.SUB_KND;//替代类型( C-完全替代P-退判替代)
supersede.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON;//替代缺失内容
gSUPERSEDE.Add(supersede);
//intLackNum--;//减1
}
/// <summary>
/// 多块替代
/// </summary>
/// <param name="prP_PLATE">钢板信息</param>
/// <param name="prorder">订单信息</param>
/// <param name="intLackNum">欠量数量</param>
public static void SaveData2(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder, ref int intLackNum)
{
//声明匹配实体类
SUPERSEDE supersede = new SUPERSEDE();
//记录被替代的号
ltPlateNo.Add(prP_PLATE.PLATE_NO);
//不需要切边
supersede.TRIMMING = "1";
supersede.SUB_RATE = Math.Round((((Convert.ToDecimal(prorder.ORD_WID) * Convert.ToDecimal(prorder.ORD_LEN) * 2)
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN))) * 100), 2).ToString();
supersede.STLGRD = prP_PLATE.STLGRD;
supersede.PLATE_NO = prP_PLATE.PLATE_NO;
supersede.APLY_STDSPEC = prP_PLATE.APLY_STDSPEC;
supersede.PROC_CD = prP_PLATE.PROC_CD;
supersede.THK = ConverDataToDecimal(prorder.ORD_THK).ToString();
supersede.WID = ConverDataToDecimal(prorder.ORD_WID).ToString();
supersede.LEN = ConverDataToDecimal(prorder.ORD_LEN).ToString();
supersede.PLATE_SIZE = prP_PLATE.THK + "*" + prP_PLATE.WID + "*" + prP_PLATE.LEN;
supersede.ORD_NO = prorder.ORD_NO;
supersede.ORD_ITEM = prorder.ORD_ITEM;
supersede.TRIMMING_WID = "0";
supersede.TRIMMING_LEN = "0";
supersede.SURPLUS_WID = "0";
supersede.SURPLUS_LEN = "0";
supersede.WGT = "0";
supersede.REDO_HOT = "";
supersede.SIZE_KND = "";
supersede.SUB_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
supersede.GP_THK = ConverDataToDecimal(prP_PLATE.THK).ToString();
supersede.GP_WID = ConverDataToDecimal(prP_PLATE.WID).ToString();
supersede.GP_LEN = ConverDataToDecimal(prP_PLATE.LEN).ToString();
supersede.GP_WGT = ConverDataToDecimal(prP_PLATE.WGT).ToString();
supersede.GP_APLY_STDSPEC = prP_PLATE.APLY_STDSPEC;
supersede.GP_ORD_FL = prP_PLATE.ORD_FL;
supersede.GP_SURF_GRD = prP_PLATE.SURF_GRD;
supersede.BOI_ORD_NO = prorder.ORD_NO;
supersede.BOI_ORD_ITEM = prorder.ORD_ITEM;
supersede.BOI_STDSPEC = prorder.STDSPEC;
supersede.BOI_ORD_THK = ConverDataToDecimal(prorder.ORD_THK).ToString();
supersede.BOI_ORD_WID = ConverDataToDecimal(prorder.ORD_WID).ToString();
supersede.BOI_ORD_LEN = ConverDataToDecimal(prorder.ORD_LEN).ToString();
supersede.BOI_WGT_UNIT = prorder.WGT_UNIT;
supersede.BOI_CUST_CD = prorder.CUST_CD;
supersede.BOI_ENDUSE_CD = prorder.ENDUSE_CD;
supersede.BOI_ORD_KND = prorder.ORD_KND;
supersede.BOB_ORD_NO = prP_PLATE.BOB_ORD_NO;
supersede.BOB_ORD_ITEM = prP_PLATE.BOB_ORD_ITEM;
supersede.BOB_STDSPEC = prP_PLATE.BOB_STDSPEC;
supersede.BOB_ORD_THK = ConverDataToDecimal(prP_PLATE.BOB_ORD_THK).ToString();
supersede.BOB_ORD_WID = ConverDataToDecimal(prP_PLATE.BOB_ORD_WID).ToString();
supersede.BOB_ORD_LEN = ConverDataToDecimal(prP_PLATE.BOB_ORD_LEN).ToString();
supersede.BOB_WGT_UNIT = prP_PLATE.BOB_WGT_UNIT;
supersede.BOB_CUST_CD = prP_PLATE.BOB_CUST_CD;
supersede.BOB_ENDUSE_CD = prP_PLATE.BOB_ENDUSE_CD;
supersede.BOB_ORD_KND = prP_PLATE.BOB_ORD_KND;
supersede.BOO_ORD_NO = prP_PLATE.BOO_ORD_NO;
supersede.BOO_ORD_ITEM = prP_PLATE.BOO_ORD_ITEM;
supersede.BOO_STDSPEC = prP_PLATE.BOO_STDSPEC;
supersede.BOO_ORD_THK = ConverDataToDecimal(prP_PLATE.BOO_ORD_THK).ToString();
supersede.BOO_ORD_WID = ConverDataToDecimal(prP_PLATE.BOO_ORD_WID).ToString();
supersede.BOO_ORD_LEN = ConverDataToDecimal(prP_PLATE.BOO_ORD_LEN).ToString();
supersede.BOO_WGT_UNIT = prP_PLATE.BOO_WGT_UNIT;
supersede.BOO_CUST_CD = prP_PLATE.BOO_CUST_CD;
supersede.SUB_USER = "替代人员";
supersede.SUR_PRO_REM = "产品备注";
supersede.GP_PLT = prP_PLATE.PLT;
supersede.GP_PROD_TIME = prP_PLATE.PROD_TIME;
supersede.SUR_FIR_TIM = "首次降级时间";//prP_PLATE.SUR_FIR_TIM;
supersede.GP_WOO_RSN = prP_PLATE.WOO_RSN;
supersede.SUR_COM = "责任单位";
supersede.SUB_NUM = "2";
supersede.SUB_DIR = "H";
supersede.SUB_US_WID = ConverDataToDecimal(prP_PLATE.SUB_SUR_LEN_1).ToString();
supersede.SUB_US_LEN = ConverDataToDecimal(prP_PLATE.SUB_SUR_WID_1).ToString();
supersede.SUB_CUT_X = ConverDataToDecimal(prP_PLATE.SUB_CUT_X).ToString();
supersede.SUB_CUT_Y = ConverDataToDecimal(prP_PLATE.SUB_CUT_Y).ToString();
supersede.SUB_LOS_WGT = "0";
supersede.SUB_FOR = "Y";
supersede.SUB_REM = "替代备注";
supersede.GP_CUR_INV = prP_PLATE.CUR_INV;
supersede.GP_TRIM_FL = prP_PLATE.TRIM_FL;
supersede.GP_SIZE_KND = prP_PLATE.SIZE_KND;
supersede.ORD_REM = "订单备注";
supersede.GP_UST_RLT_CD = prP_PLATE.UST_RLT_CD;
supersede.GP_GAS_FL = prP_PLATE.GAS_FL;
supersede.GP_CL_FL = prP_PLATE.CL_FL;
supersede.GP_HTM_CNT = prP_PLATE.HTM_CNT;
supersede.GP_STLGRD = prP_PLATE.STLGRD;
supersede.BOI_SURFACE_REQUESTS = prorder.SURFACE_REQUESTS;
supersede.BOI_VESSEL_NO = prorder.VESSEL_NO;
supersede.BOI_SIDEMARK = prorder.SIDEMARK;
supersede.BOI_FACEPAINT = prorder.FACEPAINT;
supersede.BOI_SEALMEMO = prorder.SEALMEMO;
supersede.BOI_ORD_PROD_END_TIME = prorder.ORD_PROD_END_TIME;
supersede.BOI_PROD_CD = prorder.PROD_CD;
supersede.BOI_DOME_FL = prorder.DOME_FL;
supersede.BOI_DEL_TO_DATE = prorder.DEL_TO_DATE;
supersede.SUB_FULL = "0";//是否完全替代 多块替代一定是不完全替代=0
supersede.SUB_LACK_CON = prP_PLATE.SUB_LACK_CON;//替代缺失内容
gSUPERSEDE.Add(supersede);
intLackNum -= 2;//减2
}
/// <summary>
/// 记录临时数据
/// </summary>
public static void AddTempData(GP_PLATE prP_PLATE, BP_ORDER_ITEM prorder, int intLackNum, int intSubNum, string strSubKND)
{
TEMP_DATA td = new TEMP_DATA();
td.PLATE_NO = prP_PLATE.PLATE_NO; //钢板号
td.SUB_RATE = Math.Round((((Convert.ToDecimal(prorder.ORD_WID) * Convert.ToDecimal(prorder.ORD_LEN)) * intSubNum
/ (Convert.ToDecimal(prP_PLATE.WID) * Convert.ToDecimal(prP_PLATE.LEN))) * 100), 2);//替代率
td.ORD_NO = prorder.ORD_NO;//订单号
td.ORD_ITEM = prorder.ORD_ITEM;//订单明细号
td.DEF_NUM = intLackNum;//欠量
td.SUB_PRI = "1";//优先级
//添加到临时数据中,二次优化
td.SUB_NUM = intSubNum;
td.SUB_KND = strSubKND;//替代类型( C-完全替代P-退判替代)
logger.InfoFormat("*初步匹配*---订单号【{0}-{1}】==>>钢板号【{2}】", prorder.ORD_NO, prorder.ORD_ITEM, prP_PLATE.PLATE_NO);
gTEMP_DATA.Add(td);
}
/// <summary>
/// 恢复数据
/// </summary>
public static void ResetData()
{
StringBuilder strSqlSUPERSEDE = new StringBuilder(); //声明拼接Sql语句变量
StringBuilder strSqlOrder = new StringBuilder(); //声明拼接Sql语句变量
StringBuilder strSqlPlate = new StringBuilder(); //声明拼接Sql语句变量
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
strSqlSUPERSEDE.AppendLine("DELETE FROM SUPERSEDE ");
//logger.Info(strSqlSUPERSEDE.ToString());
db.Execute(strSqlSUPERSEDE.ToString());//恢复确认表
strSqlOrder.AppendLine("UPDATE BP_ORDER_ITEM SET ");
strSqlOrder.AppendLine("SUB_PRO_STA=''");// " + prorder.SUB_PRO_STA + "'");
strSqlOrder.AppendLine(",SUB_CON_STA=''");//" + prorder.SUB_CON_STA + "'");
//strSqlOrder.AppendLine(",SUB_LACK_NUM=''");//='" + prorder.SUB_LACK_NUM + "'");
strSqlOrder.AppendLine(",SUB_SLAB_NO=''");//=SUB_SLAB_NO || '," + prP_PLATE.PLATE_NO + "'");
strSqlOrder.AppendLine(",SUB_SLAB_REM=''");//='" + prorder.SUB_SLAB_REM + "'");
//strSqlOrder.AppendLine("WHERE ORD_NO ");//='" + prorder.ORD_NO + "'");
//strSqlOrder.AppendLine("AND ORD_ITEM=''");//='" + prorder.ORD_ITEM + "'");
//strSqlOrder.AppendLine("WHERE ORD_NO ||'-' || ORD_ITEM IN ('OA108120005-01','OA108120005-02','OA108120005-03','OA108120005-04')");
//logger.Info(strSqlOrder.ToString());
db.Execute(strSqlOrder.ToString());//恢复订单表
strSqlPlate.AppendLine("UPDATE GP_PLATE SET ");
strSqlPlate.AppendLine("SUB_PRO_STA=''");//='1'");// " + prP_PLATE.SUB_PRO_STA + "'");
strSqlPlate.AppendLine(",SUB_CON_STA=''");//='" + prP_PLATE.SUB_CON_STA + "'");
strSqlPlate.AppendLine(",SUB_CUT_POS_1=''");//='" + prP_PLATE.SUB_CUT_POS_1 + "'");
strSqlPlate.AppendLine(",SUB_CUT_POS_2=''");//='" + prP_PLATE.SUB_CUT_POS_2 + "'");
strSqlPlate.AppendLine(",SUB_ORD_NO=''");//='" + prorder.ORD_NO + "'");
strSqlPlate.AppendLine(",SUB_ORD_ITEM=''");//='" + prorder.ORD_ITEM + "'");
strSqlPlate.AppendLine(",SUB_ORD_REM=''");//='" + prP_PLATE.SUB_ORD_REM + "'");
strSqlPlate.AppendLine(", SUB_SUR_LEN_1 = ''");// + prP_PLATE.SUB_SUR_LEN_1 + "'");
strSqlPlate.AppendLine(", SUB_SUR_WID_1 = ''");// + prP_PLATE.SUB_SUR_WID_1 + "'");
strSqlPlate.AppendLine(", SUB_SUR_LEN_2 = ''");// + prP_PLATE.SUB_SUR_LEN_2 + "'");
strSqlPlate.AppendLine(", SUB_SUR_WID_2 = ''");// + prP_PLATE.SUB_SUR_WID_2 + "'");
strSqlPlate.AppendLine(", SUB_SUR_STA_1 = ''");// + prP_PLATE.SUB_SUR_STA_1 + "'");
strSqlPlate.AppendLine(", SUB_SUR_STA_2 = ''");//" + prP_PLATE.SUB_SUR_STA_2 + "'");
strSqlPlate.AppendLine(", SUB_DATE = ''");// + prP_PLATE.SUB_DATE + "'");
strSqlPlate.AppendLine(", SUB_NUM = ''");// + prP_PLATE.SUB_NUM + "'"); //prP_PLATE.SUB_NUM
strSqlPlate.AppendLine(", SUB_DIR = ''");// + prP_PLATE.SUB_DIR + "'"); //prP_PLATE.SUB_DIR
strSqlPlate.AppendLine(", SUB_US_WID = ''");// + prP_PLATE.SUB_US_WID + "'"); //prP_PLATE.SUB_US_WID
strSqlPlate.AppendLine(", SUB_US_LEN = ''");// + prP_PLATE.SUB_US_LEN + "'"); //prP_PLATE.SUB_US_LEN
strSqlPlate.AppendLine(", SUB_CUT_X = ''");// + prP_PLATE.SUB_CUT_X + "'"); //prP_PLATE.SUB_CUT_X
strSqlPlate.AppendLine(", SUB_CUT_Y = ''");// + prP_PLATE.SUB_CUT_Y + "'"); //prP_PLATE.SUB_CUT_Y
strSqlPlate.AppendLine(", SUB_LOS_WGT = ''");// + prP_PLATE.SUB_LOS_WGT + "'"); //prP_PLATE.SUB_LOS_WGT
//strSqlPlate.AppendLine("WHERE PLATE_NO IN ('12303219080301','12303219040402','12303219080301','12303890340102','12303891360203','12303892060204','12305607030301','12305607030403')");//='" + prP_PLATE.PLATE_NO + "'");
//logger.Info(strSqlPlate.ToString());
db.Execute(strSqlPlate.ToString());//恢复钢材表
}
catch (Exception ex)
{
logger.Error("ERROR INFO:" + ex.ToString());
//db.Rollback();
}
}
}
/// <summary>
/// 获取时间戳
/// </summary>
/// <returns></returns>
public static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 8, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
/// <summary>
/// 整理 PDO 实体类数据
/// </summary>
/// <param name="prP_PLATE">钢板数据</param>
/// <param name="prorder">订单数据库</param>
/// <returns></returns>
public static TBDIPDO GetTBDIBKDPDO(SUPERSEDE prsup)
{
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();
if (prsup.PROC_CD == "XAC")
{
strData.Append(("BKDERP001").PadRight(10));//FORMID10位 BKDERP001 固定
strData.Append(prsup.ID.PadRight(12)); // 业务ID号 NUMBER(12) 流水号,需要再应答中带回
strData.Append(prsup.SUB_FULL); // 替代类型VARCHAR2(1), C - 完全替代P - 退判替代
strData.Append((prsup.PLATE_NO).PadRight(14));// 钢板号: VARCHAR2(14)
strData.Append((prsup.ORD_NO).PadRight(11));// 订单号: VARCHAR2(11)
strData.Append((prsup.ORD_ITEM).PadRight(4)); // 订单项次号: VARCHAR2(4)
strData.Append(GetSlabNo(prsup).PadRight(14)); // 板坯号: VARCHAR2(14)
//是否取样
if (prsup.SUB_FULL != "C")
{
if (!string.IsNullOrEmpty(prsup.SUB_LACK_CON))
{
strData.Append("1"); // 取样: VARCHAR2(1)
}
else
{
strData.Append("0"); // 不取样: VARCHAR2(1)
}
}
else
{
strData.Append("0"); // 不取样: VARCHAR2(1)
}
//是否终结
if (prsup.IS_END == "是")
{
strData.Append("1"); // 终结订单: VARCHAR2(1)
}
else
{
strData.Append("0"); // 非终结订单: VARCHAR2(1)
}
Result.QUEUEID = "BKDERP000";
}
else
{
strData.Append(("BKDMES002").PadRight(10));// FORMID10位 BKDMES002 固定
strData.Append(prsup.ID.PadRight(12));// 业务ID号 NUMBER(12) 流水号,需要再应答中带回
strData.Append(prsup.SUB_FULL); // 替代类型VARCHAR2(1), C - 完全替代P - 退判替代
strData.Append((prsup.PLATE_NO).PadRight(14)); // 钢板号: VARCHAR2(14)
strData.Append((prsup.ORD_NO).PadRight(11));// 订单号: VARCHAR2(11)
strData.Append((prsup.ORD_ITEM).PadRight(4)); // 订单项次号: VARCHAR2(4)
strData.Append(GetSlabNo(prsup).PadRight(14)); // 板坯号: VARCHAR2(14)
if (prsup.SUB_FULL != "C")
{
if (!string.IsNullOrEmpty(prsup.SUB_LACK_CON))
{
strData.Append("1"); // 取样: VARCHAR2(1)
}
else
{
strData.Append("0"); // 不取样: VARCHAR2(1)
}
}
else
{
strData.Append("0"); // 不取样: VARCHAR2(1)
}
//是否终结
if (prsup.IS_END == "是")
{
strData.Append("1"); // 终结订单: VARCHAR2(1)
}
else
{
strData.Append("0"); // 非终结订单: VARCHAR2(1)
}
Result.QUEUEID = "BKDMES000";
}
Result.DATA = strData.ToString();
return Result;
}
/// <summary>
/// 获取缓冲区板坯号
/// </summary>
/// <param name="prsup">变量数据</param>
/// <returns></returns>
public static string GetSlabNo(SUPERSEDE prsup)
{
string strSlabNo = string.Empty;
DataTable dtReturn = new DataTable();
StringBuilder strSql = new StringBuilder();
try
{
//开启数据库连接查询数据
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db_sur"))
{
//strSql.AppendLine(" SELECT ");
//strSql.AppendLine(" R.SLAB_NO ");
//strSql.AppendLine(" ,R.REQ_SEQ_NO ");
//strSql.AppendLine(" , R.ORD_NO ");
//strSql.AppendLine(" , R.ORD_ITEM ");
//strSql.AppendLine(" FROM NISCO.EP_REQ_SLAB R ");
//strSql.AppendLine(" WHERE R.SUPLY_SMS_PLT = 'B1' ");
//strSql.AppendLine(" AND R.REQ_SEQ_NO NOT IN(SELECT REQ_SEQ_NO ");
//strSql.AppendLine(" FROM NISCO.EP_SLAB_EDT ");
//strSql.AppendLine(" WHERE REQ_SEQ_NO IS NOT NULL) ");
//strSql.AppendLine(" AND NVL(R.CNF_FL,' ') = 'F' ");
//strSql.AppendLine(" AND NVL(R.REC_STS,' ') = '1' ");
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}' ", prsup.ORD_NO);
strSql.AppendFormat(" AND A.ORD_ITEM = '{0}' ", prsup.ORD_ITEM);
dtReturn = db.Query(strSql.ToString());
if (dtReturn.Rows.Count > 0)
{
strSlabNo = dtReturn.Rows[0]["REQ_SEQ_NO"].ToString();
}
}
}
catch (Exception)
{
}
//if (prsup.SLAB_LACK_FLG=="1")//欠量不用炼钢缓存区的量
//{
// strSlabNo = String.Empty;
//}
return strSlabNo;
}
/// <summary>
/// 替代履历实体类
/// </summary>
/// <param name="prsup"></param>
/// <returns></returns>
public static SUPERSEDE_HISTORY GetSupHis(SUPERSEDE prsup, SupersedeRequestArgs delAddModel)
{
SUPERSEDE_HISTORY Result = new SUPERSEDE_HISTORY();
Result.APLY_STDSPEC = prsup.APLY_STDSPEC;
Result.ID = prsup.ID;
Result.PLATE_NO = prsup.PLATE_NO;
Result.APLY_STDSPEC = prsup.APLY_STDSPEC;
Result.PROC_CD = prsup.PROC_CD;
Result.THK = prsup.THK;
Result.WID = prsup.WID;
Result.LEN = prsup.LEN;
Result.WGT = prsup.WGT;
Result.REDO_HOT = prsup.REDO_HOT;
Result.SIZE_KND = prsup.SIZE_KND;
Result.TRIMMING = prsup.TRIMMING;
Result.ORD_NO = prsup.ORD_NO;
Result.SUB_RATE = prsup.SUB_RATE;
Result.ORD_ITEM = prsup.ORD_ITEM;
Result.STLGRD = prsup.STLGRD;
Result.TRIMMING_WID = prsup.TRIMMING_WID;
Result.TRIMMING_LEN = prsup.TRIMMING_LEN;
Result.SURPLUS_WID = prsup.SURPLUS_WID;
Result.SURPLUS_LEN = prsup.SURPLUS_LEN;
Result.PLATE_SIZE = prsup.PLATE_SIZE;
Result.SUB_DATE = prsup.SUB_DATE;
Result.GP_THK = prsup.GP_THK;
Result.GP_WID = prsup.GP_WID;
Result.GP_LEN = prsup.GP_LEN;
Result.GP_WGT = prsup.GP_WGT;
Result.GP_APLY_STDSPEC = prsup.GP_APLY_STDSPEC;
Result.GP_ORD_FL = prsup.GP_ORD_FL;
Result.GP_SURF_GRD = prsup.GP_SURF_GRD;
Result.BOI_ORD_NO = prsup.BOI_ORD_NO;
Result.BOI_ORD_ITEM = prsup.BOI_ORD_ITEM;
Result.BOI_STDSPEC = prsup.BOI_STDSPEC;
Result.BOI_ORD_THK = prsup.BOI_ORD_THK;
Result.BOI_ORD_WID = prsup.BOI_ORD_WID;
Result.BOI_ORD_LEN = prsup.BOI_ORD_LEN;
Result.BOI_WGT_UNIT = prsup.BOI_WGT_UNIT;
Result.BOI_CUST_CD = prsup.BOI_CUST_CD;
Result.BOI_ENDUSE_CD = prsup.BOI_ENDUSE_CD;
Result.BOI_ORD_KND = prsup.BOI_ORD_KND;
Result.BOB_ORD_NO = prsup.BOB_ORD_NO;
Result.BOB_ORD_ITEM = prsup.BOB_ORD_ITEM;
Result.BOB_STDSPEC = prsup.BOB_STDSPEC;
Result.BOB_ORD_THK = prsup.BOB_ORD_THK;
Result.BOB_ORD_WID = prsup.BOB_ORD_WID;
Result.BOB_ORD_LEN = prsup.BOB_ORD_LEN;
Result.BOB_WGT_UNIT = prsup.BOB_WGT_UNIT;
Result.BOB_CUST_CD = prsup.BOB_CUST_CD;
Result.BOB_ENDUSE_CD = prsup.BOB_ENDUSE_CD;
Result.BOB_ORD_KND = prsup.BOB_ORD_KND;
Result.BOO_ORD_NO = prsup.BOO_ORD_NO;
Result.BOO_ORD_ITEM = prsup.BOO_ORD_ITEM;
Result.BOO_STDSPEC = prsup.BOO_STDSPEC;
Result.BOO_ORD_THK = prsup.BOO_ORD_THK;
Result.BOO_ORD_WID = prsup.BOO_ORD_WID;
Result.BOO_ORD_LEN = prsup.BOO_ORD_LEN;
Result.BOO_WGT_UNIT = prsup.BOO_WGT_UNIT;
Result.BOO_CUST_CD = prsup.BOO_CUST_CD;
Result.SUB_USER = prsup.SUB_USER;
Result.SUR_PRO_REM = prsup.SUR_PRO_REM;
Result.GP_PLT = prsup.GP_PLT;
Result.GP_PROD_TIME = prsup.GP_PROD_TIME;
Result.SUR_FIR_TIM = prsup.SUR_FIR_TIM;
Result.GP_WOO_RSN = prsup.GP_WOO_RSN;
Result.SUR_COM = prsup.SUR_COM;
Result.SUB_NUM = prsup.SUB_NUM;
Result.SUB_DIR = prsup.SUB_DIR;
Result.SUB_US_WID = prsup.SUB_US_WID;
Result.SUB_US_LEN = prsup.SUB_US_LEN;
Result.SUB_CUT_X = prsup.SUB_CUT_X;
Result.SUB_CUT_Y = prsup.SUB_CUT_Y;
Result.SUB_LOS_WGT = prsup.SUB_LOS_WGT;
Result.SUB_FOR = prsup.SUB_FOR;
Result.SUB_REM = prsup.SUB_REM;
Result.GP_CUR_INV = prsup.GP_CUR_INV;
Result.GP_TRIM_FL = prsup.GP_TRIM_FL;
Result.GP_SIZE_KND = prsup.GP_SIZE_KND;
Result.ORD_REM = prsup.ORD_REM;
Result.GP_UST_RLT_CD = prsup.GP_UST_RLT_CD;
Result.GP_GAS_FL = prsup.GP_GAS_FL;
Result.GP_CL_FL = prsup.GP_CL_FL;
Result.GP_HTM_CNT = prsup.GP_HTM_CNT;
Result.GP_STLGRD = prsup.GP_STLGRD;
Result.BOI_SURFACE_REQUESTS = prsup.BOI_SURFACE_REQUESTS;
Result.BOI_VESSEL_NO = prsup.BOI_VESSEL_NO;
Result.BOI_SIDEMARK = prsup.BOI_SIDEMARK;
Result.BOI_FACEPAINT = prsup.BOI_FACEPAINT;
Result.BOI_SEALMEMO = prsup.BOI_SEALMEMO;
Result.BOI_ORD_PROD_END_TIME = prsup.BOI_ORD_PROD_END_TIME;
Result.BOI_PROD_CD = prsup.BOI_PROD_CD;
Result.BOI_DOME_FL = prsup.BOI_DOME_FL;
Result.BOI_DEL_FR_DATE = prsup.BOI_DEL_TO_DATE;
Result.SUB_FULL = prsup.SUB_FULL;
Result.SUB_LACK_CON = prsup.SUB_LACK_CON;
//TODO:履历信息
Result.CON_DATE = DateTime.Now.ToString();
Result.CON_USER = "Auto";
Result.CON_RSL = delAddModel.STATE;
Result.PROD_GRD = prsup.PROD_GRD;
Result.CUR_INV = prsup.CUR_INV;
Result.LOC = prsup.LOC;
Result.EFF_RATE = prsup.EFF_RATE;
Result.PRICE_GRD = prsup.PRICE_GRD;
Result.STATE = delAddModel.STATE;
Result.SUB_LACK_NUM = prsup.SUB_LACK_NUM;
Result.ORD_WGT = prsup.ORD_WGT;
Result.SUB_LACK_WGT = prsup.SUB_LACK_WGT;
Result.SLAB_LACK_NUM = prsup.SLAB_LACK_NUM;
Result.LACK_NUM = prsup.LACK_NUM;
Result.SLAB_LACK_FLG = prsup.SLAB_LACK_FLG;
Result.Cutting_WGT = prsup.Cutting_WGT;
Result.STEEL_SCRAP_WGT = prsup.STEEL_SCRAP_WGT;
Result.SUB_PLATE_WGT = prsup.SUB_PLATE_WGT;
Result.CUTTING_LEN = prsup.CUTTING_LEN;
Result.CUTTING_WID = prsup.CUTTING_WID;
Result.CUTTING_THK = prsup.CUTTING_THK;
Result.IS_END = prsup.IS_END;
Result.SPLITTING = prsup.SPLITTING;
//Result.HAN_DATE = prsup.HAN_DATE;
//Result.HAN_USER = prsup.HAN_USER;
//Result.HAN_RSL = prsup.HAN_RSL;
//Result.HAN_CON = prsup.HAN_CON;
return Result;
}
/// <summary>
/// Null转换string
/// </summary>
/// <param name="obj">参数</param>
/// <returns></returns>
public static string ConverDataToString(string obj)
{
if (obj is null)
{
return string.Empty;
}
else
{
return obj;
}
}
/// <summary>
/// Null转换Decimal
/// </summary>
/// <param name="obj">参数</param>
/// <returns></returns>
public static decimal ConverDataToDecimal(object obj)
{
if (obj is null)
{
return 0;
}
else
{
return Convert.ToDecimal(obj);
}
}
public static int ConverDataToInt(object obj)
{
if (obj is null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// Export the data from datatable to CSV file
/// </summary>
/// <param name="grid"></param>
public static void ExportDataGridToCSV(IList<COM_DATA> gCOM_DATAs, string strFile)
{
//string strFile = "";
string strpath = CreateDirectoryOrFile();
string strFilePath = strpath + "\\" + strFile;
System.IO.FileStream fs = new FileStream(strFilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, new System.Text.UnicodeEncoding());
//Tabel header
//for (int i = 0; i < dt.Columns.Count; i++)
//{
// sw.Write(dt.Columns[i].ColumnName);
// sw.Write("\t");
//}
//钢板号
sw.Write("钢板号");
sw.Write("\t");
//订单号
sw.Write("订单号");
sw.Write("\t");
//订单明细号
sw.Write("订单明细号");
sw.Write("\t");
////完全替代未找到信息
sw.Write("完全替代未找到信息");
sw.Write("\t");
//部分替代未找到信息
sw.Write("部分替代未找到信息");
sw.Write("\t");
//标准
sw.Write("标准");
sw.Write("\t");
//百分率
sw.Write("百分率");
sw.Write("\t");
//热处理
sw.Write("热处理");
sw.Write("\t");
//探伤
sw.Write("探伤");
sw.Write("\t");
//切边
sw.Write("切边");
sw.Write("\t");
//物理特性
sw.Write("物理特性");
sw.Write("\t");
//化学特性
sw.Write("化学特性");
sw.Write("\t");
//仓库
sw.Write("仓库");
sw.Write("\t");
//厚度公差
sw.Write("厚度公差");
sw.Write("\t");
sw.WriteLine("");
foreach (COM_DATA item in gCOM_DATAs)
{
sw.Write(item.PLATE_NO);
sw.Write("\t");
sw.Write(item.ORD_NO);
sw.Write("\t");
sw.Write(item.ORD_ITEM);
sw.Write("\t");
sw.Write(item.NULL_FULL);
sw.Write("\t");
sw.Write(item.NULL_PART);
sw.Write("\t");
sw.Write(item.STDSPEC);
sw.Write("\t");
sw.Write(item.Rate);
sw.Write("\t");
sw.Write(item.Heat);
sw.Write("\t");
sw.Write(item.Flaw);
sw.Write("\t");
sw.Write(item.Cut);
sw.Write("\t");
sw.Write(item.Phy);
sw.Write("\t");
sw.Write(item.Chem);
sw.Write("\t");
sw.Write(item.War);
sw.Write("\t");
sw.Write(item.Thk);
sw.Write("\t");
sw.WriteLine("");
}
sw.Flush();
sw.Close();
}
/// <summary>
/// Delete special symbol
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string DelQuota(string str)
{
string result = str;
string[] strQuota = { "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "`", ";", "'", ",", ".", "/", ":", "/,", "<", ">", "?" };
for (int i = 0; i < strQuota.Length; i++)
{
if (result.IndexOf(strQuota[i]) > -1)
result = result.Replace(strQuota[i], "");
}
return result;
}
/// <summary>
/// 判断文件夹是否存在并创建文件夹
/// </summary>
/// <returns></returns>
public static string CreateDirectoryOrFile()
{
string path = "D:\\_NGProject";
string strPathDate = path + "\\" + DateTime.Now.ToString("yyyy-MM-dd");
if (!Directory.Exists(strPathDate))
{
Directory.CreateDirectory(strPathDate);
}
return strPathDate;
}
/// <summary>
/// 尺寸计算
/// </summary>
/// <param name="prorder"></param>
/// <returns></returns>
/// <summary>
/// 尺寸计算
/// </summary>
/// <param name="prorder"></param>
/// <returns></returns>
public static int SetSubNum(BP_ORDER_ITEM prorder)
{
int intRsl = prorder.SUB_LACK_NUM;
if (ConverDataToDecimal(prorder.SUB_LACK_WGT) < 0)
{
return 0;
}
//定尺
if (ConverDataToString(prorder.SIZE_KND) == "01")
{
intRsl = prorder.SUB_LACK_NUM;
}
//单定尺
if (ConverDataToString(prorder.SIZE_KND) == "02")
{
decimal decTHK = 0;
double douGRAVITY = 7.85;
try
{
GP_THK_ADD GTA = gltGPTHKADD.Where(p =>
ConverDataToString(p.ENDUSE_CD) == ConverDataToString(prorder.ENDUSE_CD)
&& ConverDataToDecimal(p.THK_MIN) < ConverDataToDecimal(prorder.ORD_THK)
&& ConverDataToDecimal(p.THK_MAX) > ConverDataToDecimal(prorder.ORD_THK)
&& ConverDataToDecimal(p.WID_MIN) < ConverDataToDecimal(prorder.ORD_WID)
&& ConverDataToDecimal(p.WID_MAX) > ConverDataToDecimal(prorder.ORD_WID)
&& ConverDataToString(p.USE_CD) == "Y").FirstOrDefault();
if (GTA != null)
{
decTHK = ConverDataToDecimal(GTA.THK_ADD);
}
}
catch (Exception)
{
}
try
{
QP_STD_HEAD QSH = gltQPSTDHEAD.Where(p =>
p.STDSPEC == prorder.STDSPEC
&& ConverDataToString(p.STDSPEC_CHR_CD) != "N").
OrderByDescending(p => p.STDSPEC_YY).FirstOrDefault();
if (QSH != null)
{
string strYY = ConverDataToString(QSH.STDSPEC_YY);
QP_STD_HEAD QSH_2 = gltQPSTDHEAD.Where(p =>
ConverDataToString(p.STDSPEC) == prorder.STDSPEC
&& ConverDataToString(p.STDSPEC_YY) == strYY
&& ConverDataToString(p.STDSPEC_CHR_CD) != "N").FirstOrDefault();
if (QSH_2 != null)
{
try
{
douGRAVITY = Convert.ToDouble(QSH_2.GRAVITY);
}
catch (Exception)
{
}
}
}
}
catch (Exception)
{
}
if (!(douGRAVITY >= 4 && douGRAVITY <= 10))
{
douGRAVITY = 7.85;
}
intRsl = ConverDataToInt(Math.Floor(ConverDataToDecimal(prorder.SUB_LACK_WGT)
/ Math.Round(ConverDataToDecimal((decTHK + ConverDataToDecimal(prorder.ORD_THK))
* ConverDataToDecimal(prorder.ORD_WID)
* ConverDataToDecimal(prorder.ORD_LEN)
* ConverDataToDecimal(douGRAVITY) / 1000000000), 3)));
}
return intRsl;
}
public static int GetSubNum(BP_ORDER_ITEM prorder)
{
int intRsl = 0;
//gltUnConSur
List<SUPERSEDE> ltSup =
gltUnConSur.Where(p => p.ORD_NO == prorder.ORD_NO
&& p.ORD_ITEM == prorder.ORD_ITEM).ToList();
if (ltSup.Count > 0)
{
foreach (SUPERSEDE itemSup in ltSup)
{
intRsl += ConverDataToInt(itemSup.SUB_NUM);
}
}
return intRsl;
}
#endregion
}
}